three.js tween object to front of camera

2019-07-22 12:49发布

I've got an object that is tweening (almost) nicely to the front of the camera using WestLangleys answer to another question:

    var pLocal = new THREE.Vector3( 0, 0, -10 );
    var pWorld = pLocal.applyMatrix4( camera.matrixWorld );
    var target = pWorld.sub( camera.position ).normalize();

    var tweenMove = new TWEEN.Tween(object.position).to(target, 2000)

The next part I'm struggling with is to get the object to remain a certain distance from the camera (adjusting the z = -10 has no effect), as when it finishes the tween it disappears (too close to camera).

Camera.near is 1.

Any ideas?

1条回答
聊天终结者
2楼-- · 2019-07-22 13:32
var pLocal = new THREE.Vector3( 0, 0, - 10 );

var target = pLocal.applyMatrix4( camera.matrixWorld );

var tweenMove = new TWEEN.Tween( object.position ).to( target, 2000 );
查看更多
登录 后发表回答