redhotmagma-visualization 1.41.1 → 1.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/AlignTargetProvider.js +50 -79
  2. package/CommonUtils/Deferred.js +11 -38
  3. package/CommonUtils/Observable.js +29 -48
  4. package/CommonUtils/PropertyObserver.js +10 -17
  5. package/CommonUtils/SyncCurrentFunction.js +33 -42
  6. package/CommonUtils/SyncObservableEvent.js +2 -6
  7. package/CommonUtils/pointerEvent.js +50 -98
  8. package/Constants.js +6 -6
  9. package/DevApp.js +187 -309
  10. package/ExposedModules.js +2 -9
  11. package/FallbackVisualization.js +4 -10
  12. package/PrintingEffects/ColorEmbossingEffect.js +15 -26
  13. package/PrintingEffects/DomingEffect.js +29 -52
  14. package/PrintingEffects/EmbossingEffect.js +17 -29
  15. package/PrintingEffects/EmbroideryEffect.js +251 -362
  16. package/PrintingEffects/EngravingEffect.js +17 -29
  17. package/PrintingEffects/PrintingEffects.js +44 -73
  18. package/PrintingEffects/PrintingEffectsUtils.js +1 -7
  19. package/React/ReactBase.js +15 -47
  20. package/Three/Controls/OrbitControls.js +105 -126
  21. package/Three/Exporters/glTFExporter.js +2 -6
  22. package/Three/Loaders/ColladaLoader.js +202 -550
  23. package/Three/Loaders/MTLLoader.js +33 -64
  24. package/Three/Loaders/OBJLoader.js +48 -80
  25. package/Three/Three2D.js +750 -1014
  26. package/Three/Three2DLayers.js +217 -341
  27. package/Three/Three3D.js +530 -800
  28. package/Three/Three3DScene.js +484 -780
  29. package/Three/ThreeBase.js +145 -230
  30. package/Utils/DesignArea/getDesignAreaCanvasSize.js +3 -11
  31. package/Utils/TextureBuilder/createTextureBuilder.js +133 -193
  32. package/Utils/TextureBuilder/textureBuilderFunctions.js +11 -27
  33. package/Utils/alignToElement.js +13 -24
  34. package/Utils/canvasBlur.js +27 -45
  35. package/Utils/createAlphaMapFromAlphaChannel.js +11 -21
  36. package/Utils/createBakedShadow.js +38 -42
  37. package/Utils/createCache.js +0 -4
  38. package/Utils/createCanvas.js +3 -9
  39. package/Utils/createImageRepository.js +63 -87
  40. package/Utils/disposeMaterial.js +4 -14
  41. package/Utils/getImageSize.js +1 -2
  42. package/Utils/imagePreloader.js +36 -48
  43. package/Utils/initTextureCanvas.js +6 -18
  44. package/Utils/isMobileDevice.js +3 -7
  45. package/Utils/optimizeTextureImage.js +13 -29
  46. package/Utils/rememberCameraViewOffset.js +8 -11
  47. package/Utils/removeObject.js +0 -4
  48. package/Utils/restrictCameraMovement.js +2 -12
  49. package/Utils/setLightShadow.js +3 -5
  50. package/Utils/setOrthographicCameraSize.js +0 -1
  51. package/Utils/updateFitSizeToElement.js +4 -9
  52. package/VisualizationContainer.js +37 -90
  53. package/VisualizationInterface.js +32 -67
  54. package/VisualizationProvider.js +5 -15
  55. package/index.js +2 -9
  56. package/package.json +6 -7
  57. package/scripts/cpPublicLocal.js +7 -2
  58. package/src/CommonUtils/Observable.js +1 -0
  59. package/src/CommonUtils/pointerEvent.js +17 -0
  60. package/src/Constants.js +2 -0
  61. package/src/DevApp.js +1 -2
  62. package/src/Three/Three2D.js +105 -1
  63. package/src/Three/ThreeBase.js +31 -3
  64. package/src/Utils/TextureBuilder/createTextureBuilder.js +12 -3
  65. package/src/VisualizationContainer.js +8 -2
  66. package/src/index.js +2 -3
  67. package/visualizationAdapterCreator.js +6 -23
