Delay when moving camera using Gsap

I’ve made showroom prototype. When user clicks to particular point of the floor camera moves to the the given point. I’ve moving camera using gsap 3 where it uses requestAnimationFrame api. But I got some lags and delays when camera moves in 3d space. I can’t fix this issue. Can anybody help?

Here’s my codepen

gsap.to(camera.position, 2, {x: intersect.point.x, z: intersect.point.z, ease:Power1.easeIn, 
 onUpdate: () => {
        camera.updateProjectionMatrix();
 }} );

however, i’ve update camera projection matrix on every camera position update

Hi!
You render your scene when you do something with your mouse (mousedown, mousemove).

Maybe makes sense to remove all render(); from mouse events, and add this code at the end of init():

  renderer.setAnimationLoop(() => {
    render();
  });
2 Likes