2014-10-02 68 views
0

有沒有辦法將Three.js網格的頂點分開?基本上,我想用鼠標輸入撕裂並撕開3D物體。最近,我爲this web app寫了一個GLSL頂點着色器,它將網格的頂點替換爲視頻的亮度。如何在Three.js中分離網格的頂點?

但我很茫然,我該如何選擇網格的頂點,並將其邊緣與最近的鄰居區分開來,而頂點着色器也正在取代該對象。

+1

你想這樣做,CPU側之前渲染?是http://threejs.org/examples/js/modifiers/ExplodeModifier.js你在找什麼? – WestLangley 2014-10-02 08:42:57

回答

0

選擇所有verticles即時通訊使用的簡單羅列:

var geometry = new THREE.CubeGeometry(30, 30, 30 ,1,1,1); 
for (var i = 0; i < geometry.vertices.length; i ++) { 
      var vertices = []; 
      for (var v = 0; v < geometry.vertices.length; v ++) { 
      vertices.push(geometry.vertices[ v ].clone()); 
      if (v === i) { 
       //getting only Z axis: 
       //vertices[ vertices.length - 1 ].x *= 2; 
       //vertices[ vertices.length - 1 ].y *= 2; 
       vertices[ vertices.length - 1 ].z *= 2; 
      } 
      } 
      geometry.morphTargets.push({ name: "target" + i, vertices: vertices }); 
     } 
    console.log(geometry.vertices); 


//Updating the morphs with new values. We only want to influence one side of the cube 
     mesh.morphTargetInfluences[0] = 1 
     mesh.morphTargetInfluences[2] = 1 
     mesh.morphTargetInfluences[5] = 1 
     mesh.morphTargetInfluences[7] = 1