@shopware-ag/dive 3.0.11 → 4.0.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 (200) hide show
  1. package/README.md +31 -5
  2. package/build/chunks/{AssetCache-MtISiPD2.cjs → AssetCache-DdxevusY.cjs} +1 -1
  3. package/build/chunks/{AssetCache-DOB996Vk.mjs → AssetCache-MXFCGzZU.mjs} +1 -1
  4. package/build/chunks/AssetExporter-CD2iuQce.mjs +108 -0
  5. package/build/chunks/AssetExporter-CoL-QXkB.cjs +1 -0
  6. package/build/chunks/{AssetLoader-B1n3KGOu.cjs → AssetLoader-BDDJG9JL.cjs} +2 -2
  7. package/build/chunks/{AssetLoader-BY5D3Cvc.mjs → AssetLoader-kRhuVN4p.mjs} +12 -21
  8. package/build/chunks/FileTypes-DGSsi-AX.mjs +2294 -0
  9. package/build/chunks/FileTypes-gD_1MonW.cjs +29 -0
  10. package/build/chunks/ModelComponent-Cj3ff6nL.cjs +1 -0
  11. package/build/chunks/ModelComponent-DkfAgTL0.mjs +87 -0
  12. package/build/chunks/OrbitController-DFPcXvlO.cjs +1 -0
  13. package/build/chunks/OrbitController-DLEyTvUt.mjs +612 -0
  14. package/build/chunks/SpriteTextComponent-ByefJLeU.cjs +1 -0
  15. package/build/chunks/SpriteTextComponent-CG5vfiFy.mjs +83 -0
  16. package/build/chunks/collectAnimations-BgYCN1le.mjs +35 -0
  17. package/build/chunks/collectAnimations-C3HfZHte.cjs +1 -0
  18. package/build/chunks/contributesToBounds-C1mva__U.cjs +1 -0
  19. package/build/chunks/contributesToBounds-DYmHYES4.mjs +14 -0
  20. package/build/chunks/detachTransformControls-2XQrpLN-.cjs +1 -0
  21. package/build/chunks/detachTransformControls-Dr3TIdVy.mjs +209 -0
  22. package/build/chunks/{isFileTypeSupported-C-hfGk-7.mjs → isFileExtensionSupported-CgcqpgqN.mjs} +1 -1
  23. package/build/chunks/{isFileTypeSupported-xoGjHFuz.cjs → isFileExtensionSupported-RvlnH2dr.cjs} +1 -1
  24. package/build/chunks/isVisibleInHierarchy-D9JcLqR5.cjs +1 -0
  25. package/build/chunks/isVisibleInHierarchy-KzVGvDEw.mjs +21 -0
  26. package/build/components/boundingbox/BoundingBoxComponent.d.ts +100 -0
  27. package/build/components/boundingbox/index.d.ts +1 -0
  28. package/build/components/camera/CameraComponent.d.ts +75 -0
  29. package/build/components/camera/index.d.ts +2 -0
  30. package/build/components/camera/perspective/PerspectiveCameraComponent.d.ts +39 -0
  31. package/build/components/grid/GridComponent.d.ts +50 -0
  32. package/build/components/index.d.ts +6 -9
  33. package/build/components/light/LightComponent.d.ts +65 -0
  34. package/build/components/light/ambient/AmbientLightComponent.d.ts +10 -0
  35. package/build/components/light/directional/DirectionalLightComponent.d.ts +23 -0
  36. package/build/components/light/hemi/HemisphereLightComponent.d.ts +21 -0
  37. package/build/components/light/index.d.ts +5 -3
  38. package/build/components/light/point/PointLightComponent.d.ts +26 -0
  39. package/build/components/line/MultiLineComponent.d.ts +133 -0
  40. package/build/components/line/index.d.ts +1 -0
  41. package/build/components/mesh/MeshComponent.d.ts +74 -0
  42. package/build/components/mesh/floor/FloorComponent.d.ts +36 -0
  43. package/build/components/mesh/index.d.ts +4 -0
  44. package/build/components/mesh/model/ModelComponent.d.ts +67 -0
  45. package/build/components/mesh/primitive/PrimitiveComponent.d.ts +43 -0
  46. package/build/components/spritetext/SpriteTextComponent.d.ts +58 -0
  47. package/build/constants/VisibilityLayerMask.d.ts +23 -0
  48. package/build/dive.cjs +1 -1
  49. package/build/dive.mjs +252 -774
  50. package/build/engine/Dive.d.ts +17 -13
  51. package/build/engine/boundingbox/BoundingBox.d.ts +76 -0
  52. package/build/engine/component/Component.d.ts +236 -0
  53. package/build/engine/environment/Environment.d.ts +8 -18
  54. package/build/engine/index.d.ts +4 -1
  55. package/build/engine/node/Node.d.ts +189 -0
  56. package/build/engine/promise/abortable/AbortablePromise.d.ts +8 -0
  57. package/build/engine/renderer/Renderer.d.ts +43 -7
  58. package/build/engine/scene/Scene.d.ts +88 -4
  59. package/build/engine/scene/root/Root.d.ts +29 -0
  60. package/build/engine/scene/xrroot/XRRoot.d.ts +1 -1
  61. package/build/engine/view/View.d.ts +15 -4
  62. package/build/helpers/collectAnimations/collectAnimations.d.ts +23 -0
  63. package/build/helpers/computeProductBounds/computeProductBounds.d.ts +18 -0
  64. package/build/helpers/contributesToBounds/contributesToBounds.d.ts +17 -0
  65. package/build/helpers/detachTransformControls/detachTransformControls.d.ts +15 -0
  66. package/build/helpers/disposeComponents/disposeComponents.d.ts +20 -0
  67. package/build/helpers/findSceneRecursive/findSceneRecursive.d.ts +7 -3
  68. package/build/helpers/implementsInterface/implementsInterface.d.ts +11 -0
  69. package/build/helpers/index.d.ts +6 -1
  70. package/build/helpers/isVisibleInHierarchy/isVisibleInHierarchy.d.ts +12 -0
  71. package/build/index.d.ts +0 -1
  72. package/build/plugins/animation/index.mjs +3 -2
  73. package/build/plugins/animation/src/system/AnimationSystem.d.ts +3 -2
  74. package/build/plugins/ar/index.cjs +1 -1
  75. package/build/plugins/ar/index.mjs +2 -2
  76. package/build/plugins/ar/src/webxr/WebXR.d.ts +7 -0
  77. package/build/plugins/assetcache/index.cjs +1 -1
  78. package/build/plugins/assetcache/index.mjs +1 -1
  79. package/build/plugins/assetexporter/index.cjs +1 -1
  80. package/build/plugins/assetexporter/index.mjs +1 -1
  81. package/build/plugins/assetexporter/src/AssetExporter.d.ts +12 -0
  82. package/build/plugins/assetloader/index.cjs +1 -1
  83. package/build/plugins/assetloader/index.mjs +2 -2
  84. package/build/plugins/mediacreator/index.cjs +1 -1
  85. package/build/plugins/mediacreator/index.mjs +32 -30
  86. package/build/plugins/mediacreator/src/MediaCreator.d.ts +1 -2
  87. package/build/plugins/orbitcontroller/index.cjs +1 -1
  88. package/build/plugins/orbitcontroller/index.d.ts +1 -0
  89. package/build/plugins/orbitcontroller/index.mjs +1 -1
  90. package/build/plugins/orbitcontroller/src/OrbitController.d.ts +39 -6
  91. package/build/plugins/orientationdisplay/index.cjs +1 -1
  92. package/build/plugins/orientationdisplay/index.mjs +41 -33
  93. package/build/plugins/orientationdisplay/src/OrientationDisplay.d.ts +3 -3
  94. package/build/plugins/quickview/index.cjs +1 -1
  95. package/build/plugins/quickview/index.mjs +71 -19
  96. package/build/plugins/quickview/src/QuickView.d.ts +40 -8
  97. package/build/plugins/quickview/types/QuickViewSettings.d.ts +14 -0
  98. package/build/plugins/state/index.cjs +1 -27
  99. package/build/plugins/state/index.mjs +2031 -4135
  100. package/build/plugins/state/src/EngineGateway.d.ts +98 -0
  101. package/build/plugins/state/src/EntityRegistry.d.ts +51 -0
  102. package/build/plugins/state/src/State.d.ts +20 -9
  103. package/build/plugins/state/src/actions/camera/computeencompassingview.d.ts +1 -1
  104. package/build/plugins/state/src/actions/camera/movecamera.d.ts +2 -2
  105. package/build/plugins/state/src/actions/index.d.ts +1 -0
  106. package/build/plugins/state/src/actions/media/generatemedia.d.ts +1 -1
  107. package/build/plugins/state/src/actions/object/addobject.d.ts +2 -3
  108. package/build/plugins/state/src/actions/object/deleteobject.d.ts +3 -4
  109. package/build/plugins/state/src/actions/object/deselectobject.d.ts +3 -4
  110. package/build/plugins/state/src/actions/object/dropit.d.ts +2 -2
  111. package/build/plugins/state/src/actions/object/getallobjects.d.ts +2 -3
  112. package/build/plugins/state/src/actions/object/getobjects.d.ts +3 -4
  113. package/build/plugins/state/src/actions/object/index.d.ts +0 -1
  114. package/build/plugins/state/src/actions/object/modelloaded.d.ts +2 -2
  115. package/build/plugins/state/src/actions/object/selectobject.d.ts +3 -4
  116. package/build/plugins/state/src/actions/object/setparent.d.ts +3 -4
  117. package/build/plugins/state/src/actions/object/updateobject.d.ts +3 -4
  118. package/build/plugins/state/src/actions/renderer/startrender.d.ts +1 -1
  119. package/build/plugins/state/src/actions/scene/exportscene.d.ts +2 -2
  120. package/build/plugins/state/src/actions/scene/index.d.ts +0 -1
  121. package/build/plugins/state/src/actions/scene/setbackground.d.ts +2 -2
  122. package/build/plugins/state/src/actions/scene/updatescene.d.ts +2 -2
  123. package/build/plugins/state/src/actions/state/getstate.d.ts +8 -0
  124. package/build/plugins/state/src/actions/state/index.d.ts +2 -0
  125. package/build/plugins/state/src/actions/state/setstate.d.ts +8 -0
  126. package/build/plugins/state/src/helpers/copyVectors/copyVectors.d.ts +17 -0
  127. package/build/plugins/state/src/helpers/updateParentLink/updateParentLink.d.ts +29 -0
  128. package/build/plugins/state/src/helpers/watchEntity/watchEntity.d.ts +30 -0
  129. package/build/plugins/state/types/ActionTypes.d.ts +18 -3
  130. package/build/plugins/state/types/RegisteredEntity.d.ts +27 -0
  131. package/build/plugins/state/types/{StateSceneData.d.ts → StateData.d.ts} +7 -8
  132. package/build/plugins/state/types/index.d.ts +3 -1
  133. package/build/plugins/state/types/schema/BaseEntitySchema.d.ts +25 -0
  134. package/build/plugins/state/types/schema/CameraSchema.d.ts +18 -0
  135. package/build/plugins/state/types/schema/EntitySchema.d.ts +21 -0
  136. package/build/plugins/state/types/schema/EntityTypeSchema.d.ts +9 -0
  137. package/build/{types → plugins/state/types}/schema/GroupSchema.d.ts +8 -1
  138. package/build/{types → plugins/state/types}/schema/LightSchema.d.ts +16 -0
  139. package/build/plugins/state/types/schema/ModelSchema.d.ts +33 -0
  140. package/build/{types → plugins/state/types}/schema/PrimitiveSchema.d.ts +8 -4
  141. package/build/{types → plugins/state/types}/schema/index.d.ts +1 -4
  142. package/build/plugins/toolbox/index.cjs +1 -1
  143. package/build/plugins/toolbox/index.mjs +194 -150
  144. package/build/plugins/toolbox/src/PointerContext.d.ts +7 -0
  145. package/build/plugins/toolbox/src/SelectionState.d.ts +21 -0
  146. package/build/plugins/toolbox/src/Toolbox.d.ts +9 -2
  147. package/build/{components → plugins/toolbox/src}/gizmo/Gizmo.d.ts +16 -2
  148. package/build/{components → plugins/toolbox/src}/gizmo/handles/AxisHandle.d.ts +2 -3
  149. package/build/{components → plugins/toolbox/src}/gizmo/handles/RadialHandle.d.ts +2 -3
  150. package/build/{components → plugins/toolbox/src}/gizmo/handles/ScaleHandle.d.ts +2 -3
  151. package/build/{components → plugins/toolbox/src}/gizmo/rotate/RotateGizmo.d.ts +2 -2
  152. package/build/{components → plugins/toolbox/src}/gizmo/scale/ScaleGizmo.d.ts +3 -3
  153. package/build/{components → plugins/toolbox/src}/gizmo/translate/TranslateGizmo.d.ts +2 -2
  154. package/build/types/components/DIVESceneObject.d.ts +13 -6
  155. package/build/types/components/index.d.ts +0 -1
  156. package/build/types/events/DIVEComponentEventMap.d.ts +14 -0
  157. package/build/types/events/DIVEEntityEventMap.d.ts +47 -0
  158. package/build/types/events/index.d.ts +2 -0
  159. package/build/types/geometry/DIVEGeometry.d.ts +16 -0
  160. package/build/types/geometry/DIVEGeometryType.d.ts +7 -0
  161. package/build/types/geometry/index.d.ts +2 -0
  162. package/build/types/index.d.ts +3 -1
  163. package/build/types/material/DIVEMaterial.d.ts +21 -0
  164. package/build/types/material/index.d.ts +1 -0
  165. package/package.json +8 -9
  166. package/build/chunks/AssetExporter-Cdxb04b3.cjs +0 -1
  167. package/build/chunks/AssetExporter-DLL_vJae.mjs +0 -67
  168. package/build/chunks/FileTypes-DMTSUCcK.cjs +0 -29
  169. package/build/chunks/FileTypes-DYtXCJQV.mjs +0 -2141
  170. package/build/chunks/PerspectiveCamera-B5TvUzTa.mjs +0 -39
  171. package/build/chunks/PerspectiveCamera-DwQUmkDv.cjs +0 -1
  172. package/build/chunks/PovSchema-Co9FznEz.cjs +0 -1
  173. package/build/chunks/PovSchema-DWWvr_ED.mjs +0 -10
  174. package/build/chunks/findInterface-C6mrvf_t.cjs +0 -1
  175. package/build/chunks/findInterface-DbJ5qzbc.mjs +0 -11
  176. package/build/components/boundingbox/BoundingBox.d.ts +0 -136
  177. package/build/components/floor/Floor.d.ts +0 -14
  178. package/build/components/grid/Grid.d.ts +0 -23
  179. package/build/components/group/Group.d.ts +0 -28
  180. package/build/components/light/AmbientLight.d.ts +0 -19
  181. package/build/components/light/PointLight.d.ts +0 -29
  182. package/build/components/light/SceneLight.d.ts +0 -20
  183. package/build/components/model/Model.d.ts +0 -26
  184. package/build/components/node/Node.d.ts +0 -24
  185. package/build/components/primitive/Primitive.d.ts +0 -27
  186. package/build/components/root/Root.d.ts +0 -34
  187. package/build/engine/camera/PerspectiveCamera.d.ts +0 -24
  188. package/build/helpers/isFileTypeSupported/isFileTypeSupported.d.ts +0 -9
  189. package/build/plugins/state/src/actions/object/placeonfloor.d.ts +0 -12
  190. package/build/plugins/state/src/actions/scene/getallscenedata.d.ts +0 -9
  191. package/build/types/components/DIVELight.d.ts +0 -4
  192. package/build/types/schema/BaseEntitySchema.d.ts +0 -8
  193. package/build/types/schema/EntitySchema.d.ts +0 -11
  194. package/build/types/schema/EntityTypeSchema.d.ts +0 -1
  195. package/build/types/schema/GeometrySchema.d.ts +0 -7
  196. package/build/types/schema/GeometryTypeSchema.d.ts +0 -1
  197. package/build/types/schema/MaterialSchema.d.ts +0 -11
  198. package/build/types/schema/ModelSchema.d.ts +0 -14
  199. package/build/types/schema/PovSchema.d.ts +0 -10
  200. /package/build/{components → plugins/toolbox/src}/gizmo/plane/GizmoPlane.d.ts +0 -0
