Is there a way to create the same effect as the lookAt function, but with interpolation. I’ve been able to use the damp function in Math Utils to interpolate between vectors, and I imagine that I would need slerp, but I’m just wondering how to get this done with the look at functionality. The effect I want to create is the camera can be at any arbitrary position, and I want a glb to smoothly rotate and animate towards the camera and “lookAt” the camera when a button is clicked. The glb will stay looking at that vector position even when the camera moves away. So I don’t want to invoke “lookAt” and the glb stay locked on and looking at the camera forever, I want store the cameras current position and rotate the glb to look at that position to until the function is invoked again in which case it will just look at the cameras new position smoothly and not snap into place. Any and all help is much appreciated thank you!
If you want to lookAt smoothly, you can’t just do that by just invoking a function, you need to use the animation loop. You’d have to do something like this:
yourObject
yourTarget
function animationLoop() {
(...)
const target = yourObject.clone()
target.lookAt(yourTarget)
yourObject.quaternion.slerp(target.quaternion, 0.1)
(...)
requestAnimationFrame(animationLoop)
}
animationLoop()
1 Like