我正在尝试遵循本教程:
http://learningthreejs.com/blog/2011/08/17/tweenjs-for-smooth-animation/
在three.js中补间相机的视野,但该值似乎没有更新。知道我做错了什么吗?这是我的代码:
var fov = 70;
var zoomFov = 100;
function onDocumentMouseUp( event ) {
castRay();
}
function castRay(){
var vector = new THREE.Vector3( ( event.clientX / window.innerWidth ) * 2 - 1, - ( event.clientY / window.innerHeight ) * 2 + 1, 0.5 );
projector.unprojectVector( vector, camera );
var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
var intersects = ray.intersectObjects( objects );
if ( intersects.length > 0 ) {
var camObj = intersects[0].object;
camTween = new TWEEN.Tween( fov ).to( zoomFov,500 ).easing( camEase );
camTween.start();
camTween.onUpdate(function(){
updateCam(fov);
});
}
}
function updateCam(fov){
console.log(fov); //MH - outputs 70 every time
}
function animate() {
requestAnimationFrame( animate );
render();
TWEEN.update();
}