@@ -0,0 +1,612 @@
1
+ var T = Object.defineProperty;
2
+ var A = (p, l, t) => l in p ? T(p, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[l] = t;
3
+ var s = (p, l, t) => A(p, typeof l != "symbol" ? l + "" : l, t);
4
+ import { TOUCH as c, MOUSE as r, Vector3 as n, EventDispatcher as O, MathUtils as L, Spherical as g, Vector2 as h, Quaternion as y } from "three/webgpu";
5
+ import { B as R } from "./FileTypes-DGSsi-AX.mjs";
6
+ import "three/examples/jsm/loaders/HDRLoader.js";
7
+ import "three/tsl";
8
+ const Z = {
9
+ enableDamping: !0,
10
+ dampingFactor: 0.05,
11
+ enabled: !0,
12
+ target: new n(),
13
+ minDistance: 0,
14
+ maxDistance: 1 / 0,
15
+ minZoom: 0,
16
+ maxZoom: 1 / 0,
17
+ minPolarAngle: 0,
18
+ maxPolarAngle: Math.PI,
19
+ minAzimuthAngle: -1 / 0,
20
+ maxAzimuthAngle: 1 / 0,
21
+ enableZoom: !0,
22
+ zoomSpeed: 1,
23
+ enableRotate: !0,
24
+ rotateSpeed: 1,
25
+ enablePan: !0,
26
+ panSpeed: 1,
27
+ screenSpacePanning: !0,
28
+ keyPanSpeed: 7,
29
+ autoRotate: !1,
30
+ autoRotateSpeed: 2,
31
+ keys: {
32
+ LEFT: "ArrowLeft",
33
+ UP: "ArrowUp",
34
+ RIGHT: "ArrowRight",
35
+ BOTTOM: "ArrowDown"
36
+ },
37
+ mouseButtons: {
38
+ LEFT: r.ROTATE,
39
+ MIDDLE: r.DOLLY,
40
+ RIGHT: r.PAN
41
+ },
42
+ touches: {
43
+ ONE: c.ROTATE,
44
+ TWO: c.DOLLY_PAN
45
+ }
46
+ }, u = class u extends O {
47
+ constructor(t, e, i) {
48
+ super();
49
+ // public API
50
+ /**
51
+ * The camera component this controller drives.
52
+ *
53
+ * The component rather than the camera: `setCameraLayer` and `onResize` live
54
+ * there, and handing out the bare camera meant every caller had to search its
55
+ * way back. What orbiting moves is `object.owner`, the node it sits on.
56
+ */
57
+ s(this, "object");
58
+ s(this, "domElements");
59
+ s(this, "enabled", !0);
60
+ s(this, "target", new n());
61
+ s(this, "minDistance", 0);
62
+ s(this, "maxDistance", 1 / 0);
63
+ s(this, "minZoom", 0);
64
+ s(this, "maxZoom", 1 / 0);
65
+ s(this, "minPolarAngle", 0);
66
+ // radians
67
+ s(this, "maxPolarAngle", Math.PI);
68
+ // radians
69
+ s(this, "minAzimuthAngle", -1 / 0);
70
+ // radians
71
+ s(this, "maxAzimuthAngle", 1 / 0);
72
+ // radians
73
+ s(this, "enableDamping", !0);
74
+ s(this, "dampingFactor", 0.05);
75
+ s(this, "enableZoom", !0);
76
+ s(this, "zoomSpeed", 1);
77
+ s(this, "enableRotate", !0);
78
+ s(this, "rotateSpeed", 1);
79
+ s(this, "enablePan", !0);
80
+ s(this, "panSpeed", 1);
81
+ s(this, "screenSpacePanning", !0);
82
+ s(this, "keyPanSpeed", 7);
83
+ s(this, "autoRotate", !1);
84
+ s(this, "autoRotateSpeed", 2);
85
+ s(this, "keys", {
86
+ LEFT: "ArrowLeft",
87
+ UP: "ArrowUp",
88
+ RIGHT: "ArrowRight",
89
+ BOTTOM: "ArrowDown"
90
+ });
91
+ s(this, "mouseButtons", {
92
+ LEFT: r.ROTATE,
93
+ MIDDLE: r.DOLLY,
94
+ RIGHT: r.PAN
95
+ });
96
+ s(this, "touches", { ONE: c.ROTATE, TWO: c.DOLLY_PAN });
97
+ s(this, "target0");
98
+ s(this, "position0");
99
+ s(this, "zoom0");
100
+ s(this, "uuid", L.generateUUID());
101
+ // private state
102
+ s(this, "state", -1);
103
+ s(this, "EPS", 1e-6);
104
+ s(this, "spherical", new g());
105
+ s(this, "sphericalDelta", new g());
106
+ s(this, "scale", 1);
107
+ s(this, "panOffset", new n());
108
+ s(this, "zoomChanged", !1);
109
+ s(this, "rotateStart", new h());
110
+ s(this, "rotateEnd", new h());
111
+ s(this, "rotateDelta", new h());
112
+ s(this, "panStart", new h());
113
+ s(this, "panEnd", new h());
114
+ s(this, "panDelta", new h());
115
+ s(this, "dollyStart", new h());
116
+ s(this, "dollyEnd", new h());
117
+ s(this, "dollyDelta", new h());
118
+ s(this, "pointers", []);
119
+ s(this, "pointerPositions", {});
120
+ // for update() function
121
+ s(this, "offset", new n());
122
+ s(this, "quat");
123
+ s(this, "quatInverse");
124
+ s(this, "lastPosition", new n());
125
+ s(this, "lastQuaternion", new y());
126
+ s(this, "lastTarget", new n());
127
+ s(this, "panLeft", (() => {
128
+ const t = new n();
129
+ return (e, i) => {
130
+ t.setFromMatrixColumn(i, 0), t.multiplyScalar(-e), this.panOffset.add(t);
131
+ };
132
+ })());
133
+ s(this, "panUp", (() => {
134
+ const t = new n();
135
+ return (e, i) => {
136
+ this.screenSpacePanning === !0 ? t.setFromMatrixColumn(i, 1) : (t.setFromMatrixColumn(i, 0), t.crossVectors(this.object.camera.up, t)), t.multiplyScalar(e), this.panOffset.add(t);
137
+ };
138
+ })());
139
+ s(this, "onMouseDown", (t) => {
140
+ let e;
141
+ switch (t.button) {
142
+ case 0:
143
+ e = this.mouseButtons.LEFT;
144
+ break;
145
+ case 1:
146
+ e = this.mouseButtons.MIDDLE;
147
+ break;
148
+ case 2:
149
+ e = this.mouseButtons.RIGHT;
150
+ break;
151
+ default:
152
+ e = -1;
153
+ }
154
+ switch (e) {
155
+ case r.DOLLY:
156
+ if (this.enableZoom === !1) return;
157
+ this.handleMouseDownDolly(t), this.state = 1;
158
+ break;
159
+ case r.ROTATE:
160
+ if (t.ctrlKey || t.metaKey || t.shiftKey) {
161
+ if (this.enablePan === !1) return;
162
+ this.handleMouseDownPan(t), this.state = 2;
163
+ } else {
164
+ if (this.enableRotate === !1) return;
165
+ this.handleMouseDownRotate(t), this.state = 0;
166
+ }
167
+ break;
168
+ case r.PAN:
169
+ if (t.ctrlKey || t.metaKey || t.shiftKey) {
170
+ if (this.enableRotate === !1) return;
171
+ this.handleMouseDownRotate(t), this.state = 0;
172
+ } else {
173
+ if (this.enablePan === !1) return;
174
+ this.handleMouseDownPan(t), this.state = 2;
175
+ }
176
+ break;
177
+ default:
178
+ this.state = -1;
179
+ }
180
+ this.state !== -1 && this.dispatchEvent({ type: "start" });
181
+ });
182
+ s(this, "onMouseMove", (t) => {
183
+ if (this.enabled !== !1)
184
+ switch (this.state) {
185
+ case 0:
186
+ if (this.enableRotate === !1) return;
187
+ this.handleMouseMoveRotate(t);
188
+ break;
189
+ case 1:
190
+ if (this.enableZoom === !1) return;
191
+ this.handleMouseMoveDolly(t);
192
+ break;
193
+ case 2:
194
+ if (this.enablePan === !1) return;
195
+ this.handleMouseMovePan(t);
196
+ break;
197
+ }
198
+ });
199
+ s(this, "onMouseWheel", (t) => {
200
+ this.enabled === !1 || this.enableZoom === !1 || this.state !== -1 || (t.preventDefault(), this.dispatchEvent({ type: "start" }), this.handleMouseWheel(t), this.dispatchEvent({ type: "end" }));
201
+ });
202
+ s(this, "onKeyDown", (t) => {
203
+ this.enabled === !1 || this.enablePan === !1 || this.handleKeyDown(t);
204
+ });
205
+ s(this, "onTouchStart", (t) => {
206
+ switch (this.trackPointer(t), this.pointers.length) {
207
+ case 1:
208
+ switch (this.touches.ONE) {
209
+ case c.ROTATE:
210
+ if (this.enableRotate === !1) return;
211
+ this.handleTouchStartRotate(t), this.state = 3;
212
+ break;
213
+ case c.PAN:
214
+ if (this.enablePan === !1) return;
215
+ this.handleTouchStartPan(t), this.state = 4;
216
+ break;
217
+ default:
218
+ this.state = -1;
219
+ }
220
+ break;
221
+ case 2:
222
+ switch (this.touches.TWO) {
223
+ case c.DOLLY_PAN:
224
+ if (this.enableZoom === !1 && this.enablePan === !1)
225
+ return;
226
+ this.handleTouchStartDollyPan(t), this.state = 5;
227
+ break;
228
+ case c.DOLLY_ROTATE:
229
+ if (this.enableZoom === !1 && this.enableRotate === !1)
230
+ return;
231
+ this.handleTouchStartDollyRotate(t), this.state = 6;
232
+ break;
233
+ default:
234
+ this.state = -1;
235
+ }
236
+ break;
237
+ default:
238
+ this.state = -1;
239
+ }
240
+ this.state !== -1 && this.dispatchEvent({ type: "start" });
241
+ });
242
+ s(this, "onTouchMove", (t) => {
243
+ switch (this.trackPointer(t), this.state) {
244
+ case 3:
245
+ if (this.enableRotate === !1) return;
246
+ this.handleTouchMoveRotate(t), this.update();
247
+ break;
248
+ case 4:
249
+ if (this.enablePan === !1) return;
250
+ this.handleTouchMovePan(t), this.update();
251
+ break;
252
+ case 5:
253
+ if (this.enableZoom === !1 && this.enablePan === !1)
254
+ return;
255
+ this.handleTouchMoveDollyPan(t), this.update();
256
+ break;
257
+ case 6:
258
+ if (this.enableZoom === !1 && this.enableRotate === !1)
259
+ return;
260
+ this.handleTouchMoveDollyRotate(t), this.update();
261
+ break;
262
+ default:
263
+ this.state = -1;
264
+ }
265
+ });
266
+ s(this, "onPointerDown", (t) => {
267
+ if (this.enabled !== !1) {
268
+ if (this.pointers.length === 0) {
269
+ const e = t.currentTarget;
270
+ e.setPointerCapture(t.pointerId), e.addEventListener("pointermove", this.onPointerMove), e.addEventListener("pointerup", this.onPointerUp);
271
+ }
272
+ this.isTrackingPointer(t) || (this.addPointer(t), t.pointerType === "touch" ? this.onTouchStart(t) : this.onMouseDown(t));
273
+ }
274
+ });
275
+ s(this, "onPointerMove", (t) => {
276
+ this.enabled !== !1 && (t.pointerType === "touch" ? this.onTouchMove(t) : this.onMouseMove(t));
277
+ });
278
+ s(this, "onPointerUp", (t) => {
279
+ if (this.removePointer(t), this.pointers.length === 0) {
280
+ const e = t.currentTarget;
281
+ e.releasePointerCapture(t.pointerId), e.removeEventListener("pointermove", this.onPointerMove), e.removeEventListener("pointerup", this.onPointerUp), this.dispatchEvent({ type: "end" }), this.state = -1;
282
+ }
283
+ });
284
+ s(this, "onPointerCancel", (t) => {
285
+ this.removePointer(t);
286
+ });
287
+ s(this, "onContextMenu", (t) => {
288
+ this.enabled !== !1 && t.preventDefault();
289
+ });
290
+ if (this.object = t, !t.isAttached)
291
+ throw new Error(
292
+ "OrbitController: the camera component must be attached to a node, because that is what gets moved."
293
+ );
294
+ this.domElements = Array.isArray(e) ? e : [e], Object.assign(this, i), this.target0 = this.target.clone(), this.position0 = this.object.owner.position.clone(), this.zoom0 = this._camera.zoom, this.quat = new y().setFromUnitVectors(
295
+ this.object.camera.up,
296
+ new n(0, 1, 0)
297
+ ), this.quatInverse = this.quat.clone().invert(), this.domElements.forEach((a) => this.addEventListeners(a)), this.update();
298
+ }
299
+ /**
300
+ * The camera, narrowed to the two kinds whose projection this can pan.
301
+ *
302
+ * `DIVECameraComponent` types its camera as the base `Camera`, which has no
303
+ * `zoom` or `fov`; the branches below narrow it further.
304
+ */
305
+ get _camera() {
306
+ return this.object.camera;
307
+ }
308
+ get domElement() {
309
+ return this.domElements[0];
310
+ }
311
+ tick() {
312
+ this.enabled && this.update();
313
+ }
314
+ getPolarAngle() {
315
+ return this.spherical.phi;
316
+ }
317
+ getAzimuthalAngle() {
318
+ return this.spherical.theta;
319
+ }
320
+ getDistance() {
321
+ return this.object.owner.position.distanceTo(this.target);
322
+ }
323
+ saveState() {
324
+ this.target0.copy(this.target), this.position0.copy(this.object.owner.position), this.zoom0 = this._camera.zoom;
325
+ }
326
+ reset() {
327
+ this.target.copy(this.target0), this.object.owner.position.copy(this.position0), this._camera.zoom = this.zoom0, this._camera.updateProjectionMatrix(), this.dispatchEvent({ type: "change" }), this.update(), this.state = -1;
328
+ }
329
+ update() {
330
+ return this.offset.copy(this.object.owner.position).sub(this.target), this.offset.applyQuaternion(this.quat), this.spherical.setFromVector3(this.offset), this.autoRotate && this.state === -1 && this.rotateLeft(this.getAutoRotationAngle()), this.enableDamping ? (this.spherical.theta += this.sphericalDelta.theta * this.dampingFactor, this.spherical.phi += this.sphericalDelta.phi * this.dampingFactor) : (this.spherical.theta += this.sphericalDelta.theta, this.spherical.phi += this.sphericalDelta.phi), this.spherical.theta = Math.max(
331
+ this.minAzimuthAngle,
332
+ Math.min(this.maxAzimuthAngle, this.spherical.theta)
333
+ ), this.spherical.phi = Math.max(
334
+ this.minPolarAngle,
335
+ Math.min(this.maxPolarAngle, this.spherical.phi)
336
+ ), this.spherical.makeSafe(), this.spherical.radius *= this.scale, this.spherical.radius = Math.max(
337
+ this.minDistance,
338
+ Math.min(this.maxDistance, this.spherical.radius)
339
+ ), this.enableDamping === !0 ? this.target.addScaledVector(this.panOffset, this.dampingFactor) : this.target.add(this.panOffset), this.offset.setFromSpherical(this.spherical), this.offset.applyQuaternion(this.quatInverse), this.object.owner.position.copy(this.target).add(this.offset), this.object.lookAt(this.target), this.enableDamping === !0 ? (this.sphericalDelta.theta *= 1 - this.dampingFactor, this.sphericalDelta.phi *= 1 - this.dampingFactor, this.panOffset.multiplyScalar(1 - this.dampingFactor)) : (this.sphericalDelta.set(0, 0, 0), this.panOffset.set(0, 0, 0)), this.scale = 1, this.zoomChanged || this.lastPosition.distanceToSquared(this.object.owner.position) > this.EPS || 8 * (1 - this.lastQuaternion.dot(this.object.owner.quaternion)) > this.EPS || this.lastTarget.distanceToSquared(this.target) > this.EPS ? (this.dispatchEvent({ type: "change" }), this.lastPosition.copy(this.object.owner.position), this.lastQuaternion.copy(this.object.owner.quaternion), this.lastTarget.copy(this.target), this.zoomChanged = !1, !0) : !1;
340
+ }
341
+ dispose() {
342
+ this.domElements.forEach(
343
+ (t) => this.removeEventListeners(t)
344
+ ), this.dispatchEvent({ type: "dispose" });
345
+ }
346
+ addDomElements(...t) {
347
+ t.forEach((e) => {
348
+ this.domElements.includes(e) || (this.domElements.push(e), this.addEventListeners(e));
349
+ });
350
+ }
351
+ removeDomElements(...t) {
352
+ t.forEach((e) => {
353
+ const i = this.domElements.indexOf(e);
354
+ i > -1 && (this.removeEventListeners(e), this.domElements.splice(i, 1));
355
+ });
356
+ }
357
+ setDomElements(...t) {
358
+ this.removeDomElements(...this.domElements), this.domElements = [], this.addDomElements(...t);
359
+ }
360
+ /**
361
+ * Where to put the camera so a sphere fills the view.
362
+ *
363
+ * Takes a `Sphere` rather than a bounding box: framing needs a centre and a
364
+ * radius, and nothing else. Build one with `new BoundingBox().enclose(...)`,
365
+ * or read `sphere` off a `BoundingBoxComponent` that already measures a node.
366
+ *
367
+ * @param sphere - What to frame, in world space.
368
+ * @param padding - Extra distance as a fraction of the fitted one.
369
+ */
370
+ computeEncompassingView(t, e = 0) {
371
+ const i = t.center, a = t.radius, o = this._camera, d = o.fov * (Math.PI / 180), P = o.aspect, m = d / 2, D = Math.atan(Math.tan(m) * P), w = a / Math.sin(m), E = a / Math.sin(D), S = Math.max(w, E) * (1 + e), f = this.object.owner.position.clone().sub(this.target).normalize(), M = f.length() > 1e-3 ? f : new n(0, 0, 1);
372
+ return {
373
+ position: i.clone().add(M.multiplyScalar(S)),
374
+ target: i
375
+ };
376
+ }
377
+ /**
378
+ * Puts the camera where the whole node fits in the view.
379
+ *
380
+ * One node, not a list: a node already is the handle for everything below it,
381
+ * so anything worth framing together belongs under a common parent.
382
+ *
383
+ * @param node - What to frame.
384
+ * @param padding - Extra distance as a fraction of the fitted one.
385
+ */
386
+ focusObject(t, e = 0) {
387
+ const i = this.computeEncompassingView(
388
+ new R().enclose(t).sphere,
389
+ e
390
+ );
391
+ this.object.owner.position.copy(i.position), this.target.copy(i.target), this.update();
392
+ }
393
+ zoomIn(t) {
394
+ this.dollyIn(Math.pow(0.95, t ?? u.DEFAULT_ZOOM_FACTOR)), this.update();
395
+ }
396
+ zoomOut(t) {
397
+ this.dollyOut(
398
+ Math.pow(0.95, t ?? u.DEFAULT_ZOOM_FACTOR)
399
+ ), this.update();
400
+ }
401
+ getState() {
402
+ return {
403
+ target: this.target.clone(),
404
+ azimuthalAngle: this.getAzimuthalAngle(),
405
+ polarAngle: this.getPolarAngle(),
406
+ distance: this.getDistance(),
407
+ position: this.object.owner.position.clone(),
408
+ quaternion: this.object.owner.quaternion.clone()
409
+ };
410
+ }
411
+ setState(t) {
412
+ this.target.copy(t.target), this.object.owner.position.copy(t.position), this.object.owner.quaternion.copy(t.quaternion), this.update();
413
+ }
414
+ //
415
+ // Private methods
416
+ //
417
+ addEventListeners(t) {
418
+ t.style.touchAction = "none", t.addEventListener("contextmenu", this.onContextMenu), t.addEventListener("pointerdown", this.onPointerDown), t.addEventListener("pointercancel", this.onPointerCancel), t.addEventListener("wheel", this.onMouseWheel, {
419
+ passive: !1
420
+ }), t.addEventListener("keydown", this.onKeyDown);
421
+ }
422
+ removeEventListeners(t) {
423
+ t.removeEventListener("contextmenu", this.onContextMenu), t.removeEventListener("pointerdown", this.onPointerDown), t.removeEventListener("pointercancel", this.onPointerCancel), t.removeEventListener("wheel", this.onMouseWheel), t.removeEventListener("keydown", this.onKeyDown), t.removeEventListener("pointermove", this.onPointerMove), t.removeEventListener("pointerup", this.onPointerUp);
424
+ }
425
+ getAutoRotationAngle() {
426
+ return 2 * Math.PI / 60 / 60 * this.autoRotateSpeed;
427
+ }
428
+ getZoomScale() {
429
+ return Math.pow(0.95, this.zoomSpeed);
430
+ }
431
+ rotateLeft(t) {
432
+ this.sphericalDelta.theta -= t;
433
+ }
434
+ rotateUp(t) {
435
+ this.sphericalDelta.phi -= t;
436
+ }
437
+ pan(t, e, i) {
438
+ const a = new n();
439
+ if ("isPerspectiveCamera" in this._camera) {
440
+ const o = this.object.owner.position;
441
+ a.copy(o).sub(this.target);
442
+ let d = a.length();
443
+ d *= Math.tan(
444
+ this._camera.fov / 2 * Math.PI / 180
445
+ ), this.panLeft(
446
+ 2 * t * d / i.clientHeight,
447
+ this.object.owner.matrix
448
+ ), this.panUp(
449
+ 2 * e * d / i.clientHeight,
450
+ this.object.owner.matrix
451
+ );
452
+ } else "isOrthographicCamera" in this._camera ? (this.panLeft(
453
+ t * (this._camera.right - this._camera.left) / this._camera.zoom / i.clientWidth,
454
+ this.object.owner.matrix
455
+ ), this.panUp(
456
+ e * (this._camera.top - this._camera.bottom) / this._camera.zoom / i.clientHeight,
457
+ this.object.owner.matrix
458
+ )) : (console.warn(
459
+ "WARNING: OrbitController encountered an unknown camera type - pan disabled."
460
+ ), this.enablePan = !1);
461
+ }
462
+ dollyIn(t) {
463
+ "isPerspectiveCamera" in this._camera || "isOrthographicCamera" in this._camera ? this.scale *= t : (console.warn(
464
+ "WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."
465
+ ), this.enableZoom = !1);
466
+ }
467
+ dollyOut(t) {
468
+ "isPerspectiveCamera" in this._camera || "isOrthographicCamera" in this._camera ? this.scale /= t : (console.warn(
469
+ "WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."
470
+ ), this.enableZoom = !1);
471
+ }
472
+ // event callbacks
473
+ handleMouseDownRotate(t) {
474
+ this.rotateStart.set(t.clientX, t.clientY);
475
+ }
476
+ handleMouseDownDolly(t) {
477
+ this.dollyStart.set(t.clientX, t.clientY);
478
+ }
479
+ handleMouseDownPan(t) {
480
+ this.panStart.set(t.clientX, t.clientY);
481
+ }
482
+ handleMouseMoveRotate(t) {
483
+ this.rotateEnd.set(t.clientX, t.clientY), this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart).multiplyScalar(this.rotateSpeed);
484
+ const e = t.currentTarget;
485
+ this.rotateLeft(
486
+ 2 * Math.PI * this.rotateDelta.x / e.clientHeight
487
+ ), this.rotateUp(
488
+ 2 * Math.PI * this.rotateDelta.y / e.clientHeight
489
+ ), this.rotateStart.copy(this.rotateEnd), this.update();
490
+ }
491
+ handleMouseMoveDolly(t) {
492
+ this.dollyEnd.set(t.clientX, t.clientY), this.dollyDelta.subVectors(this.dollyEnd, this.dollyStart), this.dollyDelta.y > 0 ? this.dollyIn(this.getZoomScale()) : this.dollyDelta.y < 0 && this.dollyOut(this.getZoomScale()), this.dollyStart.copy(this.dollyEnd), this.update();
493
+ }
494
+ handleMouseMovePan(t) {
495
+ const e = t.currentTarget;
496
+ this.panEnd.set(t.clientX, t.clientY), this.panDelta.subVectors(this.panEnd, this.panStart).multiplyScalar(this.panSpeed), this.pan(this.panDelta.x, this.panDelta.y, e), this.panStart.copy(this.panEnd), this.update();
497
+ }
498
+ handleMouseWheel(t) {
499
+ t.deltaY < 0 ? this.dollyIn(this.getZoomScale()) : t.deltaY > 0 && this.dollyOut(this.getZoomScale()), this.update();
500
+ }
501
+ handleKeyDown(t) {
502
+ let e = !1;
503
+ const i = t.currentTarget;
504
+ switch (t.code) {
505
+ case this.keys.UP:
506
+ this.pan(0, this.keyPanSpeed, i), e = !0;
507
+ break;
508
+ case this.keys.BOTTOM:
509
+ this.pan(0, -this.keyPanSpeed, i), e = !0;
510
+ break;
511
+ case this.keys.LEFT:
512
+ this.pan(this.keyPanSpeed, 0, i), e = !0;
513
+ break;
514
+ case this.keys.RIGHT:
515
+ this.pan(-this.keyPanSpeed, 0, i), e = !0;
516
+ break;
517
+ }
518
+ e && (t.preventDefault(), this.update());
519
+ }
520
+ handleTouchStartRotate(t) {
521
+ if (this.pointers.length === 1)
522
+ this.rotateStart.set(t.pageX, t.pageY);
523
+ else {
524
+ const e = this.getSecondPointer(t), i = 0.5 * (t.pageX + e.pageX), a = 0.5 * (t.pageY + e.pageY);
525
+ this.rotateStart.set(i, a);
526
+ }
527
+ }
528
+ handleTouchStartPan(t) {
529
+ if (this.pointers.length === 1)
530
+ this.panStart.set(t.pageX, t.pageY);
531
+ else {
532
+ const e = this.getSecondPointer(t), i = 0.5 * (t.pageX + e.pageX), a = 0.5 * (t.pageY + e.pageY);
533
+ this.panStart.set(i, a);
534
+ }
535
+ }
536
+ handleTouchStartDolly(t) {
537
+ const e = this.getSecondPointer(t), i = t.pageX - e.pageX, a = t.pageY - e.pageY, o = Math.sqrt(i * i + a * a);
538
+ this.dollyStart.set(0, o);
539
+ }
540
+ handleTouchStartDollyPan(t) {
541
+ this.enableZoom && this.handleTouchStartDolly(t), this.enablePan && this.handleTouchStartPan(t);
542
+ }
543
+ handleTouchStartDollyRotate(t) {
544
+ this.enableZoom && this.handleTouchStartDolly(t), this.enableRotate && this.handleTouchStartRotate(t);
545
+ }
546
+ handleTouchMoveRotate(t) {
547
+ if (this.pointers.length === 1)
548
+ this.rotateEnd.set(t.pageX, t.pageY);
549
+ else {
550
+ const i = this.getSecondPointer(t), a = 0.5 * (t.pageX + i.pageX), o = 0.5 * (t.pageY + i.pageY);
551
+ this.rotateEnd.set(a, o);
552
+ }
553
+ const e = t.currentTarget;
554
+ this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart).multiplyScalar(this.rotateSpeed), this.rotateLeft(
555
+ 2 * Math.PI * this.rotateDelta.x / e.clientHeight
556
+ ), this.rotateUp(
557
+ 2 * Math.PI * this.rotateDelta.y / e.clientHeight
558
+ ), this.rotateStart.copy(this.rotateEnd);
559
+ }
560
+ handleTouchMovePan(t) {
561
+ if (this.pointers.length === 1)
562
+ this.panEnd.set(t.pageX, t.pageY);
563
+ else {
564
+ const i = this.getSecondPointer(t), a = 0.5 * (t.pageX + i.pageX), o = 0.5 * (t.pageY + i.pageY);
565
+ this.panEnd.set(a, o);
566
+ }
567
+ const e = t.currentTarget;
568
+ this.panDelta.subVectors(this.panEnd, this.panStart).multiplyScalar(this.panSpeed), this.pan(this.panDelta.x, this.panDelta.y, e), this.panStart.copy(this.panEnd);
569
+ }
570
+ handleTouchMoveDolly(t) {
571
+ const e = this.getSecondPointer(t), i = t.pageX - e.pageX, a = t.pageY - e.pageY, o = Math.sqrt(i * i + a * a);
572
+ this.dollyEnd.set(0, o), this.dollyDelta.set(
573
+ 0,
574
+ Math.pow(this.dollyEnd.y / this.dollyStart.y, this.zoomSpeed)
575
+ ), this.dollyOut(this.dollyDelta.y), this.dollyStart.copy(this.dollyEnd);
576
+ }
577
+ handleTouchMoveDollyPan(t) {
578
+ this.enableZoom && this.handleTouchMoveDolly(t), this.enablePan && this.handleTouchMovePan(t);
579
+ }
580
+ handleTouchMoveDollyRotate(t) {
581
+ this.enableZoom && this.handleTouchMoveDolly(t), this.enableRotate && this.handleTouchMoveRotate(t);
582
+ }
583
+ addPointer(t) {
584
+ this.pointers.push(t);
585
+ }
586
+ removePointer(t) {
587
+ delete this.pointerPositions[t.pointerId];
588
+ for (let e = 0; e < this.pointers.length; e++)
589
+ if (this.pointers[e].pointerId == t.pointerId) {
590
+ this.pointers.splice(e, 1);
591
+ return;
592
+ }
593
+ }
594
+ trackPointer(t) {
595
+ let e = this.pointerPositions[t.pointerId];
596
+ e === void 0 && (e = new h(), this.pointerPositions[t.pointerId] = e), e.set(t.pageX, t.pageY);
597
+ }
598
+ getSecondPointer(t) {
599
+ return this.pointers[0].pointerId === t.pointerId ? this.pointers[1] : this.pointers[0];
600
+ }
601
+ isTrackingPointer(t) {
602
+ return this.pointers.some(
603
+ (e) => e.pointerId === t.pointerId
604
+ );
605
+ }
606
+ };
607
+ s(u, "DEFAULT_ZOOM_FACTOR", 1);
608
+ let b = u;
609
+ export {
610
+ b as O,
611
+ Z as a
612
+ };
@@ -0,0 +1 @@
1
+ "use strict";var a=Object.defineProperty;var _=(i,e,t)=>e in i?a(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var s=(i,e,t)=>_(i,typeof e!="symbol"?e+"":e,t);const r=require("three/webgpu"),x=require("./FileTypes-gD_1MonW.cjs"),h=90,o=`normal ${h}px Arial`;class p extends x.DIVEComponent{constructor(){super();s(this,"isSpriteTextComponent",!0);s(this,"_text","");s(this,"_textHeight",1);s(this,"_color",new r.Color(16777215));s(this,"_canvas");s(this,"_texture");s(this,"_sprite");this.name="SpriteTextComponent",this._canvas=document.createElement("canvas"),this._texture=new r.CanvasTexture(this._canvas),this._texture.colorSpace=r.SRGBColorSpace,this._sprite=new r.Sprite(new r.SpriteMaterial({map:this._texture})),this._sprite.name="SpriteText",this.contribute(this._sprite),this._draw()}get sprite(){return this._sprite}get text(){return this._text}get textHeight(){return this._textHeight}get color(){return this._color}setText(t){return this._text=t,this._draw(),this}setTextHeight(t){return this._textHeight=t,this._draw(),this}setColor(t){return this._color.set(t),this._draw(),this}onAttach(t){this._sprite.layers.mask=t.layers.mask}copy(t){return super.copy(t),this._text=t.text,this._textHeight=t.textHeight,this._color.copy(t.color),this._draw(),this}dispose(){this._texture.dispose(),this._sprite.material.dispose()}_draw(){const t=this._canvas.getContext("2d");if(t===null)return;t.font=o;const n=Math.max(1,Math.ceil(t.measureText(this._text).width));this._canvas.width=n,this._canvas.height=h,t.font=o,t.fillStyle=`#${this._color.getHexString()}`,t.textBaseline="bottom",t.fillText(this._text,0,h),this._texture.needsUpdate=!0,this._sprite.scale.set(this._textHeight*n/h,this._textHeight,1)}}exports.SpriteTextComponent=p;
@@ -0,0 +1,83 @@
1
+ var a = Object.defineProperty;
2
+ var n = (i, e, t) => e in i ? a(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var s = (i, e, t) => n(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Color as _, CanvasTexture as x, SRGBColorSpace as p, Sprite as c, SpriteMaterial as l } from "three/webgpu";
5
+ import { a as u } from "./FileTypes-DGSsi-AX.mjs";
6
+ const r = 90, o = `normal ${r}px Arial`;
7
+ class w extends u {
8
+ constructor() {
9
+ super();
10
+ s(this, "isSpriteTextComponent", !0);
11
+ s(this, "_text", "");
12
+ s(this, "_textHeight", 1);
13
+ s(this, "_color", new _(16777215));
14
+ s(this, "_canvas");
15
+ s(this, "_texture");
16
+ s(this, "_sprite");
17
+ this.name = "SpriteTextComponent", this._canvas = document.createElement("canvas"), this._texture = new x(this._canvas), this._texture.colorSpace = p, this._sprite = new c(new l({ map: this._texture })), this._sprite.name = "SpriteText", this.contribute(this._sprite), this._draw();
18
+ }
19
+ /** The sprite the label is drawn on. */
20
+ get sprite() {
21
+ return this._sprite;
22
+ }
23
+ /** The text currently drawn. */
24
+ get text() {
25
+ return this._text;
26
+ }
27
+ /** The label's height in world units. */
28
+ get textHeight() {
29
+ return this._textHeight;
30
+ }
31
+ /** The colour the text is rasterized in. */
32
+ get color() {
33
+ return this._color;
34
+ }
35
+ /**
36
+ * @param text - What to write.
37
+ */
38
+ setText(t) {
39
+ return this._text = t, this._draw(), this;
40
+ }
41
+ /**
42
+ * @param textHeight - The label's height in world units.
43
+ */
44
+ setTextHeight(t) {
45
+ return this._textHeight = t, this._draw(), this;
46
+ }
47
+ /**
48
+ * @param color - The colour to rasterize the text in.
49
+ */
50
+ setColor(t) {
51
+ return this._color.set(t), this._draw(), this;
52
+ }
53
+ onAttach(t) {
54
+ this._sprite.layers.mask = t.layers.mask;
55
+ }
56
+ copy(t) {
57
+ return super.copy(t), this._text = t.text, this._textHeight = t.textHeight, this._color.copy(t.color), this._draw(), this;
58
+ }
59
+ dispose() {
60
+ this._texture.dispose(), this._sprite.material.dispose();
61
+ }
62
+ /**
63
+ * Rasterizes the text to the canvas and scales the sprite to the resulting
64
+ * aspect ratio, so the label's height matches its text height in world units.
65
+ */
66
+ _draw() {
67
+ const t = this._canvas.getContext("2d");
68
+ if (t === null) return;
69
+ t.font = o;
70
+ const h = Math.max(
71
+ 1,
72
+ Math.ceil(t.measureText(this._text).width)
73
+ );
74
+ this._canvas.width = h, this._canvas.height = r, t.font = o, t.fillStyle = `#${this._color.getHexString()}`, t.textBaseline = "bottom", t.fillText(this._text, 0, r), this._texture.needsUpdate = !0, this._sprite.scale.set(
75
+ this._textHeight * h / r,
76
+ this._textHeight,
77
+ 1
78
+ );
79
+ }
80
+ }
81
+ export {
82
+ w as S
83
+ };