I have a question about three.js + tween + lookat Here's an example: https://intera3d.ru/tween_test/tokyo.html I want that when the button "TWEEN" is pressed the camera looked at the 3D model from above.
And so it happens, but at the end there is an unexpected turn of the camera / 3D model.
How can you avoid this?
Here is the "tween" function code:
function TWEEN_begin_CAMERA_1() {
const tweenCamera1 = new TWEEN.Tween(
{x: camera.position.x, y: camera.position.y, z: camera.position.z,
lookAtX: 0, lookAtY: 0, lookAtZ: 0}
)
.to( {x: 0, y: 20, z: 0, lookAtX: 0, lookAtY: 0, lookAtZ: 0}, 1000 )
const updateCamera = function (object, elapsed) {
camera.position.set(object.x, object.y, object.z);
camera.lookAt(new THREE.Vector3(object.lookAtX, object.lookAtY, object.lookAtZ))
}
tweenCamera1.onUpdate(updateCamera)
tweenCamera1.start()
}
Thanks a lot in advance for your help!
Here is an example with
THREE.Spherical, that doesn't allow camera to be set atx=0 andz=0 (at anyy), see in the docs what the method.makeSafe()does: