I’m seeing an issue with BoundingBoxGizmo illustrated in this PG https://playground.babylonjs.com/#73XBJM#5
In the PG, I have disabled camera rotation and set the camera to pan using the left mouse button. This works until I select the box which attaches the gizmo. After attaching the gizmo, the camera panning button is reset.
I have traced the problem to line 395 in BaseSixDofDragBehavior (Babylon.js/baseSixDofDragBehavior.ts at b24d65a53e12cc138495ae64cbacfbd0b126d83d · BabylonJS/Babylon.js · GitHub) where it reattaches the camera controls with only the preventDefault arg specified, so the panningMouseButton is reset to 2.
if (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera) {
this._pointerCamera.attachControl(true);
this._attachedToElement = false;
}
I believe that BaseSixDofDragBehavior should do the same thing DragBehavior does, which is to preserve the original values if the camera is an ArcRotateCamera
if (this._scene.activeCamera.getClassName() === "ArcRotateCamera") {
const arcRotateCamera = this._scene.activeCamera as ArcRotateCamera;
arcRotateCamera.attachControl(
arcRotateCamera.inputs ? arcRotateCamera.inputs.noPreventDefault : true,
arcRotateCamera._useCtrlForPanning,
arcRotateCamera._panningMouseButton
);
} else {
this._scene.activeCamera.attachControl(this._scene.activeCamera.inputs ? this._scene.activeCamera.inputs.noPreventDefault : true);
}
this._attachedToElement = false;
Note that in my case (not represented in the PG), I don’t want the BB Gizmo to ever allow moving position so I disable movement and attach PointerDragBehavior to the mesh. For some reason, when I attach the gizmo to the third mesh, the SixDofDragBehavior fires on pointer up instead of the DragBehavior and resets my panning buttons. I don’t know why this happens (I suspect a race condition of some sort) but I figure in any case, the solution is to make sure BaseSixDofDragBehavior does the right thing.
Happy to submit a PR for this if the team agrees this is unintended behavior and with my solution.