Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vector Three.js如何查找对象的世界方向向量';什么是局部上向量?_Vector_Three.js_Rotation - Fatal编程技术网

Vector Three.js如何查找对象的世界方向向量';什么是局部上向量?

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

我的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.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