diff --git a/node_modules/three/examples/jsm/controls/OrbitControls.js b/node_modules/three/examples/jsm/controls/OrbitControls.js index f29e7fe..0ef636b 100644 --- a/node_modules/three/examples/jsm/controls/OrbitControls.js +++ b/node_modules/three/examples/jsm/controls/OrbitControls.js @@ -113,6 +113,25 @@ class OrbitControls extends EventDispatcher { // public methods // + this.interactionGuards = { + pan: { + description: 'Right click + Shift + drag or middle click + drag', + callback: (e) => e.button === 2 && !e.ctrlKey, + }, + zoom: { + description: 'Scroll wheel or Right click + Ctrl + drag', + dragCallback: (e) => e.button === 2 && e.ctrlKey, + scrollCallback: () => true, + }, + rotate: { + description: 'Right click + drag', + callback: (e) => e.button === 0, + }, + } + this.setMouseGuards = (interactionGuards) => { + this.interactionGuards = interactionGuards + } + this.getPolarAngle = function () { return spherical.phi; @@ -1057,92 +1076,21 @@ class OrbitControls extends EventDispatcher { function onMouseDown( event ) { - let mouseAction; - - switch ( event.button ) { - - case 0: - - mouseAction = scope.mouseButtons.LEFT; - break; - - case 1: - - mouseAction = scope.mouseButtons.MIDDLE; - break; - - case 2: - - mouseAction = scope.mouseButtons.RIGHT; - break; - - default: - - mouseAction = - 1; - - } - - switch ( mouseAction ) { - - case MOUSE.DOLLY: - - if ( scope.enableZoom === false ) return; - - handleMouseDownDolly( event ); - - state = STATE.DOLLY; - - break; - - case MOUSE.ROTATE: - - if ( event.ctrlKey || event.metaKey || event.shiftKey ) { - - if ( scope.enablePan === false ) return; - - handleMouseDownPan( event ); - - state = STATE.PAN; - - } else { - - if ( scope.enableRotate === false ) return; - - handleMouseDownRotate( event ); - - state = STATE.ROTATE; - - } - - break; - - case MOUSE.PAN: - - if ( event.ctrlKey || event.metaKey || event.shiftKey ) { - - if ( scope.enableRotate === false ) return; - - handleMouseDownRotate( event ); - - state = STATE.ROTATE; - - } else { - - if ( scope.enablePan === false ) return; - - handleMouseDownPan( event ); - - state = STATE.PAN; - - } - - break; - - default: - - state = STATE.NONE; - - } + if (scope.interactionGuards.pan.callback(event)) { + if (scope.enablePan === false) return + handleMouseDownPan(event) + state = STATE.PAN + } else if (scope.interactionGuards.rotate.callback(event)) { + if (scope.enableRotate === false) return + handleMouseDownRotate(event) + state = STATE.ROTATE + } else if (scope.interactionGuards.zoom.dragCallback(event)) { + if (scope.enableZoom === false) return + handleMouseDownDolly(event) + state = STATE.DOLLY + } else { + return + } if ( state !== STATE.NONE ) {