How to make the right click behave as if no orbit controls exist?
yoosif0 opened this issue · comments
Question in title
Sorry, I don't understand your situation.
I think you don't need any care of it if you don't use it...
@yomotsu
The issue is that typescript enforces me to add the "right" prop to the "mouseButtons" object. Even when I set the right prop to "CameraControls.ACTION.NONE", I am still not able to use right click appropriately
mouseButtons={{
left: CameraControls.ACTION.TRUCK,
right: CameraControls.ACTION.NONE,
middle: CameraControls.ACTION.ZOOM,
wheel: CameraControls.ACTION.ZOOM,
}}
how about calling cameraControls.dispose()
to detach all events of cameraControls instance?
If I called "cameraControls.dispose()", would I need to manually add an event listener to "left", "middle", and "wheel"?
Check the documentation for more details!
https://github.com/yomotsu/camera-controls#dispose
https://github.com/yomotsu/camera-controls#disconnect
I checked the documentation and I still believe that "CameraControls.ACTION.NONE" for the right click button should allow default action
Let me get this straight.
What you mean is: you would like to enable the context menu if you set mouseButtons.right = CameraControls.ACTION.NONE
?
camera-controls/src/CameraControls.ts
Lines 872 to 878 in c457032
- If you want to remove all event listeners which attached by cameraControls, use
disconnect()
. - If you want to destroy cameraControls entirely, use
dispose()
. - If you want to disable event listeners temporarily, set
cameraControls.enabled = false
.
I tested the below, but it cause some problems.
const onContextMenu = ( event: Event ): void => {
if ( ! this._enabled || this.mouseButtons.right === CameraControls.ACTION.NONE ) return;
event.preventDefault();
};
contextmenu event is fired right after mouse down event, and contextmenu will break mouse dragging.
thus, we can't change the above code.
What you mean is: you would like to enable the context menu if you set mouseButtons.right = CameraControls.ACTION.NONE?
Yes
I've made a PR for it #362
@yomotsu thank you so much
available with v2.2.1!
let me close this issue as complicated.