@shopware-ag/dive 2.3.7 → 3.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/build/chunks/Animator-DHnpWRt_.mjs +16 -0
  2. package/build/chunks/Animator-YDE8aFEd.cjs +1 -0
  3. package/build/chunks/{AssetCache-DSpWOp3n.mjs → AssetCache-C2DuXcmp.mjs} +6 -5
  4. package/build/chunks/AssetCache-CnbDDhU8.cjs +1 -0
  5. package/build/chunks/AssetExporter-Cdxb04b3.cjs +1 -0
  6. package/build/chunks/AssetExporter-DLL_vJae.mjs +67 -0
  7. package/build/chunks/AssetLoader-DO7xlbC3.mjs +499 -0
  8. package/build/chunks/AssetLoader-h2uyFEfZ.cjs +3 -0
  9. package/build/chunks/{ClipAnimator-keFLDMNZ.mjs → ClipAnimator-D8Gho4Ec.mjs} +2 -2
  10. package/build/chunks/ClipAnimator-SdDq2wk1.cjs +1 -0
  11. package/build/chunks/FileTypes-BB4_1gBJ.mjs +1975 -0
  12. package/build/chunks/FileTypes-Bvt5QTJC.cjs +29 -0
  13. package/build/chunks/GridNode-0R5ZnzR6.mjs +30 -0
  14. package/build/chunks/GridNode-iqnu86_v.cjs +1 -0
  15. package/build/chunks/{PerspectiveCamera-BFzE2TQU.mjs → PerspectiveCamera-B5TvUzTa.mjs} +1 -1
  16. package/build/chunks/PerspectiveCamera-DwQUmkDv.cjs +1 -0
  17. package/build/chunks/{TargetAnimator-DuqPk2eq.cjs → TargetAnimator-D37bWNKD.cjs} +1 -1
  18. package/build/chunks/{TargetAnimator-DUqkkdVb.mjs → TargetAnimator-DL_9b921.mjs} +1 -1
  19. package/build/chunks/{isFileTypeSupported-zLrD710P.mjs → isFileTypeSupported-D1z0zckw.mjs} +1 -1
  20. package/build/chunks/{isFileTypeSupported-Bh5Scxis.cjs → isFileTypeSupported-MJWHcUsR.cjs} +1 -1
  21. package/build/components/boundingbox/BoundingBox.d.ts +1 -1
  22. package/build/components/floor/Floor.d.ts +1 -1
  23. package/build/components/gizmo/Gizmo.d.ts +1 -1
  24. package/build/components/gizmo/handles/AxisHandle.d.ts +1 -1
  25. package/build/components/gizmo/handles/RadialHandle.d.ts +1 -1
  26. package/build/components/gizmo/handles/ScaleHandle.d.ts +1 -1
  27. package/build/components/gizmo/plane/GizmoPlane.d.ts +1 -1
  28. package/build/components/gizmo/rotate/RotateGizmo.d.ts +1 -1
  29. package/build/components/gizmo/scale/ScaleGizmo.d.ts +1 -1
  30. package/build/components/gizmo/translate/TranslateGizmo.d.ts +1 -1
  31. package/build/components/grid/Grid.d.ts +2 -1
  32. package/build/components/group/Group.d.ts +1 -1
  33. package/build/components/light/AmbientLight.d.ts +1 -1
  34. package/build/components/light/PointLight.d.ts +1 -1
  35. package/build/components/light/SceneLight.d.ts +1 -1
  36. package/build/components/model/Model.d.ts +1 -1
  37. package/build/components/node/Node.d.ts +1 -1
  38. package/build/components/primitive/Primitive.d.ts +1 -1
  39. package/build/components/root/Root.d.ts +1 -1
  40. package/build/dive.cjs +1 -1
  41. package/build/dive.mjs +58 -60
  42. package/build/engine/Dive.d.ts +3 -31
  43. package/build/engine/camera/PerspectiveCamera.d.ts +1 -1
  44. package/build/engine/environment/Environment.d.ts +12 -27
  45. package/build/engine/renderer/Renderer.d.ts +7 -8
  46. package/build/engine/scene/Scene.d.ts +1 -1
  47. package/build/engine/scene/xrroot/XRRoot.d.ts +2 -3
  48. package/build/engine/scene/xrroot/xrlightroot/XRLightRoot.d.ts +3 -3
  49. package/build/helpers/findInterface/findInterface.d.ts +1 -1
  50. package/build/helpers/findSceneRecursive/findSceneRecursive.d.ts +1 -1
  51. package/build/helpers/implementsInterface/implementsInterface.d.ts +1 -1
  52. package/build/helpers/math/signedAngleTo/signedAngleTo.d.ts +1 -1
  53. package/build/interfaces/Hoverable.d.ts +1 -1
  54. package/build/plugins/animation/index.cjs +1 -1
  55. package/build/plugins/animation/index.mjs +12 -20
  56. package/build/plugins/animation/src/animator/Animator.d.ts +1 -1
  57. package/build/plugins/animation/src/animator/ClipAnimator.d.ts +1 -1
  58. package/build/plugins/animation/src/system/AnimationSystem.d.ts +1 -6
  59. package/build/plugins/animation/src/types/AnimatorTypes.d.ts +1 -1
  60. package/build/plugins/ar/index.cjs +1 -1
  61. package/build/plugins/ar/index.mjs +5 -4
  62. package/build/plugins/ar/src/webxr/controller/WebXRController.d.ts +1 -1
  63. package/build/plugins/ar/src/webxr/crosshair/WebXRCrosshair.d.ts +1 -1
  64. package/build/plugins/ar/src/webxr/origin/WebXROrigin.d.ts +1 -1
  65. package/build/plugins/ar/src/webxr/raycaster/WebXRRaycaster.d.ts +1 -1
  66. package/build/plugins/ar/src/webxr/touchscreencontrols/WebXRTouchscreenControls.d.ts +1 -1
  67. package/build/plugins/assetcache/index.cjs +1 -1
  68. package/build/plugins/assetcache/index.mjs +1 -1
  69. package/build/plugins/assetexporter/index.cjs +1 -1
  70. package/build/plugins/assetexporter/index.mjs +1 -1
  71. package/build/plugins/assetexporter/src/AssetExporter.d.ts +1 -1
  72. package/build/plugins/assetloader/index.cjs +1 -1
  73. package/build/plugins/assetloader/index.mjs +2 -2
  74. package/build/plugins/assetloader/src/loader/AssetLoader.d.ts +2 -2
  75. package/build/plugins/assetloader/src/step/STEPLoader.d.ts +1 -1
  76. package/build/plugins/mediacreator/index.cjs +1 -1
  77. package/build/plugins/mediacreator/index.mjs +52 -24
  78. package/build/plugins/mediacreator/src/MediaCreator.d.ts +4 -3
  79. package/build/plugins/mediacreator/types/MediaGenerationByPosition.d.ts +1 -1
  80. package/build/plugins/orbitcontroller/index.cjs +1 -1
  81. package/build/plugins/orbitcontroller/index.mjs +1 -1
  82. package/build/plugins/orbitcontroller/src/OrbitController.d.ts +1 -1
  83. package/build/plugins/orbitcontroller/types/OrbitControllerState.types.d.ts +1 -1
  84. package/build/plugins/orientationdisplay/index.cjs +1 -1
  85. package/build/plugins/orientationdisplay/index.mjs +17 -16
  86. package/build/plugins/orientationdisplay/src/axes/Axes.d.ts +1 -1
  87. package/build/plugins/quickview/index.cjs +1 -1
  88. package/build/plugins/quickview/index.mjs +9 -8
  89. package/build/plugins/shader/index.cjs +1 -1
  90. package/build/plugins/shader/index.mjs +2 -3
  91. package/build/plugins/shader/src/index.d.ts +1 -3
  92. package/build/plugins/shader/src/shaders/GridNode.d.ts +16 -0
  93. package/build/plugins/state/index.cjs +11 -11
  94. package/build/plugins/state/index.mjs +1538 -1537
  95. package/build/plugins/state/src/actions/camera/computeencompassingview.d.ts +1 -1
  96. package/build/plugins/state/src/actions/camera/getcameratransform.d.ts +1 -1
  97. package/build/plugins/state/src/actions/camera/movecamera.d.ts +1 -1
  98. package/build/plugins/state/src/actions/camera/setcameratransform.d.ts +1 -1
  99. package/build/plugins/state/types/StateSceneData.d.ts +1 -1
  100. package/build/plugins/toolbox/index.cjs +1 -1
  101. package/build/plugins/toolbox/index.d.ts +0 -1
  102. package/build/plugins/toolbox/index.mjs +224 -853
  103. package/build/plugins/toolbox/src/PointerContext.d.ts +1 -1
  104. package/build/plugins/toolbox/src/SelectionState.d.ts +1 -1
  105. package/build/plugins/toolbox/src/Toolbox.d.ts +0 -10
  106. package/build/plugins/toolbox/src/drag/DragTool.d.ts +1 -1
  107. package/build/plugins/toolbox/src/drag/DraggableEvent.d.ts +1 -1
  108. package/build/plugins/toolbox/src/hover/HoverTool.d.ts +1 -1
  109. package/build/plugins/toolbox/src/select/SelectTool.d.ts +1 -1
  110. package/build/plugins/toolbox/src/transform/TransformTool.d.ts +2 -1
  111. package/build/types/schema/GroupSchema.d.ts +1 -1
  112. package/build/types/schema/LightSchema.d.ts +1 -1
  113. package/build/types/schema/MaterialSchema.d.ts +1 -1
  114. package/build/types/schema/ModelSchema.d.ts +1 -1
  115. package/build/types/schema/PovSchema.d.ts +1 -1
  116. package/build/types/schema/PrimitiveSchema.d.ts +1 -1
  117. package/package.json +5 -4
  118. package/build/chunks/Animator-BGFdF70Z.mjs +0 -47
  119. package/build/chunks/Animator-Cu7NIkVg.cjs +0 -1
  120. package/build/chunks/AssetCache-DJyYrAdR.cjs +0 -1
  121. package/build/chunks/AssetExporter-PFiNYi50.mjs +0 -1628
  122. package/build/chunks/AssetExporter-yVhYmVXW.cjs +0 -164
  123. package/build/chunks/AssetLoader-BA_QwJMR.mjs +0 -2590
  124. package/build/chunks/AssetLoader-DJb8P6eB.cjs +0 -5
  125. package/build/chunks/ClipAnimator-tjhLo851.cjs +0 -1
  126. package/build/chunks/DIVEShaderMaterial-Bt0d8oJB.mjs +0 -3468
  127. package/build/chunks/DIVEShaderMaterial-DE8YRWj9.cjs +0 -1554
  128. package/build/chunks/FileTypes-BSJhZREN.cjs +0 -33
  129. package/build/chunks/FileTypes-CUf24rq6.mjs +0 -2155
  130. package/build/chunks/PerspectiveCamera-iAsZqrnY.cjs +0 -1
  131. package/build/chunks/draco_decoder-Bh9flJPu.cjs +0 -1
  132. package/build/chunks/draco_decoder-CEzwqP9o.mjs +0 -38
  133. package/build/chunks/draco_decoder-DtHHc5d0.mjs +0 -4
  134. package/build/chunks/draco_decoder-DvYjcLz_.cjs +0 -35
  135. package/build/chunks/draco_wasm_wrapper-FoEVV9af.cjs +0 -118
  136. package/build/chunks/draco_wasm_wrapper-yQy2VLhb.mjs +0 -121
  137. package/build/chunks/fflate.module-DHdJvhNh.cjs +0 -6
  138. package/build/chunks/fflate.module-xyO_T3Zm.mjs +0 -602
  139. package/build/plugins/shader/src/material/DIVEShaderMaterial.d.ts +0 -5
  140. package/build/plugins/shader/src/shaders/DIVEShaderLib.d.ts +0 -2
  141. package/build/plugins/shader/src/shaders/grid/index.d.ts +0 -40
  142. package/build/plugins/toolbox/src/BaseTool.d.ts +0 -59
