@shopware-ag/dive 3.0.6 → 3.0.8

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 (28) hide show
  1. package/build/chunks/{AssetCache-hZPj76ce.cjs → AssetCache-5FgjqaKg.cjs} +1 -1
  2. package/build/chunks/{AssetCache-kR5gKTDf.mjs → AssetCache-w3B0LIUw.mjs} +1 -1
  3. package/build/chunks/{AssetLoader-IE1YVWYL.mjs → AssetLoader-BeP0hkJD.mjs} +167 -151
  4. package/build/chunks/AssetLoader-Dp_S2z9P.cjs +3 -0
  5. package/build/chunks/{FileTypes-IZ9BrQ2x.cjs → FileTypes-Ba65iQSJ.cjs} +1 -1
  6. package/build/chunks/{FileTypes-DLAWiGQa.mjs → FileTypes-Ck6z0LqE.mjs} +1 -1
  7. package/build/chunks/{isFileTypeSupported-D7Sy7zU-.mjs → isFileTypeSupported-DPjSWSnx.mjs} +1 -1
  8. package/build/chunks/{isFileTypeSupported-dgHlqizJ.cjs → isFileTypeSupported-Dx01kdxM.cjs} +1 -1
  9. package/build/dive.cjs +1 -1
  10. package/build/dive.mjs +2 -2
  11. package/build/plugins/ar/index.cjs +1 -1
  12. package/build/plugins/ar/index.mjs +1 -1
  13. package/build/plugins/assetcache/index.cjs +1 -1
  14. package/build/plugins/assetcache/index.mjs +1 -1
  15. package/build/plugins/assetloader/index.cjs +1 -1
  16. package/build/plugins/assetloader/index.mjs +2 -2
  17. package/build/plugins/orbitcontroller/index.cjs +1 -1
  18. package/build/plugins/orbitcontroller/index.mjs +1 -1
  19. package/build/plugins/orientationdisplay/index.cjs +1 -1
  20. package/build/plugins/orientationdisplay/index.mjs +1 -1
  21. package/build/plugins/quickview/index.cjs +1 -1
  22. package/build/plugins/quickview/index.mjs +1 -1
  23. package/build/plugins/state/index.cjs +1 -1
  24. package/build/plugins/state/index.mjs +1 -1
  25. package/build/plugins/toolbox/index.cjs +1 -1
  26. package/build/plugins/toolbox/index.mjs +1 -1
  27. package/package.json +1 -1
  28. package/build/chunks/AssetLoader-NuQXJfHL.cjs +0 -3
