如何在不存储当前四元数和不使用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);
答案 0 :(得分:0)
反转四元数的方向并将其初始化为当前相机的工作原理:
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(this.orbitControls.target).sub(_c).normalize();
var toQuaternion = new THREE.Quaternion();
toQuaternion.setFromUnitVectors(_t0, _t1);
toQuaternion.multiply(this.camera.quaternion);