I have implemented the ability to focus on different models by double clicking on them:
function ondblclick(event){
pointer.x = ( event.clientX / window.innerWidth ) * 2 - 1;
pointer.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
raycaster.setFromCamera( pointer, camera );
const intersects = raycaster.intersectObjects( scene.children );
if(intersects.length > 0) {
var pos = new THREE.Vector3();
intersects[0].object.getWorldPosition(pos);
controls.target = pos;
}
}
It work fine, but the movement is instant so it looks and feel bad. What I want is for camera to slowly fly to the new position, instead of teleporting there. I know about the existence of lerp, but I’m very confused about how to use it.