Vector3 project with current camera (avoid 1 frame delay)

I have some custom panning/zooming logic in my project, so I can’t use attachControl on the camera for panning. I still need the GUI moveToVector3 method though, which is internally based on Vector3.Project:

It works fine actually, but there is always a lag of one frame. First of all I had to do some contortions to get it work after loading (on the first frame) and also my GUI lags behind a little (just 1 frame, so it’s not that bad but still I’d like to avoid it).

I tried doing it with TransformNodes and linkWithMesh, but that was very glitchy (I generate linkOffsets on the fly, and they were randomly ignored), although a little smoother when it worked. I can make a PG on request, but it might take a while. From a cursory look at the source code, I can’t quite understand how linkWithMesh avoids the 1 frame lag or why there would be glitches.

Is there any other way to remove the 1 frame delay? TransformNodes are rather messy for my use case anyway.

When do you call the moveToVector3? To avoid any lag, you can do it on the scene.onAfterRenderObservable

I’ll try. Could make a difference. Currently I am doing it in a onDragObservable callback.