Dynamically freezing scene, disabling rotation on mouse click

good day, I would like to have a toggle button that enables or disables the capability of rotating the scene when clicking+dragging the mouse (or with touch); I need to be able to freeze the scene to then do some picking on the mesh; what command would allow me to disable the click+drag mouse thing and later re-enable it again? (im using an arcrotatecamera),
thank you :slight_smile:

maybe this does it
camera.inputs.attached[‘pointers’].detachControl(canvas);

is it possible to just isolate the rotation event only and not all of them?

Hi @javismiles - Adding @PolygonalSun who did a nice demo on how to use cameras and who may have an idea.

2 Likes

Hey @javismiles,
My initial thoughts on this are that you could set up a listener to set your camera’s angularSensibility to Infinity on a keyup event and set it to a reasonable value on a second keyup event (default is 1000). Here’s a PG demonstrating this: Toggle Rotation with Key Press | Babylon.js Playground

2 Likes

You track if there are any interactions to the scene, and then start watching the camera velocities. Once the velocities are within a certain tolerance disable the render.

If the user interact with the scene with the mouse turn the render back on and start watching the values again.

I have seen this method do really well before in the past.

2 Likes

@PolygonalSun @Pryme8 @thomlucc thank you all for your great help, this community is really awesome. These are all great suggestions, I specially like the one shown at https://playground.babylonjs.com/#2VJS0B#1, I think for now I may just disable and re-enable all pointer events but if I decide to restrict just the rotation I will then implement that solution, thank you for the help :wink:

1 Like