@@ -1,21 +1,20 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = void 0;
9
-
10
8
  var THREE_imp = _interopRequireWildcard(require("three"));
11
-
12
9
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
-
14
10
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
-
16
11
  /* eslint-disable */
12
+
17
13
  // original source: three/examples/js/controls/OrbitControls.js
18
- var THREE = THREE_imp; // important: update file from here if needed
14
+
15
+ var THREE = THREE_imp;
16
+
17
+ // important: update file from here if needed
19
18
  // important: be careful when updating, there is a custom updateQuat function inside the update function
20
19
 
21
20
  /**
@@ -25,6 +24,7 @@ var THREE = THREE_imp; // important: update file from here if needed
25
24
  * @author WestLangley / http://github.com/WestLangley
26
25
  * @author erich666 / http://erichaines.com
27
26
  */
27
+
28
28
  // This set of controls performs orbiting, dollying (zooming), and panning.
29
29
  // Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
30
30
  //
@@ -34,88 +34,95 @@ var THREE = THREE_imp; // important: update file from here if needed
34
34
 
35
35
  THREE.OrbitControls = function (object, domElement) {
36
36
  this.object = object;
37
- this.domElement = domElement !== undefined ? domElement : document; // Set to false to disable this control
37
+ this.domElement = domElement !== undefined ? domElement : document;
38
38
 
39
- this.enabled = true; // "target" sets the location of focus, where the object orbits around
39
+ // Set to false to disable this control
40
+ this.enabled = true;
40
41
 
41
- this.target = new THREE.Vector3(); // How far you can dolly in and out ( PerspectiveCamera only )
42
+ // "target" sets the location of focus, where the object orbits around
43
+ this.target = new THREE.Vector3();
42
44
 
45
+ // How far you can dolly in and out ( PerspectiveCamera only )
43
46
  this.minDistance = 0;
44
- this.maxDistance = Infinity; // How far you can zoom in and out ( OrthographicCamera only )
47
+ this.maxDistance = Infinity;
45
48
 
49
+ // How far you can zoom in and out ( OrthographicCamera only )
46
50
  this.minZoom = 0;
47
- this.maxZoom = Infinity; // How far you can orbit vertically, upper and lower limits.
48
- // Range is 0 to Math.PI radians.
51
+ this.maxZoom = Infinity;
49
52
 
53
+ // How far you can orbit vertically, upper and lower limits.
54
+ // Range is 0 to Math.PI radians.
50
55
  this.minPolarAngle = 0; // radians
51
-
52
56
  this.maxPolarAngle = Math.PI; // radians
57
+
53
58
  // How far you can orbit horizontally, upper and lower limits.
54
59
  // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
55
-
56
60
  this.minAzimuthAngle = -Infinity; // radians
57
-
58
61
  this.maxAzimuthAngle = Infinity; // radians
62
+
59
63
  // Set to true to enable damping (inertia)
60
64
  // If damping is enabled, you must call controls.update() in your animation loop
61
-
62
65
  this.enableDamping = false;
63
- this.dampingFactor = 0.25; // This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
64
- // Set to false to disable zooming
66
+ this.dampingFactor = 0.25;
65
67
 
68
+ // This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
69
+ // Set to false to disable zooming
66
70
  this.enableZoom = true;
67
- this.zoomSpeed = 1.0; // Set to false to disable rotating
71
+ this.zoomSpeed = 1.0;
68
72
 
73
+ // Set to false to disable rotating
69
74
  this.enableRotate = true;
70
- this.rotateSpeed = 1.0; // Set to false to disable panning
75
+ this.rotateSpeed = 1.0;
71
76
 
77
+ // Set to false to disable panning
72
78
  this.enablePan = true;
73
79
  this.panSpeed = 1.0;
74
80
  this.screenSpacePanning = false; // if true, pan in screen-space
75
-
76
81
  this.keyPanSpeed = 7.0; // pixels moved per arrow key push
82
+
77
83
  // Set to true to automatically rotate around the target
78
84
  // If auto-rotate is enabled, you must call controls.update() in your animation loop
79
-
80
85
  this.autoRotate = false;
81
86
  this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
82
- // Set to false to disable use of the keys
83
87
 
84
- this.enableKeys = true; // The four arrow keys
88
+ // Set to false to disable use of the keys
89
+ this.enableKeys = true;
85
90
 
91
+ // The four arrow keys
86
92
  this.keys = {
87
93
  LEFT: 37,
88
94
  UP: 38,
89
95
  RIGHT: 39,
90
96
  BOTTOM: 40
91
- }; // Mouse buttons
97
+ };
92
98
 
