three-stdlib 2.7.0 → 2.8.1
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.
- package/{Nodes-ec4e1143.js → Nodes-894ac9dc.js} +0 -0
- package/{Nodes-427f68b0.js → Nodes-af575af7.js} +0 -0
- package/cameras/CinematicCamera.cjs.js +1 -1
- package/cameras/CinematicCamera.js +3 -8
- package/controls/ArcballControls.cjs.js +1 -1
- package/controls/ArcballControls.d.ts +6 -9
- package/controls/ArcballControls.js +188 -234
- package/controls/FirstPersonControls.cjs.js +1 -1
- package/controls/FirstPersonControls.d.ts +4 -5
- package/controls/FirstPersonControls.js +36 -45
- package/controls/TransformControls.cjs.js +1 -1
- package/controls/TransformControls.d.ts +2 -1
- package/controls/TransformControls.js +25 -26
- package/exporters/GLTFExporter.cjs.js +1 -1
- package/exporters/GLTFExporter.js +9 -18
- package/geometries/TeapotGeometry.js +2 -2
- package/index.cjs.js +1 -1
- package/loaders/EXRLoader.cjs.js +1 -1
- package/loaders/EXRLoader.js +21 -10
- package/loaders/GLTFLoader.cjs.js +1 -1
- package/loaders/GLTFLoader.js +5 -6
- package/loaders/HDRCubeTextureLoader.cjs.js +1 -1
- package/loaders/HDRCubeTextureLoader.js +1 -3
- package/loaders/LDrawLoader.cjs.js +1 -1
- package/loaders/LDrawLoader.js +1450 -1105
- package/loaders/LUT3dlLoader.cjs.js +1 -1
- package/loaders/LUT3dlLoader.js +18 -11
- package/loaders/LUTCubeLoader.cjs.js +1 -1
- package/loaders/LUTCubeLoader.js +4 -5
- package/loaders/NodeMaterialLoader.cjs.js +1 -1
- package/loaders/PCDLoader.cjs.js +1 -1
- package/loaders/PCDLoader.js +2 -2
- package/loaders/RGBELoader.cjs.js +1 -1
- package/loaders/RGBELoader.js +6 -6
- package/loaders/STLLoader.js +7 -7
- package/loaders/VRMLLoader.cjs.js +1 -1
- package/loaders/VRMLLoader.js +10 -18
- package/modifiers/CurveModifier.cjs.js +1 -1
- package/modifiers/CurveModifier.js +9 -8
- package/nodes/accessors/CameraNode.js +12 -12
- package/nodes/accessors/PositionNode.js +3 -3
- package/nodes/accessors/ReflectNode.js +3 -3
- package/nodes/core/FunctionNode.js +3 -3
- package/nodes/core/InputNode.js +3 -3
- package/nodes/core/Node.js +6 -6
- package/nodes/core/TempNode.js +6 -6
- package/nodes/effects/BlurNode.js +3 -3
- package/nodes/math/MathNode.js +3 -3
- package/nodes/utils/VelocityNode.js +6 -6
- package/objects/Lensflare.cjs.js +1 -1
- package/objects/Lensflare.js +3 -11
- package/objects/Reflector.cjs.js +1 -1
- package/objects/Reflector.js +16 -12
- package/objects/ReflectorForSSRPass.cjs.js +1 -1
- package/objects/ReflectorForSSRPass.js +1 -9
- package/objects/Refractor.cjs.js +1 -1
- package/objects/Refractor.js +7 -12
- package/objects/Water.cjs.js +1 -1
- package/objects/Water.js +5 -16
- package/package.json +2 -2
- package/postprocessing/GlitchPass.cjs.js +1 -1
- package/postprocessing/GlitchPass.js +36 -33
- package/postprocessing/SMAAPass.cjs.js +1 -1
- package/postprocessing/SMAAPass.js +93 -96
- package/postprocessing/SSAOPass.cjs.js +1 -1
- package/postprocessing/SSAOPass.js +151 -152
- package/postprocessing/SavePass.cjs.js +1 -1
- package/postprocessing/SavePass.js +27 -28
- package/renderers/nodes/accessors/UVNode.js +1 -3
- package/renderers/nodes/core/AttributeNode.js +1 -3
- package/renderers/nodes/core/Node.js +4 -12
- package/renderers/nodes/core/NodeBuilder.js +6 -18
- package/renderers/webgpu/WebGPUTextures.cjs.js +1 -1
- package/renderers/webgpu/WebGPUTextures.js +1 -2
- package/utils/LDrawUtils.cjs.js +1 -0
- package/utils/LDrawUtils.js +144 -0
- package/webxr/ARButton.js +6 -6
- package/webxr/VRButton.js +6 -6
@@ -1,5 +1,5 @@
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
2
|
-
import { Matrix4, EventDispatcher, EllipseCurve, BufferGeometry,
|
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 {
|
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,
|
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
|
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
|
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
|
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
|
-
|
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
|
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
|
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
|
-
}
|
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
|
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
|
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
|
617
|
+
if (this._grid) {
|
621
618
|
this.disposeGrid();
|
622
619
|
this.drawGrid();
|
623
620
|
}
|
@@ -631,28 +628,16 @@ class ArcballControls extends EventDispatcher {
|
|
631
628
|
}
|
632
629
|
});
|
633
630
|
|
634
|
-
_defineProperty(this, "onKeyDown", event => {
|
635
|
-
if (event.key == 'c') {
|
636
|
-
if (event.ctrlKey || event.metaKey) {
|
637
|
-
this.copyState();
|
638
|
-
}
|
639
|
-
} else if (event.key == 'v') {
|
640
|
-
if (event.ctrlKey || event.metaKey) {
|
641
|
-
this.pasteState();
|
642
|
-
}
|
643
|
-
}
|
644
|
-
});
|
645
|
-
|
646
631
|
_defineProperty(this, "onSinglePanStart", (event, operation) => {
|
647
|
-
|
632
|
+
var _this$camera4;
|
633
|
+
|
634
|
+
if (this.enabled && this.domElement) {
|
648
635
|
this.dispatchEvent(_startEvent);
|
649
636
|
this.setCenter(event.clientX, event.clientY);
|
650
637
|
|
651
638
|
switch (operation) {
|
652
639
|
case 'PAN':
|
653
|
-
if (!this.enablePan)
|
654
|
-
return;
|
655
|
-
}
|
640
|
+
if (!this.enablePan) return;
|
656
641
|
|
657
642
|
if (this._animationId != -1) {
|
658
643
|
cancelAnimationFrame(this._animationId);
|
@@ -662,7 +647,7 @@ class ArcballControls extends EventDispatcher {
|
|
662
647
|
this.dispatchEvent(_changeEvent);
|
663
648
|
}
|
664
649
|
|
665
|
-
if (this.camera
|
650
|
+
if (this.camera) {
|
666
651
|
this.updateTbState(STATE.PAN, true);
|
667
652
|
const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement);
|
668
653
|
|
@@ -679,9 +664,7 @@ class ArcballControls extends EventDispatcher {
|
|
679
664
|
break;
|
680
665
|
|
681
666
|
case 'ROTATE':
|
682
|
-
if (!this.enableRotate)
|
683
|
-
return;
|
684
|
-
}
|
667
|
+
if (!this.enableRotate) return;
|
685
668
|
|
686
669
|
if (this._animationId != -1) {
|
687
670
|
cancelAnimationFrame(this._animationId);
|
@@ -689,7 +672,7 @@ class ArcballControls extends EventDispatcher {
|
|
689
672
|
this._timeStart = -1;
|
690
673
|
}
|
691
674
|
|
692
|
-
if (this.camera
|
675
|
+
if (this.camera) {
|
693
676
|
this.updateTbState(STATE.ROTATE, true);
|
694
677
|
const rayDir = this.unprojectOnTbSurface(this.camera, _center.x, _center.y, this.domElement, this._tbRadius);
|
695
678
|
|
@@ -716,30 +699,28 @@ class ArcballControls extends EventDispatcher {
|
|
716
699
|
break;
|
717
700
|
|
718
701
|
case 'FOV':
|
719
|
-
if (!
|
720
|
-
return;
|
721
|
-
}
|
702
|
+
if (!this.enableZoom) return;
|
722
703
|
|
723
|
-
if (this.
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
704
|
+
if (((_this$camera4 = this.camera) === null || _this$camera4 === void 0 ? void 0 : _this$camera4.type) === 'PerspectiveCamera') {
|
705
|
+
if (this._animationId != -1) {
|
706
|
+
cancelAnimationFrame(this._animationId);
|
707
|
+
this._animationId = -1;
|
708
|
+
this._timeStart = -1;
|
709
|
+
this.activateGizmos(false);
|
710
|
+
this.dispatchEvent(_changeEvent);
|
711
|
+
}
|
730
712
|
|
731
|
-
|
713
|
+
this.updateTbState(STATE.FOV, true);
|
732
714
|
|
733
|
-
|
715
|
+
this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
|
734
716
|
|
735
|
-
|
717
|
+
this._currentCursorPosition.copy(this._startCursorPosition);
|
718
|
+
}
|
736
719
|
|
737
720
|
break;
|
738
721
|
|
739
722
|
case 'ZOOM':
|
740
|
-
if (!this.enableZoom)
|
741
|
-
return;
|
742
|
-
}
|
723
|
+
if (!this.enableZoom) return;
|
743
724
|
|
744
725
|
if (this._animationId != -1) {
|
745
726
|
cancelAnimationFrame(this._animationId);
|
@@ -761,13 +742,15 @@ class ArcballControls extends EventDispatcher {
|
|
761
742
|
});
|
762
743
|
|
763
744
|
_defineProperty(this, "onSinglePanMove", (event, opState) => {
|
764
|
-
|
745
|
+
var _this$camera5;
|
746
|
+
|
747
|
+
if (this.enabled && this.domElement) {
|
765
748
|
const restart = opState != this._state;
|
766
749
|
this.setCenter(event.clientX, event.clientY);
|
767
750
|
|
768
751
|
switch (opState) {
|
769
752
|
case STATE.PAN:
|
770
|
-
if (this.enablePan && this.camera
|
753
|
+
if (this.enablePan && this.camera) {
|
771
754
|
if (restart) {
|
772
755
|
//switch to pan operation
|
773
756
|
this.dispatchEvent(_endEvent);
|
@@ -799,7 +782,7 @@ class ArcballControls extends EventDispatcher {
|
|
799
782
|
break;
|
800
783
|
|
801
784
|
case STATE.ROTATE:
|
802
|
-
if (this.enableRotate && this.camera
|
785
|
+
if (this.enableRotate && this.camera) {
|
803
786
|
if (restart) {
|
804
787
|
//switch to rotate operation
|
805
788
|
this.dispatchEvent(_endEvent);
|
@@ -889,7 +872,7 @@ class ArcballControls extends EventDispatcher {
|
|
889
872
|
break;
|
890
873
|
|
891
874
|
case STATE.FOV:
|
892
|
-
if (this.enableZoom && this.camera
|
875
|
+
if (this.enableZoom && ((_this$camera5 = this.camera) === null || _this$camera5 === void 0 ? void 0 : _this$camera5.type) === 'PerspectiveCamera') {
|
893
876
|
if (restart) {
|
894
877
|
//switch to fov operation
|
895
878
|
this.dispatchEvent(_endEvent);
|
@@ -998,12 +981,12 @@ class ArcballControls extends EventDispatcher {
|
|
998
981
|
});
|
999
982
|
|
1000
983
|
_defineProperty(this, "onDoubleTap", event => {
|
1001
|
-
if (this.enabled && this.enablePan && this.scene
|
984
|
+
if (this.enabled && this.enablePan && this.scene && this.camera && this.domElement) {
|
1002
985
|
this.dispatchEvent(_startEvent);
|
1003
986
|
this.setCenter(event.clientX, event.clientY);
|
1004
987
|
const hitP = this.unprojectOnObj(this.getCursorNDC(_center.x, _center.y, this.domElement), this.camera);
|
1005
988
|
|
1006
|
-
if (hitP
|
989
|
+
if (hitP && this.enableAnimations) {
|
1007
990
|
const self = this;
|
1008
991
|
|
1009
992
|
if (this._animationId != -1) {
|
@@ -1015,7 +998,7 @@ class ArcballControls extends EventDispatcher {
|
|
1015
998
|
self.updateTbState(STATE.ANIMATION_FOCUS, true);
|
1016
999
|
self.onFocusAnim(t, hitP, self._cameraMatrixState, self._gizmoMatrixState);
|
1017
1000
|
});
|
1018
|
-
} else if (hitP
|
1001
|
+
} else if (hitP && !this.enableAnimations) {
|
1019
1002
|
this.updateTbState(STATE.FOCUS, true);
|
1020
1003
|
this.focus(hitP, this.scaleFactor);
|
1021
1004
|
this.updateTbState(STATE.IDLE, false);
|
@@ -1027,7 +1010,7 @@ class ArcballControls extends EventDispatcher {
|
|
1027
1010
|
});
|
1028
1011
|
|
1029
1012
|
_defineProperty(this, "onDoublePanStart", () => {
|
1030
|
-
if (this.enabled && this.enablePan && this.camera
|
1013
|
+
if (this.enabled && this.enablePan && this.camera && this.domElement) {
|
1031
1014
|
this.dispatchEvent(_startEvent);
|
1032
1015
|
this.updateTbState(STATE.PAN, true);
|
1033
1016
|
this.setCenter((this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2, (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2);
|
@@ -1044,7 +1027,7 @@ class ArcballControls extends EventDispatcher {
|
|
1044
1027
|
});
|
1045
1028
|
|
1046
1029
|
_defineProperty(this, "onDoublePanMove", () => {
|
1047
|
-
if (this.enabled && this.enablePan && this.camera
|
1030
|
+
if (this.enabled && this.enablePan && this.camera && this.domElement) {
|
1048
1031
|
this.setCenter((this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2, (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2);
|
1049
1032
|
|
1050
1033
|
if (this._state != STATE.PAN) {
|
@@ -1067,14 +1050,14 @@ class ArcballControls extends EventDispatcher {
|
|
1067
1050
|
|
1068
1051
|
_defineProperty(this, "onRotateStart", () => {
|
1069
1052
|
if (this.enabled && this.enableRotate) {
|
1070
|
-
var _this$
|
1053
|
+
var _this$camera6;
|
1071
1054
|
|
1072
1055
|
this.dispatchEvent(_startEvent);
|
1073
1056
|
this.updateTbState(STATE.ZROTATE, true); //this._startFingerRotation = event.rotation;
|
1074
1057
|
|
1075
1058
|
this._startFingerRotation = this.getAngle(this._touchCurrent[1], this._touchCurrent[0]) + this.getAngle(this._touchStart[1], this._touchStart[0]);
|
1076
1059
|
this._currentFingerRotation = this._startFingerRotation;
|
1077
|
-
(_this$
|
1060
|
+
(_this$camera6 = this.camera) === null || _this$camera6 === void 0 ? void 0 : _this$camera6.getWorldDirection(this._rotationAxis); //rotation axis
|
1078
1061
|
|
1079
1062
|
if (!this.enablePan && !this.enableZoom) {
|
1080
1063
|
this.activateGizmos(true);
|
@@ -1083,7 +1066,7 @@ class ArcballControls extends EventDispatcher {
|
|
1083
1066
|
});
|
1084
1067
|
|
1085
1068
|
_defineProperty(this, "onRotateMove", () => {
|
1086
|
-
if (this.enabled && this.enableRotate && this.camera
|
1069
|
+
if (this.enabled && this.enableRotate && this.camera && this.domElement) {
|
1087
1070
|
this.setCenter((this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2, (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2);
|
1088
1071
|
let rotationPoint;
|
1089
1072
|
|
@@ -1097,7 +1080,7 @@ class ArcballControls extends EventDispatcher {
|
|
1097
1080
|
|
1098
1081
|
if (!this.enablePan) {
|
1099
1082
|
rotationPoint = new Vector3().setFromMatrixPosition(this._gizmoMatrixState);
|
1100
|
-
} else if (this.camera
|
1083
|
+
} else if (this.camera) {
|
1101
1084
|
var _this$unprojectOnTbPl3;
|
1102
1085
|
|
1103
1086
|
this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);
|
@@ -1132,7 +1115,7 @@ class ArcballControls extends EventDispatcher {
|
|
1132
1115
|
});
|
1133
1116
|
|
1134
1117
|
_defineProperty(this, "onPinchMove", () => {
|
1135
|
-
if (this.enabled && this.enableZoom) {
|
1118
|
+
if (this.enabled && this.enableZoom && this.domElement) {
|
1136
1119
|
this.setCenter((this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2, (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2);
|
1137
1120
|
const minDistance = 12; //minimum distance between fingers (in css pixels)
|
1138
1121
|
|
@@ -1148,11 +1131,13 @@ class ArcballControls extends EventDispatcher {
|
|
1148
1131
|
if (!this.enablePan) {
|
1149
1132
|
scalePoint = this._gizmos.position;
|
1150
1133
|
} else {
|
1151
|
-
|
1134
|
+
var _this$camera7, _this$camera8;
|
1135
|
+
|
1136
|
+
if (((_this$camera7 = this.camera) === null || _this$camera7 === void 0 ? void 0 : _this$camera7.type) === 'OrthographicCamera') {
|
1152
1137
|
var _this$unprojectOnTbPl4;
|
1153
1138
|
|
1154
1139
|
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
|
1140
|
+
} else if (((_this$camera8 = this.camera) === null || _this$camera8 === void 0 ? void 0 : _this$camera8.type) === 'PerspectiveCamera') {
|
1156
1141
|
var _this$unprojectOnTbPl5;
|
1157
1142
|
|
1158
1143
|
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 +1158,7 @@ class ArcballControls extends EventDispatcher {
|
|
1173
1158
|
});
|
1174
1159
|
|
1175
1160
|
_defineProperty(this, "onTriplePanStart", () => {
|
1176
|
-
if (this.enabled && this.enableZoom) {
|
1161
|
+
if (this.enabled && this.enableZoom && this.domElement) {
|
1177
1162
|
this.dispatchEvent(_startEvent);
|
1178
1163
|
this.updateTbState(STATE.SCALE, true); //const center = event.center;
|
1179
1164
|
|
@@ -1195,7 +1180,7 @@ class ArcballControls extends EventDispatcher {
|
|
1195
1180
|
});
|
1196
1181
|
|
1197
1182
|
_defineProperty(this, "onTriplePanMove", () => {
|
1198
|
-
if (this.enabled && this.enableZoom && this.camera
|
1183
|
+
if (this.enabled && this.enableZoom && this.camera && this.domElement) {
|
1199
1184
|
// fov / 2
|
1200
1185
|
// |\
|
1201
1186
|
// | \
|
@@ -1278,18 +1263,6 @@ class ArcballControls extends EventDispatcher {
|
|
1278
1263
|
this.setMouseAction('FOV', 1, 'SHIFT');
|
1279
1264
|
});
|
1280
1265
|
|
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
1266
|
_defineProperty(this, "setMouseAction", (operation, mouse, key = null) => {
|
1294
1267
|
const operationInput = ['PAN', 'ROTATE', 'ZOOM', 'FOV'];
|
1295
1268
|
const mouseInput = [0, 1, 2, 'WHEEL'];
|
@@ -1344,17 +1317,6 @@ class ArcballControls extends EventDispatcher {
|
|
1344
1317
|
return true;
|
1345
1318
|
});
|
1346
1319
|
|
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
1320
|
_defineProperty(this, "getOpFromAction", (mouse, key) => {
|
1359
1321
|
let action;
|
1360
1322
|
|
@@ -1366,7 +1328,7 @@ class ArcballControls extends EventDispatcher {
|
|
1366
1328
|
}
|
1367
1329
|
}
|
1368
1330
|
|
1369
|
-
if (key
|
1331
|
+
if (key) {
|
1370
1332
|
for (let i = 0; i < this.mouseActions.length; i++) {
|
1371
1333
|
action = this.mouseActions[i];
|
1372
1334
|
|
@@ -1390,7 +1352,7 @@ class ArcballControls extends EventDispatcher {
|
|
1390
1352
|
}
|
1391
1353
|
}
|
1392
1354
|
|
1393
|
-
if (key
|
1355
|
+
if (key) {
|
1394
1356
|
for (let i = 0; i < this.mouseActions.length; i++) {
|
1395
1357
|
action = this.mouseActions[i];
|
1396
1358
|
|
@@ -1446,19 +1408,19 @@ class ArcballControls extends EventDispatcher {
|
|
1446
1408
|
const factor = 0.67;
|
1447
1409
|
const distance = camera.position.distanceTo(this._gizmos.position);
|
1448
1410
|
|
1449
|
-
if (camera.type == 'PerspectiveCamera'
|
1411
|
+
if (camera.type == 'PerspectiveCamera') {
|
1450
1412
|
const halfFovV = MathUtils.DEG2RAD * camera.fov * 0.5; //vertical fov/2 in radians
|
1451
1413
|
|
1452
1414
|
const halfFovH = Math.atan(camera.aspect * Math.tan(halfFovV)); //horizontal fov/2 in radians
|
1453
1415
|
|
1454
1416
|
return Math.tan(Math.min(halfFovV, halfFovH)) * distance * factor;
|
1455
|
-
} else if (camera.type == 'OrthographicCamera'
|
1417
|
+
} else if (camera.type == 'OrthographicCamera') {
|
1456
1418
|
return Math.min(camera.top, camera.right) * factor;
|
1457
1419
|
}
|
1458
1420
|
});
|
1459
1421
|
|
1460
1422
|
_defineProperty(this, "focus", (point, size, amount = 1) => {
|
1461
|
-
if (this.camera
|
1423
|
+
if (this.camera) {
|
1462
1424
|
const focusPoint = point.clone(); //move center of camera (along with gizmos) towards point of interest
|
1463
1425
|
|
1464
1426
|
focusPoint.sub(this._gizmos.position).multiplyScalar(amount);
|
@@ -1489,19 +1451,21 @@ class ArcballControls extends EventDispatcher {
|
|
1489
1451
|
});
|
1490
1452
|
|
1491
1453
|
_defineProperty(this, "drawGrid", () => {
|
1492
|
-
if (this.scene
|
1454
|
+
if (this.scene) {
|
1455
|
+
var _this$camera9, _this$camera10;
|
1456
|
+
|
1493
1457
|
const color = 0x888888;
|
1494
1458
|
const multiplier = 3;
|
1495
1459
|
let size, divisions, maxLength, tick;
|
1496
1460
|
|
1497
|
-
if (this.camera
|
1461
|
+
if (((_this$camera9 = this.camera) === null || _this$camera9 === void 0 ? void 0 : _this$camera9.type) === 'OrthographicCamera') {
|
1498
1462
|
const width = this.camera.right - this.camera.left;
|
1499
1463
|
const height = this.camera.bottom - this.camera.top;
|
1500
1464
|
maxLength = Math.max(width, height);
|
1501
1465
|
tick = maxLength / 20;
|
1502
1466
|
size = maxLength / this.camera.zoom * multiplier;
|
1503
1467
|
divisions = size / tick * this.camera.zoom;
|
1504
|
-
} else if (this.camera
|
1468
|
+
} else if (((_this$camera10 = this.camera) === null || _this$camera10 === void 0 ? void 0 : _this$camera10.type) === 'PerspectiveCamera') {
|
1505
1469
|
const distance = this.camera.position.distanceTo(this._gizmos.position);
|
1506
1470
|
const halfFovV = MathUtils.DEG2RAD * this.camera.fov * 0.5;
|
1507
1471
|
const halfFovH = Math.atan(this.camera.aspect * Math.tan(halfFovV));
|
@@ -1511,7 +1475,7 @@ class ArcballControls extends EventDispatcher {
|
|
1511
1475
|
divisions = size / tick;
|
1512
1476
|
}
|
1513
1477
|
|
1514
|
-
if (this._grid == null && this.camera
|
1478
|
+
if (this._grid == null && this.camera) {
|
1515
1479
|
this._grid = new GridHelper(size, divisions, color, color);
|
1516
1480
|
|
1517
1481
|
this._grid.position.copy(this._gizmos.position);
|
@@ -1527,27 +1491,43 @@ class ArcballControls extends EventDispatcher {
|
|
1527
1491
|
}
|
1528
1492
|
});
|
1529
1493
|
|
1494
|
+
_defineProperty(this, "connect", domElement => {
|
1495
|
+
// https://github.com/mrdoob/three.js/issues/20575
|
1496
|
+
if (domElement === document) {
|
1497
|
+
console.error('THREE.ArcballControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
|
1498
|
+
}
|
1499
|
+
|
1500
|
+
this.domElement = domElement; // disables touch scroll
|
1501
|
+
// touch-action needs to be defined for pointer events to work on mobile
|
1502
|
+
// https://stackoverflow.com/a/48254578
|
1503
|
+
|
1504
|
+
this.domElement.style.touchAction = 'none';
|
1505
|
+
this.domElement.addEventListener('contextmenu', this.onContextMenu);
|
1506
|
+
this.domElement.addEventListener('pointerdown', this.onPointerDown);
|
1507
|
+
this.domElement.addEventListener('pointercancel', this.onPointerCancel);
|
1508
|
+
this.domElement.addEventListener('wheel', this.onWheel);
|
1509
|
+
});
|
1510
|
+
|
1530
1511
|
_defineProperty(this, "dispose", () => {
|
1531
|
-
var _this$scene;
|
1512
|
+
var _this$domElement, _this$domElement2, _this$domElement3, _this$domElement4, _this$scene;
|
1532
1513
|
|
1533
1514
|
if (this._animationId != -1) {
|
1534
1515
|
window.cancelAnimationFrame(this._animationId);
|
1535
1516
|
}
|
1536
1517
|
|
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);
|
1518
|
+
(_this$domElement = this.domElement) === null || _this$domElement === void 0 ? void 0 : _this$domElement.removeEventListener('pointerdown', this.onPointerDown);
|
1519
|
+
(_this$domElement2 = this.domElement) === null || _this$domElement2 === void 0 ? void 0 : _this$domElement2.removeEventListener('pointercancel', this.onPointerCancel);
|
1520
|
+
(_this$domElement3 = this.domElement) === null || _this$domElement3 === void 0 ? void 0 : _this$domElement3.removeEventListener('wheel', this.onWheel);
|
1521
|
+
(_this$domElement4 = this.domElement) === null || _this$domElement4 === void 0 ? void 0 : _this$domElement4.removeEventListener('contextmenu', this.onContextMenu);
|
1541
1522
|
window.removeEventListener('pointermove', this.onPointerMove);
|
1542
1523
|
window.removeEventListener('pointerup', this.onPointerUp);
|
1543
1524
|
window.removeEventListener('resize', this.onWindowResize);
|
1544
|
-
window.addEventListener('keydown', this.onKeyDown);
|
1545
1525
|
(_this$scene = this.scene) === null || _this$scene === void 0 ? void 0 : _this$scene.remove(this._gizmos);
|
1546
1526
|
this.disposeGrid();
|
1547
1527
|
});
|
1548
1528
|
|
1549
1529
|
_defineProperty(this, "disposeGrid", () => {
|
1550
|
-
if (this._grid
|
1530
|
+
if (this._grid && this.scene) {
|
1551
1531
|
this.scene.remove(this._grid);
|
1552
1532
|
this._grid = null;
|
1553
1533
|
}
|
@@ -1558,29 +1538,9 @@ class ArcballControls extends EventDispatcher {
|
|
1558
1538
|
});
|
1559
1539
|
|
1560
1540
|
_defineProperty(this, "activateGizmos", isActive => {
|
1561
|
-
const
|
1562
|
-
|
1563
|
-
|
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
|
1541
|
+
for (const gizmo of this._gizmos.children) {
|
1542
|
+
gizmo.material.setValues({
|
1543
|
+
opacity: isActive ? 1 : 0.6
|
1584
1544
|
});
|
1585
1545
|
}
|
1586
1546
|
});
|
@@ -1596,9 +1556,11 @@ class ArcballControls extends EventDispatcher {
|
|
1596
1556
|
});
|
1597
1557
|
|
1598
1558
|
_defineProperty(this, "getCursorPosition", (cursorX, cursorY, canvas) => {
|
1559
|
+
var _this$camera11;
|
1560
|
+
|
1599
1561
|
this._v2_1.copy(this.getCursorNDC(cursorX, cursorY, canvas));
|
1600
1562
|
|
1601
|
-
if (this.camera
|
1563
|
+
if (((_this$camera11 = this.camera) === null || _this$camera11 === void 0 ? void 0 : _this$camera11.type) === 'OrthographicCamera') {
|
1602
1564
|
this._v2_1.x *= (this.camera.right - this.camera.left) * 0.5;
|
1603
1565
|
this._v2_1.y *= (this.camera.top - this.camera.bottom) * 0.5;
|
1604
1566
|
}
|
@@ -1607,11 +1569,11 @@ class ArcballControls extends EventDispatcher {
|
|
1607
1569
|
});
|
1608
1570
|
|
1609
1571
|
_defineProperty(this, "setCamera", camera => {
|
1610
|
-
if (camera
|
1572
|
+
if (camera) {
|
1611
1573
|
camera.lookAt(this.target);
|
1612
1574
|
camera.updateMatrix(); //setting state
|
1613
1575
|
|
1614
|
-
if ((camera === null || camera === void 0 ? void 0 : camera.type) == 'PerspectiveCamera'
|
1576
|
+
if ((camera === null || camera === void 0 ? void 0 : camera.type) == 'PerspectiveCamera') {
|
1615
1577
|
this._fov0 = camera.fov;
|
1616
1578
|
this._fovState = camera.fov;
|
1617
1579
|
}
|
@@ -1636,11 +1598,7 @@ class ArcballControls extends EventDispatcher {
|
|
1636
1598
|
this._upState.copy(camera.up);
|
1637
1599
|
|
1638
1600
|
this.camera = camera;
|
1639
|
-
|
1640
|
-
if (this.camera instanceof PerspectiveCamera || this.camera instanceof OrthographicCamera) {
|
1641
|
-
this.camera.updateProjectionMatrix();
|
1642
|
-
} //making gizmos
|
1643
|
-
|
1601
|
+
this.camera.updateProjectionMatrix(); //making gizmos
|
1644
1602
|
|
1645
1603
|
const tbRadius = this.calculateTbRadius(camera);
|
1646
1604
|
|
@@ -1689,7 +1647,7 @@ class ArcballControls extends EventDispatcher {
|
|
1689
1647
|
|
1690
1648
|
this._gizmoMatrixState.copy(this._gizmoMatrixState0);
|
1691
1649
|
|
1692
|
-
if (
|
1650
|
+
if (this.camera && this.camera.zoom != 1) {
|
1693
1651
|
//adapt gizmos size to camera zoom
|
1694
1652
|
const size = 1 / this.camera.zoom;
|
1695
1653
|
|
@@ -1798,13 +1756,15 @@ class ArcballControls extends EventDispatcher {
|
|
1798
1756
|
});
|
1799
1757
|
|
1800
1758
|
_defineProperty(this, "pan", (p0, p1, adjust = false) => {
|
1801
|
-
if (this.camera
|
1759
|
+
if (this.camera) {
|
1802
1760
|
const movement = p0.clone().sub(p1);
|
1803
1761
|
|
1804
|
-
if (this.camera
|
1762
|
+
if (this.camera.type === 'OrthographicCamera') {
|
1805
1763
|
//adjust movement amount
|
1806
1764
|
movement.multiplyScalar(1 / this.camera.zoom);
|
1807
|
-
}
|
1765
|
+
}
|
1766
|
+
|
1767
|
+
if (this.camera.type === 'PerspectiveCamera' && adjust) {
|
1808
1768
|
//adjust movement amount
|
1809
1769
|
this._v3_1.setFromMatrixPosition(this._cameraMatrixState0); //camera's initial position
|
1810
1770
|
|
@@ -1827,10 +1787,10 @@ class ArcballControls extends EventDispatcher {
|
|
1827
1787
|
});
|
1828
1788
|
|
1829
1789
|
_defineProperty(this, "reset", () => {
|
1830
|
-
if (this.camera
|
1790
|
+
if (this.camera) {
|
1831
1791
|
this.camera.zoom = this._zoom0;
|
1832
1792
|
|
1833
|
-
if (this.camera
|
1793
|
+
if (this.camera.type === 'PerspectiveCamera') {
|
1834
1794
|
this.camera.fov = this._fov0;
|
1835
1795
|
}
|
1836
1796
|
|
@@ -1883,10 +1843,10 @@ class ArcballControls extends EventDispatcher {
|
|
1883
1843
|
});
|
1884
1844
|
|
1885
1845
|
_defineProperty(this, "copyState", () => {
|
1886
|
-
|
1846
|
+
if (this.camera) {
|
1847
|
+
var _this$camera12;
|
1887
1848
|
|
1888
|
-
|
1889
|
-
state = JSON.stringify({
|
1849
|
+
const state = JSON.stringify(((_this$camera12 = this.camera) === null || _this$camera12 === void 0 ? void 0 : _this$camera12.type) === 'OrthographicCamera' ? {
|
1890
1850
|
arcballState: {
|
1891
1851
|
cameraFar: this.camera.far,
|
1892
1852
|
cameraMatrix: this.camera.matrix,
|
@@ -1895,9 +1855,7 @@ class ArcballControls extends EventDispatcher {
|
|
1895
1855
|
cameraZoom: this.camera.zoom,
|
1896
1856
|
gizmoMatrix: this._gizmos.matrix
|
1897
1857
|
}
|
1898
|
-
}
|
1899
|
-
} else if (this.camera instanceof PerspectiveCamera && this.camera.isPerspectiveCamera) {
|
1900
|
-
state = JSON.stringify({
|
1858
|
+
} : {
|
1901
1859
|
arcballState: {
|
1902
1860
|
cameraFar: this.camera.far,
|
1903
1861
|
cameraFov: this.camera.fov,
|
@@ -1908,9 +1866,6 @@ class ArcballControls extends EventDispatcher {
|
|
1908
1866
|
gizmoMatrix: this._gizmos.matrix
|
1909
1867
|
}
|
1910
1868
|
});
|
1911
|
-
}
|
1912
|
-
|
1913
|
-
if (state !== undefined) {
|
1914
1869
|
navigator.clipboard.writeText(state);
|
1915
1870
|
}
|
1916
1871
|
});
|
@@ -1923,28 +1878,29 @@ class ArcballControls extends EventDispatcher {
|
|
1923
1878
|
});
|
1924
1879
|
|
1925
1880
|
_defineProperty(this, "saveState", () => {
|
1926
|
-
if (this.camera
|
1927
|
-
this._cameraMatrixState0.copy(this.camera.matrix);
|
1881
|
+
if (!this.camera) return;
|
1928
1882
|
|
1929
|
-
|
1883
|
+
this._cameraMatrixState0.copy(this.camera.matrix);
|
1930
1884
|
|
1931
|
-
|
1932
|
-
this._farPos = this.camera.far;
|
1933
|
-
this._zoom0 = this.camera.zoom;
|
1885
|
+
this._gizmoMatrixState0.copy(this._gizmos.matrix);
|
1934
1886
|
|
1935
|
-
|
1887
|
+
this._nearPos = this.camera.near;
|
1888
|
+
this._farPos = this.camera.far;
|
1889
|
+
this._zoom0 = this.camera.zoom;
|
1936
1890
|
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1891
|
+
this._up0.copy(this.camera.up);
|
1892
|
+
|
1893
|
+
if (this.camera.type === 'PerspectiveCamera') {
|
1894
|
+
this._fov0 = this.camera.fov;
|
1940
1895
|
}
|
1941
1896
|
});
|
1942
1897
|
|
1943
1898
|
_defineProperty(this, "applyScale", (size, point, scaleGizmos = true) => {
|
1899
|
+
if (!this.camera) return;
|
1944
1900
|
const scalePoint = point.clone();
|
1945
1901
|
let sizeInverse = 1 / size;
|
1946
1902
|
|
1947
|
-
if (this.camera
|
1903
|
+
if (this.camera.type === 'OrthographicCamera') {
|
1948
1904
|
//camera zoom
|
1949
1905
|
this.camera.zoom = this._zoomState;
|
1950
1906
|
this.camera.zoom *= size; //check min and max zoom
|
@@ -1982,7 +1938,9 @@ class ArcballControls extends EventDispatcher {
|
|
1982
1938
|
|
1983
1939
|
this.setTransformationMatrices(this._m4_1, this._m4_2);
|
1984
1940
|
return _transformation;
|
1985
|
-
}
|
1941
|
+
}
|
1942
|
+
|
1943
|
+
if (this.camera.type === 'PerspectiveCamera') {
|
1986
1944
|
this._v3_1.setFromMatrixPosition(this._cameraMatrixState);
|
1987
1945
|
|
1988
1946
|
this._v3_2.setFromMatrixPosition(this._gizmoMatrixState); //move camera
|
@@ -2035,14 +1993,16 @@ class ArcballControls extends EventDispatcher {
|
|
2035
1993
|
});
|
2036
1994
|
|
2037
1995
|
_defineProperty(this, "setFov", value => {
|
2038
|
-
|
1996
|
+
var _this$camera13;
|
1997
|
+
|
1998
|
+
if (((_this$camera13 = this.camera) === null || _this$camera13 === void 0 ? void 0 : _this$camera13.type) === 'PerspectiveCamera') {
|
2039
1999
|
this.camera.fov = MathUtils.clamp(value, this.minFov, this.maxFov);
|
2040
2000
|
this.camera.updateProjectionMatrix();
|
2041
2001
|
}
|
2042
2002
|
});
|
2043
2003
|
|
2044
2004
|
_defineProperty(this, "setTarget", (x, y, z) => {
|
2045
|
-
if (this.camera
|
2005
|
+
if (this.camera) {
|
2046
2006
|
this.target.set(x, y, z);
|
2047
2007
|
|
2048
2008
|
this._gizmos.position.set(x, y, z); //for correct radius calculation
|
@@ -2085,17 +2045,16 @@ class ArcballControls extends EventDispatcher {
|
|
2085
2045
|
});
|
2086
2046
|
|
2087
2047
|
_defineProperty(this, "unprojectOnObj", (cursor, camera) => {
|
2088
|
-
if (
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
}
|
2048
|
+
if (!this.scene) return null;
|
2049
|
+
const raycaster = new Raycaster();
|
2050
|
+
raycaster.near = camera.near;
|
2051
|
+
raycaster.far = camera.far;
|
2052
|
+
raycaster.setFromCamera(cursor, camera);
|
2053
|
+
const intersect = raycaster.intersectObjects(this.scene.children, true);
|
2054
|
+
|
2055
|
+
for (let i = 0; i < intersect.length; i++) {
|
2056
|
+
if (intersect[i].object.uuid != this._gizmos.uuid && intersect[i].face) {
|
2057
|
+
return intersect[i].point.clone();
|
2099
2058
|
}
|
2100
2059
|
}
|
2101
2060
|
|
@@ -2121,7 +2080,9 @@ class ArcballControls extends EventDispatcher {
|
|
2121
2080
|
}
|
2122
2081
|
|
2123
2082
|
return this._v3_1;
|
2124
|
-
}
|
2083
|
+
}
|
2084
|
+
|
2085
|
+
if (camera.type == 'PerspectiveCamera') {
|
2125
2086
|
//unproject cursor on the near plane
|
2126
2087
|
this._v2_1.copy(this.getCursorNDC(cursorX, cursorY, canvas));
|
2127
2088
|
|
@@ -2216,7 +2177,9 @@ class ArcballControls extends EventDispatcher {
|
|
2216
2177
|
this._v3_1.set(this._v2_1.x, this._v2_1.y, 0);
|
2217
2178
|
|
2218
2179
|
return this._v3_1.clone();
|
2219
|
-
}
|
2180
|
+
}
|
2181
|
+
|
2182
|
+
if (camera.type == 'PerspectiveCamera') {
|
2220
2183
|
this._v2_1.copy(this.getCursorNDC(cursorX, cursorY, canvas)); //unproject cursor on the near plane
|
2221
2184
|
|
2222
2185
|
|
@@ -2271,20 +2234,21 @@ class ArcballControls extends EventDispatcher {
|
|
2271
2234
|
});
|
2272
2235
|
|
2273
2236
|
_defineProperty(this, "updateMatrixState", () => {
|
2274
|
-
if (this.camera
|
2275
|
-
//update camera and gizmos state
|
2276
|
-
this._cameraMatrixState.copy(this.camera.matrix);
|
2237
|
+
if (!this.camera) return; //update camera and gizmos state
|
2277
2238
|
|
2278
|
-
|
2239
|
+
this._cameraMatrixState.copy(this.camera.matrix);
|
2279
2240
|
|
2280
|
-
|
2281
|
-
this._cameraProjectionState.copy(this.camera.projectionMatrix);
|
2241
|
+
this._gizmoMatrixState.copy(this._gizmos.matrix);
|
2282
2242
|
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2243
|
+
if (this.camera.type === 'OrthographicCamera') {
|
2244
|
+
this._cameraProjectionState.copy(this.camera.projectionMatrix);
|
2245
|
+
|
2246
|
+
this.camera.updateProjectionMatrix();
|
2247
|
+
this._zoomState = this.camera.zoom;
|
2248
|
+
}
|
2249
|
+
|
2250
|
+
if (this.camera.type === 'PerspectiveCamera') {
|
2251
|
+
this._fovState = this.camera.fov;
|
2288
2252
|
}
|
2289
2253
|
});
|
2290
2254
|
|
@@ -2297,11 +2261,9 @@ class ArcballControls extends EventDispatcher {
|
|
2297
2261
|
});
|
2298
2262
|
|
2299
2263
|
_defineProperty(this, "update", () => {
|
2300
|
-
var _this$camera2;
|
2301
|
-
|
2302
2264
|
const EPS = 0.000001; // Update target and gizmos state
|
2303
2265
|
|
2304
|
-
if (!this.target.equals(this._currentTarget) && this.camera
|
2266
|
+
if (!this.target.equals(this._currentTarget) && this.camera) {
|
2305
2267
|
this._gizmos.position.set(this.target.x, this.target.y, this.target.z); //for correct radius calculation
|
2306
2268
|
|
2307
2269
|
|
@@ -2314,16 +2276,19 @@ class ArcballControls extends EventDispatcher {
|
|
2314
2276
|
this.makeGizmos(this.target, this._tbRadius);
|
2315
2277
|
|
2316
2278
|
this._currentTarget.copy(this.target);
|
2317
|
-
}
|
2279
|
+
}
|
2318
2280
|
|
2281
|
+
if (!this.camera) return; //check min/max parameters
|
2319
2282
|
|
2320
|
-
if (this.camera
|
2283
|
+
if (this.camera.type === 'OrthographicCamera') {
|
2321
2284
|
//check zoom
|
2322
2285
|
if (this.camera.zoom > this.maxZoom || this.camera.zoom < this.minZoom) {
|
2323
2286
|
const newZoom = MathUtils.clamp(this.camera.zoom, this.minZoom, this.maxZoom);
|
2324
2287
|
this.applyTransformMatrix(this.applyScale(newZoom / this.camera.zoom, this._gizmos.position, true));
|
2325
2288
|
}
|
2326
|
-
}
|
2289
|
+
}
|
2290
|
+
|
2291
|
+
if (this.camera.type === 'PerspectiveCamera') {
|
2327
2292
|
//check distance
|
2328
2293
|
const distance = this.camera.position.distanceTo(this._gizmos.position);
|
2329
2294
|
|
@@ -2356,21 +2321,18 @@ class ArcballControls extends EventDispatcher {
|
|
2356
2321
|
|
2357
2322
|
for (const gizmo in this._gizmos.children) {
|
2358
2323
|
const child = this._gizmos.children[gizmo];
|
2359
|
-
|
2360
|
-
if (child instanceof Mesh) {
|
2361
|
-
child.geometry = curveGeometry;
|
2362
|
-
}
|
2324
|
+
child.geometry = curveGeometry;
|
2363
2325
|
}
|
2364
2326
|
}
|
2365
2327
|
}
|
2366
2328
|
|
2367
|
-
|
2329
|
+
this.camera.lookAt(this._gizmos.position);
|
2368
2330
|
});
|
2369
2331
|
|
2370
2332
|
_defineProperty(this, "setStateFromJSON", json => {
|
2371
2333
|
const state = JSON.parse(json);
|
2372
2334
|
|
2373
|
-
if (state.arcballState
|
2335
|
+
if (state.arcballState && this.camera) {
|
2374
2336
|
this._cameraMatrixState.fromArray(state.arcballState.cameraMatrix.elements);
|
2375
2337
|
|
2376
2338
|
this._cameraMatrixState.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
|
@@ -2380,7 +2342,7 @@ class ArcballControls extends EventDispatcher {
|
|
2380
2342
|
this.camera.far = state.arcballState.cameraFar;
|
2381
2343
|
this.camera.zoom = state.arcballState.cameraZoom;
|
2382
2344
|
|
2383
|
-
if (this.camera
|
2345
|
+
if (this.camera.type === 'PerspectiveCamera') {
|
2384
2346
|
this.camera.fov = state.arcballState.cameraFov;
|
2385
2347
|
}
|
2386
2348
|
|
@@ -2411,7 +2373,7 @@ class ArcballControls extends EventDispatcher {
|
|
2411
2373
|
});
|
2412
2374
|
|
2413
2375
|
this.camera = null;
|
2414
|
-
this.domElement =
|
2376
|
+
this.domElement = _domElement;
|
2415
2377
|
this.scene = scene;
|
2416
2378
|
this.mouseActions = [];
|
2417
2379
|
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 +2431,6 @@ class ArcballControls extends EventDispatcher {
|
|
2469
2431
|
this._downValid = true;
|
2470
2432
|
this._nclicks = 0;
|
2471
2433
|
this._downEvents = [];
|
2472
|
-
this._downStart = 0; //pointerDown time
|
2473
|
-
|
2474
2434
|
this._clickStart = 0; //first click time
|
2475
2435
|
|
2476
2436
|
this._maxDownTime = 250;
|
@@ -2530,7 +2490,6 @@ class ArcballControls extends EventDispatcher {
|
|
2530
2490
|
this.enablePan = true;
|
2531
2491
|
this.enableRotate = true;
|
2532
2492
|
this.enableZoom = true;
|
2533
|
-
this.enableGizmos = true;
|
2534
2493
|
this.minDistance = 0;
|
2535
2494
|
this.maxDistance = Infinity;
|
2536
2495
|
this.minZoom = 0;
|
@@ -2543,18 +2502,13 @@ class ArcballControls extends EventDispatcher {
|
|
2543
2502
|
this._state = STATE.IDLE;
|
2544
2503
|
this.setCamera(_camera);
|
2545
2504
|
|
2546
|
-
if (this.scene
|
2505
|
+
if (this.scene) {
|
2547
2506
|
this.scene.add(this._gizmos);
|
2548
2507
|
}
|
2549
2508
|
|
2550
|
-
this.domElement.style.touchAction = 'none';
|
2551
2509
|
this._devPxRatio = window.devicePixelRatio;
|
2552
2510
|
this.initializeMouseActions();
|
2553
|
-
this.domElement.
|
2554
|
-
this.domElement.addEventListener('wheel', this.onWheel);
|
2555
|
-
this.domElement.addEventListener('pointerdown', this.onPointerDown);
|
2556
|
-
this.domElement.addEventListener('pointercancel', this.onPointerCancel);
|
2557
|
-
window.addEventListener('keydown', this.onKeyDown);
|
2511
|
+
if (this.domElement) this.connect(this.domElement);
|
2558
2512
|
window.addEventListener('resize', this.onWindowResize);
|
2559
2513
|
} //listeners
|
2560
2514
|
|
@@ -2564,7 +2518,7 @@ class ArcballControls extends EventDispatcher {
|
|
2564
2518
|
* @param {Object} transformation Object containing matrices to apply to camera and gizmos
|
2565
2519
|
*/
|
2566
2520
|
applyTransformMatrix(transformation) {
|
2567
|
-
if (
|
2521
|
+
if (transformation !== null && transformation !== void 0 && transformation.camera && this.camera) {
|
2568
2522
|
this._m4_1.copy(this._cameraMatrixState).premultiply(transformation.camera);
|
2569
2523
|
|
2570
2524
|
this._m4_1.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
|
@@ -2576,7 +2530,7 @@ class ArcballControls extends EventDispatcher {
|
|
2576
2530
|
}
|
2577
2531
|
}
|
2578
2532
|
|
2579
|
-
if (
|
2533
|
+
if (transformation !== null && transformation !== void 0 && transformation.gizmos) {
|
2580
2534
|
this._m4_1.copy(this._gizmoMatrixState).premultiply(transformation.gizmos);
|
2581
2535
|
|
2582
2536
|
this._m4_1.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
|
@@ -2584,7 +2538,7 @@ class ArcballControls extends EventDispatcher {
|
|
2584
2538
|
this._gizmos.updateMatrix();
|
2585
2539
|
}
|
2586
2540
|
|
2587
|
-
if ((this._state == STATE.SCALE || this._state == STATE.FOCUS || this._state == STATE.ANIMATION_FOCUS) &&
|
2541
|
+
if ((this._state == STATE.SCALE || this._state == STATE.FOCUS || this._state == STATE.ANIMATION_FOCUS) && this.camera) {
|
2588
2542
|
const tbRadius = this.calculateTbRadius(this.camera);
|
2589
2543
|
|
2590
2544
|
if (tbRadius !== undefined) {
|
@@ -2655,8 +2609,8 @@ class ArcballControls extends EventDispatcher {
|
|
2655
2609
|
* @param {Matrix4} gizmos Transformation to be applied to gizmos
|
2656
2610
|
*/
|
2657
2611
|
setTransformationMatrices(camera = null, gizmos = null) {
|
2658
|
-
if (camera
|
2659
|
-
if (_transformation.camera
|
2612
|
+
if (camera) {
|
2613
|
+
if (_transformation.camera) {
|
2660
2614
|
_transformation.camera.copy(camera);
|
2661
2615
|
} else {
|
2662
2616
|
_transformation.camera = camera.clone();
|
@@ -2665,8 +2619,8 @@ class ArcballControls extends EventDispatcher {
|
|
2665
2619
|
_transformation.camera = null;
|
2666
2620
|
}
|
2667
2621
|
|
2668
|
-
if (gizmos
|
2669
|
-
if (_transformation.gizmos
|
2622
|
+
if (gizmos) {
|
2623
|
+
if (_transformation.gizmos) {
|
2670
2624
|
_transformation.gizmos.copy(gizmos);
|
2671
2625
|
} else {
|
2672
2626
|
_transformation.gizmos = gizmos.clone();
|