@shopware-ag/dive 3.0.3 → 3.0.4-beta.1

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 (31) hide show
  1. package/build/chunks/AssetCache-C5gMTga4.cjs +1 -0
  2. package/build/chunks/{AssetCache-BUet32OG.mjs → AssetCache-DON6nyPa.mjs} +11 -11
  3. package/build/chunks/AssetLoader-B4s8jloI.cjs +3 -0
  4. package/build/chunks/AssetLoader-C7XL4V0l.mjs +663 -0
  5. package/build/chunks/{FileTypes-DiwbBQ8N.cjs → FileTypes-Dol5v9ki.cjs} +1 -1
  6. package/build/chunks/{FileTypes-smInt9po.mjs → FileTypes-g6ZqzZse.mjs} +1 -1
  7. package/build/chunks/{isFileTypeSupported-DJrJlL4K.cjs → isFileTypeSupported-P3xRVDuO.cjs} +1 -1
  8. package/build/chunks/{isFileTypeSupported-4wdgLa3R.mjs → isFileTypeSupported-Y7SrG74A.mjs} +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/assetloader/src/loader/AssetLoader.d.ts +2 -0
  18. package/build/plugins/orbitcontroller/index.cjs +1 -1
  19. package/build/plugins/orbitcontroller/index.mjs +1 -1
  20. package/build/plugins/orientationdisplay/index.cjs +1 -1
  21. package/build/plugins/orientationdisplay/index.mjs +1 -1
  22. package/build/plugins/quickview/index.cjs +1 -1
  23. package/build/plugins/quickview/index.mjs +1 -1
  24. package/build/plugins/state/index.cjs +1 -1
  25. package/build/plugins/state/index.mjs +1 -1
  26. package/build/plugins/toolbox/index.cjs +1 -1
  27. package/build/plugins/toolbox/index.mjs +1 -1
  28. package/package.json +1 -1
  29. package/build/chunks/AssetCache-Dhi6x0l3.cjs +0 -1
  30. package/build/chunks/AssetLoader-ClY_NYr-.cjs +0 -3
  31. package/build/chunks/AssetLoader-EA8JPhJt.mjs +0 -499
