@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,10 @@
1
+ import { DIVELightComponent } from '../LightComponent.ts';
2
+ /**
3
+ * Uniform light from every direction, with no position or direction.
4
+ *
5
+ * @module
6
+ */
7
+ export declare class AmbientLightComponent extends DIVELightComponent {
8
+ readonly isAmbientLightComponent: true;
9
+ constructor();
10
+ }
@@ -0,0 +1,23 @@
1
+ import { Vector3Like } from 'three/webgpu';
2
+ import { DIVELightComponent } from '../LightComponent.ts';
3
+ /**
4
+ * Parallel light from a fixed direction, the usual choice for sunlight. Casts
5
+ * shadows.
6
+ *
7
+ * @module
8
+ */
9
+ export declare class DirectionalLightComponent extends DIVELightComponent {
10
+ readonly isDirectionalLightComponent: true;
11
+ constructor();
12
+ /**
13
+ * Sets the direction the light shines from.
14
+ *
15
+ * three takes a directional light's direction from its world position
16
+ * relative to its target, which defaults to the world origin. So this is a
17
+ * direction, not a location: moving the node does not change where the light
18
+ * comes from, and it must never be the zero vector.
19
+ *
20
+ * @param direction - Where the light shines from. Must not be zero-length.
21
+ */
22
+ setDirection(direction: Vector3Like): void;
23
+ }
@@ -0,0 +1,21 @@
1
+ import { Vector3Like } from 'three/webgpu';
2
+ import { DIVELightComponent } from '../LightComponent.ts';
3
+ /**
4
+ * Sky-and-ground light, brighter from above than from below.
5
+ *
6
+ * @module
7
+ */
8
+ export declare class HemisphereLightComponent extends DIVELightComponent {
9
+ readonly isHemisphereLightComponent: true;
10
+ constructor();
11
+ /**
12
+ * Sets which way is "up" for this light.
13
+ *
14
+ * three derives the sky axis from the light's normalised world position, so
15
+ * this is a direction rather than a location -- moving the node does not
16
+ * change it, and it must never be the zero vector.
17
+ *
18
+ * @param direction - The sky direction. Must not be zero-length.
19
+ */
20
+ setDirection(direction: Vector3Like): void;
21
+ }
@@ -1,3 +1,5 @@
1
- export * from './AmbientLight.ts';
2
- export * from './PointLight.ts';
3
- export * from './SceneLight.ts';
1
+ export * from './ambient/AmbientLightComponent.ts';
2
+ export * from './directional/DirectionalLightComponent.ts';
3
+ export * from './hemi/HemisphereLightComponent.ts';
4
+ export * from './LightComponent.ts';
5
+ export * from './point/PointLightComponent.ts';
@@ -0,0 +1,26 @@
1
+ import { Mesh, Color } from 'three/webgpu';
2
+ import { DIVELightComponent } from '../LightComponent.ts';
3
+ /**
4
+ * Light radiating in all directions from the node's position. Casts shadows.
5
+ *
6
+ * Owns the small sphere that makes the light selectable and draggable in the
7
+ * editor. That handle is kept here rather than in a component of its own because
8
+ * it is this light's visual stand-in: it mirrors the light's colour and
9
+ * intensity, and it is already invisible outside the editor by virtue of sitting
10
+ * on the UI layer.
11
+ *
12
+ * @module
13
+ */
14
+ export declare class PointLightComponent extends DIVELightComponent {
15
+ readonly isPointLightComponent: true;
16
+ private _handle;
17
+ private _handleMaterial;
18
+ constructor();
19
+ /**
20
+ * The editor handle standing in for this light.
21
+ */
22
+ get handle(): Mesh;
23
+ setColor(color: Color): void;
24
+ setIntensity(intensity: number): void;
25
+ dispose(): void;
26
+ }
@@ -0,0 +1,133 @@
1
+ import { LineSegments, ColorRepresentation, Vector3Like } from 'three/webgpu';
2
+ import { DIVEComponent } from '../../engine/component/Component.ts';
3
+ /**
4
+ * Whatever a caller identifies one of its lines by.
5
+ *
6
+ * Opaque here: this component never inspects a key, it only compares them. A
7
+ * caller drawing lines to scene objects passes the objects; one drawing an
8
+ * arbitrary set passes numbers or symbols.
9
+ */
10
+ export type DIVELineKey = unknown;
11
+ /**
12
+ * Draws a set of independent line segments.
13
+ *
14
+ * A pure drawing primitive: it knows about points, nothing else. It does not
15
+ * watch the scene, does not care what the lines mean, and never decides when
16
+ * they should change — a caller places lines and removes them. What keeps the
17
+ * lines in sync with something else is that caller's job.
18
+ *
19
+ * All lines share **one** `LineSegments`, so the whole set costs a single draw
20
+ * call no matter how many there are. Each line owns a fixed slot of two vertices
21
+ * in a shared buffer, so adding, moving or hiding one rewrites only that slot and
22
+ * uploads only that range.
23
+ *
24
+ * ### Lines are addressed by the caller's own identity for them
25
+ *
26
+ * There is no line handle to keep. `setLineFor(key, …)` places the line for a
27
+ * key, adding it if there is none yet, so a caller never holds a second piece of
28
+ * bookkeeping beside the thing the line belongs to — which is where handles and
29
+ * their objects used to drift apart. It also means placing and moving are one
30
+ * call, so the two cannot be confused.
31
+ *
32
+ * Coordinates are in the component's own space, which is its owner's space.
33
+ * Passing world-space points would have them transformed a second time by the
34
+ * owner's matrix.
35
+ *
36
+ * @module
37
+ */
38
+ export declare class MultiLineComponent extends DIVEComponent {
39
+ readonly isMultiLineComponent: true;
40
+ private _lines;
41
+ private _geometry;
42
+ private _material;
43
+ private _positions;
44
+ private _distances;
45
+ /**
46
+ * Every line, by the key it was placed under.
47
+ *
48
+ * The single piece of bookkeeping: which keys exist, where each line is
49
+ * drawn, which buffer slot it owns and whether it is visible. Those were four
50
+ * separate containers keyed by a handle, which had to be kept in step with
51
+ * each other and with whatever the caller kept on its own side.
52
+ */
53
+ private _byKey;
54
+ /** Slots freed by removed lines, reused before the buffer grows. */
55
+ private _freeSlots;
56
+ private _capacity;
57
+ /** One past the highest slot ever used, i.e. what has to be drawn. */
58
+ private _highWater;
59
+ constructor();
60
+ /** The single object all lines are drawn by. */
61
+ get lines(): LineSegments;
62
+ /** How many lines currently exist, hidden ones included. */
63
+ get lineCount(): number;
64
+ /**
65
+ * Places the line for a key, adding it if there is none yet.
66
+ *
67
+ * @param key - Whatever the caller identifies this line by.
68
+ * @param start - Where the line begins.
69
+ * @param end - Where the line ends.
70
+ */
71
+ setLineFor(key: DIVELineKey, start: Vector3Like, end: Vector3Like): void;
72
+ /**
73
+ * Removes the line for a key and frees its slot for reuse. Does nothing if
74
+ * there is no such line.
75
+ *
76
+ * @param key - Whatever the caller identifies this line by.
77
+ */
78
+ removeLineFor(key: DIVELineKey): void;
79
+ /** Whether a line is currently drawn for this key. */
80
+ hasLineFor(key: DIVELineKey): boolean;
81
+ /**
82
+ * Shows or hides a single line.
83
+ *
84
+ * A hidden line keeps its slot and is collapsed to zero length, so toggling
85
+ * it back costs one range upload and never reshuffles the buffer.
86
+ *
87
+ * @param key - Whatever the caller identifies this line by.
88
+ * @param visible - Whether it should be drawn.
89
+ */
90
+ setLineVisibleFor(key: DIVELineKey, visible: boolean): void;
91
+ /**
92
+ * Shows or hides the whole set, including lines added later.
93
+ *
94
+ * @param visible - Whether the lines should be drawn.
95
+ */
96
+ setVisible(visible: boolean): void;
97
+ /**
98
+ * @param color - The line colour.
99
+ */
100
+ setColor(color: ColorRepresentation): void;
101
+ /**
102
+ * Sets the dash pattern.
103
+ *
104
+ * @param dashSize - Length of a drawn stretch.
105
+ * @param gapSize - Length of a gap.
106
+ */
107
+ setDashPattern(dashSize: number, gapSize: number): void;
108
+ /**
109
+ * Removes every line.
110
+ *
111
+ * Deliberately not called `clear`: that is `Object3D.clear()`, which removes
112
+ * children, and overriding it with a different meaning would be a trap.
113
+ */
114
+ clearLines(): void;
115
+ /**
116
+ * Takes on how the lines look, never which lines there are.
117
+ *
118
+ * A key is whatever the caller identifies a line by, usually one of its own
119
+ * objects -- copying the set would leave the clone drawing lines to the
120
+ * source's members. Placing lines is the caller's job here as everywhere.
121
+ *
122
+ * @param source - The component to copy from.
123
+ */
124
+ copy(source: this): this;
125
+ dispose(): void;
126
+ private _createAttribute;
127
+ /** Writes a line's endpoints into its slot, or collapses it when hidden. */
128
+ private _writeLine;
129
+ private _collapseSlot;
130
+ /** Uploads just this slot's range instead of the whole buffer. */
131
+ private _markSlotDirty;
132
+ private _grow;
133
+ }
@@ -0,0 +1 @@
1
+ export * from './MultiLineComponent.ts';
@@ -0,0 +1,74 @@
1
+ import { Mesh, MeshStandardMaterial } from 'three/webgpu';
2
+ import { DIVEComponent } from '../../engine/component/Component.ts';
3
+ import { DIVEMaterial } from '../../types/material/DIVEMaterial.ts';
4
+ /**
5
+ * Base for every component that owns a mesh and its material.
6
+ *
7
+ * Holds only what a mesh needs whatever produced it: the mesh, the material, and
8
+ * {@link setMaterial}. Where the geometry comes from is the subclass's business --
9
+ * {@link ModelComponent} loads it, {@link PrimitiveComponent} builds it, and
10
+ * {@link FloorComponent} is one fixed plane. That split exists because those two
11
+ * loading methods used to live here, which meant a primitive and a floor
12
+ * inherited a `setFromGLTF` that would have overwritten their node's transform
13
+ * with a glTF root's.
14
+ *
15
+ * Abstract, because a mesh component that owns no mesh has nothing to offer: the
16
+ * subclass is what puts one there.
17
+ *
18
+ * Contributes its content to the node rather than parenting it, and tracks
19
+ * exactly what it contributed -- so replacing the content leaves the node's child
20
+ * nodes and every other component's content alone.
21
+ *
22
+ * @module
23
+ */
24
+ export declare abstract class MeshComponent extends DIVEComponent {
25
+ readonly isMeshComponent: true;
26
+ protected _mesh: Mesh | null;
27
+ protected _material: MeshStandardMaterial | null;
28
+ /**
29
+ * Whether the material came from {@link setMaterial} rather than from content.
30
+ *
31
+ * A configured material outranks whatever an asset brings, and it has to
32
+ * survive a load that happens afterwards -- `setMaterial` before `setFromURL`
33
+ * is the ordinary case, since the caller has the schema before the file. Only
34
+ * the origin distinguishes the two: a material adopted from a previous load
35
+ * must not be pushed onto the next one.
36
+ */
37
+ protected _materialIsOwn: boolean;
38
+ /** The first mesh found in the content, if any. */
39
+ get mesh(): Mesh | null;
40
+ /** The material shared across the content, if one was set or found. */
41
+ get material(): MeshStandardMaterial | null;
42
+ /**
43
+ * Applies material properties, creating a material if there is none yet.
44
+ *
45
+ * @param material - The properties to apply.
46
+ */
47
+ setMaterial(material: Partial<DIVEMaterial>): void;
48
+ /**
49
+ * Takes on the source's material, if the source configured one itself.
50
+ *
51
+ * Only a material from {@link setMaterial} is copied: one adopted from loaded
52
+ * content belongs to that content, and the clone gets its own when it loads.
53
+ * Copied into a fresh material rather than shared, so disposing either
54
+ * component cannot take the other's material with it.
55
+ *
56
+ * @param source - The component to copy from.
57
+ */
58
+ copy(source: this): this;
59
+ /**
60
+ * Frees everything the content this component contributed is made of.
61
+ *
62
+ * The policy, because releasing GPU memory needs one: a mesh component owns
63
+ * the geometries, materials and textures of what it put into the node. Those
64
+ * are produced per load -- the asset cache holds file bytes, not parsed
65
+ * results -- so nothing here is shared with another component and there is
66
+ * nothing to leave behind for someone else.
67
+ *
68
+ * Collected before anything is freed, and collected in sets: three allows a
69
+ * mesh to carry `Material[]`, one glTF can point several meshes at the same
70
+ * material, and several materials at the same texture. Disposing twice is
71
+ * harmless in three, but counting once makes the intent checkable.
72
+ */
73
+ dispose(): void;
74
+ }
@@ -0,0 +1,36 @@
1
+ import { ColorRepresentation } from 'three/webgpu';
2
+ import { MeshComponent } from '../MeshComponent.ts';
3
+ /**
4
+ * The ground plane.
5
+ *
6
+ * Extends {@link MeshComponent} to reuse the mesh and material handling, but
7
+ * sits on {@link FLOOR_LAYER_MASK} rather than the product layer. That single
8
+ * difference is what keeps a 1000x1000 plane out of every bounding box, out of
9
+ * scene exports and out of picking, while still rendering and receiving shadows.
10
+ *
11
+ * @module
12
+ */
13
+ export declare class FloorComponent extends MeshComponent {
14
+ readonly isFloorComponent: true;
15
+ constructor();
16
+ /** Whether the floor is drawn. */
17
+ get visible(): boolean;
18
+ /**
19
+ * On the plane, which is what three reads when it draws. There is nothing
20
+ * else to set: a component carries no visibility of its own.
21
+ *
22
+ * @param visible - Whether the floor is drawn.
23
+ */
24
+ setVisibility(visible: boolean): void;
25
+ /**
26
+ * @param color - The floor colour.
27
+ */
28
+ setColor(color: ColorRepresentation): void;
29
+ /**
30
+ * The floor's own material never comes from {@link setMaterial}, so the base
31
+ * copies nothing: colour and visibility have to be carried over here.
32
+ *
33
+ * @param source - The component to copy from.
34
+ */
35
+ copy(source: this): this;
36
+ }
@@ -0,0 +1,4 @@
1
+ export * from './MeshComponent.ts';
2
+ export * from './floor/FloorComponent.ts';
3
+ export * from './model/ModelComponent.ts';
4
+ export * from './primitive/PrimitiveComponent.ts';
@@ -0,0 +1,67 @@
1
+ import { AnimationClip, Object3D } from 'three/webgpu';
2
+ import { MeshComponent } from '../MeshComponent.ts';
3
+ /**
4
+ * Geometry loaded from an asset.
5
+ *
6
+ * The only mesh component that fetches anything, which is why the asset loader
7
+ * and {@link setFromGLTF} live here and not on {@link MeshComponent}: a primitive
8
+ * or a floor has nothing to load, and inheriting `setFromGLTF` gave them a method
9
+ * that would have overwritten their node's transform.
10
+ *
11
+ * @module
12
+ */
13
+ export declare class ModelComponent extends MeshComponent {
14
+ readonly isModelComponent: true;
15
+ /**
16
+ * The clips the asset came with.
17
+ *
18
+ * Its own field, not `Object3D.animations`: they belong to the asset, and the
19
+ * mixer takes a root and its clips separately, so nothing needs them to sit
20
+ * on a graph object.
21
+ */
22
+ animations: AnimationClip[];
23
+ /** What {@link setFromURL} last loaded, so a clone can load it again. */
24
+ private _url;
25
+ constructor();
26
+ private _assetLoader;
27
+ private _getAssetLoader;
28
+ /**
29
+ * Loads an asset and takes its content as this component's geometry.
30
+ *
31
+ * Reports the load on itself. Whoever wants to hear about an entity being
32
+ * loaded listens to the component that loads it -- the node has nothing to
33
+ * do with fetching, and a component with no owner yet had nowhere to report
34
+ * before, which silently dropped the event.
35
+ *
36
+ * @param url - The asset to load.
37
+ */
38
+ setFromURL(url: string): Promise<this>;
39
+ /**
40
+ * Replaces the content with a loaded glTF hierarchy.
41
+ *
42
+ * @param gltf - What the loader returned: a glTF *scene*, whose children are
43
+ * the file's root nodes.
44
+ */
45
+ setFromGLTF(gltf: Object3D): this;
46
+ /** The asset {@link setFromURL} last loaded, if any. */
47
+ get url(): string | null;
48
+ /**
49
+ * Carries over what identifies the content, not the content itself.
50
+ *
51
+ * The one component whose state a copy cannot reproduce on its own: a load is
52
+ * asynchronous, and `copy` is not. So the clone comes back with the same
53
+ * {@link url} and clips but no geometry, and the caller finishes it:
54
+ *
55
+ * ```ts
56
+ * const clone = source.clone();
57
+ * if (clone.url) await clone.setFromURL(clone.url);
58
+ * ```
59
+ *
60
+ * Spelled out because the alternative is worse: cloning the loaded hierarchy
61
+ * would share every geometry and material with the source, and either
62
+ * component's `dispose` would then free what the other still draws.
63
+ *
64
+ * @param source - The component to copy from.
65
+ */
66
+ copy(source: this): this;
67
+ }
@@ -0,0 +1,43 @@
1
+ import { MeshComponent } from '../MeshComponent.ts';
2
+ import { DIVEGeometry } from '../../../types/geometry/DIVEGeometry.ts';
3
+ /**
4
+ * Procedurally generated geometry, built from a {@link DIVEGeometry} descriptor.
5
+ *
6
+ * Extends {@link MeshComponent} so material handling is shared -- and so
7
+ * `getComponent(MeshComponent)` finds it, which is what lets one code path apply
8
+ * materials to models and primitives alike.
9
+ *
10
+ * @module
11
+ */
12
+ export declare class PrimitiveComponent extends MeshComponent {
13
+ readonly isPrimitiveComponent: true;
14
+ /**
15
+ * The shape this component was last built from.
16
+ *
17
+ * Kept because the built `BufferGeometry` cannot be handed to a clone -- both
18
+ * would dispose it -- while the descriptor rebuilds it for free.
19
+ */
20
+ private _geometry;
21
+ constructor();
22
+ /** The shape this component was last built from, if any. */
23
+ get geometry(): DIVEGeometry | null;
24
+ /**
25
+ * Rebuilds the geometry from a descriptor.
26
+ *
27
+ * @param geometry - The shape to build.
28
+ */
29
+ setGeometry(geometry: DIVEGeometry): void;
30
+ /**
31
+ * Rebuilds the source's shape, rather than sharing the geometry it built.
32
+ *
33
+ * @param source - The component to copy from.
34
+ */
35
+ copy(source: this): this;
36
+ private _assembleGeometry;
37
+ private _createCylinderGeometry;
38
+ private _createSphereGeometry;
39
+ private _createPyramidGeometry;
40
+ private _createBoxGeometry;
41
+ private _createConeGeometry;
42
+ private _createWallGeometry;
43
+ }
@@ -0,0 +1,58 @@
1
+ import { Color, Sprite, ColorRepresentation } from 'three/webgpu';
2
+ import { DIVEComponent } from '../../engine/component/Component.ts';
3
+ import { DIVENode } from '../../engine/node/Node.ts';
4
+ /**
5
+ * A camera facing text label on a node.
6
+ *
7
+ * The text is rasterized to a canvas and applied to a sprite, so the label always
8
+ * faces the camera while keeping a constant height in world units. `textHeight`
9
+ * is that height, and the width follows from the rasterized aspect ratio.
10
+ *
11
+ * Where the label sits is the node's business, as with every component: position
12
+ * the node, not the sprite. What belongs here is what the label *is* -- its text,
13
+ * its height and its colour.
14
+ *
15
+ * Takes the owner's layer, so a caller decides what the label counts as by setting
16
+ * it on the node before attaching. Layers gate only the object they are set on, so
17
+ * the mask has to reach the sprite itself, which is what this does.
18
+ *
19
+ * @module
20
+ */
21
+ export declare class SpriteTextComponent extends DIVEComponent {
22
+ readonly isSpriteTextComponent: true;
23
+ private _text;
24
+ private _textHeight;
25
+ private _color;
26
+ private _canvas;
27
+ private _texture;
28
+ private _sprite;
29
+ constructor();
30
+ /** The sprite the label is drawn on. */
31
+ get sprite(): Sprite;
32
+ /** The text currently drawn. */
33
+ get text(): string;
34
+ /** The label's height in world units. */
35
+ get textHeight(): number;
36
+ /** The colour the text is rasterized in. */
37
+ get color(): Color;
38
+ /**
39
+ * @param text - What to write.
40
+ */
41
+ setText(text: string): this;
42
+ /**
43
+ * @param textHeight - The label's height in world units.
44
+ */
45
+ setTextHeight(textHeight: number): this;
46
+ /**
47
+ * @param color - The colour to rasterize the text in.
48
+ */
49
+ setColor(color: ColorRepresentation): this;
50
+ protected onAttach(owner: DIVENode): void;
51
+ copy(source: this): this;
52
+ dispose(): void;
53
+ /**
54
+ * Rasterizes the text to the canvas and scales the sprite to the resulting
55
+ * aspect ratio, so the label's height matches its text height in world units.
56
+ */
57
+ private _draw;
58
+ }
@@ -3,3 +3,26 @@ export declare const COORDINATE_LAYER_MASK = 2;
3
3
  export declare const UI_LAYER_MASK = 4;
