如何获取对象顶点的世界位置改变位置

时间:2014-09-12 16:54:41

标签: three.js

我搜索了一下,看看是否有人有喜欢的jsbin来展示这个问题的一个例子,所以请原谅,如果这似乎被问及。

使用r67& R68 我有一个简单的THREE.Line命名为激光'我以某种方式移动,在这个例子中,我通过鼠标移动和旋转它。无论激光在哪里,我想要获得其顶点[0,1]的世界绳索,所以稍后我可以将光线施法者附加到那些世界绳索上。

我认为我只是错过了一个核心功能,我将通过源代码挖掘并尝试查找。希望这可以在将来更新jsbin时帮助其他人。

现在我只是得到它的起始位置0,20尽管有矩阵更新等。 在jsbin中,我在网上的其他帖子中留下了其他一些注释掉的代码。

更新:可能已经弄清楚了!

function render(){

// test finding the lasers vertices
laser.updateMatrixWorld(true);

// move laser
laser.rotation.z = MousePosition.x /50;
laser.position.x = MousePosition.x;
laser.position.y = MousePosition.y;

// which of these is needed?
laser.matrixWorldNeedsUpdate = true;
lasergeo.verticesNeedUpdate = true;

// --> this line looks to work
point1 = laser.localToWorld( lasergeo.vertices[1].clone() );
// console.log("point1", point1);
}

http://jsbin.com/yuqocemigacu/1/edit?html,js,console,output

新: http://jsbin.com/yonaquzufeje/1/edit?html,js,output

在新版本中,刷新更新会跳过连接,但这是另一个问题。 离开这个开放的原因,我不知道我是否有正确的方法,可以进行900矩阵计算,但还不知道。

0 个答案:

没有答案