@@ -1,499 +0,0 @@
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-smInt9po.mjs";
7
- import { Group as b, BufferGeometry as k, BufferAttribute as E, MeshStandardMaterial as F, Mesh as N } from "three/webgpu";
8
- import "three/examples/jsm/loaders/HDRLoader.js";
9
- import "three/tsl";
10
- import { g as x, i as G } from "./isFileTypeSupported-4wdgLa3R.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-BUet32OG.mjs";
14
- function v() {
15
- let _, r;
16
- onmessage = function(e) {
17
- const n = e.data;
18
- switch (n.type) {
19
- case "init":
20
- _ = n.decoderConfig, r = new Promise(function(a) {
21
- _.onModuleLoaded = function(u) {
22
- a({ draco: u });
23
- }, DracoDecoderModule(_);
24
- });
25
- break;
26
- case "decode":
27
- const i = n.buffer, d = n.taskConfig;
28
- r.then((a) => {
29
- const u = a.draco, c = new u.Decoder();
30
- try {
31
- const f = s(
32
- u,
33
- c,
34
- new Int8Array(i),
35
- d
36
- ), p = f.attributes.map(
37
- (m) => m.array.buffer
38
- );
39
- f.index && p.push(f.index.array.buffer), self.postMessage(
40
- { type: "decode", id: n.id, geometry: f },
41
- p
42
- );
43
- } catch (f) {
44
- console.error(f), self.postMessage({
45
- type: "error",
46
- id: n.id,
47
- error: f.message
48
- });
49
- } finally {
50
- u.destroy(c);
51
- }
52
- });
53
- break;
54
- }
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);
60
- if (p === e.TRIANGULAR_MESH)
61
- c = new e.Mesh(), f = n.DecodeArrayToMesh(
62
- i,
63
- i.byteLength,
64
- c
65
- );
66
- else if (p === e.POINT_CLOUD)
67
- c = new e.PointCloud(), f = n.DecodeArrayToPointCloud(
68
- i,
69
- i.byteLength,
70
- c
71
- );
72
- else
73
- throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
74
- if (!f.ok() || c.ptr === 0)
75
- throw new Error(
76
- "THREE.DRACOLoader: Decoding failed: " + f.error_msg()
77
- );
78
- const m = { index: null, attributes: [] };
79
- for (const g in a) {
80
- const w = self[u[g]];
81
- let y, A;
82
- if (d.useUniqueIDs)
83
- A = a[g], y = n.GetAttributeByUniqueId(
84
- c,
85
- A
86
- );
87
- else {
88
- if (A = n.GetAttributeId(
89
- c,
90
- e[a[g]]
91
- ), A === -1) continue;
92
- y = n.GetAttribute(c, A);
93
- }
94
- const S = o(
95
- e,
96
- n,
97
- c,
98
- g,
99
- w,
100
- y
101
- );
102
- g === "color" && (S.vertexColorSpace = d.vertexColorSpace), m.attributes.push(S);
103
- }
104
- return p === e.TRIANGULAR_MESH && (m.index = t(e, n, c)), e.destroy(c), m;
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(
110
- e.HEAPF32.buffer,
111
- c,
112
- a
113
- ).slice();
114
- return e._free(c), { array: f, itemSize: 1 };
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);
118
- n.GetAttributeDataArrayForAllPoints(
119
- i,
120
- u,
121
- g,
122
- m,
123
- w
124
- );
125
- const y = new a(
126
- e.HEAPF32.buffer,
127
- w,
128
- p
129
- ).slice();
130
- return e._free(w), {
131
- name: d,
132
- array: y,
133
- itemSize: c
134
- };
135
- }
136
- function l(e, n) {
137
- switch (n) {
138
- case Float32Array:
139
- return e.DT_FLOAT32;
140
- case Int8Array:
141
- return e.DT_INT8;
142
- case Int16Array:
143
- return e.DT_INT16;
144
- case Int32Array:
145
- return e.DT_INT32;
146
- case Uint8Array:
147
- return e.DT_UINT8;
148
- case Uint16Array:
149
- return e.DT_UINT16;
150
- case Uint32Array:
151
- return e.DT_UINT32;
152
- }
153
- }
154
- }
155
- const L = {
156
- LOAD_DRACO_JS_DECODER: async () => (await import("three/examples/jsm/libs/draco/draco_decoder.js?raw")).default,
157
- LOAD_DRACO_WASM_WRAPPER: async () => (await import("three/examples/jsm/libs/draco/draco_wasm_wrapper.js?raw")).default,
158
- LOAD_DRACO_WASM_DECODER: async () => {
159
- const _ = (await import("three/examples/jsm/libs/draco/draco_decoder.wasm?url")).default;
160
- return await (await fetch(_)).arrayBuffer();
161
- }
162
- };
163
- class j extends W {
164
- constructor() {
165
- super(...arguments);
166
- h(this, "decoderPending", null);
167
- h(this, "decoderConfig", {
168
- type: "js",
169
- wasmBinary: null
170
- });
171
- h(this, "workerSourceURL", "");
172
- }
173
- async _initDecoder() {
174
- if (this.decoderPending) return this.decoderPending;
175
- const s = typeof WebAssembly != "object" || this.decoderConfig.type === "js", t = [];
176
- return s ? t.push(
177
- L.LOAD_DRACO_JS_DECODER()
178
- ) : (t.push(
179
- L.LOAD_DRACO_WASM_WRAPPER()
180
- ), t.push(
181
- L.LOAD_DRACO_WASM_DECODER()
182
- )), this.decoderPending = Promise.all(t).then(
183
- (o) => {
184
- const l = o[0];
185
- s || (this.decoderConfig.wasmBinary = o[1]);
186
- const e = v.toString(), n = [
187
- "/* draco decoder */",
188
- l,
189
- "",
190
- "/* worker */",
191
- e.substring(e.indexOf("{") + 1, e.lastIndexOf("}"))
192
- ].join(`
193
- `);
194
- this.workerSourceURL = URL.createObjectURL(new Blob([n]));
195
- }
196
- ), this.decoderPending;
197
- }
198
- }
199
- function B() {
200
- let _ = null, r = null;
201
- const s = [
202
- [
203
- /'CONFIG_CONTROL_DESIGN'\s*\)/g,
204
- "'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF')"
205
- ],
206
- [
207
- /'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF\.\s*\{[\s\S]*?\}\s*'/g,
208
- "'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF'"
209
- ]
210
- ];
211
- function t() {
212
- return _ || (_ = occtimportjs({
213
- // eslint-disable-line no-undef
214
- locateFile: function() {
215
- return r;
216
- }
217
- })), _;
218
- }
219
- 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);
223
- }
224
- return new Uint8Array(i.encode(d));
225
- }
226
- function l(e, n) {
227
- var i = o(n);
228
- try {
229
- var d = e.ReadStepFile(i, null);
230
- if (d.success && d.root) return d;
231
- } catch {
232
- }
233
- try {
234
- return e.ReadStepFile(n, null);
235
- } catch {
236
- return {
237
- success: !1,
238
- root: { meshes: [], children: [] },
239
- meshes: []
240
- };
241
- }
242
- }
243
- onmessage = async function(e) {
244
- var n = e.data;
245
- switch (n.type) {
246
- case "init":
247
- r = n.wasmUrl;
248
- break;
249
- case "parse":
250
- 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) {
253
- self.postMessage({
254
- type: "error",
255
- id: n.id,
256
- error: "Failed to parse CAD file"
257
- });
258
- return;
259
- }
260
- self.postMessage({
261
- type: "result",
262
- id: n.id,
263
- result: u
264
- });
265
- } catch (c) {
266
- self.postMessage({
267
- type: "error",
268
- id: n.id,
269
- error: c instanceof Error ? c.message : String(c)
270
- });
271
- }
272
- break;
273
- }
274
- };
275
- }
276
- const T = {
277
- LOAD_OCCT_JS: async () => (await import("./occt-import-js-D-bjjBtk.mjs")).default,
278
- LOAD_OCCT_WASM_URL: async () => (await import("./occt-import-js-ekuHaP1Z.mjs")).default
279
- };
280
- class H {
281
- constructor() {
282
- h(this, "_workerPending", null);
283
- h(this, "_worker", null);
284
- h(this, "_nextId", 0);
285
- h(this, "_pending", /* @__PURE__ */ new Map());
286
- }
287
- /**
288
- * Create (or return existing) blob-URL worker.
289
- * Loads occt-import-js JS as raw text, concatenates with STEPWorker
290
- * function body, and creates a classic (non-module) worker.
291
- */
292
- _getWorker() {
293
- return this._workerPending ? this._workerPending : (this._workerPending = (async () => {
294
- const [
295
- r,
296
- s
297
- ] = await Promise.all([
298
- T.LOAD_OCCT_JS(),
299
- T.LOAD_OCCT_WASM_URL()
300
- ]), t = B.toString(), o = [
301
- "/* occt-import-js */",
302
- r,
303
- "",
304
- "/* step worker */",
305
- t.substring(t.indexOf("{") + 1, t.lastIndexOf("}"))
306
- ].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")
312
- try {
313
- f.resolve(this._buildScene(u));
314
- } catch (p) {
315
- f.reject(
316
- p instanceof Error ? p : new Error(String(p))
317
- );
318
- }
319
- else
320
- f.reject(new Error(c ?? "Worker error"));
321
- }, e.onerror = (i) => {
322
- for (const [
323
- ,
324
- { reject: d }
325
- ] of this._pending)
326
- d(new Error(i.message ?? "Worker error"));
327
- this._pending.clear();
328
- }, this._worker = e, e;
329
- })(), this._workerPending);
330
- }
331
- /**
332
- * Parse STEP or IGES file content and return a Three.js Object3D
333
- */
334
- async parseAsync(r, s) {
335
- const t = this._nextId++, o = await this._getWorker();
336
- return new Promise((l, e) => {
337
- this._pending.set(t, { resolve: l, reject: e });
338
- const n = r.slice(0);
339
- o.postMessage({ type: "parse", id: t, buffer: n, fileType: s }, [
340
- n
341
- ]);
342
- });
343
- }
344
- /**
345
- * Dispose the worker. Call when the loader is no longer needed.
346
- */
347
- dispose() {
348
- if (this._worker) {
349
- for (const [
350
- ,
351
- { reject: r }
352
- ] of this._pending)
353
- r(new Error("STEPLoader disposed"));
354
- this._pending.clear(), this._worker.terminate(), this._worker = null, this._workerPending = null;
355
- }
356
- }
357
- _buildScene(r) {
358
- const s = new b();
359
- 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
- }
361
- _buildNode(r, s, t) {
362
- const o = new b();
363
- o.name = r.name ?? "Part";
364
- for (const l of r.meshes) {
365
- const e = s[l];
366
- if (e != null && e.attributes) {
367
- const n = this._createMesh(e);
368
- o.add(n);
369
- }
370
- }
371
- for (const l of r.children)
372
- this._buildNode(l, s, o);
373
- t.add(o);
374
- }
375
- _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(
379
- "position",
380
- new E(new Float32Array(s.array), 3)
381
- ), (d = t == null ? void 0 : t.array) != null && d.length ? l.setAttribute(
382
- "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)
386
- );
387
- const e = r.color, n = new F({
388
- metalness: 0.3,
389
- roughness: 0.6
390
- });
391
- 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;
394
- }
395
- }
396
- class te {
397
- constructor() {
398
- h(this, "_gltfLoader");
399
- h(this, "_usdLoader");
400
- 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();
403
- }
404
- async load(r, s) {
405
- let t;
406
- if (s)
407
- t = s;
408
- else if (t = x(r), t.length === 0 && (t = await this._detectFileTypeFromContent(r), t.length === 0))
409
- throw new R(
410
- "No file extension found in URI",
411
- ""
412
- );
413
- if (!G(t))
414
- throw new R(
415
- `Unsupported file type: ${t}. Supported types: ${M.join(", ")}`,
416
- t
417
- );
418
- const o = D.read(r);
419
- if (o)
420
- return o.arrayBuffer ? this._parse(o.arrayBuffer, t) : o.promise.then((n) => this._parse(n, t));
421
- const e = await D.create(r).load();
422
- return this._parse(e, t);
423
- }
424
- /**
425
- * Detects file type from content (magic bytes)
426
- * @param uri - The URI to load and detect
427
- * @returns The detected file extension or empty string if detection fails
428
- */
429
- async _detectFileTypeFromContent(r) {
430
- try {
431
- const s = D.read(r);
432
- let t;
433
- s ? s.arrayBuffer ? t = s.arrayBuffer : t = await s.promise : t = await D.create(r).load();
434
- const o = new Uint8Array(t);
435
- return o.length >= 12 && String.fromCharCode(
436
- o[0],
437
- o[1],
438
- o[2],
439
- o[3]
440
- ) === "glTF" ? o[12] === 0 ? "glb" : "gltf" : o.length >= 4 && o[0] === 80 && // 'P'
441
- o[1] === 75 && // 'K'
442
- (o[2] === 3 || o[2] === 5) && (o[3] === 4 || o[3] === 6) ? "usdz" : o.length >= 20 && new TextDecoder("ascii").decode(
443
- o.subarray(0, 20)
444
- ).startsWith("ISO-10303-21") ? "step" : o.length >= 80 && o[72] === 83 ? "iges" : "";
445
- } catch {
446
- return "";
447
- }
448
- }
449
- /**
450
- * parse function for the chunk
451
- * @param arrayBuffer - the array buffer to parse, will be provided within the chunk
452
- * @param type - the file type of the array buffer
453
- * @returns the parsed object, will be stored within the chunk
454
- */
455
- async _parse(r, s) {
456
- try {
457
- switch (s) {
458
- case "glb":
459
- case "gltf": {
460
- const t = await this._gltfLoader.parseAsync(
461
- r,
462
- ""
463
- );
464
- return t.scene.animations = t.animations, t.scene;
465
- }
466
- case "usdz": {
467
- const t = this._usdLoader.parse(r);
468
- return t.animations = [], t;
469
- }
470
- case "step":
471
- case "stp": {
472
- const t = await this._stepLoader.parseAsync(
473
- r,
474
- s
475
- );
476
- return t.animations = [], t;
477
- }
478
- case "iges":
479
- case "igs": {
480
- const t = await this._stepLoader.parseAsync(
481
- r,
482
- s
483
- );
484
- return t.animations = [], t;
485
- }
486
- }
487
- } catch (t) {
488
- throw t instanceof Error ? new O(
489
- `Failed to parse ${s} file: ${t.message}`,
490
- t
491
- ) : new O(`Failed to parse ${s} file`);
492
- }
493
- }
494
- }
495
- export {
496
- te as A,
497
- v as D,
498
- j as a
499
- };