Three.js重新定义了THREE.Line..etc

时间:2012-02-09 19:16:49

标签: webgl three.js

我用three.js创建一个图表,我想用THREE.Line连接节点。 用鼠标移动其中一个节点后,必须用节点新坐标重新创建边(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);

}

非常感谢任何建议!

1 个答案:

答案 0 :(得分:2)

当您直接更改几何体时,渲染循环将不会拾取它。您需要使用newEdge.__dirtyVertices = true;将顶点标记为脏。您可能还需要newEdge.dynamic = true;。请看第9节here