在不存储当前四元数和使用lookAt的情况下,如何计算相机的目标四元数(稍后用于slerp)?
这给了我想要的结果(即四元数):
// newTarget is Vector3
let fromQuaternion = (new THREE.Quaternion()).copy(this.camera.quaternion);
this.camera.lookAt(newTarget);
let toQuaternion = (new THREE.Quaternion()).copy(this.camera.quaternion);
this.camera.quaternion.set(fromQuaternion.x, fromQuaternion.y, fromQuaternion.z, fromQuaternion.w);
我试图通过以下方式避免上述情况,但这不起作用(得到更大的四元数):
// currentTarget, newTarget are Vector3
var _c = (new THREE.Vector3()).copy(this.camera.position);
var _t0 = (new THREE.Vector3()).copy(currentTarget).sub(_c).normalize();
var _t1 = (new THREE.Vector3()).copy(newTarget).sub(_c).normalize();
var toQuaternion = new THREE.Quaternion();
toQuaternion.setFromUnitVectors(_t1, _t0);