旋转方向矢量 (three.js)
Direction vector to a rotation (three.js)
我正在尝试旋转行星表面上的箭头以使其朝向行进方向。我可以从表面法线得到方向向量和向上向量。我将如何将其变成四元数以用于我的箭头旋转。我正在使用 three.js,所以他们提供的任何我可以使用的建议方法都会很有用。干杯。
我目前掌握的信息。
var upVector = new THREE.Vector3();
upVector.subVectors( new THREE.Vector3(0,0,0), lastVec );
var dirVector = new THREE.Vector3();
upVector.subVectors( lastVec, destVec );
var sideVector = new THREE.Vector3();
sideVector.crossVectors( dirVector, upVector );
var newUp = new THREE.Vector3();
newUp.crossVectors( dirVector, sideVector );
尝试(使用 myDirectionVector
):
var mx = new THREE.Matrix4().lookAt(myDirectionVector,new THREE.Vector3(0,0,0),new THREE.Vector3(0,1,0));
var qt = new THREE.Quaternion().setFromRotationMatrix(mx);
我正在尝试旋转行星表面上的箭头以使其朝向行进方向。我可以从表面法线得到方向向量和向上向量。我将如何将其变成四元数以用于我的箭头旋转。我正在使用 three.js,所以他们提供的任何我可以使用的建议方法都会很有用。干杯。
我目前掌握的信息。
var upVector = new THREE.Vector3();
upVector.subVectors( new THREE.Vector3(0,0,0), lastVec );
var dirVector = new THREE.Vector3();
upVector.subVectors( lastVec, destVec );
var sideVector = new THREE.Vector3();
sideVector.crossVectors( dirVector, upVector );
var newUp = new THREE.Vector3();
newUp.crossVectors( dirVector, sideVector );
尝试(使用 myDirectionVector
):
var mx = new THREE.Matrix4().lookAt(myDirectionVector,new THREE.Vector3(0,0,0),new THREE.Vector3(0,1,0));
var qt = new THREE.Quaternion().setFromRotationMatrix(mx);