Javascript Tweening Object3D在Three.js中指向相机-此功能正常,需要设置新的屏幕位置
我有一些代码,可以把一个物体和相机连接起来,并且可以放在半个屏幕上Javascript Tweening Object3D在Three.js中指向相机-此功能正常,需要设置新的屏幕位置,javascript,3d,three.js,Javascript,3d,Three.js,我有一些代码,可以把一个物体和相机连接起来,并且可以放在半个屏幕上 var vFOV = camera.fov * Math.PI / 180; var ratio = 2 * Math.tan( vFOV / 2 ); var screen = ratio * (window.innerWidth * 0.6 / window.innerHeight * 0.6) ; var size = getCompoundBoundingBox( object ).m
var vFOV = camera.fov * Math.PI / 180;
var ratio = 2 * Math.tan( vFOV / 2 );
var screen = ratio * (window.innerWidth * 0.6 / window.innerHeight * 0.6) ;
var size = getCompoundBoundingBox( object ).max.y;
var width = getCompoundBoundingBox( object ).max.x;
var dist = (size/screen) * (object.scale.x * 2);
//get final position in front of camera
var pLocal = new THREE.Vector3( 0, 0, -dist );
//apply the direction the camera is facing
var target = pLocal.applyMatrix4( camera.matrixWorld );
//tween the object towards the camera
var tweenMove = new TWEEN.Tween(object.position).to(target, 1500).easing(TWEEN.Easing.Cubic.InOut);
我需要做的下一件事是能够将其向左或向上移动,以用于屏幕上的其他UI和响应元素
i、 e.将其移动到左三分之一或上三分之一。它还需要与摄像机保持垂直
我尝试过将pLocal值更改为(1,0,-dist)之类的值,但这只是在对象变为二者之间时旋转对象
有什么想法我可以添加该功能吗 通过在相机左侧添加新的外观位置来解决