Skip to content

Commit a31873d

Browse files
ftoromanoffgchoqueux
authored andcommitted
feature(controls): add option enable smart travel in planarControls
1 parent b5ff9e9 commit a31873d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Controls/PlanarControls.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const defaultOptions = {
8686
focusOnMouseClick: true,
8787
handleCollision: true,
8888
minDistanceCollision: 30,
89+
enableSmartTravel: true,
8990
};
9091

9192
export const PLANAR_CONTROL_EVENT = {
@@ -138,6 +139,7 @@ export const PLANAR_CONTROL_EVENT = {
138139
* @param {boolean} [options.focusOnMouseOver=true] Set the focus on the canvas if hovered.
139140
* @param {boolean} [options.focusOnMouseClick=true] Set the focus on the canvas if clicked.
140141
* @param {boolean} [options.handleCollision=true]
142+
* @param {boolean} [options.enableSmartTravel=true] enable smart travel
141143
*/
142144
class PlanarControls extends THREE.EventDispatcher {
143145
constructor(view, options = {}) {
@@ -194,6 +196,9 @@ class PlanarControls extends THREE.EventDispatcher {
194196
defaultOptions.handleCollision : options.handleCollision;
195197
this.minDistanceCollision = defaultOptions.minDistanceCollision;
196198

199+
// enable smart travel
200+
this.enableSmartTravel = options.enableSmartTravel === undefined ? defaultOptions.enableSmartTravel : options.enableSmartTravel;
201+
197202
startPosition.copy(this.camera.position);
198203
startQuaternion.copy(this.camera.quaternion);
199204

@@ -854,7 +859,11 @@ class PlanarControls extends THREE.EventDispatcher {
854859
this.initiateDrag();
855860
}
856861
} else if (mouseButtons.MIDDLECLICK === event.button) {
857-
this.initiateSmartZoom();
862+
if (this.enableSmartTravel) {
863+
this.initiateSmartZoom();
864+
} else {
865+
return;
866+
}
858867
} else if (mouseButtons.RIGHTCLICK === event.button) {
859868
this.initiatePan();
860869
}

0 commit comments

Comments
 (0)