Javascript 使用threejs动态更新平面/立方体顶点-更新矩阵时出现问题
我有一个平面,它是使用threejs添加到场景中的。我正在使用用户界面控件调整位置和旋转,如果位置或旋转发生变化,我将运行以下代码以获取更新的平面/立方体顶点和矩阵值:Javascript 使用threejs动态更新平面/立方体顶点-更新矩阵时出现问题,javascript,three.js,Javascript,Three.js,我有一个平面,它是使用threejs添加到场景中的。我正在使用用户界面控件调整位置和旋转,如果位置或旋转发生变化,我将运行以下代码以获取更新的平面/立方体顶点和矩阵值: plane.updateMatrixWorld(); plane.updateMatrix(); plane.geometry.applyMatrix( plane.matrix ); plane.matrix.identity(); console.log(plane.matrix); // using this to ge
plane.updateMatrixWorld();
plane.updateMatrix();
plane.geometry.applyMatrix( plane.matrix );
plane.matrix.identity();
console.log(plane.matrix); // using this to get matrix values
console.log(plane.geometry.vertices); //using this to get plane vertices.
当我运行上述代码时,场景中平面/立方体/网格的位置偏移会遇到问题
尝试添加以下代码以使其对顶点进行动态更新,但无效:
plane.verticesNeedUpdate = true;
plane.elementsNeedUpdate = true;
plane.morphTargetsNeedUpdate = true;
plane.uvsNeedUpdate = true;
plane.normalsNeedUpdate = true;
plane.colorsNeedUpdate = true;
plane.tangentsNeedUpdate = true;
是的,当代码下方的位置/旋转调用发生变化时,得到了解决方案。
向量向量;
函数updateVertices(){
plane.updateMatrixWorld();
log(“平面顶点:”);
对于(i=0;iNo,不相关。谢谢。从帖子中删除了php。我意识到这个问题几乎是一年前提出的,但我想知道你是否找到了答案?我对ThreeJs也有类似的问题。当我更新平面顶点时,我希望平面上对象的物理也会更新。使用Physijs作为我的物理引擎是的,得到了解决方案,当位置/旋转发生变化时,调用此函数.var plane_vector;函数updateVertices(){plane.updateMatrix();console.log(“平面顶点”);for(i=0;i