three.js补间对象到摄像头的前面 [英] three.js tween object to front of camera

查看:120
本文介绍了three.js补间对象到摄像头的前面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个物体正在使用WestLangleys回答另一个问题(几乎)很好地过渡到相机的前面:

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)

我正在努力的下一部分是使对象与相机保持一定距离(调整z = -10无效),因为完成补间时它会消失(太近了)

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 is1。

Camera.near is 1.

有什么想法吗?

推荐答案

var pLocal = new THREE.Vector3( 0, 0, - 10 );

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

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

这篇关于three.js补间对象到摄像头的前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