2012-02-09 46 views
1

我用three.js製作一個圖形,我想用THREE.Line連接節點。 用鼠標移動其中一個節點後,必須重新創建帶有節點新坐​​標的邊(THREE.Line)。我怎麼做到的?Three.js重新定義THREE.Line ..等

我的代碼不更新的觀點:

function render(){ 

    newEdge.vertices.push(new THREE.Vertex(inNode.position)); 
    newEdge.vertices.push(new THREE.Vertex(outNode.position)); 

    var newLine = new THREE.Line(newEdge, new THREE.LineBasicMaterial({ 
     color: 0xff0000, 
     opacity: 0.9 
    })); 

    scene.objects[edgePos] = newLine; 

    renderer.render(scene, camera); 

} 

非常感謝任何建議!

回答

2

當你直接改變幾何圖形時,渲染循環將不會拾取它。您需要用newEdge.__dirtyVertices = true;將頂點標記爲髒。您可能還需要newEdge.dynamic = true;。看第9節here