As I begin the program, my camera is focused on the point (0,0,0)
. The z-coordinate of the camera increases as I scroll downward. Once it reaches 160, I aim to rotate the camera towards the point (0,0,300)
where an object is positioned. I initially tried using cameraLookAt()
, but found the transition too sudden. Seeking a smoother effect, I delved into TWEEN.js
for a solution. However, my implementation doesn't seem to be producing the desired outcome.
I could use some guidance on this issue.
if (camera.position.z > 160) {
var startRotation = new THREE.Euler().copy( camera.rotation );
var endRotation = new THREE.Euler().copy( 0, 0, 300 );
var tween = new TWEEN.Tween( startRotation ).to( { rotation: endRotation }, 2000 )
tween.onUpdate(() => {
camera.lookAt(startRotation)
})
tween.start()
}