@shopware-ag/dive 1.18.5-beta.0 → 1.18.5-beta.2

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.
@@ -0,0 +1,1257 @@
1
+ import { C as se, M as Q, V as v, Q as te, B as L, a as G, S as ne, N as re, b as H, R as ie, c as oe, P as D, I as ae, d as Y, e as ce, f as ue, g as le, h as he, L as fe, i as pe, j as de, k as xe, l as ge, m as Te, n as me, G as Me } from "./dive-Mi8g8Khn.js";
2
+ import { d as z } from "./TextureUtils-CxpuVgwF.js";
3
+ const K = {
4
+ POSITION: [
5
+ "byte",
6
+ "byte normalized",
7
+ "unsigned byte",
8
+ "unsigned byte normalized",
9
+ "short",
10
+ "short normalized",
11
+ "unsigned short",
12
+ "unsigned short normalized"
13
+ ],
14
+ NORMAL: [
15
+ "byte normalized",
16
+ "short normalized"
17
+ ],
18
+ TANGENT: [
19
+ "byte normalized",
20
+ "short normalized"
21
+ ],
22
+ TEXCOORD: [
23
+ "byte",
24
+ "byte normalized",
25
+ "unsigned byte",
26
+ "short",
27
+ "short normalized",
28
+ "unsigned short"
29
+ ]
30
+ };
31
+ class V {
32
+ constructor() {
33
+ this.pluginCallbacks = [], this.register(function(e) {
34
+ return new Se(e);
35
+ }), this.register(function(e) {
36
+ return new _e(e);
37
+ }), this.register(function(e) {
38
+ return new Fe(e);
39
+ }), this.register(function(e) {
40
+ return new Oe(e);
41
+ }), this.register(function(e) {
42
+ return new ve(e);
43
+ }), this.register(function(e) {
44
+ return new De(e);
45
+ }), this.register(function(e) {
46
+ return new Ce(e);
47
+ }), this.register(function(e) {
48
+ return new Ue(e);
49
+ }), this.register(function(e) {
50
+ return new Be(e);
51
+ }), this.register(function(e) {
52
+ return new Ge(e);
53
+ }), this.register(function(e) {
54
+ return new ze(e);
55
+ }), this.register(function(e) {
56
+ return new Pe(e);
57
+ }), this.register(function(e) {
58
+ return new ke(e);
59
+ });
60
+ }
61
+ register(e) {
62
+ return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
63
+ }
64
+ unregister(e) {
65
+ return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
66
+ }
67
+ /**
68
+ * Parse scenes and generate GLTF output
69
+ * @param {Scene or [THREE.Scenes]} input Scene or Array of THREE.Scenes
70
+ * @param {Function} onDone Callback on completed
71
+ * @param {Function} onError Callback on errors
72
+ * @param {Object} options options
73
+ */
74
+ parse(e, s, n, t) {
75
+ const i = new Le(), r = [];
76
+ for (let o = 0, a = this.pluginCallbacks.length; o < a; o++)
77
+ r.push(this.pluginCallbacks[o](i));
78
+ i.setPlugins(r), i.write(e, s, t).catch(n);
79
+ }
80
+ parseAsync(e, s) {
81
+ const n = this;
82
+ return new Promise(function(t, i) {
83
+ n.parse(e, t, i, s);
84
+ });
85
+ }
86
+ }
87
+ const T = {
88
+ POINTS: 0,
89
+ LINES: 1,
90
+ LINE_LOOP: 2,
91
+ LINE_STRIP: 3,
92
+ TRIANGLES: 4,
93
+ BYTE: 5120,
94
+ UNSIGNED_BYTE: 5121,
95
+ SHORT: 5122,
96
+ UNSIGNED_SHORT: 5123,
97
+ INT: 5124,
98
+ UNSIGNED_INT: 5125,
99
+ FLOAT: 5126,
100
+ ARRAY_BUFFER: 34962,
101
+ ELEMENT_ARRAY_BUFFER: 34963,
102
+ NEAREST: 9728,
103
+ LINEAR: 9729,
104
+ NEAREST_MIPMAP_NEAREST: 9984,
105
+ LINEAR_MIPMAP_NEAREST: 9985,
106
+ NEAREST_MIPMAP_LINEAR: 9986,
107
+ LINEAR_MIPMAP_LINEAR: 9987,
108
+ CLAMP_TO_EDGE: 33071,
109
+ MIRRORED_REPEAT: 33648,
110
+ REPEAT: 10497
111
+ }, P = "KHR_mesh_quantization", R = {};
112
+ R[ue] = T.NEAREST;
113
+ R[le] = T.NEAREST_MIPMAP_NEAREST;
114
+ R[he] = T.NEAREST_MIPMAP_LINEAR;
115
+ R[fe] = T.LINEAR;
116
+ R[pe] = T.LINEAR_MIPMAP_NEAREST;
117
+ R[de] = T.LINEAR_MIPMAP_LINEAR;
118
+ R[xe] = T.CLAMP_TO_EDGE;
119
+ R[ge] = T.REPEAT;
120
+ R[Te] = T.MIRRORED_REPEAT;
121
+ const q = {
122
+ scale: "scale",
123
+ position: "translation",
124
+ quaternion: "rotation",
125
+ morphTargetInfluences: "weights"
126
+ }, ye = new se(), W = 12, we = 1179937895, Ee = 2, X = 8, Ie = 1313821514, Ae = 5130562;
127
+ function F(c, e) {
128
+ return c.length === e.length && c.every(function(s, n) {
129
+ return s === e[n];
130
+ });
131
+ }
132
+ function Re(c) {
133
+ return new TextEncoder().encode(c).buffer;
134
+ }
135
+ function be(c) {
136
+ return F(c.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
137
+ }
138
+ function Ne(c, e, s) {
139
+ const n = {
140
+ min: new Array(c.itemSize).fill(Number.POSITIVE_INFINITY),
141
+ max: new Array(c.itemSize).fill(Number.NEGATIVE_INFINITY)
142
+ };
143
+ for (let t = e; t < e + s; t++)
144
+ for (let i = 0; i < c.itemSize; i++) {
145
+ let r;
146
+ c.itemSize > 4 ? r = c.array[t * c.itemSize + i] : (i === 0 ? r = c.getX(t) : i === 1 ? r = c.getY(t) : i === 2 ? r = c.getZ(t) : i === 3 && (r = c.getW(t)), c.normalized === !0 && (r = H.normalize(r, c.array))), n.min[i] = Math.min(n.min[i], r), n.max[i] = Math.max(n.max[i], r);
147
+ }
148
+ return n;
149
+ }
150
+ function $(c) {
151
+ return Math.ceil(c / 4) * 4;
152
+ }
153
+ function k(c, e = 0) {
154
+ const s = $(c.byteLength);
155
+ if (s !== c.byteLength) {
156
+ const n = new Uint8Array(s);
157
+ if (n.set(new Uint8Array(c)), e !== 0)
158
+ for (let t = c.byteLength; t < s; t++)
159
+ n[t] = e;
160
+ return n.buffer;
161
+ }
162
+ return c;
163
+ }
164
+ function J() {
165
+ return typeof document > "u" && typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : document.createElement("canvas");
166
+ }
167
+ function Z(c, e) {
168
+ if (c.toBlob !== void 0)
169
+ return new Promise((n) => c.toBlob(n, e));
170
+ let s;
171
+ return e === "image/jpeg" ? s = 0.92 : e === "image/webp" && (s = 0.8), c.convertToBlob({
172
+ type: e,
173
+ quality: s
174
+ });
175
+ }
176
+ class Le {
177
+ constructor() {
178
+ this.plugins = [], this.options = {}, this.pending = [], this.buffers = [], this.byteOffset = 0, this.buffers = [], this.nodeMap = /* @__PURE__ */ new Map(), this.skins = [], this.extensionsUsed = {}, this.extensionsRequired = {}, this.uids = /* @__PURE__ */ new Map(), this.uid = 0, this.json = {
179
+ asset: {
180
+ version: "2.0",
181
+ generator: "THREE.GLTFExporter"
182
+ }
183
+ }, this.cache = {
184
+ meshes: /* @__PURE__ */ new Map(),
185
+ attributes: /* @__PURE__ */ new Map(),
186
+ attributesNormalized: /* @__PURE__ */ new Map(),
187
+ materials: /* @__PURE__ */ new Map(),
188
+ textures: /* @__PURE__ */ new Map(),
189
+ images: /* @__PURE__ */ new Map()
190
+ };
191
+ }
192
+ setPlugins(e) {
193
+ this.plugins = e;
194
+ }
195
+ /**
196
+ * Parse scenes and generate GLTF output
197
+ * @param {Scene or [THREE.Scenes]} input Scene or Array of THREE.Scenes
198
+ * @param {Function} onDone Callback on completed
199
+ * @param {Object} options options
200
+ */
201
+ async write(e, s, n = {}) {
202
+ this.options = Object.assign({
203
+ // default options
204
+ binary: !1,
205
+ trs: !1,
206
+ onlyVisible: !0,
207
+ maxTextureSize: 1 / 0,
208
+ animations: [],
209
+ includeCustomExtensions: !1
210
+ }, n), this.options.animations.length > 0 && (this.options.trs = !0), this.processInput(e), await Promise.all(this.pending);
211
+ const t = this, i = t.buffers, r = t.json;
212
+ n = t.options;
213
+ const o = t.extensionsUsed, a = t.extensionsRequired, l = new Blob(i, { type: "application/octet-stream" }), f = Object.keys(o), u = Object.keys(a);
214
+ if (f.length > 0 && (r.extensionsUsed = f), u.length > 0 && (r.extensionsRequired = u), r.buffers && r.buffers.length > 0 && (r.buffers[0].byteLength = l.size), n.binary === !0) {
215
+ const m = new FileReader();
216
+ m.readAsArrayBuffer(l), m.onloadend = function() {
217
+ const h = k(m.result), p = new DataView(new ArrayBuffer(X));
218
+ p.setUint32(0, h.byteLength, !0), p.setUint32(4, Ae, !0);
219
+ const d = k(Re(JSON.stringify(r)), 32), g = new DataView(new ArrayBuffer(X));
220
+ g.setUint32(0, d.byteLength, !0), g.setUint32(4, Ie, !0);
221
+ const y = new ArrayBuffer(W), b = new DataView(y);
222
+ b.setUint32(0, we, !0), b.setUint32(4, Ee, !0);
223
+ const O = W + g.byteLength + d.byteLength + p.byteLength + h.byteLength;
224
+ b.setUint32(8, O, !0);
225
+ const x = new Blob([
226
+ y,
227
+ g,
228
+ d,
229
+ p,
230
+ h
231
+ ], { type: "application/octet-stream" }), M = new FileReader();
232
+ M.readAsArrayBuffer(x), M.onloadend = function() {
233
+ s(M.result);
234
+ };
235
+ };
236
+ } else if (r.buffers && r.buffers.length > 0) {
237
+ const m = new FileReader();
238
+ m.readAsDataURL(l), m.onloadend = function() {
239
+ const h = m.result;
240
+ r.buffers[0].uri = h, s(r);
241
+ };
242
+ } else
243
+ s(r);
244
+ }
245
+ /**
246
+ * Serializes a userData.
247
+ *
248
+ * @param {THREE.Object3D|THREE.Material} object
249
+ * @param {Object} objectDef
250
+ */
251
+ serializeUserData(e, s) {
252
+ if (Object.keys(e.userData).length === 0) return;
253
+ const n = this.options, t = this.extensionsUsed;
254
+ try {
255
+ const i = JSON.parse(JSON.stringify(e.userData));
256
+ if (n.includeCustomExtensions && i.gltfExtensions) {
257
+ s.extensions === void 0 && (s.extensions = {});
258
+ for (const r in i.gltfExtensions)
259
+ s.extensions[r] = i.gltfExtensions[r], t[r] = !0;
260
+ delete i.gltfExtensions;
261
+ }
262
+ Object.keys(i).length > 0 && (s.extras = i);
263
+ } catch (i) {
264
+ console.warn("THREE.GLTFExporter: userData of '" + e.name + "' won't be serialized because of JSON.stringify error - " + i.message);
265
+ }
266
+ }
267
+ /**
268
+ * Returns ids for buffer attributes.
269
+ * @param {Object} object
270
+ * @return {Integer}
271
+ */
272
+ getUID(e, s = !1) {
273
+ if (this.uids.has(e) === !1) {
274
+ const t = /* @__PURE__ */ new Map();
275
+ t.set(!0, this.uid++), t.set(!1, this.uid++), this.uids.set(e, t);
276
+ }
277
+ return this.uids.get(e).get(s);
278
+ }
279
+ /**
280
+ * Checks if normal attribute values are normalized.
281
+ *
282
+ * @param {BufferAttribute} normal
283
+ * @returns {Boolean}
284
+ */
285
+ isNormalizedNormalAttribute(e) {
286
+ if (this.cache.attributesNormalized.has(e)) return !1;
287
+ const n = new v();
288
+ for (let t = 0, i = e.count; t < i; t++)
289
+ if (Math.abs(n.fromBufferAttribute(e, t).length() - 1) > 5e-4) return !1;
290
+ return !0;
291
+ }
292
+ /**
293
+ * Creates normalized normal buffer attribute.
294
+ *
295
+ * @param {BufferAttribute} normal
296
+ * @returns {BufferAttribute}
297
+ *
298
+ */
299
+ createNormalizedNormalAttribute(e) {
300
+ const s = this.cache;
301
+ if (s.attributesNormalized.has(e)) return s.attributesNormalized.get(e);
302
+ const n = e.clone(), t = new v();
303
+ for (let i = 0, r = n.count; i < r; i++)
304
+ t.fromBufferAttribute(n, i), t.x === 0 && t.y === 0 && t.z === 0 ? t.setX(1) : t.normalize(), n.setXYZ(i, t.x, t.y, t.z);
305
+ return s.attributesNormalized.set(e, n), n;
306
+ }
307
+ /**
308
+ * Applies a texture transform, if present, to the map definition. Requires
309
+ * the KHR_texture_transform extension.
310
+ *
311
+ * @param {Object} mapDef
312
+ * @param {THREE.Texture} texture
313
+ */
314
+ applyTextureTransform(e, s) {
315
+ let n = !1;
316
+ const t = {};
317
+ (s.offset.x !== 0 || s.offset.y !== 0) && (t.offset = s.offset.toArray(), n = !0), s.rotation !== 0 && (t.rotation = s.rotation, n = !0), (s.repeat.x !== 1 || s.repeat.y !== 1) && (t.scale = s.repeat.toArray(), n = !0), n && (e.extensions = e.extensions || {}, e.extensions.KHR_texture_transform = t, this.extensionsUsed.KHR_texture_transform = !0);
318
+ }
319
+ buildMetalRoughTexture(e, s) {
320
+ if (e === s) return e;
321
+ function n(h) {
322
+ return h.colorSpace === ce ? function(d) {
323
+ return d < 0.04045 ? d * 0.0773993808 : Math.pow(d * 0.9478672986 + 0.0521327014, 2.4);
324
+ } : function(d) {
325
+ return d;
326
+ };
327
+ }
328
+ console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."), e instanceof G && (e = z(e)), s instanceof G && (s = z(s));
329
+ const t = e ? e.image : null, i = s ? s.image : null, r = Math.max(t ? t.width : 0, i ? i.width : 0), o = Math.max(t ? t.height : 0, i ? i.height : 0), a = J();
330
+ a.width = r, a.height = o;
331
+ const l = a.getContext("2d");
332
+ l.fillStyle = "#00ffff", l.fillRect(0, 0, r, o);
333
+ const f = l.getImageData(0, 0, r, o);
334
+ if (t) {
335
+ l.drawImage(t, 0, 0, r, o);
336
+ const h = n(e), p = l.getImageData(0, 0, r, o).data;
337
+ for (let d = 2; d < p.length; d += 4)
338
+ f.data[d] = h(p[d] / 256) * 256;
339
+ }
340
+ if (i) {
341
+ l.drawImage(i, 0, 0, r, o);
342
+ const h = n(s), p = l.getImageData(0, 0, r, o).data;
343
+ for (let d = 1; d < p.length; d += 4)
344
+ f.data[d] = h(p[d] / 256) * 256;
345
+ }
346
+ l.putImageData(f, 0, 0);
347
+ const m = (e || s).clone();
348
+ return m.source = new ne(a), m.colorSpace = re, m.channel = (e || s).channel, e && s && e.channel !== s.channel && console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."), m;
349
+ }
350
+ /**
351
+ * Process a buffer to append to the default one.
352
+ * @param {ArrayBuffer} buffer
353
+ * @return {Integer}
354
+ */
355
+ processBuffer(e) {
356
+ const s = this.json, n = this.buffers;
357
+ return s.buffers || (s.buffers = [{ byteLength: 0 }]), n.push(e), 0;
358
+ }
359
+ /**
360
+ * Process and generate a BufferView
361
+ * @param {BufferAttribute} attribute
362
+ * @param {number} componentType
363
+ * @param {number} start
364
+ * @param {number} count
365
+ * @param {number} target (Optional) Target usage of the BufferView
366
+ * @return {Object}
367
+ */
368
+ processBufferView(e, s, n, t, i) {
369
+ const r = this.json;
370
+ r.bufferViews || (r.bufferViews = []);
371
+ let o;
372
+ switch (s) {
373
+ case T.BYTE:
374
+ case T.UNSIGNED_BYTE:
375
+ o = 1;
376
+ break;
377
+ case T.SHORT:
378
+ case T.UNSIGNED_SHORT:
379
+ o = 2;
380
+ break;
381
+ default:
382
+ o = 4;
383
+ }
384
+ let a = e.itemSize * o;
385
+ i === T.ARRAY_BUFFER && (a = Math.ceil(a / 4) * 4);
386
+ const l = $(t * a), f = new DataView(new ArrayBuffer(l));
387
+ let u = 0;
388
+ for (let p = n; p < n + t; p++) {
389
+ for (let d = 0; d < e.itemSize; d++) {
390
+ let g;
391
+ e.itemSize > 4 ? g = e.array[p * e.itemSize + d] : (d === 0 ? g = e.getX(p) : d === 1 ? g = e.getY(p) : d === 2 ? g = e.getZ(p) : d === 3 && (g = e.getW(p)), e.normalized === !0 && (g = H.normalize(g, e.array))), s === T.FLOAT ? f.setFloat32(u, g, !0) : s === T.INT ? f.setInt32(u, g, !0) : s === T.UNSIGNED_INT ? f.setUint32(u, g, !0) : s === T.SHORT ? f.setInt16(u, g, !0) : s === T.UNSIGNED_SHORT ? f.setUint16(u, g, !0) : s === T.BYTE ? f.setInt8(u, g) : s === T.UNSIGNED_BYTE && f.setUint8(u, g), u += o;
392
+ }
393
+ u % a !== 0 && (u += a - u % a);
394
+ }
395
+ const m = {
396
+ buffer: this.processBuffer(f.buffer),
397
+ byteOffset: this.byteOffset,
398
+ byteLength: l
399
+ };
400
+ return i !== void 0 && (m.target = i), i === T.ARRAY_BUFFER && (m.byteStride = a), this.byteOffset += l, r.bufferViews.push(m), {
401
+ id: r.bufferViews.length - 1,
402
+ byteLength: 0
403
+ };
404
+ }
405
+ /**
406
+ * Process and generate a BufferView from an image Blob.
407
+ * @param {Blob} blob
408
+ * @return {Promise<Integer>}
409
+ */
410
+ processBufferViewImage(e) {
411
+ const s = this, n = s.json;
412
+ return n.bufferViews || (n.bufferViews = []), new Promise(function(t) {
413
+ const i = new FileReader();
414
+ i.readAsArrayBuffer(e), i.onloadend = function() {
415
+ const r = k(i.result), o = {
416
+ buffer: s.processBuffer(r),
417
+ byteOffset: s.byteOffset,
418
+ byteLength: r.byteLength
419
+ };
420
+ s.byteOffset += r.byteLength, t(n.bufferViews.push(o) - 1);
421
+ };
422
+ });
423
+ }
424
+ /**
425
+ * Process attribute to generate an accessor
426
+ * @param {BufferAttribute} attribute Attribute to process
427
+ * @param {THREE.BufferGeometry} geometry (Optional) Geometry used for truncated draw range
428
+ * @param {Integer} start (Optional)
429
+ * @param {Integer} count (Optional)
430
+ * @return {Integer|null} Index of the processed accessor on the "accessors" array
431
+ */
432
+ processAccessor(e, s, n, t) {
433
+ const i = this.json, r = {
434
+ 1: "SCALAR",
435
+ 2: "VEC2",
436
+ 3: "VEC3",
437
+ 4: "VEC4",
438
+ 9: "MAT3",
439
+ 16: "MAT4"
440
+ };
441
+ let o;
442
+ if (e.array.constructor === Float32Array)
443
+ o = T.FLOAT;
444
+ else if (e.array.constructor === Int32Array)
445
+ o = T.INT;
446
+ else if (e.array.constructor === Uint32Array)
447
+ o = T.UNSIGNED_INT;
448
+ else if (e.array.constructor === Int16Array)
449
+ o = T.SHORT;
450
+ else if (e.array.constructor === Uint16Array)
451
+ o = T.UNSIGNED_SHORT;
452
+ else if (e.array.constructor === Int8Array)
453
+ o = T.BYTE;
454
+ else if (e.array.constructor === Uint8Array)
455
+ o = T.UNSIGNED_BYTE;
456
+ else
457
+ throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + e.array.constructor.name);
458
+ if (n === void 0 && (n = 0), (t === void 0 || t === 1 / 0) && (t = e.count), t === 0) return null;
459
+ const a = Ne(e, n, t);
460
+ let l;
461
+ s !== void 0 && (l = e === s.index ? T.ELEMENT_ARRAY_BUFFER : T.ARRAY_BUFFER);
462
+ const f = this.processBufferView(e, o, n, t, l), u = {
463
+ bufferView: f.id,
464
+ byteOffset: f.byteOffset,
465
+ componentType: o,
466
+ count: t,
467
+ max: a.max,
468
+ min: a.min,
469
+ type: r[e.itemSize]
470
+ };
471
+ return e.normalized === !0 && (u.normalized = !0), i.accessors || (i.accessors = []), i.accessors.push(u) - 1;
472
+ }
473
+ /**
474
+ * Process image
475
+ * @param {Image} image to process
476
+ * @param {Integer} format of the image (RGBAFormat)
477
+ * @param {Boolean} flipY before writing out the image
478
+ * @param {String} mimeType export format
479
+ * @return {Integer} Index of the processed texture in the "images" array
480
+ */
481
+ processImage(e, s, n, t = "image/png") {
482
+ if (e !== null) {
483
+ const i = this, r = i.cache, o = i.json, a = i.options, l = i.pending;
484
+ r.images.has(e) || r.images.set(e, {});
485
+ const f = r.images.get(e), u = t + ":flipY/" + n.toString();
486
+ if (f[u] !== void 0) return f[u];
487
+ o.images || (o.images = []);
488
+ const m = { mimeType: t }, h = J();
489
+ h.width = Math.min(e.width, a.maxTextureSize), h.height = Math.min(e.height, a.maxTextureSize);
490
+ const p = h.getContext("2d");
491
+ if (n === !0 && (p.translate(0, h.height), p.scale(1, -1)), e.data !== void 0) {
492
+ s !== ie && console.error("GLTFExporter: Only RGBAFormat is supported.", s), (e.width > a.maxTextureSize || e.height > a.maxTextureSize) && console.warn("GLTFExporter: Image size is bigger than maxTextureSize", e);
493
+ const g = new Uint8ClampedArray(e.height * e.width * 4);
494
+ for (let y = 0; y < g.length; y += 4)
495
+ g[y + 0] = e.data[y + 0], g[y + 1] = e.data[y + 1], g[y + 2] = e.data[y + 2], g[y + 3] = e.data[y + 3];
496
+ p.putImageData(new ImageData(g, e.width, e.height), 0, 0);
497
+ } else if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap || typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas)
498
+ p.drawImage(e, 0, 0, h.width, h.height);
499
+ else
500
+ throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");
501
+ a.binary === !0 ? l.push(
502
+ Z(h, t).then((g) => i.processBufferViewImage(g)).then((g) => {
503
+ m.bufferView = g;
504
+ })
505
+ ) : h.toDataURL !== void 0 ? m.uri = h.toDataURL(t) : l.push(
506
+ Z(h, t).then((g) => new FileReader().readAsDataURL(g)).then((g) => {
507
+ m.uri = g;
508
+ })
509
+ );
510
+ const d = o.images.push(m) - 1;
511
+ return f[u] = d, d;
512
+ } else
513
+ throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.");
514
+ }
515
+ /**
516
+ * Process sampler
517
+ * @param {Texture} map Texture to process
518
+ * @return {Integer} Index of the processed texture in the "samplers" array
519
+ */
520
+ processSampler(e) {
521
+ const s = this.json;
522
+ s.samplers || (s.samplers = []);
523
+ const n = {
524
+ magFilter: R[e.magFilter],
525
+ minFilter: R[e.minFilter],
526
+ wrapS: R[e.wrapS],
527
+ wrapT: R[e.wrapT]
528
+ };
529
+ return s.samplers.push(n) - 1;
530
+ }
531
+ /**
532
+ * Process texture
533
+ * @param {Texture} map Map to process
534
+ * @return {Integer} Index of the processed texture in the "textures" array
535
+ */
536
+ processTexture(e) {
537
+ const n = this.options, t = this.cache, i = this.json;
538
+ if (t.textures.has(e)) return t.textures.get(e);
539
+ i.textures || (i.textures = []), e instanceof G && (e = z(e, n.maxTextureSize));
540
+ let r = e.userData.mimeType;
541
+ r === "image/webp" && (r = "image/png");
542
+ const o = {
543
+ sampler: this.processSampler(e),
544
+ source: this.processImage(e.image, e.format, e.flipY, r)
545
+ };
546
+ e.name && (o.name = e.name), this._invokeAll(function(l) {
547
+ l.writeTexture && l.writeTexture(e, o);
548
+ });
549
+ const a = i.textures.push(o) - 1;
550
+ return t.textures.set(e, a), a;
551
+ }
552
+ /**
553
+ * Process material
554
+ * @param {THREE.Material} material Material to process
555
+ * @return {Integer|null} Index of the processed material in the "materials" array
556
+ */
557
+ processMaterial(e) {
558
+ const s = this.cache, n = this.json;
559
+ if (s.materials.has(e)) return s.materials.get(e);
560
+ if (e.isShaderMaterial)
561
+ return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."), null;
562
+ n.materials || (n.materials = []);
563
+ const t = { pbrMetallicRoughness: {} };
564
+ e.isMeshStandardMaterial !== !0 && e.isMeshBasicMaterial !== !0 && console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");
565
+ const i = e.color.toArray().concat([e.opacity]);
566
+ if (F(i, [1, 1, 1, 1]) || (t.pbrMetallicRoughness.baseColorFactor = i), e.isMeshStandardMaterial ? (t.pbrMetallicRoughness.metallicFactor = e.metalness, t.pbrMetallicRoughness.roughnessFactor = e.roughness) : (t.pbrMetallicRoughness.metallicFactor = 0.5, t.pbrMetallicRoughness.roughnessFactor = 0.5), e.metalnessMap || e.roughnessMap) {
567
+ const o = this.buildMetalRoughTexture(e.metalnessMap, e.roughnessMap), a = {
568
+ index: this.processTexture(o),
569
+ channel: o.channel
570
+ };
571
+ this.applyTextureTransform(a, o), t.pbrMetallicRoughness.metallicRoughnessTexture = a;
572
+ }
573
+ if (e.map) {
574
+ const o = {
575
+ index: this.processTexture(e.map),
576
+ texCoord: e.map.channel
577
+ };
578
+ this.applyTextureTransform(o, e.map), t.pbrMetallicRoughness.baseColorTexture = o;
579
+ }
580
+ if (e.emissive) {
581
+ const o = e.emissive;
582
+ if (Math.max(o.r, o.g, o.b) > 0 && (t.emissiveFactor = e.emissive.toArray()), e.emissiveMap) {
583
+ const l = {
584
+ index: this.processTexture(e.emissiveMap),
585
+ texCoord: e.emissiveMap.channel
586
+ };
587
+ this.applyTextureTransform(l, e.emissiveMap), t.emissiveTexture = l;
588
+ }
589
+ }
590
+ if (e.normalMap) {
591
+ const o = {
592
+ index: this.processTexture(e.normalMap),
593
+ texCoord: e.normalMap.channel
594
+ };
595
+ e.normalScale && e.normalScale.x !== 1 && (o.scale = e.normalScale.x), this.applyTextureTransform(o, e.normalMap), t.normalTexture = o;
596
+ }
597
+ if (e.aoMap) {
598
+ const o = {
599
+ index: this.processTexture(e.aoMap),
600
+ texCoord: e.aoMap.channel
601
+ };
602
+ e.aoMapIntensity !== 1 && (o.strength = e.aoMapIntensity), this.applyTextureTransform(o, e.aoMap), t.occlusionTexture = o;
603
+ }
604
+ e.transparent ? t.alphaMode = "BLEND" : e.alphaTest > 0 && (t.alphaMode = "MASK", t.alphaCutoff = e.alphaTest), e.side === oe && (t.doubleSided = !0), e.name !== "" && (t.name = e.name), this.serializeUserData(e, t), this._invokeAll(function(o) {
605
+ o.writeMaterial && o.writeMaterial(e, t);
606
+ });
607
+ const r = n.materials.push(t) - 1;
608
+ return s.materials.set(e, r), r;
609
+ }
610
+ /**
611
+ * Process mesh
612
+ * @param {THREE.Mesh} mesh Mesh to process
613
+ * @return {Integer|null} Index of the processed mesh in the "meshes" array
614
+ */
615
+ processMesh(e) {
616
+ const s = this.cache, n = this.json, t = [e.geometry.uuid];
617
+ if (Array.isArray(e.material))
618
+ for (let x = 0, M = e.material.length; x < M; x++)
619
+ t.push(e.material[x].uuid);
620
+ else
621
+ t.push(e.material.uuid);
622
+ const i = t.join(":");
623
+ if (s.meshes.has(i)) return s.meshes.get(i);
624
+ const r = e.geometry;
625
+ let o;
626
+ e.isLineSegments ? o = T.LINES : e.isLineLoop ? o = T.LINE_LOOP : e.isLine ? o = T.LINE_STRIP : e.isPoints ? o = T.POINTS : o = e.material.wireframe ? T.LINES : T.TRIANGLES;
627
+ const a = {}, l = {}, f = [], u = [], m = {
628
+ uv: "TEXCOORD_0",
629
+ uv1: "TEXCOORD_1",
630
+ uv2: "TEXCOORD_2",
631
+ uv3: "TEXCOORD_3",
632
+ color: "COLOR_0",
633
+ skinWeight: "WEIGHTS_0",
634
+ skinIndex: "JOINTS_0"
635
+ }, h = r.getAttribute("normal");
636
+ h !== void 0 && !this.isNormalizedNormalAttribute(h) && (console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."), r.setAttribute("normal", this.createNormalizedNormalAttribute(h)));
637
+ let p = null;
638
+ for (let x in r.attributes) {
639
+ if (x.slice(0, 5) === "morph") continue;
640
+ const M = r.attributes[x];
641
+ if (x = m[x] || x.toUpperCase(), /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(x) || (x = "_" + x), s.attributes.has(this.getUID(M))) {
642
+ l[x] = s.attributes.get(this.getUID(M));
643
+ continue;
644
+ }
645
+ p = null;
646
+ const E = M.array;
647
+ x === "JOINTS_0" && !(E instanceof Uint16Array) && !(E instanceof Uint8Array) && (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), p = new L(new Uint16Array(E), M.itemSize, M.normalized));
648
+ const A = this.processAccessor(p || M, r);
649
+ A !== null && (x.startsWith("_") || this.detectMeshQuantization(x, M), l[x] = A, s.attributes.set(this.getUID(M), A));
650
+ }
651
+ if (h !== void 0 && r.setAttribute("normal", h), Object.keys(l).length === 0) return null;
652
+ if (e.morphTargetInfluences !== void 0 && e.morphTargetInfluences.length > 0) {
653
+ const x = [], M = [], w = {};
654
+ if (e.morphTargetDictionary !== void 0)
655
+ for (const E in e.morphTargetDictionary)
656
+ w[e.morphTargetDictionary[E]] = E;
657
+ for (let E = 0; E < e.morphTargetInfluences.length; ++E) {
658
+ const A = {};
659
+ let j = !1;
660
+ for (const _ in r.morphAttributes) {
661
+ if (_ !== "position" && _ !== "normal") {
662
+ j || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), j = !0);
663
+ continue;
664
+ }
665
+ const N = r.morphAttributes[_][E], B = _.toUpperCase(), C = r.attributes[_];
666
+ if (s.attributes.has(this.getUID(N, !0))) {
667
+ A[B] = s.attributes.get(this.getUID(N, !0));
668
+ continue;
669
+ }
670
+ const U = N.clone();
671
+ if (!r.morphTargetsRelative)
672
+ for (let I = 0, ee = N.count; I < ee; I++)
673
+ for (let S = 0; S < N.itemSize; S++)
674
+ S === 0 && U.setX(I, N.getX(I) - C.getX(I)), S === 1 && U.setY(I, N.getY(I) - C.getY(I)), S === 2 && U.setZ(I, N.getZ(I) - C.getZ(I)), S === 3 && U.setW(I, N.getW(I) - C.getW(I));
675
+ A[B] = this.processAccessor(U, r), s.attributes.set(this.getUID(C, !0), A[B]);
676
+ }
677
+ u.push(A), x.push(e.morphTargetInfluences[E]), e.morphTargetDictionary !== void 0 && M.push(w[E]);
678
+ }
679
+ a.weights = x, M.length > 0 && (a.extras = {}, a.extras.targetNames = M);
680
+ }
681
+ const d = Array.isArray(e.material);
682
+ if (d && r.groups.length === 0) return null;
683
+ let g = !1;
684
+ if (d && r.index === null) {
685
+ const x = [];
686
+ for (let M = 0, w = r.attributes.position.count; M < w; M++)
687
+ x[M] = M;
688
+ r.setIndex(x), g = !0;
689
+ }
690
+ const y = d ? e.material : [e.material], b = d ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
691
+ for (let x = 0, M = b.length; x < M; x++) {
692
+ const w = {
693
+ mode: o,
694
+ attributes: l
695
+ };
696
+ if (this.serializeUserData(r, w), u.length > 0 && (w.targets = u), r.index !== null) {
697
+ let A = this.getUID(r.index);
698
+ (b[x].start !== void 0 || b[x].count !== void 0) && (A += ":" + b[x].start + ":" + b[x].count), s.attributes.has(A) ? w.indices = s.attributes.get(A) : (w.indices = this.processAccessor(r.index, r, b[x].start, b[x].count), s.attributes.set(A, w.indices)), w.indices === null && delete w.indices;
699
+ }
700
+ const E = this.processMaterial(y[b[x].materialIndex]);
701
+ E !== null && (w.material = E), f.push(w);
702
+ }
703
+ g === !0 && r.setIndex(null), a.primitives = f, n.meshes || (n.meshes = []), this._invokeAll(function(x) {
704
+ x.writeMesh && x.writeMesh(e, a);
705
+ });
706
+ const O = n.meshes.push(a) - 1;
707
+ return s.meshes.set(i, O), O;
708
+ }
709
+ /**
710
+ * If a vertex attribute with a
711
+ * [non-standard data type](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#meshes-overview)
712
+ * is used, it is checked whether it is a valid data type according to the
713
+ * [KHR_mesh_quantization](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md)
714
+ * extension.
715
+ * In this case the extension is automatically added to the list of used extensions.
716
+ *
717
+ * @param {string} attributeName
718
+ * @param {THREE.BufferAttribute} attribute
719
+ */
720
+ detectMeshQuantization(e, s) {
721
+ if (this.extensionsUsed[P]) return;
722
+ let n;
723
+ switch (s.array.constructor) {
724
+ case Int8Array:
725
+ n = "byte";
726
+ break;
727
+ case Uint8Array:
728
+ n = "unsigned byte";
729
+ break;
730
+ case Int16Array:
731
+ n = "short";
732
+ break;
733
+ case Uint16Array:
734
+ n = "unsigned short";
735
+ break;
736
+ default:
737
+ return;
738
+ }
739
+ s.normalized && (n += " normalized");
740
+ const t = e.split("_", 1)[0];
741
+ K[t] && K[t].includes(n) && (this.extensionsUsed[P] = !0, this.extensionsRequired[P] = !0);
742
+ }
743
+ /**
744
+ * Process camera
745
+ * @param {THREE.Camera} camera Camera to process
746
+ * @return {Integer} Index of the processed mesh in the "camera" array
747
+ */
748
+ processCamera(e) {
749
+ const s = this.json;
750
+ s.cameras || (s.cameras = []);
751
+ const n = e.isOrthographicCamera, t = {
752
+ type: n ? "orthographic" : "perspective"
753
+ };
754
+ return n ? t.orthographic = {
755
+ xmag: e.right * 2,
756
+ ymag: e.top * 2,
757
+ zfar: e.far <= 0 ? 1e-3 : e.far,
758
+ znear: e.near < 0 ? 0 : e.near
759
+ } : t.perspective = {
760
+ aspectRatio: e.aspect,
761
+ yfov: H.degToRad(e.fov),
762
+ zfar: e.far <= 0 ? 1e-3 : e.far,
763
+ znear: e.near < 0 ? 0 : e.near
764
+ }, e.name !== "" && (t.name = e.type), s.cameras.push(t) - 1;
765
+ }
766
+ /**
767
+ * Creates glTF animation entry from AnimationClip object.
768
+ *
769
+ * Status:
770
+ * - Only properties listed in PATH_PROPERTIES may be animated.
771
+ *
772
+ * @param {THREE.AnimationClip} clip
773
+ * @param {THREE.Object3D} root
774
+ * @return {number|null}
775
+ */
776
+ processAnimation(e, s) {
777
+ const n = this.json, t = this.nodeMap;
778
+ n.animations || (n.animations = []), e = V.Utils.mergeMorphTargetTracks(e.clone(), s);
779
+ const i = e.tracks, r = [], o = [];
780
+ for (let a = 0; a < i.length; ++a) {
781
+ const l = i[a], f = D.parseTrackName(l.name);
782
+ let u = D.findNode(s, f.nodeName);
783
+ const m = q[f.propertyName];
784
+ if (f.objectName === "bones" && (u.isSkinnedMesh === !0 ? u = u.skeleton.getBoneByName(f.objectIndex) : u = void 0), !u || !m)
785
+ return console.warn('THREE.GLTFExporter: Could not export animation track "%s".', l.name), null;
786
+ const h = 1;
787
+ let p = l.values.length / l.times.length;
788
+ m === q.morphTargetInfluences && (p /= u.morphTargetInfluences.length);
789
+ let d;
790
+ l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (d = "CUBICSPLINE", p /= 3) : l.getInterpolation() === ae ? d = "STEP" : d = "LINEAR", o.push({
791
+ input: this.processAccessor(new L(l.times, h)),
792
+ output: this.processAccessor(new L(l.values, p)),
793
+ interpolation: d
794
+ }), r.push({
795
+ sampler: o.length - 1,
796
+ target: {
797
+ node: t.get(u),
798
+ path: m
799
+ }
800
+ });
801
+ }
802
+ return n.animations.push({
803
+ name: e.name || "clip_" + n.animations.length,
804
+ samplers: o,
805
+ channels: r
806
+ }), n.animations.length - 1;
807
+ }
808
+ /**
809
+ * @param {THREE.Object3D} object
810
+ * @return {number|null}
811
+ */
812
+ processSkin(e) {
813
+ const s = this.json, n = this.nodeMap, t = s.nodes[n.get(e)], i = e.skeleton;
814
+ if (i === void 0) return null;
815
+ const r = e.skeleton.bones[0];
816
+ if (r === void 0) return null;
817
+ const o = [], a = new Float32Array(i.bones.length * 16), l = new Q();
818
+ for (let u = 0; u < i.bones.length; ++u)
819
+ o.push(n.get(i.bones[u])), l.copy(i.boneInverses[u]), l.multiply(e.bindMatrix).toArray(a, u * 16);
820
+ return s.skins === void 0 && (s.skins = []), s.skins.push({
821
+ inverseBindMatrices: this.processAccessor(new L(a, 16)),
822
+ joints: o,
823
+ skeleton: n.get(r)
824
+ }), t.skin = s.skins.length - 1;
825
+ }
826
+ /**
827
+ * Process Object3D node
828
+ * @param {THREE.Object3D} node Object3D to processNode
829
+ * @return {Integer} Index of the node in the nodes list
830
+ */
831
+ processNode(e) {
832
+ const s = this.json, n = this.options, t = this.nodeMap;
833
+ s.nodes || (s.nodes = []);
834
+ const i = {};
835
+ if (n.trs) {
836
+ const o = e.quaternion.toArray(), a = e.position.toArray(), l = e.scale.toArray();
837
+ F(o, [0, 0, 0, 1]) || (i.rotation = o), F(a, [0, 0, 0]) || (i.translation = a), F(l, [1, 1, 1]) || (i.scale = l);
838
+ } else
839
+ e.matrixAutoUpdate && e.updateMatrix(), be(e.matrix) === !1 && (i.matrix = e.matrix.elements);
840
+ if (e.name !== "" && (i.name = String(e.name)), this.serializeUserData(e, i), e.isMesh || e.isLine || e.isPoints) {
841
+ const o = this.processMesh(e);
842
+ o !== null && (i.mesh = o);
843
+ } else e.isCamera && (i.camera = this.processCamera(e));
844
+ if (e.isSkinnedMesh && this.skins.push(e), e.children.length > 0) {
845
+ const o = [];
846
+ for (let a = 0, l = e.children.length; a < l; a++) {
847
+ const f = e.children[a];
848
+ if (f.visible || n.onlyVisible === !1) {
849
+ const u = this.processNode(f);
850
+ u !== null && o.push(u);
851
+ }
852
+ }
853
+ o.length > 0 && (i.children = o);
854
+ }
855
+ this._invokeAll(function(o) {
856
+ o.writeNode && o.writeNode(e, i);
857
+ });
858
+ const r = s.nodes.push(i) - 1;
859
+ return t.set(e, r), r;
860
+ }
861
+ /**
862
+ * Process Scene
863
+ * @param {Scene} node Scene to process
864
+ */
865
+ processScene(e) {
866
+ const s = this.json, n = this.options;
867
+ s.scenes || (s.scenes = [], s.scene = 0);
868
+ const t = {};
869
+ e.name !== "" && (t.name = e.name), s.scenes.push(t);
870
+ const i = [];
871
+ for (let r = 0, o = e.children.length; r < o; r++) {
872
+ const a = e.children[r];
873
+ if (a.visible || n.onlyVisible === !1) {
874
+ const l = this.processNode(a);
875
+ l !== null && i.push(l);
876
+ }
877
+ }
878
+ i.length > 0 && (t.nodes = i), this.serializeUserData(e, t);
879
+ }
880
+ /**
881
+ * Creates a Scene to hold a list of objects and parse it
882
+ * @param {Array} objects List of objects to process
883
+ */
884
+ processObjects(e) {
885
+ const s = new Y();
886
+ s.name = "AuxScene";
887
+ for (let n = 0; n < e.length; n++)
888
+ s.children.push(e[n]);
889
+ this.processScene(s);
890
+ }
891
+ /**
892
+ * @param {THREE.Object3D|Array<THREE.Object3D>} input
893
+ */
894
+ processInput(e) {
895
+ const s = this.options;
896
+ e = e instanceof Array ? e : [e], this._invokeAll(function(t) {
897
+ t.beforeParse && t.beforeParse(e);
898
+ });
899
+ const n = [];
900
+ for (let t = 0; t < e.length; t++)
901
+ e[t] instanceof Y ? this.processScene(e[t]) : n.push(e[t]);
902
+ n.length > 0 && this.processObjects(n);
903
+ for (let t = 0; t < this.skins.length; ++t)
904
+ this.processSkin(this.skins[t]);
905
+ for (let t = 0; t < s.animations.length; ++t)
906
+ this.processAnimation(s.animations[t], e[0]);
907
+ this._invokeAll(function(t) {
908
+ t.afterParse && t.afterParse(e);
909
+ });
910
+ }
911
+ _invokeAll(e) {
912
+ for (let s = 0, n = this.plugins.length; s < n; s++)
913
+ e(this.plugins[s]);
914
+ }
915
+ }
916
+ class Se {
917
+ constructor(e) {
918
+ this.writer = e, this.name = "KHR_lights_punctual";
919
+ }
920
+ writeNode(e, s) {
921
+ if (!e.isLight) return;
922
+ if (!e.isDirectionalLight && !e.isPointLight && !e.isSpotLight) {
923
+ console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.", e);
924
+ return;
925
+ }
926
+ const n = this.writer, t = n.json, i = n.extensionsUsed, r = {};
927
+ e.name && (r.name = e.name), r.color = e.color.toArray(), r.intensity = e.intensity, e.isDirectionalLight ? r.type = "directional" : e.isPointLight ? (r.type = "point", e.distance > 0 && (r.range = e.distance)) : e.isSpotLight && (r.type = "spot", e.distance > 0 && (r.range = e.distance), r.spot = {}, r.spot.innerConeAngle = (1 - e.penumbra) * e.angle, r.spot.outerConeAngle = e.angle), e.decay !== void 0 && e.decay !== 2 && console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."), e.target && (e.target.parent !== e || e.target.position.x !== 0 || e.target.position.y !== 0 || e.target.position.z !== -1) && console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."), i[this.name] || (t.extensions = t.extensions || {}, t.extensions[this.name] = { lights: [] }, i[this.name] = !0);
928
+ const o = t.extensions[this.name].lights;
929
+ o.push(r), s.extensions = s.extensions || {}, s.extensions[this.name] = { light: o.length - 1 };
930
+ }
931
+ }
932
+ class _e {
933
+ constructor(e) {
934
+ this.writer = e, this.name = "KHR_materials_unlit";
935
+ }
936
+ writeMaterial(e, s) {
937
+ if (!e.isMeshBasicMaterial) return;
938
+ const t = this.writer.extensionsUsed;
939
+ s.extensions = s.extensions || {}, s.extensions[this.name] = {}, t[this.name] = !0, s.pbrMetallicRoughness.metallicFactor = 0, s.pbrMetallicRoughness.roughnessFactor = 0.9;
940
+ }
941
+ }
942
+ class Ce {
943
+ constructor(e) {
944
+ this.writer = e, this.name = "KHR_materials_clearcoat";
945
+ }
946
+ writeMaterial(e, s) {
947
+ if (!e.isMeshPhysicalMaterial || e.clearcoat === 0) return;
948
+ const n = this.writer, t = n.extensionsUsed, i = {};
949
+ if (i.clearcoatFactor = e.clearcoat, e.clearcoatMap) {
950
+ const r = {
951
+ index: n.processTexture(e.clearcoatMap),
952
+ texCoord: e.clearcoatMap.channel
953
+ };
954
+ n.applyTextureTransform(r, e.clearcoatMap), i.clearcoatTexture = r;
955
+ }
956
+ if (i.clearcoatRoughnessFactor = e.clearcoatRoughness, e.clearcoatRoughnessMap) {
957
+ const r = {
958
+ index: n.processTexture(e.clearcoatRoughnessMap),
959
+ texCoord: e.clearcoatRoughnessMap.channel
960
+ };
961
+ n.applyTextureTransform(r, e.clearcoatRoughnessMap), i.clearcoatRoughnessTexture = r;
962
+ }
963
+ if (e.clearcoatNormalMap) {
964
+ const r = {
965
+ index: n.processTexture(e.clearcoatNormalMap),
966
+ texCoord: e.clearcoatNormalMap.channel
967
+ };
968
+ n.applyTextureTransform(r, e.clearcoatNormalMap), i.clearcoatNormalTexture = r;
969
+ }
970
+ s.extensions = s.extensions || {}, s.extensions[this.name] = i, t[this.name] = !0;
971
+ }
972
+ }
973
+ class Ue {
974
+ constructor(e) {
975
+ this.writer = e, this.name = "KHR_materials_iridescence";
976
+ }
977
+ writeMaterial(e, s) {
978
+ if (!e.isMeshPhysicalMaterial || e.iridescence === 0) return;
979
+ const n = this.writer, t = n.extensionsUsed, i = {};
980
+ if (i.iridescenceFactor = e.iridescence, e.iridescenceMap) {
981
+ const r = {
982
+ index: n.processTexture(e.iridescenceMap),
983
+ texCoord: e.iridescenceMap.channel
984
+ };
985
+ n.applyTextureTransform(r, e.iridescenceMap), i.iridescenceTexture = r;
986
+ }
987
+ if (i.iridescenceIor = e.iridescenceIOR, i.iridescenceThicknessMinimum = e.iridescenceThicknessRange[0], i.iridescenceThicknessMaximum = e.iridescenceThicknessRange[1], e.iridescenceThicknessMap) {
988
+ const r = {
989
+ index: n.processTexture(e.iridescenceThicknessMap),
990
+ texCoord: e.iridescenceThicknessMap.channel
991
+ };
992
+ n.applyTextureTransform(r, e.iridescenceThicknessMap), i.iridescenceThicknessTexture = r;
993
+ }
994
+ s.extensions = s.extensions || {}, s.extensions[this.name] = i, t[this.name] = !0;
995
+ }
996
+ }
997
+ class Fe {
998
+ constructor(e) {
999
+ this.writer = e, this.name = "KHR_materials_transmission";
1000
+ }
1001
+ writeMaterial(e, s) {
1002
+ if (!e.isMeshPhysicalMaterial || e.transmission === 0) return;
1003
+ const n = this.writer, t = n.extensionsUsed, i = {};
1004
+ if (i.transmissionFactor = e.transmission, e.transmissionMap) {
1005
+ const r = {
1006
+ index: n.processTexture(e.transmissionMap),
1007
+ texCoord: e.transmissionMap.channel
1008
+ };
1009
+ n.applyTextureTransform(r, e.transmissionMap), i.transmissionTexture = r;
1010
+ }
1011
+ s.extensions = s.extensions || {}, s.extensions[this.name] = i, t[this.name] = !0;
1012
+ }
1013
+ }
1014
+ class Oe {
1015
+ constructor(e) {
1016
+ this.writer = e, this.name = "KHR_materials_volume";
1017
+ }
1018
+ writeMaterial(e, s) {
1019
+ if (!e.isMeshPhysicalMaterial || e.transmission === 0) return;
1020
+ const n = this.writer, t = n.extensionsUsed, i = {};
1021
+ if (i.thicknessFactor = e.thickness, e.thicknessMap) {
1022
+ const r = {
1023
+ index: n.processTexture(e.thicknessMap),
1024
+ texCoord: e.thicknessMap.channel
1025
+ };
1026
+ n.applyTextureTransform(r, e.thicknessMap), i.thicknessTexture = r;
1027
+ }
1028
+ i.attenuationDistance = e.attenuationDistance, i.attenuationColor = e.attenuationColor.toArray(), s.extensions = s.extensions || {}, s.extensions[this.name] = i, t[this.name] = !0;
1029
+ }
1030
+ }
1031
+ class ve {
1032
+ constructor(e) {
1033
+ this.writer = e, this.name = "KHR_materials_ior";
1034
+ }
1035
+ writeMaterial(e, s) {
1036
+ if (!e.isMeshPhysicalMaterial || e.ior === 1.5) return;
1037
+ const t = this.writer.extensionsUsed, i = {};
1038
+ i.ior = e.ior, s.extensions = s.extensions || {}, s.extensions[this.name] = i, t[this.name] = !0;
1039
+ }
1040
+ }
1041
+ class De {
1042
+ constructor(e) {
1043
+ this.writer = e, this.name = "KHR_materials_specular";
1044
+ }
1045
+ writeMaterial(e, s) {
1046
+ if (!e.isMeshPhysicalMaterial || e.specularIntensity === 1 && e.specularColor.equals(ye) && !e.specularIntensityMap && !e.specularColorMap) return;
1047
+ const n = this.writer, t = n.extensionsUsed, i = {};
1048
+ if (e.specularIntensityMap) {
1049
+ const r = {
1050
+ index: n.processTexture(e.specularIntensityMap),
1051
+ texCoord: e.specularIntensityMap.channel
1052
+ };
1053
+ n.applyTextureTransform(r, e.specularIntensityMap), i.specularTexture = r;
1054
+ }
1055
+ if (e.specularColorMap) {
1056
+ const r = {
1057
+ index: n.processTexture(e.specularColorMap),
1058
+ texCoord: e.specularColorMap.channel
1059
+ };
1060
+ n.applyTextureTransform(r, e.specularColorMap), i.specularColorTexture = r;
1061
+ }
1062
+ i.specularFactor = e.specularIntensity, i.specularColorFactor = e.specularColor.toArray(), s.extensions = s.extensions || {}, s.extensions[this.name] = i, t[this.name] = !0;
1063
+ }
1064
+ }
1065
+ class Be {
1066
+ constructor(e) {
1067
+ this.writer = e, this.name = "KHR_materials_sheen";
1068
+ }
1069
+ writeMaterial(e, s) {
1070
+ if (!e.isMeshPhysicalMaterial || e.sheen == 0) return;
1071
+ const n = this.writer, t = n.extensionsUsed, i = {};
1072
+ if (e.sheenRoughnessMap) {
1073
+ const r = {
1074
+ index: n.processTexture(e.sheenRoughnessMap),
1075
+ texCoord: e.sheenRoughnessMap.channel
1076
+ };
1077
+ n.applyTextureTransform(r, e.sheenRoughnessMap), i.sheenRoughnessTexture = r;
1078
+ }
1079
+ if (e.sheenColorMap) {
1080
+ const r = {
1081
+ index: n.processTexture(e.sheenColorMap),
1082
+ texCoord: e.sheenColorMap.channel
1083
+ };
1084
+ n.applyTextureTransform(r, e.sheenColorMap), i.sheenColorTexture = r;
1085
+ }
1086
+ i.sheenRoughnessFactor = e.sheenRoughness, i.sheenColorFactor = e.sheenColor.toArray(), s.extensions = s.extensions || {}, s.extensions[this.name] = i, t[this.name] = !0;
1087
+ }
1088
+ }
1089
+ class Ge {
1090
+ constructor(e) {
1091
+ this.writer = e, this.name = "KHR_materials_anisotropy";
1092
+ }
1093
+ writeMaterial(e, s) {
1094
+ if (!e.isMeshPhysicalMaterial || e.anisotropy == 0) return;
1095
+ const n = this.writer, t = n.extensionsUsed, i = {};
1096
+ if (e.anisotropyMap) {
1097
+ const r = { index: n.processTexture(e.anisotropyMap) };
1098
+ n.applyTextureTransform(r, e.anisotropyMap), i.anisotropyTexture = r;
1099
+ }
1100
+ i.anisotropyStrength = e.anisotropy, i.anisotropyRotation = e.anisotropyRotation, s.extensions = s.extensions || {}, s.extensions[this.name] = i, t[this.name] = !0;
1101
+ }
1102
+ }
1103
+ class ze {
1104
+ constructor(e) {
1105
+ this.writer = e, this.name = "KHR_materials_emissive_strength";
1106
+ }
1107
+ writeMaterial(e, s) {
1108
+ if (!e.isMeshStandardMaterial || e.emissiveIntensity === 1) return;
1109
+ const t = this.writer.extensionsUsed, i = {};
1110
+ i.emissiveStrength = e.emissiveIntensity, s.extensions = s.extensions || {}, s.extensions[this.name] = i, t[this.name] = !0;
1111
+ }
1112
+ }
1113
+ class Pe {
1114
+ constructor(e) {
1115
+ this.writer = e, this.name = "EXT_materials_bump";
1116
+ }
1117
+ writeMaterial(e, s) {
1118
+ if (!e.isMeshStandardMaterial || e.bumpScale === 1 && !e.bumpMap) return;
1119
+ const n = this.writer, t = n.extensionsUsed, i = {};
1120
+ if (e.bumpMap) {
1121
+ const r = {
1122
+ index: n.processTexture(e.bumpMap),
1123
+ texCoord: e.bumpMap.channel
1124
+ };
1125
+ n.applyTextureTransform(r, e.bumpMap), i.bumpTexture = r;
1126
+ }
1127
+ i.bumpFactor = e.bumpScale, s.extensions = s.extensions || {}, s.extensions[this.name] = i, t[this.name] = !0;
1128
+ }
1129
+ }
1130
+ class ke {
1131
+ constructor(e) {
1132
+ this.writer = e, this.name = "EXT_mesh_gpu_instancing";
1133
+ }
1134
+ writeNode(e, s) {
1135
+ if (!e.isInstancedMesh) return;
1136
+ const n = this.writer, t = e, i = new Float32Array(t.count * 3), r = new Float32Array(t.count * 4), o = new Float32Array(t.count * 3), a = new Q(), l = new v(), f = new te(), u = new v();
1137
+ for (let h = 0; h < t.count; h++)
1138
+ t.getMatrixAt(h, a), a.decompose(l, f, u), l.toArray(i, h * 3), f.toArray(r, h * 4), u.toArray(o, h * 3);
1139
+ const m = {
1140
+ TRANSLATION: n.processAccessor(new L(i, 3)),
1141
+ ROTATION: n.processAccessor(new L(r, 4)),
1142
+ SCALE: n.processAccessor(new L(o, 3))
1143
+ };
1144
+ t.instanceColor && (m._COLOR_0 = n.processAccessor(t.instanceColor)), s.extensions = s.extensions || {}, s.extensions[this.name] = { attributes: m }, n.extensionsUsed[this.name] = !0, n.extensionsRequired[this.name] = !0;
1145
+ }
1146
+ }
1147
+ V.Utils = {
1148
+ insertKeyframe: function(c, e) {
1149
+ const n = c.getValueSize(), t = new c.TimeBufferType(c.times.length + 1), i = new c.ValueBufferType(c.values.length + n), r = c.createInterpolant(new c.ValueBufferType(n));
1150
+ let o;
1151
+ if (c.times.length === 0) {
1152
+ t[0] = e;
1153
+ for (let a = 0; a < n; a++)
1154
+ i[a] = 0;
1155
+ o = 0;
1156
+ } else if (e < c.times[0]) {
1157
+ if (Math.abs(c.times[0] - e) < 1e-3) return 0;
1158
+ t[0] = e, t.set(c.times, 1), i.set(r.evaluate(e), 0), i.set(c.values, n), o = 0;
1159
+ } else if (e > c.times[c.times.length - 1]) {
1160
+ if (Math.abs(c.times[c.times.length - 1] - e) < 1e-3)
1161
+ return c.times.length - 1;
1162
+ t[t.length - 1] = e, t.set(c.times, 0), i.set(c.values, 0), i.set(r.evaluate(e), c.values.length), o = t.length - 1;
1163
+ } else
1164
+ for (let a = 0; a < c.times.length; a++) {
1165
+ if (Math.abs(c.times[a] - e) < 1e-3) return a;
1166
+ if (c.times[a] < e && c.times[a + 1] > e) {
1167
+ t.set(c.times.slice(0, a + 1), 0), t[a + 1] = e, t.set(c.times.slice(a + 1), a + 2), i.set(c.values.slice(0, (a + 1) * n), 0), i.set(r.evaluate(e), (a + 1) * n), i.set(c.values.slice((a + 1) * n), (a + 2) * n), o = a + 1;
1168
+ break;
1169
+ }
1170
+ }
1171
+ return c.times = t, c.values = i, o;
1172
+ },
1173
+ mergeMorphTargetTracks: function(c, e) {
1174
+ const s = [], n = {}, t = c.tracks;
1175
+ for (let i = 0; i < t.length; ++i) {
1176
+ let r = t[i];
1177
+ const o = D.parseTrackName(r.name), a = D.findNode(e, o.nodeName);
1178
+ if (o.propertyName !== "morphTargetInfluences" || o.propertyIndex === void 0) {
1179
+ s.push(r);
1180
+ continue;
1181
+ }
1182
+ if (r.createInterpolant !== r.InterpolantFactoryMethodDiscrete && r.createInterpolant !== r.InterpolantFactoryMethodLinear) {
1183
+ if (r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)
1184
+ throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");
1185
+ console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(me);
1186
+ }
1187
+ const l = a.morphTargetInfluences.length, f = a.morphTargetDictionary[o.propertyIndex];
1188
+ if (f === void 0)
1189
+ throw new Error("THREE.GLTFExporter: Morph target name not found: " + o.propertyIndex);
1190
+ let u;
1191
+ if (n[a.uuid] === void 0) {
1192
+ u = r.clone();
1193
+ const h = new u.ValueBufferType(l * u.times.length);
1194
+ for (let p = 0; p < u.times.length; p++)
1195
+ h[p * l + f] = u.values[p];
1196
+ u.name = (o.nodeName || "") + ".morphTargetInfluences", u.values = h, n[a.uuid] = u, s.push(u);
1197
+ continue;
1198
+ }
1199
+ const m = r.createInterpolant(new r.ValueBufferType(1));
1200
+ u = n[a.uuid];
1201
+ for (let h = 0; h < u.times.length; h++)
1202
+ u.values[h * l + f] = m.evaluate(u.times[h]);
1203
+ for (let h = 0; h < r.times.length; h++) {
1204
+ const p = this.insertKeyframe(u, r.times[h]);
1205
+ u.values[p * l + f] = r.values[h];
1206
+ }
1207
+ }
1208
+ return c.tracks = s, c;
1209
+ }
1210
+ };
1211
+ class He {
1212
+ constructor() {
1213
+ this._importer = new Me(), this._exporter = new V();
1214
+ }
1215
+ Import(e, s) {
1216
+ return this._importer.loadAsync(e, (n) => {
1217
+ s && s(n.loaded / n.total);
1218
+ });
1219
+ }
1220
+ Export(e, s, n) {
1221
+ return s ? this._exporter.parseAsync(e, {
1222
+ binary: s,
1223
+ onlyVisible: n
1224
+ }) : this._exporter.parseAsync(e, {
1225
+ binary: s,
1226
+ onlyVisible: n
1227
+ });
1228
+ }
1229
+ }
1230
+ class Ye {
1231
+ constructor(e) {
1232
+ this._scene = e, this._gltfIO = new He();
1233
+ }
1234
+ Import(e, s) {
1235
+ switch (e) {
1236
+ case "glb":
1237
+ return this._gltfIO.Import(s).catch((n) => (console.error(n), null));
1238
+ default:
1239
+ return console.error("DIVEIO.Import: Unsupported file type: " + e), Promise.reject();
1240
+ }
1241
+ }
1242
+ Export(e) {
1243
+ switch (e) {
1244
+ case "glb":
1245
+ return this._gltfIO.Export(this._scene, !0, !0).then((s) => this._createBlobURL(s)).catch((s) => (console.error(s), null));
1246
+ default:
1247
+ return console.error("DIVEIO.Export: Unsupported file type: " + e), Promise.reject();
1248
+ }
1249
+ }
1250
+ _createBlobURL(e) {
1251
+ return URL.createObjectURL(new Blob([e]));
1252
+ }
1253
+ }
1254
+ export {
1255
+ Ye as DIVEIO
1256
+ };
1257
+ //# sourceMappingURL=IO-BgiJzKrU.js.map