Skip to content

Commit

Permalink
feature(controls): add option enable smart travel in planarControls
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff authored and gchoqueux committed Dec 2, 2020
1 parent b5ff9e9 commit a31873d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Controls/PlanarControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const defaultOptions = {
focusOnMouseClick: true,
handleCollision: true,
minDistanceCollision: 30,
enableSmartTravel: true,
};

export const PLANAR_CONTROL_EVENT = {
Expand Down Expand Up @@ -138,6 +139,7 @@ export const PLANAR_CONTROL_EVENT = {
* @param {boolean} [options.focusOnMouseOver=true] Set the focus on the canvas if hovered.
* @param {boolean} [options.focusOnMouseClick=true] Set the focus on the canvas if clicked.
* @param {boolean} [options.handleCollision=true]
* @param {boolean} [options.enableSmartTravel=true] enable smart travel
*/
class PlanarControls extends THREE.EventDispatcher {
constructor(view, options = {}) {
Expand Down Expand Up @@ -194,6 +196,9 @@ class PlanarControls extends THREE.EventDispatcher {
defaultOptions.handleCollision : options.handleCollision;
this.minDistanceCollision = defaultOptions.minDistanceCollision;

// enable smart travel
this.enableSmartTravel = options.enableSmartTravel === undefined ? defaultOptions.enableSmartTravel : options.enableSmartTravel;

startPosition.copy(this.camera.position);
startQuaternion.copy(this.camera.quaternion);

Expand Down Expand Up @@ -854,7 +859,11 @@ class PlanarControls extends THREE.EventDispatcher {
this.initiateDrag();
}
} else if (mouseButtons.MIDDLECLICK === event.button) {
this.initiateSmartZoom();
if (this.enableSmartTravel) {
this.initiateSmartZoom();
} else {
return;
}
} else if (mouseButtons.RIGHTCLICK === event.button) {
this.initiatePan();
}
Expand Down

0 comments on commit a31873d

Please sign in to comment.