javascript - Tweening Object3D towards camera in Three.js - this works, need to set new screen position -
i have code tweens object towards camera , fits half screen
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 direction camera facing var target = plocal.applymatrix4( camera.matrixworld ); //tween object towards camera var tweenmove = new tween.tween(object.position).to(target, 1500).easing(tween.easing.cubic.inout);
the next thing need able able move either left or up, other ui on screen , responsive element.
i.e. move left 3rd, or top third. needs still square onto camera.
i've tried changing plocal value (1, 0, - dist) rotates object when tweens up.
any ideas how can add functionality?
solved adding new position left of camera
Comments
Post a Comment