Conflict between camera interaction and picking events

I’m designing an interface that uses an ArcRotateCamera and also includes picking. I’m having problems with picking events occurring during camera interaction, and I’m wondering how to prevent them.

Here’s an example of the problem:
https://playground.babylonjs.com/index.html#1A3M5C#57

As I move the camera around, constant picking will print the name of the picked mesh to console. If I release the pointer on top of a mesh, sometimes the picking callback will get called (though not always).

Is there a way to know that the camera interaction is currently active so that I can ignore the pick events?

Conversely, if I give up and make the interface modal (user selects picking mode or camera mode), is there a way to just disable the camera interaction? Do I just attach and detach?

Thanks.

Hey!
so yes you can simply call attach/detach to disable camera control over the inputs.
To your initial problem I would use pointerDown instead of pointerPick so you will be sure that the event is initiated from the mesh

Thanks! I looked at some of the gizmo examples, and it seems that they correctly prevent gizmo interaction events from propagating to the camera inappropriately.

How do they do that?

I guess I’m looking for something like “preventDefault()” in the DOM, except in the scene.

Thanks.

The gizmo are running inside the UtilityLayer. Maybe it is an option for your use case?
https://doc.babylonjs.com/how_to/utilitylayerrenderer

1 Like