@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
@@ -1,58 +1,60 @@
1
- var g = Object.defineProperty;
2
- var p = (c, t, e) => t in c ? g(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
3
- var a = (c, t, e) => p(c, typeof t != "symbol" ? t + "" : t, e);
4
- import { RenderTarget as y, SRGBColorSpace as w } from "three/webgpu";
5
- import { D as b } from "../../chunks/PerspectiveCamera-B5TvUzTa.mjs";
6
- class T {
7
- constructor(t, e, r) {
8
- a(this, "_renderer");
9
- a(this, "_scene");
10
- a(this, "_controller");
11
- this._renderer = t, this._scene = e, this._controller = r;
1
+ var l = Object.defineProperty;
2
+ var p = (a, t, r) => t in a ? l(a, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[t] = r;
3
+ var h = (a, t, r) => p(a, typeof t != "symbol" ? t + "" : t, r);
4
+ import { RenderTarget as w, SRGBColorSpace as y } from "three/webgpu";
5
+ import { D as C } from "../../chunks/FileTypes-DGSsi-AX.mjs";
6
+ import "three/examples/jsm/loaders/HDRLoader.js";
7
+ import "three/tsl";
8
+ class M {
9
+ constructor(t, r, e) {
10
+ h(this, "_renderer");
11
+ h(this, "_scene");
12
+ h(this, "_controller");
13
+ this._renderer = t, this._scene = r, this._controller = e;
12
14
  }
13
15
  async generateMedia(t) {
14
- const { position: e, target: r, resolution: i } = t, { width: o, height: s } = i, h = this._controller.object.position.clone(), d = this._controller.object.quaternion.clone(), l = this._controller.target.clone(), n = this._renderer.canvas.clientWidth || o, _ = this._renderer.canvas.clientHeight || s;
16
+ const { position: r, target: e, resolution: i } = t, { width: o, height: s } = i, d = this._controller.object.owner.position.clone(), n = this._controller.target.clone(), _ = this._renderer.canvas.clientWidth || o, g = this._renderer.canvas.clientHeight || s;
15
17
  try {
16
- return "onResize" in this._controller.object && this._controller.object.onResize(o, s), this._controller.object.position.copy(e), this._controller.target.copy(r), this._controller.update(), (await this.drawCanvas(void 0, i)).toDataURL();
18
+ return this._controller.object.onResize(o, s), this._controller.object.owner.position.copy(r), this._controller.target.copy(e), this._controller.update(), (await this.drawCanvas(void 0, i)).toDataURL();
17
19
  } finally {
18
- this._controller.object.position.copy(h), this._controller.object.quaternion.copy(d), this._controller.target.copy(l), this._controller.update(), "onResize" in this._controller.object && this._controller.object.onResize(n, _);
20
+ this._controller.object.owner.position.copy(d), this._controller.target.copy(n), this._controller.update(), this._controller.object.onResize(_, g);
19
21
  }
20
22
  }
21
- async drawCanvas(t, e) {
23
+ async drawCanvas(t, r) {
22
24
  await this._renderer.initAsync();
23
- const r = this._renderer.webgpurenderer, i = Math.max(
25
+ const e = this._renderer.webgpurenderer, i = Math.max(
24
26
  1,
25
- (e == null ? void 0 : e.width) ?? (t == null ? void 0 : t.width) ?? (t == null ? void 0 : t.clientWidth) ?? this._renderer.canvas.clientWidth
27
+ (r == null ? void 0 : r.width) ?? (t == null ? void 0 : t.width) ?? (t == null ? void 0 : t.clientWidth) ?? this._renderer.canvas.clientWidth
26
28
  ), o = Math.max(
27
29
  1,
28
- (e == null ? void 0 : e.height) ?? (t == null ? void 0 : t.height) ?? (t == null ? void 0 : t.clientHeight) ?? this._renderer.canvas.clientHeight
29
- ), s = new y(i, o, {
30
- colorSpace: w
31
- }), h = r.getRenderTarget(), d = this._controller.object.layers.mask;
30
+ (r == null ? void 0 : r.height) ?? (t == null ? void 0 : t.height) ?? (t == null ? void 0 : t.clientHeight) ?? this._renderer.canvas.clientHeight
31
+ ), s = new w(i, o, {
32
+ colorSpace: y
33
+ }), d = e.getRenderTarget(), n = this._controller.object.camera, _ = n.layers.mask;
32
34
  try {
33
- r.setRenderTarget(s), this._controller.object.layers.mask = b.LIVE_VIEW_LAYER_MASK, r.render(this._scene, this._controller.object);
34
- const l = await r.readRenderTargetPixelsAsync(
35
+ e.setRenderTarget(s), n.layers.mask = C.LIVE_VIEW_LAYER_MASK, e.render(this._scene, n);
36
+ const g = await e.readRenderTargetPixelsAsync(
35
37
  s,
36
38
  0,
37
39
  0,
38
40
  i,
39
41
  o
40
- ), n = t ?? document.createElement("canvas");
41
- return n.width = i, n.height = o, this._writePixelsToCanvas(n, l, i, o), n;
42
+ ), c = t ?? document.createElement("canvas");
43
+ return c.width = i, c.height = o, this._writePixelsToCanvas(c, g, i, o), c;
42
44
  } finally {
43
- this._controller.object.layers.mask = d, r.setRenderTarget(h), s.dispose();
45
+ n.layers.mask = _, e.setRenderTarget(d), s.dispose();
44
46
  }
45
47
  }
46
- _writePixelsToCanvas(t, e, r, i) {
48
+ _writePixelsToCanvas(t, r, e, i) {
47
49
  const o = t.getContext("2d");
48
50
  if (!o)
49
51
  throw new Error(
50
52
  "MediaCreator.drawCanvas: 2D canvas context is not available."
51
53
  );
52
- const s = o.createImageData(r, i);
53
- s.data.set(new Uint8ClampedArray(Array.from(e))), o.putImageData(s, 0, 0);
54
+ const s = o.createImageData(e, i);
55
+ s.data.set(new Uint8ClampedArray(Array.from(r))), o.putImageData(s, 0, 0);
54
56
  }
55
57
  }
56
58
  export {
57
- T as MediaCreator
59
+ M as MediaCreator
58
60
  };
@@ -1,5 +1,4 @@
1
- import { DIVEScene } from '../../../engine/scene/Scene.ts';
2
- import { DIVERenderer } from '../../../engine/renderer/Renderer.ts';
1
+ import { DIVEScene, DIVERenderer } from '../../../index.ts';
3
2
  import { OrbitController } from '../../orbitcontroller/index.ts';
4
3
  import { MediaGenerationByPosition, MediaGenerationResolution } from '../types/index.ts';
5
4
  /**
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-DMTSUCcK.cjs");exports.OrbitController=t.OrbitController;exports.OrbitControllerDefaultSettings=t.OrbitControllerDefaultSettings;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/OrbitController-DFPcXvlO.cjs");exports.OrbitController=t.OrbitController;exports.OrbitControllerDefaultSettings=t.OrbitControllerDefaultSettings;
@@ -1 +1,2 @@
1
1
  export * from './src/OrbitController.ts';
2
+ export * from './types/index.ts';
@@ -1,4 +1,4 @@
1
- import { O as o, a as e } from "../../chunks/FileTypes-DYtXCJQV.mjs";
1
+ import { O as o, a as e } from "../../chunks/OrbitController-DLEyTvUt.mjs";
2
2
  export {
3
3
  o as OrbitController,
4
4
  e as OrbitControllerDefaultSettings
@@ -1,5 +1,5 @@
1
- import { EventDispatcher, MOUSE, Object3D, OrthographicCamera, TOUCH, Vector3, Vector3Like } from 'three/webgpu';
2
- import { DIVEPerspectiveCamera, DIVETicker, BoundingBox } from '../../../index.ts';
1
+ import { EventDispatcher, MOUSE, Sphere, TOUCH, Vector3, Vector3Like } from 'three/webgpu';
2
+ import { DIVENode, DIVETicker, DIVECameraComponent } from '../../../index.ts';
3
3
  import { OrbitControllerState } from '../types/index.ts';
4
4
  export type OrbitControllerSettings = {
5
5
  enableDamping?: boolean;
@@ -57,7 +57,21 @@ type EventMap = {
57
57
  };
58
58
  export declare class OrbitController extends EventDispatcher<EventMap> implements DIVETicker {
59
59
  static readonly DEFAULT_ZOOM_FACTOR = 1;
60
- object: DIVEPerspectiveCamera | OrthographicCamera;
60
+ /**
61
+ * The camera component this controller drives.
62
+ *
63
+ * The component rather than the camera: `setCameraLayer` and `onResize` live
64
+ * there, and handing out the bare camera meant every caller had to search its
65
+ * way back. What orbiting moves is `object.owner`, the node it sits on.
66
+ */
67
+ object: DIVECameraComponent;
68
+ /**
69
+ * The camera, narrowed to the two kinds whose projection this can pan.
70
+ *
71
+ * `DIVECameraComponent` types its camera as the base `Camera`, which has no
72
+ * `zoom` or `fov`; the branches below narrow it further.
73
+ */
74
+ private get _camera();
61
75
  get domElement(): HTMLCanvasElement;
62
76
  domElements: HTMLCanvasElement[];
63
77
  enabled: boolean;
@@ -125,7 +139,7 @@ export declare class OrbitController extends EventDispatcher<EventMap> implement
125
139
  private readonly lastPosition;
126
140
  private readonly lastQuaternion;
127
141
  private readonly lastTarget;
128
- constructor(camera: DIVEPerspectiveCamera | OrthographicCamera, domElements: HTMLCanvasElement | HTMLCanvasElement[], settings?: OrbitControllerSettings);
142
+ constructor(cameraComponent: DIVECameraComponent, domElements: HTMLCanvasElement | HTMLCanvasElement[], settings?: OrbitControllerSettings);
129
143
  tick(): void;
130
144
  getPolarAngle(): number;
131
145
  getAzimuthalAngle(): number;
@@ -137,11 +151,30 @@ export declare class OrbitController extends EventDispatcher<EventMap> implement
137
151
  addDomElements(...domElements: HTMLCanvasElement[]): void;
138
152
  removeDomElements(...domElements: HTMLCanvasElement[]): void;
139
153
  setDomElements(...domElements: HTMLCanvasElement[]): void;
140
- computeEncompassingView(bb: BoundingBox, padding?: number): {
154
+ /**
155
+ * Where to put the camera so a sphere fills the view.
156
+ *
157
+ * Takes a `Sphere` rather than a bounding box: framing needs a centre and a
158
+ * radius, and nothing else. Build one with `new BoundingBox().enclose(...)`,
159
+ * or read `sphere` off a `BoundingBoxComponent` that already measures a node.
160
+ *
161
+ * @param sphere - What to frame, in world space.
162
+ * @param padding - Extra distance as a fraction of the fitted one.
163
+ */
164
+ computeEncompassingView(sphere: Sphere, padding?: number): {
141
165
  position: Vector3Like;
142
166
  target: Vector3Like;
143
167
  };
144
- focusObject(object: Object3D, padding?: number): void;
168
+ /**
169
+ * Puts the camera where the whole node fits in the view.
170
+ *
171
+ * One node, not a list: a node already is the handle for everything below it,
172
+ * so anything worth framing together belongs under a common parent.
173
+ *
174
+ * @param node - What to frame.
175
+ * @param padding - Extra distance as a fraction of the fitted one.
176
+ */
177
+ focusObject(node: DIVENode, padding?: number): void;
145
178
  zoomIn(by?: number): void;
146
179
  zoomOut(by?: number): void;
147
180
  getState(): OrbitControllerState;
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var c=(s,r,e)=>r in s?p(s,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[r]=e;var o=(s,r,e)=>c(s,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("three/webgpu");require("../../chunks/FileTypes-DMTSUCcK.cjs");const h=require("../../chunks/PerspectiveCamera-DwQUmkDv.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const n=require("../../chunks/AxisHelperColors-BrGqktN5.cjs"),_=require("three-spritetext");class l extends t.Object3D{constructor(){super();o(this,"_axesHelper");this._axesHelper=new t.AxesHelper(.5),this._axesHelper.layers.mask=h.COORDINATE_LAYER_MASK,this._axesHelper.material.depthTest=!1,this._axesHelper.position.set(0,0,-1),this._axesHelper.setColors(new t.Color(n.AxesColorRed),new t.Color(n.AxesColorGreen),new t.Color(n.AxesColorBlue));const e=new _("X",.2,n.AxesColorRedLetter),i=new _("Y",.2,n.AxesColorGreenLetter),a=new _("Z",.2,n.AxesColorBlueLetter);e.layers.mask=h.COORDINATE_LAYER_MASK,i.layers.mask=h.COORDINATE_LAYER_MASK,a.layers.mask=h.COORDINATE_LAYER_MASK,e.position.set(.7,0,0),i.position.set(0,.7,0),a.position.set(0,0,.7),this._axesHelper.add(e),this._axesHelper.add(i),this._axesHelper.add(a),this.add(this._axesHelper)}setFromCameraMatrix(e){this._axesHelper.rotation.setFromRotationMatrix(new t.Matrix4().extractRotation(e).invert())}}class d{constructor(r,e,i){o(this,"uuid",t.MathUtils.generateUUID());o(this,"_axes");o(this,"_orthographicCamera");o(this,"_restoreViewport",new t.Vector4);this._renderer=r,this._scene=e,this._camera=i,this._orthographicCamera=new t.OrthographicCamera(-1,1,1,-1,.1,100),this._orthographicCamera.name="OrientationDisplayCamera",this._orthographicCamera.layers.mask=h.COORDINATE_LAYER_MASK,this._scene.add(this._orthographicCamera),this._axes=new l,this._axes.name="OrientationDisplayAxes",this._scene.add(this._axes)}tick(){var a;if(!this._renderer.webgpurenderer.initialized)return;const r=this._scene.background??null,e=this._renderer.webgpurenderer.autoClear;this._scene.background=null,this._renderer.webgpurenderer.getViewport(this._restoreViewport);const i=((a=this._renderer.webgpurenderer.domElement)==null?void 0:a.clientHeight)??this._restoreViewport.w;this._renderer.webgpurenderer.setViewport(0,Math.max(0,i-150),150,150),this._renderer.webgpurenderer.autoClear=!1,this._axes.setFromCameraMatrix(this._camera.matrix),this._renderer.webgpurenderer.render(this._scene,this._orthographicCamera),this._renderer.webgpurenderer.setViewport(this._restoreViewport),this._renderer.webgpurenderer.autoClear=e,this._scene.background=r}dispose(){this._scene.remove(this._axes),this._scene.remove(this._orthographicCamera)}}exports.OrientationDisplay=d;exports.OrientationDisplayAxes=l;
1
+ "use strict";var _=Object.defineProperty;var c=(t,e,r)=>e in t?_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var o=(t,e,r)=>c(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("three/webgpu"),d=require("../../chunks/FileTypes-gD_1MonW.cjs"),h=require("../../chunks/contributesToBounds-C1mva__U.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const a=require("../../chunks/AxisHelperColors-BrGqktN5.cjs"),x=require("../../chunks/SpriteTextComponent-ByefJLeU.cjs"),n=(t,e,r)=>{const i=new d.DIVENode;return i.position.set(r.x,r.y,r.z),i.layers.mask=h.COORDINATE_LAYER_MASK,i.addComponent(new x.SpriteTextComponent).setText(t).setTextHeight(.2).setColor(e),i};class p extends s.Object3D{constructor(){super();o(this,"_axesHelper");this._axesHelper=new s.AxesHelper(.5),this._axesHelper.layers.mask=h.COORDINATE_LAYER_MASK,this._axesHelper.material.depthTest=!1,this._axesHelper.position.set(0,0,-1),this._axesHelper.setColors(new s.Color(a.AxesColorRed),new s.Color(a.AxesColorGreen),new s.Color(a.AxesColorBlue)),this._axesHelper.add(n("X",a.AxesColorRedLetter,{x:.7,y:0,z:0}),n("Y",a.AxesColorGreenLetter,{x:0,y:.7,z:0}),n("Z",a.AxesColorBlueLetter,{x:0,y:0,z:.7})),this.add(this._axesHelper)}setFromCameraMatrix(r){this._axesHelper.rotation.setFromRotationMatrix(new s.Matrix4().extractRotation(r).invert())}}class u{constructor(e,r,i){o(this,"uuid",s.MathUtils.generateUUID());o(this,"_axes");o(this,"_orthographicCamera");o(this,"_restoreViewport",new s.Vector4);this._renderer=e,this._scene=r,this._cameraComponent=i,this._orthographicCamera=new s.OrthographicCamera(-1,1,1,-1,.1,100),this._orthographicCamera.name="OrientationDisplayCamera",this._orthographicCamera.layers.mask=h.COORDINATE_LAYER_MASK,this._scene.add(this._orthographicCamera),this._axes=new p,this._axes.name="OrientationDisplayAxes",this._scene.add(this._axes)}tick(){var l;if(!this._renderer.webgpurenderer.initialized)return;const e=this._scene.background??null,r=this._renderer.webgpurenderer.autoClear;this._scene.background=null,this._renderer.webgpurenderer.getViewport(this._restoreViewport);const i=((l=this._renderer.webgpurenderer.domElement)==null?void 0:l.clientHeight)??this._restoreViewport.w;this._renderer.webgpurenderer.setViewport(0,Math.max(0,i-150),150,150),this._renderer.webgpurenderer.autoClear=!1,this._axes.setFromCameraMatrix(this._cameraComponent.camera.matrixWorld),this._renderer.webgpurenderer.render(this._scene,this._orthographicCamera),this._renderer.webgpurenderer.setViewport(this._restoreViewport),this._renderer.webgpurenderer.autoClear=r,this._scene.background=e}dispose(){this._scene.remove(this._axes),this._scene.remove(this._orthographicCamera)}}exports.OrientationDisplay=u;exports.OrientationDisplayAxes=p;
@@ -1,67 +1,75 @@
1
1
  var p = Object.defineProperty;
2
- var _ = (t, r, e) => r in t ? p(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
3
- var i = (t, r, e) => _(t, typeof r != "symbol" ? r + "" : r, e);
4
- import { Object3D as l, AxesHelper as d, Color as n, Matrix4 as c, OrthographicCamera as m, MathUtils as x, Vector4 as w } from "three/webgpu";
5
- import "../../chunks/FileTypes-DYtXCJQV.mjs";
6
- import { C as o } from "../../chunks/PerspectiveCamera-B5TvUzTa.mjs";
2
+ var _ = (t, e, r) => e in t ? p(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var a = (t, e, r) => _(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import { Object3D as d, AxesHelper as l, Color as o, Matrix4 as m, OrthographicCamera as c, MathUtils as x, Vector4 as C } from "three/webgpu";
5
+ import { d as u } from "../../chunks/FileTypes-DGSsi-AX.mjs";
6
+ import { C as n } from "../../chunks/contributesToBounds-DYmHYES4.mjs";
7
7
  import "three/examples/jsm/loaders/HDRLoader.js";
8
8
  import "three/tsl";
9
- import { A as u, a as g, b as C, c as b, d as A, e as H } from "../../chunks/AxisHelperColors-JLBHYQDi.mjs";
10
- import h from "three-spritetext";
11
- class k extends l {
9
+ import { A as w, a as g, b, c as A, d as H, e as y } from "../../chunks/AxisHelperColors-JLBHYQDi.mjs";
10
+ import { S as V } from "../../chunks/SpriteTextComponent-CG5vfiFy.mjs";
11
+ const i = (t, e, r) => {
12
+ const s = new u();
13
+ return s.position.set(r.x, r.y, r.z), s.layers.mask = n, s.addComponent(new V()).setText(t).setTextHeight(0.2).setColor(e), s;
14
+ };
15
+ class f extends d {
12
16
  constructor() {
13
17
  super();
14
- i(this, "_axesHelper");
15
- this._axesHelper = new d(0.5), this._axesHelper.layers.mask = o, this._axesHelper.material.depthTest = !1, this._axesHelper.position.set(0, 0, -1), this._axesHelper.setColors(
16
- new n(u),
17
- new n(g),
18
- new n(C)
19
- );
20
- const e = new h("X", 0.2, b), s = new h("Y", 0.2, A), a = new h("Z", 0.2, H);
21
- e.layers.mask = o, s.layers.mask = o, a.layers.mask = o, e.position.set(0.7, 0, 0), s.position.set(0, 0.7, 0), a.position.set(0, 0, 0.7), this._axesHelper.add(e), this._axesHelper.add(s), this._axesHelper.add(a), this.add(this._axesHelper);
18
+ a(this, "_axesHelper");
19
+ this._axesHelper = new l(0.5), this._axesHelper.layers.mask = n, this._axesHelper.material.depthTest = !1, this._axesHelper.position.set(0, 0, -1), this._axesHelper.setColors(
20
+ new o(w),
21
+ new o(g),
22
+ new o(b)
23
+ ), this._axesHelper.add(
24
+ i("X", A, { x: 0.7, y: 0, z: 0 }),
25
+ i("Y", H, { x: 0, y: 0.7, z: 0 }),
26
+ i("Z", y, { x: 0, y: 0, z: 0.7 })
27
+ ), this.add(this._axesHelper);
22
28
  }
23
- setFromCameraMatrix(e) {
29
+ setFromCameraMatrix(r) {
24
30
  this._axesHelper.rotation.setFromRotationMatrix(
25
- new c().extractRotation(e).invert()
31
+ new m().extractRotation(r).invert()
26
32
  );
27
33
  }
28
34
  }
29
- class L {
30
- constructor(r, e, s) {
31
- i(this, "uuid", x.generateUUID());
32
- i(this, "_axes");
33
- i(this, "_orthographicCamera");
34
- i(this, "_restoreViewport", new w());
35
- this._renderer = r, this._scene = e, this._camera = s, this._orthographicCamera = new m(
35
+ class E {
36
+ constructor(e, r, s) {
37
+ a(this, "uuid", x.generateUUID());
38
+ a(this, "_axes");
39
+ a(this, "_orthographicCamera");
40
+ a(this, "_restoreViewport", new C());
41
+ this._renderer = e, this._scene = r, this._cameraComponent = s, this._orthographicCamera = new c(
36
42
  -1,
37
43
  1,
38
44
  1,
39
45
  -1,
40
46
  0.1,
41
47
  100
42
- ), this._orthographicCamera.name = "OrientationDisplayCamera", this._orthographicCamera.layers.mask = o, this._scene.add(this._orthographicCamera), this._axes = new k(), this._axes.name = "OrientationDisplayAxes", this._scene.add(this._axes);
48
+ ), this._orthographicCamera.name = "OrientationDisplayCamera", this._orthographicCamera.layers.mask = n, this._scene.add(this._orthographicCamera), this._axes = new f(), this._axes.name = "OrientationDisplayAxes", this._scene.add(this._axes);
43
49
  }
44
50
  tick() {
45
- var a;
51
+ var h;
46
52
  if (!this._renderer.webgpurenderer.initialized) return;
47
- const r = this._scene.background ?? null, e = this._renderer.webgpurenderer.autoClear;
53
+ const e = this._scene.background ?? null, r = this._renderer.webgpurenderer.autoClear;
48
54
  this._scene.background = null, this._renderer.webgpurenderer.getViewport(this._restoreViewport);
49
- const s = ((a = this._renderer.webgpurenderer.domElement) == null ? void 0 : a.clientHeight) ?? this._restoreViewport.w;
55
+ const s = ((h = this._renderer.webgpurenderer.domElement) == null ? void 0 : h.clientHeight) ?? this._restoreViewport.w;
50
56
  this._renderer.webgpurenderer.setViewport(
51
57
  0,
52
58
  Math.max(0, s - 150),
53
59
  150,
54
60
  150
55
- ), this._renderer.webgpurenderer.autoClear = !1, this._axes.setFromCameraMatrix(this._camera.matrix), this._renderer.webgpurenderer.render(
61
+ ), this._renderer.webgpurenderer.autoClear = !1, this._axes.setFromCameraMatrix(
62
+ this._cameraComponent.camera.matrixWorld
63
+ ), this._renderer.webgpurenderer.render(
56
64
  this._scene,
57
65
  this._orthographicCamera
58
- ), this._renderer.webgpurenderer.setViewport(this._restoreViewport), this._renderer.webgpurenderer.autoClear = e, this._scene.background = r;
66
+ ), this._renderer.webgpurenderer.setViewport(this._restoreViewport), this._renderer.webgpurenderer.autoClear = r, this._scene.background = e;
59
67
  }
60
68
  dispose() {
61
69
  this._scene.remove(this._axes), this._scene.remove(this._orthographicCamera);
62
70
  }
63
71
  }
64
72
  export {
65
- L as OrientationDisplay,
66
- k as OrientationDisplayAxes
73
+ E as OrientationDisplay,
74
+ f as OrientationDisplayAxes
67
75
  };
@@ -1,4 +1,4 @@
1
- import { DIVERenderer, DIVETicker, DIVEScene, DIVEPerspectiveCamera } from '../../../index.ts';
1
+ import { DIVECameraComponent, DIVERenderer, DIVETicker, DIVEScene } from '../../../index.ts';
2
2
  /**
3
3
  * Shows the scene axes in the bottom left corner of the screen.
4
4
  *
@@ -7,12 +7,12 @@ import { DIVERenderer, DIVETicker, DIVEScene, DIVEPerspectiveCamera } from '../.
7
7
  export declare class OrientationDisplay implements DIVETicker {
8
8
  private _renderer;
9
9
  private _scene;
10
- private _camera;
10
+ private _cameraComponent;
11
11
  uuid: string;
12
12
  private _axes;
13
13
  private _orthographicCamera;
14
14
  private _restoreViewport;
15
- constructor(_renderer: DIVERenderer, _scene: DIVEScene, _camera: DIVEPerspectiveCamera);
15
+ constructor(_renderer: DIVERenderer, _scene: DIVEScene, _cameraComponent: DIVECameraComponent);
16
16
  tick(): void;
17
17
  dispose(): void;
18
18
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../chunks/FileTypes-DMTSUCcK.cjs");require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const s={...a.DIVEDefaultSettings},u=async(r,i)=>{const e=new a.DIVE({...i,autoStart:!1});e.mainView.camera.position.set(0,1,2);const t=await new a.DIVEModel().setFromURL(r);e.scene.root.add(t),t.placeOnFloor();const o=new a.OrbitController(e.mainView.camera,e.mainView.canvas);e.clock.addTicker(o);const c=Object.assign(e,{orbitController:o,model:t}),n=e.disposeAsync.bind(e);return c.disposeAsync=async()=>{o.dispose(),await n()},((i==null?void 0:i.autoStart)??!0)&&(await e.startAsync(),o.focusObject(t)),c};exports.QuickView=u;exports.QuickViewDefaultSettings=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../chunks/FileTypes-gD_1MonW.cjs");require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const b=require("../../chunks/ModelComponent-Cj3ff6nL.cjs"),E=require("../../chunks/OrbitController-DFPcXvlO.cjs"),v={...s.DIVEDefaultSettings},d=u=>{s.disposeComponents(u),u.removeFromParent()};async function D(u,l){let a=!1;const e=new s.DIVE({...l,autoStart:!1});try{e.mainView.cameraComponent.owner.position.set(0,1,2);const i=new E.OrbitController(e.mainView.cameraComponent,e.mainView.canvas);e.clock.addTicker(i);let o=null,c=null,f=0,w=Promise.resolve();const m=()=>{const t=o??e.scene.root;new s.BoundingBox().enclose(t).isEmpty||i.focusObject(t)},p=()=>{o&&(d(o),o=null),c&&(c.destroyInstance(),c=null,e.scene.root.nodes.forEach(d))},k=e.disposeAsync.bind(e);e.disposeAsync=async()=>{a=!0,f++,i.dispose(),p(),await k()};const q=async(t,r)=>{c&&p(),o||(o=new s.DIVENode,o.name="QuickViewModel",o.addComponent(new b.ModelComponent),e.scene.root.add(o));const n=o;if(await n.requireComponent(b.ModelComponent).setFromURL(t),a){s.disposeComponents(n),n.removeFromParent();return}((r==null?void 0:r.dropToFloor)??!0)&&n.dropIt(),((r==null?void 0:r.focus)??!0)&&m()},h=async(t,r)=>{p();const n=new(await Promise.resolve().then(()=>require("../state/index.cjs"))).State(e,i);if(c=n,await n.performAction("SET_STATE",t),a){n.destroyInstance(),e.scene.root.nodes.forEach(d);return}((r==null?void 0:r.focus)??!0)&&m()},y=(t,r)=>{const n=++f,C=w.then(()=>{if(!(n!==f||a))return typeof t=="string"?q(t,r):h(t,r)});return w=C.then(()=>{},()=>{}),C},V=Object.assign(e,{orbitController:i,load:y});return Object.defineProperties(V,{model:{get:()=>o,enumerable:!0},state:{get:()=>c,enumerable:!0}}),await y(u,{focus:!1}),((l==null?void 0:l.autoStart)??!0)&&(await e.startAsync(),m()),V}catch(i){a=!0;try{await e.disposeAsync()}catch(o){console.error("Failed to clean up a QuickView:",o)}throw i}}exports.QuickView=D;exports.QuickViewDefaultSettings=v;
@@ -1,25 +1,77 @@
1
- import { D as n, b as r, c as l, O as m } from "../../chunks/FileTypes-DYtXCJQV.mjs";
1
+ import { b as A, c as D, B as I, d as v, e as k } from "../../chunks/FileTypes-DGSsi-AX.mjs";
2
2
  import "three/webgpu";
3
3
  import "three/examples/jsm/loaders/HDRLoader.js";
4
4
  import "three/tsl";
5
- const V = {
6
- ...n
7
- }, D = async (c, a) => {
8
- const o = new r({ ...a, autoStart: !1 });
9
- o.mainView.camera.position.set(0, 1, 2);
10
- const e = await new l().setFromURL(c);
11
- o.scene.root.add(e), e.placeOnFloor();
12
- const i = new m(
13
- o.mainView.camera,
14
- o.mainView.canvas
15
- );
16
- o.clock.addTicker(i);
17
- const t = Object.assign(o, { orbitController: i, model: e }), s = o.disposeAsync.bind(o);
18
- return t.disposeAsync = async () => {
19
- i.dispose(), await s();
20
- }, ((a == null ? void 0 : a.autoStart) ?? !0) && (await o.startAsync(), i.focusObject(e)), t;
5
+ import { M as b } from "../../chunks/ModelComponent-DkfAgTL0.mjs";
6
+ import { O as F } from "../../chunks/OrbitController-DLEyTvUt.mjs";
7
+ const B = {
8
+ ...A
9
+ }, l = (i) => {
10
+ k(i), i.removeFromParent();
21
11
  };
12
+ async function M(i, u) {
13
+ let s = !1;
14
+ const e = new D({ ...u, autoStart: !1 });
15
+ try {
16
+ e.mainView.cameraComponent.owner.position.set(0, 1, 2);
17
+ const a = new F(
18
+ e.mainView.cameraComponent,
19
+ e.mainView.canvas
20
+ );
21
+ e.clock.addTicker(a);
22
+ let o = null, c = null, m = 0, w = Promise.resolve();
23
+ const f = () => {
24
+ const t = o ?? e.scene.root;
25
+ new I().enclose(t).isEmpty || a.focusObject(t);
26
+ }, p = () => {
27
+ o && (l(o), o = null), c && (c.destroyInstance(), c = null, e.scene.root.nodes.forEach(l));
28
+ }, C = e.disposeAsync.bind(e);
29
+ e.disposeAsync = async () => {
30
+ s = !0, m++, a.dispose(), p(), await C();
31
+ };
32
+ const E = async (t, r) => {
33
+ c && p(), o || (o = new v(), o.name = "QuickViewModel", o.addComponent(new b()), e.scene.root.add(o));
34
+ const n = o;
35
+ if (await n.requireComponent(b).setFromURL(t), s) {
36
+ k(n), n.removeFromParent();
37
+ return;
38
+ }
39
+ ((r == null ? void 0 : r.dropToFloor) ?? !0) && n.dropIt(), ((r == null ? void 0 : r.focus) ?? !0) && f();
40
+ }, h = async (t, r) => {
41
+ p();
42
+ const n = new (await import("../state/index.mjs")).State(e, a);
43
+ if (c = n, await n.performAction("SET_STATE", t), s) {
44
+ n.destroyInstance(), e.scene.root.nodes.forEach(l);
45
+ return;
46
+ }
47
+ ((r == null ? void 0 : r.focus) ?? !0) && f();
48
+ }, d = (t, r) => {
49
+ const n = ++m, V = w.then(() => {
50
+ if (!(n !== m || s))
51
+ return typeof t == "string" ? E(t, r) : h(t, r);
52
+ });
53
+ return w = V.then(
54
+ () => {
55
+ },
56
+ () => {
57
+ }
58
+ ), V;
59
+ }, y = Object.assign(e, { orbitController: a, load: d });
60
+ return Object.defineProperties(y, {
61
+ model: { get: () => o, enumerable: !0 },
62
+ state: { get: () => c, enumerable: !0 }
63
+ }), await d(i, { focus: !1 }), ((u == null ? void 0 : u.autoStart) ?? !0) && (await e.startAsync(), f()), y;
64
+ } catch (a) {
65
+ s = !0;
66
+ try {
67
+ await e.disposeAsync();
68
+ } catch (o) {
69
+ console.error("Failed to clean up a QuickView:", o);
70
+ }
71
+ throw a;
72
+ }
73
+ }
22
74
  export {
23
- D as QuickView,
24
- V as QuickViewDefaultSettings
75
+ M as QuickView,
76
+ B as QuickViewDefaultSettings
25
77
  };
@@ -1,15 +1,47 @@
1
- import { DIVE, DIVEModel } from '../../../index.ts';
1
+ import { DIVE, DIVENode } from '../../../index.ts';
2
2
  import { OrbitController } from '../../orbitcontroller/index.ts';
3
- import { QuickViewSettings } from '../types/index.ts';
4
- export declare const QuickViewDefaultSettings: Omit<Required<QuickViewSettings>, 'hdr'>;
3
+ import { State, StateData } from '../../state/index.ts';
4
+ import { QuickViewLoadSettings, QuickViewSettings } from '../types/index.ts';
5
+ /**
6
+ * What {@link QuickView} hands back.
7
+ *
8
+ * Named after the factory, and declared in the same module so it can be: a
9
+ * function lives in the value namespace and a type in the type one, so one
10
+ * import and no `type` keyword covers both.
11
+ *
12
+ * import { QuickView } from '@shopware-ag/dive/quickview';
13
+ * const view: Ref<QuickView | null> = ref(null);
14
+ *
15
+ * One type, because a QuickView can hold either kind of source and can be handed
16
+ * the other one later -- {@link load} takes whatever {@link QuickView} takes. So
17
+ * which of {@link model} and {@link state} is there is a question about right
18
+ * now, not about how the view was built, and both are therefore nullable rather
19
+ * than promised.
20
+ */
5
21
  export type QuickView = DIVE & {
6
22
  orbitController: OrbitController;
7
- model: DIVEModel;
23
+ /** The node the model sits on, or `null` while a scene state is loaded. */
24
+ readonly model: DIVENode | null;
25
+ /** The state driving the scene, or `null` while a single model is loaded. */
26
+ readonly state: State | null;
27
+ /**
28
+ * Puts something else in front of the viewer.
29
+ *
30
+ * Takes the same sources the factory does, and replaces whatever is loaded --
31
+ * including across kinds: a QuickView built from a URI can be handed scene
32
+ * state and the other way round. The previous source is torn down first, its
33
+ * GPU resources included.
34
+ *
35
+ * @param source - A model URI, or the scene data to apply.
36
+ * @param settings - What to skip; see {@link QuickViewLoadSettings}.
37
+ */
38
+ load: (source: string | StateData, settings?: Partial<QuickViewLoadSettings>) => Promise<void>;
8
39
  };
40
+ export declare const QuickViewDefaultSettings: Omit<Required<QuickViewSettings>, 'hdr'>;
9
41
  /**
42
+ * Creates a QuickView from a model URI or from scene data.
10
43
  *
11
- * @param uri - The URI of the 3D model to display in QuickView
12
- * @param settings - The settings for the QuickView
13
- * @returns The DIVE instance with the orbit controller and hdr environment - { ...DIVE, orbitController: OrbitController, hdr: HDREnvironment }
44
+ * @param source - A model URI, or the scene data to display.
45
+ * @param settings - The settings for the QuickView.
14
46
  */
15
- export declare const QuickView: (uri: string, settings?: Partial<QuickViewSettings>) => Promise<QuickView>;
47
+ export declare function QuickView(source: string | StateData, settings?: Partial<QuickViewSettings>): Promise<QuickView>;
@@ -1,2 +1,16 @@
1
1
  import { DIVESettings } from '../../../index.ts';
2
2
  export type QuickViewSettings = DIVESettings;
3
+ /**
4
+ * What to do around a model swap, beyond loading it.
5
+ *
6
+ * Both default to `true`, because that is what a viewer wants: a model that
7
+ * stands on the ground and fills the view. Turn one off where the caller has its
8
+ * own answer -- a configurator that keeps the camera where the user put it, or a
9
+ * scene where the model is meant to float.
10
+ */
11
+ export type QuickViewLoadSettings = {
12
+ /** Drop the model onto whatever is below it. @default true */
13
+ dropToFloor: boolean;
14
+ /** Frame the model once it is loaded. @default true */
15
+ focus: boolean;
16
+ };