Using Tween To Animate A Camera
I'm trying to ease camera rotation to look at a selected object in a graph. So far, I have fourd.render_loop.push(() => TWEEN.update()); fourd.intersect_callback = function(ve
Solution 1:
You can tween the camera's orientation (or rotation), but to do so, it is simplest to tween the camera's quaternion, instead.
var dummy = newTHREE.Camera(); // create these once and reusevar qStart = newTHREE.Quaternion();
var qEnd = newTHREE.Quaternion();
. . .
// tweenvar time = { t: 0 };
newTWEEN.Tween( time )
.to( { t : 1 }, 1000 )
.easing( TWEEN.Easing.Linear.None )
.onStart( function() {
dummy.position.copy( camera.position );
dummy.lookAt( point ); // point is your target Vector3
qStart.copy( camera.quaternion );
qEnd.copy( dummy.quaternion );
} )
.onUpdate( function() {
THREE.Quaternion.slerp( qStart, qEnd, camera.quaternion, time.t );
} )
.onComplete( function() {
camera.quaternion.copy( qEnd ); // so it is exact
} )
.start();
three.js r.88
Post a Comment for "Using Tween To Animate A Camera"