Vector Three.js如何查找对象的世界方向向量';什么是局部上向量?
我的object3D有一个上方向向量(0,1,0)。object3D围绕偏航、俯仰和滚动移动其原点 我的问题: 如何找到在世界坐标中显示object3D上方向向量的向量 编码上下文的示例:-Vector Three.js如何查找对象的世界方向向量';什么是局部上向量?,vector,three.js,rotation,Vector,Three.js,Rotation,我的object3D有一个上方向向量(0,1,0)。object3D围绕偏航、俯仰和滚动移动其原点 我的问题: 如何找到在世界坐标中显示object3D上方向向量的向量 编码上下文的示例:- var v1 = new THREE.Vector3(); v1.add( givenObject3D.up ); // now v1 = (0,1,0) givenObject3D.updateMatrixWorld(); FunctionXXX (v1, givenObject3D.matrixW
var v1 = new THREE.Vector3();
v1.add( givenObject3D.up ); // now v1 = (0,1,0)
givenObject3D.updateMatrixWorld();
FunctionXXX (v1, givenObject3D.matrixWorld );
//... now v1 is a vector in world coordinates
//... v1 points in the same direction as the givenObject3D's up vector.
v1.normalize();
您需要获取对象的
向上
向量的世界方向。为此,对应用于对象的up
向量应用相同的旋转
如果对象直接是场景的子对象,则可以执行以下操作:
var v1 = new THREE.Vector3(); // create once and reuse it
...
v1.copy( object.up ).applyQuaternion( object.quaternion );
如果对象具有旋转的父对象,则需要使用以下模式:
var v1 = new THREE.Vector3(); // create once and reuse it
var worldQuaternion = new THREE.Quaternion(); // create once and reuse it
...
object.getWorldQuaternion( worldQuaternion );
v1.copy( object.up ).applyQuaternion( worldQuaternion );
3.js r.74