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.
For anyone who finds this when dealing with a 1-frame delay on screen space projection, it’s possible Ontropy meant to say onBeforeCameraRenderObservable in the previous message. If you don’t want to rearrange your code into a different callback function, another way to remove the 1 frame delay is by calling scene.updateTransformMatrix() before doing your Vector3.Project