99
+ // Mouse buttons
93
100
  this.mouseButtons = {
94
101
  LEFT: THREE.MOUSE.LEFT,
95
102
  MIDDLE: THREE.MOUSE.MIDDLE,
96
103
  RIGHT: THREE.MOUSE.RIGHT
97
- }; // for reset
104
+ };
98
105
 
106
+ // for reset
99
107
  this.target0 = this.target.clone();
100
108
  this.position0 = this.object.position.clone();
101
- this.zoom0 = this.object.zoom; //
109
+ this.zoom0 = this.object.zoom;
110
+
111
+ //
102
112
  // public methods
103
113
  //
104
114
 
105
115
  this.getPolarAngle = function () {
106
116
  return spherical.phi;
107
117
  };
108
-
109
118
  this.getAzimuthalAngle = function () {
110
119
  return spherical.theta;
111
120
  };
112
-
113
121
  this.saveState = function () {
114
122
  scope.target0.copy(scope.target);
115
123
  scope.position0.copy(scope.object.position);
116
124
  scope.zoom0 = scope.object.zoom;
117
125
  };
118
-
119
126
  this.reset = function () {
120
127
  scope.target.copy(scope.target0);
121
128
  scope.object.position.copy(scope.position0);
@@ -124,23 +131,24 @@ THREE.OrbitControls = function (object, domElement) {
124
131
  scope.dispatchEvent(changeEvent);
125
132
  scope.update();
126
133
  state = STATE.NONE;
127
- }; // this method is exposed, but perhaps it would be better if we can make it private...
128
-
134
+ };
129
135
 
