From 93bc087e1e471394c23c547fe1e7fa5c522a64b4 Mon Sep 17 00:00:00 2001 From: AnthonyGlt Date: Tue, 18 Jul 2023 17:54:47 +0200 Subject: [PATCH] fix(StateControl): use uncaught key event --- src/Controls/StateControl.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Controls/StateControl.js b/src/Controls/StateControl.js index c2901d3253..ef75ca1691 100644 --- a/src/Controls/StateControl.js +++ b/src/Controls/StateControl.js @@ -324,17 +324,25 @@ class StateControl extends THREE.EventDispatcher { viewCoords.copy(this._view.eventToViewCoords(event)); switch (event.pointerType) { - case 'mouse': + case 'mouse': { this._currentMousePressed = event.button; - + let clickKeyPressed = this._currentKeyPressed; + + if (clickKeyPressed === undefined) { + if (event.ctrlKey) { + clickKeyPressed = CONTROL_KEYS.CTRL; + } else if (event.shiftKey) { + clickKeyPressed = CONTROL_KEYS.SHIFT; + } + } this.currentState = this.inputToState( this._currentMousePressed, - this._currentKeyPressed, + clickKeyPressed, // Detect if the mouse button was pressed less than 500 ms before, and if the cursor has not moved two much // since previous click. If so, set dblclick to true. event.timeStamp - this._clickTimeStamp < 500 - && this._lastMousePressed.button === this._currentMousePressed - && this._lastMousePressed.viewCoords.distanceTo(viewCoords) < 5, + && this._lastMousePressed.button === this._currentMousePressed + && this._lastMousePressed.viewCoords.distanceTo(viewCoords) < 5, ); this._clickTimeStamp = event.timeStamp; @@ -342,6 +350,7 @@ class StateControl extends THREE.EventDispatcher { this._lastMousePressed.viewCoords.copy(viewCoords); break; + } // TODO : add touch event management default: }