Skip to content

Commit

Permalink
Fix panRightClick::CameraControl. Caused by custom mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
ijlal99 committed Nov 5, 2024
1 parent 7dd43e8 commit ed07367
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/viewer/scene/CameraControl/CameraControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,8 @@ class CameraControl extends Component {
keyMap[this.AXIS_VIEW_TOP] = [input.KEY_NUM_5];
keyMap[this.AXIS_VIEW_BOTTOM] = [input.KEY_NUM_6];
keyMap[this.MOUSE_PAN] = [
[input.KEY_SHIFT],
this._configs.panRightClick ? [input.MOUSE_RIGHT_BUTTON] : [input.MOUSE_MIDDLE_BUTTON]
[input.MOUSE_LEFT_BUTTON, input.KEY_SHIFT],
this._configs.panRightClick ? input.MOUSE_RIGHT_BUTTON : input.MOUSE_MIDDLE_BUTTON
]
keyMap[this.MOUSE_ROTATE] = [input.MOUSE_LEFT_BUTTON];
keyMap[this.MOUSE_DOLLY] = [];
Expand All @@ -921,8 +921,8 @@ class CameraControl extends Component {
keyMap[this.AXIS_VIEW_TOP] = [input.KEY_NUM_5];
keyMap[this.AXIS_VIEW_BOTTOM] = [input.KEY_NUM_6];
keyMap[this.MOUSE_PAN] = [
[input.KEY_SHIFT],
this._configs.panRightClick ? [input.MOUSE_RIGHT_BUTTON] : [input.MOUSE_MIDDLE_BUTTON]
[input.MOUSE_LEFT_BUTTON, input.KEY_SHIFT],
this._configs.panRightClick ? input.MOUSE_RIGHT_BUTTON : input.MOUSE_MIDDLE_BUTTON
]
keyMap[this.MOUSE_ROTATE] = [input.MOUSE_LEFT_BUTTON];
keyMap[this.MOUSE_DOLLY] = [];
Expand Down Expand Up @@ -1444,6 +1444,20 @@ class CameraControl extends Component {
*/
set panRightClick(value) {
this._configs.panRightClick = value !== false;
const panKeyMap = this._keyMap[this.MOUSE_PAN];
if (panKeyMap && panKeyMap.length > 0) {
const input = this.scene.input;
for (let i = 0, len = panKeyMap.length; i < len; i++) {
if (this._configs.panRightClick && panKeyMap[i] === input.MOUSE_MIDDLE_BUTTON) {
this._keyMap[this.MOUSE_PAN][i] = input.MOUSE_RIGHT_BUTTON;
return;
}
else if (!this._configs.panRightClick && panKeyMap[i] === input.MOUSE_RIGHT_BUTTON) {
this._keyMap[this.MOUSE_PAN][i] = input.MOUSE_MIDDLE_BUTTON;
return;
}
}
}
}

/**
Expand Down

0 comments on commit ed07367

Please sign in to comment.