Skip to content

Commit 16c66b9

Browse files
authored
Merge pull request #187 from WhitestormJS/#136
#136 - fixes left/right/top/bottom pan - thanks goes to @thejmazz
2 parents cb9cfeb + f132aa3 commit 16c66b9

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/modules/controls/lib/ThreeOrbitControls.js

+9-15
Original file line numberDiff line numberDiff line change
@@ -267,35 +267,31 @@ export class ThreeOrbitControls extends EventDispatcher {
267267
sphericalDelta.phi -= angle;
268268
}
269269

270-
const panLeft = () => {
270+
const panLeft = (() => {
271271
const v = new Vector3();
272272

273-
return function panLeft(distance, objectMatrix) {
273+
return (distance, objectMatrix) => {
274274
v.setFromMatrixColumn(objectMatrix, 0); // get X column of objectMatrix
275275
v.multiplyScalar(-distance);
276-
277276
panOffset.add(v);
278-
279277
};
280-
};
278+
})();
281279

282-
const panUp = () => {
280+
const panUp = (() => {
283281
const v = new Vector3();
284282

285-
return function panUp(distance, objectMatrix) {
283+
return (distance, objectMatrix) => {
286284
v.setFromMatrixColumn(objectMatrix, 1); // get Y column of objectMatrix
287285
v.multiplyScalar(distance);
288-
289286
panOffset.add(v);
290-
291287
};
292-
};
288+
})();
293289

294290
// deltaX and deltaY are in pixels; right and down are positive
295-
const pan = () => {
291+
const pan = (() => {
296292
const offset = new Vector3();
297293

298-
return function pan(deltaX, deltaY) {
294+
return (deltaX, deltaY) => {
299295
const element = this.domElement === document ? this.domElement.body : this.domElement;
300296

301297
if (this.object instanceof PerspectiveCamera) {
@@ -320,11 +316,9 @@ export class ThreeOrbitControls extends EventDispatcher {
320316
// camera neither orthographic nor perspective
321317
console.warn('WARNING: OrbitControlsModule.js encountered an unknown camera type - pan disabled.');
322318
this.enablePan = false;
323-
324319
}
325-
326320
};
327-
};
321+
})();
328322

329323
const dollyIn = (dollyScale) => {
330324
if (this.object instanceof PerspectiveCamera) {

0 commit comments

Comments
 (0)