136
+ // this method is exposed, but perhaps it would be better if we can make it private...
130
137
  this.update = function () {
131
138
  var offset = new THREE.Vector3();
132
- var up = object.up.clone(); // so camera.up is the orbit axis
139
+ var up = object.up.clone();
133
140
 
141
+ // so camera.up is the orbit axis
134
142
  var quat;
135
- var quatInverse; // the up vector of the camera object can be changed by its rotation,
136
- // to make sure the controls will continue to work the quaternions also have to be updated
143
+ var quatInverse;
137
144
 
145
+ // the up vector of the camera object can be changed by its rotation,
146
+ // to make sure the controls will continue to work the quaternions also have to be updated
138
147
  function updateQuat(object) {
139
148
  quat = new THREE.Quaternion().setFromUnitVectors(object.up, new THREE.Vector3(0, 1, 0));
140
149
  quatInverse = quat.clone().invert();
141
150
  up = object.up.clone();
142
151
  }
143
-
144
152
  updateQuat(object);
145
153
  var lastPosition = new THREE.Vector3();
146
154
  var lastQuaternion = new THREE.Quaternion();
@@ -148,36 +156,39 @@ THREE.OrbitControls = function (object, domElement) {
148
156
  if (!up.equals(scope.object.up)) {
149
157
  updateQuat(scope.object);
150
158
  }
151
-
152
159
  var position = scope.object.position;
153
- offset.copy(position).sub(scope.target); // rotate offset to "y-axis-is-up" space
160
+ offset.copy(position).sub(scope.target);
154
161
 
155
- offset.applyQuaternion(quat); // angle from z-axis around y-axis
162
+ // rotate offset to "y-axis-is-up" space
163
+ offset.applyQuaternion(quat);
156
164
 
165
+ // angle from z-axis around y-axis
157
166
  spherical.setFromVector3(offset);
158
-
159
167
  if (scope.autoRotate && state === STATE.NONE) {
160
168
  rotateLeft(getAutoRotationAngle());
161
169
  }
162
-
163
170
  spherical.theta += sphericalDelta.theta;
164
- spherical.phi += sphericalDelta.phi; // restrict theta to be between desired limits
171
+ spherical.phi += sphericalDelta.phi;
165
172
 
166
- spherical.theta = Math.max(scope.minAzimuthAngle, Math.min(scope.maxAzimuthAngle, spherical.theta)); // restrict phi to be between desired limits
173
+ // restrict theta to be between desired limits
174
+ spherical.theta = Math.max(scope.minAzimuthAngle, Math.min(scope.maxAzimuthAngle, spherical.theta));
167
175
 
176
+ // restrict phi to be between desired limits
168
177
  spherical.phi = Math.max(scope.minPolarAngle, Math.min(scope.maxPolarAngle, spherical.phi));
169
178
  spherical.makeSafe();
170
- spherical.radius *= scale; // restrict radius to be between desired limits
179
+ spherical.radius *= scale;
171
180
 
172
- spherical.radius = Math.max(scope.minDistance, Math.min(scope.maxDistance, spherical.radius)); // move target to panned location
181
+ // restrict radius to be between desired limits
182
+ spherical.radius = Math.max(scope.minDistance, Math.min(scope.maxDistance, spherical.radius));
173
183
 
184
+ // move target to panned location
174
185
  scope.target.add(panOffset);
175
- offset.setFromSpherical(spherical); // rotate offset back to "camera-up-vector-is-up" space
186
+ offset.setFromSpherical(spherical);
176
187
 
188
+ // rotate offset back to "camera-up-vector-is-up" space
177
189
  offset.applyQuaternion(quatInverse);
178
190
  position.copy(scope.target).add(offset);
179
191
  scope.object.lookAt(scope.target);
180
-
181
192
  if (scope.enableDamping === true) {
182
193
  sphericalDelta.theta *= 1 - scope.dampingFactor;
183
194
  sphericalDelta.phi *= 1 - scope.dampingFactor;
@@ -186,8 +197,9 @@ THREE.OrbitControls = function (object, domElement) {
186
197
  sphericalDelta.set(0, 0, 0);
187
198
  panOffset.set(0, 0, 0);
188
199
  }
200
+ scale = 1;
189
201
 
190
- scale = 1; // update condition is:
202
+ // update condition is:
191
203
  // min(camera displacement, camera rotation in radians)^2 > EPS
192
204
  // using small-angle approximation cos(x/2) = 1 - x^2 / 8
193
205
 
@@ -198,11 +210,9 @@ THREE.OrbitControls = function (object, domElement) {
198
210
  zoomChanged = false;
199
211
  return true;
200
212
  }
201
-
202
213
  return false;
203
214
  };
204
215
  }();
205
-
206
216
  this.dispose = function () {
207
217
  scope.domElement.removeEventListener("contextmenu", onContextMenu, false);
208
218
  scope.domElement.removeEventListener("mousedown", onMouseDown, false);
@@ -213,12 +223,15 @@ THREE.OrbitControls = function (object, domElement) {
213
223
  scope.domElement.removeEventListener("touchmove", onTouchMove, false);
214
224
  document.removeEventListener("mousemove", onMouseMove, false);
215
225
  document.removeEventListener("mouseup", onMouseUp, false);
216
- window.removeEventListener("keydown", onKeyDown, false); //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here?
217
- }; //
226
+ window.removeEventListener("keydown", onKeyDown, false);
227
+
228
+ //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here?
229
+ };
230
+
231
+ //
218
232
  // internals
219
233
  //
220
234
 
221
-
222
235
  var scope = this;
223
236
  var changeEvent = {
224
237
  type: "change"
@@ -238,8 +251,9 @@ THREE.OrbitControls = function (object, domElement) {
238
251
  TOUCH_DOLLY_PAN: 4
239
252
  };
240
253
  var state = STATE.NONE;
241
- var EPS = 0.000001; // current position in spherical coordinates
254
+ var EPS = 0.000001;
242
255
 
256
+ // current position in spherical coordinates
243
257
  var spherical = new THREE.Spherical();
244
258
  var sphericalDelta = new THREE.Spherical();
245
259
  var scale = 1;
@@ -254,33 +268,26 @@ THREE.OrbitControls = function (object, domElement) {
254
268
  var dollyStart = new THREE.Vector2();
255
269
  var dollyEnd = new THREE.Vector2();
256
270
  var dollyDelta = new THREE.Vector2();
257
-
258
271
  function getAutoRotationAngle() {
259
272
  return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
260
273
  }
261
-
262
274
  function getZoomScale() {
263
275
  return Math.pow(0.95, scope.zoomSpeed);
264
276
  }
265
-
266
277
  function rotateLeft(angle) {
267
278
  sphericalDelta.theta -= angle;
268
279
  }
269
-
270
280
  function rotateUp(angle) {
271
281
  sphericalDelta.phi -= angle;
272
282
  }
273
-
274
283
  var panLeft = function () {
275
284
  var v = new THREE.Vector3();
276
285
  return function panLeft(distance, objectMatrix) {
277
286
  v.setFromMatrixColumn(objectMatrix, 0); // get X column of objectMatrix
278
-
279
287
  v.multiplyScalar(-distance);
280
288
  panOffset.add(v);
281
289
  };
282
290
  }();
283
-
284
291
  var panUp = function () {
285
292
  var v = new THREE.Vector3();
286
293
  return function panUp(distance, objectMatrix) {
@@ -290,26 +297,26 @@ THREE.OrbitControls = function (object, domElement) {
290
297
  v.setFromMatrixColumn(objectMatrix, 0);
291
298
  v.crossVectors(scope.object.up, v);
292
299
  }
293
-
294
300
  v.multiplyScalar(distance);
295
301
  panOffset.add(v);
296
302
  };
297
- }(); // deltaX and deltaY are in pixels; right and down are positive
298
-
303
+ }();
299
304
 
305
+ // deltaX and deltaY are in pixels; right and down are positive
300
306
  var pan = function () {
301
307
  var offset = new THREE.Vector3();
302
308
  return function pan(deltaX, deltaY) {
303
309
  var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
304
-
305
310
  if (scope.object.isPerspectiveCamera) {
306
311
  // perspective
307
312
  var position = scope.object.position;
308
313
  offset.copy(position).sub(scope.target);
309
- var targetDistance = offset.length(); // half of the fov is center to top of screen
314
+ var targetDistance = offset.length();
310
315
 
311
- targetDistance *= Math.tan(scope.object.fov / 2 * Math.PI / 180.0); // we use only clientHeight here so aspect ratio does not distort speed
316
+ // half of the fov is center to top of screen
317
+ targetDistance *= Math.tan(scope.object.fov / 2 * Math.PI / 180.0);
312
318
 
319
+ // we use only clientHeight here so aspect ratio does not distort speed
313
320
  panLeft(2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix);
314
321
  panUp(2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix);
315
322
  } else if (scope.object.isOrthographicCamera) {
@@ -323,7 +330,6 @@ THREE.OrbitControls = function (object, domElement) {
323
330
  }
324
331
  };
325
332
  }();
326
-
327
333
  function dollyIn(dollyScale) {
328
334
  if (scope.object.isPerspectiveCamera) {
329
335
  scale /= dollyScale;
@@ -336,7 +342,6 @@ THREE.OrbitControls = function (object, domElement) {
336
342
  scope.enableZoom = false;
337
343
  }
338
344
  }
339
-
340
345
  function dollyOut(dollyScale) {
341
346
  if (scope.object.isPerspectiveCamera) {
342
347
  scale *= dollyScale;
@@ -348,28 +353,30 @@ THREE.OrbitControls = function (object, domElement) {
348
353
  console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
349
354
  scope.enableZoom = false;
350
355
  }
351
- } //
356
+ }
357
+
358
+ //
352
359
  // event callbacks - update the object state
353
360
  //
354
361
 
355
-
356
362
  function handleMouseDownRotate(event) {
357
363
  //console.log( 'handleMouseDownRotate' );
364
+
358
365
  rotateStart.set(event.clientX, event.clientY);
359
366
  }
360
-
361
367
  function handleMouseDownDolly(event) {
362
368
  //console.log( 'handleMouseDownDolly' );
369
+
363
370
  dollyStart.set(event.clientX, event.clientY);
364
371
  }
365
-
366
372
  function handleMouseDownPan(event) {
367
373
  //console.log( 'handleMouseDownPan' );
374
+
368
375
  panStart.set(event.clientX, event.clientY);
369
376
  }
370
-
371
377
  function handleMouseMoveRotate(event) {
372
378
  //console.log( 'handleMouseMoveRotate' );
379
+
373
380
  rotateEnd.set(event.clientX, event.clientY);
374
381
  rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
375
382
  var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
@@ -379,93 +386,86 @@ THREE.OrbitControls = function (object, domElement) {
379
386
  rotateStart.copy(rotateEnd);
380
387
  scope.update();
381
388
  }
382
-
383
389
  function handleMouseMoveDolly(event) {
384
390
  //console.log( 'handleMouseMoveDolly' );
391
+
385
392
  dollyEnd.set(event.clientX, event.clientY);
386
393
  dollyDelta.subVectors(dollyEnd, dollyStart);
387
-
388
394
  if (dollyDelta.y > 0) {
389
395
  dollyIn(getZoomScale());
390
396
  } else if (dollyDelta.y < 0) {
391
397
  dollyOut(getZoomScale());
392
398
  }
393
-
394
399
  dollyStart.copy(dollyEnd);
395
400
  scope.update();
396
401
  }
397
-
398
402
  function handleMouseMovePan(event) {
399
403
  //console.log( 'handleMouseMovePan' );
404
+
400
405
  panEnd.set(event.clientX, event.clientY);
401
406
  panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
402
407
  pan(panDelta.x, panDelta.y);
403
408
  panStart.copy(panEnd);
404
409
  scope.update();
405
410
  }
406
-
407
- function handleMouseUp(event) {// console.log( 'handleMouseUp' );
411
+ function handleMouseUp(event) {
412
+ // console.log( 'handleMouseUp' );
408
413
  }
409
-
410
414
  function handleMouseWheel(event) {
411
415
  // console.log( 'handleMouseWheel' );
416
+
412
417
  if (event.deltaY < 0) {
413
418
  dollyOut(getZoomScale());
414
419
  } else if (event.deltaY > 0) {
415
420
  dollyIn(getZoomScale());
416
421
  }
417
-
418
422
  scope.update();
419
423
  }
420
-
421
424
  function handleKeyDown(event) {
422
425
  //console.log( 'handleKeyDown' );
426
+
423
427
  switch (event.keyCode) {
424
428
  case scope.keys.UP:
425
429
  pan(0, scope.keyPanSpeed);
426
430
  scope.update();
427
431
  break;
428
-
429
432
  case scope.keys.BOTTOM:
430
433
  pan(0, -scope.keyPanSpeed);
431
434
  scope.update();
432
435
  break;
433
-
434
436
  case scope.keys.LEFT:
435
437
  pan(scope.keyPanSpeed, 0);
436
438
  scope.update();
437
439
  break;
438
-
439
440
  case scope.keys.RIGHT:
440
441
  pan(-scope.keyPanSpeed, 0);
441
442
  scope.update();
442
443
  break;
443
444
  }
444
445
  }
445
-
446
446
  function handleTouchStartRotate(event) {
447
447
  //console.log( 'handleTouchStartRotate' );
448
+
448
449
  rotateStart.set(event.touches[0].pageX, event.touches[0].pageY);
449
450
  }
450
-
451
451
  function handleTouchStartDollyPan(event) {
452
452
  //console.log( 'handleTouchStartDollyPan' );
453
+
453
454
  if (scope.enableZoom) {
454
455
  var dx = event.touches[0].pageX - event.touches[1].pageX;
455
456
  var dy = event.touches[0].pageY - event.touches[1].pageY;
456
457
  var distance = Math.sqrt(dx * dx + dy * dy);
457
458
  dollyStart.set(0, distance);
458
459
  }
459
-
460
460
  if (scope.enablePan) {
461
461
  var x = 0.5 * (event.touches[0].pageX + event.touches[1].pageX);
462
462
  var y = 0.5 * (event.touches[0].pageY + event.touches[1].pageY);
463
463
  panStart.set(x, y);
464
464
  }
465
465
  }
466
-
467
466
  function handleTouchMoveRotate(event) {
468
467
  //console.log( 'handleTouchMoveRotate' );
468
+
469
469
  rotateEnd.set(event.touches[0].pageX, event.touches[0].pageY);
470
470
  rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
471
471
  var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
@@ -475,9 +475,9 @@ THREE.OrbitControls = function (object, domElement) {
475
475
  rotateStart.copy(rotateEnd);
476
476
  scope.update();
477
477
  }
478
-
479
478
  function handleTouchMoveDollyPan(event) {
480
479
  //console.log( 'handleTouchMoveDollyPan' );
480
+
481
481
  if (scope.enableZoom) {
482
482
  var dx = event.touches[0].pageX - event.touches[1].pageX;
483
483
  var dy = event.touches[0].pageY - event.touches[1].pageY;
@@ -487,7 +487,6 @@ THREE.OrbitControls = function (object, domElement) {
487
487
  dollyIn(dollyDelta.y);
488
488
  dollyStart.copy(dollyEnd);
489
489
  }
490
-
491
490
  if (scope.enablePan) {
492
491
  var x = 0.5 * (event.touches[0].pageX + event.touches[1].pageX);
493
492
  var y = 0.5 * (event.touches[0].pageY + event.touches[1].pageY);
@@ -496,20 +495,19 @@ THREE.OrbitControls = function (object, domElement) {
496
495
  pan(panDelta.x, panDelta.y);
497
496
  panStart.copy(panEnd);
498
497
  }
499
-
500
498
  scope.update();
501
499
  }
500
+ function handleTouchEnd(event) {
501
+ //console.log( 'handleTouchEnd' );
502
+ }
502
503
 
503
- function handleTouchEnd(event) {//console.log( 'handleTouchEnd' );
504
- } //
504
+ //
505
505
  // event handlers - FSM: listen for events and reset state
506
506
  //
507
507
 
508
-
509
508
  function onMouseDown(event) {
510
509
  if (scope.enabled === false) return;
511
510
  event.preventDefault();
512
-
513
511
  switch (event.button) {
514
512
  case scope.mouseButtons.LEFT:
515
513
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
@@ -521,51 +519,42 @@ THREE.OrbitControls = function (object, domElement) {
521
519
  handleMouseDownRotate(event);
522
520
  state = STATE.ROTATE;
523
521
  }
524
-
525
522
  break;
526
-
527
523
  case scope.mouseButtons.MIDDLE:
528
524
  if (scope.enableZoom === false) return;
529
525
  handleMouseDownDolly(event);
530
526
  state = STATE.DOLLY;
531
527
  break;
532
-
533
528
  case scope.mouseButtons.RIGHT:
534
529
  if (scope.enablePan === false) return;
535
530
  handleMouseDownPan(event);
536
531
  state = STATE.PAN;
537
532
  break;
538
533
  }
539
-
540
534
  if (state !== STATE.NONE) {
541
535
  document.addEventListener("mousemove", onMouseMove, false);
542
536
  document.addEventListener("mouseup", onMouseUp, false);
543
537
  scope.dispatchEvent(startEvent);
544
538
  }
545
539
  }
546
-
547
540
  function onMouseMove(event) {
548
541
  if (scope.enabled === false) return;
549
542
  event.preventDefault();
550
-
551
543
  switch (state) {
552
544
  case STATE.ROTATE:
553
545
  if (scope.enableRotate === false) return;
554
546
  handleMouseMoveRotate(event);
555
547
  break;
556
-
557
548
  case STATE.DOLLY:
558
549
  if (scope.enableZoom === false) return;
559
550
  handleMouseMoveDolly(event);
560
551
  break;
561
-
562
552
  case STATE.PAN:
563
553
  if (scope.enablePan === false) return;
564
554
  handleMouseMovePan(event);
565
555
  break;
566
556
  }
567
557
  }
568
-
569
558
  function onMouseUp(event) {
570
559
  if (scope.enabled === false) return;
571
560
  handleMouseUp(event);
@@ -574,7 +563,6 @@ THREE.OrbitControls = function (object, domElement) {
574
563
  scope.dispatchEvent(endEvent);
575
564
  state = STATE.NONE;
576
565
  }
577
-
578
566
  function onMouseWheel(event) {
579
567
  if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE && state !== STATE.ROTATE) return;
580
568
  event.preventDefault();
@@ -583,16 +571,13 @@ THREE.OrbitControls = function (object, domElement) {
583
571
  handleMouseWheel(event);
584
572
  scope.dispatchEvent(endEvent);
585
573
  }
586
-
587
574
  function onKeyDown(event) {
588
575
  if (scope.enabled === false || scope.enableKeys === false || scope.enablePan === false) return;
589
576
  handleKeyDown(event);
590
577
  }
591
-
592
578
  function onTouchStart(event) {
593
579
  if (scope.enabled === false) return;
594
580
  event.preventDefault();
595
-
596
581
  switch (event.touches.length) {
597
582
  case 1:
598
583
  // one-fingered touch: rotate
@@ -600,28 +585,23 @@ THREE.OrbitControls = function (object, domElement) {
600
585
  handleTouchStartRotate(event);
601
586
  state = STATE.TOUCH_ROTATE;
602
587
  break;
603
-
604
588
  case 2:
605
589
  // two-fingered touch: dolly-pan
606
590
  if (scope.enableZoom === false && scope.enablePan === false) return;
607
591
  handleTouchStartDollyPan(event);
608
592
  state = STATE.TOUCH_DOLLY_PAN;
609
593
  break;
610
-
611
594
  default:
612
595
  state = STATE.NONE;
613
596
  }
614
-
615
597
  if (state !== STATE.NONE) {
616
598
  scope.dispatchEvent(startEvent);
617
599
  }
618
600
  }
619
-
620
601
  function onTouchMove(event) {
621
602
  if (scope.enabled === false) return;
622
603
  event.preventDefault();
623
604
  event.stopPropagation();
624
-
625
605
  switch (event.touches.length) {
626
606
  case 1:
627
607
  // one-fingered touch: rotate
@@ -630,7 +610,6 @@ THREE.OrbitControls = function (object, domElement) {
630
610
 
631
611
  handleTouchMoveRotate(event);
632
612
  break;
633
-
634
613
  case 2:
635
614
  // two-fingered touch: dolly-pan
636
615
  if (scope.enableZoom === false && scope.enablePan === false) return;
@@ -638,24 +617,22 @@ THREE.OrbitControls = function (object, domElement) {
638
617
 
639
618
  handleTouchMoveDollyPan(event);
640
619
  break;
641
-
642
620
  default:
643
621
  state = STATE.NONE;
644
622
  }
645
623
  }
646
-
647
624
  function onTouchEnd(event) {
648
625
  if (scope.enabled === false) return;
649
626
  handleTouchEnd(event);
650
627
  scope.dispatchEvent(endEvent);
651
628
  state = STATE.NONE;
652
629
  }
653
-
654
630
  function onContextMenu(event) {
655
631
  if (scope.enabled === false) return;
656
632
  event.preventDefault();
657
- } //
633
+ }
658
634
 
635
+ //
659
636
 
660
637
  scope.domElement.addEventListener("contextmenu", onContextMenu, false);
661
638
  scope.domElement.addEventListener("mousedown", onMouseDown, false);
@@ -664,11 +641,12 @@ THREE.OrbitControls = function (object, domElement) {
664
641
  scope.domElement.addEventListener("touchstart", onTouchStart, false);
665
642
  scope.domElement.addEventListener("touchend", onTouchEnd, false);
666
643
  scope.domElement.addEventListener("touchmove", onTouchMove, false);
667
- window.addEventListener("keydown", onKeyDown, false); // force an update at start
644
+ window.addEventListener("keydown", onKeyDown, false);
645
+
646
+ // force an update at start
668
647
 
669
648
  this.update();
670
649
  };
671
-
672
650
  THREE.OrbitControls.prototype = Object.create(THREE.EventDispatcher.prototype);
673
651
  THREE.OrbitControls.prototype.constructor = THREE.OrbitControls;
674
652
  Object.defineProperties(THREE.OrbitControls.prototype, {
@@ -679,6 +657,7 @@ Object.defineProperties(THREE.OrbitControls.prototype, {
679
657
  }
680
658
  },
681
659
  // backward compatibility
660
+
682
661
  noZoom: {
683
662
  get: function get() {
684
663
  console.warn("THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.");
@@ -739,7 +718,7 @@ Object.defineProperties(THREE.OrbitControls.prototype, {
739
718
  this.dampingFactor = value;
740
719
  }
741
720
  }
742
- }); // important: don't forget to export it
721
+ });
743
722
 
744
- var _default = THREE.OrbitControls;
745
- exports["default"] = _default;
723
+ // important: don't forget to export it
724
+ var _default = exports["default"] = THREE.OrbitControls;