@threepipe/plugin-gltf-transform 0.1.0 → 0.1.3
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/dist/GLTFDracoExportPlugin.d.ts +19 -3
- package/dist/GLTFDracoExportPlugin.d.ts.map +1 -1
- package/dist/GLTFDracoExporter.d.ts +1 -1
- package/dist/GLTFDracoExporter.d.ts.map +1 -1
- package/dist/dependencies.txt +0 -3
- package/dist/index.js +439 -665
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +440 -666
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -3
- package/src/GLTFDracoExportPlugin.ts +90 -49
- package/src/GLTFDracoExporter.ts +37 -30
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @threepipe/plugin-gltf-transform v0.1.
|
|
4
|
-
* Copyright 2022-
|
|
3
|
+
* @threepipe/plugin-gltf-transform v0.1.3
|
|
4
|
+
* Copyright 2022-2025 repalash <palash@shaders.app>
|
|
5
5
|
* Apache-2.0 License
|
|
6
6
|
* See ./dependencies.txt for any bundled third-party dependencies and licenses.
|
|
7
7
|
*/
|
|
8
|
-
import { GLTFViewerConfigExtension, GLTFExporter2, AViewerPluginSync,
|
|
8
|
+
import { GLTFViewerConfigExtension, GLTFExporter2, AViewerPluginSync, GLTFMaterialsBumpMapExtension, GLTFMaterialsLightMapExtension, GLTFMaterialsAlphaMapExtension, GLTFMaterialsDisplacementMapExtension, customBumpMapGLTFExtension, GLTFLightExtrasExtension, GLTFObject3DExtrasExtension, GLTFMaterialExtrasExtension, clearCoatTintGLTFExtension, noiseBumpMaterialGLTFExtension, fragmentClippingGLTFExtension, generateUUID, AssetExporterPlugin } from "threepipe";
|
|
9
9
|
class EventDispatcher {
|
|
10
10
|
constructor() {
|
|
11
11
|
this._listeners = {};
|
|
@@ -21,8 +21,7 @@ class EventDispatcher {
|
|
|
21
21
|
return this;
|
|
22
22
|
}
|
|
23
23
|
removeEventListener(type, listener) {
|
|
24
|
-
if (this._listeners === void 0)
|
|
25
|
-
return this;
|
|
24
|
+
if (this._listeners === void 0) return this;
|
|
26
25
|
const listeners = this._listeners;
|
|
27
26
|
const listenerArray = listeners[type];
|
|
28
27
|
if (listenerArray !== void 0) {
|
|
@@ -34,8 +33,7 @@ class EventDispatcher {
|
|
|
34
33
|
return this;
|
|
35
34
|
}
|
|
36
35
|
dispatchEvent(event) {
|
|
37
|
-
if (this._listeners === void 0)
|
|
38
|
-
return this;
|
|
36
|
+
if (this._listeners === void 0) return this;
|
|
39
37
|
const listeners = this._listeners;
|
|
40
38
|
const listenerArray = listeners[event.type];
|
|
41
39
|
if (listenerArray !== void 0) {
|
|
@@ -96,8 +94,7 @@ class GraphEdge extends EventDispatcher {
|
|
|
96
94
|
}
|
|
97
95
|
/** Destroys a (currently intact) edge, updating both the graph and the owner. */
|
|
98
96
|
dispose() {
|
|
99
|
-
if (this._disposed)
|
|
100
|
-
return;
|
|
97
|
+
if (this._disposed) return;
|
|
101
98
|
this._disposed = true;
|
|
102
99
|
this.dispatchEvent({
|
|
103
100
|
type: "dispose",
|
|
@@ -162,12 +159,10 @@ class Graph extends EventDispatcher {
|
|
|
162
159
|
_registerEdge(edge) {
|
|
163
160
|
this._edges.add(edge);
|
|
164
161
|
const parent = edge.getParent();
|
|
165
|
-
if (!this._parentEdges.has(parent))
|
|
166
|
-
this._parentEdges.set(parent, /* @__PURE__ */ new Set());
|
|
162
|
+
if (!this._parentEdges.has(parent)) this._parentEdges.set(parent, /* @__PURE__ */ new Set());
|
|
167
163
|
this._parentEdges.get(parent).add(edge);
|
|
168
164
|
const child = edge.getChild();
|
|
169
|
-
if (!this._childEdges.has(child))
|
|
170
|
-
this._childEdges.set(child, /* @__PURE__ */ new Set());
|
|
165
|
+
if (!this._childEdges.has(child)) this._childEdges.set(child, /* @__PURE__ */ new Set());
|
|
171
166
|
this._childEdges.get(child).add(edge);
|
|
172
167
|
edge.addEventListener("dispose", () => this._removeEdge(edge));
|
|
173
168
|
return edge;
|
|
@@ -299,8 +294,7 @@ class GraphNode extends EventDispatcher {
|
|
|
299
294
|
* disposed object is not reusable.
|
|
300
295
|
*/
|
|
301
296
|
dispose() {
|
|
302
|
-
if (this._disposed)
|
|
303
|
-
return;
|
|
297
|
+
if (this._disposed) return;
|
|
304
298
|
this.graph.listChildEdges(this).forEach((edge) => edge.dispose());
|
|
305
299
|
this.graph.disconnectParents(this);
|
|
306
300
|
this._disposed = true;
|
|
@@ -379,10 +373,8 @@ class GraphNode extends EventDispatcher {
|
|
|
379
373
|
throw new Error(`Cannot overwrite immutable attribute, "${attribute}".`);
|
|
380
374
|
}
|
|
381
375
|
const prevRef = this[$attributes][attribute];
|
|
382
|
-
if (prevRef)
|
|
383
|
-
|
|
384
|
-
if (!value)
|
|
385
|
-
return this;
|
|
376
|
+
if (prevRef) prevRef.dispose();
|
|
377
|
+
if (!value) return this;
|
|
386
378
|
const ref = this.graph.createEdge(attribute, this, value, attributes);
|
|
387
379
|
ref.addEventListener("dispose", () => {
|
|
388
380
|
delete this[$attributes][attribute];
|
|
@@ -452,10 +444,8 @@ class GraphNode extends EventDispatcher {
|
|
|
452
444
|
setRefMap(attribute, key, value, metadata) {
|
|
453
445
|
const refMap = this[$attributes][attribute];
|
|
454
446
|
const prevRef = refMap[key];
|
|
455
|
-
if (prevRef)
|
|
456
|
-
|
|
457
|
-
if (!value)
|
|
458
|
-
return this;
|
|
447
|
+
if (prevRef) prevRef.dispose();
|
|
448
|
+
if (!value) return this;
|
|
459
449
|
metadata = Object.assign(metadata || {}, {
|
|
460
450
|
key
|
|
461
451
|
});
|
|
@@ -519,43 +509,36 @@ function v$1(t, e, r) {
|
|
|
519
509
|
}
|
|
520
510
|
function T(t) {
|
|
521
511
|
const e = { min: [Infinity, Infinity, Infinity], max: [-Infinity, -Infinity, -Infinity] }, r = t.propertyType === h.NODE ? [t] : t.listChildren();
|
|
522
|
-
for (const t2 of r)
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
A$1(s.min, e), A$1(s.max, e);
|
|
529
|
-
});
|
|
512
|
+
for (const t2 of r) t2.traverse((t3) => {
|
|
513
|
+
const r2 = t3.getMesh();
|
|
514
|
+
if (!r2) return;
|
|
515
|
+
const s = x(r2, t3.getWorldMatrix());
|
|
516
|
+
A$1(s.min, e), A$1(s.max, e);
|
|
517
|
+
});
|
|
530
518
|
return e;
|
|
531
519
|
}
|
|
532
520
|
Math.hypot || (Math.hypot = function() {
|
|
533
|
-
for (var t = 0, e = arguments.length; e--; )
|
|
534
|
-
t += arguments[e] * arguments[e];
|
|
521
|
+
for (var t = 0, e = arguments.length; e--; ) t += arguments[e] * arguments[e];
|
|
535
522
|
return Math.sqrt(t);
|
|
536
523
|
}), m = new w$1(3), w$1 != Float32Array && (m[0] = 0, m[1] = 0, m[2] = 0);
|
|
537
524
|
function x(t, e) {
|
|
538
525
|
const r = { min: [Infinity, Infinity, Infinity], max: [-Infinity, -Infinity, -Infinity] };
|
|
539
526
|
for (const s of t.listPrimitives()) {
|
|
540
527
|
const t2 = s.getAttribute("POSITION");
|
|
541
|
-
if (!t2)
|
|
542
|
-
continue;
|
|
528
|
+
if (!t2) continue;
|
|
543
529
|
let n = [0, 0, 0], i = [0, 0, 0];
|
|
544
|
-
for (let s2 = 0; s2 < t2.getCount(); s2++)
|
|
545
|
-
n = t2.getElement(s2, n), i = v$1(i, n, e), A$1(i, r);
|
|
530
|
+
for (let s2 = 0; s2 < t2.getCount(); s2++) n = t2.getElement(s2, n), i = v$1(i, n, e), A$1(i, r);
|
|
546
531
|
}
|
|
547
532
|
return r;
|
|
548
533
|
}
|
|
549
534
|
function A$1(t, e) {
|
|
550
|
-
for (let r = 0; r < 3; r++)
|
|
551
|
-
e.min[r] = Math.min(t[r], e.min[r]), e.max[r] = Math.max(t[r], e.max[r]);
|
|
535
|
+
for (let r = 0; r < 3; r++) e.min[r] = Math.min(t[r], e.min[r]), e.max[r] = Math.max(t[r], e.max[r]);
|
|
552
536
|
}
|
|
553
537
|
class E {
|
|
554
538
|
static createBufferFromDataURI(t) {
|
|
555
539
|
if ("undefined" == typeof Buffer) {
|
|
556
540
|
const e = atob(t.split(",")[1]), r = new Uint8Array(e.length);
|
|
557
|
-
for (let t2 = 0; t2 < e.length; t2++)
|
|
558
|
-
r[t2] = e.charCodeAt(t2);
|
|
541
|
+
for (let t2 = 0; t2 < e.length; t2++) r[t2] = e.charCodeAt(t2);
|
|
559
542
|
return r;
|
|
560
543
|
}
|
|
561
544
|
{
|
|
@@ -571,44 +554,34 @@ class E {
|
|
|
571
554
|
}
|
|
572
555
|
static concat(t) {
|
|
573
556
|
let e = 0;
|
|
574
|
-
for (const r2 of t)
|
|
575
|
-
e += r2.byteLength;
|
|
557
|
+
for (const r2 of t) e += r2.byteLength;
|
|
576
558
|
const r = new Uint8Array(e);
|
|
577
559
|
let s = 0;
|
|
578
|
-
for (const e2 of t)
|
|
579
|
-
r.set(e2, s), s += e2.byteLength;
|
|
560
|
+
for (const e2 of t) r.set(e2, s), s += e2.byteLength;
|
|
580
561
|
return r;
|
|
581
562
|
}
|
|
582
563
|
static pad(t, e = 0) {
|
|
583
564
|
const r = this.padNumber(t.byteLength);
|
|
584
|
-
if (r === t.byteLength)
|
|
585
|
-
return t;
|
|
565
|
+
if (r === t.byteLength) return t;
|
|
586
566
|
const s = new Uint8Array(r);
|
|
587
|
-
if (s.set(t), 0 !== e)
|
|
588
|
-
for (let n = t.byteLength; n < r; n++)
|
|
589
|
-
s[n] = e;
|
|
567
|
+
if (s.set(t), 0 !== e) for (let n = t.byteLength; n < r; n++) s[n] = e;
|
|
590
568
|
return s;
|
|
591
569
|
}
|
|
592
570
|
static padNumber(t) {
|
|
593
571
|
return 4 * Math.ceil(t / 4);
|
|
594
572
|
}
|
|
595
573
|
static equals(t, e) {
|
|
596
|
-
if (t === e)
|
|
597
|
-
|
|
598
|
-
if (t.byteLength !== e.byteLength)
|
|
599
|
-
return false;
|
|
574
|
+
if (t === e) return true;
|
|
575
|
+
if (t.byteLength !== e.byteLength) return false;
|
|
600
576
|
let r = t.byteLength;
|
|
601
|
-
for (; r--; )
|
|
602
|
-
if (t[r] !== e[r])
|
|
603
|
-
return false;
|
|
577
|
+
for (; r--; ) if (t[r] !== e[r]) return false;
|
|
604
578
|
return true;
|
|
605
579
|
}
|
|
606
580
|
static toView(t, e = 0, r = Infinity) {
|
|
607
581
|
return new Uint8Array(t.buffer, t.byteOffset + e, Math.min(t.byteLength, r));
|
|
608
582
|
}
|
|
609
583
|
static assertView(t) {
|
|
610
|
-
if (t && !ArrayBuffer.isView(t))
|
|
611
|
-
throw new Error(`Method requires Uint8Array parameter; received "${typeof t}".`);
|
|
584
|
+
if (t && !ArrayBuffer.isView(t)) throw new Error(`Method requires Uint8Array parameter; received "${typeof t}".`);
|
|
612
585
|
return t;
|
|
613
586
|
}
|
|
614
587
|
}
|
|
@@ -624,14 +597,12 @@ let M$1 = class M {
|
|
|
624
597
|
}
|
|
625
598
|
static convertSRGBToLinear(t, e) {
|
|
626
599
|
const r = t, s = e;
|
|
627
|
-
for (let t2 = 0; t2 < 3; t2++)
|
|
628
|
-
s[t2] = r[t2] < 0.04045 ? 0.0773993808 * r[t2] : Math.pow(0.9478672986 * r[t2] + 0.0521327014, 2.4);
|
|
600
|
+
for (let t2 = 0; t2 < 3; t2++) s[t2] = r[t2] < 0.04045 ? 0.0773993808 * r[t2] : Math.pow(0.9478672986 * r[t2] + 0.0521327014, 2.4);
|
|
629
601
|
return e;
|
|
630
602
|
}
|
|
631
603
|
static convertLinearToSRGB(t, e) {
|
|
632
604
|
const r = t, s = e;
|
|
633
|
-
for (let t2 = 0; t2 < 3; t2++)
|
|
634
|
-
s[t2] = r[t2] < 31308e-7 ? 12.92 * r[t2] : 1.055 * Math.pow(r[t2], 0.41666) - 0.055;
|
|
605
|
+
for (let t2 = 0; t2 < 3; t2++) s[t2] = r[t2] < 31308e-7 ? 12.92 * r[t2] : 1.055 * Math.pow(r[t2], 0.41666) - 0.055;
|
|
635
606
|
return e;
|
|
636
607
|
}
|
|
637
608
|
};
|
|
@@ -653,9 +624,7 @@ class I {
|
|
|
653
624
|
this.impls[t] = e;
|
|
654
625
|
}
|
|
655
626
|
static getMimeType(t) {
|
|
656
|
-
for (const e in this.impls)
|
|
657
|
-
if (this.impls[e].match(t))
|
|
658
|
-
return e;
|
|
627
|
+
for (const e in this.impls) if (this.impls[e].match(t)) return e;
|
|
659
628
|
return null;
|
|
660
629
|
}
|
|
661
630
|
static getSize(t, e) {
|
|
@@ -665,16 +634,12 @@ class I {
|
|
|
665
634
|
return this.impls[e] ? this.impls[e].getChannels(t) : null;
|
|
666
635
|
}
|
|
667
636
|
static getVRAMByteLength(t, e) {
|
|
668
|
-
if (!this.impls[e])
|
|
669
|
-
|
|
670
|
-
if (this.impls[e].getVRAMByteLength)
|
|
671
|
-
return this.impls[e].getVRAMByteLength(t);
|
|
637
|
+
if (!this.impls[e]) return null;
|
|
638
|
+
if (this.impls[e].getVRAMByteLength) return this.impls[e].getVRAMByteLength(t);
|
|
672
639
|
let r = 0;
|
|
673
640
|
const s = this.getSize(t, e);
|
|
674
|
-
if (!s)
|
|
675
|
-
|
|
676
|
-
for (; s[0] > 1 || s[1] > 1; )
|
|
677
|
-
r += s[0] * s[1] * 4, s[0] = Math.max(Math.floor(s[0] / 2), 1), s[1] = Math.max(Math.floor(s[1] / 2), 1);
|
|
641
|
+
if (!s) return null;
|
|
642
|
+
for (; s[0] > 1 || s[1] > 1; ) r += s[0] * s[1] * 4, s[0] = Math.max(Math.floor(s[0] / 2), 1), s[1] = Math.max(Math.floor(s[1] / 2), 1);
|
|
678
643
|
return r += 4, r;
|
|
679
644
|
}
|
|
680
645
|
static mimeTypeToExtension(t) {
|
|
@@ -685,10 +650,8 @@ class I {
|
|
|
685
650
|
}
|
|
686
651
|
}
|
|
687
652
|
function R$1(t, e) {
|
|
688
|
-
if (e > t.byteLength)
|
|
689
|
-
|
|
690
|
-
if (255 !== t.getUint8(e))
|
|
691
|
-
throw new TypeError("Invalid JPG, marker table corrupted");
|
|
653
|
+
if (e > t.byteLength) throw new TypeError("Corrupt JPG, exceeded buffer limits");
|
|
654
|
+
if (255 !== t.getUint8(e)) throw new TypeError("Invalid JPG, marker table corrupted");
|
|
692
655
|
return t;
|
|
693
656
|
}
|
|
694
657
|
I.impls = { "image/jpeg": new class {
|
|
@@ -698,8 +661,7 @@ I.impls = { "image/jpeg": new class {
|
|
|
698
661
|
getSize(t) {
|
|
699
662
|
let e, r, s = new DataView(t.buffer, t.byteOffset + 4);
|
|
700
663
|
for (; s.byteLength; ) {
|
|
701
|
-
if (e = s.getUint16(0, false), R$1(s, e), r = s.getUint8(e + 1), 192 === r || 193 === r || 194 === r)
|
|
702
|
-
return [s.getUint16(e + 7, false), s.getUint16(e + 5, false)];
|
|
664
|
+
if (e = s.getUint16(0, false), R$1(s, e), r = s.getUint8(e + 1), 192 === r || 193 === r || 194 === r) return [s.getUint16(e + 7, false), s.getUint16(e + 5, false)];
|
|
703
665
|
s = new DataView(t.buffer, s.byteOffset + e + 2);
|
|
704
666
|
}
|
|
705
667
|
throw new TypeError("Invalid JPG, no size found");
|
|
@@ -725,11 +687,9 @@ function O$1(t) {
|
|
|
725
687
|
return "[object Object]" === Object.prototype.toString.call(t);
|
|
726
688
|
}
|
|
727
689
|
function C$1(t) {
|
|
728
|
-
if (false === O$1(t))
|
|
729
|
-
return false;
|
|
690
|
+
if (false === O$1(t)) return false;
|
|
730
691
|
const e = t.constructor;
|
|
731
|
-
if (void 0 === e)
|
|
732
|
-
return true;
|
|
692
|
+
if (void 0 === e) return true;
|
|
733
693
|
const r = e.prototype;
|
|
734
694
|
return false !== O$1(r) && false !== Object.prototype.hasOwnProperty.call(r, "isPrototypeOf");
|
|
735
695
|
}
|
|
@@ -764,11 +724,8 @@ let P$1 = class P {
|
|
|
764
724
|
return t;
|
|
765
725
|
}
|
|
766
726
|
static eq(t, e, r = 1e-5) {
|
|
767
|
-
if (t.length !== e.length)
|
|
768
|
-
|
|
769
|
-
for (let s = 0; s < t.length; s++)
|
|
770
|
-
if (Math.abs(t[s] - e[s]) > r)
|
|
771
|
-
return false;
|
|
727
|
+
if (t.length !== e.length) return false;
|
|
728
|
+
for (let s = 0; s < t.length; s++) if (Math.abs(t[s] - e[s]) > r) return false;
|
|
772
729
|
return true;
|
|
773
730
|
}
|
|
774
731
|
static decodeNormalizedInt(t, e) {
|
|
@@ -831,76 +788,54 @@ let P$1 = class P {
|
|
|
831
788
|
}
|
|
832
789
|
};
|
|
833
790
|
function L$1(t, e) {
|
|
834
|
-
if (!!t != !!e)
|
|
835
|
-
return false;
|
|
791
|
+
if (!!t != !!e) return false;
|
|
836
792
|
const r = t.getChild(), s = e.getChild();
|
|
837
793
|
return r === s || r.equals(s);
|
|
838
794
|
}
|
|
839
795
|
function j$1(t, e) {
|
|
840
|
-
if (!!t != !!e)
|
|
841
|
-
|
|
842
|
-
if (t.length !== e.length)
|
|
843
|
-
return false;
|
|
796
|
+
if (!!t != !!e) return false;
|
|
797
|
+
if (t.length !== e.length) return false;
|
|
844
798
|
for (let r = 0; r < t.length; r++) {
|
|
845
799
|
const s = t[r], n = e[r];
|
|
846
|
-
if (s.getChild() !== n.getChild() && !s.getChild().equals(n.getChild()))
|
|
847
|
-
return false;
|
|
800
|
+
if (s.getChild() !== n.getChild() && !s.getChild().equals(n.getChild())) return false;
|
|
848
801
|
}
|
|
849
802
|
return true;
|
|
850
803
|
}
|
|
851
804
|
function D$1(t, e) {
|
|
852
|
-
if (!!t != !!e)
|
|
853
|
-
return false;
|
|
805
|
+
if (!!t != !!e) return false;
|
|
854
806
|
const r = Object.keys(t), s = Object.keys(e);
|
|
855
|
-
if (r.length !== s.length)
|
|
856
|
-
return false;
|
|
807
|
+
if (r.length !== s.length) return false;
|
|
857
808
|
for (const r2 in t) {
|
|
858
809
|
const s2 = t[r2], n = e[r2];
|
|
859
|
-
if (!!s2 != !!n)
|
|
860
|
-
return false;
|
|
810
|
+
if (!!s2 != !!n) return false;
|
|
861
811
|
const i = s2.getChild(), o = n.getChild();
|
|
862
|
-
if (i !== o && !i.equals(o))
|
|
863
|
-
return false;
|
|
812
|
+
if (i !== o && !i.equals(o)) return false;
|
|
864
813
|
}
|
|
865
814
|
return true;
|
|
866
815
|
}
|
|
867
816
|
function _$1(t, e) {
|
|
868
|
-
if (t === e)
|
|
869
|
-
|
|
870
|
-
if (
|
|
871
|
-
|
|
872
|
-
if (t.length !== e.length)
|
|
873
|
-
return false;
|
|
874
|
-
for (let r = 0; r < t.length; r++)
|
|
875
|
-
if (t[r] !== e[r])
|
|
876
|
-
return false;
|
|
817
|
+
if (t === e) return true;
|
|
818
|
+
if (!!t != !!e || !t || !e) return false;
|
|
819
|
+
if (t.length !== e.length) return false;
|
|
820
|
+
for (let r = 0; r < t.length; r++) if (t[r] !== e[r]) return false;
|
|
877
821
|
return true;
|
|
878
822
|
}
|
|
879
823
|
function k$1(t, e) {
|
|
880
|
-
if (t === e)
|
|
881
|
-
|
|
882
|
-
if (
|
|
883
|
-
return false;
|
|
884
|
-
if (!C$1(t) || !C$1(e))
|
|
885
|
-
return t === e;
|
|
824
|
+
if (t === e) return true;
|
|
825
|
+
if (!!t != !!e) return false;
|
|
826
|
+
if (!C$1(t) || !C$1(e)) return t === e;
|
|
886
827
|
const r = t, s = e;
|
|
887
828
|
let n, i = 0, o = 0;
|
|
888
|
-
for (n in r)
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
o++;
|
|
892
|
-
if (i !== o)
|
|
893
|
-
return false;
|
|
829
|
+
for (n in r) i++;
|
|
830
|
+
for (n in s) o++;
|
|
831
|
+
if (i !== o) return false;
|
|
894
832
|
for (n in r) {
|
|
895
833
|
const t2 = r[n], e2 = s[n];
|
|
896
834
|
if (z$1(t2) && z$1(e2)) {
|
|
897
|
-
if (!_$1(t2, e2))
|
|
898
|
-
return false;
|
|
835
|
+
if (!_$1(t2, e2)) return false;
|
|
899
836
|
} else if (C$1(t2) && C$1(e2)) {
|
|
900
|
-
if (!k$1(t2, e2))
|
|
901
|
-
|
|
902
|
-
} else if (t2 !== e2)
|
|
903
|
-
return false;
|
|
837
|
+
if (!k$1(t2, e2)) return false;
|
|
838
|
+
} else if (t2 !== e2) return false;
|
|
904
839
|
}
|
|
905
840
|
return true;
|
|
906
841
|
}
|
|
@@ -909,14 +844,12 @@ function z$1(t) {
|
|
|
909
844
|
}
|
|
910
845
|
const G$1 = "23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ", J$1 = /* @__PURE__ */ new Set(), $$1 = function() {
|
|
911
846
|
let t = "";
|
|
912
|
-
for (let e = 0; e < 6; e++)
|
|
913
|
-
t += G$1.charAt(Math.floor(Math.random() * G$1.length));
|
|
847
|
+
for (let e = 0; e < 6; e++) t += G$1.charAt(Math.floor(Math.random() * G$1.length));
|
|
914
848
|
return t;
|
|
915
849
|
}, V$1 = function() {
|
|
916
850
|
for (let t = 0; t < 999; t++) {
|
|
917
851
|
const t2 = $$1();
|
|
918
|
-
if (!J$1.has(t2))
|
|
919
|
-
return J$1.add(t2), t2;
|
|
852
|
+
if (!J$1.has(t2)) return J$1.add(t2), t2;
|
|
920
853
|
}
|
|
921
854
|
return "";
|
|
922
855
|
};
|
|
@@ -932,12 +865,10 @@ let W$1 = class W {
|
|
|
932
865
|
return N$1.extension(new URL(t, "https://null.example").pathname);
|
|
933
866
|
}
|
|
934
867
|
static resolve(t, e) {
|
|
935
|
-
if (!this.isRelativePath(e))
|
|
936
|
-
return e;
|
|
868
|
+
if (!this.isRelativePath(e)) return e;
|
|
937
869
|
const r = t.split("/"), s = e.split("/");
|
|
938
870
|
r.pop();
|
|
939
|
-
for (let t2 = 0; t2 < s.length; t2++)
|
|
940
|
-
"." !== s[t2] && (".." === s[t2] ? r.pop() : r.push(s[t2]));
|
|
871
|
+
for (let t2 = 0; t2 < s.length; t2++) "." !== s[t2] && (".." === s[t2] ? r.pop() : r.push(s[t2]));
|
|
941
872
|
return r.join("/");
|
|
942
873
|
}
|
|
943
874
|
static isAbsoluteURL(t) {
|
|
@@ -980,58 +911,39 @@ let Y$1 = class Y extends GraphNode {
|
|
|
980
911
|
copy(t, o = q$1) {
|
|
981
912
|
for (const t2 in this[$attributes]) {
|
|
982
913
|
const o2 = this[$attributes][t2];
|
|
983
|
-
if (o2 instanceof GraphEdge)
|
|
984
|
-
|
|
985
|
-
else if (
|
|
986
|
-
for (const t3 of o2)
|
|
987
|
-
t3.dispose();
|
|
988
|
-
else if (isRefMap(o2))
|
|
989
|
-
for (const t3 in o2)
|
|
990
|
-
o2[t3].dispose();
|
|
914
|
+
if (o2 instanceof GraphEdge) this[$immutableKeys].has(t2) || o2.dispose();
|
|
915
|
+
else if (isRefList(o2)) for (const t3 of o2) t3.dispose();
|
|
916
|
+
else if (isRefMap(o2)) for (const t3 in o2) o2[t3].dispose();
|
|
991
917
|
}
|
|
992
918
|
for (const a in t[$attributes]) {
|
|
993
919
|
const u = this[$attributes][a], c2 = t[$attributes][a];
|
|
994
|
-
if (c2 instanceof GraphEdge)
|
|
995
|
-
|
|
996
|
-
else if (
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
const e = c2[t2];
|
|
1002
|
-
this.setRefMap(a, t2, o(e.getChild()), e.getAttributes());
|
|
1003
|
-
}
|
|
1004
|
-
else
|
|
1005
|
-
this[$attributes][a] = C$1(c2) ? JSON.parse(JSON.stringify(c2)) : Array.isArray(c2) || c2 instanceof ArrayBuffer || ArrayBuffer.isView(c2) ? c2.slice() : c2;
|
|
920
|
+
if (c2 instanceof GraphEdge) this[$immutableKeys].has(a) ? u.getChild().copy(o(c2.getChild()), o) : this.setRef(a, o(c2.getChild()), c2.getAttributes());
|
|
921
|
+
else if (isRefList(c2)) for (const t2 of c2) this.addRef(a, o(t2.getChild()), t2.getAttributes());
|
|
922
|
+
else if (isRefMap(c2)) for (const t2 in c2) {
|
|
923
|
+
const e = c2[t2];
|
|
924
|
+
this.setRefMap(a, t2, o(e.getChild()), e.getAttributes());
|
|
925
|
+
}
|
|
926
|
+
else this[$attributes][a] = C$1(c2) ? JSON.parse(JSON.stringify(c2)) : Array.isArray(c2) || c2 instanceof ArrayBuffer || ArrayBuffer.isView(c2) ? c2.slice() : c2;
|
|
1006
927
|
}
|
|
1007
928
|
return this;
|
|
1008
929
|
}
|
|
1009
930
|
equals(t, r = H$1) {
|
|
1010
|
-
if (this === t)
|
|
1011
|
-
|
|
1012
|
-
if (this.propertyType !== t.propertyType)
|
|
1013
|
-
return false;
|
|
931
|
+
if (this === t) return true;
|
|
932
|
+
if (this.propertyType !== t.propertyType) return false;
|
|
1014
933
|
for (const s in this[$attributes]) {
|
|
1015
|
-
if (r.has(s))
|
|
1016
|
-
continue;
|
|
934
|
+
if (r.has(s)) continue;
|
|
1017
935
|
const a = this[$attributes][s], u = t[$attributes][s];
|
|
1018
936
|
if (isRef(a) || isRef(u)) {
|
|
1019
|
-
if (!L$1(a, u))
|
|
1020
|
-
return false;
|
|
937
|
+
if (!L$1(a, u)) return false;
|
|
1021
938
|
} else if (isRefList(a) || isRefList(u)) {
|
|
1022
|
-
if (!j$1(a, u))
|
|
1023
|
-
return false;
|
|
939
|
+
if (!j$1(a, u)) return false;
|
|
1024
940
|
} else if (isRefMap(a) || isRefMap(u)) {
|
|
1025
|
-
if (!D$1(a, u))
|
|
1026
|
-
return false;
|
|
941
|
+
if (!D$1(a, u)) return false;
|
|
1027
942
|
} else if (C$1(a) || C$1(u)) {
|
|
1028
|
-
if (!k$1(a, u))
|
|
1029
|
-
return false;
|
|
943
|
+
if (!k$1(a, u)) return false;
|
|
1030
944
|
} else if (z$1(a) || z$1(u)) {
|
|
1031
|
-
if (!_$1(a, u))
|
|
1032
|
-
|
|
1033
|
-
} else if (a !== u)
|
|
1034
|
-
return false;
|
|
945
|
+
if (!_$1(a, u)) return false;
|
|
946
|
+
} else if (a !== u) return false;
|
|
1035
947
|
}
|
|
1036
948
|
return true;
|
|
1037
949
|
}
|
|
@@ -1106,37 +1018,31 @@ let K$1 = class K extends Z$1 {
|
|
|
1106
1018
|
getMinNormalized(t) {
|
|
1107
1019
|
const e = this.getElementSize();
|
|
1108
1020
|
this.getMin(t);
|
|
1109
|
-
for (let r = 0; r < e; r++)
|
|
1110
|
-
t[r] = this.o(t[r]);
|
|
1021
|
+
for (let r = 0; r < e; r++) t[r] = this.o(t[r]);
|
|
1111
1022
|
return t;
|
|
1112
1023
|
}
|
|
1113
1024
|
getMin(t) {
|
|
1114
1025
|
const e = this.get("array"), r = this.getCount(), s = this.getElementSize();
|
|
1115
|
-
for (let e2 = 0; e2 < s; e2++)
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
Number.isFinite(s2) && (t[r2] = Math.min(t[r2], s2));
|
|
1121
|
-
}
|
|
1026
|
+
for (let e2 = 0; e2 < s; e2++) t[e2] = Infinity;
|
|
1027
|
+
for (let n = 0; n < r * s; n += s) for (let r2 = 0; r2 < s; r2++) {
|
|
1028
|
+
const s2 = e[n + r2];
|
|
1029
|
+
Number.isFinite(s2) && (t[r2] = Math.min(t[r2], s2));
|
|
1030
|
+
}
|
|
1122
1031
|
return t;
|
|
1123
1032
|
}
|
|
1124
1033
|
getMaxNormalized(t) {
|
|
1125
1034
|
const e = this.getElementSize();
|
|
1126
1035
|
this.getMax(t);
|
|
1127
|
-
for (let r = 0; r < e; r++)
|
|
1128
|
-
t[r] = this.o(t[r]);
|
|
1036
|
+
for (let r = 0; r < e; r++) t[r] = this.o(t[r]);
|
|
1129
1037
|
return t;
|
|
1130
1038
|
}
|
|
1131
1039
|
getMax(t) {
|
|
1132
1040
|
const e = this.get("array"), r = this.getCount(), s = this.getElementSize();
|
|
1133
|
-
for (let e2 = 0; e2 < s; e2++)
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
Number.isFinite(s2) && (t[r2] = Math.max(t[r2], s2));
|
|
1139
|
-
}
|
|
1041
|
+
for (let e2 = 0; e2 < s; e2++) t[e2] = -Infinity;
|
|
1042
|
+
for (let n = 0; n < r * s; n += s) for (let r2 = 0; r2 < s; r2++) {
|
|
1043
|
+
const s2 = e[n + r2];
|
|
1044
|
+
Number.isFinite(s2) && (t[r2] = Math.max(t[r2], s2));
|
|
1045
|
+
}
|
|
1140
1046
|
return t;
|
|
1141
1047
|
}
|
|
1142
1048
|
getCount() {
|
|
@@ -1173,14 +1079,12 @@ let K$1 = class K extends Z$1 {
|
|
|
1173
1079
|
}
|
|
1174
1080
|
getElement(t, e) {
|
|
1175
1081
|
const r = this.getElementSize(), s = this.get("array");
|
|
1176
|
-
for (let n = 0; n < r; n++)
|
|
1177
|
-
e[n] = this.o(s[t * r + n]);
|
|
1082
|
+
for (let n = 0; n < r; n++) e[n] = this.o(s[t * r + n]);
|
|
1178
1083
|
return e;
|
|
1179
1084
|
}
|
|
1180
1085
|
setElement(t, e) {
|
|
1181
1086
|
const r = this.getElementSize(), s = this.get("array");
|
|
1182
|
-
for (let n = 0; n < r; n++)
|
|
1183
|
-
s[t * r + n] = this.i(e[n]);
|
|
1087
|
+
for (let n = 0; n < r; n++) s[t * r + n] = this.i(e[n]);
|
|
1184
1088
|
return this;
|
|
1185
1089
|
}
|
|
1186
1090
|
getSparse() {
|
|
@@ -1371,8 +1275,7 @@ let rt$1 = class rt extends Z$1 {
|
|
|
1371
1275
|
rt$1.Type = { PERSPECTIVE: "perspective", ORTHOGRAPHIC: "orthographic" };
|
|
1372
1276
|
let st$1 = class st extends Y$1 {
|
|
1373
1277
|
t(t) {
|
|
1374
|
-
if (!this.parentTypes.includes(t.propertyType))
|
|
1375
|
-
throw new Error(`Parent "${t.propertyType}" invalid for child "${this.propertyType}".`);
|
|
1278
|
+
if (!this.parentTypes.includes(t.propertyType)) throw new Error(`Parent "${t.propertyType}" invalid for child "${this.propertyType}".`);
|
|
1376
1279
|
}
|
|
1377
1280
|
};
|
|
1378
1281
|
st$1.EXTENSION_NAME = void 0;
|
|
@@ -1579,8 +1482,7 @@ let ft$1 = class ft extends Z$1 {
|
|
|
1579
1482
|
return Object.assign(super.getDefaults(), { translation: [0, 0, 0], rotation: [0, 0, 0, 1], scale: [1, 1, 1], weights: [], camera: null, mesh: null, skin: null, children: [] });
|
|
1580
1483
|
}
|
|
1581
1484
|
copy(t, e = q$1) {
|
|
1582
|
-
if (e === q$1)
|
|
1583
|
-
throw new Error("Node cannot be copied.");
|
|
1485
|
+
if (e === q$1) throw new Error("Node cannot be copied.");
|
|
1584
1486
|
return super.copy(t, e);
|
|
1585
1487
|
}
|
|
1586
1488
|
getTranslation() {
|
|
@@ -1622,12 +1524,10 @@ let ft$1 = class ft extends Z$1 {
|
|
|
1622
1524
|
}
|
|
1623
1525
|
getWorldMatrix() {
|
|
1624
1526
|
const t = [];
|
|
1625
|
-
for (let e2 = this; null != e2; e2 = e2.u)
|
|
1626
|
-
t.push(e2);
|
|
1527
|
+
for (let e2 = this; null != e2; e2 = e2.u) t.push(e2);
|
|
1627
1528
|
let e;
|
|
1628
1529
|
const r = t.pop().getMatrix();
|
|
1629
|
-
for (; e = t.pop(); )
|
|
1630
|
-
B$1(r, r, e.getMatrix());
|
|
1530
|
+
for (; e = t.pop(); ) B$1(r, r, e.getMatrix());
|
|
1631
1531
|
return r;
|
|
1632
1532
|
}
|
|
1633
1533
|
addChild(t) {
|
|
@@ -1673,8 +1573,7 @@ let ft$1 = class ft extends Z$1 {
|
|
|
1673
1573
|
}
|
|
1674
1574
|
traverse(t) {
|
|
1675
1575
|
t(this);
|
|
1676
|
-
for (const e of this.listChildren())
|
|
1677
|
-
e.traverse(t);
|
|
1576
|
+
for (const e of this.listChildren()) e.traverse(t);
|
|
1678
1577
|
return this;
|
|
1679
1578
|
}
|
|
1680
1579
|
};
|
|
@@ -1750,8 +1649,7 @@ function gt$1() {
|
|
|
1750
1649
|
return (gt$1 = Object.assign || function(t) {
|
|
1751
1650
|
for (var e = 1; e < arguments.length; e++) {
|
|
1752
1651
|
var r = arguments[e];
|
|
1753
|
-
for (var s in r)
|
|
1754
|
-
Object.prototype.hasOwnProperty.call(r, s) && (t[s] = r[s]);
|
|
1652
|
+
for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (t[s] = r[s]);
|
|
1755
1653
|
}
|
|
1756
1654
|
return t;
|
|
1757
1655
|
}).apply(this, arguments);
|
|
@@ -1764,8 +1662,7 @@ let pt$1 = class pt extends Z$1 {
|
|
|
1764
1662
|
return Object.assign(super.getDefaults(), { children: [] });
|
|
1765
1663
|
}
|
|
1766
1664
|
copy(t, e = q$1) {
|
|
1767
|
-
if (e === q$1)
|
|
1768
|
-
throw new Error("Scene cannot be copied.");
|
|
1665
|
+
if (e === q$1) throw new Error("Scene cannot be copied.");
|
|
1769
1666
|
return super.copy(t, e);
|
|
1770
1667
|
}
|
|
1771
1668
|
addChild(t) {
|
|
@@ -1778,8 +1675,7 @@ let pt$1 = class pt extends Z$1 {
|
|
|
1778
1675
|
return this.listRefs("children");
|
|
1779
1676
|
}
|
|
1780
1677
|
traverse(t) {
|
|
1781
|
-
for (const e of this.listChildren())
|
|
1782
|
-
e.traverse(t);
|
|
1678
|
+
for (const e of this.listChildren()) e.traverse(t);
|
|
1783
1679
|
return this;
|
|
1784
1680
|
}
|
|
1785
1681
|
};
|
|
@@ -1860,8 +1756,7 @@ let yt$1 = class yt extends Z$1 {
|
|
|
1860
1756
|
throw new Error("Root cannot be cloned.");
|
|
1861
1757
|
}
|
|
1862
1758
|
copy(t, e = q$1) {
|
|
1863
|
-
if (e === q$1)
|
|
1864
|
-
throw new Error("Root cannot be copied.");
|
|
1759
|
+
if (e === q$1) throw new Error("Root cannot be copied.");
|
|
1865
1760
|
this.set("asset", gt$1({}, t.get("asset"))), this.setName(t.getName()), this.setExtras(gt$1({}, t.getExtras())), this.setDefaultScene(t.getDefaultScene() ? e(t.getDefaultScene()) : null);
|
|
1866
1761
|
for (const r of t.listRefMapKeys("extensions")) {
|
|
1867
1762
|
const s = t.getExtension(r);
|
|
@@ -1953,31 +1848,26 @@ class vt {
|
|
|
1953
1848
|
}
|
|
1954
1849
|
const e = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
|
|
1955
1850
|
e.add(t.T), r.set(t.T, this.T);
|
|
1956
|
-
for (const s2 of t.v.listEdges())
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
s3 = t2.propertyType === h.TEXTURE_INFO ? t2 : new t2.constructor(this.v), r.set(t2, s3), e.add(t2);
|
|
1962
|
-
}
|
|
1851
|
+
for (const s2 of t.v.listEdges()) for (const t2 of [s2.getParent(), s2.getChild()]) {
|
|
1852
|
+
if (e.has(t2)) continue;
|
|
1853
|
+
let s3;
|
|
1854
|
+
s3 = t2.propertyType === h.TEXTURE_INFO ? t2 : new t2.constructor(this.v), r.set(t2, s3), e.add(t2);
|
|
1855
|
+
}
|
|
1963
1856
|
const s = (t2) => {
|
|
1964
1857
|
const e2 = r.get(t2);
|
|
1965
|
-
if (!e2)
|
|
1966
|
-
throw new Error("Could resolve property.");
|
|
1858
|
+
if (!e2) throw new Error("Could resolve property.");
|
|
1967
1859
|
return e2;
|
|
1968
1860
|
};
|
|
1969
1861
|
for (const t2 of e) {
|
|
1970
1862
|
const e2 = r.get(t2);
|
|
1971
|
-
if (!e2)
|
|
1972
|
-
throw new Error("Could resolve property.");
|
|
1863
|
+
if (!e2) throw new Error("Could resolve property.");
|
|
1973
1864
|
e2.propertyType !== h.TEXTURE_INFO && e2.copy(t2, s);
|
|
1974
1865
|
}
|
|
1975
1866
|
return this;
|
|
1976
1867
|
}
|
|
1977
1868
|
async transform(...t) {
|
|
1978
1869
|
const e = t.map((t2) => t2.name);
|
|
1979
|
-
for (const r of t)
|
|
1980
|
-
await r(this, { stack: e });
|
|
1870
|
+
for (const r of t) await r(this, { stack: e });
|
|
1981
1871
|
return this;
|
|
1982
1872
|
}
|
|
1983
1873
|
createExtension(t) {
|
|
@@ -2041,8 +1931,7 @@ let Tt$1 = class Tt {
|
|
|
2041
1931
|
this.document.getRoot().p(this);
|
|
2042
1932
|
const t = this.document.getGraph();
|
|
2043
1933
|
t.removeEventListener("node:create", this.S), t.removeEventListener("node:dispose", this.S);
|
|
2044
|
-
for (const t2 of this.properties)
|
|
2045
|
-
t2.dispose();
|
|
1934
|
+
for (const t2 of this.properties) t2.dispose();
|
|
2046
1935
|
}
|
|
2047
1936
|
static register() {
|
|
2048
1937
|
}
|
|
@@ -2079,8 +1968,7 @@ let bt$1 = class bt {
|
|
|
2079
1968
|
setTextureInfo(t, e) {
|
|
2080
1969
|
this.textureInfos.set(t, e), void 0 !== e.texCoord && t.setTexCoord(e.texCoord), void 0 !== e.extras && t.setExtras(e.extras);
|
|
2081
1970
|
const r = this.jsonDoc.json.textures[e.index];
|
|
2082
|
-
if (void 0 === r.sampler)
|
|
2083
|
-
return;
|
|
1971
|
+
if (void 0 === r.sampler) return;
|
|
2084
1972
|
const s = this.jsonDoc.json.samplers[r.sampler];
|
|
2085
1973
|
void 0 !== s.magFilter && t.setMagFilter(s.magFilter), void 0 !== s.minFilter && t.setMinFilter(s.minFilter), void 0 !== s.wrapS && t.setWrapS(s.wrapS), void 0 !== s.wrapT && t.setWrapT(s.wrapT);
|
|
2086
1974
|
}
|
|
@@ -2088,39 +1976,37 @@ let bt$1 = class bt {
|
|
|
2088
1976
|
const xt$1 = { logger: U$1.DEFAULT_INSTANCE, extensions: [], dependencies: {} };
|
|
2089
1977
|
function At$1(t, e) {
|
|
2090
1978
|
const r = e.bufferViews[t.bufferView], s = e.jsonDoc.json.bufferViews[t.bufferView], n = p[t.componentType], i = K$1.getElementSize(t.type), o = n.BYTES_PER_ELEMENT;
|
|
2091
|
-
if (void 0 !== s.byteStride && s.byteStride !== i * o)
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
return u;
|
|
2123
|
-
}(t, e);
|
|
1979
|
+
if (void 0 !== s.byteStride && s.byteStride !== i * o) return function(t2, e2) {
|
|
1980
|
+
const r2 = e2.bufferViews[t2.bufferView], s2 = e2.jsonDoc.json.bufferViews[t2.bufferView], n2 = p[t2.componentType], i2 = K$1.getElementSize(t2.type), o2 = n2.BYTES_PER_ELEMENT, a2 = t2.byteOffset || 0, u = new n2(t2.count * i2), c2 = new DataView(r2.buffer, r2.byteOffset, r2.byteLength), h2 = s2.byteStride;
|
|
1981
|
+
for (let e3 = 0; e3 < t2.count; e3++) for (let r3 = 0; r3 < i2; r3++) {
|
|
1982
|
+
const s3 = a2 + e3 * h2 + r3 * o2;
|
|
1983
|
+
let n3;
|
|
1984
|
+
switch (t2.componentType) {
|
|
1985
|
+
case K$1.ComponentType.FLOAT:
|
|
1986
|
+
n3 = c2.getFloat32(s3, true);
|
|
1987
|
+
break;
|
|
1988
|
+
case K$1.ComponentType.UNSIGNED_INT:
|
|
1989
|
+
n3 = c2.getUint32(s3, true);
|
|
1990
|
+
break;
|
|
1991
|
+
case K$1.ComponentType.UNSIGNED_SHORT:
|
|
1992
|
+
n3 = c2.getUint16(s3, true);
|
|
1993
|
+
break;
|
|
1994
|
+
case K$1.ComponentType.UNSIGNED_BYTE:
|
|
1995
|
+
n3 = c2.getUint8(s3);
|
|
1996
|
+
break;
|
|
1997
|
+
case K$1.ComponentType.SHORT:
|
|
1998
|
+
n3 = c2.getInt16(s3, true);
|
|
1999
|
+
break;
|
|
2000
|
+
case K$1.ComponentType.BYTE:
|
|
2001
|
+
n3 = c2.getInt8(s3);
|
|
2002
|
+
break;
|
|
2003
|
+
default:
|
|
2004
|
+
throw new Error(`Unexpected componentType "${t2.componentType}".`);
|
|
2005
|
+
}
|
|
2006
|
+
u[e3 * i2 + r3] = n3;
|
|
2007
|
+
}
|
|
2008
|
+
return u;
|
|
2009
|
+
}(t, e);
|
|
2124
2010
|
const a = r.byteOffset + (t.byteOffset || 0);
|
|
2125
2011
|
return new n(r.buffer.slice(a, a + t.count * i * o));
|
|
2126
2012
|
}
|
|
@@ -2154,8 +2040,7 @@ let Mt$1 = class Mt {
|
|
|
2154
2040
|
return e.type = t.getType(), e.componentType = t.getComponentType(), e.count = t.getCount(), this.O.getGraph().listParentEdges(t).some((t2) => "attributes" === t2.getName() && "POSITION" === t2.getAttributes().key || "input" === t2.getName()) && (e.max = t.getMax([]).map(Math.fround), e.min = t.getMin([]).map(Math.fround)), t.getNormalized() && (e.normalized = t.getNormalized()), e;
|
|
2155
2041
|
}
|
|
2156
2042
|
createImageData(t, e, r) {
|
|
2157
|
-
if (this.options.format === g.GLB)
|
|
2158
|
-
this.imageBufferViews.push(e), t.bufferView = this.jsonDoc.json.bufferViews.length, this.jsonDoc.json.bufferViews.push({ buffer: 0, byteOffset: -1, byteLength: e.byteLength });
|
|
2043
|
+
if (this.options.format === g.GLB) this.imageBufferViews.push(e), t.bufferView = this.jsonDoc.json.bufferViews.length, this.jsonDoc.json.bufferViews.push({ buffer: 0, byteOffset: -1, byteLength: e.byteLength });
|
|
2159
2044
|
else {
|
|
2160
2045
|
const s = I.mimeTypeToExtension(r.getMimeType());
|
|
2161
2046
|
t.uri = this.imageURIGenerator.createURI(r, s), this.jsonDoc.resources[t.uri] = e;
|
|
@@ -2163,28 +2048,23 @@ let Mt$1 = class Mt {
|
|
|
2163
2048
|
}
|
|
2164
2049
|
getAccessorUsage(t) {
|
|
2165
2050
|
const e = this.C.get(t);
|
|
2166
|
-
if (e)
|
|
2167
|
-
|
|
2168
|
-
if (t.getSparse())
|
|
2169
|
-
return l.SPARSE;
|
|
2051
|
+
if (e) return e;
|
|
2052
|
+
if (t.getSparse()) return l.SPARSE;
|
|
2170
2053
|
for (const e2 of this.O.getGraph().listParentEdges(t)) {
|
|
2171
2054
|
const { usage: t2 } = e2.getAttributes();
|
|
2172
|
-
if (t2)
|
|
2173
|
-
return t2;
|
|
2055
|
+
if (t2) return t2;
|
|
2174
2056
|
e2.getParent().propertyType !== h.ROOT && this.logger.warn(`Missing attribute ".usage" on edge, "${e2.getName()}".`);
|
|
2175
2057
|
}
|
|
2176
2058
|
return l.OTHER;
|
|
2177
2059
|
}
|
|
2178
2060
|
addAccessorToUsageGroup(t, e) {
|
|
2179
2061
|
const r = this.C.get(t);
|
|
2180
|
-
if (r && r !== e)
|
|
2181
|
-
throw new Error(`Accessor with usage "${r}" cannot be reused as "${e}".`);
|
|
2062
|
+
if (r && r !== e) throw new Error(`Accessor with usage "${r}" cannot be reused as "${e}".`);
|
|
2182
2063
|
return this.C.set(t, e), this;
|
|
2183
2064
|
}
|
|
2184
2065
|
listAccessorUsageGroups() {
|
|
2185
2066
|
const t = {};
|
|
2186
|
-
for (const [e, r] of Array.from(this.C.entries()))
|
|
2187
|
-
t[r] = t[r] || [], t[r].push(e);
|
|
2067
|
+
for (const [e, r] of Array.from(this.C.entries())) t[r] = t[r] || [], t[r].push(e);
|
|
2188
2068
|
return t;
|
|
2189
2069
|
}
|
|
2190
2070
|
};
|
|
@@ -2194,8 +2074,7 @@ let St$1 = class St {
|
|
|
2194
2074
|
this.multiple = void 0, this.basename = void 0, this.counter = {}, this.multiple = t, this.basename = e;
|
|
2195
2075
|
}
|
|
2196
2076
|
createURI(t, e) {
|
|
2197
|
-
if (t.getURI())
|
|
2198
|
-
return t.getURI();
|
|
2077
|
+
if (t.getURI()) return t.getURI();
|
|
2199
2078
|
if (this.multiple) {
|
|
2200
2079
|
const r = this.basename(t);
|
|
2201
2080
|
return this.counter[r] = this.counter[r] || 1, `${r}_${this.counter[r]++}.${e}`;
|
|
@@ -2216,8 +2095,7 @@ let Ft$1 = class Ft {
|
|
|
2216
2095
|
return this.M = t, this;
|
|
2217
2096
|
}
|
|
2218
2097
|
registerExtensions(t) {
|
|
2219
|
-
for (const e of t)
|
|
2220
|
-
this.h.add(e), e.register();
|
|
2098
|
+
for (const e of t) this.h.add(e), e.register();
|
|
2221
2099
|
return this;
|
|
2222
2100
|
}
|
|
2223
2101
|
registerDependencies(t) {
|
|
@@ -2243,12 +2121,10 @@ let Ft$1 = class Ft {
|
|
|
2243
2121
|
const i = new bt$1(t2), o = s.asset, a = n.getRoot().getAsset();
|
|
2244
2122
|
o.copyright && (a.copyright = o.copyright), o.extras && (a.extras = o.extras), void 0 !== s.extras && n.getRoot().setExtras(gt$1({}, s.extras));
|
|
2245
2123
|
const u = s.extensionsUsed || [], c2 = s.extensionsRequired || [];
|
|
2246
|
-
for (const t3 of r.extensions)
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
e2.install(t4, r.dependencies[t4]);
|
|
2251
|
-
}
|
|
2124
|
+
for (const t3 of r.extensions) if (u.includes(t3.EXTENSION_NAME)) {
|
|
2125
|
+
const e2 = n.createExtension(t3).setRequired(c2.includes(t3.EXTENSION_NAME));
|
|
2126
|
+
for (const t4 of e2.readDependencies) e2.install(t4, r.dependencies[t4]);
|
|
2127
|
+
}
|
|
2252
2128
|
const f2 = s.buffers || [];
|
|
2253
2129
|
n.getRoot().listExtensionsUsed().filter((t3) => t3.prereadTypes.includes(h.BUFFER)).forEach((t3) => t3.preread(i, h.BUFFER)), i.buffers = f2.map((t3) => {
|
|
2254
2130
|
const e2 = n.createBuffer(t3.name);
|
|
@@ -2271,10 +2147,8 @@ let Ft$1 = class Ft {
|
|
|
2271
2147
|
if (e2.extras && r2.setExtras(e2.extras), void 0 !== e2.bufferView) {
|
|
2272
2148
|
const n2 = s.bufferViews[e2.bufferView], i2 = t2.json.buffers[n2.buffer], o2 = n2.byteOffset || 0, a2 = (i2.uri ? t2.resources[i2.uri] : t2.resources["@glb.bin"]).slice(o2, o2 + n2.byteLength);
|
|
2273
2149
|
r2.setImage(a2);
|
|
2274
|
-
} else
|
|
2275
|
-
|
|
2276
|
-
if (void 0 !== e2.mimeType)
|
|
2277
|
-
r2.setMimeType(e2.mimeType);
|
|
2150
|
+
} else void 0 !== e2.uri && (r2.setImage(t2.resources[e2.uri]), 0 !== e2.uri.indexOf("__") && r2.setURI(e2.uri));
|
|
2151
|
+
if (void 0 !== e2.mimeType) r2.setMimeType(e2.mimeType);
|
|
2278
2152
|
else if (e2.uri) {
|
|
2279
2153
|
const t3 = N$1.extension(e2.uri);
|
|
2280
2154
|
r2.setMimeType(I.extensionToMimeType(t3));
|
|
@@ -2312,14 +2186,12 @@ let Ft$1 = class Ft {
|
|
|
2312
2186
|
return t3.extras && e2.setExtras(t3.extras), void 0 !== t3.weights && e2.setWeights(t3.weights), (t3.primitives || []).forEach((r2) => {
|
|
2313
2187
|
const s2 = n.createPrimitive();
|
|
2314
2188
|
r2.extras && s2.setExtras(r2.extras), void 0 !== r2.material && s2.setMaterial(i.materials[r2.material]), void 0 !== r2.mode && s2.setMode(r2.mode);
|
|
2315
|
-
for (const [t4, e3] of Object.entries(r2.attributes || {}))
|
|
2316
|
-
s2.setAttribute(t4, i.accessors[e3]);
|
|
2189
|
+
for (const [t4, e3] of Object.entries(r2.attributes || {})) s2.setAttribute(t4, i.accessors[e3]);
|
|
2317
2190
|
void 0 !== r2.indices && s2.setIndices(i.accessors[r2.indices]);
|
|
2318
2191
|
const o2 = t3.extras && t3.extras.targetNames || [];
|
|
2319
2192
|
(r2.targets || []).forEach((t4, e3) => {
|
|
2320
2193
|
const r3 = o2[e3] || e3.toString(), a2 = n.createPrimitiveTarget(r3);
|
|
2321
|
-
for (const [e4, r4] of Object.entries(t4))
|
|
2322
|
-
a2.setAttribute(e4, i.accessors[r4]);
|
|
2194
|
+
for (const [e4, r4] of Object.entries(t4)) a2.setAttribute(e4, i.accessors[r4]);
|
|
2323
2195
|
s2.addTarget(a2);
|
|
2324
2196
|
}), e2.addPrimitive(s2);
|
|
2325
2197
|
}), e2;
|
|
@@ -2345,8 +2217,7 @@ let Ft$1 = class Ft {
|
|
|
2345
2217
|
}), i.skins = (s.skins || []).map((t3) => {
|
|
2346
2218
|
const e2 = n.createSkin(t3.name);
|
|
2347
2219
|
t3.extras && e2.setExtras(t3.extras), void 0 !== t3.inverseBindMatrices && e2.setInverseBindMatrices(i.accessors[t3.inverseBindMatrices]), void 0 !== t3.skeleton && e2.setSkeleton(i.nodes[t3.skeleton]);
|
|
2348
|
-
for (const r2 of t3.joints)
|
|
2349
|
-
e2.addJoint(i.nodes[r2]);
|
|
2220
|
+
for (const r2 of t3.joints) e2.addJoint(i.nodes[r2]);
|
|
2350
2221
|
return e2;
|
|
2351
2222
|
}), w2.map((t3, e2) => {
|
|
2352
2223
|
const r2 = i.nodes[e2];
|
|
@@ -2374,28 +2245,20 @@ let Ft$1 = class Ft {
|
|
|
2374
2245
|
let n3;
|
|
2375
2246
|
n3 = void 0 !== t4.bufferView ? At$1(t4, e3) : new r3(t4.count * s3);
|
|
2376
2247
|
const i2 = t4.sparse;
|
|
2377
|
-
if (!i2)
|
|
2378
|
-
return n3;
|
|
2248
|
+
if (!i2) return n3;
|
|
2379
2249
|
const o2 = i2.count, a2 = gt$1({}, t4, i2.indices, { count: o2, type: "SCALAR" }), u2 = gt$1({}, t4, i2.values, { count: o2 }), c3 = At$1(a2, e3), h2 = At$1(u2, e3);
|
|
2380
|
-
for (let t5 = 0; t5 < a2.count; t5++)
|
|
2381
|
-
for (let e4 = 0; e4 < s3; e4++)
|
|
2382
|
-
n3[c3[t5] * s3 + e4] = h2[t5 * s3 + e4];
|
|
2250
|
+
for (let t5 = 0; t5 < a2.count; t5++) for (let e4 = 0; e4 < s3; e4++) n3[c3[t5] * s3 + e4] = h2[t5 * s3 + e4];
|
|
2383
2251
|
return n3;
|
|
2384
2252
|
}(t3, i));
|
|
2385
2253
|
}), n;
|
|
2386
2254
|
}
|
|
2387
2255
|
static validate(t2, e) {
|
|
2388
2256
|
const r = t2.json;
|
|
2389
|
-
if ("2.0" !== r.asset.version)
|
|
2390
|
-
throw new Error(`Unsupported glTF version, "${r.asset.version}".`);
|
|
2257
|
+
if ("2.0" !== r.asset.version) throw new Error(`Unsupported glTF version, "${r.asset.version}".`);
|
|
2391
2258
|
if (r.extensionsRequired) {
|
|
2392
|
-
for (const t3 of r.extensionsRequired)
|
|
2393
|
-
if (!e.extensions.find((e2) => e2.EXTENSION_NAME === t3))
|
|
2394
|
-
throw new Error(`Missing required extension, "${t3}".`);
|
|
2259
|
+
for (const t3 of r.extensionsRequired) if (!e.extensions.find((e2) => e2.EXTENSION_NAME === t3)) throw new Error(`Missing required extension, "${t3}".`);
|
|
2395
2260
|
}
|
|
2396
|
-
if (r.extensionsUsed)
|
|
2397
|
-
for (const t3 of r.extensionsUsed)
|
|
2398
|
-
e.extensions.find((e2) => e2.EXTENSION_NAME === t3) || e.logger.warn(`Missing optional extension, "${t3}".`);
|
|
2261
|
+
if (r.extensionsUsed) for (const t3 of r.extensionsUsed) e.extensions.find((e2) => e2.EXTENSION_NAME === t3) || e.logger.warn(`Missing optional extension, "${t3}".`);
|
|
2399
2262
|
}
|
|
2400
2263
|
}).read(t, { extensions: Array.from(this.h), dependencies: this.F, logger: this.M });
|
|
2401
2264
|
}
|
|
@@ -2405,27 +2268,22 @@ let Ft$1 = class Ft {
|
|
|
2405
2268
|
const r = e.json;
|
|
2406
2269
|
if (r.buffers && r.buffers.some((t2) => function(t3, e2) {
|
|
2407
2270
|
return void 0 !== e2.uri && !(e2.uri in t3.resources);
|
|
2408
|
-
}(e, t2)))
|
|
2409
|
-
throw new Error("Cannot resolve external buffers with binaryToJSON().");
|
|
2271
|
+
}(e, t2))) throw new Error("Cannot resolve external buffers with binaryToJSON().");
|
|
2410
2272
|
if (r.images && r.images.some((t2) => function(t3, e2) {
|
|
2411
2273
|
return void 0 !== e2.uri && !(e2.uri in t3.resources) && void 0 === e2.bufferView;
|
|
2412
|
-
}(e, t2)))
|
|
2413
|
-
throw new Error("Cannot resolve external images with binaryToJSON().");
|
|
2274
|
+
}(e, t2))) throw new Error("Cannot resolve external images with binaryToJSON().");
|
|
2414
2275
|
return e;
|
|
2415
2276
|
}
|
|
2416
2277
|
async readBinary(t) {
|
|
2417
2278
|
return this.readJSON(await this.binaryToJSON(E.assertView(t)));
|
|
2418
2279
|
}
|
|
2419
2280
|
async writeJSON(t, e = {}) {
|
|
2420
|
-
if (e.format === g.GLB && t.getRoot().listBuffers().length > 1)
|
|
2421
|
-
throw new Error("GLB must have 0–1 buffers.");
|
|
2281
|
+
if (e.format === g.GLB && t.getRoot().listBuffers().length > 1) throw new Error("GLB must have 0–1 buffers.");
|
|
2422
2282
|
return (class {
|
|
2423
2283
|
static write(t2, e2) {
|
|
2424
2284
|
const r = t2.getRoot(), s = { asset: gt$1({ generator: "glTF-Transform v3.2.1" }, r.getAsset()), extras: gt$1({}, r.getExtras()) }, n = { json: s, resources: {} }, i = new Mt$1(t2, n, e2), o = e2.logger || U$1.DEFAULT_INSTANCE, a = new Set(e2.extensions.map((t3) => t3.EXTENSION_NAME)), u = t2.getRoot().listExtensionsUsed().filter((t3) => a.has(t3.extensionName)), c2 = t2.getRoot().listExtensionsRequired().filter((t3) => a.has(t3.extensionName));
|
|
2425
2285
|
u.length < t2.getRoot().listExtensionsUsed().length && o.warn("Some extensions were not registered for I/O, and will not be written.");
|
|
2426
|
-
for (const t3 of u)
|
|
2427
|
-
for (const r2 of t3.writeDependencies)
|
|
2428
|
-
t3.install(r2, e2.dependencies[r2]);
|
|
2286
|
+
for (const t3 of u) for (const r2 of t3.writeDependencies) t3.install(r2, e2.dependencies[r2]);
|
|
2429
2287
|
function l2(t3, e3, r2, n2) {
|
|
2430
2288
|
const o2 = [];
|
|
2431
2289
|
let a2 = 0;
|
|
@@ -2491,15 +2349,12 @@ let Ft$1 = class Ft {
|
|
|
2491
2349
|
const t4 = i.createAccessorDef(e4);
|
|
2492
2350
|
s.accessors.push(t4), i.accessorIndexMap.set(e4, s.accessors.length - 1);
|
|
2493
2351
|
const r3 = [], n3 = [], a3 = [], h3 = new Array(e4.getElementSize()).fill(0);
|
|
2494
|
-
for (let t5 = 0, s2 = e4.getCount(); t5 < s2; t5++)
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
n3.push(a3[t6]);
|
|
2499
|
-
}
|
|
2352
|
+
for (let t5 = 0, s2 = e4.getCount(); t5 < s2; t5++) if (e4.getElement(t5, a3), !P$1.eq(a3, h3, 0)) {
|
|
2353
|
+
c3 = Math.max(t5, c3), r3.push(t5);
|
|
2354
|
+
for (let t6 = 0; t6 < a3.length; t6++) n3.push(a3[t6]);
|
|
2355
|
+
}
|
|
2500
2356
|
const f3 = r3.length, l4 = { accessorDef: t4, count: f3 };
|
|
2501
|
-
if (u2.set(e4, l4), 0 === f3)
|
|
2502
|
-
continue;
|
|
2357
|
+
if (u2.set(e4, l4), 0 === f3) continue;
|
|
2503
2358
|
if (f3 > e4.getCount() / 3) {
|
|
2504
2359
|
const t5 = (100 * r3.length / e4.getCount()).toFixed(1);
|
|
2505
2360
|
o.warn(`Sparse accessor with many non-zero elements (${t5}%) may increase file size.`);
|
|
@@ -2507,13 +2362,11 @@ let Ft$1 = class Ft {
|
|
|
2507
2362
|
const d4 = p[e4.getComponentType()];
|
|
2508
2363
|
l4.indices = r3, l4.values = new d4(n3);
|
|
2509
2364
|
}
|
|
2510
|
-
if (!Number.isFinite(c3))
|
|
2511
|
-
return { buffers: n2, byteLength: a2 };
|
|
2365
|
+
if (!Number.isFinite(c3)) return { buffers: n2, byteLength: a2 };
|
|
2512
2366
|
const h2 = c3 < 255 ? Uint8Array : c3 < 65535 ? Uint16Array : Uint32Array, f2 = c3 < 255 ? Ot$1 : c3 < 65535 ? Nt$1 : Rt$1, l3 = { buffer: e3, byteOffset: r2 + a2, byteLength: 0 };
|
|
2513
2367
|
for (const e4 of t3) {
|
|
2514
2368
|
const t4 = u2.get(e4);
|
|
2515
|
-
if (0 === t4.count)
|
|
2516
|
-
continue;
|
|
2369
|
+
if (0 === t4.count) continue;
|
|
2517
2370
|
t4.indicesByteOffset = l3.byteLength;
|
|
2518
2371
|
const r3 = E.pad(E.toView(new h2(t4.indices)));
|
|
2519
2372
|
n2.push(r3), a2 += r3.byteLength, l3.byteLength += r3.byteLength;
|
|
@@ -2522,8 +2375,7 @@ let Ft$1 = class Ft {
|
|
|
2522
2375
|
const d3 = s.bufferViews.length - 1, g2 = { buffer: e3, byteOffset: r2 + a2, byteLength: 0 };
|
|
2523
2376
|
for (const e4 of t3) {
|
|
2524
2377
|
const t4 = u2.get(e4);
|
|
2525
|
-
if (0 === t4.count)
|
|
2526
|
-
continue;
|
|
2378
|
+
if (0 === t4.count) continue;
|
|
2527
2379
|
t4.valuesByteOffset = g2.byteLength;
|
|
2528
2380
|
const r3 = E.pad(E.toView(t4.values));
|
|
2529
2381
|
n2.push(r3), a2 += r3.byteLength, g2.byteLength += r3.byteLength;
|
|
@@ -2538,8 +2390,7 @@ let Ft$1 = class Ft {
|
|
|
2538
2390
|
}
|
|
2539
2391
|
const w2 = /* @__PURE__ */ new Map();
|
|
2540
2392
|
for (const e3 of t2.getGraph().listEdges()) {
|
|
2541
|
-
if (e3.getParent() === r)
|
|
2542
|
-
continue;
|
|
2393
|
+
if (e3.getParent() === r) continue;
|
|
2543
2394
|
const t3 = e3.getChild();
|
|
2544
2395
|
if (t3 instanceof K$1) {
|
|
2545
2396
|
const r2 = w2.get(t3) || [];
|
|
@@ -2553,50 +2404,40 @@ let Ft$1 = class Ft {
|
|
|
2553
2404
|
return s2 && i.createImageData(r2, s2, t3), i.imageIndexMap.set(t3, e3), r2;
|
|
2554
2405
|
}), u.filter((t3) => t3.prewriteTypes.includes(h.ACCESSOR)).forEach((t3) => t3.prewrite(i, h.ACCESSOR)), r.listAccessors().forEach((t3) => {
|
|
2555
2406
|
const e3 = i.accessorUsageGroupedByParent, r2 = i.accessorParents;
|
|
2556
|
-
if (i.accessorIndexMap.has(t3))
|
|
2557
|
-
return;
|
|
2407
|
+
if (i.accessorIndexMap.has(t3)) return;
|
|
2558
2408
|
const s2 = w2.get(t3) || [], n2 = i.getAccessorUsage(t3);
|
|
2559
2409
|
if (i.addAccessorToUsageGroup(t3, n2), e3.has(n2)) {
|
|
2560
2410
|
const e4 = s2[0].getParent(), n3 = r2.get(e4) || /* @__PURE__ */ new Set();
|
|
2561
2411
|
n3.add(t3), r2.set(e4, n3);
|
|
2562
2412
|
}
|
|
2563
|
-
}), u.filter((t3) => t3.prewriteTypes.includes(h.BUFFER)).forEach((t3) => t3.prewrite(i, h.BUFFER)), (r.listAccessors().length > 0 || r.listTextures().length > 0 || i.otherBufferViews.size > 0) && 0 === r.listBuffers().length)
|
|
2564
|
-
throw new Error("Buffer required for Document resources, but none was found.");
|
|
2413
|
+
}), u.filter((t3) => t3.prewriteTypes.includes(h.BUFFER)).forEach((t3) => t3.prewrite(i, h.BUFFER)), (r.listAccessors().length > 0 || r.listTextures().length > 0 || i.otherBufferViews.size > 0) && 0 === r.listBuffers().length) throw new Error("Buffer required for Document resources, but none was found.");
|
|
2565
2414
|
s.buffers = [], r.listBuffers().forEach((t3, r2) => {
|
|
2566
2415
|
const o2 = i.createPropertyDef(t3), a2 = i.accessorUsageGroupedByParent, u2 = i.accessorParents, c3 = t3.listParents().filter((t4) => t4 instanceof K$1), h2 = new Set(c3), p2 = [], w3 = s.buffers.length;
|
|
2567
2416
|
let y3 = 0;
|
|
2568
2417
|
const v2 = i.listAccessorUsageGroups();
|
|
2569
|
-
for (const t4 in v2)
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
} else
|
|
2578
|
-
for (const t5 of s2) {
|
|
2579
|
-
const e3 = d2([t5], w3, y3);
|
|
2580
|
-
y3 += e3.byteLength, p2.push(...e3.buffers);
|
|
2581
|
-
}
|
|
2582
|
-
}
|
|
2583
|
-
else {
|
|
2584
|
-
const e3 = v2[t4].filter((t5) => h2.has(t5));
|
|
2585
|
-
if (!e3.length)
|
|
2586
|
-
continue;
|
|
2587
|
-
const r3 = t4 === It$1.ELEMENT_ARRAY_BUFFER ? Mt$1.BufferViewTarget.ELEMENT_ARRAY_BUFFER : void 0, s2 = t4 === It$1.SPARSE ? m2(e3, w3, y3) : l2(e3, w3, y3, r3);
|
|
2588
|
-
y3 += s2.byteLength, p2.push(...s2.buffers);
|
|
2418
|
+
for (const t4 in v2) if (a2.has(t4)) for (const r3 of Array.from(u2.values())) {
|
|
2419
|
+
const s2 = Array.from(r3).filter((t5) => h2.has(t5)).filter((e3) => i.getAccessorUsage(e3) === t4);
|
|
2420
|
+
if (s2.length) if (t4 !== It$1.ARRAY_BUFFER || e2.vertexLayout === f.INTERLEAVED) {
|
|
2421
|
+
const e3 = t4 === It$1.ARRAY_BUFFER ? d2(s2, w3, y3) : l2(s2, w3, y3);
|
|
2422
|
+
y3 += e3.byteLength, p2.push(...e3.buffers);
|
|
2423
|
+
} else for (const t5 of s2) {
|
|
2424
|
+
const e3 = d2([t5], w3, y3);
|
|
2425
|
+
y3 += e3.byteLength, p2.push(...e3.buffers);
|
|
2589
2426
|
}
|
|
2427
|
+
}
|
|
2428
|
+
else {
|
|
2429
|
+
const e3 = v2[t4].filter((t5) => h2.has(t5));
|
|
2430
|
+
if (!e3.length) continue;
|
|
2431
|
+
const r3 = t4 === It$1.ELEMENT_ARRAY_BUFFER ? Mt$1.BufferViewTarget.ELEMENT_ARRAY_BUFFER : void 0, s2 = t4 === It$1.SPARSE ? m2(e3, w3, y3) : l2(e3, w3, y3, r3);
|
|
2432
|
+
y3 += s2.byteLength, p2.push(...s2.buffers);
|
|
2433
|
+
}
|
|
2590
2434
|
if (i.imageBufferViews.length && 0 === r2) {
|
|
2591
|
-
for (let t4 = 0; t4 < i.imageBufferViews.length; t4++)
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
}
|
|
2435
|
+
for (let t4 = 0; t4 < i.imageBufferViews.length; t4++) if (s.bufferViews[s.images[t4].bufferView].byteOffset = y3, y3 += i.imageBufferViews[t4].byteLength, p2.push(i.imageBufferViews[t4]), y3 % 8) {
|
|
2436
|
+
const t5 = 8 - y3 % 8;
|
|
2437
|
+
y3 += t5, p2.push(new Uint8Array(t5));
|
|
2438
|
+
}
|
|
2596
2439
|
}
|
|
2597
|
-
if (i.otherBufferViews.has(t3))
|
|
2598
|
-
for (const e3 of i.otherBufferViews.get(t3))
|
|
2599
|
-
s.bufferViews.push({ buffer: w3, byteOffset: y3, byteLength: e3.byteLength }), i.otherBufferViewsIndexMap.set(e3, s.bufferViews.length - 1), y3 += e3.byteLength, p2.push(e3);
|
|
2440
|
+
if (i.otherBufferViews.has(t3)) for (const e3 of i.otherBufferViews.get(t3)) s.bufferViews.push({ buffer: w3, byteOffset: y3, byteLength: e3.byteLength }), i.otherBufferViewsIndexMap.set(e3, s.bufferViews.length - 1), y3 += e3.byteLength, p2.push(e3);
|
|
2600
2441
|
if (y3) {
|
|
2601
2442
|
let r3;
|
|
2602
2443
|
e2.format === g.GLB ? r3 = "@glb.bin" : (r3 = i.bufferURIGenerator.createURI(t3, "bin"), o2.uri = r3), o2.byteLength = y3, n.resources[r3] = E.concat(p2);
|
|
@@ -2635,12 +2476,10 @@ let Ft$1 = class Ft {
|
|
|
2635
2476
|
r3 && (e4.material = i.materialIndexMap.get(r3)), Object.keys(t4.getExtras()).length && (e4.extras = t4.getExtras());
|
|
2636
2477
|
const n2 = t4.getIndices();
|
|
2637
2478
|
n2 && (e4.indices = i.accessorIndexMap.get(n2));
|
|
2638
|
-
for (const r4 of t4.listSemantics())
|
|
2639
|
-
e4.attributes[r4] = i.accessorIndexMap.get(t4.getAttribute(r4));
|
|
2479
|
+
for (const r4 of t4.listSemantics()) e4.attributes[r4] = i.accessorIndexMap.get(t4.getAttribute(r4));
|
|
2640
2480
|
for (const r4 of t4.listTargets()) {
|
|
2641
2481
|
const t5 = {};
|
|
2642
|
-
for (const e5 of r4.listSemantics())
|
|
2643
|
-
t5[e5] = i.accessorIndexMap.get(r4.getAttribute(e5));
|
|
2482
|
+
for (const e5 of r4.listSemantics()) t5[e5] = i.accessorIndexMap.get(r4.getAttribute(e5));
|
|
2644
2483
|
e4.targets = e4.targets || [], e4.targets.push(t5);
|
|
2645
2484
|
}
|
|
2646
2485
|
return t4.listTargets().length && !s2 && (s2 = t4.listTargets().map((t5) => t5.getName())), e4;
|
|
@@ -2651,8 +2490,7 @@ let Ft$1 = class Ft {
|
|
|
2651
2490
|
r2.perspective = { znear: t3.getZNear(), zfar: t3.getZFar(), yfov: t3.getYFov() };
|
|
2652
2491
|
const e4 = t3.getAspectRatio();
|
|
2653
2492
|
null !== e4 && (r2.perspective.aspectRatio = e4);
|
|
2654
|
-
} else
|
|
2655
|
-
r2.orthographic = { znear: t3.getZNear(), zfar: t3.getZFar(), xmag: t3.getXMag(), ymag: t3.getYMag() };
|
|
2493
|
+
} else r2.orthographic = { znear: t3.getZNear(), zfar: t3.getZFar(), xmag: t3.getXMag(), ymag: t3.getYMag() };
|
|
2656
2494
|
return i.cameraIndexMap.set(t3, e3), r2;
|
|
2657
2495
|
}), s.nodes = r.listNodes().map((t3, e3) => {
|
|
2658
2496
|
const r2 = i.createPropertyDef(t3);
|
|
@@ -2689,8 +2527,7 @@ let Ft$1 = class Ft {
|
|
|
2689
2527
|
const s2 = t3[r2];
|
|
2690
2528
|
(Array.isArray(s2) && 0 === s2.length || null === s2 || "" === s2 || s2 && "object" == typeof s2 && 0 === Object.keys(s2).length) && e3.push(r2);
|
|
2691
2529
|
}
|
|
2692
|
-
for (const r2 of e3)
|
|
2693
|
-
delete t3[r2];
|
|
2530
|
+
for (const r2 of e3) delete t3[r2];
|
|
2694
2531
|
}(s), n;
|
|
2695
2532
|
}
|
|
2696
2533
|
}).write(t, { format: e.format || g.GLTF, basename: e.basename || "", logger: this.M, vertexLayout: this.U, dependencies: gt$1({}, this.F), extensions: Array.from(this.h) });
|
|
@@ -2699,8 +2536,7 @@ let Ft$1 = class Ft {
|
|
|
2699
2536
|
const { json: e, resources: r } = await this.writeJSON(t, { format: g.GLB }), s = new Uint32Array([1179937895, 2, 12]), n = JSON.stringify(e), i = E.pad(E.encodeText(n), 32), o = E.toView(new Uint32Array([i.byteLength, 1313821514])), a = E.concat([o, i]);
|
|
2700
2537
|
s[s.length - 1] += a.byteLength;
|
|
2701
2538
|
const u = Object.values(r)[0];
|
|
2702
|
-
if (!u || !u.byteLength)
|
|
2703
|
-
return E.concat([E.toView(s), a]);
|
|
2539
|
+
if (!u || !u.byteLength) return E.concat([E.toView(s), a]);
|
|
2704
2540
|
const c2 = E.pad(u, 0), h2 = E.toView(new Uint32Array([c2.byteLength, 5130562])), f2 = E.concat([h2, c2]);
|
|
2705
2541
|
return s[s.length - 1] += f2.byteLength, E.concat([E.toView(s), a, f2]);
|
|
2706
2542
|
}
|
|
@@ -2708,8 +2544,7 @@ let Ft$1 = class Ft {
|
|
|
2708
2544
|
var r = this;
|
|
2709
2545
|
const s = [...t.json.images || [], ...t.json.buffers || []].map(async function(s2) {
|
|
2710
2546
|
const n = s2.uri;
|
|
2711
|
-
if (!n || n.match(/data:/))
|
|
2712
|
-
return Promise.resolve();
|
|
2547
|
+
if (!n || n.match(/data:/)) return Promise.resolve();
|
|
2713
2548
|
t.resources[n] = await r.readURI(r.resolve(e, n), "view"), r.lastReadBytes += t.resources[n].byteLength;
|
|
2714
2549
|
});
|
|
2715
2550
|
await Promise.all(s);
|
|
@@ -2717,8 +2552,7 @@ let Ft$1 = class Ft {
|
|
|
2717
2552
|
j(t) {
|
|
2718
2553
|
function e(e2) {
|
|
2719
2554
|
if (e2.uri) {
|
|
2720
|
-
if (e2.uri in t.resources)
|
|
2721
|
-
E.assertView(t.resources[e2.uri]);
|
|
2555
|
+
if (e2.uri in t.resources) E.assertView(t.resources[e2.uri]);
|
|
2722
2556
|
else if (e2.uri.match(/data:/)) {
|
|
2723
2557
|
const r = `__${V$1()}.${N$1.extension(e2.uri)}`;
|
|
2724
2558
|
t.resources[r] = E.createBufferFromDataURI(e2.uri), e2.uri = r;
|
|
@@ -2726,8 +2560,7 @@ let Ft$1 = class Ft {
|
|
|
2726
2560
|
}
|
|
2727
2561
|
}
|
|
2728
2562
|
(t.json.images || []).forEach((t2) => {
|
|
2729
|
-
if (void 0 === t2.bufferView && void 0 === t2.uri)
|
|
2730
|
-
throw new Error("Missing resource URI or buffer view.");
|
|
2563
|
+
if (void 0 === t2.bufferView && void 0 === t2.uri) throw new Error("Missing resource URI or buffer view.");
|
|
2731
2564
|
e(t2);
|
|
2732
2565
|
}), (t.json.buffers || []).forEach(e);
|
|
2733
2566
|
}
|
|
@@ -2736,23 +2569,18 @@ let Ft$1 = class Ft {
|
|
|
2736
2569
|
return t = { json: gt$1({}, t.json), resources: gt$1({}, t.resources) }, e && (t.json.images = e.map((t2) => gt$1({}, t2))), r && (t.json.buffers = r.map((t2) => gt$1({}, t2))), t;
|
|
2737
2570
|
}
|
|
2738
2571
|
P(t) {
|
|
2739
|
-
if (!Ut(t))
|
|
2740
|
-
throw new Error("Invalid glTF 2.0 binary.");
|
|
2572
|
+
if (!Ut(t)) throw new Error("Invalid glTF 2.0 binary.");
|
|
2741
2573
|
const e = new Uint32Array(t.buffer, t.byteOffset + 12, 2);
|
|
2742
|
-
if (e[1] !== Ct$1.JSON)
|
|
2743
|
-
throw new Error("Missing required GLB JSON chunk.");
|
|
2574
|
+
if (e[1] !== Ct$1.JSON) throw new Error("Missing required GLB JSON chunk.");
|
|
2744
2575
|
const r = e[0], s = E.decodeText(E.toView(t, 20, r)), n = JSON.parse(s), i = 20 + r;
|
|
2745
|
-
if (t.byteLength <= i)
|
|
2746
|
-
return { json: n, resources: {} };
|
|
2576
|
+
if (t.byteLength <= i) return { json: n, resources: {} };
|
|
2747
2577
|
const o = new Uint32Array(t.buffer, t.byteOffset + i, 2);
|
|
2748
|
-
if (o[1] !== Ct$1.BIN)
|
|
2749
|
-
throw new Error("Expected GLB BIN in second chunk.");
|
|
2578
|
+
if (o[1] !== Ct$1.BIN) throw new Error("Expected GLB BIN in second chunk.");
|
|
2750
2579
|
return { json: n, resources: { "@glb.bin": E.toView(t, i + 8, o[0]) } };
|
|
2751
2580
|
}
|
|
2752
2581
|
};
|
|
2753
2582
|
function Ut(t) {
|
|
2754
|
-
if (t.byteLength < 3 * Uint32Array.BYTES_PER_ELEMENT)
|
|
2755
|
-
return false;
|
|
2583
|
+
if (t.byteLength < 3 * Uint32Array.BYTES_PER_ELEMENT) return false;
|
|
2756
2584
|
const e = new Uint32Array(t.buffer, t.byteOffset, 3);
|
|
2757
2585
|
return 1179937895 === e[0] && 2 === e[1];
|
|
2758
2586
|
}
|
|
@@ -2863,8 +2691,7 @@ class BufferReader {
|
|
|
2863
2691
|
byteLength++;
|
|
2864
2692
|
this._offset++;
|
|
2865
2693
|
}
|
|
2866
|
-
if (byteLength < maxByteLength)
|
|
2867
|
-
this._offset++;
|
|
2694
|
+
if (byteLength < maxByteLength) this._offset++;
|
|
2868
2695
|
return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
|
|
2869
2696
|
}
|
|
2870
2697
|
}
|
|
@@ -2978,11 +2805,9 @@ function read(data) {
|
|
|
2978
2805
|
const key = decodeText(keyData);
|
|
2979
2806
|
const valueData = kvdReader._scan(keyValueByteLength - keyData.byteLength);
|
|
2980
2807
|
container.keyValue[key] = key.match(/^ktx/i) ? decodeText(valueData) : valueData;
|
|
2981
|
-
if (kvdReader._offset % 4)
|
|
2982
|
-
kvdReader._skip(4 - kvdReader._offset % 4);
|
|
2808
|
+
if (kvdReader._offset % 4) kvdReader._skip(4 - kvdReader._offset % 4);
|
|
2983
2809
|
}
|
|
2984
|
-
if (sgdByteLength <= 0)
|
|
2985
|
-
return container;
|
|
2810
|
+
if (sgdByteLength <= 0) return container;
|
|
2986
2811
|
const sgdReader = new BufferReader(data, sgdByteOffset, sgdByteLength, true);
|
|
2987
2812
|
const endpointCount = sgdReader._nextUint16();
|
|
2988
2813
|
const selectorCount = sgdReader._nextUint16();
|
|
@@ -3050,19 +2875,15 @@ class y extends Tt$1 {
|
|
|
3050
2875
|
}
|
|
3051
2876
|
read(e) {
|
|
3052
2877
|
return (e.jsonDoc.json.nodes || []).forEach((t, s) => {
|
|
3053
|
-
if (!t.extensions || !t.extensions[N2])
|
|
3054
|
-
return;
|
|
2878
|
+
if (!t.extensions || !t.extensions[N2]) return;
|
|
3055
2879
|
const n = t.extensions[N2], r = this.createInstancedMesh();
|
|
3056
|
-
for (const t2 in n.attributes)
|
|
3057
|
-
r.setAttribute(t2, e.accessors[n.attributes[t2]]);
|
|
2880
|
+
for (const t2 in n.attributes) r.setAttribute(t2, e.accessors[n.attributes[t2]]);
|
|
3058
2881
|
e.nodes[s].setExtension(N2, r);
|
|
3059
2882
|
}), this;
|
|
3060
2883
|
}
|
|
3061
2884
|
prewrite(e) {
|
|
3062
2885
|
e.accessorUsageGroupedByParent.add("INSTANCE_ATTRIBUTE");
|
|
3063
|
-
for (const t of this.properties)
|
|
3064
|
-
for (const s of t.listAttributes())
|
|
3065
|
-
e.addAccessorToUsageGroup(s, "INSTANCE_ATTRIBUTE");
|
|
2886
|
+
for (const t of this.properties) for (const s of t.listAttributes()) e.addAccessorToUsageGroup(s, "INSTANCE_ATTRIBUTE");
|
|
3066
2887
|
return this;
|
|
3067
2888
|
}
|
|
3068
2889
|
write(e) {
|
|
@@ -3083,8 +2904,7 @@ function _() {
|
|
|
3083
2904
|
return (_ = Object.assign || function(e) {
|
|
3084
2905
|
for (var t = 1; t < arguments.length; t++) {
|
|
3085
2906
|
var s = arguments[t];
|
|
3086
|
-
for (var n in s)
|
|
3087
|
-
Object.prototype.hasOwnProperty.call(s, n) && (e[n] = s[n]);
|
|
2907
|
+
for (var n in s) Object.prototype.hasOwnProperty.call(s, n) && (e[n] = s[n]);
|
|
3088
2908
|
}
|
|
3089
2909
|
return e;
|
|
3090
2910
|
}).apply(this, arguments);
|
|
@@ -3100,13 +2920,11 @@ y.EXTENSION_NAME = N2, function(e) {
|
|
|
3100
2920
|
const { BYTE: M2, SHORT: O, FLOAT: w } = K$1.ComponentType, { encodeNormalizedInt: D, decodeNormalizedInt: b } = P$1;
|
|
3101
2921
|
function F(e, t, s, r) {
|
|
3102
2922
|
const { filter: o, bits: i } = r, a = { array: e.getArray(), byteStride: e.getElementSize() * e.getComponentSize(), componentType: e.getComponentType(), normalized: e.getNormalized() };
|
|
3103
|
-
if (s !== S2.ATTRIBUTES)
|
|
3104
|
-
return a;
|
|
2923
|
+
if (s !== S2.ATTRIBUTES) return a;
|
|
3105
2924
|
if (o !== C.NONE) {
|
|
3106
2925
|
let s2 = e.getNormalized() ? function(e2) {
|
|
3107
2926
|
const t2 = e2.getComponentType(), s3 = e2.getArray(), n = new Float32Array(s3.length);
|
|
3108
|
-
for (let e3 = 0; e3 < s3.length; e3++)
|
|
3109
|
-
n[e3] = b(s3[e3], t2);
|
|
2927
|
+
for (let e3 = 0; e3 < s3.length; e3++) n[e3] = b(s3[e3], t2);
|
|
3110
2928
|
return n;
|
|
3111
2929
|
}(e) : new Float32Array(a.array);
|
|
3112
2930
|
switch (o) {
|
|
@@ -3116,8 +2934,7 @@ function F(e, t, s, r) {
|
|
|
3116
2934
|
case C.OCTAHEDRAL:
|
|
3117
2935
|
a.byteStride = i > 8 ? 8 : 4, a.componentType = i > 8 ? O : M2, a.normalized = true, s2 = 3 === e.getElementSize() ? function(e2) {
|
|
3118
2936
|
const t2 = new Float32Array(4 * e2.length / 3);
|
|
3119
|
-
for (let s3 = 0, n = e2.length / 3; s3 < n; s3++)
|
|
3120
|
-
t2[4 * s3] = e2[3 * s3], t2[4 * s3 + 1] = e2[3 * s3 + 1], t2[4 * s3 + 2] = e2[3 * s3 + 2];
|
|
2937
|
+
for (let s3 = 0, n = e2.length / 3; s3 < n; s3++) t2[4 * s3] = e2[3 * s3], t2[4 * s3 + 1] = e2[3 * s3 + 1], t2[4 * s3 + 2] = e2[3 * s3 + 2];
|
|
3121
2938
|
return t2;
|
|
3122
2939
|
}(s2) : s2, a.array = t.encodeFilterOct(s2, e.getCount(), a.byteStride, i);
|
|
3123
2940
|
break;
|
|
@@ -3128,14 +2945,11 @@ function F(e, t, s, r) {
|
|
|
3128
2945
|
throw new Error("Invalid filter.");
|
|
3129
2946
|
}
|
|
3130
2947
|
a.min = e.getMin([]), a.max = e.getMax([]), e.getNormalized() && (a.min = a.min.map((t2) => b(t2, e.getComponentType())), a.max = a.max.map((t2) => b(t2, e.getComponentType()))), a.normalized && (a.min = a.min.map((e2) => D(e2, a.componentType)), a.max = a.max.map((e2) => D(e2, a.componentType)));
|
|
3131
|
-
} else
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
r2[n * s2 + o2] = e2[n * t2 + o2];
|
|
3137
|
-
return r2;
|
|
3138
|
-
}(a.array, e.getElementSize()), a.byteStride = a.array.byteLength / e.getCount());
|
|
2948
|
+
} else a.byteStride % 4 && (a.array = function(e2, t2) {
|
|
2949
|
+
const s2 = E.padNumber(e2.BYTES_PER_ELEMENT * t2) / e2.BYTES_PER_ELEMENT, r2 = new e2.constructor(e2.length / t2 * s2);
|
|
2950
|
+
for (let n = 0; n * t2 < e2.length; n++) for (let o2 = 0; o2 < t2; o2++) r2[n * s2 + o2] = e2[n * t2 + o2];
|
|
2951
|
+
return r2;
|
|
2952
|
+
}(a.array, e.getElementSize()), a.byteStride = a.array.byteLength / e.getCount());
|
|
3139
2953
|
return a;
|
|
3140
2954
|
}
|
|
3141
2955
|
function j(e, t) {
|
|
@@ -3145,40 +2959,28 @@ function v(e, t) {
|
|
|
3145
2959
|
const s = t.getGraph().listParentEdges(e).filter((e2) => !(e2.getParent() instanceof yt$1));
|
|
3146
2960
|
for (const t2 of s) {
|
|
3147
2961
|
const s2 = t2.getName(), n = t2.getAttributes().key || "";
|
|
3148
|
-
if ("indices" === s2)
|
|
3149
|
-
return { filter: C.NONE };
|
|
2962
|
+
if ("indices" === s2) return { filter: C.NONE };
|
|
3150
2963
|
if ("attributes" === s2) {
|
|
3151
|
-
if ("POSITION" === n)
|
|
3152
|
-
|
|
3153
|
-
if ("
|
|
3154
|
-
|
|
3155
|
-
if ("
|
|
3156
|
-
|
|
3157
|
-
if ("TANGENT" === n)
|
|
3158
|
-
return { filter: C.OCTAHEDRAL, bits: 8 };
|
|
3159
|
-
if (n.startsWith("JOINTS_"))
|
|
3160
|
-
return { filter: C.NONE };
|
|
3161
|
-
if (n.startsWith("WEIGHTS_"))
|
|
3162
|
-
return { filter: C.NONE };
|
|
2964
|
+
if ("POSITION" === n) return { filter: C.NONE };
|
|
2965
|
+
if ("TEXCOORD_0" === n) return { filter: C.NONE };
|
|
2966
|
+
if ("NORMAL" === n) return { filter: C.OCTAHEDRAL, bits: 8 };
|
|
2967
|
+
if ("TANGENT" === n) return { filter: C.OCTAHEDRAL, bits: 8 };
|
|
2968
|
+
if (n.startsWith("JOINTS_")) return { filter: C.NONE };
|
|
2969
|
+
if (n.startsWith("WEIGHTS_")) return { filter: C.NONE };
|
|
3163
2970
|
}
|
|
3164
2971
|
if ("output" === s2) {
|
|
3165
2972
|
const t3 = k(e);
|
|
3166
2973
|
return "rotation" === t3 ? { filter: C.QUATERNION, bits: 16 } : "translation" === t3 || "scale" === t3 ? { filter: C.EXPONENTIAL, bits: 12 } : { filter: C.NONE };
|
|
3167
2974
|
}
|
|
3168
|
-
if ("input" === s2)
|
|
3169
|
-
|
|
3170
|
-
if ("inverseBindMatrices" === s2)
|
|
3171
|
-
return { filter: C.NONE };
|
|
2975
|
+
if ("input" === s2) return { filter: C.NONE };
|
|
2976
|
+
if ("inverseBindMatrices" === s2) return { filter: C.NONE };
|
|
3172
2977
|
}
|
|
3173
2978
|
return { filter: C.NONE };
|
|
3174
2979
|
}
|
|
3175
2980
|
function k(e) {
|
|
3176
|
-
for (const t of e.listParents())
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
if (e2 instanceof X$1)
|
|
3180
|
-
return e2.getTargetPath();
|
|
3181
|
-
}
|
|
2981
|
+
for (const t of e.listParents()) if (t instanceof tt$1) {
|
|
2982
|
+
for (const e2 of t.listParents()) if (e2 instanceof X$1) return e2.getTargetPath();
|
|
2983
|
+
}
|
|
3182
2984
|
return null;
|
|
3183
2985
|
}
|
|
3184
2986
|
const B = "EXT_meshopt_compression", G = { method: A.QUANTIZE };
|
|
@@ -3194,13 +2996,11 @@ class L extends Tt$1 {
|
|
|
3194
2996
|
}
|
|
3195
2997
|
preread(e, s) {
|
|
3196
2998
|
if (!this._decoder) {
|
|
3197
|
-
if (!this.isRequired())
|
|
3198
|
-
return this;
|
|
2999
|
+
if (!this.isRequired()) return this;
|
|
3199
3000
|
throw new Error(`[${B}] Please install extension dependency, "meshopt.decoder".`);
|
|
3200
3001
|
}
|
|
3201
3002
|
if (!this._decoder.supported) {
|
|
3202
|
-
if (!this.isRequired())
|
|
3203
|
-
return this;
|
|
3003
|
+
if (!this.isRequired()) return this;
|
|
3204
3004
|
throw new Error(`[${B}]: Missing WASM support.`);
|
|
3205
3005
|
}
|
|
3206
3006
|
return s === h.BUFFER ? this._prereadBuffers(e) : s === h.PRIMITIVE && this._prereadPrimitives(e), this;
|
|
@@ -3208,8 +3008,7 @@ class L extends Tt$1 {
|
|
|
3208
3008
|
_prereadBuffers(e) {
|
|
3209
3009
|
const t = e.jsonDoc;
|
|
3210
3010
|
(t.json.bufferViews || []).forEach((s, r) => {
|
|
3211
|
-
if (!s.extensions || !s.extensions[B])
|
|
3212
|
-
return;
|
|
3011
|
+
if (!s.extensions || !s.extensions[B]) return;
|
|
3213
3012
|
const o = s.extensions[B], i = o.byteOffset || 0, a = o.byteLength || 0, c$1 = o.count, u = o.byteStride, l2 = new Uint8Array(c$1 * u), f2 = t.json.buffers[o.buffer], g2 = E.toView(f2.uri ? t.resources[f2.uri] : t.resources[c], i, a);
|
|
3214
3013
|
this._decoder.decodeGltfBuffer(l2, c$1, u, g2, o.mode, o.filter), e.bufferViews[r] = l2;
|
|
3215
3014
|
});
|
|
@@ -3222,11 +3021,9 @@ class L extends Tt$1 {
|
|
|
3222
3021
|
});
|
|
3223
3022
|
}
|
|
3224
3023
|
read(e) {
|
|
3225
|
-
if (!this.isRequired())
|
|
3226
|
-
return this;
|
|
3024
|
+
if (!this.isRequired()) return this;
|
|
3227
3025
|
for (const [e2, t] of this._decoderFallbackBufferMap) {
|
|
3228
|
-
for (const s of e2.listParents())
|
|
3229
|
-
s instanceof K$1 && s.swap(e2, t);
|
|
3026
|
+
for (const s of e2.listParents()) s instanceof K$1 && s.swap(e2, t);
|
|
3230
3027
|
e2.dispose();
|
|
3231
3028
|
}
|
|
3232
3029
|
return this;
|
|
@@ -3238,13 +3035,10 @@ class L extends Tt$1 {
|
|
|
3238
3035
|
const t = e.jsonDoc.json, s = this._encoder, n = this._encoderOptions, o = this.document.createBuffer(), i = this.document.getRoot().listBuffers().indexOf(o);
|
|
3239
3036
|
this._encoderFallbackBuffer = o, this._encoderBufferViews = {}, this._encoderBufferViewData = {}, this._encoderBufferViewAccessors = {};
|
|
3240
3037
|
for (const o2 of this.document.getRoot().listAccessors()) {
|
|
3241
|
-
if ("weights" === k(o2))
|
|
3242
|
-
|
|
3243
|
-
if (o2.getSparse())
|
|
3244
|
-
continue;
|
|
3038
|
+
if ("weights" === k(o2)) continue;
|
|
3039
|
+
if (o2.getSparse()) continue;
|
|
3245
3040
|
const a = e.getAccessorUsage(o2), c2 = j(o2, a), u = n.method === A.FILTER ? v(o2, this.document) : { filter: C.NONE }, l2 = F(o2, s, c2, u), { array: h2, byteStride: f2 } = l2, g2 = o2.getBuffer();
|
|
3246
|
-
if (!g2)
|
|
3247
|
-
throw new Error(`${B}: Missing buffer for accessor.`);
|
|
3041
|
+
if (!g2) throw new Error(`${B}: Missing buffer for accessor.`);
|
|
3248
3042
|
const p2 = this.document.getRoot().listBuffers().indexOf(g2), x2 = [a, c2, u.filter, f2, p2].join(":");
|
|
3249
3043
|
let d2 = this._encoderBufferViews[x2], T2 = this._encoderBufferViewData[x2], m2 = this._encoderBufferViewAccessors[x2];
|
|
3250
3044
|
d2 && T2 || (m2 = this._encoderBufferViewAccessors[x2] = [], T2 = this._encoderBufferViewData[x2] = [], d2 = this._encoderBufferViews[x2] = { buffer: i, target: Mt$1.USAGE_TO_TARGET[a], byteOffset: 0, byteLength: 0, byteStride: a === Mt$1.BufferViewUsage.ARRAY_BUFFER ? f2 : void 0, extensions: { [B]: { buffer: p2, byteOffset: 0, byteLength: 0, mode: c2, filter: u.filter !== C.NONE ? u.filter : void 0, byteStride: f2, count: 0 } } });
|
|
@@ -3263,8 +3057,7 @@ class L extends Tt$1 {
|
|
|
3263
3057
|
let t = 0;
|
|
3264
3058
|
for (const s2 in this._encoderBufferViews) {
|
|
3265
3059
|
const r2 = this._encoderBufferViews[s2], o2 = e.otherBufferViewsIndexMap.get(this._encoderBufferViewData[s2][0]), i = this._encoderBufferViewAccessors[s2];
|
|
3266
|
-
for (const e2 of i)
|
|
3267
|
-
e2.bufferView = o2;
|
|
3060
|
+
for (const e2 of i) e2.bufferView = o2;
|
|
3268
3061
|
const a = e.jsonDoc.json.bufferViews[o2], c2 = a.byteOffset || 0;
|
|
3269
3062
|
Object.assign(a, r2), a.byteOffset = t, a.extensions[B].byteOffset = c2, t += E.padNumber(r2.byteLength);
|
|
3270
3063
|
}
|
|
@@ -3279,25 +3072,18 @@ class U2 {
|
|
|
3279
3072
|
return e.length >= 12 && "ftypavif" === E.decodeText(e.slice(4, 12));
|
|
3280
3073
|
}
|
|
3281
3074
|
getSize(e) {
|
|
3282
|
-
if (!this.match(e))
|
|
3283
|
-
return null;
|
|
3075
|
+
if (!this.match(e)) return null;
|
|
3284
3076
|
const t = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
3285
3077
|
let s = P2(t, 0);
|
|
3286
|
-
if (!s)
|
|
3287
|
-
return null;
|
|
3078
|
+
if (!s) return null;
|
|
3288
3079
|
let n = s.end;
|
|
3289
|
-
for (; s = P2(t, n); )
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
return [t.getUint32(s.start + 4), t.getUint32(s.start + 8)];
|
|
3297
|
-
if ("mdat" === s.type)
|
|
3298
|
-
break;
|
|
3299
|
-
n = s.end;
|
|
3300
|
-
}
|
|
3080
|
+
for (; s = P2(t, n); ) if ("meta" === s.type) n = s.start + 4;
|
|
3081
|
+
else if ("iprp" === s.type || "ipco" === s.type) n = s.start;
|
|
3082
|
+
else {
|
|
3083
|
+
if ("ispe" === s.type) return [t.getUint32(s.start + 4), t.getUint32(s.start + 8)];
|
|
3084
|
+
if ("mdat" === s.type) break;
|
|
3085
|
+
n = s.end;
|
|
3086
|
+
}
|
|
3301
3087
|
return null;
|
|
3302
3088
|
}
|
|
3303
3089
|
getChannels(e) {
|
|
@@ -3332,8 +3118,7 @@ class V extends Tt$1 {
|
|
|
3332
3118
|
}
|
|
3333
3119
|
}
|
|
3334
3120
|
function P2(e, t) {
|
|
3335
|
-
if (e.byteLength < 4 + t)
|
|
3336
|
-
return null;
|
|
3121
|
+
if (e.byteLength < 4 + t) return null;
|
|
3337
3122
|
const s = e.getUint32(t);
|
|
3338
3123
|
return e.byteLength < s + t || s < 8 ? null : { type: E.decodeText(new Uint8Array(e.buffer, e.byteOffset + t + 4, 4)), start: t + 8, end: t + s };
|
|
3339
3124
|
}
|
|
@@ -3345,14 +3130,12 @@ class K2 {
|
|
|
3345
3130
|
}
|
|
3346
3131
|
getSize(e) {
|
|
3347
3132
|
const t = E.decodeText(e.slice(0, 4)), s = E.decodeText(e.slice(8, 12));
|
|
3348
|
-
if ("RIFF" !== t || "WEBP" !== s)
|
|
3349
|
-
return null;
|
|
3133
|
+
if ("RIFF" !== t || "WEBP" !== s) return null;
|
|
3350
3134
|
const r = new DataView(e.buffer, e.byteOffset);
|
|
3351
3135
|
let o = 12;
|
|
3352
3136
|
for (; o < r.byteLength; ) {
|
|
3353
3137
|
const e2 = E.decodeText(new Uint8Array([r.getUint8(o), r.getUint8(o + 1), r.getUint8(o + 2), r.getUint8(o + 3)])), t2 = r.getUint32(o + 4, true);
|
|
3354
|
-
if ("VP8 " === e2)
|
|
3355
|
-
return [16383 & r.getInt16(o + 14, true), 16383 & r.getInt16(o + 16, true)];
|
|
3138
|
+
if ("VP8 " === e2) return [16383 & r.getInt16(o + 14, true), 16383 & r.getInt16(o + 16, true)];
|
|
3356
3139
|
if ("VP8L" === e2) {
|
|
3357
3140
|
const e3 = r.getUint8(o + 9), t3 = r.getUint8(o + 10), s2 = r.getUint8(o + 11);
|
|
3358
3141
|
return [1 + ((63 & t3) << 8 | e3), 1 + ((15 & r.getUint8(o + 12)) << 10 | s2 << 2 | (192 & t3) >> 6)];
|
|
@@ -3398,11 +3181,9 @@ let q, Y2, Q2, W2;
|
|
|
3398
3181
|
function J(e, t) {
|
|
3399
3182
|
const s = new q.DecoderBuffer();
|
|
3400
3183
|
try {
|
|
3401
|
-
if (s.Init(t, t.length), e.GetEncodedGeometryType(s) !== q.TRIANGULAR_MESH)
|
|
3402
|
-
throw new Error(`[${$}] Unknown geometry type.`);
|
|
3184
|
+
if (s.Init(t, t.length), e.GetEncodedGeometryType(s) !== q.TRIANGULAR_MESH) throw new Error(`[${$}] Unknown geometry type.`);
|
|
3403
3185
|
const n = new q.Mesh();
|
|
3404
|
-
if (!e.DecodeBufferToMesh(s, n).ok() || 0 === n.ptr)
|
|
3405
|
-
throw new Error(`[${$}] Decoding failure.`);
|
|
3186
|
+
if (!e.DecodeBufferToMesh(s, n).ok() || 0 === n.ptr) throw new Error(`[${$}] Decoding failure.`);
|
|
3406
3187
|
return n;
|
|
3407
3188
|
} finally {
|
|
3408
3189
|
q.destroy(s);
|
|
@@ -3445,13 +3226,10 @@ function oe(e, t = re) {
|
|
|
3445
3226
|
continue;
|
|
3446
3227
|
}
|
|
3447
3228
|
const c3 = ie(t2), l3 = ae(r, a2.getComponentType(), o, W2[c3], a2.getCount(), a2.getElementSize(), a2.getArray());
|
|
3448
|
-
if (-1 === l3)
|
|
3449
|
-
|
|
3450
|
-
if (i[t2] = l3, "mesh" === s.quantizationVolume || "POSITION" !== t2)
|
|
3451
|
-
n.SetAttributeQuantization(W2[c3], s.quantizationBits[c3]);
|
|
3229
|
+
if (-1 === l3) throw new Error(`Error compressing "${t2}" attribute.`);
|
|
3230
|
+
if (i[t2] = l3, "mesh" === s.quantizationVolume || "POSITION" !== t2) n.SetAttributeQuantization(W2[c3], s.quantizationBits[c3]);
|
|
3452
3231
|
else {
|
|
3453
|
-
if ("object" != typeof s.quantizationVolume)
|
|
3454
|
-
throw new Error("Invalid quantization volume state.");
|
|
3232
|
+
if ("object" != typeof s.quantizationVolume) throw new Error("Invalid quantization volume state.");
|
|
3455
3233
|
{
|
|
3456
3234
|
const { quantizationVolume: e2 } = s, t3 = Math.max(e2.max[0] - e2.min[0], e2.max[1] - e2.min[1], e2.max[2] - e2.min[2]);
|
|
3457
3235
|
n.SetAttributeExplicitQuantization(W2[c3], s.quantizationBits[c3], a2.getElementSize(), e2.min, t3);
|
|
@@ -3459,18 +3237,14 @@ function oe(e, t = re) {
|
|
|
3459
3237
|
}
|
|
3460
3238
|
}
|
|
3461
3239
|
const l2 = e.getIndices();
|
|
3462
|
-
if (!l2)
|
|
3463
|
-
throw new ce("Primitive must have indices.");
|
|
3240
|
+
if (!l2) throw new ce("Primitive must have indices.");
|
|
3464
3241
|
r.AddFacesToMesh(o, l2.getCount() / 3, l2.getArray()), n.SetSpeedOptions(s.encodeSpeed, s.decodeSpeed), n.SetTrackEncodedProperties(true), n.SetEncodingMethod(s.method === te.SEQUENTIAL || c2 || u ? W2.MESH_SEQUENTIAL_ENCODING : W2.MESH_EDGEBREAKER_ENCODING);
|
|
3465
3242
|
const h2 = n.EncodeMeshToDracoBuffer(o, a);
|
|
3466
|
-
if (h2 <= 0)
|
|
3467
|
-
throw new ce("Error applying Draco compression.");
|
|
3243
|
+
if (h2 <= 0) throw new ce("Error applying Draco compression.");
|
|
3468
3244
|
const f2 = new Uint8Array(h2);
|
|
3469
|
-
for (let e2 = 0; e2 < h2; ++e2)
|
|
3470
|
-
f2[e2] = a.GetValue(e2);
|
|
3245
|
+
for (let e2 = 0; e2 < h2; ++e2) f2[e2] = a.GetValue(e2);
|
|
3471
3246
|
const g2 = e.getAttribute("POSITION").getCount(), p2 = n.GetNumberOfEncodedPoints(), x2 = 3 * n.GetNumberOfEncodedFaces();
|
|
3472
|
-
if ((c2 || u) && p2 !== g2)
|
|
3473
|
-
throw new ce('Compression reduced vertex count unexpectedly, corrupting mesh data. Applying the "weld" function before compression may resolve the issue. See: https://github.com/google/draco/issues/929');
|
|
3247
|
+
if ((c2 || u) && p2 !== g2) throw new ce('Compression reduced vertex count unexpectedly, corrupting mesh data. Applying the "weld" function before compression may resolve the issue. See: https://github.com/google/draco/issues/929');
|
|
3474
3248
|
return W2.destroy(a), W2.destroy(o), W2.destroy(r), W2.destroy(n), { numVertices: p2, numIndices: x2, data: f2, attributeIDs: i };
|
|
3475
3249
|
}
|
|
3476
3250
|
function ie(e) {
|
|
@@ -3508,30 +3282,26 @@ class le extends Tt$1 {
|
|
|
3508
3282
|
return this._encoderOptions = e, this;
|
|
3509
3283
|
}
|
|
3510
3284
|
preread(e) {
|
|
3511
|
-
if (!this._decoderModule)
|
|
3512
|
-
throw new Error(`[${ue}] Please install extension dependency, "draco3d.decoder".`);
|
|
3285
|
+
if (!this._decoderModule) throw new Error(`[${ue}] Please install extension dependency, "draco3d.decoder".`);
|
|
3513
3286
|
const t = this.document.getLogger(), s = e.jsonDoc, r = /* @__PURE__ */ new Map();
|
|
3514
3287
|
try {
|
|
3515
3288
|
const o = s.json.meshes || [];
|
|
3516
|
-
for (const i of o)
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
const s2 = e.jsonDoc.json.accessors[o2.attributes[t2]], n = a.GetAttributeByUniqueId(c$1, i2.attributes[t2]), r2 = ee(a, c$1, n, s2);
|
|
3528
|
-
e.accessors[o2.attributes[t2]].setArray(r2);
|
|
3529
|
-
}
|
|
3530
|
-
void 0 !== o2.indices && e.accessors[o2.indices].setArray(Z2(a, c$1));
|
|
3289
|
+
for (const i of o) for (const o2 of i.primitives) {
|
|
3290
|
+
if (!o2.extensions || !o2.extensions[ue]) continue;
|
|
3291
|
+
const i2 = o2.extensions[ue];
|
|
3292
|
+
let [a, c$1] = r.get(i2.bufferView) || [];
|
|
3293
|
+
if (!c$1 || !a) {
|
|
3294
|
+
const e2 = s.json.bufferViews[i2.bufferView], o3 = s.json.buffers[e2.buffer], u = E.toView(o3.uri ? s.resources[o3.uri] : s.resources[c], e2.byteOffset || 0, e2.byteLength);
|
|
3295
|
+
a = new this._decoderModule.Decoder(), c$1 = J(a, u), r.set(i2.bufferView, [a, c$1]), t.debug(`[${ue}] Decompressed ${u.byteLength} bytes.`);
|
|
3296
|
+
}
|
|
3297
|
+
for (const t2 in o2.attributes) {
|
|
3298
|
+
const s2 = e.jsonDoc.json.accessors[o2.attributes[t2]], n = a.GetAttributeByUniqueId(c$1, i2.attributes[t2]), r2 = ee(a, c$1, n, s2);
|
|
3299
|
+
e.accessors[o2.attributes[t2]].setArray(r2);
|
|
3531
3300
|
}
|
|
3301
|
+
void 0 !== o2.indices && e.accessors[o2.indices].setArray(Z2(a, c$1));
|
|
3302
|
+
}
|
|
3532
3303
|
} finally {
|
|
3533
|
-
for (const [e2, t2] of Array.from(r.values()))
|
|
3534
|
-
this._decoderModule.destroy(e2), this._decoderModule.destroy(t2);
|
|
3304
|
+
for (const [e2, t2] of Array.from(r.values())) this._decoderModule.destroy(e2), this._decoderModule.destroy(t2);
|
|
3535
3305
|
}
|
|
3536
3306
|
return this;
|
|
3537
3307
|
}
|
|
@@ -3539,52 +3309,42 @@ class le extends Tt$1 {
|
|
|
3539
3309
|
return this;
|
|
3540
3310
|
}
|
|
3541
3311
|
prewrite(e, s) {
|
|
3542
|
-
if (!this._encoderModule)
|
|
3543
|
-
throw new Error(`[${ue}] Please install extension dependency, "draco3d.encoder".`);
|
|
3312
|
+
if (!this._encoderModule) throw new Error(`[${ue}] Please install extension dependency, "draco3d.encoder".`);
|
|
3544
3313
|
const n = this.document.getLogger();
|
|
3545
3314
|
n.debug(`[${ue}] Compression options: ${JSON.stringify(this._encoderOptions)}`);
|
|
3546
3315
|
const r = function(e2) {
|
|
3547
3316
|
const s2 = e2.getLogger(), n2 = /* @__PURE__ */ new Set(), r2 = /* @__PURE__ */ new Set();
|
|
3548
|
-
for (const t of e2.getRoot().listMeshes())
|
|
3549
|
-
for (const e3 of t.listPrimitives())
|
|
3550
|
-
e3.getIndices() ? e3.getMode() !== lt$1.Mode.TRIANGLES ? (r2.add(e3), s2.warn(`[${ue}] Skipping Draco compression on non-TRIANGLES primitive.`)) : n2.add(e3) : (r2.add(e3), s2.warn(`[${ue}] Skipping Draco compression on non-indexed primitive.`));
|
|
3317
|
+
for (const t of e2.getRoot().listMeshes()) for (const e3 of t.listPrimitives()) e3.getIndices() ? e3.getMode() !== lt$1.Mode.TRIANGLES ? (r2.add(e3), s2.warn(`[${ue}] Skipping Draco compression on non-TRIANGLES primitive.`)) : n2.add(e3) : (r2.add(e3), s2.warn(`[${ue}] Skipping Draco compression on non-indexed primitive.`));
|
|
3551
3318
|
const i2 = e2.getRoot().listAccessors(), a2 = /* @__PURE__ */ new Map();
|
|
3552
|
-
for (let e3 = 0; e3 < i2.length; e3++)
|
|
3553
|
-
a2.set(i2[e3], e3);
|
|
3319
|
+
for (let e3 = 0; e3 < i2.length; e3++) a2.set(i2[e3], e3);
|
|
3554
3320
|
const c2 = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), l2 = /* @__PURE__ */ new Map();
|
|
3555
3321
|
for (const t of Array.from(n2)) {
|
|
3556
3322
|
let s3 = he(t, a2);
|
|
3557
|
-
if (u.has(s3))
|
|
3558
|
-
l2.set(t, s3);
|
|
3323
|
+
if (u.has(s3)) l2.set(t, s3);
|
|
3559
3324
|
else {
|
|
3560
3325
|
if (c2.has(t.getIndices())) {
|
|
3561
3326
|
const s4 = t.getIndices(), n3 = s4.clone();
|
|
3562
3327
|
a2.set(n3, e2.getRoot().listAccessors().length - 1), t.swap(s4, n3);
|
|
3563
3328
|
}
|
|
3564
|
-
for (const s4 of t.listAttributes())
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
}
|
|
3329
|
+
for (const s4 of t.listAttributes()) if (c2.has(s4)) {
|
|
3330
|
+
const n3 = s4.clone();
|
|
3331
|
+
a2.set(n3, e2.getRoot().listAccessors().length - 1), t.swap(s4, n3);
|
|
3332
|
+
}
|
|
3569
3333
|
s3 = he(t, a2), u.add(s3), l2.set(t, s3), c2.set(t.getIndices(), s3);
|
|
3570
|
-
for (const e3 of t.listAttributes())
|
|
3571
|
-
c2.set(e3, s3);
|
|
3334
|
+
for (const e3 of t.listAttributes()) c2.set(e3, s3);
|
|
3572
3335
|
}
|
|
3573
3336
|
}
|
|
3574
3337
|
for (const e3 of Array.from(c2.keys())) {
|
|
3575
3338
|
const s3 = new Set(e3.listParents().map((e4) => e4.propertyType));
|
|
3576
|
-
if (2 !== s3.size || !s3.has(h.PRIMITIVE) || !s3.has(h.ROOT))
|
|
3577
|
-
throw new Error(`[${ue}] Compressed accessors must only be used as indices or vertex attributes.`);
|
|
3339
|
+
if (2 !== s3.size || !s3.has(h.PRIMITIVE) || !s3.has(h.ROOT)) throw new Error(`[${ue}] Compressed accessors must only be used as indices or vertex attributes.`);
|
|
3578
3340
|
}
|
|
3579
3341
|
for (const e3 of Array.from(n2)) {
|
|
3580
3342
|
const t = l2.get(e3), s3 = e3.getIndices();
|
|
3581
|
-
if (c2.get(s3) !== t || e3.listAttributes().some((e4) => c2.get(e4) !== t))
|
|
3582
|
-
throw new Error(`[${ue}] Draco primitives must share all, or no, accessors.`);
|
|
3343
|
+
if (c2.get(s3) !== t || e3.listAttributes().some((e4) => c2.get(e4) !== t)) throw new Error(`[${ue}] Draco primitives must share all, or no, accessors.`);
|
|
3583
3344
|
}
|
|
3584
3345
|
for (const e3 of Array.from(r2)) {
|
|
3585
3346
|
const t = e3.getIndices();
|
|
3586
|
-
if (c2.has(t) || e3.listAttributes().some((e4) => c2.has(e4)))
|
|
3587
|
-
throw new Error(`[${ue}] Accessor cannot be shared by compressed and uncompressed primitives.`);
|
|
3347
|
+
if (c2.has(t) || e3.listAttributes().some((e4) => c2.has(e4))) throw new Error(`[${ue}] Accessor cannot be shared by compressed and uncompressed primitives.`);
|
|
3588
3348
|
}
|
|
3589
3349
|
return l2;
|
|
3590
3350
|
}(this.document), i = /* @__PURE__ */ new Map();
|
|
@@ -3592,8 +3352,7 @@ class le extends Tt$1 {
|
|
|
3592
3352
|
"scene" === this._encoderOptions.quantizationVolume && (1 !== this.document.getRoot().listScenes().length ? n.warn(`[${ue}]: quantizationVolume=scene requires exactly 1 scene.`) : a = T(this.document.getRoot().listScenes().pop()));
|
|
3593
3353
|
for (const t of Array.from(r.keys())) {
|
|
3594
3354
|
const s2 = r.get(t);
|
|
3595
|
-
if (!s2)
|
|
3596
|
-
throw new Error("Unexpected primitive.");
|
|
3355
|
+
if (!s2) throw new Error("Unexpected primitive.");
|
|
3597
3356
|
if (i.has(s2)) {
|
|
3598
3357
|
i.set(s2, i.get(s2));
|
|
3599
3358
|
continue;
|
|
@@ -3614,8 +3373,7 @@ class le extends Tt$1 {
|
|
|
3614
3373
|
l2.count = u.numIndices, e.accessorIndexMap.set(o, c2.length), c2.push(l2);
|
|
3615
3374
|
for (const s3 of t.listSemantics()) {
|
|
3616
3375
|
const n2 = t.getAttribute(s3);
|
|
3617
|
-
if (void 0 === u.attributeIDs[s3])
|
|
3618
|
-
continue;
|
|
3376
|
+
if (void 0 === u.attributeIDs[s3]) continue;
|
|
3619
3377
|
const r2 = e.createAccessorDef(n2);
|
|
3620
3378
|
r2.count = u.numVertices, e.accessorIndexMap.set(n2, c2.length), c2.push(r2);
|
|
3621
3379
|
}
|
|
@@ -3630,8 +3388,7 @@ class le extends Tt$1 {
|
|
|
3630
3388
|
const n = e.jsonDoc.json.meshes[e.meshIndexMap.get(s)];
|
|
3631
3389
|
for (let r = 0; r < s.listPrimitives().length; r++) {
|
|
3632
3390
|
const o = s.listPrimitives()[r], i = n.primitives[r], a = t.primitiveHashMap.get(o);
|
|
3633
|
-
if (!a)
|
|
3634
|
-
continue;
|
|
3391
|
+
if (!a) continue;
|
|
3635
3392
|
const c2 = t.primitiveEncodingMap.get(a);
|
|
3636
3393
|
c2 && (i.extensions = i.extensions || {}, i.extensions[ue] = { bufferView: e.otherBufferViewsIndexMap.get(c2.data), attributes: c2.attributeIDs });
|
|
3637
3394
|
}
|
|
@@ -3646,8 +3403,7 @@ class le extends Tt$1 {
|
|
|
3646
3403
|
function he(e, t) {
|
|
3647
3404
|
const s = [], n = e.getIndices();
|
|
3648
3405
|
s.push(t.get(n));
|
|
3649
|
-
for (const n2 of e.listAttributes())
|
|
3650
|
-
s.push(t.get(n2));
|
|
3406
|
+
for (const n2 of e.listAttributes()) s.push(t.get(n2));
|
|
3651
3407
|
return s.sort().join("|");
|
|
3652
3408
|
}
|
|
3653
3409
|
le.EXTENSION_NAME = ue, le.EncoderMethod = te;
|
|
@@ -3713,8 +3469,7 @@ class pe extends Tt$1 {
|
|
|
3713
3469
|
}
|
|
3714
3470
|
read(e) {
|
|
3715
3471
|
const t = e.jsonDoc;
|
|
3716
|
-
if (!t.json.extensions || !t.json.extensions[ge])
|
|
3717
|
-
return this;
|
|
3472
|
+
if (!t.json.extensions || !t.json.extensions[ge]) return this;
|
|
3718
3473
|
const s = (t.json.extensions[ge].lights || []).map((e2) => {
|
|
3719
3474
|
var t2, s2;
|
|
3720
3475
|
const n = this.createLight().setName(e2.name || "").setType(e2.type);
|
|
@@ -3726,8 +3481,7 @@ class pe extends Tt$1 {
|
|
|
3726
3481
|
}
|
|
3727
3482
|
write(e) {
|
|
3728
3483
|
const t = e.jsonDoc;
|
|
3729
|
-
if (0 === this.properties.size)
|
|
3730
|
-
return this;
|
|
3484
|
+
if (0 === this.properties.size) return this;
|
|
3731
3485
|
const s = [], n = /* @__PURE__ */ new Map();
|
|
3732
3486
|
for (const e2 of this.properties) {
|
|
3733
3487
|
const t2 = e2, r = { type: t2.getType() };
|
|
@@ -4561,20 +4315,17 @@ class xt extends Tt$1 {
|
|
|
4561
4315
|
}
|
|
4562
4316
|
read(e) {
|
|
4563
4317
|
const t = e.jsonDoc;
|
|
4564
|
-
if (!t.json.extensions || !t.json.extensions[pt2])
|
|
4565
|
-
return this;
|
|
4318
|
+
if (!t.json.extensions || !t.json.extensions[pt2]) return this;
|
|
4566
4319
|
const s = (t.json.extensions[pt2].variants || []).map((e2) => this.createVariant().setName(e2.name || ""));
|
|
4567
4320
|
return (t.json.meshes || []).forEach((t2, n) => {
|
|
4568
4321
|
const r = e.meshes[n];
|
|
4569
4322
|
(t2.primitives || []).forEach((t3, n2) => {
|
|
4570
|
-
if (!t3.extensions || !t3.extensions[pt2])
|
|
4571
|
-
return;
|
|
4323
|
+
if (!t3.extensions || !t3.extensions[pt2]) return;
|
|
4572
4324
|
const o = this.createMappingList(), i = t3.extensions[pt2];
|
|
4573
4325
|
for (const t4 of i.mappings) {
|
|
4574
4326
|
const n3 = this.createMapping();
|
|
4575
4327
|
void 0 !== t4.material && n3.setMaterial(e.materials[t4.material]);
|
|
4576
|
-
for (const e2 of t4.variants || [])
|
|
4577
|
-
n3.addVariant(s[e2]);
|
|
4328
|
+
for (const e2 of t4.variants || []) n3.addVariant(s[e2]);
|
|
4578
4329
|
o.addMapping(n3);
|
|
4579
4330
|
}
|
|
4580
4331
|
r.listPrimitives()[n2].setExtension(pt2, o);
|
|
@@ -4583,17 +4334,14 @@ class xt extends Tt$1 {
|
|
|
4583
4334
|
}
|
|
4584
4335
|
write(e) {
|
|
4585
4336
|
const t = e.jsonDoc, s = this.listVariants();
|
|
4586
|
-
if (!s.length)
|
|
4587
|
-
return this;
|
|
4337
|
+
if (!s.length) return this;
|
|
4588
4338
|
const n = [], r = /* @__PURE__ */ new Map();
|
|
4589
|
-
for (const t2 of s)
|
|
4590
|
-
r.set(t2, n.length), n.push(e.createPropertyDef(t2));
|
|
4339
|
+
for (const t2 of s) r.set(t2, n.length), n.push(e.createPropertyDef(t2));
|
|
4591
4340
|
for (const t2 of this.document.getRoot().listMeshes()) {
|
|
4592
4341
|
const s2 = e.meshIndexMap.get(t2);
|
|
4593
4342
|
t2.listPrimitives().forEach((t3, n2) => {
|
|
4594
4343
|
const o = t3.getExtension(pt2);
|
|
4595
|
-
if (!o)
|
|
4596
|
-
return;
|
|
4344
|
+
if (!o) return;
|
|
4597
4345
|
const i = e.jsonDoc.json.meshes[s2].primitives[n2], a = o.listMappings().map((t4) => {
|
|
4598
4346
|
const s3 = e.createPropertyDef(t4), n3 = t4.getMaterial();
|
|
4599
4347
|
return n3 && (s3.material = e.materialIndexMap.get(n3)), s3.variants = t4.listVariants().map((e2) => r.get(e2)), s3;
|
|
@@ -4712,10 +4460,8 @@ class yt2 {
|
|
|
4712
4460
|
}
|
|
4713
4461
|
getChannels(e) {
|
|
4714
4462
|
const t = read(e).dataFormatDescriptor[0];
|
|
4715
|
-
if (t.colorModel === KHR_DF_MODEL_ETC1S)
|
|
4716
|
-
|
|
4717
|
-
if (t.colorModel === KHR_DF_MODEL_UASTC)
|
|
4718
|
-
return 3 == (15 & t.samples[0].channelType) ? 4 : 3;
|
|
4463
|
+
if (t.colorModel === KHR_DF_MODEL_ETC1S) return 2 === t.samples.length && 15 == (15 & t.samples[1].channelType) ? 4 : 3;
|
|
4464
|
+
if (t.colorModel === KHR_DF_MODEL_UASTC) return 3 == (15 & t.samples[0].channelType) ? 4 : 3;
|
|
4719
4465
|
throw new Error(`Unexpected KTX2 colorModel, "${t.colorModel}".`);
|
|
4720
4466
|
}
|
|
4721
4467
|
getVRAMByteLength(e) {
|
|
@@ -4799,8 +4545,7 @@ class Ct extends Tt$1 {
|
|
|
4799
4545
|
}
|
|
4800
4546
|
read(e) {
|
|
4801
4547
|
for (const [t, s] of Array.from(e.textureInfos.entries())) {
|
|
4802
|
-
if (!s.extensions || !s.extensions[St2])
|
|
4803
|
-
continue;
|
|
4548
|
+
if (!s.extensions || !s.extensions[St2]) continue;
|
|
4804
4549
|
const e2 = this.createTransform(), n = s.extensions[St2];
|
|
4805
4550
|
void 0 !== n.offset && e2.setOffset(n.offset), void 0 !== n.rotation && e2.setRotation(n.rotation), void 0 !== n.scale && e2.setScale(n.scale), void 0 !== n.texCoord && e2.setTexCoord(n.texCoord), t.setExtension(St2, e2);
|
|
4806
4551
|
}
|
|
@@ -4810,8 +4555,7 @@ class Ct extends Tt$1 {
|
|
|
4810
4555
|
const t = Array.from(e.textureInfoDefMap.entries());
|
|
4811
4556
|
for (const [e2, s] of t) {
|
|
4812
4557
|
const t2 = e2.getExtension(St2);
|
|
4813
|
-
if (!t2)
|
|
4814
|
-
continue;
|
|
4558
|
+
if (!t2) continue;
|
|
4815
4559
|
s.extensions = s.extensions || {};
|
|
4816
4560
|
const n = {}, r = P$1.eq;
|
|
4817
4561
|
r(t2.getOffset(), [0, 0]) || (n.offset = t2.getOffset()), 0 !== t2.getRotation() && (n.rotation = t2.getRotation()), r(t2.getScale(), [1, 1]) || (n.scale = t2.getScale()), null != t2.getTexCoord() && (n.texCoord = t2.getTexCoord()), s.extensions[St2] = n;
|
|
@@ -4854,8 +4598,7 @@ class Ot extends st$1 {
|
|
|
4854
4598
|
return t && this.set("context", t), delete e["@context"], this.set("properties", e);
|
|
4855
4599
|
}
|
|
4856
4600
|
_assertContext(e) {
|
|
4857
|
-
if (!(e.split(":")[0] in this.get("context")))
|
|
4858
|
-
throw new Error(`KHR_xmp_json_ld: Missing context for term, "${e}".`);
|
|
4601
|
+
if (!(e.split(":")[0] in this.get("context"))) throw new Error(`KHR_xmp_json_ld: Missing context for term, "${e}".`);
|
|
4859
4602
|
}
|
|
4860
4603
|
}
|
|
4861
4604
|
function wt2(e) {
|
|
@@ -4876,8 +4619,7 @@ class bt2 extends Tt$1 {
|
|
|
4876
4619
|
read(e) {
|
|
4877
4620
|
var t;
|
|
4878
4621
|
const s = null == (t = e.jsonDoc.json.extensions) ? void 0 : t[Dt];
|
|
4879
|
-
if (!s || !s.packets)
|
|
4880
|
-
return this;
|
|
4622
|
+
if (!s || !s.packets) return this;
|
|
4881
4623
|
const n = e.jsonDoc.json, r = this.document.getRoot(), o = s.packets.map((e2) => this.createPacket().fromJSONLD(e2)), i = [[n.asset], n.scenes, n.nodes, n.meshes, n.materials, n.images, n.animations], a = [[r], r.listScenes(), r.listNodes(), r.listMeshes(), r.listMaterials(), r.listTextures(), r.listAnimations()];
|
|
4882
4624
|
for (let e2 = 0; e2 < i.length; e2++) {
|
|
4883
4625
|
const t2 = i[e2] || [];
|
|
@@ -4950,8 +4692,7 @@ class GLTFDracoExporter extends GLTFExporter2 {
|
|
|
4950
4692
|
return this;
|
|
4951
4693
|
}
|
|
4952
4694
|
async _loadLibs() {
|
|
4953
|
-
if (this._loadedLibs || !this.loader)
|
|
4954
|
-
return;
|
|
4695
|
+
if (this._loadedLibs || !this.loader) return;
|
|
4955
4696
|
const libs = await Promise.all([
|
|
4956
4697
|
this.loader.initEncoder(),
|
|
4957
4698
|
this.loader.initDecoder()
|
|
@@ -4963,7 +4704,7 @@ class GLTFDracoExporter extends GLTFExporter2 {
|
|
|
4963
4704
|
});
|
|
4964
4705
|
this._loadedLibs = true;
|
|
4965
4706
|
}
|
|
4966
|
-
async parseAsync(obj, { compress = false, dracoOptions, ...options }) {
|
|
4707
|
+
async parseAsync(obj, { compress = false, dracoOptions, ...options }, throwOnError = false) {
|
|
4967
4708
|
if (!this.loader) {
|
|
4968
4709
|
console.error("GLTFDracoExporter: No DRACOLoader2 instance provided");
|
|
4969
4710
|
return super.parseAsync(obj, options);
|
|
@@ -4975,37 +4716,41 @@ class GLTFDracoExporter extends GLTFExporter2 {
|
|
|
4975
4716
|
}
|
|
4976
4717
|
const uncompressed = await new Promise((resolve, reject) => this.parse(obj, resolve, reject, ops));
|
|
4977
4718
|
const uncompressedBlob = await super.parseAsync(uncompressed, ops);
|
|
4978
|
-
if (!compress)
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
}
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
4719
|
+
if (!compress) return uncompressedBlob;
|
|
4720
|
+
try {
|
|
4721
|
+
if (!uncompressed) throw new Error("GLTFDracoExporter: gltf is null");
|
|
4722
|
+
let gltf = uncompressed;
|
|
4723
|
+
const bytes = gltf.byteLength || Infinity;
|
|
4724
|
+
const iDocument = await (typeof gltf === "object" && !gltf.byteLength ? this._io.readJSON({
|
|
4725
|
+
json: gltf,
|
|
4726
|
+
resources: {}
|
|
4727
|
+
}) : this._io.readBinary(new Uint8Array(gltf)));
|
|
4728
|
+
iDocument.createExtension(le).setRequired(true).setEncoderOptions({ ...this._encoderOptions, ...dracoOptions ?? {} });
|
|
4729
|
+
if (ops.exportExt === "glb") {
|
|
4730
|
+
gltf = await this._io.writeBinary(iDocument);
|
|
4731
|
+
if (isFinite(bytes)) {
|
|
4732
|
+
console.log("DRACO Compression ratio: " + (gltf.byteLength / bytes).toFixed(5));
|
|
4733
|
+
}
|
|
4734
|
+
} else {
|
|
4735
|
+
const jDoc = await this._io.writeJSON(iDocument);
|
|
4736
|
+
gltf = jDoc.json;
|
|
4737
|
+
if (Object.values(jDoc.resources).filter((v2) => v2).length > 0) {
|
|
4738
|
+
console.warn("DRACOExporter: extra resources in resources not supported properly");
|
|
4739
|
+
gltf.resources = jDoc.resources;
|
|
4740
|
+
}
|
|
5000
4741
|
}
|
|
4742
|
+
gltf.__isGLTFOutput = true;
|
|
4743
|
+
const blob = await super.parseAsync(gltf, ops);
|
|
4744
|
+
if (!blob) throw new Error("GLTFDracoExporter: blob is null");
|
|
4745
|
+
blob.ext = "glb";
|
|
4746
|
+
blob.__uncompressed = uncompressedBlob;
|
|
4747
|
+
return blob;
|
|
4748
|
+
} catch (e) {
|
|
4749
|
+
if (throwOnError) throw e;
|
|
4750
|
+
console.error("Unable to compress glb with DRACO extension, fallback to uncompressed");
|
|
4751
|
+
console.error(e);
|
|
4752
|
+
return uncompressedBlob;
|
|
5001
4753
|
}
|
|
5002
|
-
gltf.__isGLTFOutput = true;
|
|
5003
|
-
const blob = await super.parseAsync(gltf, ops);
|
|
5004
|
-
if (!blob)
|
|
5005
|
-
throw new Error("GLTFDracoExporter: blob is null");
|
|
5006
|
-
blob.ext = "glb";
|
|
5007
|
-
blob.__uncompressed = uncompressedBlob;
|
|
5008
|
-
return blob;
|
|
5009
4754
|
}
|
|
5010
4755
|
addExtension(extension) {
|
|
5011
4756
|
this._io.registerExtensions([extension]);
|
|
@@ -5189,8 +4934,7 @@ class GenericExtension extends Tt$1 {
|
|
|
5189
4934
|
if (paramsExt) {
|
|
5190
4935
|
const sceneIndex = context.jsonDoc.json.scene || 0;
|
|
5191
4936
|
const sceneDef = jsonDoc.json.scenes[sceneIndex];
|
|
5192
|
-
if (!sceneDef)
|
|
5193
|
-
return;
|
|
4937
|
+
if (!sceneDef) return;
|
|
5194
4938
|
sceneDef.extensions = sceneDef.extensions || {};
|
|
5195
4939
|
sceneDef.extensions[this.extensionName] = paramsExt.getExtras();
|
|
5196
4940
|
}
|
|
@@ -5200,14 +4944,10 @@ class GenericExtension extends Tt$1 {
|
|
|
5200
4944
|
}
|
|
5201
4945
|
function stringToChannel(s) {
|
|
5202
4946
|
let r = 0;
|
|
5203
|
-
if (s.includes("R"))
|
|
5204
|
-
|
|
5205
|
-
if (s.includes("
|
|
5206
|
-
|
|
5207
|
-
if (s.includes("B"))
|
|
5208
|
-
r |= d.B;
|
|
5209
|
-
if (s.includes("A"))
|
|
5210
|
-
r |= d.A;
|
|
4947
|
+
if (s.includes("R")) r |= d.R;
|
|
4948
|
+
if (s.includes("G")) r |= d.G;
|
|
4949
|
+
if (s.includes("B")) r |= d.B;
|
|
4950
|
+
if (s.includes("A")) r |= d.A;
|
|
5211
4951
|
return r;
|
|
5212
4952
|
}
|
|
5213
4953
|
function createGenericExtensionClass(name, textures) {
|
|
@@ -5231,6 +4971,45 @@ const _GLTFDracoExportPlugin = class _GLTFDracoExportPlugin extends AViewerPlugi
|
|
|
5231
4971
|
constructor() {
|
|
5232
4972
|
super(...arguments);
|
|
5233
4973
|
this.enabled = true;
|
|
4974
|
+
this.extraExtensions = [
|
|
4975
|
+
[GLTFMaterialsBumpMapExtension.WebGiMaterialsBumpMapExtension, GLTFMaterialsBumpMapExtension.Textures],
|
|
4976
|
+
[GLTFMaterialsLightMapExtension.WebGiMaterialsLightMapExtension, GLTFMaterialsLightMapExtension.Textures],
|
|
4977
|
+
[GLTFMaterialsAlphaMapExtension.WebGiMaterialsAlphaMapExtension, GLTFMaterialsAlphaMapExtension.Textures],
|
|
4978
|
+
[GLTFMaterialsDisplacementMapExtension.WebGiMaterialsDisplacementMapExtension, GLTFMaterialsDisplacementMapExtension.Textures],
|
|
4979
|
+
[customBumpMapGLTFExtension.name, customBumpMapGLTFExtension.textures],
|
|
4980
|
+
[GLTFLightExtrasExtension.WebGiLightExtrasExtension, GLTFLightExtrasExtension.Textures],
|
|
4981
|
+
[GLTFObject3DExtrasExtension.WebGiObject3DExtrasExtension, GLTFObject3DExtrasExtension.Textures],
|
|
4982
|
+
[GLTFMaterialExtrasExtension.WebGiMaterialExtrasExtension, GLTFMaterialExtrasExtension.Textures],
|
|
4983
|
+
[clearCoatTintGLTFExtension.name, clearCoatTintGLTFExtension.textures],
|
|
4984
|
+
[noiseBumpMaterialGLTFExtension.name, noiseBumpMaterialGLTFExtension.textures],
|
|
4985
|
+
[fragmentClippingGLTFExtension.name, fragmentClippingGLTFExtension.textures],
|
|
4986
|
+
// extenal plugins
|
|
4987
|
+
// AnisotropyMaterialExtension
|
|
4988
|
+
["WEBGI_materials_anisotropy", {
|
|
4989
|
+
anisotropyDirection: "RGB"
|
|
4990
|
+
}]
|
|
4991
|
+
// todo port
|
|
4992
|
+
// DiamondMaterialExtension
|
|
4993
|
+
// AnimationMarkersExtension
|
|
4994
|
+
// ThinFilmLayerMaterialExtension
|
|
4995
|
+
// TriplanarMappingMaterialExtension
|
|
4996
|
+
// SSBevelMaterialExtension
|
|
4997
|
+
];
|
|
4998
|
+
this._lastExporter = void 0;
|
|
4999
|
+
this._ctor = (_2, _exporter) => {
|
|
5000
|
+
if (!this._viewer) throw new Error("Viewer not set");
|
|
5001
|
+
const tempFile = generateUUID() + ".drc";
|
|
5002
|
+
const ex = new GLTFDracoExporter(
|
|
5003
|
+
{},
|
|
5004
|
+
// todo unregister on dispose
|
|
5005
|
+
this._viewer.assetManager.importer.registerFile(tempFile)
|
|
5006
|
+
);
|
|
5007
|
+
ex.setup(this._viewer, _exporter.extensions);
|
|
5008
|
+
for (const [ext, config] of this.extraExtensions) {
|
|
5009
|
+
ex.createAndAddExtension(ext, config);
|
|
5010
|
+
}
|
|
5011
|
+
return ex;
|
|
5012
|
+
};
|
|
5234
5013
|
this._makeUi = (exporter) => {
|
|
5235
5014
|
var _a;
|
|
5236
5015
|
return [
|
|
@@ -5285,51 +5064,38 @@ const _GLTFDracoExportPlugin = class _GLTFDracoExportPlugin extends AViewerPlugi
|
|
|
5285
5064
|
];
|
|
5286
5065
|
};
|
|
5287
5066
|
}
|
|
5067
|
+
addExtension(name, textures) {
|
|
5068
|
+
const ext = this.extraExtensions.findIndex((e) => e[0] === name);
|
|
5069
|
+
if (ext >= 0) this.extraExtensions[ext] = [name, textures];
|
|
5070
|
+
else this.extraExtensions.push([name, textures]);
|
|
5071
|
+
}
|
|
5072
|
+
/**
|
|
5073
|
+
* Note - don't remove an extension when removing a plugin.
|
|
5074
|
+
*
|
|
5075
|
+
* extensions can be removed if you don't want to save the data of some plugin when transforming glb. But since this is not desirable in most cases, it is not recommended.
|
|
5076
|
+
* @param name
|
|
5077
|
+
*/
|
|
5078
|
+
removeExtension(name) {
|
|
5079
|
+
const ext = this.extraExtensions.findIndex((e) => e[0] === name);
|
|
5080
|
+
if (ext >= 0) this.extraExtensions.splice(ext, 1);
|
|
5081
|
+
}
|
|
5288
5082
|
onAdded(viewer) {
|
|
5289
5083
|
var _a;
|
|
5290
5084
|
super.onAdded(viewer);
|
|
5291
|
-
const importer = viewer.assetManager.importer;
|
|
5292
5085
|
const exporter = viewer.assetManager.exporter;
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5086
|
+
let glbExporter = exporter.getExporter("glb");
|
|
5087
|
+
this._lastExporter = glbExporter == null ? void 0 : glbExporter.ctor;
|
|
5088
|
+
if (!glbExporter) {
|
|
5089
|
+
console.error("GLTFDracoExportPlugin: GLB exporter not found in AssetManager.exporter, creating a new one.");
|
|
5090
|
+
glbExporter = {
|
|
5298
5091
|
ext: ["glb", "gltf"],
|
|
5299
|
-
extensions: []
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
// todo unregister on dispose
|
|
5307
|
-
importer.registerFile(tempFile)
|
|
5308
|
-
);
|
|
5309
|
-
ex.setup(viewer, _exporter.extensions);
|
|
5310
|
-
ex.createAndAddExtension(GLTFMaterialsBumpMapExtension.WebGiMaterialsBumpMapExtension, {
|
|
5311
|
-
bumpTexture: "R"
|
|
5312
|
-
});
|
|
5313
|
-
ex.createAndAddExtension(GLTFMaterialsLightMapExtension.WebGiMaterialsLightMapExtension, {
|
|
5314
|
-
lightMapTexture: "RGB"
|
|
5315
|
-
});
|
|
5316
|
-
ex.createAndAddExtension(GLTFMaterialsAlphaMapExtension.WebGiMaterialsAlphaMapExtension, {
|
|
5317
|
-
alphaTexture: "G"
|
|
5318
|
-
});
|
|
5319
|
-
ex.createAndAddExtension(GLTFMaterialsDisplacementMapExtension.WebGiMaterialsDisplacementMapExtension, {
|
|
5320
|
-
displacementTexture: "R"
|
|
5321
|
-
});
|
|
5322
|
-
ex.createAndAddExtension(CustomBumpMapPlugin.CUSTOM_BUMP_MAP_GLTF_EXTENSION, {
|
|
5323
|
-
customBumpMap: "RGB"
|
|
5324
|
-
});
|
|
5325
|
-
ex.createAndAddExtension(GLTFLightExtrasExtension.WebGiLightExtrasExtension);
|
|
5326
|
-
ex.createAndAddExtension(GLTFObject3DExtrasExtension.WebGiObject3DExtrasExtension);
|
|
5327
|
-
ex.createAndAddExtension(GLTFMaterialExtrasExtension.WebGiMaterialExtrasExtension);
|
|
5328
|
-
ex.createAndAddExtension(ClearcoatTintPlugin.CLEARCOAT_TINT_GLTF_EXTENSION);
|
|
5329
|
-
ex.createAndAddExtension(NoiseBumpMaterialPlugin.NOISE_BUMP_MATERIAL_GLTF_EXTENSION);
|
|
5330
|
-
return ex;
|
|
5331
|
-
}
|
|
5332
|
-
});
|
|
5092
|
+
extensions: [],
|
|
5093
|
+
ctor: this._ctor
|
|
5094
|
+
};
|
|
5095
|
+
exporter.addExporter(glbExporter);
|
|
5096
|
+
} else {
|
|
5097
|
+
glbExporter.ctor = this._ctor;
|
|
5098
|
+
}
|
|
5333
5099
|
const exportPlugin = viewer.getPlugin(AssetExporterPlugin);
|
|
5334
5100
|
if (exportPlugin) {
|
|
5335
5101
|
Object.assign(exportPlugin.exportOptions, {
|
|
@@ -5355,6 +5121,14 @@ const _GLTFDracoExportPlugin = class _GLTFDracoExportPlugin extends AViewerPlugi
|
|
|
5355
5121
|
}
|
|
5356
5122
|
}
|
|
5357
5123
|
}
|
|
5124
|
+
onRemove(viewer) {
|
|
5125
|
+
const exporter = viewer.assetManager.exporter;
|
|
5126
|
+
const glbExporter = exporter.getExporter("glb");
|
|
5127
|
+
if (glbExporter && this._lastExporter) {
|
|
5128
|
+
glbExporter.ctor = this._lastExporter;
|
|
5129
|
+
}
|
|
5130
|
+
super.onRemove(viewer);
|
|
5131
|
+
}
|
|
5358
5132
|
};
|
|
5359
5133
|
_GLTFDracoExportPlugin.PluginType = "GLTFDracoExportPlugin";
|
|
5360
5134
|
let GLTFDracoExportPlugin = _GLTFDracoExportPlugin;
|