@@ -1 +1 @@
1
- "use strict";var d=Object.defineProperty;var l=(i,e,t)=>e in i?d(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var s=(i,e,t)=>l(i,typeof e!="symbol"?e+"":e,t);require("./FileTypes-IZ9BrQ2x.cjs");require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const _=require("./network-error-CdDXil5g.cjs");class f{constructor(e){s(this,"_promise");s(this,"_resolve");s(this,"_arrayBuffer",null);s(this,"_size",0);s(this,"_createdAt");s(this,"_updatedAt");this._uri=e,this._promise=new Promise(t=>{this._resolve=t}),this._createdAt=new Date,this._updatedAt=new Date}get promise(){return this._promise}get size(){return this._size}get createdAt(){return this._createdAt}get updatedAt(){return this._updatedAt}get arrayBuffer(){return this._arrayBuffer}_getHeader(e,t){var r,a;return((a=(r=e.headers)==null?void 0:r.get)==null?void 0:a.call(r,t))??null}_concatChunks(e,t){const r=new Uint8Array(t);let a=0;for(const n of e)r.set(n,a),a+=n.byteLength;return r.buffer}async _readBodyWithReader(e){const t=e.body.getReader(),r=[];let a=0;try{for(;;){const o=await t.read();if(o.done)break;const u=o.value??new Uint8Array(0);r.push(u),a+=u.byteLength}}finally{t.releaseLock()}return this._concatChunks(r,a)}async load(){var t;const e=await fetch(this._uri);if(!e.ok)throw new _.NetworkError(this._uri);try{(t=e.body)!=null&&t.getReader?this._arrayBuffer=await this._readBodyWithReader(e):this._arrayBuffer=await e.arrayBuffer(),this._size+=this._arrayBuffer.byteLength,this._updatedAt=new Date}catch{throw new _.FileContentError(this._uri)}return this._resolve(this._arrayBuffer),this._arrayBuffer}}class y{constructor(){s(this,"_cache",new Map)}get(){return this._cache}create(e){const t=new f(e);return this._cache.set(e,t),t}write(e,t){this._cache.set(e,t)}read(e){return this._cache.get(e)??null}delete(...e){e.forEach(t=>{this._cache.delete(t)})}clear(){this._cache.clear()}}const h=Symbol.for("@shopware-ag/dive/assetcache"),c=globalThis;c[h]||(c[h]=new y);const w=c[h];exports.AssetCache=w;exports.Chunk=f;
1
+ "use strict";var d=Object.defineProperty;var l=(i,e,t)=>e in i?d(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var s=(i,e,t)=>l(i,typeof e!="symbol"?e+"":e,t);require("./FileTypes-Ba65iQSJ.cjs");require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const _=require("./network-error-CdDXil5g.cjs");class f{constructor(e){s(this,"_promise");s(this,"_resolve");s(this,"_arrayBuffer",null);s(this,"_size",0);s(this,"_createdAt");s(this,"_updatedAt");this._uri=e,this._promise=new Promise(t=>{this._resolve=t}),this._createdAt=new Date,this._updatedAt=new Date}get promise(){return this._promise}get size(){return this._size}get createdAt(){return this._createdAt}get updatedAt(){return this._updatedAt}get arrayBuffer(){return this._arrayBuffer}_getHeader(e,t){var r,a;return((a=(r=e.headers)==null?void 0:r.get)==null?void 0:a.call(r,t))??null}_concatChunks(e,t){const r=new Uint8Array(t);let a=0;for(const n of e)r.set(n,a),a+=n.byteLength;return r.buffer}async _readBodyWithReader(e){const t=e.body.getReader(),r=[];let a=0;try{for(;;){const o=await t.read();if(o.done)break;const u=o.value??new Uint8Array(0);r.push(u),a+=u.byteLength}}finally{t.releaseLock()}return this._concatChunks(r,a)}async load(){var t;const e=await fetch(this._uri);if(!e.ok)throw new _.NetworkError(this._uri);try{(t=e.body)!=null&&t.getReader?this._arrayBuffer=await this._readBodyWithReader(e):this._arrayBuffer=await e.arrayBuffer(),this._size+=this._arrayBuffer.byteLength,this._updatedAt=new Date}catch{throw new _.FileContentError(this._uri)}return this._resolve(this._arrayBuffer),this._arrayBuffer}}class y{constructor(){s(this,"_cache",new Map)}get(){return this._cache}create(e){const t=new f(e);return this._cache.set(e,t),t}write(e,t){this._cache.set(e,t)}read(e){return this._cache.get(e)??null}delete(...e){e.forEach(t=>{this._cache.delete(t)})}clear(){this._cache.clear()}}const h=Symbol.for("@shopware-ag/dive/assetcache"),c=globalThis;c[h]||(c[h]=new y);const w=c[h];exports.AssetCache=w;exports.Chunk=f;
@@ -1,7 +1,7 @@
1
1
  var _ = Object.defineProperty;
2
2
  var f = (i, e, t) => e in i ? _(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
3
  var s = (i, e, t) => f(i, typeof e != "symbol" ? e + "" : e, t);
4
- import "./FileTypes-DLAWiGQa.mjs";
4
+ import "./FileTypes-Ck6z0LqE.mjs";
5
5
  import "three/webgpu";
6
6
  import "three/examples/jsm/loaders/HDRLoader.js";
7
7
  import "three/tsl";
@@ -1,139 +1,155 @@
1
- var C = Object.defineProperty;
2
- var I = (_, r, s) => r in _ ? C(_, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : _[r] = s;
3
- var h = (_, r, s) => I(_, typeof r != "symbol" ? r + "" : r, s);
4
- import { GLTFLoader as P } from "three/examples/jsm/loaders/GLTFLoader.js";
5
- import { USDLoader as U } from "three/examples/jsm/loaders/USDLoader.js";
6
- import { S as M } from "./FileTypes-DLAWiGQa.mjs";
7
- import { Group as b, BufferGeometry as k, BufferAttribute as E, MeshStandardMaterial as F, Mesh as N } from "three/webgpu";
1
+ var k = Object.defineProperty;
2
+ var F = (_, r, s) => r in _ ? k(_, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : _[r] = s;
3
+ var h = (_, r, s) => F(_, typeof r != "symbol" ? r + "" : r, s);
4
+ import { GLTFLoader as x } from "three/examples/jsm/loaders/GLTFLoader.js";
5
+ import { USDLoader as G } from "three/examples/jsm/loaders/USDLoader.js";
6
+ import { S as B } from "./FileTypes-Ck6z0LqE.mjs";
7
+ import { Group as C, BufferGeometry as W, BufferAttribute as O, MeshStandardMaterial as v, Mesh as j } from "three/webgpu";
8
8
  import "three/examples/jsm/loaders/HDRLoader.js";
9
9
  import "three/tsl";
10
- import { g as x, i as G } from "./isFileTypeSupported-D7Sy7zU-.mjs";
11
- import { F as R, P as O } from "./parse-error-DfOPyLWM.mjs";
12
- import { DRACOLoader as W } from "three/examples/jsm/loaders/DRACOLoader.js";
13
- import { A as D } from "./AssetCache-kR5gKTDf.mjs";
14
- function v() {
10
+ import { g as H, i as z } from "./isFileTypeSupported-DPjSWSnx.mjs";
11
+ import { F as P, P as M } from "./parse-error-DfOPyLWM.mjs";
12
+ import { DRACOLoader as Y } from "three/examples/jsm/loaders/DRACOLoader.js";
13
+ import { A as S } from "./AssetCache-w3B0LIUw.mjs";
14
+ function J() {
15
15
  let _, r;
16
16
  onmessage = function(e) {
17
17
  const n = e.data;
18
18
  switch (n.type) {
19
19
  case "init":
20
- _ = n.decoderConfig, r = new Promise(function(a) {
21
- _.onModuleLoaded = function(u) {
22
- a({ draco: u });
20
+ _ = n.decoderConfig, r = new Promise(function(i) {
21
+ _.onModuleLoaded = function(f) {
22
+ i({ draco: f });
23
23
  }, DracoDecoderModule(_);
24
24
  });
25
25
  break;
26
26
  case "decode":
27
- const i = n.buffer, d = n.taskConfig;
28
- r.then((a) => {
29
- const u = a.draco, c = new u.Decoder();
27
+ const c = n.buffer, d = n.taskConfig;
28
+ r.then((i) => {
29
+ const f = i.draco, a = new f.Decoder();
30
30
  try {
31
- const f = s(
32
- u,
33
- c,
34
- new Int8Array(i),
31
+ const l = s(
32
+ f,
33
+ a,
34
+ new Int8Array(c),
35
35
  d
36
- ), p = f.attributes.map(
36
+ ), p = l.attributes.map(
37
37
  (m) => m.array.buffer
38
38
  );
39
- f.index && p.push(f.index.array.buffer), self.postMessage(
40
- { type: "decode", id: n.id, geometry: f },
39
+ l.index && p.push(l.index.array.buffer), self.postMessage(
40
+ { type: "decode", id: n.id, geometry: l },
41
41
  p
42
42
  );
43
- } catch (f) {
44
- console.error(f), self.postMessage({
43
+ } catch (l) {
44
+ console.error(l), self.postMessage({
45
45
  type: "error",
46
46
  id: n.id,
47
- error: f.message
47
+ error: l.message
48
48
  });
49
49
  } finally {
50
- u.destroy(c);
50
+ f.destroy(a);
51
51
  }
52
52
  });
53
53
  break;
54
54
  }
55
55
  };
56
- function s(e, n, i, d) {
57
- const a = d.attributeIDs, u = d.attributeTypes;
58
- let c, f;
59
- const p = n.GetEncodedGeometryType(i);
56
+ function s(e, n, c, d) {
57
+ const i = d.attributeIDs, f = d.attributeTypes;
58
+ let a, l;
59
+ const p = n.GetEncodedGeometryType(c);
60
60
  if (p === e.TRIANGULAR_MESH)
61
- c = new e.Mesh(), f = n.DecodeArrayToMesh(
62
- i,
63
- i.byteLength,
64
- c
61
+ a = new e.Mesh(), l = n.DecodeArrayToMesh(
62
+ c,
63
+ c.byteLength,
64
+ a
65
65
  );
66
66
  else if (p === e.POINT_CLOUD)
67
- c = new e.PointCloud(), f = n.DecodeArrayToPointCloud(
68
- i,
69
- i.byteLength,
70
- c
67
+ a = new e.PointCloud(), l = n.DecodeArrayToPointCloud(
68
+ c,
69
+ c.byteLength,
70
+ a
71
71
  );
72
72
  else
73
73
  throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
74
- if (!f.ok() || c.ptr === 0)
74
+ if (!l.ok() || a.ptr === 0)
75
75
  throw new Error(
76
- "THREE.DRACOLoader: Decoding failed: " + f.error_msg()
76
+ "THREE.DRACOLoader: Decoding failed: " + l.error_msg()
77
77
  );
78
78
  const m = { index: null, attributes: [] };
79
- for (const g in a) {
80
- const w = self[u[g]];
81
- let y, A;
79
+ for (const g in i) {
80
+ const E = self[f[g]];
81
+ let w, A;
82
82
  if (d.useUniqueIDs)
83
- A = a[g], y = n.GetAttributeByUniqueId(
84
- c,
83
+ A = i[g], w = n.GetAttributeByUniqueId(
84
+ a,
85
85
  A
86
86
  );
87
87
  else {
88
88
  if (A = n.GetAttributeId(
89
- c,
90
- e[a[g]]
89
+ a,
90
+ e[i[g]]
91
91
  ), A === -1) continue;
92
- y = n.GetAttribute(c, A);
92
+ w = n.GetAttribute(a, A);
93
93
  }
94
- const S = o(
94
+ const y = o(
95
95
  e,
96
96
  n,
97
- c,
97
+ a,
98
98
  g,
99
- w,
100
- y
99
+ E,
100
+ w
101
101
  );
102
- g === "color" && (S.vertexColorSpace = d.vertexColorSpace), m.attributes.push(S);
102
+ g === "color" && (y.vertexColorSpace = d.vertexColorSpace), m.attributes.push(y);
103
103
  }
104
- return p === e.TRIANGULAR_MESH && (m.index = t(e, n, c)), e.destroy(c), m;
104
+ return p === e.TRIANGULAR_MESH && (m.index = t(e, n, a)), e.destroy(a), m;
105
105
  }
106
- function t(e, n, i) {
107
- const a = i.num_faces() * 3, u = a * 4, c = e._malloc(u);
108
- n.GetTrianglesUInt32Array(i, u, c);
109
- const f = new Uint32Array(
106
+ function t(e, n, c) {
107
+ const i = c.num_faces() * 3, f = i * 4, a = e._malloc(f);
108
+ n.GetTrianglesUInt32Array(c, f, a);
109
+ const l = new Uint32Array(
110
110
  e.HEAPF32.buffer,
111
- c,
112
- a
111
+ a,
112
+ i
113
113
  ).slice();
114
- return e._free(c), { array: f, itemSize: 1 };
114
+ return e._free(a), { array: l, itemSize: 1 };
115
115
  }
116
- function o(e, n, i, d, a, u) {
117
- const c = u.num_components(), p = i.num_points() * c, m = p * a.BYTES_PER_ELEMENT, g = l(e, a), w = e._malloc(m);
116
+ function o(e, n, c, d, i, f) {
117
+ const a = c.num_points(), l = f.num_components(), p = u(e, i), m = l * i.BYTES_PER_ELEMENT, g = Math.ceil(m / 4) * 4, E = g / i.BYTES_PER_ELEMENT, w = a * m, A = a * g, y = e._malloc(w);
118
118
  n.GetAttributeDataArrayForAllPoints(
119
- i,
120
- u,
121
- g,
122
- m,
123
- w
119
+ c,
120
+ f,
121
+ p,
122
+ w,
123
+ y
124
124
  );
125
- const y = new a(
125
+ const R = new i(
126
126
  e.HEAPF32.buffer,
127
- w,
128
- p
129
- ).slice();
130
- return e._free(w), {
127
+ y,
128
+ w / i.BYTES_PER_ELEMENT
129
+ );
130
+ let D;
131
+ if (m === g)
132
+ D = R.slice();
133
+ else {
134
+ D = new i(
135
+ A / i.BYTES_PER_ELEMENT
136
+ );
137
+ let I = 0;
138
+ for (let T = 0, N = R.length; T < N; T += l) {
139
+ for (let L = 0; L < l; L++)
140
+ D[I + L] = R[T + L];
141
+ I += E;
142
+ }
143
+ }
144
+ return e._free(y), {
131
145
  name: d,
132
- array: y,
133
- itemSize: c
146
+ count: a,
147
+ itemSize: l,
148
+ array: D,
149
+ stride: E
134
150
  };
135
151
  }
136
- function l(e, n) {
152
+ function u(e, n) {
137
153
  switch (n) {
138
154
  case Float32Array:
139
155
  return e.DT_FLOAT32;
@@ -152,7 +168,7 @@ function v() {
152
168
  }
153
169
  }
154
170
  }
155
- const L = {
171
+ const b = {
156
172
  LOAD_DRACO_JS_DECODER: async () => (await import("three/examples/jsm/libs/draco/draco_decoder.js?raw")).default,
157
173
  LOAD_DRACO_WASM_WRAPPER: async () => (await import("three/examples/jsm/libs/draco/draco_wasm_wrapper.js?raw")).default,
158
174
  LOAD_DRACO_WASM_DECODER: async () => {
@@ -160,7 +176,7 @@ const L = {
160
176
  return await (await fetch(_)).arrayBuffer();
161
177
  }
162
178
  };
163
- class j extends W {
179
+ class $ extends Y {
164
180
  constructor() {
165
181
  super(...arguments);
166
182
  h(this, "decoderPending", null);
@@ -174,18 +190,18 @@ class j extends W {
174
190
  if (this.decoderPending) return this.decoderPending;
175
191
  const s = typeof WebAssembly != "object" || this.decoderConfig.type === "js", t = [];
176
192
  return s ? t.push(
177
- L.LOAD_DRACO_JS_DECODER()
193
+ b.LOAD_DRACO_JS_DECODER()
178
194
  ) : (t.push(
179
- L.LOAD_DRACO_WASM_WRAPPER()
195
+ b.LOAD_DRACO_WASM_WRAPPER()
180
196
  ), t.push(
181
- L.LOAD_DRACO_WASM_DECODER()
197
+ b.LOAD_DRACO_WASM_DECODER()
182
198
  )), this.decoderPending = Promise.all(t).then(
183
199
  (o) => {
184
- const l = o[0];
200
+ const u = o[0];
185
201
  s || (this.decoderConfig.wasmBinary = o[1]);
186
- const e = v.toString(), n = [
202
+ const e = J.toString(), n = [
187
203
  "/* draco decoder */",
188
- l,
204
+ u,
189
205
  "",
190
206
  "/* worker */",
191
207
  e.substring(e.indexOf("{") + 1, e.lastIndexOf("}"))
@@ -196,7 +212,7 @@ class j extends W {
196
212
  ), this.decoderPending;
197
213
  }
198
214
  }
199
- function B() {
215
+ function q() {
200
216
  let _ = null, r = null;
201
217
  const s = [
202
218
  [
@@ -217,16 +233,16 @@ function B() {
217
233
  })), _;
218
234
  }
219
235
  function o(e) {
220
- for (var n = new TextDecoder("utf-8", { fatal: !1 }), i = new TextEncoder(), d = n.decode(e), a = 0; a < s.length; a++) {
221
- var u = s[a][0], c = s[a][1];
222
- d = d.replace(u, c);
236
+ for (var n = new TextDecoder("utf-8", { fatal: !1 }), c = new TextEncoder(), d = n.decode(e), i = 0; i < s.length; i++) {
237
+ var f = s[i][0], a = s[i][1];
238
+ d = d.replace(f, a);
223
239
  }
224
- return new Uint8Array(i.encode(d));
240
+ return new Uint8Array(c.encode(d));
225
241
  }
226
- function l(e, n) {
227
- var i = o(n);
242
+ function u(e, n) {
243
+ var c = o(n);
228
244
  try {
229
- var d = e.ReadStepFile(i, null);
245
+ var d = e.ReadStepFile(c, null);
230
246
  if (d.success && d.root) return d;
231
247
  } catch {
232
248
  }
@@ -248,8 +264,8 @@ function B() {
248
264
  break;
249
265
  case "parse":
250
266
  try {
251
- var i = await t(), d = new Uint8Array(n.buffer), a = n.fileType, u;
252
- if (a === "step" || a === "stp" ? u = l(i, d) : u = i.ReadIgesFile(d, null), !u.success || !u.root) {
267
+ var c = await t(), d = new Uint8Array(n.buffer), i = n.fileType, f;
268
+ if (i === "step" || i === "stp" ? f = u(c, d) : f = c.ReadIgesFile(d, null), !f.success || !f.root) {
253
269
  self.postMessage({
254
270
  type: "error",
255
271
  id: n.id,
@@ -260,24 +276,24 @@ function B() {
260
276
  self.postMessage({
261
277
  type: "result",
262
278
  id: n.id,
263
- result: u
279
+ result: f
264
280
  });
265
- } catch (c) {
281
+ } catch (a) {
266
282
  self.postMessage({
267
283
  type: "error",
268
284
  id: n.id,
269
- error: c instanceof Error ? c.message : String(c)
285
+ error: a instanceof Error ? a.message : String(a)
270
286
  });
271
287
  }
272
288
  break;
273
289
  }
274
290
  };
275
291
  }
276
- const T = {
292
+ const U = {
277
293
  LOAD_OCCT_JS: async () => (await import("./occt-import-js-D-bjjBtk.mjs")).default,
278
294
  LOAD_OCCT_WASM_URL: async () => (await import("./occt-import-js-ekuHaP1Z.mjs")).default
279
295
  };
280
- class H {
296
+ class V {
281
297
  constructor() {
282
298
  h(this, "_workerPending", null);
283
299
  h(this, "_worker", null);
@@ -295,35 +311,35 @@ class H {
295
311
  r,
296
312
  s
297
313
  ] = await Promise.all([
298
- T.LOAD_OCCT_JS(),
299
- T.LOAD_OCCT_WASM_URL()
300
- ]), t = B.toString(), o = [
314
+ U.LOAD_OCCT_JS(),
315
+ U.LOAD_OCCT_WASM_URL()
316
+ ]), t = q.toString(), o = [
301
317
  "/* occt-import-js */",
302
318
  r,
303
319
  "",
304
320
  "/* step worker */",
305
321
  t.substring(t.indexOf("{") + 1, t.lastIndexOf("}"))
306
322
  ].join(`
307
- `), l = URL.createObjectURL(new Blob([o])), e = new Worker(l), n = new URL(s, window.location.href).href;
308
- return e.postMessage({ type: "init", wasmUrl: n }), e.onmessage = (i) => {
309
- const { type: d, id: a, result: u, error: c } = i.data, f = this._pending.get(a);
310
- if (f)
311
- if (this._pending.delete(a), d === "result")
323
+ `), u = URL.createObjectURL(new Blob([o])), e = new Worker(u), n = new URL(s, window.location.href).href;
324
+ return e.postMessage({ type: "init", wasmUrl: n }), e.onmessage = (c) => {
325
+ const { type: d, id: i, result: f, error: a } = c.data, l = this._pending.get(i);
326
+ if (l)
327
+ if (this._pending.delete(i), d === "result")
312
328
  try {
313
- f.resolve(this._buildScene(u));
329
+ l.resolve(this._buildScene(f));
314
330
  } catch (p) {
315
- f.reject(
331
+ l.reject(
316
332
  p instanceof Error ? p : new Error(String(p))
317
333
  );
318
334
  }
319
335
  else
320
- f.reject(new Error(c ?? "Worker error"));
321
- }, e.onerror = (i) => {
336
+ l.reject(new Error(a ?? "Worker error"));
337
+ }, e.onerror = (c) => {
322
338
  for (const [
323
339
  ,
324
340
  { reject: d }
325
341
  ] of this._pending)
326
- d(new Error(i.message ?? "Worker error"));
342
+ d(new Error(c.message ?? "Worker error"));
327
343
  this._pending.clear();
328
344
  }, this._worker = e, e;
329
345
  })(), this._workerPending);
@@ -333,8 +349,8 @@ class H {
333
349
  */
334
350
  async parseAsync(r, s) {
335
351
  const t = this._nextId++, o = await this._getWorker();
336
- return new Promise((l, e) => {
337
- this._pending.set(t, { resolve: l, reject: e });
352
+ return new Promise((u, e) => {
353
+ this._pending.set(t, { resolve: u, reject: e });
338
354
  const n = r.slice(0);
339
355
  o.postMessage({ type: "parse", id: t, buffer: n, fileType: s }, [
340
356
  n
@@ -355,70 +371,70 @@ class H {
355
371
  }
356
372
  }
357
373
  _buildScene(r) {
358
- const s = new b();
374
+ const s = new C();
359
375
  return s.name = r.root.name ?? "CAD Model", this._buildNode(r.root, r.meshes, s), s.rotation.x = -Math.PI / 2, s.rotation.z = Math.PI / 2, s;
360
376
  }
361
377
  _buildNode(r, s, t) {
362
- const o = new b();
378
+ const o = new C();
363
379
  o.name = r.name ?? "Part";
364
- for (const l of r.meshes) {
365
- const e = s[l];
380
+ for (const u of r.meshes) {
381
+ const e = s[u];
366
382
  if (e != null && e.attributes) {
367
383
  const n = this._createMesh(e);
368
384
  o.add(n);
369
385
  }
370
386
  }
371
- for (const l of r.children)
372
- this._buildNode(l, s, o);
387
+ for (const u of r.children)
388
+ this._buildNode(u, s, o);
373
389
  t.add(o);
374
390
  }
375
391
  _createMesh(r) {
376
- var d, a;
377
- const { position: s, normal: t } = r.attributes, o = r.index ?? r.attributes.index, l = new k();
378
- l.setAttribute(
392
+ var d, i;
393
+ const { position: s, normal: t } = r.attributes, o = r.index ?? r.attributes.index, u = new W();
394
+ u.setAttribute(
379
395
  "position",
380
- new E(new Float32Array(s.array), 3)
381
- ), (d = t == null ? void 0 : t.array) != null && d.length ? l.setAttribute(
396
+ new O(new Float32Array(s.array), 3)
397
+ ), (d = t == null ? void 0 : t.array) != null && d.length ? u.setAttribute(
382
398
  "normal",
383
- new E(new Float32Array(t.array), 3)
384
- ) : l.computeVertexNormals(), (a = o == null ? void 0 : o.array) != null && a.length && l.setIndex(
385
- new E(new Uint32Array(o.array), 1)
399
+ new O(new Float32Array(t.array), 3)
400
+ ) : u.computeVertexNormals(), (i = o == null ? void 0 : o.array) != null && i.length && u.setIndex(
401
+ new O(new Uint32Array(o.array), 1)
386
402
  );
387
- const e = r.color, n = new F({
403
+ const e = r.color, n = new v({
388
404
  metalness: 0.3,
389
405
  roughness: 0.6
390
406
  });
391
407
  e && e.length >= 3 ? n.color.setRGB(e[0], e[1], e[2]) : n.color.setHex(13421772);
392
- const i = new N(l, n);
393
- return i.name = r.name ?? "Mesh", i.castShadow = !0, i.receiveShadow = !0, i;
408
+ const c = new j(u, n);
409
+ return c.name = r.name ?? "Mesh", c.castShadow = !0, c.receiveShadow = !0, c;
394
410
  }
395
411
  }
396
- class te {
412
+ class ae {
397
413
  constructor() {
398
414
  h(this, "_gltfLoader");
399
415
  h(this, "_usdLoader");
400
416
  h(this, "_stepLoader");
401
- const r = new j();
402
- r.setDecoderConfig({ type: "wasm" }), this._gltfLoader = new P(), this._gltfLoader.setDRACOLoader(r), this._usdLoader = new U(), this._stepLoader = new H();
417
+ const r = new $();
418
+ r.setDecoderConfig({ type: "wasm" }), this._gltfLoader = new x(), this._gltfLoader.setDRACOLoader(r), this._usdLoader = new G(), this._stepLoader = new V();
403
419
  }
404
420
  async load(r, s) {
405
421
  let t;
406
422
  if (s)
407
423
  t = s;
408
- else if (t = x(r), t.length === 0 && (t = await this._detectFileTypeFromContent(r), t.length === 0))
409
- throw new R(
424
+ else if (t = H(r), t.length === 0 && (t = await this._detectFileTypeFromContent(r), t.length === 0))
425
+ throw new P(
410
426
  "No file extension found in URI",
411
427
  ""
412
428
  );
413
- if (!G(t))
414
- throw new R(
415
- `Unsupported file type: ${t}. Supported types: ${M.join(", ")}`,
429
+ if (!z(t))
430
+ throw new P(
431
+ `Unsupported file type: ${t}. Supported types: ${B.join(", ")}`,
416
432
  t
417
433
  );
418
- const o = D.read(r);
434
+ const o = S.read(r);
419
435
  if (o)
420
436
  return o.arrayBuffer ? this._parse(o.arrayBuffer, t) : o.promise.then((n) => this._parse(n, t));
421
- const e = await D.create(r).load();
437
+ const e = await S.create(r).load();
422
438
  return this._parse(e, t);
423
439
  }
424
440
  /**
@@ -428,9 +444,9 @@ class te {
428
444
  */
429
445
  async _detectFileTypeFromContent(r) {
430
446
  try {
431
- const s = D.read(r);
447
+ const s = S.read(r);
432
448
  let t;
433
- s ? s.arrayBuffer ? t = s.arrayBuffer : t = await s.promise : t = await D.create(r).load();
449
+ s ? s.arrayBuffer ? t = s.arrayBuffer : t = await s.promise : t = await S.create(r).load();
434
450
  const o = new Uint8Array(t);
435
451
  return o.length >= 12 && String.fromCharCode(
436
452
  o[0],
@@ -485,15 +501,15 @@ class te {
485
501
  }
486
502
  }
487
503
  } catch (t) {
488
- throw t instanceof Error ? new O(
504
+ throw t instanceof Error ? new M(
489
505
  `Failed to parse ${s} file: ${t.message}`,
490
506
  t
491
- ) : new O(`Failed to parse ${s} file`);
507
+ ) : new M(`Failed to parse ${s} file`);
492
508
  }
493
509
  }
494
510
  }
495
511
  export {
496
- te as A,
497
- v as D,
498
- j as a
512
+ ae as A,
513
+ J as D,
514
+ $ as a
499
515
  };
@@ -0,0 +1,3 @@
1
+ "use strict";var G=Object.create;var C=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var q=(c,t,n)=>t in c?C(c,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[t]=n;var H=(c,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of v(t))!j.call(c,s)&&s!==n&&C(c,s,{get:()=>t[s],enumerable:!(r=B(t,s))||r.enumerable});return c};var I=(c,t,n)=>(n=c!=null?G(W(c)):{},H(t||!c||!c.__esModule?C(n,"default",{value:c,enumerable:!0}):n,c));var p=(c,t,n)=>q(c,typeof t!="symbol"?t+"":t,n);const z=require("three/examples/jsm/loaders/GLTFLoader.js"),Y=require("three/examples/jsm/loaders/USDLoader.js"),J=require("./FileTypes-Ba65iQSJ.cjs"),w=require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const U=require("./isFileTypeSupported-Dx01kdxM.cjs"),R=require("./parse-error-Dy_EE4rL.cjs"),$=require("three/examples/jsm/loaders/DRACOLoader.js"),T=require("./AssetCache-5FgjqaKg.cjs");function N(){let c,t;onmessage=function(e){const o=e.data;switch(o.type){case"init":c=o.decoderConfig,t=new Promise(function(i){c.onModuleLoaded=function(_){i({draco:_})},DracoDecoderModule(c)});break;case"decode":const d=o.buffer,l=o.taskConfig;t.then(i=>{const _=i.draco,a=new _.Decoder;try{const u=n(_,a,new Int8Array(d),l),h=u.attributes.map(g=>g.array.buffer);u.index&&h.push(u.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:u},h)}catch(u){console.error(u),self.postMessage({type:"error",id:o.id,error:u.message})}finally{_.destroy(a)}});break}};function n(e,o,d,l){const i=l.attributeIDs,_=l.attributeTypes;let a,u;const h=o.GetEncodedGeometryType(d);if(h===e.TRIANGULAR_MESH)a=new e.Mesh,u=o.DecodeArrayToMesh(d,d.byteLength,a);else if(h===e.POINT_CLOUD)a=new e.PointCloud,u=o.DecodeArrayToPointCloud(d,d.byteLength,a);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||a.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());const g={index:null,attributes:[]};for(const A in i){const D=self[_[A]];let y,m;if(l.useUniqueIDs)m=i[A],y=o.GetAttributeByUniqueId(a,m);else{if(m=o.GetAttributeId(a,e[i[A]]),m===-1)continue;y=o.GetAttribute(a,m)}const E=s(e,o,a,A,D,y);A==="color"&&(E.vertexColorSpace=l.vertexColorSpace),g.attributes.push(E)}return h===e.TRIANGULAR_MESH&&(g.index=r(e,o,a)),e.destroy(a),g}function r(e,o,d){const i=d.num_faces()*3,_=i*4,a=e._malloc(_);o.GetTrianglesUInt32Array(d,_,a);const u=new Uint32Array(e.HEAPF32.buffer,a,i).slice();return e._free(a),{array:u,itemSize:1}}function s(e,o,d,l,i,_){const a=d.num_points(),u=_.num_components(),h=f(e,i),g=u*i.BYTES_PER_ELEMENT,A=Math.ceil(g/4)*4,D=A/i.BYTES_PER_ELEMENT,y=a*g,m=a*A,E=e._malloc(y);o.GetAttributeDataArrayForAllPoints(d,_,h,y,E);const O=new i(e.HEAPF32.buffer,E,y/i.BYTES_PER_ELEMENT);let L;if(g===A)L=O.slice();else{L=new i(m/i.BYTES_PER_ELEMENT);let M=0;for(let b=0,x=O.length;b<x;b+=u){for(let S=0;S<u;S++)L[M+S]=O[b+S];M+=D}}return e._free(E),{name:l,count:a,itemSize:u,array:L,stride:D}}function f(e,o){switch(o){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}}const P={LOAD_DRACO_JS_DECODER:async()=>(await import("three/examples/jsm/libs/draco/draco_decoder.js?raw")).default,LOAD_DRACO_WASM_WRAPPER:async()=>(await import("three/examples/jsm/libs/draco/draco_wasm_wrapper.js?raw")).default,LOAD_DRACO_WASM_DECODER:async()=>{const c=(await import("three/examples/jsm/libs/draco/draco_decoder.wasm?url")).default;return await(await fetch(c)).arrayBuffer()}};class k extends $.DRACOLoader{constructor(){super(...arguments);p(this,"decoderPending",null);p(this,"decoderConfig",{type:"js",wasmBinary:null});p(this,"workerSourceURL","")}async _initDecoder(){if(this.decoderPending)return this.decoderPending;const n=typeof WebAssembly!="object"||this.decoderConfig.type==="js",r=[];return n?r.push(P.LOAD_DRACO_JS_DECODER()):(r.push(P.LOAD_DRACO_WASM_WRAPPER()),r.push(P.LOAD_DRACO_WASM_DECODER())),this.decoderPending=Promise.all(r).then(s=>{const f=s[0];n||(this.decoderConfig.wasmBinary=s[1]);const e=N.toString(),o=["/* draco decoder */",f,"","/* worker */",e.substring(e.indexOf("{")+1,e.lastIndexOf("}"))].join(`
2
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}}function V(){let c=null,t=null;const n=[[/'CONFIG_CONTROL_DESIGN'\s*\)/g,"'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF')"],[/'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF\.\s*\{[\s\S]*?\}\s*'/g,"'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF'"]];function r(){return c||(c=occtimportjs({locateFile:function(){return t}})),c}function s(e){for(var o=new TextDecoder("utf-8",{fatal:!1}),d=new TextEncoder,l=o.decode(e),i=0;i<n.length;i++){var _=n[i][0],a=n[i][1];l=l.replace(_,a)}return new Uint8Array(d.encode(l))}function f(e,o){var d=s(o);try{var l=e.ReadStepFile(d,null);if(l.success&&l.root)return l}catch{}try{return e.ReadStepFile(o,null)}catch{return{success:!1,root:{meshes:[],children:[]},meshes:[]}}}onmessage=async function(e){var o=e.data;switch(o.type){case"init":t=o.wasmUrl;break;case"parse":try{var d=await r(),l=new Uint8Array(o.buffer),i=o.fileType,_;if(i==="step"||i==="stp"?_=f(d,l):_=d.ReadIgesFile(l,null),!_.success||!_.root){self.postMessage({type:"error",id:o.id,error:"Failed to parse CAD file"});return}self.postMessage({type:"result",id:o.id,result:_})}catch(a){self.postMessage({type:"error",id:o.id,error:a instanceof Error?a.message:String(a)})}break}}}const F={LOAD_OCCT_JS:async()=>(await Promise.resolve().then(()=>require("./occt-import-js-DdbbsFBH.cjs"))).default,LOAD_OCCT_WASM_URL:async()=>(await Promise.resolve().then(()=>require("./occt-import-js-BQ1yZHCj.cjs"))).default};class Z{constructor(){p(this,"_workerPending",null);p(this,"_worker",null);p(this,"_nextId",0);p(this,"_pending",new Map)}_getWorker(){return this._workerPending?this._workerPending:(this._workerPending=(async()=>{const[t,n]=await Promise.all([F.LOAD_OCCT_JS(),F.LOAD_OCCT_WASM_URL()]),r=V.toString(),s=["/* occt-import-js */",t,"","/* step worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
3
+ `),f=URL.createObjectURL(new Blob([s])),e=new Worker(f),o=new URL(n,window.location.href).href;return e.postMessage({type:"init",wasmUrl:o}),e.onmessage=d=>{const{type:l,id:i,result:_,error:a}=d.data,u=this._pending.get(i);if(u)if(this._pending.delete(i),l==="result")try{u.resolve(this._buildScene(_))}catch(h){u.reject(h instanceof Error?h:new Error(String(h)))}else u.reject(new Error(a??"Worker error"))},e.onerror=d=>{for(const[,{reject:l}]of this._pending)l(new Error(d.message??"Worker error"));this._pending.clear()},this._worker=e,e})(),this._workerPending)}async parseAsync(t,n){const r=this._nextId++,s=await this._getWorker();return new Promise((f,e)=>{this._pending.set(r,{resolve:f,reject:e});const o=t.slice(0);s.postMessage({type:"parse",id:r,buffer:o,fileType:n},[o])})}dispose(){if(this._worker){for(const[,{reject:t}]of this._pending)t(new Error("STEPLoader disposed"));this._pending.clear(),this._worker.terminate(),this._worker=null,this._workerPending=null}}_buildScene(t){const n=new w.Group;return n.name=t.root.name??"CAD Model",this._buildNode(t.root,t.meshes,n),n.rotation.x=-Math.PI/2,n.rotation.z=Math.PI/2,n}_buildNode(t,n,r){const s=new w.Group;s.name=t.name??"Part";for(const f of t.meshes){const e=n[f];if(e!=null&&e.attributes){const o=this._createMesh(e);s.add(o)}}for(const f of t.children)this._buildNode(f,n,s);r.add(s)}_createMesh(t){var l,i;const{position:n,normal:r}=t.attributes,s=t.index??t.attributes.index,f=new w.BufferGeometry;f.setAttribute("position",new w.BufferAttribute(new Float32Array(n.array),3)),(l=r==null?void 0:r.array)!=null&&l.length?f.setAttribute("normal",new w.BufferAttribute(new Float32Array(r.array),3)):f.computeVertexNormals(),(i=s==null?void 0:s.array)!=null&&i.length&&f.setIndex(new w.BufferAttribute(new Uint32Array(s.array),1));const e=t.color,o=new w.MeshStandardMaterial({metalness:.3,roughness:.6});e&&e.length>=3?o.color.setRGB(e[0],e[1],e[2]):o.color.setHex(13421772);const d=new w.Mesh(f,o);return d.name=t.name??"Mesh",d.castShadow=!0,d.receiveShadow=!0,d}}class K{constructor(){p(this,"_gltfLoader");p(this,"_usdLoader");p(this,"_stepLoader");const t=new k;t.setDecoderConfig({type:"wasm"}),this._gltfLoader=new z.GLTFLoader,this._gltfLoader.setDRACOLoader(t),this._usdLoader=new Y.USDLoader,this._stepLoader=new Z}async load(t,n){let r;if(n)r=n;else if(r=U.getFileTypeFromUri(t),r.length===0&&(r=await this._detectFileTypeFromContent(t),r.length===0))throw new R.FileTypeError("No file extension found in URI","");if(!U.isFileTypeSupported(r))throw new R.FileTypeError(`Unsupported file type: ${r}. Supported types: ${J.SUPPORTED_FILE_TYPES.join(", ")}`,r);const s=T.AssetCache.read(t);if(s)return s.arrayBuffer?this._parse(s.arrayBuffer,r):s.promise.then(o=>this._parse(o,r));const e=await T.AssetCache.create(t).load();return this._parse(e,r)}async _detectFileTypeFromContent(t){try{const n=T.AssetCache.read(t);let r;n?n.arrayBuffer?r=n.arrayBuffer:r=await n.promise:r=await T.AssetCache.create(t).load();const s=new Uint8Array(r);return s.length>=12&&String.fromCharCode(s[0],s[1],s[2],s[3])==="glTF"?s[12]===0?"glb":"gltf":s.length>=4&&s[0]===80&&s[1]===75&&(s[2]===3||s[2]===5)&&(s[3]===4||s[3]===6)?"usdz":s.length>=20&&new TextDecoder("ascii").decode(s.subarray(0,20)).startsWith("ISO-10303-21")?"step":s.length>=80&&s[72]===83?"iges":""}catch{return""}}async _parse(t,n){try{switch(n){case"glb":case"gltf":{const r=await this._gltfLoader.parseAsync(t,"");return r.scene.animations=r.animations,r.scene}case"usdz":{const r=this._usdLoader.parse(t);return r.animations=[],r}case"step":case"stp":{const r=await this._stepLoader.parseAsync(t,n);return r.animations=[],r}case"iges":case"igs":{const r=await this._stepLoader.parseAsync(t,n);return r.animations=[],r}}}catch(r){throw r instanceof Error?new R.ParseError(`Failed to parse ${n} file: ${r.message}`,r):new R.ParseError(`Failed to parse ${n} file`)}}}exports.AssetLoader=K;exports.DRACOWorker=N;exports.DracoLoader=k;
@@ -26,4 +26,4 @@
26
26
  @@%-::::::::::::-%@ @%-------------=%@@
27
27
  @@@@+:::::::#@@ @@*-------*@@@@
28
28
  @@@@@@@ @@@@@@
29
- `;window.DIVE={instances:[],get instance(){return window.DIVE.instances[0]}};const P={autoStart:!0,displayAxes:!1,...H,...a.DIVEPerspectiveCameraDefaultSettings,...K,...R};class nA{constructor(t){e(this,"_instanceId",g.MathUtils.generateUUID());e(this,"_settings");e(this,"_disposed",!1);e(this,"_views");e(this,"_mainView");e(this,"_scene");e(this,"_clock");e(this,"_orientationDisplay",null);this._settings={...P,...t??{}},this._clock=new O,this._scene=new V({backgroundColor:(t==null?void 0:t.backgroundColor)??P.backgroundColor,displayGrid:(t==null?void 0:t.displayGrid)??P.displayGrid,displayFloor:(t==null?void 0:t.displayFloor)??P.displayFloor});const A=new Z(this._scene,new a.DIVEPerspectiveCamera,this._settings);this._clock.addTicker(A),this._views=[A],this._mainView=A,this._settings.displayAxes&&Promise.resolve().then(()=>require("../plugins/orientationdisplay/index.cjs")).then(({OrientationDisplay:i})=>{this._disposed||(this._orientationDisplay=new i(this.mainView.renderer,this.scene,this.mainView.camera),this._clock.addTicker(this._orientationDisplay))}),console.log("DIVE 3.0.6 initialized successfully!"),console.log(sA),window.DIVE.instances.push(this),this._settings.autoStart&&this.start()}get views(){return this._views}get mainView(){return this._mainView}get canvas(){return this.mainView.canvas}get scene(){return this._scene}get clock(){return this._clock}start(){this.startAsync()}async startAsync(){this._disposed||(await this._clock.startAsync(),await this.mainView.initAsync())}stop(){this._clock.stop()}async disposeAsync(){return new Promise(t=>{if(this._disposed){t();return}this._disposed=!0,this._clock.dispose(),this._views.forEach(A=>{A.dispose()}),this._views=[],this._orientationDisplay&&(this._orientationDisplay.dispose(),this._orientationDisplay=null),this.scene.dispose(),window.DIVE.instances=window.DIVE.instances.filter(A=>A._instanceId!==this._instanceId),t()})}}const U={glb:{key:"glb",extension:"glb"},gltf:{key:"gltf",extension:"gltf"},usdz:{key:"usdz",extension:"usdz"},step:{key:"step",extension:"step"},stp:{key:"stp",extension:"stp"},iges:{key:"iges",extension:"iges"},igs:{key:"igs",extension:"igs"}},fA=Object.values(U).map(f=>f.extension);exports.BoundingBox=u;exports.DIVE=nA;exports.DIVEAbortablePromise=w;exports.DIVEAmbientLight=Q;exports.DIVECanvasLifecycleManager=E;exports.DIVEClock=O;exports.DIVEDefaultSettings=P;exports.DIVEDeferredPromise=j;exports.DIVEEnvironment=F;exports.DIVEEnvironmentDefaultSettings=L;exports.DIVEFloor=S;exports.DIVEGrid=p;exports.DIVEGroup=x;exports.DIVEModel=d;exports.DIVENode=G;exports.DIVEPointLight=W;exports.DIVEPrimitive=k;exports.DIVERenderer=X;exports.DIVERendererDefaultSettings=K;exports.DIVERoot=T;exports.DIVEScene=V;exports.DIVESceneDefaultSettings=H;exports.DIVESceneLight=N;exports.DIVEView=Z;exports.FILE_TYPES=U;exports.GRID_MAJOR_LINE_COLOR=_;exports.GRID_MINOR_LINE_COLOR=J;exports.OrbitController=l;exports.OrbitControllerDefaultSettings=R;exports.SUPPORTED_FILE_TYPES=fA;exports.findSceneRecursive=v;
29
+ `;window.DIVE={instances:[],get instance(){return window.DIVE.instances[0]}};const P={autoStart:!0,displayAxes:!1,...H,...a.DIVEPerspectiveCameraDefaultSettings,...K,...R};class nA{constructor(t){e(this,"_instanceId",g.MathUtils.generateUUID());e(this,"_settings");e(this,"_disposed",!1);e(this,"_views");e(this,"_mainView");e(this,"_scene");e(this,"_clock");e(this,"_orientationDisplay",null);this._settings={...P,...t??{}},this._clock=new O,this._scene=new V({backgroundColor:(t==null?void 0:t.backgroundColor)??P.backgroundColor,displayGrid:(t==null?void 0:t.displayGrid)??P.displayGrid,displayFloor:(t==null?void 0:t.displayFloor)??P.displayFloor});const A=new Z(this._scene,new a.DIVEPerspectiveCamera,this._settings);this._clock.addTicker(A),this._views=[A],this._mainView=A,this._settings.displayAxes&&Promise.resolve().then(()=>require("../plugins/orientationdisplay/index.cjs")).then(({OrientationDisplay:i})=>{this._disposed||(this._orientationDisplay=new i(this.mainView.renderer,this.scene,this.mainView.camera),this._clock.addTicker(this._orientationDisplay))}),console.log("DIVE 3.0.8 initialized successfully!"),console.log(sA),window.DIVE.instances.push(this),this._settings.autoStart&&this.start()}get views(){return this._views}get mainView(){return this._mainView}get canvas(){return this.mainView.canvas}get scene(){return this._scene}get clock(){return this._clock}start(){this.startAsync()}async startAsync(){this._disposed||(await this._clock.startAsync(),await this.mainView.initAsync())}stop(){this._clock.stop()}async disposeAsync(){return new Promise(t=>{if(this._disposed){t();return}this._disposed=!0,this._clock.dispose(),this._views.forEach(A=>{A.dispose()}),this._views=[],this._orientationDisplay&&(this._orientationDisplay.dispose(),this._orientationDisplay=null),this.scene.dispose(),window.DIVE.instances=window.DIVE.instances.filter(A=>A._instanceId!==this._instanceId),t()})}}const U={glb:{key:"glb",extension:"glb"},gltf:{key:"gltf",extension:"gltf"},usdz:{key:"usdz",extension:"usdz"},step:{key:"step",extension:"step"},stp:{key:"stp",extension:"stp"},iges:{key:"iges",extension:"iges"},igs:{key:"igs",extension:"igs"}},fA=Object.values(U).map(f=>f.extension);exports.BoundingBox=u;exports.DIVE=nA;exports.DIVEAbortablePromise=w;exports.DIVEAmbientLight=Q;exports.DIVECanvasLifecycleManager=E;exports.DIVEClock=O;exports.DIVEDefaultSettings=P;exports.DIVEDeferredPromise=j;exports.DIVEEnvironment=F;exports.DIVEEnvironmentDefaultSettings=L;exports.DIVEFloor=S;exports.DIVEGrid=p;exports.DIVEGroup=x;exports.DIVEModel=d;exports.DIVENode=G;exports.DIVEPointLight=W;exports.DIVEPrimitive=k;exports.DIVERenderer=X;exports.DIVERendererDefaultSettings=K;exports.DIVERoot=T;exports.DIVEScene=V;exports.DIVESceneDefaultSettings=H;exports.DIVESceneLight=N;exports.DIVEView=Z;exports.FILE_TYPES=U;exports.GRID_MAJOR_LINE_COLOR=_;exports.GRID_MINOR_LINE_COLOR=J;exports.OrbitController=l;exports.OrbitControllerDefaultSettings=R;exports.SUPPORTED_FILE_TYPES=fA;exports.findSceneRecursive=v;
@@ -2000,7 +2000,7 @@ class ai {
2000
2000
  ), this._clock.addTicker(this._orientationDisplay));
2001
2001
  }
2002
2002
  ), console.log(
2003
- "DIVE 3.0.6 initialized successfully!"
2003
+ "DIVE 3.0.8 initialized successfully!"
2004
2004
  ), console.log(ei), window.DIVE.instances.push(this), this._settings.autoStart && this.start();
2005
2005
  }
2006
2006
  get views() {
@@ -1,4 +1,4 @@
1
- import { F as n } from "./FileTypes-DLAWiGQa.mjs";
1
+ import { F as n } from "./FileTypes-Ck6z0LqE.mjs";
2
2
  function r(e) {
3
3
  var i;
4
4
  const t = e.split("/").pop() || "";
@@ -1 +1 @@
1
- "use strict";const n=require("./FileTypes-IZ9BrQ2x.cjs");function o(e){var t;const i=e.split("/").pop()||"";return!i.includes(".")||i.endsWith(".")?"":((t=i.split(".").pop())==null?void 0:t.toLowerCase().split("?")[0])||""}function r(e){return e.toLowerCase()in n.FILE_TYPES}exports.getFileTypeFromUri=o;exports.isFileTypeSupported=r;
1
+ "use strict";const n=require("./FileTypes-Ba65iQSJ.cjs");function o(e){var t;const i=e.split("/").pop()||"";return!i.includes(".")||i.endsWith(".")?"":((t=i.split(".").pop())==null?void 0:t.toLowerCase().split("?")[0])||""}function r(e){return e.toLowerCase()in n.FILE_TYPES}exports.getFileTypeFromUri=o;exports.isFileTypeSupported=r;
package/build/dive.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var O=(r,i,e)=>i in r?b(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-IZ9BrQ2x.cjs"),u=require("./chunks/PerspectiveCamera-DwQUmkDv.cjs"),_=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),s=require("three/webgpu"),V=require("./chunks/findInterface-C6mrvf_t.cjs"),y=require("./chunks/isFileTypeSupported-dgHlqizJ.cjs"),w=require("./chunks/network-error-CdDXil5g.cjs"),A=require("./chunks/parse-error-Dy_EE4rL.cjs"),P=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 R(r,i=0){const e=p(r,+i);return p(Math.ceil(e),-i)}function v(r,i=0){const e=p(r,+i);return p(Math.floor(e),-i)}function x(r,i=0){if(r<0)return-x(-r,i);const e=p(r,+i);return p(Math.round(e),-i)}function H(r,i,e){return Math.atan2(r.clone().cross(i).dot(e),i.clone().dot(r))}function G(r,i=0){const e=p(r,+i);return p(Math.round(e),-i).toFixed(i)}function z(r,i=0){const e=p(r,+i);return p(Math.trunc(e),-i)}function L(r){return(s.MathUtils.radToDeg(r)+360)%360}function C(r){return s.MathUtils.degToRad(r)}const S={ceilExp:R,floorExp:v,roundExp:x,toFixedExp:G,truncateExp:z,signedAngleTo:H,radToDeg:L,degToRad:C};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=S.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 T 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 j 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 N 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 F 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 T(e),this._rotateGizmo=new Y(e),this._scaleGizmo=new j(e),this._gizmoPlane=new N,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 U{constructor(){n(this,"isMovable",!0)}}class K{constructor(){n(this,"isSelectable",!0)}}function X(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 q(r){return r.entityType==="group"}function B(r){return r.entityType==="light"}function Z(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.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=V.findInterface;exports.implementsInterface=V.implementsInterface;exports.getFileTypeFromUri=y.getFileTypeFromUri;exports.isFileTypeSupported=y.isFileTypeSupported;exports.FileContentError=w.FileContentError;exports.NetworkError=w.NetworkError;exports.FileTypeError=A.FileTypeError;exports.ParseError=A.ParseError;exports.isModelSchema=P.isModelSchema;exports.isPovSchema=P.isPovSchema;exports.DIVEGizmo=F;exports.DIVEMath=S;exports.DIVEMovable=U;exports.DIVESelectable=K;exports.applyMixins=X;exports.deepClone=f;exports.getObjectDelta=I;exports.isGroupSchema=q;exports.isLightSchema=B;exports.isPrimitiveSchema=Z;
1
+ "use strict";var b=Object.defineProperty;var O=(r,i,e)=>i in r?b(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-Ba65iQSJ.cjs"),u=require("./chunks/PerspectiveCamera-DwQUmkDv.cjs"),_=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),s=require("three/webgpu"),V=require("./chunks/findInterface-C6mrvf_t.cjs"),y=require("./chunks/isFileTypeSupported-Dx01kdxM.cjs"),w=require("./chunks/network-error-CdDXil5g.cjs"),A=require("./chunks/parse-error-Dy_EE4rL.cjs"),P=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 R(r,i=0){const e=p(r,+i);return p(Math.ceil(e),-i)}function v(r,i=0){const e=p(r,+i);return p(Math.floor(e),-i)}function x(r,i=0){if(r<0)return-x(-r,i);const e=p(r,+i);return p(Math.round(e),-i)}function H(r,i,e){return Math.atan2(r.clone().cross(i).dot(e),i.clone().dot(r))}function G(r,i=0){const e=p(r,+i);return p(Math.round(e),-i).toFixed(i)}function z(r,i=0){const e=p(r,+i);return p(Math.trunc(e),-i)}function L(r){return(s.MathUtils.radToDeg(r)+360)%360}function C(r){return s.MathUtils.degToRad(r)}const S={ceilExp:R,floorExp:v,roundExp:x,toFixedExp:G,truncateExp:z,signedAngleTo:H,radToDeg:L,degToRad:C};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=S.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 T 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 j 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 N 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 F 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 T(e),this._rotateGizmo=new Y(e),this._scaleGizmo=new j(e),this._gizmoPlane=new N,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 U{constructor(){n(this,"isMovable",!0)}}class K{constructor(){n(this,"isSelectable",!0)}}function X(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 q(r){return r.entityType==="group"}function B(r){return r.entityType==="light"}function Z(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.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=V.findInterface;exports.implementsInterface=V.implementsInterface;exports.getFileTypeFromUri=y.getFileTypeFromUri;exports.isFileTypeSupported=y.isFileTypeSupported;exports.FileContentError=w.FileContentError;exports.NetworkError=w.NetworkError;exports.FileTypeError=A.FileTypeError;exports.ParseError=A.ParseError;exports.isModelSchema=P.isModelSchema;exports.isPovSchema=P.isPovSchema;exports.DIVEGizmo=F;exports.DIVEMath=S;exports.DIVEMovable=U;exports.DIVESelectable=K;exports.applyMixins=X;exports.deepClone=f;exports.getObjectDelta=I;exports.isGroupSchema=q;exports.isLightSchema=B;exports.isPrimitiveSchema=Z;
package/build/dive.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  var S = Object.defineProperty;
2
2
  var A = (r, s, t) => s in r ? S(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
3
3
  var i = (r, s, t) => A(r, typeof s != "symbol" ? s + "" : s, t);
4
- import { B as ot, b as ht, d as lt, e as ct, f as dt, g as pt, D as ut, h as ft, i as _t, j as gt, k as mt, l as Dt, m as Et, c as yt, n as wt, o as Mt, p as xt, q as It, r as Pt, s as Vt, t as bt, u as Ht, v as vt, w as zt, F as Ot, G as St, x as At, S as Gt, y as Rt } from "./chunks/FileTypes-DLAWiGQa.mjs";
4
+ import { B as ot, b as ht, d as lt, e as ct, f as dt, g as pt, D as ut, h as ft, i as _t, j as gt, k as mt, l as Dt, m as Et, c as yt, n as wt, o as Mt, p as xt, q as It, r as Pt, s as Vt, t as bt, u as Ht, v as vt, w as zt, F as Ot, G as St, x as At, S as Gt, y as Rt } from "./chunks/FileTypes-Ck6z0LqE.mjs";
5
5
  import { U as d } from "./chunks/PerspectiveCamera-35cBnxwG.mjs";
6
6
  import { C as Yt, a as jt, D as Lt, b as Ct, H as Nt, P as Xt } from "./chunks/PerspectiveCamera-35cBnxwG.mjs";
7
7
  import { A as I, a as P, b as V } from "./chunks/AxisHelperColors-JLBHYQDi.mjs";
8
8
  import { e as Zt, d as qt, c as Qt } from "./chunks/AxisHelperColors-JLBHYQDi.mjs";
9
9
  import { Object3D as f, Color as b, Vector3 as c, TorusGeometry as H, MeshBasicMaterial as g, Mesh as p, MathUtils as z, Euler as G, CylinderGeometry as D, BoxGeometry as R, PlaneGeometry as y } from "three/webgpu";
10
10
  import { f as kt, i as Ut } from "./chunks/findInterface-DbJ5qzbc.mjs";
11
- import { g as Kt, i as Jt } from "./chunks/isFileTypeSupported-D7Sy7zU-.mjs";
11
+ import { g as Kt, i as Jt } from "./chunks/isFileTypeSupported-DPjSWSnx.mjs";
12
12
  import { F as te, N as ee } from "./chunks/network-error-BONfHWQq.mjs";
13
13
  import { F as se, P as ie } from "./chunks/parse-error-DfOPyLWM.mjs";
14
14
  import { i as ae, a as oe } from "./chunks/PovSchema-DWWvr_ED.mjs";
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var h=(o,e,r)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var l=(o,e,r)=>h(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../systeminfo/index.cjs"),A=require("../assetconverter/index.cjs"),O=require("../../chunks/AssetLoader-NuQXJfHL.cjs");require("three/examples/jsm/loaders/DRACOLoader.js");const w=require("../../chunks/AssetExporter-Cdxb04b3.cjs");var m=(o=>(o.AR_DESKTOP_PLATFORM_ERROR="ar-desktop-platform-error",o.AR_QUICK_LOOK_NOT_SAFARI_ERROR="ar-quicklook-not-safari-error",o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR="ar-quicklook-version-mismatch-error",o.AR_QUICK_LOOK_UNKNOWN_ERROR="ar-quicklook-unknown-error",o))(m||{});class a extends Error{constructor(r,t){super(r);l(this,"type");this.name=this.constructor.name,this.type=t,Object.setPrototypeOf(this,new.target.prototype)}}class R extends a{constructor(){super("AR features are not supported on desktop platforms.","ar-desktop-platform-error")}}class p extends a{constructor(){super("ARQuickLook on iOS is only available in Safari.","ar-quicklook-not-safari-error")}}class d extends a{constructor(e,r){super(`ARQuickLook requires iOS version ${r} or later. Current version: ${e}.`,"ar-quicklook-version-mismatch-error"),this.currentVersion=e,this.requiredVersion=r}}class u extends a{constructor(){super("An unknown ARQuickLook compatibility error occurred.","ar-quicklook-unknown-error")}}const k=12;class S{constructor(){l(this,"converter",new A.AssetConverter(new O.AssetLoader,new w.AssetExporter))}async launch(e,r){if(c.SystemInfo.getBrowser()!==c.EBrowser.SAFARI)return Promise.reject(new p);const t=c.SystemInfo.getIOSVersion();if(t&&t.major<k)return Promise.reject(new d(t.full,k));if(!t)return Promise.reject(new u);if(!c.SystemInfo.getSupportsARQuickLook())return Promise.reject(new u);const n=await this.convertToUSDZ(e,r);return this.launchARQuickLook(n,r)}async convertToUSDZ(e,r){const t=await this.converter.convert(e).to("usdz",{quickLookCompatible:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}}}),n=new Blob([t],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(n)}launchARQuickLook(e,r){return new Promise(t=>{(r==null?void 0:r.arScale)==="fixed"&&(e=e.concat("#allowsContentScaling=0"));const n=document.createElement("a");n.innerHTML="<picture></picture>",n.rel="ar",n.href=e,n.download="scene.usdz",t(),n.click()})}}class _{launch(e,r){const t=self.location.toString(),n=document.createElement("a"),s=this._createParams(t,e,r),i=this._createIntent(t,e,s);n.setAttribute("href",i),n.click()}_createParams(e,r,t){const n=new URL(r,e),s=new URLSearchParams(n.search);return s.set("mode","ar_preferred"),this._applyScaleOption(s,t),this._applyPlacementOption(s,t),this._applySoundOption(s,e),this._applyLinkOption(s,e),s}_applyScaleOption(e,r){(r==null?void 0:r.arScale)==="fixed"&&e.set("resizable","false")}_applyPlacementOption(e,r){(r==null?void 0:r.arPlacement)==="vertical"&&e.set("enable_vertical_placement","true")}_applySoundOption(e,r){if(e.has("sound")){const t=new URL(e.get("sound"),r);e.set("sound",t.toString())}}_applyLinkOption(e,r){if(e.has("link")){const t=new URL(e.get("link"),r);e.set("link",t.toString())}}_createIntent(e,r,t){const n=new URL(e),s=new URL(r,e),i="#model-viewer-no-ar-fallback";return n.hash=i,`intent://arvr.google.com/scene-viewer/1.2?${t.toString()+"&file="+s.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(n.toString())};end;`}}class L{async launch(e,r){const t=c.SystemInfo.getSystem();return t===c.ESystem.IOS?new S().launch(e,r):t===c.ESystem.ANDROID?new _().launch(e,r):Promise.reject(new R)}}exports.ARDesktopPlatformError=R;exports.ARError=a;exports.ARQuickLook=S;exports.ARQuickLookNotSafariError=p;exports.ARQuickLookUnknownError=u;exports.ARQuickLookVersionMismatchError=d;exports.ARSystem=L;exports.EARErrorType=m;exports.SceneViewer=_;
1
+ "use strict";var f=Object.defineProperty;var h=(o,e,r)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var l=(o,e,r)=>h(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../systeminfo/index.cjs"),A=require("../assetconverter/index.cjs"),O=require("../../chunks/AssetLoader-Dp_S2z9P.cjs");require("three/examples/jsm/loaders/DRACOLoader.js");const w=require("../../chunks/AssetExporter-Cdxb04b3.cjs");var m=(o=>(o.AR_DESKTOP_PLATFORM_ERROR="ar-desktop-platform-error",o.AR_QUICK_LOOK_NOT_SAFARI_ERROR="ar-quicklook-not-safari-error",o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR="ar-quicklook-version-mismatch-error",o.AR_QUICK_LOOK_UNKNOWN_ERROR="ar-quicklook-unknown-error",o))(m||{});class a extends Error{constructor(r,t){super(r);l(this,"type");this.name=this.constructor.name,this.type=t,Object.setPrototypeOf(this,new.target.prototype)}}class R extends a{constructor(){super("AR features are not supported on desktop platforms.","ar-desktop-platform-error")}}class p extends a{constructor(){super("ARQuickLook on iOS is only available in Safari.","ar-quicklook-not-safari-error")}}class d extends a{constructor(e,r){super(`ARQuickLook requires iOS version ${r} or later. Current version: ${e}.`,"ar-quicklook-version-mismatch-error"),this.currentVersion=e,this.requiredVersion=r}}class u extends a{constructor(){super("An unknown ARQuickLook compatibility error occurred.","ar-quicklook-unknown-error")}}const k=12;class S{constructor(){l(this,"converter",new A.AssetConverter(new O.AssetLoader,new w.AssetExporter))}async launch(e,r){if(c.SystemInfo.getBrowser()!==c.EBrowser.SAFARI)return Promise.reject(new p);const t=c.SystemInfo.getIOSVersion();if(t&&t.major<k)return Promise.reject(new d(t.full,k));if(!t)return Promise.reject(new u);if(!c.SystemInfo.getSupportsARQuickLook())return Promise.reject(new u);const n=await this.convertToUSDZ(e,r);return this.launchARQuickLook(n,r)}async convertToUSDZ(e,r){const t=await this.converter.convert(e).to("usdz",{quickLookCompatible:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}}}),n=new Blob([t],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(n)}launchARQuickLook(e,r){return new Promise(t=>{(r==null?void 0:r.arScale)==="fixed"&&(e=e.concat("#allowsContentScaling=0"));const n=document.createElement("a");n.innerHTML="<picture></picture>",n.rel="ar",n.href=e,n.download="scene.usdz",t(),n.click()})}}class _{launch(e,r){const t=self.location.toString(),n=document.createElement("a"),s=this._createParams(t,e,r),i=this._createIntent(t,e,s);n.setAttribute("href",i),n.click()}_createParams(e,r,t){const n=new URL(r,e),s=new URLSearchParams(n.search);return s.set("mode","ar_preferred"),this._applyScaleOption(s,t),this._applyPlacementOption(s,t),this._applySoundOption(s,e),this._applyLinkOption(s,e),s}_applyScaleOption(e,r){(r==null?void 0:r.arScale)==="fixed"&&e.set("resizable","false")}_applyPlacementOption(e,r){(r==null?void 0:r.arPlacement)==="vertical"&&e.set("enable_vertical_placement","true")}_applySoundOption(e,r){if(e.has("sound")){const t=new URL(e.get("sound"),r);e.set("sound",t.toString())}}_applyLinkOption(e,r){if(e.has("link")){const t=new URL(e.get("link"),r);e.set("link",t.toString())}}_createIntent(e,r,t){const n=new URL(e),s=new URL(r,e),i="#model-viewer-no-ar-fallback";return n.hash=i,`intent://arvr.google.com/scene-viewer/1.2?${t.toString()+"&file="+s.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(n.toString())};end;`}}class L{async launch(e,r){const t=c.SystemInfo.getSystem();return t===c.ESystem.IOS?new S().launch(e,r):t===c.ESystem.ANDROID?new _().launch(e,r):Promise.reject(new R)}}exports.ARDesktopPlatformError=R;exports.ARError=a;exports.ARQuickLook=S;exports.ARQuickLookNotSafariError=p;exports.ARQuickLookUnknownError=u;exports.ARQuickLookVersionMismatchError=d;exports.ARSystem=L;exports.EARErrorType=m;exports.SceneViewer=_;
@@ -3,7 +3,7 @@ var R = (o, e, r) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writab
3
3
  var l = (o, e, r) => R(o, typeof e != "symbol" ? e + "" : e, r);
4
4
  import { SystemInfo as c, EBrowser as d, ESystem as u } from "../systeminfo/index.mjs";
5
5
  import { AssetConverter as h } from "../assetconverter/index.mjs";
6
- import { A as _ } from "../../chunks/AssetLoader-IE1YVWYL.mjs";
6
+ import { A as _ } from "../../chunks/AssetLoader-BeP0hkJD.mjs";
7
7
  import "three/examples/jsm/loaders/DRACOLoader.js";
8
8
  import { A as f } from "../../chunks/AssetExporter-DLL_vJae.mjs";
9
9
  var S = /* @__PURE__ */ ((o) => (o.AR_DESKTOP_PLATFORM_ERROR = "ar-desktop-platform-error", o.AR_QUICK_LOOK_NOT_SAFARI_ERROR = "ar-quicklook-not-safari-error", o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR = "ar-quicklook-version-mismatch-error", o.AR_QUICK_LOOK_UNKNOWN_ERROR = "ar-quicklook-unknown-error", o))(S || {});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetCache-hZPj76ce.cjs");exports.AssetCache=e.AssetCache;exports.Chunk=e.Chunk;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetCache-5FgjqaKg.cjs");exports.AssetCache=e.AssetCache;exports.Chunk=e.Chunk;
@@ -1,4 +1,4 @@
1
- import { A as e, C } from "../../chunks/AssetCache-kR5gKTDf.mjs";
1
+ import { A as e, C } from "../../chunks/AssetCache-w3B0LIUw.mjs";
2
2
  export {
3
3
  e as AssetCache,
4
4
  C as Chunk
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetLoader-NuQXJfHL.cjs");exports.AssetLoader=e.AssetLoader;exports.DRACOWorker=e.DRACOWorker;exports.DracoLoader=e.DracoLoader;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetLoader-Dp_S2z9P.cjs");exports.AssetLoader=e.AssetLoader;exports.DRACOWorker=e.DRACOWorker;exports.DracoLoader=e.DracoLoader;
@@ -1,5 +1,5 @@
1
- import { A as o } from "../../chunks/AssetLoader-IE1YVWYL.mjs";
2
- import { D as s, a as t } from "../../chunks/AssetLoader-IE1YVWYL.mjs";
1
+ import { A as o } from "../../chunks/AssetLoader-BeP0hkJD.mjs";
2
+ import { D as s, a as t } from "../../chunks/AssetLoader-BeP0hkJD.mjs";
3
3
  export {
4
4
  o as AssetLoader,
5
5
  s as DRACOWorker,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-IZ9BrQ2x.cjs");exports.OrbitController=t.OrbitController;exports.OrbitControllerDefaultSettings=t.OrbitControllerDefaultSettings;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-Ba65iQSJ.cjs");exports.OrbitController=t.OrbitController;exports.OrbitControllerDefaultSettings=t.OrbitControllerDefaultSettings;
@@ -1,4 +1,4 @@
1
- import { O as o, a as e } from "../../chunks/FileTypes-DLAWiGQa.mjs";
1
+ import { O as o, a as e } from "../../chunks/FileTypes-Ck6z0LqE.mjs";
2
2
  export {
3
3
  o as OrbitController,
4
4
  e as OrbitControllerDefaultSettings
@@ -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-IZ9BrQ2x.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 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-Ba65iQSJ.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;
@@ -2,7 +2,7 @@ var p = Object.defineProperty;
2
2
  var _ = (t, r, e) => r in t ? p(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
3
3
  var i = (t, r, e) => _(t, typeof r != "symbol" ? r + "" : r, e);
4
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-DLAWiGQa.mjs";
5
+ import "../../chunks/FileTypes-Ck6z0LqE.mjs";
6
6
  import { C as o } from "../../chunks/PerspectiveCamera-35cBnxwG.mjs";
7
7
  import "three/examples/jsm/loaders/HDRLoader.js";
8
8
  import "three/tsl";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../chunks/FileTypes-IZ9BrQ2x.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 a=require("../../chunks/FileTypes-Ba65iQSJ.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,4 +1,4 @@
1
- import { D as n, b as r, c as l, O as m } from "../../chunks/FileTypes-DLAWiGQa.mjs";
1
+ import { D as n, b as r, c as l, O as m } from "../../chunks/FileTypes-Ck6z0LqE.mjs";
2
2
  import "three/webgpu";
3
3
  import "three/examples/jsm/loaders/HDRLoader.js";
4
4
  import "three/tsl";
@@ -1,4 +1,4 @@
1
- "use strict";var $d=Object.defineProperty;var Hd=(d,g,o)=>g in d?$d(d,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):d[g]=o;var rn=(d,g,o)=>Hd(d,typeof g!="symbol"?g+"":g,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qd=require("three/webgpu"),zd=require("../../chunks/FileTypes-IZ9BrQ2x.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const Mi=require("../../chunks/PovSchema-Co9FznEz.cjs"),Ao={};function G(d,g){Ao[d]=g}function xo(d){return Ao[d]}class F{constructor(g,o){rn(this,"_payload");rn(this,"_dependencies");this._payload=g,this._dependencies=o}static define({description:g,execute:o}){return class extends F{constructor(m,N){super(m,N);rn(this,"_description",g);rn(this,"_payload");this._payload=m}execute(){return o(this._payload,this._dependencies)}}}}const mo=F.define({description:"Launches AR mode in native capabilities. (iOS: AR Quick Look, Android: Google Scene Viewer)",execute:async(d,{getARSystem:g})=>g().then(o=>{o.launch(d.uri,d.options)})});G("LAUNCH_AR",mo);const Eo=F.define({description:"Calculates the camera position and target to view the whole scene. (experimental).",execute:(d,{engine:g,controller:o})=>{const S=new zd.BoundingBox(g.scene.root,!1,65280);return o.computeEncompassingView(S)}});G("COMPUTE_ENCOMPASSING_VIEW",Eo);const So=F.define({description:"Gets the current camera position and target.",execute:(d,{controller:g})=>({position:g.object.position.clone(),target:g.target.clone()})});G("GET_CAMERA_TRANSFORM",So);const bo=F.define({description:"Moves the camera to a new position and target.",execute:async(d,{controller:g,registered:o,getAnimationSystem:S,engine:m})=>{const N=await S();let q={x:0,y:0,z:0},un={x:0,y:0,z:0};if("id"in d){const Gn=o.get(d.id);if(!Gn)throw new Error(`POV with id ${d.id} not registered. Registered: ${o}`);if(!Mi.isPovSchema(Gn))throw new Error(`Object with id ${d.id} is not a POV. Object: ${Gn}`);q=Gn.position,un=Gn.target}else q=d.position,un=d.target;m.clock.hasTicker(N)||m.clock.addTicker(N),g.enabled=!0;const jn=await N.fromTargets([{object:g.object.position,to:q},{object:g.target,to:un}],d.duration,{easing:N.Easing.Quadratic.Out,onUpdate:()=>{g.object.lookAt(g.target)},onComplete:()=>{g.enabled=!d.locked}});return jn.play(),{stop:()=>jn.stop()}}});G("MOVE_CAMERA",bo);const Oo=F.define({description:"Sets the camera layer to a certain layer.",execute:(d,{controller:g})=>{"setCameraLayer"in g.object&&g.object.setCameraLayer(d.layer)}});G("SET_CAMERA_LAYER",Oo);const To=F.define({description:"Sets the camera position and target.",execute:(d,{controller:g})=>{g.object.position.copy(d.position),g.target.copy(d.target),g.update()}});G("SET_CAMERA_TRANSFORM",To);const Co=F.define({description:"Zooms the camera in or out by a certain amount.",execute:(d,{controller:g})=>{d.direction==="IN"&&g.zoomIn(d.by),d.direction==="OUT"&&g.zoomOut(d.by)}});G("ZOOM_CAMERA",Co);const Ro=F.define({description:"Generates a screenshot, stores it in a Blob and returns a Promise of a valid URI.",execute:async(d,{registered:g,getMediaCreator:o})=>{const S=await o();if("id"in d){const m=g.get(d.id);if(!m)throw new Error(`Object with id ${d.id} not registered. Registered: ${g}`);if(!Mi.isPovSchema(m))throw new Error(`Object with id ${d.id} is not a POV. Object: ${m}`);const{resolution:N}=d,{position:q,target:un}=m;return S.generateMedia({position:q,target:un,resolution:N})}return S.generateMedia(d)}});G("GENERATE_MEDIA",Ro);const Io=F.define({description:"Adds an object to the scene.",execute:(d,{engine:g,registered:o})=>{o.get(d.id)||(d.parentId===void 0&&(d.parentId=null),o.set(d.id,d),g.scene.root.addSceneObject(d))}});G("ADD_OBJECT",Io);var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},lt={exports:{}};/**
1
+ "use strict";var $d=Object.defineProperty;var Hd=(d,g,o)=>g in d?$d(d,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):d[g]=o;var rn=(d,g,o)=>Hd(d,typeof g!="symbol"?g+"":g,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qd=require("three/webgpu"),zd=require("../../chunks/FileTypes-Ba65iQSJ.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const Mi=require("../../chunks/PovSchema-Co9FznEz.cjs"),Ao={};function G(d,g){Ao[d]=g}function xo(d){return Ao[d]}class F{constructor(g,o){rn(this,"_payload");rn(this,"_dependencies");this._payload=g,this._dependencies=o}static define({description:g,execute:o}){return class extends F{constructor(m,N){super(m,N);rn(this,"_description",g);rn(this,"_payload");this._payload=m}execute(){return o(this._payload,this._dependencies)}}}}const mo=F.define({description:"Launches AR mode in native capabilities. (iOS: AR Quick Look, Android: Google Scene Viewer)",execute:async(d,{getARSystem:g})=>g().then(o=>{o.launch(d.uri,d.options)})});G("LAUNCH_AR",mo);const Eo=F.define({description:"Calculates the camera position and target to view the whole scene. (experimental).",execute:(d,{engine:g,controller:o})=>{const S=new zd.BoundingBox(g.scene.root,!1,65280);return o.computeEncompassingView(S)}});G("COMPUTE_ENCOMPASSING_VIEW",Eo);const So=F.define({description:"Gets the current camera position and target.",execute:(d,{controller:g})=>({position:g.object.position.clone(),target:g.target.clone()})});G("GET_CAMERA_TRANSFORM",So);const bo=F.define({description:"Moves the camera to a new position and target.",execute:async(d,{controller:g,registered:o,getAnimationSystem:S,engine:m})=>{const N=await S();let q={x:0,y:0,z:0},un={x:0,y:0,z:0};if("id"in d){const Gn=o.get(d.id);if(!Gn)throw new Error(`POV with id ${d.id} not registered. Registered: ${o}`);if(!Mi.isPovSchema(Gn))throw new Error(`Object with id ${d.id} is not a POV. Object: ${Gn}`);q=Gn.position,un=Gn.target}else q=d.position,un=d.target;m.clock.hasTicker(N)||m.clock.addTicker(N),g.enabled=!0;const jn=await N.fromTargets([{object:g.object.position,to:q},{object:g.target,to:un}],d.duration,{easing:N.Easing.Quadratic.Out,onUpdate:()=>{g.object.lookAt(g.target)},onComplete:()=>{g.enabled=!d.locked}});return jn.play(),{stop:()=>jn.stop()}}});G("MOVE_CAMERA",bo);const Oo=F.define({description:"Sets the camera layer to a certain layer.",execute:(d,{controller:g})=>{"setCameraLayer"in g.object&&g.object.setCameraLayer(d.layer)}});G("SET_CAMERA_LAYER",Oo);const To=F.define({description:"Sets the camera position and target.",execute:(d,{controller:g})=>{g.object.position.copy(d.position),g.target.copy(d.target),g.update()}});G("SET_CAMERA_TRANSFORM",To);const Co=F.define({description:"Zooms the camera in or out by a certain amount.",execute:(d,{controller:g})=>{d.direction==="IN"&&g.zoomIn(d.by),d.direction==="OUT"&&g.zoomOut(d.by)}});G("ZOOM_CAMERA",Co);const Ro=F.define({description:"Generates a screenshot, stores it in a Blob and returns a Promise of a valid URI.",execute:async(d,{registered:g,getMediaCreator:o})=>{const S=await o();if("id"in d){const m=g.get(d.id);if(!m)throw new Error(`Object with id ${d.id} not registered. Registered: ${g}`);if(!Mi.isPovSchema(m))throw new Error(`Object with id ${d.id} is not a POV. Object: ${m}`);const{resolution:N}=d,{position:q,target:un}=m;return S.generateMedia({position:q,target:un,resolution:N})}return S.generateMedia(d)}});G("GENERATE_MEDIA",Ro);const Io=F.define({description:"Adds an object to the scene.",execute:(d,{engine:g,registered:o})=>{o.get(d.id)||(d.parentId===void 0&&(d.parentId=null),o.set(d.id,d),g.scene.root.addSceneObject(d))}});G("ADD_OBJECT",Io);var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},lt={exports:{}};/**
2
2
  * @license
3
3
  * Lodash <https://lodash.com/>
4
4
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
@@ -2,7 +2,7 @@ var _p = Object.defineProperty;
2
2
  var pp = (p, g, o) => g in p ? _p(p, g, { enumerable: !0, configurable: !0, writable: !0, value: o }) : p[g] = o;
3
3
  var rn = (p, g, o) => pp(p, typeof g != "symbol" ? g + "" : g, o);
4
4
  import { MathUtils as dp } from "three/webgpu";
5
- import { B as vp } from "../../chunks/FileTypes-DLAWiGQa.mjs";
5
+ import { B as vp } from "../../chunks/FileTypes-Ck6z0LqE.mjs";
6
6
  import "three/examples/jsm/loaders/HDRLoader.js";
7
7
  import "three/tsl";
8
8
  import { a as vo, i as wp } from "../../chunks/PovSchema-DWWvr_ED.mjs";
@@ -1 +1 @@
1
- "use strict";var y=Object.defineProperty;var S=(n,t,e)=>t in n?y(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>S(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("three/webgpu");require("../../chunks/FileTypes-IZ9BrQ2x.cjs");const h=require("../../chunks/PerspectiveCamera-DwQUmkDv.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const _=require("../../chunks/findInterface-C6mrvf_t.cjs"),T=require("three/examples/jsm/controls/TransformControls.js"),d=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class m{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(t){var e,s,i;this._selected!==t&&(this._selected&&((s=(e=this._selected).onDeselect)==null||s.call(e)),this._selected=t,(i=t.onSelect)==null||i.call(t),this.notifyListeners())}deselect(){var t,e;this._selected&&((e=(t=this._selected).onDeselect)==null||e.call(t),this._selected=null,this.notifyListeners())}onChange(t){this._listeners.add(t)}offChange(t){this._listeners.delete(t)}dispose(){this._selected=null,this._listeners.clear()}notifyListeners(){for(const t of this._listeners)t(this._selected)}}class b{constructor(){r(this,"name","hover");r(this,"priority",20);r(this,"_hovered",null)}get hovered(){return this._hovered}onActivate(){this._hovered=null}onDeactivate(){var t,e;this._hovered&&((e=(t=this._hovered).onPointerLeave)==null||e.call(t),this._hovered=null)}onPointerMove(t){var i,o,a,l,p,f,v;const e=t.modelIntersects[0],s=_.findInterface(e==null?void 0:e.object,"isHoverable");if(e&&s){if(!this._hovered){(i=s.onPointerEnter)==null||i.call(s,e),this._hovered=s;return}if(this._hovered.uuid!==s.uuid){(a=(o=this._hovered).onPointerLeave)==null||a.call(o),(l=s.onPointerEnter)==null||l.call(s,e),this._hovered=s;return}(p=s.onPointerOver)==null||p.call(s,e);return}this._hovered&&((v=(f=this._hovered).onPointerLeave)==null||v.call(f),this._hovered=null)}}const P=n=>n.name==="select";class g{constructor(t){r(this,"name","select");r(this,"priority",30);r(this,"_selectionState");this._selectionState=t}get selected(){return this._selectionState.selected}onActivate(){}onDeactivate(){}onClick(t){const e=t.modelIntersects[0],s=_.findInterface(e==null?void 0:e.object,"isSelectable");if(!e||!s){this._selectionState.deselect();return}const i=this._selectionState.selected;i&&i.uuid===s.uuid||this._selectionState.select(s)}select(t){this._selectionState.select(t)}deselect(){this._selectionState.deselect()}}const w=n=>n.name==="transform";class u extends c.EventDispatcher{constructor(e,s,i){super();r(this,"name","transform");r(this,"priority",5);r(this,"_scene");r(this,"_controller");r(this,"_selectionState");r(this,"_gizmo");r(this,"_gizmoHelper");r(this,"_scaleLinked",!1);r(this,"_gizmoVisible",!0);r(this,"_selectionChangeHandler");this._scene=e,this._controller=s,this._selectionState=i,this._gizmo=this.initGizmo(),this._gizmoHelper=this._gizmo.getHelper(),this._scene.add(this._gizmoHelper),this._selectionChangeHandler=this.onSelectionChange.bind(this)}get gizmo(){return this._gizmo}get isDragging(){return this._gizmo.dragging}onActivate(){this._selectionState.onChange(this._selectionChangeHandler);const e=this._selectionState.selected;e&&this.attachGizmo(e)}onDeactivate(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach()}onPointerMove(e){if(this._gizmo.dragging||e.uiIntersects.length>0&&e.uiIntersects.some(i=>this.isGizmoChild(i.object)))return!0}setGizmoMode(e){this._gizmo.mode=e}setGizmoVisible(e){this._gizmoVisible=e;const s=this._scene.children.includes(this._gizmoHelper);e&&!s?(this._scene.add(this._gizmoHelper),this._gizmo.getRaycaster().layers.enableAll()):!e&&s&&(this._scene.remove(this._gizmoHelper),this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(e){this._scaleLinked=e}dispose(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach(),this._scene.remove(this._gizmoHelper),this._gizmo.dispose()}onSelectionChange(e){e&&_.implementsInterface(e,"isMovable")?this.attachGizmo(e):this._gizmo.detach()}attachGizmo(e){_.implementsInterface(e,"isMovable")&&(this._gizmo.attach(e),this.setGizmoVisible(e.visible&&this._gizmoVisible))}isGizmoChild(e){let s=e;for(;s;){if(s===this._gizmoHelper)return!0;s=s.parent}return!1}initGizmo(){const e=new T.TransformControls(this._controller.object,this._controller.domElement);return e.mode="translate",e.getHelper().traverse(i=>{if(!("isMesh"in i))return;const o=i.material;i.name==="X"&&o.color.set(d.AxesColorRed),i.name==="Y"&&o.color.set(d.AxesColorGreen),i.name==="Z"&&o.color.set(d.AxesColorBlue),i.name==="XY"&&o.color.set(d.AxesColorBlue),i.name==="YZ"&&o.color.set(d.AxesColorRed),i.name==="XZ"&&o.color.set(d.AxesColorGreen)}),e.addEventListener("mouseDown",()=>{var i,o;this._controller.enabled=!1,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveStart)==null||o.call(i))}),e.addEventListener("objectChange",()=>{var i,o;if(_.implementsInterface(e.object,"isMovable")){if((o=(i=e.object).onMove)==null||o.call(i),this._scaleLinked&&e.object){const a=e.object.scale,l=(a.x+a.y+a.z)/3;e.object.scale.set(l,l,l)}switch(this.dispatchEvent({type:"object-change",object:e.object}),e.mode){case"translate":this.dispatchEvent({type:"object-position-change",object:e.object});break;case"rotate":this.dispatchEvent({type:"object-rotation-change",object:e.object});break;case"scale":this.dispatchEvent({type:"object-scale-change",object:e.object});break}}}),e.addEventListener("mouseUp",()=>{var i,o;this._controller.enabled=!0,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveEnd)==null||o.call(i))}),e}}const C=.001;class D{constructor(t){r(this,"name","drag");r(this,"priority",10);r(this,"_controller");r(this,"_raycaster");r(this,"_dragging",!1);r(this,"_draggable",null);r(this,"_dragStart",new c.Vector3);r(this,"_dragCurrent",new c.Vector3);r(this,"_dragEnd",new c.Vector3);r(this,"_dragDelta",new c.Vector3);r(this,"_dragRaycastTargets",null);this._controller=t,this._raycaster=new c.Raycaster}get isDragging(){return this._dragging}get draggable(){return this._draggable}onActivate(){this.resetDragState()}onDeactivate(){this._dragging&&this._draggable&&this.endDrag(),this.resetDragState()}onPointerDown(t){var e;t.pointerPrimaryDown&&(this._draggable=_.findInterface((e=t.intersects[0])==null?void 0:e.object,"isDraggable")||null)}onPointerMove(t){if(t.pointerPrimaryDown&&this._draggable&&(this._raycaster.setFromCamera(t.pointer,this._controller.object),this._dragging||t.lastPointerDown.distanceTo(t.pointer)>C&&this.startDrag(t),this._dragging))return this.updateDrag(t),!0}onPointerUp(t){this._dragging&&(this._raycaster.setFromCamera(t.pointer,this._controller.object),this.endDrag()),this._draggable=null}setDragRaycastTargets(t){this._dragRaycastTargets=t}startDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragStart.copy(e.point),this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.set(0,0,0),(i=(s=this._draggable)==null?void 0:s.onDragStart)==null||i.call(s,this.createDragEvent()),this._dragging=!0,this._controller.enabled=!1)}updateDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.subVectors(this._dragCurrent,this._dragStart),(i=(s=this._draggable)==null?void 0:s.onDrag)==null||i.call(s,this.createDragEvent()))}endDrag(){var e,s;const t=this.createDragEvent();(s=(e=this._draggable)==null?void 0:e.onDragEnd)==null||s.call(e,t),this._dragging=!1,this._controller.enabled=!0,this.resetDragState()}getDragIntersect(t){return this._dragRaycastTargets?this._raycaster.intersectObjects(this._dragRaycastTargets,!0)[0]||null:t.intersects[0]||null}createDragEvent(){return{dragStart:this._dragStart.clone(),dragCurrent:this._dragCurrent.clone(),dragEnd:this._dragEnd.clone(),dragDelta:this._dragDelta.clone()}}resetDragState(){this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0)}}const E=.001;class M{constructor(t,e){r(this,"_scene");r(this,"_controller");r(this,"_canvas");r(this,"_tools");r(this,"_activeTools",new Map);r(this,"_sortedActiveTools",[]);r(this,"_selectionState");r(this,"_raycaster");r(this,"_pointer");r(this,"_productLayerMask");r(this,"_uiLayerMask");r(this,"_pointerPrimaryDown",!1);r(this,"_pointerMiddleDown",!1);r(this,"_pointerSecondaryDown",!1);r(this,"_lastPointerDown");r(this,"_boundPointerMove");r(this,"_boundPointerDown");r(this,"_boundPointerUp");r(this,"_boundWheel");this._scene=t,this._controller=e,this._canvas=e.domElement,this._selectionState=new m,this._raycaster=new c.Raycaster,this._pointer=new c.Vector2,this._lastPointerDown=new c.Vector2,this._productLayerMask=new c.Layers,this._productLayerMask.set(Math.log2(h.PRODUCT_LAYER_MASK)),this._uiLayerMask=new c.Layers,this._uiLayerMask.set(Math.log2(h.UI_LAYER_MASK)),this._tools=new Map([["hover",new b],["select",new g(this._selectionState)],["transform",new u(t,e,this._selectionState)],["drag",new D(e)]]),this._boundPointerMove=this.onPointerMove.bind(this),this._boundPointerDown=this.onPointerDown.bind(this),this._boundPointerUp=this.onPointerUp.bind(this),this._boundWheel=this.onWheel.bind(this),this._canvas.addEventListener("pointermove",this._boundPointerMove),this._canvas.addEventListener("pointerdown",this._boundPointerDown),this._canvas.addEventListener("pointerup",this._boundPointerUp),this._canvas.addEventListener("wheel",this._boundWheel)}get selectionState(){return this._selectionState}enableTool(t){var s;const e=this._tools.get(t);e&&(this._activeTools.has(t)||(this._activeTools.set(t,e),this.updateSortedTools(),(s=e.onActivate)==null||s.call(e)))}disableTool(t){var s;const e=this._activeTools.get(t);e&&((s=e.onDeactivate)==null||s.call(e),this._activeTools.delete(t),this.updateSortedTools())}isToolEnabled(t){return this._activeTools.has(t)}getTool(t){return this._tools.get(t)}getActiveTools(){return[...this._sortedActiveTools]}dispose(){var t;for(const e of this._activeTools.values())(t=e.onDeactivate)==null||t.call(e);this._activeTools.clear(),this._tools.clear(),this._sortedActiveTools=[],this._canvas.removeEventListener("pointermove",this._boundPointerMove),this._canvas.removeEventListener("pointerdown",this._boundPointerDown),this._canvas.removeEventListener("pointerup",this._boundPointerUp),this._canvas.removeEventListener("wheel",this._boundWheel),this._selectionState.dispose()}onPointerMove(t){var s;this.updatePointer(t);const e=this.createPointerContext(t);for(const i of this._sortedActiveTools)if((s=i.onPointerMove)==null?void 0:s.call(i,e))break}onPointerDown(t){var s;this.updatePointerState(t,!0),this.updatePointer(t),this._lastPointerDown.copy(this._pointer);const e=this.createPointerContext(t);for(const i of this._sortedActiveTools)if((s=i.onPointerDown)==null?void 0:s.call(i,e))break}onPointerUp(t){var i,o;this.updatePointer(t);const e=this.createPointerContext(t),s=!this.pointerWasDragged();for(const a of this._sortedActiveTools)if((i=a.onPointerUp)==null?void 0:i.call(a,e))break;if(s){for(const a of this._sortedActiveTools)if((o=a.onClick)==null?void 0:o.call(a,e))break}this.updatePointerState(t,!1)}onWheel(t){var s;const e=this.createWheelContext(t);for(const i of this._sortedActiveTools)if((s=i.onWheel)==null?void 0:s.call(i,e))break}createPointerContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.UI_LAYER_MASK),pointerPrimaryDown:this._pointerPrimaryDown,pointerMiddleDown:this._pointerMiddleDown,pointerSecondaryDown:this._pointerSecondaryDown,lastPointerDown:this._lastPointerDown.clone()}}createWheelContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.UI_LAYER_MASK)}}updatePointer(t){this._pointer.x=t.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(t.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object)}updatePointerState(t,e){switch(t.button){case 0:this._pointerPrimaryDown=e;break;case 1:this._pointerMiddleDown=e;break;case 2:this._pointerSecondaryDown=e;break}}raycast(){this._raycaster.layers.mask=h.PRODUCT_LAYER_MASK|h.UI_LAYER_MASK;const t=this._scene.children.filter(e=>e.visible&&"isMesh"in e&&e.isMesh);return this._raycaster.intersectObjects(t,!0)}filterIntersectsByLayer(t,e){return t.filter(s=>(s.object.layers.mask&e)!==0)}updateSortedTools(){this._sortedActiveTools=[...this._activeTools.values()].sort((t,e)=>t.priority-e.priority)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>E}}exports.DIVESelectTool=g;exports.DIVETransformTool=u;exports.DragTool=D;exports.HoverTool=b;exports.SelectTool=g;exports.SelectionState=m;exports.Toolbox=M;exports.TransformTool=u;exports.isSelectTool=P;exports.isTransformTool=w;
1
+ "use strict";var y=Object.defineProperty;var S=(n,t,e)=>t in n?y(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>S(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("three/webgpu");require("../../chunks/FileTypes-Ba65iQSJ.cjs");const h=require("../../chunks/PerspectiveCamera-DwQUmkDv.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const _=require("../../chunks/findInterface-C6mrvf_t.cjs"),T=require("three/examples/jsm/controls/TransformControls.js"),d=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class m{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(t){var e,s,i;this._selected!==t&&(this._selected&&((s=(e=this._selected).onDeselect)==null||s.call(e)),this._selected=t,(i=t.onSelect)==null||i.call(t),this.notifyListeners())}deselect(){var t,e;this._selected&&((e=(t=this._selected).onDeselect)==null||e.call(t),this._selected=null,this.notifyListeners())}onChange(t){this._listeners.add(t)}offChange(t){this._listeners.delete(t)}dispose(){this._selected=null,this._listeners.clear()}notifyListeners(){for(const t of this._listeners)t(this._selected)}}class b{constructor(){r(this,"name","hover");r(this,"priority",20);r(this,"_hovered",null)}get hovered(){return this._hovered}onActivate(){this._hovered=null}onDeactivate(){var t,e;this._hovered&&((e=(t=this._hovered).onPointerLeave)==null||e.call(t),this._hovered=null)}onPointerMove(t){var i,o,a,l,p,f,v;const e=t.modelIntersects[0],s=_.findInterface(e==null?void 0:e.object,"isHoverable");if(e&&s){if(!this._hovered){(i=s.onPointerEnter)==null||i.call(s,e),this._hovered=s;return}if(this._hovered.uuid!==s.uuid){(a=(o=this._hovered).onPointerLeave)==null||a.call(o),(l=s.onPointerEnter)==null||l.call(s,e),this._hovered=s;return}(p=s.onPointerOver)==null||p.call(s,e);return}this._hovered&&((v=(f=this._hovered).onPointerLeave)==null||v.call(f),this._hovered=null)}}const P=n=>n.name==="select";class g{constructor(t){r(this,"name","select");r(this,"priority",30);r(this,"_selectionState");this._selectionState=t}get selected(){return this._selectionState.selected}onActivate(){}onDeactivate(){}onClick(t){const e=t.modelIntersects[0],s=_.findInterface(e==null?void 0:e.object,"isSelectable");if(!e||!s){this._selectionState.deselect();return}const i=this._selectionState.selected;i&&i.uuid===s.uuid||this._selectionState.select(s)}select(t){this._selectionState.select(t)}deselect(){this._selectionState.deselect()}}const w=n=>n.name==="transform";class u extends c.EventDispatcher{constructor(e,s,i){super();r(this,"name","transform");r(this,"priority",5);r(this,"_scene");r(this,"_controller");r(this,"_selectionState");r(this,"_gizmo");r(this,"_gizmoHelper");r(this,"_scaleLinked",!1);r(this,"_gizmoVisible",!0);r(this,"_selectionChangeHandler");this._scene=e,this._controller=s,this._selectionState=i,this._gizmo=this.initGizmo(),this._gizmoHelper=this._gizmo.getHelper(),this._scene.add(this._gizmoHelper),this._selectionChangeHandler=this.onSelectionChange.bind(this)}get gizmo(){return this._gizmo}get isDragging(){return this._gizmo.dragging}onActivate(){this._selectionState.onChange(this._selectionChangeHandler);const e=this._selectionState.selected;e&&this.attachGizmo(e)}onDeactivate(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach()}onPointerMove(e){if(this._gizmo.dragging||e.uiIntersects.length>0&&e.uiIntersects.some(i=>this.isGizmoChild(i.object)))return!0}setGizmoMode(e){this._gizmo.mode=e}setGizmoVisible(e){this._gizmoVisible=e;const s=this._scene.children.includes(this._gizmoHelper);e&&!s?(this._scene.add(this._gizmoHelper),this._gizmo.getRaycaster().layers.enableAll()):!e&&s&&(this._scene.remove(this._gizmoHelper),this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(e){this._scaleLinked=e}dispose(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach(),this._scene.remove(this._gizmoHelper),this._gizmo.dispose()}onSelectionChange(e){e&&_.implementsInterface(e,"isMovable")?this.attachGizmo(e):this._gizmo.detach()}attachGizmo(e){_.implementsInterface(e,"isMovable")&&(this._gizmo.attach(e),this.setGizmoVisible(e.visible&&this._gizmoVisible))}isGizmoChild(e){let s=e;for(;s;){if(s===this._gizmoHelper)return!0;s=s.parent}return!1}initGizmo(){const e=new T.TransformControls(this._controller.object,this._controller.domElement);return e.mode="translate",e.getHelper().traverse(i=>{if(!("isMesh"in i))return;const o=i.material;i.name==="X"&&o.color.set(d.AxesColorRed),i.name==="Y"&&o.color.set(d.AxesColorGreen),i.name==="Z"&&o.color.set(d.AxesColorBlue),i.name==="XY"&&o.color.set(d.AxesColorBlue),i.name==="YZ"&&o.color.set(d.AxesColorRed),i.name==="XZ"&&o.color.set(d.AxesColorGreen)}),e.addEventListener("mouseDown",()=>{var i,o;this._controller.enabled=!1,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveStart)==null||o.call(i))}),e.addEventListener("objectChange",()=>{var i,o;if(_.implementsInterface(e.object,"isMovable")){if((o=(i=e.object).onMove)==null||o.call(i),this._scaleLinked&&e.object){const a=e.object.scale,l=(a.x+a.y+a.z)/3;e.object.scale.set(l,l,l)}switch(this.dispatchEvent({type:"object-change",object:e.object}),e.mode){case"translate":this.dispatchEvent({type:"object-position-change",object:e.object});break;case"rotate":this.dispatchEvent({type:"object-rotation-change",object:e.object});break;case"scale":this.dispatchEvent({type:"object-scale-change",object:e.object});break}}}),e.addEventListener("mouseUp",()=>{var i,o;this._controller.enabled=!0,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveEnd)==null||o.call(i))}),e}}const C=.001;class D{constructor(t){r(this,"name","drag");r(this,"priority",10);r(this,"_controller");r(this,"_raycaster");r(this,"_dragging",!1);r(this,"_draggable",null);r(this,"_dragStart",new c.Vector3);r(this,"_dragCurrent",new c.Vector3);r(this,"_dragEnd",new c.Vector3);r(this,"_dragDelta",new c.Vector3);r(this,"_dragRaycastTargets",null);this._controller=t,this._raycaster=new c.Raycaster}get isDragging(){return this._dragging}get draggable(){return this._draggable}onActivate(){this.resetDragState()}onDeactivate(){this._dragging&&this._draggable&&this.endDrag(),this.resetDragState()}onPointerDown(t){var e;t.pointerPrimaryDown&&(this._draggable=_.findInterface((e=t.intersects[0])==null?void 0:e.object,"isDraggable")||null)}onPointerMove(t){if(t.pointerPrimaryDown&&this._draggable&&(this._raycaster.setFromCamera(t.pointer,this._controller.object),this._dragging||t.lastPointerDown.distanceTo(t.pointer)>C&&this.startDrag(t),this._dragging))return this.updateDrag(t),!0}onPointerUp(t){this._dragging&&(this._raycaster.setFromCamera(t.pointer,this._controller.object),this.endDrag()),this._draggable=null}setDragRaycastTargets(t){this._dragRaycastTargets=t}startDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragStart.copy(e.point),this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.set(0,0,0),(i=(s=this._draggable)==null?void 0:s.onDragStart)==null||i.call(s,this.createDragEvent()),this._dragging=!0,this._controller.enabled=!1)}updateDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.subVectors(this._dragCurrent,this._dragStart),(i=(s=this._draggable)==null?void 0:s.onDrag)==null||i.call(s,this.createDragEvent()))}endDrag(){var e,s;const t=this.createDragEvent();(s=(e=this._draggable)==null?void 0:e.onDragEnd)==null||s.call(e,t),this._dragging=!1,this._controller.enabled=!0,this.resetDragState()}getDragIntersect(t){return this._dragRaycastTargets?this._raycaster.intersectObjects(this._dragRaycastTargets,!0)[0]||null:t.intersects[0]||null}createDragEvent(){return{dragStart:this._dragStart.clone(),dragCurrent:this._dragCurrent.clone(),dragEnd:this._dragEnd.clone(),dragDelta:this._dragDelta.clone()}}resetDragState(){this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0)}}const E=.001;class M{constructor(t,e){r(this,"_scene");r(this,"_controller");r(this,"_canvas");r(this,"_tools");r(this,"_activeTools",new Map);r(this,"_sortedActiveTools",[]);r(this,"_selectionState");r(this,"_raycaster");r(this,"_pointer");r(this,"_productLayerMask");r(this,"_uiLayerMask");r(this,"_pointerPrimaryDown",!1);r(this,"_pointerMiddleDown",!1);r(this,"_pointerSecondaryDown",!1);r(this,"_lastPointerDown");r(this,"_boundPointerMove");r(this,"_boundPointerDown");r(this,"_boundPointerUp");r(this,"_boundWheel");this._scene=t,this._controller=e,this._canvas=e.domElement,this._selectionState=new m,this._raycaster=new c.Raycaster,this._pointer=new c.Vector2,this._lastPointerDown=new c.Vector2,this._productLayerMask=new c.Layers,this._productLayerMask.set(Math.log2(h.PRODUCT_LAYER_MASK)),this._uiLayerMask=new c.Layers,this._uiLayerMask.set(Math.log2(h.UI_LAYER_MASK)),this._tools=new Map([["hover",new b],["select",new g(this._selectionState)],["transform",new u(t,e,this._selectionState)],["drag",new D(e)]]),this._boundPointerMove=this.onPointerMove.bind(this),this._boundPointerDown=this.onPointerDown.bind(this),this._boundPointerUp=this.onPointerUp.bind(this),this._boundWheel=this.onWheel.bind(this),this._canvas.addEventListener("pointermove",this._boundPointerMove),this._canvas.addEventListener("pointerdown",this._boundPointerDown),this._canvas.addEventListener("pointerup",this._boundPointerUp),this._canvas.addEventListener("wheel",this._boundWheel)}get selectionState(){return this._selectionState}enableTool(t){var s;const e=this._tools.get(t);e&&(this._activeTools.has(t)||(this._activeTools.set(t,e),this.updateSortedTools(),(s=e.onActivate)==null||s.call(e)))}disableTool(t){var s;const e=this._activeTools.get(t);e&&((s=e.onDeactivate)==null||s.call(e),this._activeTools.delete(t),this.updateSortedTools())}isToolEnabled(t){return this._activeTools.has(t)}getTool(t){return this._tools.get(t)}getActiveTools(){return[...this._sortedActiveTools]}dispose(){var t;for(const e of this._activeTools.values())(t=e.onDeactivate)==null||t.call(e);this._activeTools.clear(),this._tools.clear(),this._sortedActiveTools=[],this._canvas.removeEventListener("pointermove",this._boundPointerMove),this._canvas.removeEventListener("pointerdown",this._boundPointerDown),this._canvas.removeEventListener("pointerup",this._boundPointerUp),this._canvas.removeEventListener("wheel",this._boundWheel),this._selectionState.dispose()}onPointerMove(t){var s;this.updatePointer(t);const e=this.createPointerContext(t);for(const i of this._sortedActiveTools)if((s=i.onPointerMove)==null?void 0:s.call(i,e))break}onPointerDown(t){var s;this.updatePointerState(t,!0),this.updatePointer(t),this._lastPointerDown.copy(this._pointer);const e=this.createPointerContext(t);for(const i of this._sortedActiveTools)if((s=i.onPointerDown)==null?void 0:s.call(i,e))break}onPointerUp(t){var i,o;this.updatePointer(t);const e=this.createPointerContext(t),s=!this.pointerWasDragged();for(const a of this._sortedActiveTools)if((i=a.onPointerUp)==null?void 0:i.call(a,e))break;if(s){for(const a of this._sortedActiveTools)if((o=a.onClick)==null?void 0:o.call(a,e))break}this.updatePointerState(t,!1)}onWheel(t){var s;const e=this.createWheelContext(t);for(const i of this._sortedActiveTools)if((s=i.onWheel)==null?void 0:s.call(i,e))break}createPointerContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.UI_LAYER_MASK),pointerPrimaryDown:this._pointerPrimaryDown,pointerMiddleDown:this._pointerMiddleDown,pointerSecondaryDown:this._pointerSecondaryDown,lastPointerDown:this._lastPointerDown.clone()}}createWheelContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.UI_LAYER_MASK)}}updatePointer(t){this._pointer.x=t.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(t.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object)}updatePointerState(t,e){switch(t.button){case 0:this._pointerPrimaryDown=e;break;case 1:this._pointerMiddleDown=e;break;case 2:this._pointerSecondaryDown=e;break}}raycast(){this._raycaster.layers.mask=h.PRODUCT_LAYER_MASK|h.UI_LAYER_MASK;const t=this._scene.children.filter(e=>e.visible&&"isMesh"in e&&e.isMesh);return this._raycaster.intersectObjects(t,!0)}filterIntersectsByLayer(t,e){return t.filter(s=>(s.object.layers.mask&e)!==0)}updateSortedTools(){this._sortedActiveTools=[...this._activeTools.values()].sort((t,e)=>t.priority-e.priority)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>E}}exports.DIVESelectTool=g;exports.DIVETransformTool=u;exports.DragTool=D;exports.HoverTool=b;exports.SelectTool=g;exports.SelectionState=m;exports.Toolbox=M;exports.TransformTool=u;exports.isSelectTool=P;exports.isTransformTool=w;
@@ -2,7 +2,7 @@ var S = Object.defineProperty;
2
2
  var w = (n, t, e) => t in n ? S(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
3
  var o = (n, t, e) => w(n, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { EventDispatcher as T, Vector3 as l, Raycaster as P, Vector2 as f, Layers as m } from "three/webgpu";
5
- import "../../chunks/FileTypes-DLAWiGQa.mjs";
5
+ import "../../chunks/FileTypes-Ck6z0LqE.mjs";
6
6
  import { P as _, U as d } from "../../chunks/PerspectiveCamera-35cBnxwG.mjs";
7
7
  import "three/examples/jsm/loaders/HDRLoader.js";
8
8
  import "three/tsl";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/dive",
3
- "version": "3.0.6",
3
+ "version": "3.0.8",
4
4
  "description": "Shopware Spatial Framework",
5
5
  "type": "module",
6
6
  "main": "build/dive.cjs",
@@ -1,3 +0,0 @@
1
- "use strict";var U=Object.create;var b=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var x=(i,t,n)=>t in i?b(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var G=(i,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of F(t))!N.call(i,s)&&s!==n&&b(i,s,{get:()=>t[s],enumerable:!(r=M(t,s))||r.enumerable});return i};var S=(i,t,n)=>(n=i!=null?U(k(i)):{},G(t||!i||!i.__esModule?b(n,"default",{value:i,enumerable:!0}):n,i));var h=(i,t,n)=>x(i,typeof t!="symbol"?t+"":t,n);const v=require("three/examples/jsm/loaders/GLTFLoader.js"),W=require("three/examples/jsm/loaders/USDLoader.js"),j=require("./FileTypes-IZ9BrQ2x.cjs"),A=require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const C=require("./isFileTypeSupported-dgHlqizJ.cjs"),L=require("./parse-error-Dy_EE4rL.cjs"),B=require("three/examples/jsm/loaders/DRACOLoader.js"),E=require("./AssetCache-hZPj76ce.cjs");function I(){let i,t;onmessage=function(e){const o=e.data;switch(o.type){case"init":i=o.decoderConfig,t=new Promise(function(a){i.onModuleLoaded=function(f){a({draco:f})},DracoDecoderModule(i)});break;case"decode":const c=o.buffer,u=o.taskConfig;t.then(a=>{const f=a.draco,d=new f.Decoder;try{const _=n(f,d,new Int8Array(c),u),p=_.attributes.map(g=>g.array.buffer);_.index&&p.push(_.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:_},p)}catch(_){console.error(_),self.postMessage({type:"error",id:o.id,error:_.message})}finally{f.destroy(d)}});break}};function n(e,o,c,u){const a=u.attributeIDs,f=u.attributeTypes;let d,_;const p=o.GetEncodedGeometryType(c);if(p===e.TRIANGULAR_MESH)d=new e.Mesh,_=o.DecodeArrayToMesh(c,c.byteLength,d);else if(p===e.POINT_CLOUD)d=new e.PointCloud,_=o.DecodeArrayToPointCloud(c,c.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!_.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+_.error_msg());const g={index:null,attributes:[]};for(const w in a){const y=self[f[w]];let m,D;if(u.useUniqueIDs)D=a[w],m=o.GetAttributeByUniqueId(d,D);else{if(D=o.GetAttributeId(d,e[a[w]]),D===-1)continue;m=o.GetAttribute(d,D)}const R=s(e,o,d,w,y,m);w==="color"&&(R.vertexColorSpace=u.vertexColorSpace),g.attributes.push(R)}return p===e.TRIANGULAR_MESH&&(g.index=r(e,o,d)),e.destroy(d),g}function r(e,o,c){const a=c.num_faces()*3,f=a*4,d=e._malloc(f);o.GetTrianglesUInt32Array(c,f,d);const _=new Uint32Array(e.HEAPF32.buffer,d,a).slice();return e._free(d),{array:_,itemSize:1}}function s(e,o,c,u,a,f){const d=f.num_components(),p=c.num_points()*d,g=p*a.BYTES_PER_ELEMENT,w=l(e,a),y=e._malloc(g);o.GetAttributeDataArrayForAllPoints(c,f,w,g,y);const m=new a(e.HEAPF32.buffer,y,p).slice();return e._free(y),{name:u,array:m,itemSize:d}}function l(e,o){switch(o){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}}const T={LOAD_DRACO_JS_DECODER:async()=>(await import("three/examples/jsm/libs/draco/draco_decoder.js?raw")).default,LOAD_DRACO_WASM_WRAPPER:async()=>(await import("three/examples/jsm/libs/draco/draco_wasm_wrapper.js?raw")).default,LOAD_DRACO_WASM_DECODER:async()=>{const i=(await import("three/examples/jsm/libs/draco/draco_decoder.wasm?url")).default;return await(await fetch(i)).arrayBuffer()}};class P extends B.DRACOLoader{constructor(){super(...arguments);h(this,"decoderPending",null);h(this,"decoderConfig",{type:"js",wasmBinary:null});h(this,"workerSourceURL","")}async _initDecoder(){if(this.decoderPending)return this.decoderPending;const n=typeof WebAssembly!="object"||this.decoderConfig.type==="js",r=[];return n?r.push(T.LOAD_DRACO_JS_DECODER()):(r.push(T.LOAD_DRACO_WASM_WRAPPER()),r.push(T.LOAD_DRACO_WASM_DECODER())),this.decoderPending=Promise.all(r).then(s=>{const l=s[0];n||(this.decoderConfig.wasmBinary=s[1]);const e=I.toString(),o=["/* draco decoder */",l,"","/* worker */",e.substring(e.indexOf("{")+1,e.lastIndexOf("}"))].join(`
2
- `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}}function q(){let i=null,t=null;const n=[[/'CONFIG_CONTROL_DESIGN'\s*\)/g,"'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF')"],[/'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF\.\s*\{[\s\S]*?\}\s*'/g,"'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF'"]];function r(){return i||(i=occtimportjs({locateFile:function(){return t}})),i}function s(e){for(var o=new TextDecoder("utf-8",{fatal:!1}),c=new TextEncoder,u=o.decode(e),a=0;a<n.length;a++){var f=n[a][0],d=n[a][1];u=u.replace(f,d)}return new Uint8Array(c.encode(u))}function l(e,o){var c=s(o);try{var u=e.ReadStepFile(c,null);if(u.success&&u.root)return u}catch{}try{return e.ReadStepFile(o,null)}catch{return{success:!1,root:{meshes:[],children:[]},meshes:[]}}}onmessage=async function(e){var o=e.data;switch(o.type){case"init":t=o.wasmUrl;break;case"parse":try{var c=await r(),u=new Uint8Array(o.buffer),a=o.fileType,f;if(a==="step"||a==="stp"?f=l(c,u):f=c.ReadIgesFile(u,null),!f.success||!f.root){self.postMessage({type:"error",id:o.id,error:"Failed to parse CAD file"});return}self.postMessage({type:"result",id:o.id,result:f})}catch(d){self.postMessage({type:"error",id:o.id,error:d instanceof Error?d.message:String(d)})}break}}}const O={LOAD_OCCT_JS:async()=>(await Promise.resolve().then(()=>require("./occt-import-js-DdbbsFBH.cjs"))).default,LOAD_OCCT_WASM_URL:async()=>(await Promise.resolve().then(()=>require("./occt-import-js-BQ1yZHCj.cjs"))).default};class H{constructor(){h(this,"_workerPending",null);h(this,"_worker",null);h(this,"_nextId",0);h(this,"_pending",new Map)}_getWorker(){return this._workerPending?this._workerPending:(this._workerPending=(async()=>{const[t,n]=await Promise.all([O.LOAD_OCCT_JS(),O.LOAD_OCCT_WASM_URL()]),r=q.toString(),s=["/* occt-import-js */",t,"","/* step worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
3
- `),l=URL.createObjectURL(new Blob([s])),e=new Worker(l),o=new URL(n,window.location.href).href;return e.postMessage({type:"init",wasmUrl:o}),e.onmessage=c=>{const{type:u,id:a,result:f,error:d}=c.data,_=this._pending.get(a);if(_)if(this._pending.delete(a),u==="result")try{_.resolve(this._buildScene(f))}catch(p){_.reject(p instanceof Error?p:new Error(String(p)))}else _.reject(new Error(d??"Worker error"))},e.onerror=c=>{for(const[,{reject:u}]of this._pending)u(new Error(c.message??"Worker error"));this._pending.clear()},this._worker=e,e})(),this._workerPending)}async parseAsync(t,n){const r=this._nextId++,s=await this._getWorker();return new Promise((l,e)=>{this._pending.set(r,{resolve:l,reject:e});const o=t.slice(0);s.postMessage({type:"parse",id:r,buffer:o,fileType:n},[o])})}dispose(){if(this._worker){for(const[,{reject:t}]of this._pending)t(new Error("STEPLoader disposed"));this._pending.clear(),this._worker.terminate(),this._worker=null,this._workerPending=null}}_buildScene(t){const n=new A.Group;return n.name=t.root.name??"CAD Model",this._buildNode(t.root,t.meshes,n),n.rotation.x=-Math.PI/2,n.rotation.z=Math.PI/2,n}_buildNode(t,n,r){const s=new A.Group;s.name=t.name??"Part";for(const l of t.meshes){const e=n[l];if(e!=null&&e.attributes){const o=this._createMesh(e);s.add(o)}}for(const l of t.children)this._buildNode(l,n,s);r.add(s)}_createMesh(t){var u,a;const{position:n,normal:r}=t.attributes,s=t.index??t.attributes.index,l=new A.BufferGeometry;l.setAttribute("position",new A.BufferAttribute(new Float32Array(n.array),3)),(u=r==null?void 0:r.array)!=null&&u.length?l.setAttribute("normal",new A.BufferAttribute(new Float32Array(r.array),3)):l.computeVertexNormals(),(a=s==null?void 0:s.array)!=null&&a.length&&l.setIndex(new A.BufferAttribute(new Uint32Array(s.array),1));const e=t.color,o=new A.MeshStandardMaterial({metalness:.3,roughness:.6});e&&e.length>=3?o.color.setRGB(e[0],e[1],e[2]):o.color.setHex(13421772);const c=new A.Mesh(l,o);return c.name=t.name??"Mesh",c.castShadow=!0,c.receiveShadow=!0,c}}class z{constructor(){h(this,"_gltfLoader");h(this,"_usdLoader");h(this,"_stepLoader");const t=new P;t.setDecoderConfig({type:"wasm"}),this._gltfLoader=new v.GLTFLoader,this._gltfLoader.setDRACOLoader(t),this._usdLoader=new W.USDLoader,this._stepLoader=new H}async load(t,n){let r;if(n)r=n;else if(r=C.getFileTypeFromUri(t),r.length===0&&(r=await this._detectFileTypeFromContent(t),r.length===0))throw new L.FileTypeError("No file extension found in URI","");if(!C.isFileTypeSupported(r))throw new L.FileTypeError(`Unsupported file type: ${r}. Supported types: ${j.SUPPORTED_FILE_TYPES.join(", ")}`,r);const s=E.AssetCache.read(t);if(s)return s.arrayBuffer?this._parse(s.arrayBuffer,r):s.promise.then(o=>this._parse(o,r));const e=await E.AssetCache.create(t).load();return this._parse(e,r)}async _detectFileTypeFromContent(t){try{const n=E.AssetCache.read(t);let r;n?n.arrayBuffer?r=n.arrayBuffer:r=await n.promise:r=await E.AssetCache.create(t).load();const s=new Uint8Array(r);return s.length>=12&&String.fromCharCode(s[0],s[1],s[2],s[3])==="glTF"?s[12]===0?"glb":"gltf":s.length>=4&&s[0]===80&&s[1]===75&&(s[2]===3||s[2]===5)&&(s[3]===4||s[3]===6)?"usdz":s.length>=20&&new TextDecoder("ascii").decode(s.subarray(0,20)).startsWith("ISO-10303-21")?"step":s.length>=80&&s[72]===83?"iges":""}catch{return""}}async _parse(t,n){try{switch(n){case"glb":case"gltf":{const r=await this._gltfLoader.parseAsync(t,"");return r.scene.animations=r.animations,r.scene}case"usdz":{const r=this._usdLoader.parse(t);return r.animations=[],r}case"step":case"stp":{const r=await this._stepLoader.parseAsync(t,n);return r.animations=[],r}case"iges":case"igs":{const r=await this._stepLoader.parseAsync(t,n);return r.animations=[],r}}}catch(r){throw r instanceof Error?new L.ParseError(`Failed to parse ${n} file: ${r.message}`,r):new L.ParseError(`Failed to parse ${n} file`)}}}exports.AssetLoader=z;exports.DRACOWorker=I;exports.DracoLoader=P;