@@ -1,13 +1,15 @@
1
- var Ht = Object.defineProperty;
2
- var Xt = (l, e, t) => e in l ? Ht(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var o = (l, e, t) => Xt(l, typeof e != "symbol" ? e + "" : e, t);
4
- import { Object3D as ht, Vector3 as h, Quaternion as E, Raycaster as ot, MeshBasicMaterial as Dt, LineBasicMaterial as kt, CylinderGeometry as w, BoxGeometry as f, BufferGeometry as dt, Float32BufferAttribute as pt, Mesh as r, OctahedronGeometry as tt, Line as A, TorusGeometry as Q, SphereGeometry as Yt, Euler as Qt, Matrix4 as Et, PlaneGeometry as Ot, DoubleSide as Rt, EventDispatcher as Zt, Vector2 as F, Layers as _t } from "three";
5
- import "../../chunks/FileTypes-CUf24rq6.mjs";
6
- import { P as G, U as W } from "../../chunks/PerspectiveCamera-BFzE2TQU.mjs";
7
- import "../../chunks/DIVEShaderMaterial-Bt0d8oJB.mjs";
8
- import { f as B, i as O } from "../../chunks/findInterface-DbJ5qzbc.mjs";
9
- import { A as ut, a as gt, b as ft } from "../../chunks/AxisHelperColors-JLBHYQDi.mjs";
10
- class Gt {
1
+ var S = Object.defineProperty;
2
+ var w = (n, t, e) => t in n ? S(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var o = (n, t, e) => w(n, typeof t != "symbol" ? t + "" : t, e);
4
+ import { EventDispatcher as T, Vector3 as l, Raycaster as P, Vector2 as f, Layers as m } from "three/webgpu";
5
+ import "../../chunks/FileTypes-BB4_1gBJ.mjs";
6
+ import { P as _, U as d } from "../../chunks/PerspectiveCamera-B5TvUzTa.mjs";
7
+ import "three/examples/jsm/loaders/HDRLoader.js";
8
+ import "three/tsl";
9
+ import { f as g, i as h } from "../../chunks/findInterface-DbJ5qzbc.mjs";
10
+ import { TransformControls as E } from "three/examples/jsm/controls/TransformControls.js";
11
+ import { A as b, a as D, b as y } from "../../chunks/AxisHelperColors-JLBHYQDi.mjs";
12
+ class z {
11
13
  constructor() {
12
14
  o(this, "_selected", null);
13
15
  o(this, "_listeners", /* @__PURE__ */ new Set());
@@ -22,29 +24,29 @@ class Gt {
22
24
  * Select an object. Deselects any previously selected object.
23
25
  * Calls onSelect on the new object and onDeselect on the previous.
24
26
  */
25
- select(e) {
26
- var t, i, n;
27
- this._selected !== e && (this._selected && ((i = (t = this._selected).onDeselect) == null || i.call(t)), this._selected = e, (n = e.onSelect) == null || n.call(e), this.notifyListeners());
27
+ select(t) {
28
+ var e, s, i;
29
+ this._selected !== t && (this._selected && ((s = (e = this._selected).onDeselect) == null || s.call(e)), this._selected = t, (i = t.onSelect) == null || i.call(t), this.notifyListeners());
28
30
  }
29
31
  /**
30
32
  * Deselect the currently selected object.
31
33
  * Calls onDeselect on the object.
32
34
  */
33
35
  deselect() {
34
- var e, t;
35
- this._selected && ((t = (e = this._selected).onDeselect) == null || t.call(e), this._selected = null, this.notifyListeners());
36
+ var t, e;
37
+ this._selected && ((e = (t = this._selected).onDeselect) == null || e.call(t), this._selected = null, this.notifyListeners());
36
38
  }
37
39
  /**
38
40
  * Register a callback to be notified when selection changes.
39
41
  */
40
- onChange(e) {
41
- this._listeners.add(e);
42
+ onChange(t) {
43
+ this._listeners.add(t);
42
44
  }
43
45
  /**
44
46
  * Unregister a previously registered callback.
45
47
  */
46
- offChange(e) {
47
- this._listeners.delete(e);
48
+ offChange(t) {
49
+ this._listeners.delete(t);
48
50
  }
49
51
  /**
50
52
  * Dispose of the selection state and clear all listeners.
@@ -53,11 +55,11 @@ class Gt {
53
55
  this._selected = null, this._listeners.clear();
54
56
  }
55
57
  notifyListeners() {
56
- for (const e of this._listeners)
57
- e(this._selected);
58
+ for (const t of this._listeners)
59
+ t(this._selected);
58
60
  }
59
61
  }
60
- class Wt {
62
+ class C {
61
63
  constructor() {
62
64
  o(this, "name", "hover");
63
65
  o(this, "priority", 20);
@@ -73,37 +75,37 @@ class Wt {
73
75
  this._hovered = null;
74
76
  }
75
77
  onDeactivate() {
76
- var e, t;
77
- this._hovered && ((t = (e = this._hovered).onPointerLeave) == null || t.call(e), this._hovered = null);
78
+ var t, e;
79
+ this._hovered && ((e = (t = this._hovered).onPointerLeave) == null || e.call(t), this._hovered = null);
78
80
  }
79
- onPointerMove(e) {
80
- var n, a, s, c, u, P, M;
81
- const t = e.modelIntersects[0], i = B(
82
- t == null ? void 0 : t.object,
81
+ onPointerMove(t) {
82
+ var i, r, a, c, u, p, v;
83
+ const e = t.modelIntersects[0], s = g(
84
+ e == null ? void 0 : e.object,
83
85
  "isHoverable"
84
86
  );
85
- if (t && i) {
87
+ if (e && s) {
86
88
  if (!this._hovered) {
87
- (n = i.onPointerEnter) == null || n.call(i, t), this._hovered = i;
89
+ (i = s.onPointerEnter) == null || i.call(s, e), this._hovered = s;
88
90
  return;
89
91
  }
90
- if (this._hovered.uuid !== i.uuid) {
91
- (s = (a = this._hovered).onPointerLeave) == null || s.call(a), (c = i.onPointerEnter) == null || c.call(i, t), this._hovered = i;
92
+ if (this._hovered.uuid !== s.uuid) {
93
+ (a = (r = this._hovered).onPointerLeave) == null || a.call(r), (c = s.onPointerEnter) == null || c.call(s, e), this._hovered = s;
92
94
  return;
93
95
  }
94
- (u = i.onPointerOver) == null || u.call(i, t);
96
+ (u = s.onPointerOver) == null || u.call(s, e);
95
97
  return;
96
98
  }
97
- this._hovered && ((M = (P = this._hovered).onPointerLeave) == null || M.call(P), this._hovered = null);
99
+ this._hovered && ((v = (p = this._hovered).onPointerLeave) == null || v.call(p), this._hovered = null);
98
100
  }
99
101
  }
100
- const de = (l) => l.name === "select";
101
- class qt {
102
- constructor(e) {
102
+ const B = (n) => n.name === "select";
103
+ class M {
104
+ constructor(t) {
103
105
  o(this, "name", "select");
104
106
  o(this, "priority", 30);
105
107
  o(this, "_selectionState");
106
- this._selectionState = e;
108
+ this._selectionState = t;
107
109
  }
108
110
  /**
109
111
  * Get the currently selected object.
@@ -115,23 +117,23 @@ class qt {
115
117
  }
116
118
  onDeactivate() {
117
119
  }
118
- onClick(e) {
119
- const t = e.modelIntersects[0], i = B(
120
- t == null ? void 0 : t.object,
120
+ onClick(t) {
121
+ const e = t.modelIntersects[0], s = g(
122
+ e == null ? void 0 : e.object,
121
123
  "isSelectable"
122
124
  );
123
- if (!t || !i) {
125
+ if (!e || !s) {
124
126
  this._selectionState.deselect();
125
127
  return;
126
128
  }
127
- const n = this._selectionState.selected;
128
- n && n.uuid === i.uuid || this._selectionState.select(i);
129
+ const i = this._selectionState.selected;
130
+ i && i.uuid === s.uuid || this._selectionState.select(s);
129
131
  }
130
132
  /**
131
133
  * Programmatically select an object.
132
134
  */
133
- select(e) {
134
- this._selectionState.select(e);
135
+ select(t) {
136
+ this._selectionState.select(t);
135
137
  }
136
138
  /**
137
139
  * Programmatically deselect the current selection.
@@ -140,469 +142,9 @@ class qt {
140
142
  this._selectionState.deselect();
141
143
  }
142
144
  }
143
- const j = new ot(), _ = new h(), C = new h(), p = new E(), mt = {
144
- X: new h(1, 0, 0),
145
- Y: new h(0, 1, 0),
146
- Z: new h(0, 0, 1)
147
- }, rt = { type: "change" }, wt = { type: "mouseDown" }, yt = { type: "mouseUp", mode: null }, bt = { type: "objectChange" };
148
- class Ut extends ht {
149
- constructor(e, t) {
150
- super(), t === void 0 && (console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'), t = document), this.isTransformControls = !0, this.visible = !1, this.domElement = t, this.domElement.style.touchAction = "none";
151
- const i = new $t();
152
- this._gizmo = i, this.add(i);
153
- const n = new Jt();
154
- this._plane = n, this.add(n);
155
- const a = this;
156
- function s(g, b) {
157
- let H = b;
158
- Object.defineProperty(a, g, {
159
- get: function() {
160
- return H !== void 0 ? H : b;
161
- },
162
- set: function(z) {
163
- H !== z && (H = z, n[g] = z, i[g] = z, a.dispatchEvent({ type: g + "-changed", value: z }), a.dispatchEvent(rt));
164
- }
165
- }), a[g] = b, n[g] = b, i[g] = b;
166
- }
167
- s("camera", e), s("object", void 0), s("enabled", !0), s("axis", null), s("mode", "translate"), s("translationSnap", null), s("rotationSnap", null), s("scaleSnap", null), s("space", "world"), s("size", 1), s("dragging", !1), s("showX", !0), s("showY", !0), s("showZ", !0);
168
- const c = new h(), u = new h(), P = new E(), M = new E(), k = new h(), Y = new E(), lt = new h(), V = new h(), x = new h(), I = 0, S = new h();
169
- s("worldPosition", c), s("worldPositionStart", u), s("worldQuaternion", P), s("worldQuaternionStart", M), s("cameraPosition", k), s("cameraQuaternion", Y), s("pointStart", lt), s("pointEnd", V), s("rotationAxis", x), s("rotationAngle", I), s("eye", S), this._offset = new h(), this._startNorm = new h(), this._endNorm = new h(), this._cameraScale = new h(), this._parentPosition = new h(), this._parentQuaternion = new E(), this._parentQuaternionInv = new E(), this._parentScale = new h(), this._worldScaleStart = new h(), this._worldQuaternionInv = new E(), this._worldScale = new h(), this._positionStart = new h(), this._quaternionStart = new E(), this._scaleStart = new h(), this._getPointer = Ft.bind(this), this._onPointerDown = Vt.bind(this), this._onPointerHover = Bt.bind(this), this._onPointerMove = Nt.bind(this), this._onPointerUp = Kt.bind(this), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointermove", this._onPointerHover), this.domElement.addEventListener("pointerup", this._onPointerUp);
170
- }
171
- // updateMatrixWorld updates key transformation variables
172
- updateMatrixWorld(e) {
173
- this.object !== void 0 && (this.object.updateMatrixWorld(), this.object.parent === null ? console.error("TransformControls: The attached 3D object must be a part of the scene graph.") : this.object.parent.matrixWorld.decompose(this._parentPosition, this._parentQuaternion, this._parentScale), this.object.matrixWorld.decompose(this.worldPosition, this.worldQuaternion, this._worldScale), this._parentQuaternionInv.copy(this._parentQuaternion).invert(), this._worldQuaternionInv.copy(this.worldQuaternion).invert()), this.camera.updateMatrixWorld(), this.camera.matrixWorld.decompose(this.cameraPosition, this.cameraQuaternion, this._cameraScale), this.camera.isOrthographicCamera ? this.camera.getWorldDirection(this.eye).negate() : this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(), super.updateMatrixWorld(e);
174
- }
175
- pointerHover(e) {
176
- if (this.object === void 0 || this.dragging === !0) return;
177
- e !== null && j.setFromCamera(e, this.camera);
178
- const t = at(this._gizmo.picker[this.mode], j);
179
- t ? this.axis = t.object.name : this.axis = null;
180
- }
181
- pointerDown(e) {
182
- if (!(this.object === void 0 || this.dragging === !0 || e != null && e.button !== 0) && this.axis !== null) {
183
- e !== null && j.setFromCamera(e, this.camera);
184
- const t = at(this._plane, j, !0);
185
- t && (this.object.updateMatrixWorld(), this.object.parent.updateMatrixWorld(), this._positionStart.copy(this.object.position), this._quaternionStart.copy(this.object.quaternion), this._scaleStart.copy(this.object.scale), this.object.matrixWorld.decompose(this.worldPositionStart, this.worldQuaternionStart, this._worldScaleStart), this.pointStart.copy(t.point).sub(this.worldPositionStart)), this.dragging = !0, wt.mode = this.mode, this.dispatchEvent(wt);
186
- }
187
- }
188
- pointerMove(e) {
189
- const t = this.axis, i = this.mode, n = this.object;
190
- let a = this.space;
191
- if (i === "scale" ? a = "local" : (t === "E" || t === "XYZE" || t === "XYZ") && (a = "world"), n === void 0 || t === null || this.dragging === !1 || e !== null && e.button !== -1) return;
192
- e !== null && j.setFromCamera(e, this.camera);
193
- const s = at(this._plane, j, !0);
194
- if (s) {
195
- if (this.pointEnd.copy(s.point).sub(this.worldPositionStart), i === "translate")
196
- this._offset.copy(this.pointEnd).sub(this.pointStart), a === "local" && t !== "XYZ" && this._offset.applyQuaternion(this._worldQuaternionInv), t.indexOf("X") === -1 && (this._offset.x = 0), t.indexOf("Y") === -1 && (this._offset.y = 0), t.indexOf("Z") === -1 && (this._offset.z = 0), a === "local" && t !== "XYZ" ? this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale) : this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale), n.position.copy(this._offset).add(this._positionStart), this.translationSnap && (a === "local" && (n.position.applyQuaternion(p.copy(this._quaternionStart).invert()), t.search("X") !== -1 && (n.position.x = Math.round(n.position.x / this.translationSnap) * this.translationSnap), t.search("Y") !== -1 && (n.position.y = Math.round(n.position.y / this.translationSnap) * this.translationSnap), t.search("Z") !== -1 && (n.position.z = Math.round(n.position.z / this.translationSnap) * this.translationSnap), n.position.applyQuaternion(this._quaternionStart)), a === "world" && (n.parent && n.position.add(_.setFromMatrixPosition(n.parent.matrixWorld)), t.search("X") !== -1 && (n.position.x = Math.round(n.position.x / this.translationSnap) * this.translationSnap), t.search("Y") !== -1 && (n.position.y = Math.round(n.position.y / this.translationSnap) * this.translationSnap), t.search("Z") !== -1 && (n.position.z = Math.round(n.position.z / this.translationSnap) * this.translationSnap), n.parent && n.position.sub(_.setFromMatrixPosition(n.parent.matrixWorld))));
197
- else if (i === "scale") {
198
- if (t.search("XYZ") !== -1) {
199
- let c = this.pointEnd.length() / this.pointStart.length();
200
- this.pointEnd.dot(this.pointStart) < 0 && (c *= -1), C.set(c, c, c);
201
- } else
202
- _.copy(this.pointStart), C.copy(this.pointEnd), _.applyQuaternion(this._worldQuaternionInv), C.applyQuaternion(this._worldQuaternionInv), C.divide(_), t.search("X") === -1 && (C.x = 1), t.search("Y") === -1 && (C.y = 1), t.search("Z") === -1 && (C.z = 1);
203
- n.scale.copy(this._scaleStart).multiply(C), this.scaleSnap && (t.search("X") !== -1 && (n.scale.x = Math.round(n.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap), t.search("Y") !== -1 && (n.scale.y = Math.round(n.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap), t.search("Z") !== -1 && (n.scale.z = Math.round(n.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap));
204
- } else if (i === "rotate") {
205
- this._offset.copy(this.pointEnd).sub(this.pointStart);
206
- const c = 20 / this.worldPosition.distanceTo(_.setFromMatrixPosition(this.camera.matrixWorld));
207
- let u = !1;
208
- t === "XYZE" ? (this.rotationAxis.copy(this._offset).cross(this.eye).normalize(), this.rotationAngle = this._offset.dot(_.copy(this.rotationAxis).cross(this.eye)) * c) : (t === "X" || t === "Y" || t === "Z") && (this.rotationAxis.copy(mt[t]), _.copy(mt[t]), a === "local" && _.applyQuaternion(this.worldQuaternion), _.cross(this.eye), _.length() === 0 ? u = !0 : this.rotationAngle = this._offset.dot(_.normalize()) * c), (t === "E" || u) && (this.rotationAxis.copy(this.eye), this.rotationAngle = this.pointEnd.angleTo(this.pointStart), this._startNorm.copy(this.pointStart).normalize(), this._endNorm.copy(this.pointEnd).normalize(), this.rotationAngle *= this._endNorm.cross(this._startNorm).dot(this.eye) < 0 ? 1 : -1), this.rotationSnap && (this.rotationAngle = Math.round(this.rotationAngle / this.rotationSnap) * this.rotationSnap), a === "local" && t !== "E" && t !== "XYZE" ? (n.quaternion.copy(this._quaternionStart), n.quaternion.multiply(p.setFromAxisAngle(this.rotationAxis, this.rotationAngle)).normalize()) : (this.rotationAxis.applyQuaternion(this._parentQuaternionInv), n.quaternion.copy(p.setFromAxisAngle(this.rotationAxis, this.rotationAngle)), n.quaternion.multiply(this._quaternionStart).normalize());
209
- }
210
- this.dispatchEvent(rt), this.dispatchEvent(bt);
211
- }
212
- }
213
- pointerUp(e) {
214
- e !== null && e.button !== 0 || (this.dragging && this.axis !== null && (yt.mode = this.mode, this.dispatchEvent(yt)), this.dragging = !1, this.axis = null);
215
- }
216
- dispose() {
217
- this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointermove", this._onPointerHover), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.traverse(function(e) {
218
- e.geometry && e.geometry.dispose(), e.material && e.material.dispose();
219
- });
220
- }
221
- // Set current object
222
- attach(e) {
223
- return this.object = e, this.visible = !0, this;
224
- }
225
- // Detach from object
226
- detach() {
227
- return this.object = void 0, this.visible = !1, this.axis = null, this;
228
- }
229
- reset() {
230
- this.enabled && this.dragging && (this.object.position.copy(this._positionStart), this.object.quaternion.copy(this._quaternionStart), this.object.scale.copy(this._scaleStart), this.dispatchEvent(rt), this.dispatchEvent(bt), this.pointStart.copy(this.pointEnd));
231
- }
232
- getRaycaster() {
233
- return j;
234
- }
235
- // TODO: deprecate
236
- getMode() {
237
- return this.mode;
238
- }
239
- setMode(e) {
240
- this.mode = e;
241
- }
242
- setTranslationSnap(e) {
243
- this.translationSnap = e;
244
- }
245
- setRotationSnap(e) {
246
- this.rotationSnap = e;
247
- }
248
- setScaleSnap(e) {
249
- this.scaleSnap = e;
250
- }
251
- setSize(e) {
252
- this.size = e;
253
- }
254
- setSpace(e) {
255
- this.space = e;
256
- }
257
- }
258
- function Ft(l) {
259
- if (this.domElement.ownerDocument.pointerLockElement)
260
- return {
261
- x: 0,
262
- y: 0,
263
- button: l.button
264
- };
265
- {
266
- const e = this.domElement.getBoundingClientRect();
267
- return {
268
- x: (l.clientX - e.left) / e.width * 2 - 1,
269
- y: -(l.clientY - e.top) / e.height * 2 + 1,
270
- button: l.button
271
- };
272
- }
273
- }
274
- function Bt(l) {
275
- if (this.enabled)
276
- switch (l.pointerType) {
277
- case "mouse":
278
- case "pen":
279
- this.pointerHover(this._getPointer(l));
280
- break;
281
- }
282
- }
283
- function Vt(l) {
284
- this.enabled && (document.pointerLockElement || this.domElement.setPointerCapture(l.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.pointerHover(this._getPointer(l)), this.pointerDown(this._getPointer(l)));
285
- }
286
- function Nt(l) {
287
- this.enabled && this.pointerMove(this._getPointer(l));
288
- }
289
- function Kt(l) {
290
- this.enabled && (this.domElement.releasePointerCapture(l.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.pointerUp(this._getPointer(l)));
291
- }
292
- function at(l, e, t) {
293
- const i = e.intersectObject(l, !0);
294
- for (let n = 0; n < i.length; n++)
295
- if (i[n].object.visible || t)
296
- return i[n];
297
- return !1;
298
- }
299
- const et = new Qt(), d = new h(0, 1, 0), vt = new h(0, 0, 0), Pt = new Et(), it = new E(), nt = new E(), D = new h(), St = new Et(), q = new h(1, 0, 0), L = new h(0, 1, 0), U = new h(0, 0, 1), st = new h(), R = new h(), Z = new h();
300
- class $t extends ht {
301
- constructor() {
302
- super(), this.isTransformControlsGizmo = !0, this.type = "TransformControlsGizmo";
303
- const e = new Dt({
304
- depthTest: !1,
305
- depthWrite: !1,
306
- fog: !1,
307
- toneMapped: !1,
308
- transparent: !0
309
- }), t = new kt({
310
- depthTest: !1,
311
- depthWrite: !1,
312
- fog: !1,
313
- toneMapped: !1,
314
- transparent: !0
315
- }), i = e.clone();
316
- i.opacity = 0.15;
317
- const n = t.clone();
318
- n.opacity = 0.5;
319
- const a = e.clone();
320
- a.color.setHex(16711680);
321
- const s = e.clone();
322
- s.color.setHex(65280);
323
- const c = e.clone();
324
- c.color.setHex(255);
325
- const u = e.clone();
326
- u.color.setHex(16711680), u.opacity = 0.5;
327
- const P = e.clone();
328
- P.color.setHex(65280), P.opacity = 0.5;
329
- const M = e.clone();
330
- M.color.setHex(255), M.opacity = 0.5;
331
- const k = e.clone();
332
- k.opacity = 0.25;
333
- const Y = e.clone();
334
- Y.color.setHex(16776960), Y.opacity = 0.25, e.clone().color.setHex(16776960);
335
- const V = e.clone();
336
- V.color.setHex(7895160);
337
- const x = new w(0, 0.04, 0.1, 12);
338
- x.translate(0, 0.05, 0);
339
- const I = new f(0.08, 0.08, 0.08);
340
- I.translate(0, 0.04, 0);
341
- const S = new dt();
342
- S.setAttribute("position", new pt([0, 0, 0, 1, 0, 0], 3));
343
- const g = new w(75e-4, 75e-4, 0.5, 3);
344
- g.translate(0, 0.25, 0);
345
- function b(y, N) {
346
- const v = new Q(y, 75e-4, 3, 64, N * Math.PI * 2);
347
- return v.rotateY(Math.PI / 2), v.rotateX(Math.PI / 2), v;
348
- }
349
- function H() {
350
- const y = new dt();
351
- return y.setAttribute("position", new pt([0, 0, 0, 1, 1, 1], 3)), y;
352
- }
353
- const z = {
354
- X: [
355
- [new r(x, a), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
356
- [new r(x, a), [-0.5, 0, 0], [0, 0, Math.PI / 2]],
357
- [new r(g, a), [0, 0, 0], [0, 0, -Math.PI / 2]]
358
- ],
359
- Y: [
360
- [new r(x, s), [0, 0.5, 0]],
361
- [new r(x, s), [0, -0.5, 0], [Math.PI, 0, 0]],
362
- [new r(g, s)]
363
- ],
364
- Z: [
365
- [new r(x, c), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
366
- [new r(x, c), [0, 0, -0.5], [-Math.PI / 2, 0, 0]],
367
- [new r(g, c), null, [Math.PI / 2, 0, 0]]
368
- ],
369
- XYZ: [
370
- [new r(new tt(0.1, 0), k.clone()), [0, 0, 0]]
371
- ],
372
- XY: [
373
- [new r(new f(0.15, 0.15, 0.01), M.clone()), [0.15, 0.15, 0]]
374
- ],
375
- YZ: [
376
- [new r(new f(0.15, 0.15, 0.01), u.clone()), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
377
- ],
378
- XZ: [
379
- [new r(new f(0.15, 0.15, 0.01), P.clone()), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
380
- ]
381
- }, Mt = {
382
- X: [
383
- [new r(new w(0.2, 0, 0.6, 4), i), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
384
- [new r(new w(0.2, 0, 0.6, 4), i), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
385
- ],
386
- Y: [
387
- [new r(new w(0.2, 0, 0.6, 4), i), [0, 0.3, 0]],
388
- [new r(new w(0.2, 0, 0.6, 4), i), [0, -0.3, 0], [0, 0, Math.PI]]
389
- ],
390
- Z: [
391
- [new r(new w(0.2, 0, 0.6, 4), i), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
392
- [new r(new w(0.2, 0, 0.6, 4), i), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
393
- ],
394
- XYZ: [
395
- [new r(new tt(0.2, 0), i)]
396
- ],
397
- XY: [
398
- [new r(new f(0.2, 0.2, 0.01), i), [0.15, 0.15, 0]]
399
- ],
400
- YZ: [
401
- [new r(new f(0.2, 0.2, 0.01), i), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
402
- ],
403
- XZ: [
404
- [new r(new f(0.2, 0.2, 0.01), i), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
405
- ]
406
- }, xt = {
407
- START: [
408
- [new r(new tt(0.01, 2), n), null, null, null, "helper"]
409
- ],
410
- END: [
411
- [new r(new tt(0.01, 2), n), null, null, null, "helper"]
412
- ],
413
- DELTA: [
414
- [new A(H(), n), null, null, null, "helper"]
415
- ],
416
- X: [
417
- [new A(S, n.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
418
- ],
419
- Y: [
420
- [new A(S, n.clone()), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]
421
- ],
422
- Z: [
423
- [new A(S, n.clone()), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]
424
- ]
425
- }, It = {
426
- XYZE: [
427
- [new r(b(0.5, 1), V), null, [0, Math.PI / 2, 0]]
428
- ],
429
- X: [
430
- [new r(b(0.5, 0.5), a)]
431
- ],
432
- Y: [
433
- [new r(b(0.5, 0.5), s), null, [0, 0, -Math.PI / 2]]
434
- ],
435
- Z: [
436
- [new r(b(0.5, 0.5), c), null, [0, Math.PI / 2, 0]]
437
- ],
438
- E: [
439
- [new r(b(0.75, 1), Y), null, [0, Math.PI / 2, 0]]
440
- ]
441
- }, Tt = {
442
- AXIS: [
443
- [new A(S, n.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
444
- ]
445
- }, At = {
446
- XYZE: [
447
- [new r(new Yt(0.25, 10, 8), i)]
448
- ],
449
- X: [
450
- [new r(new Q(0.5, 0.1, 4, 24), i), [0, 0, 0], [0, -Math.PI / 2, -Math.PI / 2]]
451
- ],
452
- Y: [
453
- [new r(new Q(0.5, 0.1, 4, 24), i), [0, 0, 0], [Math.PI / 2, 0, 0]]
454
- ],
455
- Z: [
456
- [new r(new Q(0.5, 0.1, 4, 24), i), [0, 0, 0], [0, 0, -Math.PI / 2]]
457
- ],
458
- E: [
459
- [new r(new Q(0.75, 0.1, 2, 24), i)]
460
- ]
461
- }, Ct = {
462
- X: [
463
- [new r(I, a), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
464
- [new r(g, a), [0, 0, 0], [0, 0, -Math.PI / 2]],
465
- [new r(I, a), [-0.5, 0, 0], [0, 0, Math.PI / 2]]
466
- ],
467
- Y: [
468
- [new r(I, s), [0, 0.5, 0]],
469
- [new r(g, s)],
470
- [new r(I, s), [0, -0.5, 0], [0, 0, Math.PI]]
471
- ],
472
- Z: [
473
- [new r(I, c), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
474
- [new r(g, c), [0, 0, 0], [Math.PI / 2, 0, 0]],
475
- [new r(I, c), [0, 0, -0.5], [-Math.PI / 2, 0, 0]]
476
- ],
477
- XY: [
478
- [new r(new f(0.15, 0.15, 0.01), M), [0.15, 0.15, 0]]
479
- ],
480
- YZ: [
481
- [new r(new f(0.15, 0.15, 0.01), u), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
482
- ],
483
- XZ: [
484
- [new r(new f(0.15, 0.15, 0.01), P), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
485
- ],
486
- XYZ: [
487
- [new r(new f(0.1, 0.1, 0.1), k.clone())]
488
- ]
489
- }, zt = {
490
- X: [
491
- [new r(new w(0.2, 0, 0.6, 4), i), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
492
- [new r(new w(0.2, 0, 0.6, 4), i), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
493
- ],
494
- Y: [
495
- [new r(new w(0.2, 0, 0.6, 4), i), [0, 0.3, 0]],
496
- [new r(new w(0.2, 0, 0.6, 4), i), [0, -0.3, 0], [0, 0, Math.PI]]
497
- ],
498
- Z: [
499
- [new r(new w(0.2, 0, 0.6, 4), i), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
500
- [new r(new w(0.2, 0, 0.6, 4), i), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
501
- ],
502
- XY: [
503
- [new r(new f(0.2, 0.2, 0.01), i), [0.15, 0.15, 0]]
504
- ],
505
- YZ: [
506
- [new r(new f(0.2, 0.2, 0.01), i), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
507
- ],
508
- XZ: [
509
- [new r(new f(0.2, 0.2, 0.01), i), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
510
- ],
511
- XYZ: [
512
- [new r(new f(0.2, 0.2, 0.2), i), [0, 0, 0]]
513
- ]
514
- }, jt = {
515
- X: [
516
- [new A(S, n.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
517
- ],
518
- Y: [
519
- [new A(S, n.clone()), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]
520
- ],
521
- Z: [
522
- [new A(S, n.clone()), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]
523
- ]
524
- };
525
- function T(y) {
526
- const N = new ht();
527
- for (const v in y)
528
- for (let X = y[v].length; X--; ) {
529
- const m = y[v][X][0].clone(), K = y[v][X][1], $ = y[v][X][2], J = y[v][X][3], Lt = y[v][X][4];
530
- m.name = v, m.tag = Lt, K && m.position.set(K[0], K[1], K[2]), $ && m.rotation.set($[0], $[1], $[2]), J && m.scale.set(J[0], J[1], J[2]), m.updateMatrix();
531
- const ct = m.geometry.clone();
532
- ct.applyMatrix4(m.matrix), m.geometry = ct, m.renderOrder = 1 / 0, m.position.set(0, 0, 0), m.rotation.set(0, 0, 0), m.scale.set(1, 1, 1), N.add(m);
533
- }
534
- return N;
535
- }
536
- this.gizmo = {}, this.picker = {}, this.helper = {}, this.add(this.gizmo.translate = T(z)), this.add(this.gizmo.rotate = T(It)), this.add(this.gizmo.scale = T(Ct)), this.add(this.picker.translate = T(Mt)), this.add(this.picker.rotate = T(At)), this.add(this.picker.scale = T(zt)), this.add(this.helper.translate = T(xt)), this.add(this.helper.rotate = T(Tt)), this.add(this.helper.scale = T(jt)), this.picker.translate.visible = !1, this.picker.rotate.visible = !1, this.picker.scale.visible = !1;
537
- }
538
- // updateMatrixWorld will update transformations and appearance of individual handles
539
- updateMatrixWorld(e) {
540
- const i = (this.mode === "scale" ? "local" : this.space) === "local" ? this.worldQuaternion : nt;
541
- this.gizmo.translate.visible = this.mode === "translate", this.gizmo.rotate.visible = this.mode === "rotate", this.gizmo.scale.visible = this.mode === "scale", this.helper.translate.visible = this.mode === "translate", this.helper.rotate.visible = this.mode === "rotate", this.helper.scale.visible = this.mode === "scale";
542
- let n = [];
543
- n = n.concat(this.picker[this.mode].children), n = n.concat(this.gizmo[this.mode].children), n = n.concat(this.helper[this.mode].children);
544
- for (let a = 0; a < n.length; a++) {
545
- const s = n[a];
546
- s.visible = !0, s.rotation.set(0, 0, 0), s.position.copy(this.worldPosition);
547
- let c;
548
- if (this.camera.isOrthographicCamera ? c = (this.camera.top - this.camera.bottom) / this.camera.zoom : c = this.worldPosition.distanceTo(this.cameraPosition) * Math.min(1.9 * Math.tan(Math.PI * this.camera.fov / 360) / this.camera.zoom, 7), s.scale.set(1, 1, 1).multiplyScalar(c * this.size / 4), s.tag === "helper") {
549
- s.visible = !1, s.name === "AXIS" ? (s.visible = !!this.axis, this.axis === "X" && (p.setFromEuler(et.set(0, 0, 0)), s.quaternion.copy(i).multiply(p), Math.abs(d.copy(q).applyQuaternion(i).dot(this.eye)) > 0.9 && (s.visible = !1)), this.axis === "Y" && (p.setFromEuler(et.set(0, 0, Math.PI / 2)), s.quaternion.copy(i).multiply(p), Math.abs(d.copy(L).applyQuaternion(i).dot(this.eye)) > 0.9 && (s.visible = !1)), this.axis === "Z" && (p.setFromEuler(et.set(0, Math.PI / 2, 0)), s.quaternion.copy(i).multiply(p), Math.abs(d.copy(U).applyQuaternion(i).dot(this.eye)) > 0.9 && (s.visible = !1)), this.axis === "XYZE" && (p.setFromEuler(et.set(0, Math.PI / 2, 0)), d.copy(this.rotationAxis), s.quaternion.setFromRotationMatrix(Pt.lookAt(vt, d, L)), s.quaternion.multiply(p), s.visible = this.dragging), this.axis === "E" && (s.visible = !1)) : s.name === "START" ? (s.position.copy(this.worldPositionStart), s.visible = this.dragging) : s.name === "END" ? (s.position.copy(this.worldPosition), s.visible = this.dragging) : s.name === "DELTA" ? (s.position.copy(this.worldPositionStart), s.quaternion.copy(this.worldQuaternionStart), _.set(1e-10, 1e-10, 1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1), _.applyQuaternion(this.worldQuaternionStart.clone().invert()), s.scale.copy(_), s.visible = this.dragging) : (s.quaternion.copy(i), this.dragging ? s.position.copy(this.worldPositionStart) : s.position.copy(this.worldPosition), this.axis && (s.visible = this.axis.search(s.name) !== -1));
550
- continue;
551
- }
552
- s.quaternion.copy(i), this.mode === "translate" || this.mode === "scale" ? (s.name === "X" && Math.abs(d.copy(q).applyQuaternion(i).dot(this.eye)) > 0.99 && (s.scale.set(1e-10, 1e-10, 1e-10), s.visible = !1), s.name === "Y" && Math.abs(d.copy(L).applyQuaternion(i).dot(this.eye)) > 0.99 && (s.scale.set(1e-10, 1e-10, 1e-10), s.visible = !1), s.name === "Z" && Math.abs(d.copy(U).applyQuaternion(i).dot(this.eye)) > 0.99 && (s.scale.set(1e-10, 1e-10, 1e-10), s.visible = !1), s.name === "XY" && Math.abs(d.copy(U).applyQuaternion(i).dot(this.eye)) < 0.2 && (s.scale.set(1e-10, 1e-10, 1e-10), s.visible = !1), s.name === "YZ" && Math.abs(d.copy(q).applyQuaternion(i).dot(this.eye)) < 0.2 && (s.scale.set(1e-10, 1e-10, 1e-10), s.visible = !1), s.name === "XZ" && Math.abs(d.copy(L).applyQuaternion(i).dot(this.eye)) < 0.2 && (s.scale.set(1e-10, 1e-10, 1e-10), s.visible = !1)) : this.mode === "rotate" && (it.copy(i), d.copy(this.eye).applyQuaternion(p.copy(i).invert()), s.name.search("E") !== -1 && s.quaternion.setFromRotationMatrix(Pt.lookAt(this.eye, vt, L)), s.name === "X" && (p.setFromAxisAngle(q, Math.atan2(-d.y, d.z)), p.multiplyQuaternions(it, p), s.quaternion.copy(p)), s.name === "Y" && (p.setFromAxisAngle(L, Math.atan2(d.x, d.z)), p.multiplyQuaternions(it, p), s.quaternion.copy(p)), s.name === "Z" && (p.setFromAxisAngle(U, Math.atan2(d.y, d.x)), p.multiplyQuaternions(it, p), s.quaternion.copy(p))), s.visible = s.visible && (s.name.indexOf("X") === -1 || this.showX), s.visible = s.visible && (s.name.indexOf("Y") === -1 || this.showY), s.visible = s.visible && (s.name.indexOf("Z") === -1 || this.showZ), s.visible = s.visible && (s.name.indexOf("E") === -1 || this.showX && this.showY && this.showZ), s.material._color = s.material._color || s.material.color.clone(), s.material._opacity = s.material._opacity || s.material.opacity, s.material.color.copy(s.material._color), s.material.opacity = s.material._opacity, this.enabled && this.axis && (s.name === this.axis || this.axis.split("").some(function(u) {
553
- return s.name === u;
554
- })) && (s.material.color.setHex(16776960), s.material.opacity = 1);
555
- }
556
- super.updateMatrixWorld(e);
557
- }
558
- }
559
- class Jt extends r {
560
- constructor() {
561
- super(
562
- new Ot(1e5, 1e5, 2, 2),
563
- new Dt({ visible: !1, wireframe: !0, side: Rt, transparent: !0, opacity: 0.1, toneMapped: !1 })
564
- ), this.isTransformControlsPlane = !0, this.type = "TransformControlsPlane";
565
- }
566
- updateMatrixWorld(e) {
567
- let t = this.space;
568
- switch (this.position.copy(this.worldPosition), this.mode === "scale" && (t = "local"), st.copy(q).applyQuaternion(t === "local" ? this.worldQuaternion : nt), R.copy(L).applyQuaternion(t === "local" ? this.worldQuaternion : nt), Z.copy(U).applyQuaternion(t === "local" ? this.worldQuaternion : nt), d.copy(R), this.mode) {
569
- case "translate":
570
- case "scale":
571
- switch (this.axis) {
572
- case "X":
573
- d.copy(this.eye).cross(st), D.copy(st).cross(d);
574
- break;
575
- case "Y":
576
- d.copy(this.eye).cross(R), D.copy(R).cross(d);
577
- break;
578
- case "Z":
579
- d.copy(this.eye).cross(Z), D.copy(Z).cross(d);
580
- break;
581
- case "XY":
582
- D.copy(Z);
583
- break;
584
- case "YZ":
585
- D.copy(st);
586
- break;
587
- case "XZ":
588
- d.copy(Z), D.copy(R);
589
- break;
590
- case "XYZ":
591
- case "E":
592
- D.set(0, 0, 0);
593
- break;
594
- }
595
- break;
596
- case "rotate":
597
- default:
598
- D.set(0, 0, 0);
599
- }
600
- D.length() === 0 ? this.quaternion.copy(this.cameraQuaternion) : (St.lookAt(_.set(0, 0, 0), D, d), this.quaternion.setFromRotationMatrix(St)), super.updateMatrixWorld(e);
601
- }
602
- }
603
- const pe = (l) => l.name === "transform";
604
- class te extends Zt {
605
- constructor(t, i, n) {
145
+ const Y = (n) => n.name === "transform";
146
+ class L extends T {
147
+ constructor(e, s, i) {
606
148
  super();
607
149
  o(this, "name", "transform");
608
150
  o(this, "priority", 5);
@@ -610,10 +152,11 @@ class te extends Zt {
610
152
  o(this, "_controller");
611
153
  o(this, "_selectionState");
612
154
  o(this, "_gizmo");
155
+ o(this, "_gizmoHelper");
613
156
  o(this, "_scaleLinked", !1);
614
157
  o(this, "_gizmoVisible", !0);
615
158
  o(this, "_selectionChangeHandler");
616
- this._scene = t, this._controller = i, this._selectionState = n, this._gizmo = this.initGizmo(), this._scene.add(this._gizmo), this._selectionChangeHandler = this.onSelectionChange.bind(this);
159
+ this._scene = e, this._controller = s, this._selectionState = i, this._gizmo = this.initGizmo(), this._gizmoHelper = this._gizmo.getHelper(), this._scene.add(this._gizmoHelper), this._selectionChangeHandler = this.onSelectionChange.bind(this);
617
160
  }
618
161
  /**
619
162
  * Get the TransformControls gizmo.
@@ -629,111 +172,111 @@ class te extends Zt {
629
172
  }
630
173
  onActivate() {
631
174
  this._selectionState.onChange(this._selectionChangeHandler);
632
- const t = this._selectionState.selected;
633
- t && this.attachGizmo(t);
175
+ const e = this._selectionState.selected;
176
+ e && this.attachGizmo(e);
634
177
  }
635
178
  onDeactivate() {
636
179
  this._selectionState.offChange(this._selectionChangeHandler), this._gizmo.detach();
637
180
  }
638
- onPointerMove(t) {
639
- if (this._gizmo.dragging || t.uiIntersects.length > 0 && t.uiIntersects.some(
640
- (n) => this.isGizmoChild(n.object)
181
+ onPointerMove(e) {
182
+ if (this._gizmo.dragging || e.uiIntersects.length > 0 && e.uiIntersects.some(
183
+ (i) => this.isGizmoChild(i.object)
641
184
  ))
642
185
  return !0;
643
186
  }
644
187
  /**
645
188
  * Set the gizmo transformation mode.
646
189
  */
647
- setGizmoMode(t) {
648
- this._gizmo.mode = t;
190
+ setGizmoMode(e) {
191
+ this._gizmo.mode = e;
649
192
  }
650
193
  /**
651
194
  * Set whether the gizmo is visible.
652
195
  */
653
- setGizmoVisible(t) {
654
- this._gizmoVisible = t;
655
- const i = this._scene.children.includes(this._gizmo);
656
- t && !i ? (this._scene.add(this._gizmo), this._gizmo.getRaycaster().layers.enableAll()) : !t && i && (this._scene.remove(this._gizmo), this._gizmo.getRaycaster().layers.disableAll());
196
+ setGizmoVisible(e) {
197
+ this._gizmoVisible = e;
198
+ const s = this._scene.children.includes(this._gizmoHelper);
199
+ e && !s ? (this._scene.add(this._gizmoHelper), this._gizmo.getRaycaster().layers.enableAll()) : !e && s && (this._scene.remove(this._gizmoHelper), this._gizmo.getRaycaster().layers.disableAll());
657
200
  }
658
201
  /**
659
202
  * Set whether scale operations are linked (uniform scaling).
660
203
  */
661
- setGizmoScaleLinked(t) {
662
- this._scaleLinked = t;
204
+ setGizmoScaleLinked(e) {
205
+ this._scaleLinked = e;
663
206
  }
664
207
  /**
665
208
  * Dispose of the tool and clean up resources.
666
209
  */
667
210
  dispose() {
668
- this._selectionState.offChange(this._selectionChangeHandler), this._gizmo.detach(), this._scene.remove(this._gizmo), this._gizmo.dispose();
211
+ this._selectionState.offChange(this._selectionChangeHandler), this._gizmo.detach(), this._scene.remove(this._gizmoHelper), this._gizmo.dispose();
669
212
  }
670
213
  // ============ Private Methods ============
671
- onSelectionChange(t) {
672
- t && O(t, "isMovable") ? this.attachGizmo(t) : this._gizmo.detach();
214
+ onSelectionChange(e) {
215
+ e && h(e, "isMovable") ? this.attachGizmo(e) : this._gizmo.detach();
673
216
  }
674
- attachGizmo(t) {
675
- O(t, "isMovable") && (this._gizmo.attach(t), this.setGizmoVisible(t.visible && this._gizmoVisible));
217
+ attachGizmo(e) {
218
+ h(e, "isMovable") && (this._gizmo.attach(e), this.setGizmoVisible(e.visible && this._gizmoVisible));
676
219
  }
677
- isGizmoChild(t) {
678
- let i = t;
679
- for (; i; ) {
680
- if (i === this._gizmo) return !0;
681
- i = i.parent;
220
+ isGizmoChild(e) {
221
+ let s = e;
222
+ for (; s; ) {
223
+ if (s === this._gizmoHelper) return !0;
224
+ s = s.parent;
682
225
  }
683
226
  return !1;
684
227
  }
685
228
  initGizmo() {
686
- const t = new Ut(
229
+ const e = new E(
687
230
  this._controller.object,
688
231
  this._controller.domElement
689
232
  );
690
- return t.mode = "translate", t.traverse((i) => {
233
+ return e.mode = "translate", e.getHelper().traverse((i) => {
691
234
  if (!("isMesh" in i)) return;
692
- const n = i.material;
693
- i.name === "X" && n.color.set(ut), i.name === "Y" && n.color.set(gt), i.name === "Z" && n.color.set(ft), i.name === "XY" && n.color.set(ft), i.name === "YZ" && n.color.set(ut), i.name === "XZ" && n.color.set(gt);
694
- }), t.addEventListener("mouseDown", () => {
695
- var i, n;
696
- this._controller.enabled = !1, O(t.object, "isMovable") && ((n = (i = t.object).onMoveStart) == null || n.call(i));
697
- }), t.addEventListener("objectChange", () => {
698
- var i, n;
699
- if (O(t.object, "isMovable")) {
700
- if ((n = (i = t.object).onMove) == null || n.call(i), this._scaleLinked && t.object) {
701
- const a = t.object.scale, s = (a.x + a.y + a.z) / 3;
702
- t.object.scale.set(s, s, s);
235
+ const r = i.material;
236
+ i.name === "X" && r.color.set(b), i.name === "Y" && r.color.set(D), i.name === "Z" && r.color.set(y), i.name === "XY" && r.color.set(y), i.name === "YZ" && r.color.set(b), i.name === "XZ" && r.color.set(D);
237
+ }), e.addEventListener("mouseDown", () => {
238
+ var i, r;
239
+ this._controller.enabled = !1, h(e.object, "isMovable") && ((r = (i = e.object).onMoveStart) == null || r.call(i));
240
+ }), e.addEventListener("objectChange", () => {
241
+ var i, r;
242
+ if (h(e.object, "isMovable")) {
243
+ if ((r = (i = e.object).onMove) == null || r.call(i), this._scaleLinked && e.object) {
244
+ const a = e.object.scale, c = (a.x + a.y + a.z) / 3;
245
+ e.object.scale.set(c, c, c);
703
246
  }
704
247
  switch (this.dispatchEvent({
705
248
  type: "object-change",
706
- object: t.object
707
- }), t.mode) {
249
+ object: e.object
250
+ }), e.mode) {
708
251
  case "translate":
709
252
  this.dispatchEvent({
710
253
  type: "object-position-change",
711
- object: t.object
254
+ object: e.object
712
255
  });
713
256
  break;
714
257
  case "rotate":
715
258
  this.dispatchEvent({
716
259
  type: "object-rotation-change",
717
- object: t.object
260
+ object: e.object
718
261
  });
719
262
  break;
720
263
  case "scale":
721
264
  this.dispatchEvent({
722
265
  type: "object-scale-change",
723
- object: t.object
266
+ object: e.object
724
267
  });
725
268
  break;
726
269
  }
727
270
  }
728
- }), t.addEventListener("mouseUp", () => {
729
- var i, n;
730
- this._controller.enabled = !0, O(t.object, "isMovable") && ((n = (i = t.object).onMoveEnd) == null || n.call(i));
731
- }), t;
271
+ }), e.addEventListener("mouseUp", () => {
272
+ var i, r;
273
+ this._controller.enabled = !0, h(e.object, "isMovable") && ((r = (i = e.object).onMoveEnd) == null || r.call(i));
274
+ }), e;
732
275
  }
733
276
  }
734
- const ee = 1e-3;
735
- class ie {
736
- constructor(e) {
277
+ const A = 1e-3;
278
+ class j {
279
+ constructor(t) {
737
280
  o(this, "name", "drag");
738
281
  o(this, "priority", 10);
739
282
  o(this, "_controller");
@@ -741,13 +284,13 @@ class ie {
741
284
  // Drag state
742
285
  o(this, "_dragging", !1);
743
286
  o(this, "_draggable", null);
744
- o(this, "_dragStart", new h());
745
- o(this, "_dragCurrent", new h());
746
- o(this, "_dragEnd", new h());
747
- o(this, "_dragDelta", new h());
287
+ o(this, "_dragStart", new l());
288
+ o(this, "_dragCurrent", new l());
289
+ o(this, "_dragEnd", new l());
290
+ o(this, "_dragDelta", new l());
748
291
  // Custom raycast targets for drag plane
749
292
  o(this, "_dragRaycastTargets", null);
750
- this._controller = e, this._raycaster = new ot();
293
+ this._controller = t, this._raycaster = new P();
751
294
  }
752
295
  /**
753
296
  * Whether a drag operation is currently in progress.
@@ -767,19 +310,19 @@ class ie {
767
310
  onDeactivate() {
768
311
  this._dragging && this._draggable && this.endDrag(), this.resetDragState();
769
312
  }
770
- onPointerDown(e) {
771
- var t;
772
- e.pointerPrimaryDown && (this._draggable = B(
773
- (t = e.intersects[0]) == null ? void 0 : t.object,
313
+ onPointerDown(t) {
314
+ var e;
315
+ t.pointerPrimaryDown && (this._draggable = g(
316
+ (e = t.intersects[0]) == null ? void 0 : e.object,
774
317
  "isDraggable"
775
318
  ) || null);
776
319
  }
777
- onPointerMove(e) {
778
- if (e.pointerPrimaryDown && this._draggable && (this._raycaster.setFromCamera(e.pointer, this._controller.object), this._dragging || e.lastPointerDown.distanceTo(e.pointer) > ee && this.startDrag(e), this._dragging))
779
- return this.updateDrag(e), !0;
320
+ onPointerMove(t) {
321
+ if (t.pointerPrimaryDown && this._draggable && (this._raycaster.setFromCamera(t.pointer, this._controller.object), this._dragging || t.lastPointerDown.distanceTo(t.pointer) > A && this.startDrag(t), this._dragging))
322
+ return this.updateDrag(t), !0;
780
323
  }
781
- onPointerUp(e) {
782
- this._dragging && (this._raycaster.setFromCamera(e.pointer, this._controller.object), this.endDrag()), this._draggable = null;
324
+ onPointerUp(t) {
325
+ this._dragging && (this._raycaster.setFromCamera(t.pointer, this._controller.object), this.endDrag()), this._draggable = null;
783
326
  }
784
327
  /**
785
328
  * Set custom objects to raycast against during drag.
@@ -787,30 +330,30 @@ class ie {
787
330
  *
788
331
  * @param targets Objects to raycast against, or null to use scene objects
789
332
  */
790
- setDragRaycastTargets(e) {
791
- this._dragRaycastTargets = e;
333
+ setDragRaycastTargets(t) {
334
+ this._dragRaycastTargets = t;
792
335
  }
793
336
  // ============ Private Methods ============
794
- startDrag(e) {
795
- var i, n;
796
- const t = this.getDragIntersect(e);
797
- t && (this._dragStart.copy(t.point), this._dragCurrent.copy(t.point), this._dragEnd.copy(t.point), this._dragDelta.set(0, 0, 0), (n = (i = this._draggable) == null ? void 0 : i.onDragStart) == null || n.call(i, this.createDragEvent()), this._dragging = !0, this._controller.enabled = !1);
337
+ startDrag(t) {
338
+ var s, i;
339
+ const e = this.getDragIntersect(t);
340
+ e && (this._dragStart.copy(e.point), this._dragCurrent.copy(e.point), this._dragEnd.copy(e.point), this._dragDelta.set(0, 0, 0), (i = (s = this._draggable) == null ? void 0 : s.onDragStart) == null || i.call(s, this.createDragEvent()), this._dragging = !0, this._controller.enabled = !1);
798
341
  }
799
- updateDrag(e) {
800
- var i, n;
801
- const t = this.getDragIntersect(e);
802
- t && (this._dragCurrent.copy(t.point), this._dragEnd.copy(t.point), this._dragDelta.subVectors(this._dragCurrent, this._dragStart), (n = (i = this._draggable) == null ? void 0 : i.onDrag) == null || n.call(i, this.createDragEvent()));
342
+ updateDrag(t) {
343
+ var s, i;
344
+ const e = this.getDragIntersect(t);
345
+ e && (this._dragCurrent.copy(e.point), this._dragEnd.copy(e.point), this._dragDelta.subVectors(this._dragCurrent, this._dragStart), (i = (s = this._draggable) == null ? void 0 : s.onDrag) == null || i.call(s, this.createDragEvent()));
803
346
  }
804
347
  endDrag() {
805
- var t, i;
806
- const e = this.createDragEvent();
807
- (i = (t = this._draggable) == null ? void 0 : t.onDragEnd) == null || i.call(t, e), this._dragging = !1, this._controller.enabled = !0, this.resetDragState();
348
+ var e, s;
349
+ const t = this.createDragEvent();
350
+ (s = (e = this._draggable) == null ? void 0 : e.onDragEnd) == null || s.call(e, t), this._dragging = !1, this._controller.enabled = !0, this.resetDragState();
808
351
  }
809
- getDragIntersect(e) {
352
+ getDragIntersect(t) {
810
353
  return this._dragRaycastTargets ? this._raycaster.intersectObjects(
811
354
  this._dragRaycastTargets,
812
355
  !0
813
- )[0] || null : e.intersects[0] || null;
356
+ )[0] || null : t.intersects[0] || null;
814
357
  }
815
358
  createDragEvent() {
816
359
  return {
@@ -824,9 +367,9 @@ class ie {
824
367
  this._dragStart.set(0, 0, 0), this._dragCurrent.set(0, 0, 0), this._dragEnd.set(0, 0, 0), this._dragDelta.set(0, 0, 0);
825
368
  }
826
369
  }
827
- const se = 1e-3;
828
- class _e {
829
- constructor(e, t) {
370
+ const k = 1e-3;
371
+ class X {
372
+ constructor(t, e) {
830
373
  o(this, "_scene");
831
374
  o(this, "_controller");
832
375
  o(this, "_canvas");
@@ -851,22 +394,22 @@ class _e {
851
394
  o(this, "_boundPointerDown");
852
395
  o(this, "_boundPointerUp");
853
396
  o(this, "_boundWheel");
854
- this._scene = e, this._controller = t, this._canvas = t.domElement, this._selectionState = new Gt(), this._raycaster = new ot(), this._pointer = new F(), this._lastPointerDown = new F(), this._productLayerMask = new _t(), this._productLayerMask.set(Math.log2(G)), this._uiLayerMask = new _t(), this._uiLayerMask.set(Math.log2(W)), this._tools = /* @__PURE__ */ new Map([
397
+ this._scene = t, this._controller = e, this._canvas = e.domElement, this._selectionState = new z(), this._raycaster = new P(), this._pointer = new f(), this._lastPointerDown = new f(), this._productLayerMask = new m(), this._productLayerMask.set(Math.log2(_)), this._uiLayerMask = new m(), this._uiLayerMask.set(Math.log2(d)), this._tools = /* @__PURE__ */ new Map([
855
398
  [
856
399
  "hover",
857
- new Wt()
400
+ new C()
858
401
  ],
859
402
  [
860
403
  "select",
861
- new qt(this._selectionState)
404
+ new M(this._selectionState)
862
405
  ],
863
406
  [
864
407
  "transform",
865
- new te(e, t, this._selectionState)
408
+ new L(t, e, this._selectionState)
866
409
  ],
867
410
  [
868
411
  "drag",
869
- new ie(t)
412
+ new j(e)
870
413
  ]
871
414
  ]), this._boundPointerMove = this.onPointerMove.bind(this), this._boundPointerDown = this.onPointerDown.bind(this), this._boundPointerUp = this.onPointerUp.bind(this), this._boundWheel = this.onWheel.bind(this), this._canvas.addEventListener("pointermove", this._boundPointerMove), this._canvas.addEventListener("pointerdown", this._boundPointerDown), this._canvas.addEventListener("pointerup", this._boundPointerUp), this._canvas.addEventListener("wheel", this._boundWheel);
872
415
  }
@@ -876,30 +419,30 @@ class _e {
876
419
  /**
877
420
  * Enable a tool by type.
878
421
  */
879
- enableTool(e) {
880
- var i;
881
- const t = this._tools.get(e);
882
- t && (this._activeTools.has(e) || (this._activeTools.set(e, t), this.updateSortedTools(), (i = t.onActivate) == null || i.call(t)));
422
+ enableTool(t) {
423
+ var s;
424
+ const e = this._tools.get(t);
425
+ e && (this._activeTools.has(t) || (this._activeTools.set(t, e), this.updateSortedTools(), (s = e.onActivate) == null || s.call(e)));
883
426
  }
884
427
  /**
885
428
  * Disable an active tool by type.
886
429
  */
887
- disableTool(e) {
888
- var i;
889
- const t = this._activeTools.get(e);
890
- t && ((i = t.onDeactivate) == null || i.call(t), this._activeTools.delete(e), this.updateSortedTools());
430
+ disableTool(t) {
431
+ var s;
432
+ const e = this._activeTools.get(t);
433
+ e && ((s = e.onDeactivate) == null || s.call(e), this._activeTools.delete(t), this.updateSortedTools());
891
434
  }
892
435
  /**
893
436
  * Check if a tool is currently enabled.
894
437
  */
895
- isToolEnabled(e) {
896
- return this._activeTools.has(e);
438
+ isToolEnabled(t) {
439
+ return this._activeTools.has(t);
897
440
  }
898
441
  /**
899
442
  * Get a tool by type.
900
443
  */
901
- getTool(e) {
902
- return this._tools.get(e);
444
+ getTool(t) {
445
+ return this._tools.get(t);
903
446
  }
904
447
  /**
905
448
  * Get all currently active tools.
@@ -911,58 +454,58 @@ class _e {
911
454
  * Dispose of the toolbox and clean up resources.
912
455
  */
913
456
  dispose() {
914
- var e;
915
- for (const t of this._activeTools.values())
916
- (e = t.onDeactivate) == null || e.call(t);
457
+ var t;
458
+ for (const e of this._activeTools.values())
459
+ (t = e.onDeactivate) == null || t.call(e);
917
460
  this._activeTools.clear(), this._tools.clear(), this._sortedActiveTools = [], this._canvas.removeEventListener("pointermove", this._boundPointerMove), this._canvas.removeEventListener("pointerdown", this._boundPointerDown), this._canvas.removeEventListener("pointerup", this._boundPointerUp), this._canvas.removeEventListener("wheel", this._boundWheel), this._selectionState.dispose();
918
461
  }
919
462
  // ============ Event Handlers ============
920
- onPointerMove(e) {
921
- var i;
922
- this.updatePointer(e);
923
- const t = this.createPointerContext(e);
924
- for (const n of this._sortedActiveTools)
925
- if ((i = n.onPointerMove) == null ? void 0 : i.call(n, t)) break;
926
- }
927
- onPointerDown(e) {
928
- var i;
929
- this.updatePointerState(e, !0), this.updatePointer(e), this._lastPointerDown.copy(this._pointer);
930
- const t = this.createPointerContext(e);
931
- for (const n of this._sortedActiveTools)
932
- if ((i = n.onPointerDown) == null ? void 0 : i.call(n, t)) break;
933
- }
934
- onPointerUp(e) {
935
- var n, a;
936
- this.updatePointer(e);
937
- const t = this.createPointerContext(e), i = !this.pointerWasDragged();
938
- for (const s of this._sortedActiveTools)
939
- if ((n = s.onPointerUp) == null ? void 0 : n.call(s, t)) break;
940
- if (i) {
941
- for (const s of this._sortedActiveTools)
942
- if ((a = s.onClick) == null ? void 0 : a.call(s, t)) break;
463
+ onPointerMove(t) {
464
+ var s;
465
+ this.updatePointer(t);
466
+ const e = this.createPointerContext(t);
467
+ for (const i of this._sortedActiveTools)
468
+ if ((s = i.onPointerMove) == null ? void 0 : s.call(i, e)) break;
469
+ }
470
+ onPointerDown(t) {
471
+ var s;
472
+ this.updatePointerState(t, !0), this.updatePointer(t), this._lastPointerDown.copy(this._pointer);
473
+ const e = this.createPointerContext(t);
474
+ for (const i of this._sortedActiveTools)
475
+ if ((s = i.onPointerDown) == null ? void 0 : s.call(i, e)) break;
476
+ }
477
+ onPointerUp(t) {
478
+ var i, r;
479
+ this.updatePointer(t);
480
+ const e = this.createPointerContext(t), s = !this.pointerWasDragged();
481
+ for (const a of this._sortedActiveTools)
482
+ if ((i = a.onPointerUp) == null ? void 0 : i.call(a, e)) break;
483
+ if (s) {
484
+ for (const a of this._sortedActiveTools)
485
+ if ((r = a.onClick) == null ? void 0 : r.call(a, e)) break;
943
486
  }
944
- this.updatePointerState(e, !1);
487
+ this.updatePointerState(t, !1);
945
488
  }
946
- onWheel(e) {
947
- var i;
948
- const t = this.createWheelContext(e);
949
- for (const n of this._sortedActiveTools)
950
- if ((i = n.onWheel) == null ? void 0 : i.call(n, t)) break;
489
+ onWheel(t) {
490
+ var s;
491
+ const e = this.createWheelContext(t);
492
+ for (const i of this._sortedActiveTools)
493
+ if ((s = i.onWheel) == null ? void 0 : s.call(i, e)) break;
951
494
  }
952
495
  // ============ Context Creation ============
953
- createPointerContext(e) {
954
- const t = this.raycast();
496
+ createPointerContext(t) {
497
+ const e = this.raycast();
955
498
  return {
956
- event: e,
499
+ event: t,
957
500
  pointer: this._pointer.clone(),
958
- intersects: t,
501
+ intersects: e,
959
502
  modelIntersects: this.filterIntersectsByLayer(
960
- t,
961
- G
503
+ e,
504
+ _
962
505
  ),
963
506
  uiIntersects: this.filterIntersectsByLayer(
964
- t,
965
- W
507
+ e,
508
+ d
966
509
  ),
967
510
  pointerPrimaryDown: this._pointerPrimaryDown,
968
511
  pointerMiddleDown: this._pointerMiddleDown,
@@ -970,241 +513,69 @@ class _e {
970
513
  lastPointerDown: this._lastPointerDown.clone()
971
514
  };
972
515
  }
973
- createWheelContext(e) {
974
- const t = this.raycast();
516
+ createWheelContext(t) {
517
+ const e = this.raycast();
975
518
  return {
976
- event: e,
519
+ event: t,
977
520
  pointer: this._pointer.clone(),
978
- intersects: t,
521
+ intersects: e,
979
522
  modelIntersects: this.filterIntersectsByLayer(
980
- t,
981
- G
523
+ e,
524
+ _
982
525
  ),
983
526
  uiIntersects: this.filterIntersectsByLayer(
984
- t,
985
- W
527
+ e,
528
+ d
986
529
  )
987
530
  };
988
531
  }
989
532
  // ============ Helper Methods ============
990
- updatePointer(e) {
991
- this._pointer.x = e.offsetX / this._canvas.clientWidth * 2 - 1, this._pointer.y = -(e.offsetY / this._canvas.clientHeight) * 2 + 1, this._raycaster.setFromCamera(this._pointer, this._controller.object);
533
+ updatePointer(t) {
534
+ this._pointer.x = t.offsetX / this._canvas.clientWidth * 2 - 1, this._pointer.y = -(t.offsetY / this._canvas.clientHeight) * 2 + 1, this._raycaster.setFromCamera(this._pointer, this._controller.object);
992
535
  }
993
- updatePointerState(e, t) {
994
- switch (e.button) {
536
+ updatePointerState(t, e) {
537
+ switch (t.button) {
995
538
  case 0:
996
- this._pointerPrimaryDown = t;
539
+ this._pointerPrimaryDown = e;
997
540
  break;
998
541
  case 1:
999
- this._pointerMiddleDown = t;
542
+ this._pointerMiddleDown = e;
1000
543
  break;
1001
544
  case 2:
1002
- this._pointerSecondaryDown = t;
545
+ this._pointerSecondaryDown = e;
1003
546
  break;
1004
547
  }
1005
548
  }
1006
549
  raycast() {
1007
- this._raycaster.layers.mask = G | W;
1008
- const e = this._scene.children.filter(
1009
- (t) => t.visible && "isMesh" in t && t.isMesh
550
+ this._raycaster.layers.mask = _ | d;
551
+ const t = this._scene.children.filter(
552
+ (e) => e.visible && "isMesh" in e && e.isMesh
1010
553
  );
1011
- return this._raycaster.intersectObjects(e, !0);
554
+ return this._raycaster.intersectObjects(t, !0);
1012
555
  }
1013
- filterIntersectsByLayer(e, t) {
1014
- return e.filter(
1015
- (i) => (i.object.layers.mask & t) !== 0
556
+ filterIntersectsByLayer(t, e) {
557
+ return t.filter(
558
+ (s) => (s.object.layers.mask & e) !== 0
1016
559
  );
1017
560
  }
1018
561
  updateSortedTools() {
1019
562
  this._sortedActiveTools = [...this._activeTools.values()].sort(
1020
- (e, t) => e.priority - t.priority
1021
- );
1022
- }
1023
- pointerWasDragged() {
1024
- return this._lastPointerDown.distanceTo(this._pointer) > se;
1025
- }
1026
- // ============ Legacy API Compatibility ============
1027
- /**
1028
- * @deprecated Use enableTool/disableTool instead.
1029
- * Enable or disable a tool by type.
1030
- */
1031
- useTool(e) {
1032
- const t = [
1033
- "hover",
1034
- "select",
1035
- "transform",
1036
- "drag"
1037
- ];
1038
- for (const i of t)
1039
- (i === e || e === "select") && this.enableTool(i);
1040
- }
1041
- /**
1042
- * @deprecated Use getActiveTools instead.
1043
- * Get the first active tool (for legacy compatibility).
1044
- */
1045
- getActiveTool() {
1046
- return this._sortedActiveTools[0] || null;
1047
- }
1048
- }
1049
- class ue {
1050
- constructor(e, t) {
1051
- o(this, "POINTER_DRAG_THRESHOLD", 1e-3);
1052
- o(this, "name");
1053
- o(this, "_canvas");
1054
- o(this, "_scene");
1055
- o(this, "_controller");
1056
- // general pointer members
1057
- o(this, "_pointer");
1058
- o(this, "_pointerPrimaryDown");
1059
- o(this, "_pointerMiddleDown");
1060
- o(this, "_pointerSecondaryDown");
1061
- o(this, "_lastPointerDown");
1062
- o(this, "_lastPointerUp");
1063
- // raycast members
1064
- o(this, "_raycaster");
1065
- o(this, "_intersects");
1066
- // hovering members
1067
- o(this, "_hovered");
1068
- // dragging members
1069
- o(this, "_dragging");
1070
- o(this, "_dragStart");
1071
- o(this, "_dragCurrent");
1072
- o(this, "_dragEnd");
1073
- o(this, "_dragDelta");
1074
- o(this, "_draggable");
1075
- o(this, "_dragRaycastOnObjects");
1076
- this.name = "BaseTool", this._canvas = t.domElement, this._scene = e, this._controller = t, this._pointer = new F(), this._pointerPrimaryDown = !1, this._pointerMiddleDown = !1, this._pointerSecondaryDown = !1, this._lastPointerDown = new F(), this._lastPointerUp = new F(), this._raycaster = new ot(), this._raycaster.layers.mask = G | W, this._intersects = [], this._hovered = null, this._dragging = !1, this._dragStart = new h(), this._dragCurrent = new h(), this._dragEnd = new h(), this._dragDelta = new h(), this._draggable = null, this._dragRaycastOnObjects = null;
1077
- }
1078
- get _pointerAnyDown() {
1079
- return this._pointerPrimaryDown || this._pointerMiddleDown || this._pointerSecondaryDown;
1080
- }
1081
- activate() {
1082
- }
1083
- deactivate() {
1084
- }
1085
- onPointerDown(e) {
1086
- var t;
1087
- switch (e.button) {
1088
- case 0: {
1089
- this._pointerPrimaryDown = !0;
1090
- break;
1091
- }
1092
- case 1: {
1093
- this._pointerMiddleDown = !0;
1094
- break;
1095
- }
1096
- case 2: {
1097
- this._pointerSecondaryDown = !0;
1098
- break;
1099
- }
1100
- default:
1101
- console.warn(
1102
- "DIVEBaseTool.onPointerDown: Unknown button: " + e.button
1103
- );
1104
- }
1105
- this._lastPointerDown.copy(this._pointer), this._draggable = B(
1106
- (t = this._intersects[0]) == null ? void 0 : t.object,
1107
- "isDraggable"
1108
- ) || null;
1109
- }
1110
- onDragStart(e) {
1111
- this._draggable && (this._dragRaycastOnObjects !== null && (this._intersects = this._raycaster.intersectObjects(
1112
- this._dragRaycastOnObjects,
1113
- !0
1114
- )), this._intersects.length !== 0 && (this._dragStart.copy(this._intersects[0].point.clone()), this._dragCurrent.copy(this._intersects[0].point.clone()), this._dragEnd.copy(this._dragStart.clone()), this._dragDelta.set(0, 0, 0), this._draggable && this._draggable.onDragStart && (this._draggable.onDragStart({
1115
- dragStart: this._dragStart,
1116
- dragCurrent: this._dragCurrent,
1117
- dragEnd: this._dragEnd,
1118
- dragDelta: this._dragDelta
1119
- }), this._dragging = !0, this._controller.enabled = !1)));
1120
- }
1121
- onPointerMove(e) {
1122
- var i;
1123
- this._pointer.x = e.offsetX / this._canvas.clientWidth * 2 - 1, this._pointer.y = -(e.offsetY / this._canvas.clientHeight) * 2 + 1, this._raycaster.setFromCamera(this._pointer, this._controller.object), this._intersects = this.raycast(this._scene.children);
1124
- const t = B(
1125
- (i = this._intersects[0]) == null ? void 0 : i.object,
1126
- "isHoverable"
1127
- );
1128
- if (this._intersects[0] && t) {
1129
- if (!this._hovered) {
1130
- t.onPointerEnter && t.onPointerEnter(this._intersects[0]), this._hovered = t;
1131
- return;
1132
- }
1133
- if (this._hovered.uuid !== t.uuid) {
1134
- this._hovered.onPointerLeave && this._hovered.onPointerLeave(), t.onPointerEnter && t.onPointerEnter(this._intersects[0]), this._hovered = t;
1135
- return;
1136
- }
1137
- t.onPointerOver && t.onPointerOver(this._intersects[0]), this._hovered = t;
1138
- } else
1139
- this._hovered && this._hovered.onPointerLeave && this._hovered.onPointerLeave(), this._hovered = null;
1140
- this._pointerAnyDown && (this._dragging || this.onDragStart(e), this.onDrag(e));
1141
- }
1142
- onDrag(e) {
1143
- this._dragRaycastOnObjects !== null && (this._intersects = this._raycaster.intersectObjects(
1144
- this._dragRaycastOnObjects,
1145
- !0
1146
- ));
1147
- const t = this._intersects[0];
1148
- t && (this._dragCurrent.copy(t.point.clone()), this._dragEnd.copy(t.point.clone()), this._dragDelta.subVectors(
1149
- this._dragCurrent.clone(),
1150
- this._dragStart.clone()
1151
- ), this._draggable && this._draggable.onDrag && this._draggable.onDrag({
1152
- dragStart: this._dragStart,
1153
- dragCurrent: this._dragCurrent,
1154
- dragEnd: this._dragEnd,
1155
- dragDelta: this._dragDelta
1156
- }));
1157
- }
1158
- onPointerUp(e) {
1159
- switch (this.pointerWasDragged() || this._dragging ? this._draggable && this.onDragEnd(e) : this.onClick(e), e.button) {
1160
- case 0:
1161
- this._pointerPrimaryDown = !1;
1162
- break;
1163
- case 1:
1164
- this._pointerMiddleDown = !1;
1165
- break;
1166
- case 2:
1167
- this._pointerSecondaryDown = !1;
1168
- break;
1169
- }
1170
- this._lastPointerUp.copy(this._pointer);
1171
- }
1172
- onClick(e) {
1173
- }
1174
- onDragEnd(e) {
1175
- const t = this._intersects[0];
1176
- t && (this._dragEnd.copy(t.point.clone()), this._dragCurrent.copy(t.point.clone()), this._dragDelta.subVectors(
1177
- this._dragCurrent.clone(),
1178
- this._dragStart.clone()
1179
- )), this._draggable && this._draggable.onDragEnd && this._draggable.onDragEnd({
1180
- dragStart: this._dragStart,
1181
- dragCurrent: this._dragCurrent,
1182
- dragEnd: this._dragEnd,
1183
- dragDelta: this._dragDelta
1184
- }), this._draggable = null, this._dragging = !1, this._dragStart.set(0, 0, 0), this._dragCurrent.set(0, 0, 0), this._dragEnd.set(0, 0, 0), this._dragDelta.set(0, 0, 0), this._controller.enabled = !0;
1185
- }
1186
- onWheel(e) {
1187
- }
1188
- raycast(e) {
1189
- const i = (e || this._scene.children).filter(
1190
- (n) => n.visible && "isMesh" in n && n.isMesh
563
+ (t, e) => t.priority - e.priority
1191
564
  );
1192
- return this._raycaster.intersectObjects(i, !0);
1193
565
  }
1194
566
  pointerWasDragged() {
1195
- return this._lastPointerDown.distanceTo(this._pointer) > this.POINTER_DRAG_THRESHOLD;
567
+ return this._lastPointerDown.distanceTo(this._pointer) > k;
1196
568
  }
1197
569
  }
1198
570
  export {
1199
- ue as DIVEBaseTool,
1200
- qt as DIVESelectTool,
1201
- te as DIVETransformTool,
1202
- ie as DragTool,
1203
- Wt as HoverTool,
1204
- qt as SelectTool,
1205
- Gt as SelectionState,
1206
- _e as Toolbox,
1207
- te as TransformTool,
1208
- de as isSelectTool,
1209
- pe as isTransformTool
571
+ M as DIVESelectTool,
572
+ L as DIVETransformTool,
573
+ j as DragTool,
574
+ C as HoverTool,
575
+ M as SelectTool,
576
+ z as SelectionState,
577
+ X as Toolbox,
578
+ L as TransformTool,
579
+ B as isSelectTool,
580
+ Y as isTransformTool
1210
581
  };