4
4
  export declare const HELPER_LAYER_MASK = 8;
5
5
  export declare const PRODUCT_LAYER_MASK = 16;
6
+ /**
7
+ * The ground plane.
8
+ *
9
+ * Deliberately separate from `PRODUCT_LAYER_MASK`: the floor has to render and
10
+ * receive shadows, but it must not count towards bounding boxes, scene exports
11
+ * or picking. Keeping it on its own bit makes "does this geometry count?" a
12
+ * plain `mask & PRODUCT_LAYER_MASK` test with no per-class exceptions.
13
+ */
14
+ export declare const FLOOR_LAYER_MASK = 32;
15
+ /**
16
+ * Stands in for an entity that has no geometry of its own.
17
+ *
18
+ * A point light is nothing but a position; the little sphere you can see and
19
+ * click in the editor represents it. Picking a proxy therefore means picking the
20
+ * entity behind it, which is what `findInterface` resolves by walking up.
21
+ *
22
+ * Its own bit, because it sits between two others that both fit badly:
23
+ * `PRODUCT_LAYER_MASK` would make it count towards bounds, snapping and exports,
24
+ * and `UI_LAYER_MASK` is the gizmo — which must never be selectable as an
25
+ * object. `HELPER_LAYER_MASK` is the opposite case again: decoration that is not
26
+ * picked at all.
27
+ */
28
+ export declare const PROXY_LAYER_MASK = 64;
package/build/dive.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var R=Object.defineProperty;var O=(r,i,e)=>i in r?R(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var n=(r,i,e)=>O(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./chunks/FileTypes-DMTSUCcK.cjs"),u=require("./chunks/PerspectiveCamera-DwQUmkDv.cjs"),_=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),s=require("three/webgpu"),y=require("./chunks/findInterface-C6mrvf_t.cjs"),V=require("./chunks/isFileTypeSupported-xoGjHFuz.cjs"),P=require("./chunks/network-error-CdDXil5g.cjs"),w=require("./chunks/parse-error-Dy_EE4rL.cjs"),S=require("./chunks/PovSchema-Co9FznEz.cjs");class m extends s.Object3D{constructor(e,t,o,h,a){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVERadialHandle",this.axis=e,this._color.set(a),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1;const l=new s.TorusGeometry(t,.01,13,48,o);this._lineMaterial=new s.MeshBasicMaterial({color:a,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,this.add(d);const g=new s.TorusGeometry(t,.1,3,48,o),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this.add(this._colliderMesh),this.lookAt(h)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}function p(r,i){const e=(r+"e").split("e");return+(e[0]+"e"+(+e[1]+(i||0)))}function v(r,i=0){const e=p(r,+i);return p(Math.ceil(e),-i)}function H(r,i=0){const e=p(r,+i);return p(Math.floor(e),-i)}function A(r,i=0){if(r<0)return-A(-r,i);const e=p(r,+i);return p(Math.round(e),-i)}function G(r,i,e){return Math.atan2(r.clone().cross(i).dot(e),i.clone().dot(r))}function z(r,i=0){const e=p(r,+i);return p(Math.round(e),-i).toFixed(i)}function L(r,i=0){const e=p(r,+i);return p(Math.trunc(e),-i)}function C(r){return(s.MathUtils.radToDeg(r)+360)%360}function T(r){return s.MathUtils.degToRad(r)}const x={ceilExp:v,floorExp:H,roundExp:A,toFixedExp:z,truncateExp:L,signedAngleTo:G,radToDeg:C,degToRad:T};class Y extends s.Object3D{constructor(e){super();n(this,"children");n(this,"_controller");n(this,"_startRot");this.name="DIVERotateGizmo",this.children=[],this._startRot=null,this._controller=e,this.add(new m("x",1,Math.PI/2,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new m("y",1,-Math.PI/2,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new m("z",1,Math.PI/2,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHandleHover(e,t){this._startRot||this.parent&&this.parent.parent&&(this.parent.parent.onHover("rotate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startRot=t.rotation.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startRot||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragCurrent.clone().sub(this.parent.parent.position).normalize(),h=t.dragStart.clone().sub(this.parent.parent.position).normalize(),a=x.signedAngleTo(h,o,e.forwardVector),l=new s.Euler(this._startRot.x+e.forwardVector.x*a,this._startRot.y+e.forwardVector.y*a,this._startRot.z+e.forwardVector.z*a);this.parent.parent.onChange(void 0,l)}onHandleDragEnd(e){this._startRot=null,this.handleHighlight(e.axis,!1,!1)}}class D extends s.Object3D{constructor(e,t,o,h){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVEAxisHandle",this.axis=e,this._color.set(h),this._colorHover=this._color.clone().multiplyScalar(2),this._highlight=!1,this._hovered=!1;const a=new s.CylinderGeometry(.01,.01,t,13);this._lineMaterial=new s.MeshBasicMaterial({color:h,depthTest:!1,depthWrite:!1});const l=new s.Mesh(a,this._lineMaterial);l.layers.mask=u.UI_LAYER_MASK,l.renderOrder=1/0,l.rotateX(Math.PI/2),l.translateY(t/2),this.add(l);const d=new s.CylinderGeometry(.1,.1,t,3),g=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(d,g),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}class j extends s.Object3D{constructor(e){super();n(this,"_controller");n(this,"children");n(this,"_startPos");this.name="DIVETranslateGizmo",this.children=[],this._startPos=null,this._controller=e,this.add(new D("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new D("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new D("z",1,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHandleHover(e,t){this._startPos||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startPos=t.position.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startPos||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(this._startPos.clone().add(o))}onHandleDragEnd(e){this._startPos=null,this.handleHighlight(e.axis,!1,!1)}}class M extends s.Object3D{constructor(e,t,o,h,a=.05){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");n(this,"_box");n(this,"_boxSize");this.name="DIVEScaleHandle",this.axis=e,this._color.set(h),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1,this._boxSize=a;const l=new s.CylinderGeometry(.01,.01,t-a/2,13);this._lineMaterial=new s.MeshBasicMaterial({color:h,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,d.rotateX(Math.PI/2),d.translateY(t/2-a/4),this.add(d),this._box=new s.Mesh(new s.BoxGeometry(a,a,a),this._lineMaterial),this._box.layers.mask=u.UI_LAYER_MASK,this._box.renderOrder=1/0,this._box.rotateX(Math.PI/2),this._box.translateY(t-a/2),this._box.rotateZ(o.x*Math.PI/2),this._box.rotateX(o.z*Math.PI/2),this.add(this._box);const g=new s.CylinderGeometry(.1,.1,t+a/2,3),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}update(e){this._box.scale.copy(new s.Vector3(1,1,1).sub(this.forwardVector).add(e.clone().multiply(this.forwardVector)))}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHoverAxis(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHoverAxis(this,!1)}onDragStart(){this.parent&&this.parent.onAxisDragStart(this)}onDrag(e){this.parent&&this.parent.onAxisDrag(this,e)}onDragEnd(){this.parent&&this.parent.onAxisDragEnd(this)}}class F extends s.Object3D{constructor(e){super();n(this,"isHoverable",!0);n(this,"children");n(this,"_controller");n(this,"_startScale");this.name="DIVEScaleGizmo",this.children=[],this._startScale=null,this._controller=e,this.add(new M("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new M("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new M("z",1,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}update(e){this.children.forEach(t=>{t.update(e)})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHoverAxis(e,t){this._startScale||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onAxisDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startScale=t.scale.clone(),this.handleHighlight(e.axis,!0,!0))}onAxisDrag(e,t){if(!this._startScale||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(void 0,void 0,this._startScale.clone().add(o))}onAxisDragEnd(e){this._startScale=null,this.handleHighlight(e.axis,!1,!1)}}class U extends s.Object3D{constructor(){super();n(this,"_meshX");n(this,"_meshY");n(this,"_meshZ");this.name="DIVEGizmoPlane";const e=new s.MeshBasicMaterial({transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1,side:2}),t=new s.PlaneGeometry(100,100,2,2),o=e.clone();o.color.set(16711680),this._meshX=new s.Mesh(t,o),this._meshX.layers.mask=u.UI_LAYER_MASK,this._meshX.rotateY(Math.PI/2);const h=new s.PlaneGeometry(100,100,2,2),a=e.clone();a.color.set(65280),this._meshY=new s.Mesh(h,a),this._meshY.layers.mask=u.UI_LAYER_MASK,this._meshY.rotateX(-Math.PI/2);const l=new s.PlaneGeometry(100,100,2,2),d=e.clone();d.color.set(255),this._meshZ=new s.Mesh(l,d),this._meshZ.layers.mask=u.UI_LAYER_MASK}get XPlane(){return this._meshX}get YPlane(){return this._meshY}get ZPlane(){return this._meshZ}assemble(e,t){if(this.clear(),e==="translate"||e==="scale")switch(t){case"x":this.add(this._meshY),this.add(this._meshZ);break;case"y":this.add(this._meshX),this.add(this._meshZ);break;case"z":this.add(this._meshX),this.add(this._meshY);break}else if(e==="rotate")switch(t){case"x":this.add(this._meshX);break;case"y":this.add(this._meshY);break;case"z":this.add(this._meshZ);break}}}class N extends s.Object3D{constructor(e){super();n(this,"_mode");n(this,"_gizmoNode");n(this,"_translateGizmo");n(this,"_rotateGizmo");n(this,"_scaleGizmo");n(this,"_gizmoPlane");n(this,"_object");this.name="DIVEGizmo",e.addEventListener("change",()=>{const t=e.getDistance()/2.5;this.scale.set(t,t,t)}),this._mode="translate",this._gizmoNode=new s.Object3D,this.add(this._gizmoNode),this._translateGizmo=new j(e),this._rotateGizmo=new Y(e),this._scaleGizmo=new F(e),this._gizmoPlane=new U,this._gizmoPlane.visible=!1,this._object=null}get mode(){return this._mode}set mode(e){this._mode=e,this.assemble()}set debug(e){this._translateGizmo.debug=e,this._rotateGizmo.debug=e,this._scaleGizmo.debug=e}get gizmoNode(){return this._gizmoNode}get gizmoPlane(){return this._gizmoPlane}get object(){return this._object}attach(e){return this._object=e,this.assemble(),this}detach(){return this._object=null,this.assemble(),this}onHover(e,t,o){o&&this._gizmoPlane.assemble(e,t)}onChange(e,t,o){this.object!==null&&(e&&(this.position.copy(e),this.object.position.copy(e)),t&&this.object.rotation.copy(t),o&&(this.object.scale.copy(o),this._scaleGizmo.update(o)))}assemble(){this._gizmoNode.clear(),this._gizmoPlane.clear(),this._translateGizmo.reset(),this._rotateGizmo.reset(),this._scaleGizmo.reset(),this.object!==null&&(this._mode==="translate"&&this._gizmoNode.add(this._translateGizmo),this._mode==="rotate"&&this._gizmoNode.add(this._rotateGizmo),this._mode==="scale"&&this._gizmoNode.add(this._scaleGizmo),this.add(this._gizmoPlane))}}class K{constructor(){n(this,"isMovable",!0)}}class X{constructor(){n(this,"isSelectable",!0)}}function q(r,i){return i.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(o=>{if(o==="constructor")return;const h=Object.getOwnPropertyDescriptor(e.prototype,o);Object.defineProperty(r.prototype,o,h)});const t=new e;Object.getOwnPropertyNames(t).forEach(o=>{const h=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r.prototype,o,h)})}),r}function f(r,i=new WeakMap){if(r===null||typeof r!="object")return r;if(i.has(r))return i.get(r);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const a=[];i.set(r,a);for(let l=0;l<r.length;l++)a[l]=f(r[l],i);return a}if(r instanceof Map){const a=new Map;i.set(r,a);for(const[l,d]of r)a.set(f(l,i),f(d,i));return a}if(r instanceof Set){const a=new Set;i.set(r,a);for(const l of r)a.add(f(l,i));return a}const e=r;if(typeof e.clone=="function"){const a=e.clone();return i.set(r,a),a}const t=Object.create(Object.getPrototypeOf(r));i.set(r,t);const o=Object.getOwnPropertyNames(r);for(const a of o){const l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}const h=Object.getOwnPropertySymbols(r);for(const a of h){const l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}return t}const I=(r,i)=>{if(Object.keys(r).length===0&&Object.keys(i).length===0)return{};if(typeof r!="object"||typeof i!="object")return i;let e={};return Object.keys(i).forEach(t=>{if(!Object.keys(r).includes(t)){e={...e,[t]:i[t]};return}if(Array.isArray(i[t])){if(!Array.isArray(r[t])){e={...e,[t]:i[t]};return}const o=r[t],h=i[t];if(o.length===0&&h.length===0){e={...e};return}if(o.length!==h.length){e={...e,[t]:i[t]};return}const a=[];if(h.forEach((l,d)=>{const g=I(o[d],h[d]);Object.keys(g).length&&a.push(h[d])}),Object.keys(a).length){e={...e,[t]:a};return}return}if(typeof i[t]=="object"){if(typeof r[t]!="object"){e={...e,[t]:i[t]};return}const o=I(r[t],i[t]);if(Object.keys(o).length){e={...e,[t]:o};return}}r[t]!==i[t]&&(e={...e,[t]:i[t]})}),e};function B(r){return c.SUPPORTED_MIME_TYPES.includes(r.toLowerCase())}function b(r){return r.toLowerCase()in c.FILE_TYPES}function Z(r){return b(V.getFileTypeFromUri(r))}function k(r){return r.entityType==="group"}function Q(r){return r.entityType==="light"}function W(r){return r.entityType==="primitive"}exports.BoundingBox=c.BoundingBox;exports.DIVE=c.DIVE;exports.DIVEAbortablePromise=c.DIVEAbortablePromise;exports.DIVEAmbientLight=c.DIVEAmbientLight;exports.DIVECanvasLifecycleManager=c.DIVECanvasLifecycleManager;exports.DIVEClock=c.DIVEClock;exports.DIVEDefaultSettings=c.DIVEDefaultSettings;exports.DIVEDeferredPromise=c.DIVEDeferredPromise;exports.DIVEEnvironment=c.DIVEEnvironment;exports.DIVEEnvironmentDefaultSettings=c.DIVEEnvironmentDefaultSettings;exports.DIVEFloor=c.DIVEFloor;exports.DIVEGrid=c.DIVEGrid;exports.DIVEGroup=c.DIVEGroup;exports.DIVEModel=c.DIVEModel;exports.DIVENode=c.DIVENode;exports.DIVEPointLight=c.DIVEPointLight;exports.DIVEPrimitive=c.DIVEPrimitive;exports.DIVERenderer=c.DIVERenderer;exports.DIVERendererDefaultSettings=c.DIVERendererDefaultSettings;exports.DIVERoot=c.DIVERoot;exports.DIVEScene=c.DIVEScene;exports.DIVESceneDefaultSettings=c.DIVESceneDefaultSettings;exports.DIVESceneLight=c.DIVESceneLight;exports.DIVEView=c.DIVEView;exports.FILE_TYPES=c.FILE_TYPES;exports.GRID_MAJOR_LINE_COLOR=c.GRID_MAJOR_LINE_COLOR;exports.GRID_MINOR_LINE_COLOR=c.GRID_MINOR_LINE_COLOR;exports.SUPPORTED_FILE_TYPES=c.SUPPORTED_FILE_TYPES;exports.SUPPORTED_MIME_TYPES=c.SUPPORTED_MIME_TYPES;exports.findSceneRecursive=c.findSceneRecursive;exports.COORDINATE_LAYER_MASK=u.COORDINATE_LAYER_MASK;exports.DEFAULT_LAYER_MASK=u.DEFAULT_LAYER_MASK;exports.DIVEPerspectiveCamera=u.DIVEPerspectiveCamera;exports.DIVEPerspectiveCameraDefaultSettings=u.DIVEPerspectiveCameraDefaultSettings;exports.HELPER_LAYER_MASK=u.HELPER_LAYER_MASK;exports.PRODUCT_LAYER_MASK=u.PRODUCT_LAYER_MASK;exports.UI_LAYER_MASK=u.UI_LAYER_MASK;exports.AxesColorBlue=_.AxesColorBlue;exports.AxesColorBlueLetter=_.AxesColorBlueLetter;exports.AxesColorGreen=_.AxesColorGreen;exports.AxesColorGreenLetter=_.AxesColorGreenLetter;exports.AxesColorRed=_.AxesColorRed;exports.AxesColorRedLetter=_.AxesColorRedLetter;exports.findInterface=y.findInterface;exports.implementsInterface=y.implementsInterface;exports.getFileTypeFromUri=V.getFileTypeFromUri;exports.isFileTypeSupported=V.isFileTypeSupported;exports.FileContentError=P.FileContentError;exports.NetworkError=P.NetworkError;exports.FileTypeError=w.FileTypeError;exports.ParseError=w.ParseError;exports.isModelSchema=S.isModelSchema;exports.isPovSchema=S.isPovSchema;exports.DIVEGizmo=N;exports.DIVEMath=x;exports.DIVEMovable=K;exports.DIVESelectable=X;exports.applyMixins=q;exports.deepClone=f;exports.getObjectDelta=I;exports.isFileExtensionSupported=b;exports.isGroupSchema=k;exports.isLightSchema=Q;exports.isMimeTypeSupported=B;exports.isPrimitiveSchema=W;exports.isURIFileExtensionSupported=Z;
1
+ "use strict";var M=Object.defineProperty;var P=(e,t,n)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var I=(e,t,n)=>P(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/FileTypes-gD_1MonW.cjs"),f=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),E=require("./chunks/contributesToBounds-C1mva__U.cjs"),m=require("./chunks/detachTransformControls-2XQrpLN-.cjs"),L=require("./chunks/ModelComponent-Cj3ff6nL.cjs"),V=require("./chunks/SpriteTextComponent-ByefJLeU.cjs"),_=require("./chunks/collectAnimations-C3HfZHte.cjs"),d=require("./chunks/isVisibleInHierarchy-D9JcLqR5.cjs"),D=require("./chunks/isFileExtensionSupported-RvlnH2dr.cjs"),g=require("three/webgpu"),A=require("./chunks/network-error-CdDXil5g.cjs"),O=require("./chunks/parse-error-Dy_EE4rL.cjs");class h{constructor(){I(this,"isMovable",!0)}}class y{constructor(){I(this,"isSelectable",!0)}}function T(e,t){return t.forEach(n=>{Object.getOwnPropertyNames(n.prototype).forEach(c=>{if(c==="constructor")return;const l=Object.getOwnPropertyDescriptor(n.prototype,c);Object.defineProperty(e.prototype,c,l)});const r=new n;Object.getOwnPropertyNames(r).forEach(c=>{const l=Object.getOwnPropertyDescriptor(r,c);Object.defineProperty(e.prototype,c,l)})}),e}function a(e,t=new WeakMap){if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e)){const i=[];t.set(e,i);for(let s=0;s<e.length;s++)i[s]=a(e[s],t);return i}if(e instanceof Map){const i=new Map;t.set(e,i);for(const[s,u]of e)i.set(a(s,t),a(u,t));return i}if(e instanceof Set){const i=new Set;t.set(e,i);for(const s of e)i.add(a(s,t));return i}const n=e;if(typeof n.clone=="function"){const i=n.clone();return t.set(e,i),i}const r=Object.create(Object.getPrototypeOf(e));t.set(e,r);const c=Object.getOwnPropertyNames(e);for(const i of c){const s=Object.getOwnPropertyDescriptor(e,i);if(s)if(s.value!==void 0){const u=a(s.value,t);Object.defineProperty(r,i,{...s,value:u})}else Object.defineProperty(r,i,s)}const l=Object.getOwnPropertySymbols(e);for(const i of l){const s=Object.getOwnPropertyDescriptor(e,i);if(s)if(s.value!==void 0){const u=a(s.value,t);Object.defineProperty(r,i,{...s,value:u})}else Object.defineProperty(r,i,s)}return r}const C=(e,t)=>{if(Object.keys(e).length===0&&Object.keys(t).length===0)return{};if(typeof e!="object"||typeof t!="object")return t;let n={};return Object.keys(t).forEach(r=>{if(!Object.keys(e).includes(r)){n={...n,[r]:t[r]};return}if(Array.isArray(t[r])){if(!Array.isArray(e[r])){n={...n,[r]:t[r]};return}const c=e[r],l=t[r];if(c.length===0&&l.length===0){n={...n};return}if(c.length!==l.length){n={...n,[r]:t[r]};return}const i=[];if(l.forEach((s,u)=>{const R=C(c[u],l[u]);Object.keys(R).length&&i.push(l[u])}),Object.keys(i).length){n={...n,[r]:i};return}return}if(typeof t[r]=="object"){if(typeof e[r]!="object"){n={...n,[r]:t[r]};return}const c=C(e[r],t[r]);if(Object.keys(c).length){n={...n,[r]:c};return}}e[r]!==t[r]&&(n={...n,[r]:t[r]})}),n};function x(e){return o.SUPPORTED_MIME_TYPES.includes(e.toLowerCase())}function F(e){return D.isFileExtensionSupported(D.getFileTypeFromUri(e))}function p(e,t){const n=(e+"e").split("e");return+(n[0]+"e"+(+n[1]+(t||0)))}function Y(e,t=0){const n=p(e,+t);return p(Math.ceil(n),-t)}function w(e,t=0){const n=p(e,+t);return p(Math.floor(n),-t)}function S(e,t=0){if(e<0)return-S(-e,t);const n=p(e,+t);return p(Math.round(n),-t)}function B(e,t,n){return Math.atan2(e.clone().cross(t).dot(n),t.clone().dot(e))}function U(e,t=0){const n=p(e,+t);return p(Math.round(n),-t).toFixed(t)}function b(e,t=0){const n=p(e,+t);return p(Math.trunc(n),-t)}function N(e){return(g.MathUtils.radToDeg(e)+360)%360}function K(e){return g.MathUtils.degToRad(e)}const v={ceilExp:Y,floorExp:w,roundExp:S,toFixedExp:U,truncateExp:b,signedAngleTo:B,radToDeg:N,degToRad:K};exports.BoundingBox=o.BoundingBox;exports.BoundingBoxComponent=o.BoundingBoxComponent;exports.DIVE=o.DIVE;exports.DIVEAbortablePromise=o.DIVEAbortablePromise;exports.DIVECameraComponent=o.DIVECameraComponent;exports.DIVECanvasLifecycleManager=o.DIVECanvasLifecycleManager;exports.DIVEClock=o.DIVEClock;exports.DIVEComponent=o.DIVEComponent;exports.DIVEDefaultSettings=o.DIVEDefaultSettings;exports.DIVEDeferredPromise=o.DIVEDeferredPromise;exports.DIVEEnvironment=o.DIVEEnvironment;exports.DIVEEnvironmentDefaultSettings=o.DIVEEnvironmentDefaultSettings;exports.DIVELightComponent=o.DIVELightComponent;exports.DIVENode=o.DIVENode;exports.DIVEPerspectiveCameraDefaultSettings=o.DIVEPerspectiveCameraDefaultSettings;exports.DIVERenderer=o.DIVERenderer;exports.DIVERendererDefaultSettings=o.DIVERendererDefaultSettings;exports.DIVERoot=o.DIVERoot;exports.DIVEScene=o.DIVEScene;exports.DIVESceneDefaultSettings=o.DIVESceneDefaultSettings;exports.DIVEView=o.DIVEView;exports.DirectionalLightComponent=o.DirectionalLightComponent;exports.FILE_TYPES=o.FILE_TYPES;exports.FloorComponent=o.FloorComponent;exports.GRID_MAJOR_LINE_COLOR=o.GRID_MAJOR_LINE_COLOR;exports.GRID_MINOR_LINE_COLOR=o.GRID_MINOR_LINE_COLOR;exports.GridComponent=o.GridComponent;exports.HemisphereLightComponent=o.HemisphereLightComponent;exports.MeshComponent=o.MeshComponent;exports.MultiLineComponent=o.MultiLineComponent;exports.PerspectiveCameraComponent=o.PerspectiveCameraComponent;exports.SUPPORTED_FILE_TYPES=o.SUPPORTED_FILE_TYPES;exports.SUPPORTED_MIME_TYPES=o.SUPPORTED_MIME_TYPES;exports.computeProductBounds=o.computeProductBounds;exports.contributedBy=o.contributedBy;exports.disposeComponents=o.disposeComponents;exports.findComponent=o.findComponent;exports.findSceneRecursive=o.findSceneRecursive;exports.isDIVEComponent=o.isDIVEComponent;exports.AxesColorBlue=f.AxesColorBlue;exports.AxesColorBlueLetter=f.AxesColorBlueLetter;exports.AxesColorGreen=f.AxesColorGreen;exports.AxesColorGreenLetter=f.AxesColorGreenLetter;exports.AxesColorRed=f.AxesColorRed;exports.AxesColorRedLetter=f.AxesColorRedLetter;exports.COORDINATE_LAYER_MASK=E.COORDINATE_LAYER_MASK;exports.DEFAULT_LAYER_MASK=E.DEFAULT_LAYER_MASK;exports.FLOOR_LAYER_MASK=E.FLOOR_LAYER_MASK;exports.HELPER_LAYER_MASK=E.HELPER_LAYER_MASK;exports.PRODUCT_LAYER_MASK=E.PRODUCT_LAYER_MASK;exports.PROXY_LAYER_MASK=E.PROXY_LAYER_MASK;exports.UI_LAYER_MASK=E.UI_LAYER_MASK;exports.contributesToBounds=E.contributesToBounds;exports.AmbientLightComponent=m.AmbientLightComponent;exports.PointLightComponent=m.PointLightComponent;exports.PrimitiveComponent=m.PrimitiveComponent;exports.detachTransformControls=m.detachTransformControls;exports.ModelComponent=L.ModelComponent;exports.SpriteTextComponent=V.SpriteTextComponent;exports.collectAnimations=_.collectAnimations;exports.findInterface=d.findInterface;exports.implementsInterface=d.implementsInterface;exports.isVisibleInHierarchy=d.isVisibleInHierarchy;exports.getFileTypeFromUri=D.getFileTypeFromUri;exports.isFileExtensionSupported=D.isFileExtensionSupported;exports.FileContentError=A.FileContentError;exports.NetworkError=A.NetworkError;exports.FileTypeError=O.FileTypeError;exports.ParseError=O.ParseError;exports.DIVEMath=v;exports.DIVEMovable=h;exports.DIVESelectable=y;exports.applyMixins=T;exports.deepClone=a;exports.getObjectDelta=C;exports.isMimeTypeSupported=x;exports.isURIFileExtensionSupported=F;