three-stdlib 2.7.0 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
- import { Matrix4, EventDispatcher, EllipseCurve, BufferGeometry, Mesh, PerspectiveCamera, MathUtils, OrthographicCamera, Vector3, GridHelper, LineBasicMaterial, Line, Raycaster, Vector2, Quaternion, Group, Box3, Sphere } from 'three';
2
+ import { Matrix4, EventDispatcher, EllipseCurve, BufferGeometry, MathUtils, Vector3, GridHelper, LineBasicMaterial, Line, Raycaster, Vector2, Quaternion, Group, Box3, Sphere } from 'three';
3
3
 
4
4
  //trackball state
5
5
  const STATE = {
@@ -44,13 +44,13 @@ const _endEvent = {
44
44
  };
45
45
  /**
46
46
  *
47
- * @param {Camera} camera Virtual camera used in the scene
48
- * @param {HTMLElement} domElement Renderer's dom element
49
- * @param {Scene} scene The scene to be rendered
47
+ * @param {CamOrthographicCamera | PerspectiveCameraera} camera Virtual camera used in the scene
48
+ * @param {HTMLElement=null} domElement Renderer's dom element
49
+ * @param {Scene=null} scene The scene to be rendered
50
50
  */
51
51
 
52
52
  class ArcballControls extends EventDispatcher {
53
- constructor(_camera, domElement, scene = null) {
53
+ constructor(_camera, _domElement = null, scene = null) {
54
54
  super();
55
55
 
56
56
  _defineProperty(this, "camera", void 0);
@@ -143,8 +143,6 @@ class ArcballControls extends EventDispatcher {
143
143
 
144
144
  _defineProperty(this, "_downEvents", void 0);
145
145
 
146
- _defineProperty(this, "_downStart", void 0);
147
-
148
146
  _defineProperty(this, "_clickStart", void 0);
149
147
 
150
148
  _defineProperty(this, "_maxDownTime", void 0);
@@ -215,8 +213,6 @@ class ArcballControls extends EventDispatcher {
215
213
 
216
214
  _defineProperty(this, "enableZoom", void 0);
217
215
 
218
- _defineProperty(this, "enableGizmos", void 0);
219
-
220
216
  _defineProperty(this, "minDistance", void 0);
221
217
 
222
218
  _defineProperty(this, "maxDistance", void 0);
@@ -236,7 +232,7 @@ class ArcballControls extends EventDispatcher {
236
232
  _defineProperty(this, "onWindowResize", () => {
237
233
  const scale = (this._gizmos.scale.x + this._gizmos.scale.y + this._gizmos.scale.z) / 3;
238
234
 
239
- if (this.camera !== null) {
235
+ if (this.camera) {
240
236
  const tbRadius = this.calculateTbRadius(this.camera);
241
237
 
242
238
  if (tbRadius !== undefined) {
@@ -252,10 +248,7 @@ class ArcballControls extends EventDispatcher {
252
248
 
253
249
  for (const gizmo in this._gizmos.children) {
254
250
  const child = this._gizmos.children[gizmo];
255
-
256
- if (child instanceof Mesh) {
257
- child.geometry = curveGeometry;
258
- }
251
+ child.geometry = curveGeometry;
259
252
  }
260
253
 
261
254
  this.dispatchEvent(_changeEvent);
@@ -288,8 +281,6 @@ class ArcballControls extends EventDispatcher {
288
281
  this._downValid = true;
289
282
 
290
283
  this._downEvents.push(event);
291
-
292
- this._downStart = performance.now();
293
284
  } else {
294
285
  this._downValid = false;
295
286
  }
@@ -334,7 +325,7 @@ class ArcballControls extends EventDispatcher {
334
325
 
335
326
  this._mouseOp = this.getOpFromAction(event.button, modifier);
336
327
 
337
- if (this._mouseOp != null) {
328
+ if (this._mouseOp) {
338
329
  window.addEventListener('pointermove', this.onPointerMove);
339
330
  window.addEventListener('pointerup', this.onPointerUp); //singleStart
340
331
 
@@ -392,7 +383,7 @@ class ArcballControls extends EventDispatcher {
392
383
 
393
384
  const mouseOpState = this.getOpStateFromAction(this._button, modifier);
394
385
 
395
- if (mouseOpState != null) {
386
+ if (mouseOpState) {
396
387
  this.onSinglePanMove(event, mouseOpState);
397
388
  }
398
389
  } //checkDistance
@@ -505,7 +496,9 @@ class ArcballControls extends EventDispatcher {
505
496
  });
506
497
 
507
498
  _defineProperty(this, "onWheel", event => {
508
- if (this.enabled && this.enableZoom) {
499
+ var _this$camera3;
500
+
501
+ if (this.enabled && this.enableZoom && this.domElement) {
509
502
  let modifier = null;
510
503
 
511
504
  if (event.ctrlKey || event.metaKey) {
@@ -516,7 +509,7 @@ class ArcballControls extends EventDispatcher {
516
509
 
517
510
  const mouseOp = this.getOpFromAction('WHEEL', modifier);
518
511
 
519
- if (mouseOp != null) {
512
+ if (mouseOp) {
520
513
  event.preventDefault();
521
514
  this.dispatchEvent(_startEvent);
522
515
  const notchDeltaY = 125; //distance of one notch of mouse wheel
@@ -541,13 +534,17 @@ class ArcballControls extends EventDispatcher {
541
534
  }
542
535
 
543
536
  if (this.cursorZoom && this.enablePan) {
537
+ var _this$camera, _this$camera2;
538
+
544
539
  let scalePoint;
545
540
 
546
- if (this.camera instanceof OrthographicCamera && this.camera.isOrthographicCamera) {
541
+ if (((_this$camera = this.camera) === null || _this$camera === void 0 ? void 0 : _this$camera.type) === 'OrthographicCamera') {
547
542
  var _this$unprojectOnTbPl;
548
543
 
549
544
  scalePoint = (_this$unprojectOnTbPl = this.unprojectOnTbPlane(this.camera, event.clientX, event.clientY, this.domElement)) === null || _this$unprojectOnTbPl === void 0 ? void 0 : _this$unprojectOnTbPl.applyQuaternion(this.camera.quaternion).multiplyScalar(1 / this.camera.zoom).add(this._gizmos.position);
550
- } else if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
545
+ }
546
+
547
+ if (((_this$camera2 = this.camera) === null || _this$camera2 === void 0 ? void 0 : _this$camera2.type) === 'PerspectiveCamera') {
551
548
  var _this$unprojectOnTbPl2;
552
549
 
553
550
  scalePoint = (_this$unprojectOnTbPl2 = this.unprojectOnTbPlane(this.camera, event.clientX, event.clientY, this.domElement)) === null || _this$unprojectOnTbPl2 === void 0 ? void 0 : _this$unprojectOnTbPl2.applyQuaternion(this.camera.quaternion).add(this._gizmos.position);
@@ -558,7 +555,7 @@ class ArcballControls extends EventDispatcher {
558
555
  this.applyTransformMatrix(this.applyScale(size, this._gizmos.position));
559
556
  }
560
557
 
561
- if (this._grid != null) {
558
+ if (this._grid) {
562
559
  this.disposeGrid();
563
560
  this.drawGrid();
564
561
  }
@@ -569,7 +566,7 @@ class ArcballControls extends EventDispatcher {
569
566
  break;
570
567
 
571
568
  case 'FOV':
572
- if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
569
+ if (((_this$camera3 = this.camera) === null || _this$camera3 === void 0 ? void 0 : _this$camera3.type) === 'PerspectiveCamera') {
573
570
  this.updateTbState(STATE.FOV, true); //Vertigo effect
574
571
  // fov / 2
575
572
  // |\
@@ -617,7 +614,7 @@ class ArcballControls extends EventDispatcher {
617
614
  this.applyTransformMatrix(this.applyScale(size, this._gizmos.position, false));
618
615
  }
619
616
 
620
- if (this._grid != null) {
617
+ if (this._grid) {
621
618
  this.disposeGrid();
622
619
  this.drawGrid();
623
620
  }
@@ -644,15 +641,15 @@ class ArcballControls extends EventDispatcher {
644
641
  });
645
642
 
646
643
  _defineProperty(this, "onSinglePanStart", (event, operation) => {
647
- if (this.enabled) {
644
+ var _this$camera4;
645
+
646
+ if (this.enabled && this.domElement) {
648
647
  this.dispatchEvent(_startEvent);
649
648
  this.setCenter(event.clientX, event.clientY);
650
649
 
651
650
  switch (operation) {
652
651
  case 'PAN':
653
- if (!this.enablePan) {
654
- return;
655
- }
652
+ if (!this.enablePan) return;
656
653
 
657
654
  if (this._animationId != -1) {
658
655
  cancelAnimationFrame(this._animationId);
@@ -662,7 +659,7 @@ class ArcballControls extends EventDispatcher {
662
659
  this.dispatchEvent(_changeEvent);
663
660
  }
664
661
 
665
- if (this.camera !== null) {
662
+ if (this.camera) {
666
663
  this.updateTbState(STATE.PAN, true);
667
664
  const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement);
668
665
 
@@ -679,9 +676,7 @@ class ArcballControls extends EventDispatcher {
679
676
  break;
680
677
 
681
678
  case 'ROTATE':
682
- if (!this.enableRotate) {
683
- return;
684
- }
679
+ if (!this.enableRotate) return;
685
680
 
686
681
  if (this._animationId != -1) {
687
682
  cancelAnimationFrame(this._animationId);
@@ -689,7 +684,7 @@ class ArcballControls extends EventDispatcher {
689
684
  this._timeStart = -1;
690
685
  }
691
686
 
692
- if (this.camera !== null) {
687
+ if (this.camera) {
693
688
  this.updateTbState(STATE.ROTATE, true);
694
689
  const rayDir = this.unprojectOnTbSurface(this.camera, _center.x, _center.y, this.domElement, this._tbRadius);
695
690
 
@@ -716,30 +711,28 @@ class ArcballControls extends EventDispatcher {
716
711
  break;
717
712
 
718
713
  case 'FOV':
719
- if (!(this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) || !this.enableZoom) {
720
- return;
721
- }
714
+ if (!this.enableZoom) return;
722
715
 
723
- if (this._animationId != -1) {
724
- cancelAnimationFrame(this._animationId);
725
- this._animationId = -1;
726
- this._timeStart = -1;
727
- this.activateGizmos(false);
728
- this.dispatchEvent(_changeEvent);
729
- }
716
+ if (((_this$camera4 = this.camera) === null || _this$camera4 === void 0 ? void 0 : _this$camera4.type) === 'PerspectiveCamera') {
717
+ if (this._animationId != -1) {
718
+ cancelAnimationFrame(this._animationId);
719
+ this._animationId = -1;
720
+ this._timeStart = -1;
721
+ this.activateGizmos(false);
722
+ this.dispatchEvent(_changeEvent);
723
+ }
730
724
 
731
- this.updateTbState(STATE.FOV, true);
725
+ this.updateTbState(STATE.FOV, true);
732
726
 
733
- this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
727
+ this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
734
728
 
735
- this._currentCursorPosition.copy(this._startCursorPosition);
729
+ this._currentCursorPosition.copy(this._startCursorPosition);
730
+ }
736
731
 
737
732
  break;
738
733
 
739
734
  case 'ZOOM':
740
- if (!this.enableZoom) {
741
- return;
742
- }
735
+ if (!this.enableZoom) return;
743
736
 
744
737
  if (this._animationId != -1) {
745
738
  cancelAnimationFrame(this._animationId);
@@ -761,13 +754,15 @@ class ArcballControls extends EventDispatcher {
761
754
  });
762
755
 
763
756
  _defineProperty(this, "onSinglePanMove", (event, opState) => {
764
- if (this.enabled) {
757
+ var _this$camera5;
758
+
759
+ if (this.enabled && this.domElement) {
765
760
  const restart = opState != this._state;
766
761
  this.setCenter(event.clientX, event.clientY);
767
762
 
768
763
  switch (opState) {
769
764
  case STATE.PAN:
770
- if (this.enablePan && this.camera !== null) {
765
+ if (this.enablePan && this.camera) {
771
766
  if (restart) {
772
767
  //switch to pan operation
773
768
  this.dispatchEvent(_endEvent);
@@ -799,7 +794,7 @@ class ArcballControls extends EventDispatcher {
799
794
  break;
800
795
 
801
796
  case STATE.ROTATE:
802
- if (this.enableRotate && this.camera !== null) {
797
+ if (this.enableRotate && this.camera) {
803
798
  if (restart) {
804
799
  //switch to rotate operation
805
800
  this.dispatchEvent(_endEvent);
@@ -889,7 +884,7 @@ class ArcballControls extends EventDispatcher {
889
884
  break;
890
885
 
891
886
  case STATE.FOV:
892
- if (this.enableZoom && this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
887
+ if (this.enableZoom && ((_this$camera5 = this.camera) === null || _this$camera5 === void 0 ? void 0 : _this$camera5.type) === 'PerspectiveCamera') {
893
888
  if (restart) {
894
889
  //switch to fov operation
895
890
  this.dispatchEvent(_endEvent);
@@ -998,12 +993,12 @@ class ArcballControls extends EventDispatcher {
998
993
  });
999
994
 
1000
995
  _defineProperty(this, "onDoubleTap", event => {
1001
- if (this.enabled && this.enablePan && this.scene != null && this.camera !== null) {
996
+ if (this.enabled && this.enablePan && this.scene && this.camera && this.domElement) {
1002
997
  this.dispatchEvent(_startEvent);
1003
998
  this.setCenter(event.clientX, event.clientY);
1004
999
  const hitP = this.unprojectOnObj(this.getCursorNDC(_center.x, _center.y, this.domElement), this.camera);
1005
1000
 
1006
- if (hitP != null && this.enableAnimations) {
1001
+ if (hitP && this.enableAnimations) {
1007
1002
  const self = this;
1008
1003
 
1009
1004
  if (this._animationId != -1) {
@@ -1015,7 +1010,7 @@ class ArcballControls extends EventDispatcher {
1015
1010
  self.updateTbState(STATE.ANIMATION_FOCUS, true);
1016
1011
  self.onFocusAnim(t, hitP, self._cameraMatrixState, self._gizmoMatrixState);
1017
1012
  });
1018
- } else if (hitP != null && !this.enableAnimations) {
1013
+ } else if (hitP && !this.enableAnimations) {
1019
1014
  this.updateTbState(STATE.FOCUS, true);
1020
1015
  this.focus(hitP, this.scaleFactor);
1021
1016
  this.updateTbState(STATE.IDLE, false);
@@ -1027,7 +1022,7 @@ class ArcballControls extends EventDispatcher {
1027
1022
  });
1028
1023
 
1029
1024
  _defineProperty(this, "onDoublePanStart", () => {
1030
- if (this.enabled && this.enablePan && this.camera !== null) {
1025
+ if (this.enabled && this.enablePan && this.camera && this.domElement) {
1031
1026
  this.dispatchEvent(_startEvent);
1032
1027
  this.updateTbState(STATE.PAN, true);
1033
1028
  this.setCenter((this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2, (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2);
@@ -1044,7 +1039,7 @@ class ArcballControls extends EventDispatcher {
1044
1039
  });
1045
1040
 
1046
1041
  _defineProperty(this, "onDoublePanMove", () => {
1047
- if (this.enabled && this.enablePan && this.camera !== null) {
1042
+ if (this.enabled && this.enablePan && this.camera && this.domElement) {
1048
1043
  this.setCenter((this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2, (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2);
1049
1044
 
1050
1045
  if (this._state != STATE.PAN) {
@@ -1067,14 +1062,14 @@ class ArcballControls extends EventDispatcher {
1067
1062
 
1068
1063
  _defineProperty(this, "onRotateStart", () => {
1069
1064
  if (this.enabled && this.enableRotate) {
1070
- var _this$camera;
1065
+ var _this$camera6;
1071
1066
 
1072
1067
  this.dispatchEvent(_startEvent);
1073
1068
  this.updateTbState(STATE.ZROTATE, true); //this._startFingerRotation = event.rotation;
1074
1069
 
1075
1070
  this._startFingerRotation = this.getAngle(this._touchCurrent[1], this._touchCurrent[0]) + this.getAngle(this._touchStart[1], this._touchStart[0]);
1076
1071
  this._currentFingerRotation = this._startFingerRotation;
1077
- (_this$camera = this.camera) === null || _this$camera === void 0 ? void 0 : _this$camera.getWorldDirection(this._rotationAxis); //rotation axis
1072
+ (_this$camera6 = this.camera) === null || _this$camera6 === void 0 ? void 0 : _this$camera6.getWorldDirection(this._rotationAxis); //rotation axis
1078
1073
 
1079
1074
  if (!this.enablePan && !this.enableZoom) {
1080
1075
  this.activateGizmos(true);
@@ -1083,7 +1078,7 @@ class ArcballControls extends EventDispatcher {
1083
1078
  });
1084
1079
 
1085
1080
  _defineProperty(this, "onRotateMove", () => {
1086
- if (this.enabled && this.enableRotate && this.camera !== null) {
1081
+ if (this.enabled && this.enableRotate && this.camera && this.domElement) {
1087
1082
  this.setCenter((this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2, (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2);
1088
1083
  let rotationPoint;
1089
1084
 
@@ -1097,7 +1092,7 @@ class ArcballControls extends EventDispatcher {
1097
1092
 
1098
1093
  if (!this.enablePan) {
1099
1094
  rotationPoint = new Vector3().setFromMatrixPosition(this._gizmoMatrixState);
1100
- } else if (this.camera instanceof PerspectiveCamera || this.camera instanceof OrthographicCamera) {
1095
+ } else if (this.camera) {
1101
1096
  var _this$unprojectOnTbPl3;
1102
1097
 
1103
1098
  this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);
@@ -1132,7 +1127,7 @@ class ArcballControls extends EventDispatcher {
1132
1127
  });
1133
1128
 
1134
1129
  _defineProperty(this, "onPinchMove", () => {
1135
- if (this.enabled && this.enableZoom) {
1130
+ if (this.enabled && this.enableZoom && this.domElement) {
1136
1131
  this.setCenter((this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2, (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2);
1137
1132
  const minDistance = 12; //minimum distance between fingers (in css pixels)
1138
1133
 
@@ -1148,11 +1143,13 @@ class ArcballControls extends EventDispatcher {
1148
1143
  if (!this.enablePan) {
1149
1144
  scalePoint = this._gizmos.position;
1150
1145
  } else {
1151
- if (this.camera instanceof OrthographicCamera && this.camera.isOrthographicCamera) {
1146
+ var _this$camera7, _this$camera8;
1147
+
1148
+ if (((_this$camera7 = this.camera) === null || _this$camera7 === void 0 ? void 0 : _this$camera7.type) === 'OrthographicCamera') {
1152
1149
  var _this$unprojectOnTbPl4;
1153
1150
 
1154
1151
  scalePoint = (_this$unprojectOnTbPl4 = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement)) === null || _this$unprojectOnTbPl4 === void 0 ? void 0 : _this$unprojectOnTbPl4.applyQuaternion(this.camera.quaternion).multiplyScalar(1 / this.camera.zoom).add(this._gizmos.position);
1155
- } else if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
1152
+ } else if (((_this$camera8 = this.camera) === null || _this$camera8 === void 0 ? void 0 : _this$camera8.type) === 'PerspectiveCamera') {
1156
1153
  var _this$unprojectOnTbPl5;
1157
1154
 
1158
1155
  scalePoint = (_this$unprojectOnTbPl5 = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement)) === null || _this$unprojectOnTbPl5 === void 0 ? void 0 : _this$unprojectOnTbPl5.applyQuaternion(this.camera.quaternion).add(this._gizmos.position);
@@ -1173,7 +1170,7 @@ class ArcballControls extends EventDispatcher {
1173
1170
  });
1174
1171
 
1175
1172
  _defineProperty(this, "onTriplePanStart", () => {
1176
- if (this.enabled && this.enableZoom) {
1173
+ if (this.enabled && this.enableZoom && this.domElement) {
1177
1174
  this.dispatchEvent(_startEvent);
1178
1175
  this.updateTbState(STATE.SCALE, true); //const center = event.center;
1179
1176
 
@@ -1195,7 +1192,7 @@ class ArcballControls extends EventDispatcher {
1195
1192
  });
1196
1193
 
1197
1194
  _defineProperty(this, "onTriplePanMove", () => {
1198
- if (this.enabled && this.enableZoom && this.camera !== null) {
1195
+ if (this.enabled && this.enableZoom && this.camera && this.domElement) {
1199
1196
  // fov / 2
1200
1197
  // |\
1201
1198
  // | \
@@ -1278,18 +1275,6 @@ class ArcballControls extends EventDispatcher {
1278
1275
  this.setMouseAction('FOV', 1, 'SHIFT');
1279
1276
  });
1280
1277
 
1281
- _defineProperty(this, "compareMouseAction", (action1, action2) => {
1282
- if (action1.operation == action2.operation) {
1283
- if (action1.mouse == action2.mouse && action1.key == action2.key) {
1284
- return true;
1285
- } else {
1286
- return false;
1287
- }
1288
- } else {
1289
- return false;
1290
- }
1291
- });
1292
-
1293
1278
  _defineProperty(this, "setMouseAction", (operation, mouse, key = null) => {
1294
1279
  const operationInput = ['PAN', 'ROTATE', 'ZOOM', 'FOV'];
1295
1280
  const mouseInput = [0, 1, 2, 'WHEEL'];
@@ -1344,17 +1329,6 @@ class ArcballControls extends EventDispatcher {
1344
1329
  return true;
1345
1330
  });
1346
1331
 
1347
- _defineProperty(this, "unsetMouseAction", (mouse, key = null) => {
1348
- for (let i = 0; i < this.mouseActions.length; i++) {
1349
- if (this.mouseActions[i].mouse == mouse && this.mouseActions[i].key == key) {
1350
- this.mouseActions.splice(i, 1);
1351
- return true;
1352
- }
1353
- }
1354
-
1355
- return false;
1356
- });
1357
-
1358
1332
  _defineProperty(this, "getOpFromAction", (mouse, key) => {
1359
1333
  let action;
1360
1334
 
@@ -1366,7 +1340,7 @@ class ArcballControls extends EventDispatcher {
1366
1340
  }
1367
1341
  }
1368
1342
 
1369
- if (key != null) {
1343
+ if (key) {
1370
1344
  for (let i = 0; i < this.mouseActions.length; i++) {
1371
1345
  action = this.mouseActions[i];
1372
1346
 
@@ -1390,7 +1364,7 @@ class ArcballControls extends EventDispatcher {
1390
1364
  }
1391
1365
  }
1392
1366
 
1393
- if (key != null) {
1367
+ if (key) {
1394
1368
  for (let i = 0; i < this.mouseActions.length; i++) {
1395
1369
  action = this.mouseActions[i];
1396
1370
 
@@ -1446,19 +1420,19 @@ class ArcballControls extends EventDispatcher {
1446
1420
  const factor = 0.67;
1447
1421
  const distance = camera.position.distanceTo(this._gizmos.position);
1448
1422
 
1449
- if (camera.type == 'PerspectiveCamera' && camera instanceof PerspectiveCamera) {
1423
+ if (camera.type == 'PerspectiveCamera') {
1450
1424
  const halfFovV = MathUtils.DEG2RAD * camera.fov * 0.5; //vertical fov/2 in radians
1451
1425
 
1452
1426
  const halfFovH = Math.atan(camera.aspect * Math.tan(halfFovV)); //horizontal fov/2 in radians
1453
1427
 
1454
1428
  return Math.tan(Math.min(halfFovV, halfFovH)) * distance * factor;
1455
- } else if (camera.type == 'OrthographicCamera' && camera instanceof OrthographicCamera) {
1429
+ } else if (camera.type == 'OrthographicCamera') {
1456
1430
  return Math.min(camera.top, camera.right) * factor;
1457
1431
  }
1458
1432
  });
1459
1433
 
1460
1434
  _defineProperty(this, "focus", (point, size, amount = 1) => {
1461
- if (this.camera !== null) {
1435
+ if (this.camera) {
1462
1436
  const focusPoint = point.clone(); //move center of camera (along with gizmos) towards point of interest
1463
1437
 
1464
1438
  focusPoint.sub(this._gizmos.position).multiplyScalar(amount);
@@ -1489,19 +1463,21 @@ class ArcballControls extends EventDispatcher {
1489
1463
  });
1490
1464
 
1491
1465
  _defineProperty(this, "drawGrid", () => {
1492
- if (this.scene != null) {
1466
+ if (this.scene) {
1467
+ var _this$camera9, _this$camera10;
1468
+
1493
1469
  const color = 0x888888;
1494
1470
  const multiplier = 3;
1495
1471
  let size, divisions, maxLength, tick;
1496
1472
 
1497
- if (this.camera instanceof OrthographicCamera && this.camera.isOrthographicCamera) {
1473
+ if (((_this$camera9 = this.camera) === null || _this$camera9 === void 0 ? void 0 : _this$camera9.type) === 'OrthographicCamera') {
1498
1474
  const width = this.camera.right - this.camera.left;
1499
1475
  const height = this.camera.bottom - this.camera.top;
1500
1476
  maxLength = Math.max(width, height);
1501
1477
  tick = maxLength / 20;
1502
1478
  size = maxLength / this.camera.zoom * multiplier;
1503
1479
  divisions = size / tick * this.camera.zoom;
1504
- } else if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
1480
+ } else if (((_this$camera10 = this.camera) === null || _this$camera10 === void 0 ? void 0 : _this$camera10.type) === 'PerspectiveCamera') {
1505
1481
  const distance = this.camera.position.distanceTo(this._gizmos.position);
1506
1482
  const halfFovV = MathUtils.DEG2RAD * this.camera.fov * 0.5;
1507
1483
  const halfFovH = Math.atan(this.camera.aspect * Math.tan(halfFovV));
@@ -1511,7 +1487,7 @@ class ArcballControls extends EventDispatcher {
1511
1487
  divisions = size / tick;
1512
1488
  }
1513
1489
 
1514
- if (this._grid == null && this.camera !== null) {
1490
+ if (this._grid == null && this.camera) {
1515
1491
  this._grid = new GridHelper(size, divisions, color, color);
1516
1492
 
1517
1493
  this._grid.position.copy(this._gizmos.position);
@@ -1527,17 +1503,34 @@ class ArcballControls extends EventDispatcher {
1527
1503
  }
1528
1504
  });
1529
1505
 
1506
+ _defineProperty(this, "connect", domElement => {
1507
+ // https://github.com/mrdoob/three.js/issues/20575
1508
+ if (domElement === document) {
1509
+ console.error('THREE.ArcballControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
1510
+ }
1511
+
1512
+ this.domElement = domElement; // disables touch scroll
1513
+ // touch-action needs to be defined for pointer events to work on mobile
1514
+ // https://stackoverflow.com/a/48254578
1515
+
1516
+ this.domElement.style.touchAction = 'none';
1517
+ this.domElement.addEventListener('contextmenu', this.onContextMenu);
1518
+ this.domElement.addEventListener('pointerdown', this.onPointerDown);
1519
+ this.domElement.addEventListener('pointercancel', this.onPointerCancel);
1520
+ this.domElement.addEventListener('wheel', this.onWheel);
1521
+ });
1522
+
1530
1523
  _defineProperty(this, "dispose", () => {
1531
- var _this$scene;
1524
+ var _this$domElement, _this$domElement2, _this$domElement3, _this$domElement4, _this$scene;
1532
1525
 
1533
1526
  if (this._animationId != -1) {
1534
1527
  window.cancelAnimationFrame(this._animationId);
1535
1528
  }
1536
1529
 
1537
- this.domElement.removeEventListener('pointerdown', this.onPointerDown);
1538
- this.domElement.removeEventListener('pointercancel', this.onPointerCancel);
1539
- this.domElement.removeEventListener('wheel', this.onWheel);
1540
- this.domElement.removeEventListener('contextmenu', this.onContextMenu);
1530
+ (_this$domElement = this.domElement) === null || _this$domElement === void 0 ? void 0 : _this$domElement.removeEventListener('pointerdown', this.onPointerDown);
1531
+ (_this$domElement2 = this.domElement) === null || _this$domElement2 === void 0 ? void 0 : _this$domElement2.removeEventListener('pointercancel', this.onPointerCancel);
1532
+ (_this$domElement3 = this.domElement) === null || _this$domElement3 === void 0 ? void 0 : _this$domElement3.removeEventListener('wheel', this.onWheel);
1533
+ (_this$domElement4 = this.domElement) === null || _this$domElement4 === void 0 ? void 0 : _this$domElement4.removeEventListener('contextmenu', this.onContextMenu);
1541
1534
  window.removeEventListener('pointermove', this.onPointerMove);
1542
1535
  window.removeEventListener('pointerup', this.onPointerUp);
1543
1536
  window.removeEventListener('resize', this.onWindowResize);
@@ -1547,7 +1540,7 @@ class ArcballControls extends EventDispatcher {
1547
1540
  });
1548
1541
 
1549
1542
  _defineProperty(this, "disposeGrid", () => {
1550
- if (this._grid != null && this.scene != null) {
1543
+ if (this._grid && this.scene) {
1551
1544
  this.scene.remove(this._grid);
1552
1545
  this._grid = null;
1553
1546
  }
@@ -1558,29 +1551,9 @@ class ArcballControls extends EventDispatcher {
1558
1551
  });
1559
1552
 
1560
1553
  _defineProperty(this, "activateGizmos", isActive => {
1561
- const gizmoX = this._gizmos.children[0];
1562
- const gizmoY = this._gizmos.children[1];
1563
- const gizmoZ = this._gizmos.children[2];
1564
-
1565
- if (isActive) {
1566
- gizmoX.material.setValues({
1567
- opacity: 1
1568
- });
1569
- gizmoY.material.setValues({
1570
- opacity: 1
1571
- });
1572
- gizmoZ.material.setValues({
1573
- opacity: 1
1574
- });
1575
- } else {
1576
- gizmoX.material.setValues({
1577
- opacity: 0.6
1578
- });
1579
- gizmoY.material.setValues({
1580
- opacity: 0.6
1581
- });
1582
- gizmoZ.material.setValues({
1583
- opacity: 0.6
1554
+ for (const gizmo of this._gizmos.children) {
1555
+ gizmo.material.setValues({
1556
+ opacity: isActive ? 1 : 0.6
1584
1557
  });
1585
1558
  }
1586
1559
  });
@@ -1596,9 +1569,11 @@ class ArcballControls extends EventDispatcher {
1596
1569
  });
1597
1570
 
1598
1571
  _defineProperty(this, "getCursorPosition", (cursorX, cursorY, canvas) => {
1572
+ var _this$camera11;
1573
+
1599
1574
  this._v2_1.copy(this.getCursorNDC(cursorX, cursorY, canvas));
1600
1575
 
1601
- if (this.camera instanceof OrthographicCamera) {
1576
+ if (((_this$camera11 = this.camera) === null || _this$camera11 === void 0 ? void 0 : _this$camera11.type) === 'OrthographicCamera') {
1602
1577
  this._v2_1.x *= (this.camera.right - this.camera.left) * 0.5;
1603
1578
  this._v2_1.y *= (this.camera.top - this.camera.bottom) * 0.5;
1604
1579
  }
@@ -1607,11 +1582,11 @@ class ArcballControls extends EventDispatcher {
1607
1582
  });
1608
1583
 
1609
1584
  _defineProperty(this, "setCamera", camera => {
1610
- if (camera instanceof PerspectiveCamera || camera instanceof OrthographicCamera) {
1585
+ if (camera) {
1611
1586
  camera.lookAt(this.target);
1612
1587
  camera.updateMatrix(); //setting state
1613
1588
 
1614
- if ((camera === null || camera === void 0 ? void 0 : camera.type) == 'PerspectiveCamera' && camera instanceof PerspectiveCamera) {
1589
+ if ((camera === null || camera === void 0 ? void 0 : camera.type) == 'PerspectiveCamera') {
1615
1590
  this._fov0 = camera.fov;
1616
1591
  this._fovState = camera.fov;
1617
1592
  }
@@ -1636,11 +1611,7 @@ class ArcballControls extends EventDispatcher {
1636
1611
  this._upState.copy(camera.up);
1637
1612
 
1638
1613
  this.camera = camera;
1639
-
1640
- if (this.camera instanceof PerspectiveCamera || this.camera instanceof OrthographicCamera) {
1641
- this.camera.updateProjectionMatrix();
1642
- } //making gizmos
1643
-
1614
+ this.camera.updateProjectionMatrix(); //making gizmos
1644
1615
 
1645
1616
  const tbRadius = this.calculateTbRadius(camera);
1646
1617
 
@@ -1689,7 +1660,7 @@ class ArcballControls extends EventDispatcher {
1689
1660
 
1690
1661
  this._gizmoMatrixState.copy(this._gizmoMatrixState0);
1691
1662
 
1692
- if ((this.camera instanceof PerspectiveCamera || this.camera instanceof OrthographicCamera) && this.camera.zoom != 1) {
1663
+ if (this.camera && this.camera.zoom != 1) {
1693
1664
  //adapt gizmos size to camera zoom
1694
1665
  const size = 1 / this.camera.zoom;
1695
1666
 
@@ -1798,13 +1769,15 @@ class ArcballControls extends EventDispatcher {
1798
1769
  });
1799
1770
 
1800
1771
  _defineProperty(this, "pan", (p0, p1, adjust = false) => {
1801
- if (this.camera !== null) {
1772
+ if (this.camera) {
1802
1773
  const movement = p0.clone().sub(p1);
1803
1774
 
1804
- if (this.camera instanceof OrthographicCamera && this.camera.isOrthographicCamera) {
1775
+ if (this.camera.type === 'OrthographicCamera') {
1805
1776
  //adjust movement amount
1806
1777
  movement.multiplyScalar(1 / this.camera.zoom);
1807
- } else if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera && adjust) {
1778
+ }
1779
+
1780
+ if (this.camera.type === 'PerspectiveCamera' && adjust) {
1808
1781
  //adjust movement amount
1809
1782
  this._v3_1.setFromMatrixPosition(this._cameraMatrixState0); //camera's initial position
1810
1783
 
@@ -1827,10 +1800,10 @@ class ArcballControls extends EventDispatcher {
1827
1800
  });
1828
1801
 
1829
1802
  _defineProperty(this, "reset", () => {
1830
- if (this.camera instanceof PerspectiveCamera || this.camera instanceof OrthographicCamera) {
1803
+ if (this.camera) {
1831
1804
  this.camera.zoom = this._zoom0;
1832
1805
 
1833
- if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
1806
+ if (this.camera.type === 'PerspectiveCamera') {
1834
1807
  this.camera.fov = this._fov0;
1835
1808
  }
1836
1809
 
@@ -1883,10 +1856,10 @@ class ArcballControls extends EventDispatcher {
1883
1856
  });
1884
1857
 
1885
1858
  _defineProperty(this, "copyState", () => {
1886
- let state;
1859
+ if (this.camera) {
1860
+ var _this$camera12;
1887
1861
 
1888
- if (this.camera instanceof OrthographicCamera && this.camera.isOrthographicCamera) {
1889
- state = JSON.stringify({
1862
+ const state = JSON.stringify(((_this$camera12 = this.camera) === null || _this$camera12 === void 0 ? void 0 : _this$camera12.type) === 'OrthographicCamera' ? {
1890
1863
  arcballState: {
1891
1864
  cameraFar: this.camera.far,
1892
1865
  cameraMatrix: this.camera.matrix,
@@ -1895,9 +1868,7 @@ class ArcballControls extends EventDispatcher {
1895
1868
  cameraZoom: this.camera.zoom,
1896
1869
  gizmoMatrix: this._gizmos.matrix
1897
1870
  }
1898
- });
1899
- } else if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
1900
- state = JSON.stringify({
1871
+ } : {
1901
1872
  arcballState: {
1902
1873
  cameraFar: this.camera.far,
1903
1874
  cameraFov: this.camera.fov,
@@ -1908,9 +1879,6 @@ class ArcballControls extends EventDispatcher {
1908
1879
  gizmoMatrix: this._gizmos.matrix
1909
1880
  }
1910
1881
  });
1911
- }
1912
-
1913
- if (state !== undefined) {
1914
1882
  navigator.clipboard.writeText(state);
1915
1883
  }
1916
1884
  });
@@ -1923,28 +1891,29 @@ class ArcballControls extends EventDispatcher {
1923
1891
  });
1924
1892
 
1925
1893
  _defineProperty(this, "saveState", () => {
1926
- if (this.camera instanceof PerspectiveCamera || this.camera instanceof OrthographicCamera) {
1927
- this._cameraMatrixState0.copy(this.camera.matrix);
1894
+ if (!this.camera) return;
1928
1895
 
1929
- this._gizmoMatrixState0.copy(this._gizmos.matrix);
1896
+ this._cameraMatrixState0.copy(this.camera.matrix);
1930
1897
 
1931
- this._nearPos = this.camera.near;
1932
- this._farPos = this.camera.far;
1933
- this._zoom0 = this.camera.zoom;
1898
+ this._gizmoMatrixState0.copy(this._gizmos.matrix);
1934
1899
 
1935
- this._up0.copy(this.camera.up);
1900
+ this._nearPos = this.camera.near;
1901
+ this._farPos = this.camera.far;
1902
+ this._zoom0 = this.camera.zoom;
1936
1903
 
1937
- if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
1938
- this._fov0 = this.camera.fov;
1939
- }
1904
+ this._up0.copy(this.camera.up);
1905
+
1906
+ if (this.camera.type === 'PerspectiveCamera') {
1907
+ this._fov0 = this.camera.fov;
1940
1908
  }
1941
1909
  });
1942
1910
 
1943
1911
  _defineProperty(this, "applyScale", (size, point, scaleGizmos = true) => {
1912
+ if (!this.camera) return;
1944
1913
  const scalePoint = point.clone();
1945
1914
  let sizeInverse = 1 / size;
1946
1915
 
1947
- if (this.camera instanceof OrthographicCamera && this.camera.isOrthographicCamera) {
1916
+ if (this.camera.type === 'OrthographicCamera') {
1948
1917
  //camera zoom
1949
1918
  this.camera.zoom = this._zoomState;
1950
1919
  this.camera.zoom *= size; //check min and max zoom
@@ -1982,7 +1951,9 @@ class ArcballControls extends EventDispatcher {
1982
1951
 
1983
1952
  this.setTransformationMatrices(this._m4_1, this._m4_2);
1984
1953
  return _transformation;
1985
- } else if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
1954
+ }
1955
+
1956
+ if (this.camera.type === 'PerspectiveCamera') {
1986
1957
  this._v3_1.setFromMatrixPosition(this._cameraMatrixState);
1987
1958
 
1988
1959
  this._v3_2.setFromMatrixPosition(this._gizmoMatrixState); //move camera
@@ -2035,14 +2006,16 @@ class ArcballControls extends EventDispatcher {
2035
2006
  });
2036
2007
 
2037
2008
  _defineProperty(this, "setFov", value => {
2038
- if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
2009
+ var _this$camera13;
2010
+
2011
+ if (((_this$camera13 = this.camera) === null || _this$camera13 === void 0 ? void 0 : _this$camera13.type) === 'PerspectiveCamera') {
2039
2012
  this.camera.fov = MathUtils.clamp(value, this.minFov, this.maxFov);
2040
2013
  this.camera.updateProjectionMatrix();
2041
2014
  }
2042
2015
  });
2043
2016
 
2044
2017
  _defineProperty(this, "setTarget", (x, y, z) => {
2045
- if (this.camera !== null) {
2018
+ if (this.camera) {
2046
2019
  this.target.set(x, y, z);
2047
2020
 
2048
2021
  this._gizmos.position.set(x, y, z); //for correct radius calculation
@@ -2085,17 +2058,16 @@ class ArcballControls extends EventDispatcher {
2085
2058
  });
2086
2059
 
2087
2060
  _defineProperty(this, "unprojectOnObj", (cursor, camera) => {
2088
- if ((camera instanceof PerspectiveCamera || camera instanceof OrthographicCamera) && this.scene != null) {
2089
- const raycaster = new Raycaster();
2090
- raycaster.near = camera.near;
2091
- raycaster.far = camera.far;
2092
- raycaster.setFromCamera(cursor, camera);
2093
- const intersect = raycaster.intersectObjects(this.scene.children, true);
2094
-
2095
- for (let i = 0; i < intersect.length; i++) {
2096
- if (intersect[i].object.uuid != this._gizmos.uuid && intersect[i].face != null) {
2097
- return intersect[i].point.clone();
2098
- }
2061
+ if (!this.scene) return null;
2062
+ const raycaster = new Raycaster();
2063
+ raycaster.near = camera.near;
2064
+ raycaster.far = camera.far;
2065
+ raycaster.setFromCamera(cursor, camera);
2066
+ const intersect = raycaster.intersectObjects(this.scene.children, true);
2067
+
2068
+ for (let i = 0; i < intersect.length; i++) {
2069
+ if (intersect[i].object.uuid != this._gizmos.uuid && intersect[i].face) {
2070
+ return intersect[i].point.clone();
2099
2071
  }
2100
2072
  }
2101
2073
 
@@ -2121,7 +2093,9 @@ class ArcballControls extends EventDispatcher {
2121
2093
  }
2122
2094
 
2123
2095
  return this._v3_1;
2124
- } else if (camera.type == 'PerspectiveCamera') {
2096
+ }
2097
+
2098
+ if (camera.type == 'PerspectiveCamera') {
2125
2099
  //unproject cursor on the near plane
2126
2100
  this._v2_1.copy(this.getCursorNDC(cursorX, cursorY, canvas));
2127
2101
 
@@ -2216,7 +2190,9 @@ class ArcballControls extends EventDispatcher {
2216
2190
  this._v3_1.set(this._v2_1.x, this._v2_1.y, 0);
2217
2191
 
2218
2192
  return this._v3_1.clone();
2219
- } else if (camera.type == 'PerspectiveCamera') {
2193
+ }
2194
+
2195
+ if (camera.type == 'PerspectiveCamera') {
2220
2196
  this._v2_1.copy(this.getCursorNDC(cursorX, cursorY, canvas)); //unproject cursor on the near plane
2221
2197
 
2222
2198
 
@@ -2271,20 +2247,21 @@ class ArcballControls extends EventDispatcher {
2271
2247
  });
2272
2248
 
2273
2249
  _defineProperty(this, "updateMatrixState", () => {
2274
- if (this.camera !== null) {
2275
- //update camera and gizmos state
2276
- this._cameraMatrixState.copy(this.camera.matrix);
2250
+ if (!this.camera) return; //update camera and gizmos state
2277
2251
 
2278
- this._gizmoMatrixState.copy(this._gizmos.matrix);
2252
+ this._cameraMatrixState.copy(this.camera.matrix);
2279
2253
 
2280
- if (this.camera instanceof OrthographicCamera && this.camera.isOrthographicCamera) {
2281
- this._cameraProjectionState.copy(this.camera.projectionMatrix);
2254
+ this._gizmoMatrixState.copy(this._gizmos.matrix);
2282
2255
 
2283
- this.camera.updateProjectionMatrix();
2284
- this._zoomState = this.camera.zoom;
2285
- } else if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
2286
- this._fovState = this.camera.fov;
2287
- }
2256
+ if (this.camera.type === 'OrthographicCamera') {
2257
+ this._cameraProjectionState.copy(this.camera.projectionMatrix);
2258
+
2259
+ this.camera.updateProjectionMatrix();
2260
+ this._zoomState = this.camera.zoom;
2261
+ }
2262
+
2263
+ if (this.camera.type === 'PerspectiveCamera') {
2264
+ this._fovState = this.camera.fov;
2288
2265
  }
2289
2266
  });
2290
2267
 
@@ -2297,11 +2274,9 @@ class ArcballControls extends EventDispatcher {
2297
2274
  });
2298
2275
 
2299
2276
  _defineProperty(this, "update", () => {
2300
- var _this$camera2;
2301
-
2302
2277
  const EPS = 0.000001; // Update target and gizmos state
2303
2278
 
2304
- if (!this.target.equals(this._currentTarget) && this.camera !== null) {
2279
+ if (!this.target.equals(this._currentTarget) && this.camera) {
2305
2280
  this._gizmos.position.set(this.target.x, this.target.y, this.target.z); //for correct radius calculation
2306
2281
 
2307
2282
 
@@ -2314,16 +2289,19 @@ class ArcballControls extends EventDispatcher {
2314
2289
  this.makeGizmos(this.target, this._tbRadius);
2315
2290
 
2316
2291
  this._currentTarget.copy(this.target);
2317
- } //check min/max parameters
2292
+ }
2318
2293
 
2294
+ if (!this.camera) return; //check min/max parameters
2319
2295
 
2320
- if (this.camera instanceof OrthographicCamera && this.camera.isOrthographicCamera) {
2296
+ if (this.camera.type === 'OrthographicCamera') {
2321
2297
  //check zoom
2322
2298
  if (this.camera.zoom > this.maxZoom || this.camera.zoom < this.minZoom) {
2323
2299
  const newZoom = MathUtils.clamp(this.camera.zoom, this.minZoom, this.maxZoom);
2324
2300
  this.applyTransformMatrix(this.applyScale(newZoom / this.camera.zoom, this._gizmos.position, true));
2325
2301
  }
2326
- } else if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
2302
+ }
2303
+
2304
+ if (this.camera.type === 'PerspectiveCamera') {
2327
2305
  //check distance
2328
2306
  const distance = this.camera.position.distanceTo(this._gizmos.position);
2329
2307
 
@@ -2356,21 +2334,18 @@ class ArcballControls extends EventDispatcher {
2356
2334
 
2357
2335
  for (const gizmo in this._gizmos.children) {
2358
2336
  const child = this._gizmos.children[gizmo];
2359
-
2360
- if (child instanceof Mesh) {
2361
- child.geometry = curveGeometry;
2362
- }
2337
+ child.geometry = curveGeometry;
2363
2338
  }
2364
2339
  }
2365
2340
  }
2366
2341
 
2367
- (_this$camera2 = this.camera) === null || _this$camera2 === void 0 ? void 0 : _this$camera2.lookAt(this._gizmos.position);
2342
+ this.camera.lookAt(this._gizmos.position);
2368
2343
  });
2369
2344
 
2370
2345
  _defineProperty(this, "setStateFromJSON", json => {
2371
2346
  const state = JSON.parse(json);
2372
2347
 
2373
- if (state.arcballState != undefined && (this.camera instanceof PerspectiveCamera || this.camera instanceof OrthographicCamera)) {
2348
+ if (state.arcballState && this.camera) {
2374
2349
  this._cameraMatrixState.fromArray(state.arcballState.cameraMatrix.elements);
2375
2350
 
2376
2351
  this._cameraMatrixState.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
@@ -2380,7 +2355,7 @@ class ArcballControls extends EventDispatcher {
2380
2355
  this.camera.far = state.arcballState.cameraFar;
2381
2356
  this.camera.zoom = state.arcballState.cameraZoom;
2382
2357
 
2383
- if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
2358
+ if (this.camera.type === 'PerspectiveCamera') {
2384
2359
  this.camera.fov = state.arcballState.cameraFov;
2385
2360
  }
2386
2361
 
@@ -2411,7 +2386,7 @@ class ArcballControls extends EventDispatcher {
2411
2386
  });
2412
2387
 
2413
2388
  this.camera = null;
2414
- this.domElement = domElement;
2389
+ this.domElement = _domElement;
2415
2390
  this.scene = scene;
2416
2391
  this.mouseActions = [];
2417
2392
  this._mouseOp = null; //global vectors and matrices that are used in some operations to avoid creating new objects every time (e.g. every time cursor moves)
@@ -2469,8 +2444,6 @@ class ArcballControls extends EventDispatcher {
2469
2444
  this._downValid = true;
2470
2445
  this._nclicks = 0;
2471
2446
  this._downEvents = [];
2472
- this._downStart = 0; //pointerDown time
2473
-
2474
2447
  this._clickStart = 0; //first click time
2475
2448
 
2476
2449
  this._maxDownTime = 250;
@@ -2530,7 +2503,6 @@ class ArcballControls extends EventDispatcher {
2530
2503
  this.enablePan = true;
2531
2504
  this.enableRotate = true;
2532
2505
  this.enableZoom = true;
2533
- this.enableGizmos = true;
2534
2506
  this.minDistance = 0;
2535
2507
  this.maxDistance = Infinity;
2536
2508
  this.minZoom = 0;
@@ -2543,17 +2515,13 @@ class ArcballControls extends EventDispatcher {
2543
2515
  this._state = STATE.IDLE;
2544
2516
  this.setCamera(_camera);
2545
2517
 
2546
- if (this.scene != null) {
2518
+ if (this.scene) {
2547
2519
  this.scene.add(this._gizmos);
2548
2520
  }
2549
2521
 
2550
- this.domElement.style.touchAction = 'none';
2551
2522
  this._devPxRatio = window.devicePixelRatio;
2552
2523
  this.initializeMouseActions();
2553
- this.domElement.addEventListener('contextmenu', this.onContextMenu);
2554
- this.domElement.addEventListener('wheel', this.onWheel);
2555
- this.domElement.addEventListener('pointerdown', this.onPointerDown);
2556
- this.domElement.addEventListener('pointercancel', this.onPointerCancel);
2524
+ if (this.domElement) this.connect(this.domElement);
2557
2525
  window.addEventListener('keydown', this.onKeyDown);
2558
2526
  window.addEventListener('resize', this.onWindowResize);
2559
2527
  } //listeners
@@ -2564,7 +2532,7 @@ class ArcballControls extends EventDispatcher {
2564
2532
  * @param {Object} transformation Object containing matrices to apply to camera and gizmos
2565
2533
  */
2566
2534
  applyTransformMatrix(transformation) {
2567
- if ((transformation === null || transformation === void 0 ? void 0 : transformation.camera) != null && this.camera !== null) {
2535
+ if (transformation !== null && transformation !== void 0 && transformation.camera && this.camera) {
2568
2536
  this._m4_1.copy(this._cameraMatrixState).premultiply(transformation.camera);
2569
2537
 
2570
2538
  this._m4_1.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
@@ -2576,7 +2544,7 @@ class ArcballControls extends EventDispatcher {
2576
2544
  }
2577
2545
  }
2578
2546
 
2579
- if ((transformation === null || transformation === void 0 ? void 0 : transformation.gizmos) != null) {
2547
+ if (transformation !== null && transformation !== void 0 && transformation.gizmos) {
2580
2548
  this._m4_1.copy(this._gizmoMatrixState).premultiply(transformation.gizmos);
2581
2549
 
2582
2550
  this._m4_1.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
@@ -2584,7 +2552,7 @@ class ArcballControls extends EventDispatcher {
2584
2552
  this._gizmos.updateMatrix();
2585
2553
  }
2586
2554
 
2587
- if ((this._state == STATE.SCALE || this._state == STATE.FOCUS || this._state == STATE.ANIMATION_FOCUS) && (this.camera instanceof PerspectiveCamera || this.camera instanceof OrthographicCamera)) {
2555
+ if ((this._state == STATE.SCALE || this._state == STATE.FOCUS || this._state == STATE.ANIMATION_FOCUS) && this.camera) {
2588
2556
  const tbRadius = this.calculateTbRadius(this.camera);
2589
2557
 
2590
2558
  if (tbRadius !== undefined) {
@@ -2655,8 +2623,8 @@ class ArcballControls extends EventDispatcher {
2655
2623
  * @param {Matrix4} gizmos Transformation to be applied to gizmos
2656
2624
  */
2657
2625
  setTransformationMatrices(camera = null, gizmos = null) {
2658
- if (camera != null) {
2659
- if (_transformation.camera != null) {
2626
+ if (camera) {
2627
+ if (_transformation.camera) {
2660
2628
  _transformation.camera.copy(camera);
2661
2629
  } else {
2662
2630
  _transformation.camera = camera.clone();
@@ -2665,8 +2633,8 @@ class ArcballControls extends EventDispatcher {
2665
2633
  _transformation.camera = null;
2666
2634
  }
2667
2635
 
2668
- if (gizmos != null) {
2669
- if (_transformation.gizmos != null) {
2636
+ if (gizmos) {
2637
+ if (_transformation.gizmos) {
2670
2638
  _transformation.gizmos.copy(gizmos);
2671
2639
  } else {
2672
2640
  _transformation.gizmos = gizmos.clone();