Cursor zoom functioanly

I am using code from a playground solution to zoom in on cursor, using orthographic camera, but cannot seem to fix the first zoom event, it zooms further in than expected but all the following zooms out/in work fine. Could someone have a little look and point me to where am going wrong please?

Here is a playground. https://playground.babylonjs.com/#88CB6A#55

Also there is a issue after panning it seems to rotate from a different point, any ideas in relation to that problem also, or is that how panning is ment to work?

Many Thanks

pinging @PolygonalSun

1 Like

Hey @jcharnley, lemme take a look and see what’s going on.

1 Like

Thank you. Let me know if you need anymore details

I have a question, is there any reason why the active camera’s mode is being switched to Orthographic whenever the an event like a WheelEvent is being handled?

Based on what I’m seeing, the reason that there is such a drastic initial change is that your camera is being swapped to an Orthographic mode during a WheelEvent, which is handled differently from the standard Perspective camera.

It also looks like you’re creating a camera and then overwriting that camera in your promise. Unless there’s a specific reason for it, I’d recommend just creating and initializing your camera in the createScene function.

By any chance, do you have the link for the original solution PG that you pulled code from?

Sorry about the delay and thanks for your reply. The only reason we was trying to switch to Orthaographic was to allow for crusor zoom. The original PG taken from is https://playground.babylonjs.com/#EBPQH9#28

The specific reason I override the default camera with another default camera in the promise is that without it, I cannot position the model or camera in the middle of the model. ive tried setPivotPoint on the meshes and also bakeCurrentTransformIntoVertices().

If you could give us some pointers on the central position that would be great also.

I’ve also found this to allow for cursor zoom with arc cam, do you think this would be a safer option?


pinging @PolygonalSun
Thanks
Jason

ive fixed the zoom problem but the model does not load in the right position, https://playground.babylonjs.com/#88CB6A#57

Can someone help with that, i’ve been trying to rewrite the code all day but no luck and this way seems to work but its offset on load