所以我正在尝试根据在场景中单击的对象使用补间来补间相机的 fov,效果很好,但现在我想要它做的是让相机将焦点切换到被点击,这不起作用。这是我的点击代码:
function onDocumentMouseDown( event ) {
event.preventDefault();
var vector = new THREE.Vector3( ( event.clientX / window.innerWidth ) * 2 - 1, - ( event.clientY / window.innerHeight ) * 2 + 1, 0.5 );
var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
var intersects = ray.intersectObjects( objects );
if ( intersects.length > 0 ) { //We've clicked a certain object
camTarget = intersects[0].object.position; //HERE'S THE VECTOR3 I WANT TO LOOK AT
camTween.start();
}
}
以及我的补间/相机运动代码:
var camUpdate = function(){
camera.fov = currentFov.fov; //WORKING
camera.lookAt(camTarget); //NOT WORKING
camera.updateProjectionMatrix();
}
var currentFov = { fov: camera.fov };
TWEEN.removeAll();
camTween = new TWEEN.Tween(currentFov).to({fov: +zoomInFov},tweenTime).easing(camEase).onUpdate(camUpdate);
相机正在适当地补间视野,但它似乎始终指向它始终指向的同一方向,而不是切换到 lookAt 命令中指定的“camTarget”向量。