@shopware-ag/dive 3.0.4-beta.9 → 3.0.5
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.
- package/build/chunks/AssetCache-Cx-7ZrLh.mjs +81 -0
- package/build/chunks/AssetCache-Dz3QV4v9.cjs +1 -0
- package/build/chunks/AssetLoader-DIdy7ilw.mjs +499 -0
- package/build/chunks/AssetLoader-hRB8Yi1R.cjs +3 -0
- package/build/chunks/FileTypes-BAZBx71E.cjs +29 -0
- package/build/chunks/{FileTypes-C5Pw8sMd.mjs → FileTypes-CqQRve61.mjs} +372 -405
- package/build/chunks/{PerspectiveCamera-35cBnxwG.mjs → PerspectiveCamera-B5TvUzTa.mjs} +2 -2
- package/build/chunks/{isFileTypeSupported-BJG6_fK4.cjs → isFileTypeSupported-Bcoe_7V1.cjs} +1 -1
- package/build/chunks/{isFileTypeSupported-DnEHvsHJ.mjs → isFileTypeSupported-DIxRBRrm.mjs} +1 -1
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +61 -63
- package/build/engine/Dive.d.ts +1 -4
- package/build/engine/canvas/CanvasLifecycleManager.d.ts +10 -2
- package/build/engine/clock/Clock.d.ts +1 -2
- package/build/engine/environment/Environment.d.ts +2 -2
- package/build/engine/index.d.ts +0 -2
- package/build/engine/renderer/Renderer.d.ts +1 -1
- package/build/engine/view/View.d.ts +4 -2
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +1 -1
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetcache/src/chunk/Chunk.d.ts +0 -5
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +2 -2
- package/build/plugins/assetloader/src/loader/AssetLoader.d.ts +0 -2
- package/build/plugins/mediacreator/index.cjs +1 -1
- package/build/plugins/mediacreator/index.mjs +5 -5
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.mjs +9 -10
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +17 -17
- package/build/plugins/state/index.cjs +1 -1
- package/build/plugins/state/index.mjs +1 -1
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +2 -2
- package/package.json +6 -2
- package/build/chunks/AssetCache-BOcd08Uz.cjs +0 -1
- package/build/chunks/AssetCache-Uvek9Lmo.mjs +0 -194
- package/build/chunks/AssetLoader-BNE2SB25.mjs +0 -663
- package/build/chunks/AssetLoader-BNu1PH9Z.cjs +0 -3
- package/build/chunks/FileTypes-BRIPrVRB.cjs +0 -29
- package/build/engine/promise/abortable/AbortablePromise.d.ts +0 -17
- package/build/engine/promise/deferred/DeferredPromise.d.ts +0 -18
|
@@ -1,663 +0,0 @@
|
|
|
1
|
-
var T = Object.defineProperty;
|
|
2
|
-
var I = (u, t, o) => t in u ? T(u, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : u[t] = o;
|
|
3
|
-
var _ = (u, t, o) => I(u, typeof t != "symbol" ? t + "" : t, o);
|
|
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 k } from "./FileTypes-C5Pw8sMd.mjs";
|
|
7
|
-
import { Group as S, BufferGeometry as F, BufferAttribute as D, MeshStandardMaterial as N, Mesh as G } from "three/webgpu";
|
|
8
|
-
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
9
|
-
import "three/tsl";
|
|
10
|
-
import { g as v, i as W } from "./isFileTypeSupported-DnEHvsHJ.mjs";
|
|
11
|
-
import { F as C, P as R } from "./parse-error-DfOPyLWM.mjs";
|
|
12
|
-
import { DRACOLoader as B } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
13
|
-
import { A as L } from "./AssetCache-Uvek9Lmo.mjs";
|
|
14
|
-
function H() {
|
|
15
|
-
let u, t;
|
|
16
|
-
onmessage = function(s) {
|
|
17
|
-
const n = s.data;
|
|
18
|
-
switch (n.type) {
|
|
19
|
-
case "init":
|
|
20
|
-
u = n.decoderConfig, t = new Promise(function(c) {
|
|
21
|
-
u.onModuleLoaded = function(h) {
|
|
22
|
-
c({ draco: h });
|
|
23
|
-
}, DracoDecoderModule(u);
|
|
24
|
-
});
|
|
25
|
-
break;
|
|
26
|
-
case "decode":
|
|
27
|
-
const a = n.buffer, l = n.taskConfig;
|
|
28
|
-
t.then((c) => {
|
|
29
|
-
const h = c.draco, d = new h.Decoder();
|
|
30
|
-
try {
|
|
31
|
-
const f = o(
|
|
32
|
-
h,
|
|
33
|
-
d,
|
|
34
|
-
new Int8Array(a),
|
|
35
|
-
l
|
|
36
|
-
), p = f.attributes.map(
|
|
37
|
-
(g) => g.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
|
-
h.destroy(d);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
function o(s, n, a, l) {
|
|
57
|
-
const c = l.attributeIDs, h = l.attributeTypes;
|
|
58
|
-
let d, f;
|
|
59
|
-
const p = n.GetEncodedGeometryType(a);
|
|
60
|
-
if (p === s.TRIANGULAR_MESH)
|
|
61
|
-
d = new s.Mesh(), f = n.DecodeArrayToMesh(
|
|
62
|
-
a,
|
|
63
|
-
a.byteLength,
|
|
64
|
-
d
|
|
65
|
-
);
|
|
66
|
-
else if (p === s.POINT_CLOUD)
|
|
67
|
-
d = new s.PointCloud(), f = n.DecodeArrayToPointCloud(
|
|
68
|
-
a,
|
|
69
|
-
a.byteLength,
|
|
70
|
-
d
|
|
71
|
-
);
|
|
72
|
-
else
|
|
73
|
-
throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
|
|
74
|
-
if (!f.ok() || d.ptr === 0)
|
|
75
|
-
throw new Error(
|
|
76
|
-
"THREE.DRACOLoader: Decoding failed: " + f.error_msg()
|
|
77
|
-
);
|
|
78
|
-
const g = { index: null, attributes: [] };
|
|
79
|
-
for (const m in c) {
|
|
80
|
-
const w = self[h[m]];
|
|
81
|
-
let A, y;
|
|
82
|
-
if (l.useUniqueIDs)
|
|
83
|
-
y = c[m], A = n.GetAttributeByUniqueId(
|
|
84
|
-
d,
|
|
85
|
-
y
|
|
86
|
-
);
|
|
87
|
-
else {
|
|
88
|
-
if (y = n.GetAttributeId(
|
|
89
|
-
d,
|
|
90
|
-
s[c[m]]
|
|
91
|
-
), y === -1) continue;
|
|
92
|
-
A = n.GetAttribute(d, y);
|
|
93
|
-
}
|
|
94
|
-
const b = e(
|
|
95
|
-
s,
|
|
96
|
-
n,
|
|
97
|
-
d,
|
|
98
|
-
m,
|
|
99
|
-
w,
|
|
100
|
-
A
|
|
101
|
-
);
|
|
102
|
-
m === "color" && (b.vertexColorSpace = l.vertexColorSpace), g.attributes.push(b);
|
|
103
|
-
}
|
|
104
|
-
return p === s.TRIANGULAR_MESH && (g.index = r(s, n, d)), s.destroy(d), g;
|
|
105
|
-
}
|
|
106
|
-
function r(s, n, a) {
|
|
107
|
-
const c = a.num_faces() * 3, h = c * 4, d = s._malloc(h);
|
|
108
|
-
n.GetTrianglesUInt32Array(a, h, d);
|
|
109
|
-
const f = new Uint32Array(
|
|
110
|
-
s.HEAPF32.buffer,
|
|
111
|
-
d,
|
|
112
|
-
c
|
|
113
|
-
).slice();
|
|
114
|
-
return s._free(d), { array: f, itemSize: 1 };
|
|
115
|
-
}
|
|
116
|
-
function e(s, n, a, l, c, h) {
|
|
117
|
-
const d = h.num_components(), p = a.num_points() * d, g = p * c.BYTES_PER_ELEMENT, m = i(s, c), w = s._malloc(g);
|
|
118
|
-
n.GetAttributeDataArrayForAllPoints(
|
|
119
|
-
a,
|
|
120
|
-
h,
|
|
121
|
-
m,
|
|
122
|
-
g,
|
|
123
|
-
w
|
|
124
|
-
);
|
|
125
|
-
const A = new c(
|
|
126
|
-
s.HEAPF32.buffer,
|
|
127
|
-
w,
|
|
128
|
-
p
|
|
129
|
-
).slice();
|
|
130
|
-
return s._free(w), {
|
|
131
|
-
name: l,
|
|
132
|
-
array: A,
|
|
133
|
-
itemSize: d
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function i(s, n) {
|
|
137
|
-
switch (n) {
|
|
138
|
-
case Float32Array:
|
|
139
|
-
return s.DT_FLOAT32;
|
|
140
|
-
case Int8Array:
|
|
141
|
-
return s.DT_INT8;
|
|
142
|
-
case Int16Array:
|
|
143
|
-
return s.DT_INT16;
|
|
144
|
-
case Int32Array:
|
|
145
|
-
return s.DT_INT32;
|
|
146
|
-
case Uint8Array:
|
|
147
|
-
return s.DT_UINT8;
|
|
148
|
-
case Uint16Array:
|
|
149
|
-
return s.DT_UINT16;
|
|
150
|
-
case Uint32Array:
|
|
151
|
-
return s.DT_UINT32;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
const E = {
|
|
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 u = (await import("three/examples/jsm/libs/draco/draco_decoder.wasm?url")).default;
|
|
160
|
-
return await (await fetch(u)).arrayBuffer();
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
class j extends B {
|
|
164
|
-
constructor() {
|
|
165
|
-
super(...arguments);
|
|
166
|
-
_(this, "decoderPending", null);
|
|
167
|
-
_(this, "decoderConfig", {
|
|
168
|
-
type: "js",
|
|
169
|
-
wasmBinary: null
|
|
170
|
-
});
|
|
171
|
-
_(this, "workerSourceURL", "");
|
|
172
|
-
}
|
|
173
|
-
async _initDecoder() {
|
|
174
|
-
if (this.decoderPending) return this.decoderPending;
|
|
175
|
-
const o = typeof WebAssembly != "object" || this.decoderConfig.type === "js", r = [];
|
|
176
|
-
return o ? r.push(
|
|
177
|
-
E.LOAD_DRACO_JS_DECODER()
|
|
178
|
-
) : (r.push(
|
|
179
|
-
E.LOAD_DRACO_WASM_WRAPPER()
|
|
180
|
-
), r.push(
|
|
181
|
-
E.LOAD_DRACO_WASM_DECODER()
|
|
182
|
-
)), this.decoderPending = Promise.all(r).then(
|
|
183
|
-
(e) => {
|
|
184
|
-
const i = e[0];
|
|
185
|
-
o || (this.decoderConfig.wasmBinary = e[1]);
|
|
186
|
-
const s = H.toString(), n = [
|
|
187
|
-
"/* draco decoder */",
|
|
188
|
-
i,
|
|
189
|
-
"",
|
|
190
|
-
"/* worker */",
|
|
191
|
-
s.substring(s.indexOf("{") + 1, s.lastIndexOf("}"))
|
|
192
|
-
].join(`
|
|
193
|
-
`);
|
|
194
|
-
this.workerSourceURL = URL.createObjectURL(new Blob([n]));
|
|
195
|
-
}
|
|
196
|
-
), this.decoderPending;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
function z() {
|
|
200
|
-
let u = null, t = null;
|
|
201
|
-
const o = [
|
|
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 r() {
|
|
212
|
-
return u || (u = occtimportjs({
|
|
213
|
-
// eslint-disable-line no-undef
|
|
214
|
-
locateFile: function() {
|
|
215
|
-
return t;
|
|
216
|
-
}
|
|
217
|
-
})), u;
|
|
218
|
-
}
|
|
219
|
-
function e(s) {
|
|
220
|
-
for (var n = new TextDecoder("utf-8", { fatal: !1 }), a = new TextEncoder(), l = n.decode(s), c = 0; c < o.length; c++) {
|
|
221
|
-
var h = o[c][0], d = o[c][1];
|
|
222
|
-
l = l.replace(h, d);
|
|
223
|
-
}
|
|
224
|
-
return new Uint8Array(a.encode(l));
|
|
225
|
-
}
|
|
226
|
-
function i(s, n) {
|
|
227
|
-
var a = e(n);
|
|
228
|
-
try {
|
|
229
|
-
var l = s.ReadStepFile(a, null);
|
|
230
|
-
if (l.success && l.root) return l;
|
|
231
|
-
} catch {
|
|
232
|
-
}
|
|
233
|
-
try {
|
|
234
|
-
return s.ReadStepFile(n, null);
|
|
235
|
-
} catch {
|
|
236
|
-
return {
|
|
237
|
-
success: !1,
|
|
238
|
-
root: { meshes: [], children: [] },
|
|
239
|
-
meshes: []
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
onmessage = async function(s) {
|
|
244
|
-
var n = s.data;
|
|
245
|
-
switch (n.type) {
|
|
246
|
-
case "init":
|
|
247
|
-
t = n.wasmUrl;
|
|
248
|
-
break;
|
|
249
|
-
case "parse":
|
|
250
|
-
try {
|
|
251
|
-
var a = await r(), l = new Uint8Array(n.buffer), c = n.fileType, h;
|
|
252
|
-
if (c === "step" || c === "stp" ? h = i(a, l) : h = a.ReadIgesFile(l, null), !h.success || !h.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: h
|
|
264
|
-
});
|
|
265
|
-
} catch (d) {
|
|
266
|
-
self.postMessage({
|
|
267
|
-
type: "error",
|
|
268
|
-
id: n.id,
|
|
269
|
-
error: d instanceof Error ? d.message : String(d)
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
const O = {
|
|
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 J {
|
|
281
|
-
constructor() {
|
|
282
|
-
_(this, "_workerPending", null);
|
|
283
|
-
_(this, "_worker", null);
|
|
284
|
-
_(this, "_nextId", 0);
|
|
285
|
-
_(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
|
-
t,
|
|
296
|
-
o
|
|
297
|
-
] = await Promise.all([
|
|
298
|
-
O.LOAD_OCCT_JS(),
|
|
299
|
-
O.LOAD_OCCT_WASM_URL()
|
|
300
|
-
]), r = z.toString(), e = [
|
|
301
|
-
"/* occt-import-js */",
|
|
302
|
-
t,
|
|
303
|
-
"",
|
|
304
|
-
"/* step worker */",
|
|
305
|
-
r.substring(r.indexOf("{") + 1, r.lastIndexOf("}"))
|
|
306
|
-
].join(`
|
|
307
|
-
`), i = URL.createObjectURL(new Blob([e])), s = new Worker(i), n = new URL(o, window.location.href).href;
|
|
308
|
-
return s.postMessage({ type: "init", wasmUrl: n }), s.onmessage = (a) => {
|
|
309
|
-
const { type: l, id: c, result: h, error: d } = a.data, f = this._pending.get(c);
|
|
310
|
-
if (f)
|
|
311
|
-
if (this._pending.delete(c), l === "result")
|
|
312
|
-
try {
|
|
313
|
-
f.resolve(this._buildScene(h));
|
|
314
|
-
} catch (p) {
|
|
315
|
-
f.reject(
|
|
316
|
-
p instanceof Error ? p : new Error(String(p))
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
else
|
|
320
|
-
f.reject(new Error(d ?? "Worker error"));
|
|
321
|
-
}, s.onerror = (a) => {
|
|
322
|
-
for (const [
|
|
323
|
-
,
|
|
324
|
-
{ reject: l }
|
|
325
|
-
] of this._pending)
|
|
326
|
-
l(new Error(a.message ?? "Worker error"));
|
|
327
|
-
this._pending.clear();
|
|
328
|
-
}, this._worker = s, s;
|
|
329
|
-
})(), this._workerPending);
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Parse STEP or IGES file content and return a Three.js Object3D
|
|
333
|
-
*/
|
|
334
|
-
async parseAsync(t, o) {
|
|
335
|
-
const r = this._nextId++, e = await this._getWorker();
|
|
336
|
-
return new Promise((i, s) => {
|
|
337
|
-
this._pending.set(r, { resolve: i, reject: s });
|
|
338
|
-
const n = t.slice(0);
|
|
339
|
-
e.postMessage({ type: "parse", id: r, buffer: n, fileType: o }, [
|
|
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: t }
|
|
352
|
-
] of this._pending)
|
|
353
|
-
t(new Error("STEPLoader disposed"));
|
|
354
|
-
this._pending.clear(), this._worker.terminate(), this._worker = null, this._workerPending = null;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
_buildScene(t) {
|
|
358
|
-
const o = new S();
|
|
359
|
-
return o.name = t.root.name ?? "CAD Model", this._buildNode(t.root, t.meshes, o), o.rotation.x = -Math.PI / 2, o.rotation.z = Math.PI / 2, o;
|
|
360
|
-
}
|
|
361
|
-
_buildNode(t, o, r) {
|
|
362
|
-
const e = new S();
|
|
363
|
-
e.name = t.name ?? "Part";
|
|
364
|
-
for (const i of t.meshes) {
|
|
365
|
-
const s = o[i];
|
|
366
|
-
if (s != null && s.attributes) {
|
|
367
|
-
const n = this._createMesh(s);
|
|
368
|
-
e.add(n);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
for (const i of t.children)
|
|
372
|
-
this._buildNode(i, o, e);
|
|
373
|
-
r.add(e);
|
|
374
|
-
}
|
|
375
|
-
_createMesh(t) {
|
|
376
|
-
var l, c;
|
|
377
|
-
const { position: o, normal: r } = t.attributes, e = t.index ?? t.attributes.index, i = new F();
|
|
378
|
-
i.setAttribute(
|
|
379
|
-
"position",
|
|
380
|
-
new D(new Float32Array(o.array), 3)
|
|
381
|
-
), (l = r == null ? void 0 : r.array) != null && l.length ? i.setAttribute(
|
|
382
|
-
"normal",
|
|
383
|
-
new D(new Float32Array(r.array), 3)
|
|
384
|
-
) : i.computeVertexNormals(), (c = e == null ? void 0 : e.array) != null && c.length && i.setIndex(
|
|
385
|
-
new D(new Uint32Array(e.array), 1)
|
|
386
|
-
);
|
|
387
|
-
const s = t.color, n = new N({
|
|
388
|
-
metalness: 0.3,
|
|
389
|
-
roughness: 0.6
|
|
390
|
-
});
|
|
391
|
-
s && s.length >= 3 ? n.color.setRGB(s[0], s[1], s[2]) : n.color.setHex(13421772);
|
|
392
|
-
const a = new G(i, n);
|
|
393
|
-
return a.name = t.name ?? "Mesh", a.castShadow = !0, a.receiveShadow = !0, a;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
const M = (u) => Array.isArray(u == null ? void 0 : u.children) ? u.children.length : 0;
|
|
397
|
-
class te {
|
|
398
|
-
constructor() {
|
|
399
|
-
_(this, "_gltfLoader");
|
|
400
|
-
_(this, "_usdLoader");
|
|
401
|
-
_(this, "_stepLoader");
|
|
402
|
-
const t = new j();
|
|
403
|
-
t.setDecoderConfig({ type: "wasm" }), this._gltfLoader = new P(), this._gltfLoader.setDRACOLoader(t), this._usdLoader = new U(), this._stepLoader = new J();
|
|
404
|
-
}
|
|
405
|
-
_logLoad(t, o = {}) {
|
|
406
|
-
console.info("[AssetLoader.load]", t, o);
|
|
407
|
-
}
|
|
408
|
-
_logLoadError(t, o, r = {}) {
|
|
409
|
-
console.error("[AssetLoader.load]", t, {
|
|
410
|
-
...r,
|
|
411
|
-
error: o instanceof Error ? o.message : String(o)
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
async load(t, o) {
|
|
415
|
-
const r = performance.now();
|
|
416
|
-
let e;
|
|
417
|
-
if (this._logLoad("start", {
|
|
418
|
-
uri: t,
|
|
419
|
-
fileType: o ?? null
|
|
420
|
-
}), o)
|
|
421
|
-
e = o, this._logLoad("using-explicit-file-type", {
|
|
422
|
-
uri: t,
|
|
423
|
-
extension: e,
|
|
424
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
425
|
-
});
|
|
426
|
-
else if (e = v(t), this._logLoad("derived-file-type-from-uri", {
|
|
427
|
-
uri: t,
|
|
428
|
-
extension: e,
|
|
429
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
430
|
-
}), e.length === 0 && (this._logLoad("detect-file-type-from-content-start", {
|
|
431
|
-
uri: t,
|
|
432
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
433
|
-
}), e = await this._detectFileTypeFromContent(t), this._logLoad("detect-file-type-from-content-complete", {
|
|
434
|
-
uri: t,
|
|
435
|
-
extension: e,
|
|
436
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
437
|
-
}), e.length === 0))
|
|
438
|
-
throw new C(
|
|
439
|
-
"No file extension found in URI",
|
|
440
|
-
""
|
|
441
|
-
);
|
|
442
|
-
if (!W(e))
|
|
443
|
-
throw new C(
|
|
444
|
-
`Unsupported file type: ${e}. Supported types: ${k.join(", ")}`,
|
|
445
|
-
e
|
|
446
|
-
);
|
|
447
|
-
const i = L.read(t);
|
|
448
|
-
if (this._logLoad(i ? "cache-hit" : "cache-miss", {
|
|
449
|
-
uri: t,
|
|
450
|
-
extension: e,
|
|
451
|
-
hasArrayBuffer: !!(i != null && i.arrayBuffer),
|
|
452
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
453
|
-
}), i)
|
|
454
|
-
return i.arrayBuffer ? (this._logLoad("parse-start", {
|
|
455
|
-
uri: t,
|
|
456
|
-
extension: e,
|
|
457
|
-
source: "cache-array-buffer",
|
|
458
|
-
byteLength: i.arrayBuffer.byteLength,
|
|
459
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
460
|
-
}), this._parse(i.arrayBuffer, e, {
|
|
461
|
-
uri: t,
|
|
462
|
-
source: "cache-array-buffer",
|
|
463
|
-
startedAt: r
|
|
464
|
-
})) : (this._logLoad("await-existing-cache-promise-start", {
|
|
465
|
-
uri: t,
|
|
466
|
-
extension: e,
|
|
467
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
468
|
-
}), i.promise.then((a) => (this._logLoad("await-existing-cache-promise-resolved", {
|
|
469
|
-
uri: t,
|
|
470
|
-
extension: e,
|
|
471
|
-
byteLength: a.byteLength,
|
|
472
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
473
|
-
}), this._logLoad("parse-start", {
|
|
474
|
-
uri: t,
|
|
475
|
-
extension: e,
|
|
476
|
-
source: "cache-promise",
|
|
477
|
-
byteLength: a.byteLength,
|
|
478
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
479
|
-
}), this._parse(a, e, {
|
|
480
|
-
uri: t,
|
|
481
|
-
source: "cache-promise",
|
|
482
|
-
startedAt: r
|
|
483
|
-
}))));
|
|
484
|
-
const s = L.create(t);
|
|
485
|
-
this._logLoad("chunk-created", {
|
|
486
|
-
uri: t,
|
|
487
|
-
extension: e,
|
|
488
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
489
|
-
}), this._logLoad("chunk-load-start", {
|
|
490
|
-
uri: t,
|
|
491
|
-
extension: e,
|
|
492
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
493
|
-
});
|
|
494
|
-
const n = await s.load();
|
|
495
|
-
return this._logLoad("chunk-load-resolved", {
|
|
496
|
-
uri: t,
|
|
497
|
-
extension: e,
|
|
498
|
-
byteLength: n.byteLength,
|
|
499
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
500
|
-
}), this._logLoad("parse-start", {
|
|
501
|
-
uri: t,
|
|
502
|
-
extension: e,
|
|
503
|
-
source: "fresh-chunk",
|
|
504
|
-
byteLength: n.byteLength,
|
|
505
|
-
elapsedMs: Math.round(performance.now() - r)
|
|
506
|
-
}), this._parse(n, e, {
|
|
507
|
-
uri: t,
|
|
508
|
-
source: "fresh-chunk",
|
|
509
|
-
startedAt: r
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* Detects file type from content (magic bytes)
|
|
514
|
-
* @param uri - The URI to load and detect
|
|
515
|
-
* @returns The detected file extension or empty string if detection fails
|
|
516
|
-
*/
|
|
517
|
-
async _detectFileTypeFromContent(t) {
|
|
518
|
-
try {
|
|
519
|
-
const o = L.read(t);
|
|
520
|
-
let r;
|
|
521
|
-
o ? o.arrayBuffer ? r = o.arrayBuffer : r = await o.promise : r = await L.create(t).load();
|
|
522
|
-
const e = new Uint8Array(r);
|
|
523
|
-
return e.length >= 12 && String.fromCharCode(
|
|
524
|
-
e[0],
|
|
525
|
-
e[1],
|
|
526
|
-
e[2],
|
|
527
|
-
e[3]
|
|
528
|
-
) === "glTF" ? e[12] === 0 ? "glb" : "gltf" : e.length >= 4 && e[0] === 80 && // 'P'
|
|
529
|
-
e[1] === 75 && // 'K'
|
|
530
|
-
(e[2] === 3 || e[2] === 5) && (e[3] === 4 || e[3] === 6) ? "usdz" : e.length >= 20 && new TextDecoder("ascii").decode(
|
|
531
|
-
e.subarray(0, 20)
|
|
532
|
-
).startsWith("ISO-10303-21") ? "step" : e.length >= 80 && e[72] === 83 ? "iges" : "";
|
|
533
|
-
} catch {
|
|
534
|
-
return "";
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* parse function for the chunk
|
|
539
|
-
* @param arrayBuffer - the array buffer to parse, will be provided within the chunk
|
|
540
|
-
* @param type - the file type of the array buffer
|
|
541
|
-
* @returns the parsed object, will be stored within the chunk
|
|
542
|
-
*/
|
|
543
|
-
async _parse(t, o, r) {
|
|
544
|
-
try {
|
|
545
|
-
switch (this._logLoad("parse-dispatch", {
|
|
546
|
-
uri: r.uri,
|
|
547
|
-
type: o,
|
|
548
|
-
source: r.source,
|
|
549
|
-
byteLength: t.byteLength,
|
|
550
|
-
elapsedMs: Math.round(performance.now() - r.startedAt)
|
|
551
|
-
}), o) {
|
|
552
|
-
case "glb":
|
|
553
|
-
case "gltf": {
|
|
554
|
-
this._logLoad("gltf-parse-start", {
|
|
555
|
-
uri: r.uri,
|
|
556
|
-
type: o,
|
|
557
|
-
source: r.source,
|
|
558
|
-
elapsedMs: Math.round(
|
|
559
|
-
performance.now() - r.startedAt
|
|
560
|
-
)
|
|
561
|
-
});
|
|
562
|
-
const e = await this._gltfLoader.parseAsync(
|
|
563
|
-
t,
|
|
564
|
-
""
|
|
565
|
-
);
|
|
566
|
-
return e.scene.animations = e.animations, this._logLoad("gltf-parse-complete", {
|
|
567
|
-
uri: r.uri,
|
|
568
|
-
type: o,
|
|
569
|
-
source: r.source,
|
|
570
|
-
childCount: M(e.scene),
|
|
571
|
-
animationCount: Array.isArray(e.animations) ? e.animations.length : 0,
|
|
572
|
-
elapsedMs: Math.round(
|
|
573
|
-
performance.now() - r.startedAt
|
|
574
|
-
)
|
|
575
|
-
}), e.scene;
|
|
576
|
-
}
|
|
577
|
-
case "usdz": {
|
|
578
|
-
this._logLoad("usdz-parse-start", {
|
|
579
|
-
uri: r.uri,
|
|
580
|
-
type: o,
|
|
581
|
-
source: r.source,
|
|
582
|
-
elapsedMs: Math.round(
|
|
583
|
-
performance.now() - r.startedAt
|
|
584
|
-
)
|
|
585
|
-
});
|
|
586
|
-
const e = this._usdLoader.parse(t);
|
|
587
|
-
return e.animations = [], this._logLoad("usdz-parse-complete", {
|
|
588
|
-
uri: r.uri,
|
|
589
|
-
type: o,
|
|
590
|
-
source: r.source,
|
|
591
|
-
childCount: M(e),
|
|
592
|
-
elapsedMs: Math.round(
|
|
593
|
-
performance.now() - r.startedAt
|
|
594
|
-
)
|
|
595
|
-
}), e;
|
|
596
|
-
}
|
|
597
|
-
case "step":
|
|
598
|
-
case "stp": {
|
|
599
|
-
this._logLoad("step-parse-start", {
|
|
600
|
-
uri: r.uri,
|
|
601
|
-
type: o,
|
|
602
|
-
source: r.source,
|
|
603
|
-
elapsedMs: Math.round(
|
|
604
|
-
performance.now() - r.startedAt
|
|
605
|
-
)
|
|
606
|
-
});
|
|
607
|
-
const e = await this._stepLoader.parseAsync(
|
|
608
|
-
t,
|
|
609
|
-
o
|
|
610
|
-
);
|
|
611
|
-
return e.animations = [], this._logLoad("step-parse-complete", {
|
|
612
|
-
uri: r.uri,
|
|
613
|
-
type: o,
|
|
614
|
-
source: r.source,
|
|
615
|
-
childCount: M(e),
|
|
616
|
-
elapsedMs: Math.round(
|
|
617
|
-
performance.now() - r.startedAt
|
|
618
|
-
)
|
|
619
|
-
}), e;
|
|
620
|
-
}
|
|
621
|
-
case "iges":
|
|
622
|
-
case "igs": {
|
|
623
|
-
this._logLoad("iges-parse-start", {
|
|
624
|
-
uri: r.uri,
|
|
625
|
-
type: o,
|
|
626
|
-
source: r.source,
|
|
627
|
-
elapsedMs: Math.round(
|
|
628
|
-
performance.now() - r.startedAt
|
|
629
|
-
)
|
|
630
|
-
});
|
|
631
|
-
const e = await this._stepLoader.parseAsync(
|
|
632
|
-
t,
|
|
633
|
-
o
|
|
634
|
-
);
|
|
635
|
-
return e.animations = [], this._logLoad("iges-parse-complete", {
|
|
636
|
-
uri: r.uri,
|
|
637
|
-
type: o,
|
|
638
|
-
source: r.source,
|
|
639
|
-
childCount: M(e),
|
|
640
|
-
elapsedMs: Math.round(
|
|
641
|
-
performance.now() - r.startedAt
|
|
642
|
-
)
|
|
643
|
-
}), e;
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
} catch (e) {
|
|
647
|
-
throw this._logLoadError("parse-failed", e, {
|
|
648
|
-
uri: r.uri,
|
|
649
|
-
type: o,
|
|
650
|
-
source: r.source,
|
|
651
|
-
elapsedMs: Math.round(performance.now() - r.startedAt)
|
|
652
|
-
}), e instanceof Error ? new R(
|
|
653
|
-
`Failed to parse ${o} file: ${e.message}`,
|
|
654
|
-
e
|
|
655
|
-
) : new R(`Failed to parse ${o} file`);
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
export {
|
|
660
|
-
te as A,
|
|
661
|
-
H as D,
|
|
662
|
-
j as a
|
|
663
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";var U=Object.create;var b=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var v=(a,r,s)=>r in a?b(a,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[r]=s;var W=(a,r,s,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of F(r))!G.call(a,e)&&e!==s&&b(a,e,{get:()=>r[e],enumerable:!(t=k(r,e))||t.enumerable});return a};var C=(a,r,s)=>(s=a!=null?U(N(a)):{},W(r||!a||!a.__esModule?b(s,"default",{value:a,enumerable:!0}):s,a));var _=(a,r,s)=>v(a,typeof r!="symbol"?r+"":r,s);const B=require("three/examples/jsm/loaders/GLTFLoader.js"),q=require("three/examples/jsm/loaders/USDLoader.js"),j=require("./FileTypes-BRIPrVRB.cjs"),m=require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const R=require("./isFileTypeSupported-BJG6_fK4.cjs"),M=require("./parse-error-Dy_EE4rL.cjs"),H=require("three/examples/jsm/loaders/DRACOLoader.js"),D=require("./AssetCache-BOcd08Uz.cjs");function I(){let a,r;onmessage=function(o){const n=o.data;switch(n.type){case"init":a=n.decoderConfig,r=new Promise(function(d){a.onModuleLoaded=function(h){d({draco:h})},DracoDecoderModule(a)});break;case"decode":const i=n.buffer,u=n.taskConfig;r.then(d=>{const h=d.draco,l=new h.Decoder;try{const f=s(h,l,new Int8Array(i),u),p=f.attributes.map(g=>g.array.buffer);f.index&&p.push(f.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:f},p)}catch(f){console.error(f),self.postMessage({type:"error",id:n.id,error:f.message})}finally{h.destroy(l)}});break}};function s(o,n,i,u){const d=u.attributeIDs,h=u.attributeTypes;let l,f;const p=n.GetEncodedGeometryType(i);if(p===o.TRIANGULAR_MESH)l=new o.Mesh,f=n.DecodeArrayToMesh(i,i.byteLength,l);else if(p===o.POINT_CLOUD)l=new o.PointCloud,f=n.DecodeArrayToPointCloud(i,i.byteLength,l);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||l.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const g={index:null,attributes:[]};for(const w in d){const A=self[h[w]];let L,y;if(u.useUniqueIDs)y=d[w],L=n.GetAttributeByUniqueId(l,y);else{if(y=n.GetAttributeId(l,o[d[w]]),y===-1)continue;L=n.GetAttribute(l,y)}const T=e(o,n,l,w,A,L);w==="color"&&(T.vertexColorSpace=u.vertexColorSpace),g.attributes.push(T)}return p===o.TRIANGULAR_MESH&&(g.index=t(o,n,l)),o.destroy(l),g}function t(o,n,i){const d=i.num_faces()*3,h=d*4,l=o._malloc(h);n.GetTrianglesUInt32Array(i,h,l);const f=new Uint32Array(o.HEAPF32.buffer,l,d).slice();return o._free(l),{array:f,itemSize:1}}function e(o,n,i,u,d,h){const l=h.num_components(),p=i.num_points()*l,g=p*d.BYTES_PER_ELEMENT,w=c(o,d),A=o._malloc(g);n.GetAttributeDataArrayForAllPoints(i,h,w,g,A);const L=new d(o.HEAPF32.buffer,A,p).slice();return o._free(A),{name:u,array:L,itemSize:l}}function c(o,n){switch(n){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}const S={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 a=(await import("three/examples/jsm/libs/draco/draco_decoder.wasm?url")).default;return await(await fetch(a)).arrayBuffer()}};class P extends H.DRACOLoader{constructor(){super(...arguments);_(this,"decoderPending",null);_(this,"decoderConfig",{type:"js",wasmBinary:null});_(this,"workerSourceURL","")}async _initDecoder(){if(this.decoderPending)return this.decoderPending;const s=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return s?t.push(S.LOAD_DRACO_JS_DECODER()):(t.push(S.LOAD_DRACO_WASM_WRAPPER()),t.push(S.LOAD_DRACO_WASM_DECODER())),this.decoderPending=Promise.all(t).then(e=>{const c=e[0];s||(this.decoderConfig.wasmBinary=e[1]);const o=I.toString(),n=["/* draco decoder */",c,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
|
|
2
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}}function z(){let a=null,r=null;const s=[[/'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 t(){return a||(a=occtimportjs({locateFile:function(){return r}})),a}function e(o){for(var n=new TextDecoder("utf-8",{fatal:!1}),i=new TextEncoder,u=n.decode(o),d=0;d<s.length;d++){var h=s[d][0],l=s[d][1];u=u.replace(h,l)}return new Uint8Array(i.encode(u))}function c(o,n){var i=e(n);try{var u=o.ReadStepFile(i,null);if(u.success&&u.root)return u}catch{}try{return o.ReadStepFile(n,null)}catch{return{success:!1,root:{meshes:[],children:[]},meshes:[]}}}onmessage=async function(o){var n=o.data;switch(n.type){case"init":r=n.wasmUrl;break;case"parse":try{var i=await t(),u=new Uint8Array(n.buffer),d=n.fileType,h;if(d==="step"||d==="stp"?h=c(i,u):h=i.ReadIgesFile(u,null),!h.success||!h.root){self.postMessage({type:"error",id:n.id,error:"Failed to parse CAD file"});return}self.postMessage({type:"result",id:n.id,result:h})}catch(l){self.postMessage({type:"error",id:n.id,error:l instanceof Error?l.message:String(l)})}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 J{constructor(){_(this,"_workerPending",null);_(this,"_worker",null);_(this,"_nextId",0);_(this,"_pending",new Map)}_getWorker(){return this._workerPending?this._workerPending:(this._workerPending=(async()=>{const[r,s]=await Promise.all([O.LOAD_OCCT_JS(),O.LOAD_OCCT_WASM_URL()]),t=z.toString(),e=["/* occt-import-js */",r,"","/* step worker */",t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))].join(`
|
|
3
|
-
`),c=URL.createObjectURL(new Blob([e])),o=new Worker(c),n=new URL(s,window.location.href).href;return o.postMessage({type:"init",wasmUrl:n}),o.onmessage=i=>{const{type:u,id:d,result:h,error:l}=i.data,f=this._pending.get(d);if(f)if(this._pending.delete(d),u==="result")try{f.resolve(this._buildScene(h))}catch(p){f.reject(p instanceof Error?p:new Error(String(p)))}else f.reject(new Error(l??"Worker error"))},o.onerror=i=>{for(const[,{reject:u}]of this._pending)u(new Error(i.message??"Worker error"));this._pending.clear()},this._worker=o,o})(),this._workerPending)}async parseAsync(r,s){const t=this._nextId++,e=await this._getWorker();return new Promise((c,o)=>{this._pending.set(t,{resolve:c,reject:o});const n=r.slice(0);e.postMessage({type:"parse",id:t,buffer:n,fileType:s},[n])})}dispose(){if(this._worker){for(const[,{reject:r}]of this._pending)r(new Error("STEPLoader disposed"));this._pending.clear(),this._worker.terminate(),this._worker=null,this._workerPending=null}}_buildScene(r){const s=new m.Group;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}_buildNode(r,s,t){const e=new m.Group;e.name=r.name??"Part";for(const c of r.meshes){const o=s[c];if(o!=null&&o.attributes){const n=this._createMesh(o);e.add(n)}}for(const c of r.children)this._buildNode(c,s,e);t.add(e)}_createMesh(r){var u,d;const{position:s,normal:t}=r.attributes,e=r.index??r.attributes.index,c=new m.BufferGeometry;c.setAttribute("position",new m.BufferAttribute(new Float32Array(s.array),3)),(u=t==null?void 0:t.array)!=null&&u.length?c.setAttribute("normal",new m.BufferAttribute(new Float32Array(t.array),3)):c.computeVertexNormals(),(d=e==null?void 0:e.array)!=null&&d.length&&c.setIndex(new m.BufferAttribute(new Uint32Array(e.array),1));const o=r.color,n=new m.MeshStandardMaterial({metalness:.3,roughness:.6});o&&o.length>=3?n.color.setRGB(o[0],o[1],o[2]):n.color.setHex(13421772);const i=new m.Mesh(c,n);return i.name=r.name??"Mesh",i.castShadow=!0,i.receiveShadow=!0,i}}const E=a=>Array.isArray(a==null?void 0:a.children)?a.children.length:0;class ${constructor(){_(this,"_gltfLoader");_(this,"_usdLoader");_(this,"_stepLoader");const r=new P;r.setDecoderConfig({type:"wasm"}),this._gltfLoader=new B.GLTFLoader,this._gltfLoader.setDRACOLoader(r),this._usdLoader=new q.USDLoader,this._stepLoader=new J}_logLoad(r,s={}){console.info("[AssetLoader.load]",r,s)}_logLoadError(r,s,t={}){console.error("[AssetLoader.load]",r,{...t,error:s instanceof Error?s.message:String(s)})}async load(r,s){const t=performance.now();let e;if(this._logLoad("start",{uri:r,fileType:s??null}),s)e=s,this._logLoad("using-explicit-file-type",{uri:r,extension:e,elapsedMs:Math.round(performance.now()-t)});else if(e=R.getFileTypeFromUri(r),this._logLoad("derived-file-type-from-uri",{uri:r,extension:e,elapsedMs:Math.round(performance.now()-t)}),e.length===0&&(this._logLoad("detect-file-type-from-content-start",{uri:r,elapsedMs:Math.round(performance.now()-t)}),e=await this._detectFileTypeFromContent(r),this._logLoad("detect-file-type-from-content-complete",{uri:r,extension:e,elapsedMs:Math.round(performance.now()-t)}),e.length===0))throw new M.FileTypeError("No file extension found in URI","");if(!R.isFileTypeSupported(e))throw new M.FileTypeError(`Unsupported file type: ${e}. Supported types: ${j.SUPPORTED_FILE_TYPES.join(", ")}`,e);const c=D.AssetCache.read(r);if(this._logLoad(c?"cache-hit":"cache-miss",{uri:r,extension:e,hasArrayBuffer:!!(c!=null&&c.arrayBuffer),elapsedMs:Math.round(performance.now()-t)}),c)return c.arrayBuffer?(this._logLoad("parse-start",{uri:r,extension:e,source:"cache-array-buffer",byteLength:c.arrayBuffer.byteLength,elapsedMs:Math.round(performance.now()-t)}),this._parse(c.arrayBuffer,e,{uri:r,source:"cache-array-buffer",startedAt:t})):(this._logLoad("await-existing-cache-promise-start",{uri:r,extension:e,elapsedMs:Math.round(performance.now()-t)}),c.promise.then(i=>(this._logLoad("await-existing-cache-promise-resolved",{uri:r,extension:e,byteLength:i.byteLength,elapsedMs:Math.round(performance.now()-t)}),this._logLoad("parse-start",{uri:r,extension:e,source:"cache-promise",byteLength:i.byteLength,elapsedMs:Math.round(performance.now()-t)}),this._parse(i,e,{uri:r,source:"cache-promise",startedAt:t}))));const o=D.AssetCache.create(r);this._logLoad("chunk-created",{uri:r,extension:e,elapsedMs:Math.round(performance.now()-t)}),this._logLoad("chunk-load-start",{uri:r,extension:e,elapsedMs:Math.round(performance.now()-t)});const n=await o.load();return this._logLoad("chunk-load-resolved",{uri:r,extension:e,byteLength:n.byteLength,elapsedMs:Math.round(performance.now()-t)}),this._logLoad("parse-start",{uri:r,extension:e,source:"fresh-chunk",byteLength:n.byteLength,elapsedMs:Math.round(performance.now()-t)}),this._parse(n,e,{uri:r,source:"fresh-chunk",startedAt:t})}async _detectFileTypeFromContent(r){try{const s=D.AssetCache.read(r);let t;s?s.arrayBuffer?t=s.arrayBuffer:t=await s.promise:t=await D.AssetCache.create(r).load();const e=new Uint8Array(t);return e.length>=12&&String.fromCharCode(e[0],e[1],e[2],e[3])==="glTF"?e[12]===0?"glb":"gltf":e.length>=4&&e[0]===80&&e[1]===75&&(e[2]===3||e[2]===5)&&(e[3]===4||e[3]===6)?"usdz":e.length>=20&&new TextDecoder("ascii").decode(e.subarray(0,20)).startsWith("ISO-10303-21")?"step":e.length>=80&&e[72]===83?"iges":""}catch{return""}}async _parse(r,s,t){try{switch(this._logLoad("parse-dispatch",{uri:t.uri,type:s,source:t.source,byteLength:r.byteLength,elapsedMs:Math.round(performance.now()-t.startedAt)}),s){case"glb":case"gltf":{this._logLoad("gltf-parse-start",{uri:t.uri,type:s,source:t.source,elapsedMs:Math.round(performance.now()-t.startedAt)});const e=await this._gltfLoader.parseAsync(r,"");return e.scene.animations=e.animations,this._logLoad("gltf-parse-complete",{uri:t.uri,type:s,source:t.source,childCount:E(e.scene),animationCount:Array.isArray(e.animations)?e.animations.length:0,elapsedMs:Math.round(performance.now()-t.startedAt)}),e.scene}case"usdz":{this._logLoad("usdz-parse-start",{uri:t.uri,type:s,source:t.source,elapsedMs:Math.round(performance.now()-t.startedAt)});const e=this._usdLoader.parse(r);return e.animations=[],this._logLoad("usdz-parse-complete",{uri:t.uri,type:s,source:t.source,childCount:E(e),elapsedMs:Math.round(performance.now()-t.startedAt)}),e}case"step":case"stp":{this._logLoad("step-parse-start",{uri:t.uri,type:s,source:t.source,elapsedMs:Math.round(performance.now()-t.startedAt)});const e=await this._stepLoader.parseAsync(r,s);return e.animations=[],this._logLoad("step-parse-complete",{uri:t.uri,type:s,source:t.source,childCount:E(e),elapsedMs:Math.round(performance.now()-t.startedAt)}),e}case"iges":case"igs":{this._logLoad("iges-parse-start",{uri:t.uri,type:s,source:t.source,elapsedMs:Math.round(performance.now()-t.startedAt)});const e=await this._stepLoader.parseAsync(r,s);return e.animations=[],this._logLoad("iges-parse-complete",{uri:t.uri,type:s,source:t.source,childCount:E(e),elapsedMs:Math.round(performance.now()-t.startedAt)}),e}}}catch(e){throw this._logLoadError("parse-failed",e,{uri:t.uri,type:s,source:t.source,elapsedMs:Math.round(performance.now()-t.startedAt)}),e instanceof Error?new M.ParseError(`Failed to parse ${s} file: ${e.message}`,e):new M.ParseError(`Failed to parse ${s} file`)}}}exports.AssetLoader=$;exports.DRACOWorker=I;exports.DracoLoader=P;
|