@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/index.js CHANGED
@@ -3,8 +3,8 @@
3
3
  })(this, function(exports2, threepipe) {
4
4
  "use strict";/**
5
5
  * @license
6
- * @threepipe/plugin-gltf-transform v0.1.0
7
- * Copyright 2022-2024 repalash <palash@shaders.app>
6
+ * @threepipe/plugin-gltf-transform v0.1.3
7
+ * Copyright 2022-2025 repalash <palash@shaders.app>
8
8
  * Apache-2.0 License
9
9
  * See ./dependencies.txt for any bundled third-party dependencies and licenses.
10
10
  */
@@ -24,8 +24,7 @@
24
24
  return this;
25
25
  }
26
26
  removeEventListener(type, listener) {
27
- if (this._listeners === void 0)
28
- return this;
27
+ if (this._listeners === void 0) return this;
29
28
  const listeners = this._listeners;
30
29
  const listenerArray = listeners[type];
31
30
  if (listenerArray !== void 0) {
@@ -37,8 +36,7 @@
37
36
  return this;
38
37
  }
39
38
  dispatchEvent(event) {
40
- if (this._listeners === void 0)
41
- return this;
39
+ if (this._listeners === void 0) return this;
42
40
  const listeners = this._listeners;
43
41
  const listenerArray = listeners[event.type];
44
42
  if (listenerArray !== void 0) {
@@ -99,8 +97,7 @@
99
97
  }
100
98
  /** Destroys a (currently intact) edge, updating both the graph and the owner. */
101
99
  dispose() {
102
- if (this._disposed)
103
- return;
100
+ if (this._disposed) return;
104
101
  this._disposed = true;
105
102
  this.dispatchEvent({
106
103
  type: "dispose",
@@ -165,12 +162,10 @@
165
162
  _registerEdge(edge) {
166
163
  this._edges.add(edge);
167
164
  const parent = edge.getParent();
168
- if (!this._parentEdges.has(parent))
169
- this._parentEdges.set(parent, /* @__PURE__ */ new Set());
165
+ if (!this._parentEdges.has(parent)) this._parentEdges.set(parent, /* @__PURE__ */ new Set());
170
166
  this._parentEdges.get(parent).add(edge);
171
167
  const child = edge.getChild();
172
- if (!this._childEdges.has(child))
173
- this._childEdges.set(child, /* @__PURE__ */ new Set());
168
+ if (!this._childEdges.has(child)) this._childEdges.set(child, /* @__PURE__ */ new Set());
174
169
  this._childEdges.get(child).add(edge);
175
170
  edge.addEventListener("dispose", () => this._removeEdge(edge));
176
171
  return edge;
@@ -302,8 +297,7 @@
302
297
  * disposed object is not reusable.
303
298
  */
304
299
  dispose() {
305
- if (this._disposed)
306
- return;
300
+ if (this._disposed) return;
307
301
  this.graph.listChildEdges(this).forEach((edge) => edge.dispose());
308
302
  this.graph.disconnectParents(this);
309
303
  this._disposed = true;
@@ -382,10 +376,8 @@
382
376
  throw new Error(`Cannot overwrite immutable attribute, "${attribute}".`);
383
377
  }
384
378
  const prevRef = this[$attributes][attribute];
385
- if (prevRef)
386
- prevRef.dispose();
387
- if (!value)
388
- return this;
379
+ if (prevRef) prevRef.dispose();
380
+ if (!value) return this;
389
381
  const ref = this.graph.createEdge(attribute, this, value, attributes);
390
382
  ref.addEventListener("dispose", () => {
391
383
  delete this[$attributes][attribute];
@@ -455,10 +447,8 @@
455
447
  setRefMap(attribute, key, value, metadata) {
456
448
  const refMap = this[$attributes][attribute];
457
449
  const prevRef = refMap[key];
458
- if (prevRef)
459
- prevRef.dispose();
460
- if (!value)
461
- return this;
450
+ if (prevRef) prevRef.dispose();
451
+ if (!value) return this;
462
452
  metadata = Object.assign(metadata || {}, {
463
453
  key
464
454
  });
@@ -522,43 +512,36 @@
522
512
  }
523
513
  function T(t) {
524
514
  const e = { min: [Infinity, Infinity, Infinity], max: [-Infinity, -Infinity, -Infinity] }, r = t.propertyType === h.NODE ? [t] : t.listChildren();
525
- for (const t2 of r)
526
- t2.traverse((t3) => {
527
- const r2 = t3.getMesh();
528
- if (!r2)
529
- return;
530
- const s = x(r2, t3.getWorldMatrix());
531
- A$1(s.min, e), A$1(s.max, e);
532
- });
515
+ for (const t2 of r) t2.traverse((t3) => {
516
+ const r2 = t3.getMesh();
517
+ if (!r2) return;
518
+ const s = x(r2, t3.getWorldMatrix());
519
+ A$1(s.min, e), A$1(s.max, e);
520
+ });
533
521
  return e;
534
522
  }
535
523
  Math.hypot || (Math.hypot = function() {
536
- for (var t = 0, e = arguments.length; e--; )
537
- t += arguments[e] * arguments[e];
524
+ for (var t = 0, e = arguments.length; e--; ) t += arguments[e] * arguments[e];
538
525
  return Math.sqrt(t);
539
526
  }), m = new w$1(3), w$1 != Float32Array && (m[0] = 0, m[1] = 0, m[2] = 0);
540
527
  function x(t, e) {
541
528
  const r = { min: [Infinity, Infinity, Infinity], max: [-Infinity, -Infinity, -Infinity] };
542
529
  for (const s of t.listPrimitives()) {
543
530
  const t2 = s.getAttribute("POSITION");
544
- if (!t2)
545
- continue;
531
+ if (!t2) continue;
546
532
  let n = [0, 0, 0], i = [0, 0, 0];
547
- for (let s2 = 0; s2 < t2.getCount(); s2++)
548
- n = t2.getElement(s2, n), i = v$1(i, n, e), A$1(i, r);
533
+ for (let s2 = 0; s2 < t2.getCount(); s2++) n = t2.getElement(s2, n), i = v$1(i, n, e), A$1(i, r);
549
534
  }
550
535
  return r;
551
536
  }
552
537
  function A$1(t, e) {
553
- for (let r = 0; r < 3; r++)
554
- e.min[r] = Math.min(t[r], e.min[r]), e.max[r] = Math.max(t[r], e.max[r]);
538
+ 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]);
555
539
  }
556
540
  class E {
557
541
  static createBufferFromDataURI(t) {
558
542
  if ("undefined" == typeof Buffer) {
559
543
  const e = atob(t.split(",")[1]), r = new Uint8Array(e.length);
560
- for (let t2 = 0; t2 < e.length; t2++)
561
- r[t2] = e.charCodeAt(t2);
544
+ for (let t2 = 0; t2 < e.length; t2++) r[t2] = e.charCodeAt(t2);
562
545
  return r;
563
546
  }
564
547
  {
@@ -574,44 +557,34 @@
574
557
  }
575
558
  static concat(t) {
576
559
  let e = 0;
577
- for (const r2 of t)
578
- e += r2.byteLength;
560
+ for (const r2 of t) e += r2.byteLength;
579
561
  const r = new Uint8Array(e);
580
562
  let s = 0;
581
- for (const e2 of t)
582
- r.set(e2, s), s += e2.byteLength;
563
+ for (const e2 of t) r.set(e2, s), s += e2.byteLength;
583
564
  return r;
584
565
  }
585
566
  static pad(t, e = 0) {
586
567
  const r = this.padNumber(t.byteLength);
587
- if (r === t.byteLength)
588
- return t;
568
+ if (r === t.byteLength) return t;
589
569
  const s = new Uint8Array(r);
590
- if (s.set(t), 0 !== e)
591
- for (let n = t.byteLength; n < r; n++)
592
- s[n] = e;
570
+ if (s.set(t), 0 !== e) for (let n = t.byteLength; n < r; n++) s[n] = e;
593
571
  return s;
594
572
  }
595
573
  static padNumber(t) {
596
574
  return 4 * Math.ceil(t / 4);
597
575
  }
598
576
  static equals(t, e) {
599
- if (t === e)
600
- return true;
601
- if (t.byteLength !== e.byteLength)
602
- return false;
577
+ if (t === e) return true;
578
+ if (t.byteLength !== e.byteLength) return false;
603
579
  let r = t.byteLength;
604
- for (; r--; )
605
- if (t[r] !== e[r])
606
- return false;
580
+ for (; r--; ) if (t[r] !== e[r]) return false;
607
581
  return true;
608
582
  }
609
583
  static toView(t, e = 0, r = Infinity) {
610
584
  return new Uint8Array(t.buffer, t.byteOffset + e, Math.min(t.byteLength, r));
611
585
  }
612
586
  static assertView(t) {
613
- if (t && !ArrayBuffer.isView(t))
614
- throw new Error(`Method requires Uint8Array parameter; received "${typeof t}".`);
587
+ if (t && !ArrayBuffer.isView(t)) throw new Error(`Method requires Uint8Array parameter; received "${typeof t}".`);
615
588
  return t;
616
589
  }
617
590
  }
@@ -627,14 +600,12 @@
627
600
  }
628
601
  static convertSRGBToLinear(t, e) {
629
602
  const r = t, s = e;
630
- for (let t2 = 0; t2 < 3; t2++)
631
- s[t2] = r[t2] < 0.04045 ? 0.0773993808 * r[t2] : Math.pow(0.9478672986 * r[t2] + 0.0521327014, 2.4);
603
+ 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);
632
604
  return e;
633
605
  }
634
606
  static convertLinearToSRGB(t, e) {
635
607
  const r = t, s = e;
636
- for (let t2 = 0; t2 < 3; t2++)
637
- s[t2] = r[t2] < 31308e-7 ? 12.92 * r[t2] : 1.055 * Math.pow(r[t2], 0.41666) - 0.055;
608
+ 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;
638
609
  return e;
639
610
  }
640
611
  };
@@ -656,9 +627,7 @@
656
627
  this.impls[t] = e;
657
628
  }
658
629
  static getMimeType(t) {
659
- for (const e in this.impls)
660
- if (this.impls[e].match(t))
661
- return e;
630
+ for (const e in this.impls) if (this.impls[e].match(t)) return e;
662
631
  return null;
663
632
  }
664
633
  static getSize(t, e) {
@@ -668,16 +637,12 @@
668
637
  return this.impls[e] ? this.impls[e].getChannels(t) : null;
669
638
  }
670
639
  static getVRAMByteLength(t, e) {
671
- if (!this.impls[e])
672
- return null;
673
- if (this.impls[e].getVRAMByteLength)
674
- return this.impls[e].getVRAMByteLength(t);
640
+ if (!this.impls[e]) return null;
641
+ if (this.impls[e].getVRAMByteLength) return this.impls[e].getVRAMByteLength(t);
675
642
  let r = 0;
676
643
  const s = this.getSize(t, e);
677
- if (!s)
678
- return null;
679
- for (; s[0] > 1 || s[1] > 1; )
680
- 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);
644
+ if (!s) return null;
645
+ 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);
681
646
  return r += 4, r;
682
647
  }
683
648
  static mimeTypeToExtension(t) {
@@ -688,10 +653,8 @@
688
653
  }
689
654
  }
690
655
  function R$1(t, e) {
691
- if (e > t.byteLength)
692
- throw new TypeError("Corrupt JPG, exceeded buffer limits");
693
- if (255 !== t.getUint8(e))
694
- throw new TypeError("Invalid JPG, marker table corrupted");
656
+ if (e > t.byteLength) throw new TypeError("Corrupt JPG, exceeded buffer limits");
657
+ if (255 !== t.getUint8(e)) throw new TypeError("Invalid JPG, marker table corrupted");
695
658
  return t;
696
659
  }
697
660
  I.impls = { "image/jpeg": new class {
@@ -701,8 +664,7 @@
701
664
  getSize(t) {
702
665
  let e, r, s = new DataView(t.buffer, t.byteOffset + 4);
703
666
  for (; s.byteLength; ) {
704
- if (e = s.getUint16(0, false), R$1(s, e), r = s.getUint8(e + 1), 192 === r || 193 === r || 194 === r)
705
- return [s.getUint16(e + 7, false), s.getUint16(e + 5, false)];
667
+ 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)];
706
668
  s = new DataView(t.buffer, s.byteOffset + e + 2);
707
669
  }
708
670
  throw new TypeError("Invalid JPG, no size found");
@@ -728,11 +690,9 @@
728
690
  return "[object Object]" === Object.prototype.toString.call(t);
729
691
  }
730
692
  function C$1(t) {
731
- if (false === O$1(t))
732
- return false;
693
+ if (false === O$1(t)) return false;
733
694
  const e = t.constructor;
734
- if (void 0 === e)
735
- return true;
695
+ if (void 0 === e) return true;
736
696
  const r = e.prototype;
737
697
  return false !== O$1(r) && false !== Object.prototype.hasOwnProperty.call(r, "isPrototypeOf");
738
698
  }
@@ -767,11 +727,8 @@
767
727
  return t;
768
728
  }
769
729
  static eq(t, e, r = 1e-5) {
770
- if (t.length !== e.length)
771
- return false;
772
- for (let s = 0; s < t.length; s++)
773
- if (Math.abs(t[s] - e[s]) > r)
774
- return false;
730
+ if (t.length !== e.length) return false;
731
+ for (let s = 0; s < t.length; s++) if (Math.abs(t[s] - e[s]) > r) return false;
775
732
  return true;
776
733
  }
777
734
  static decodeNormalizedInt(t, e) {
@@ -834,76 +791,54 @@
834
791
  }
835
792
  };
836
793
  function L$1(t, e) {
837
- if (!!t != !!e)
838
- return false;
794
+ if (!!t != !!e) return false;
839
795
  const r = t.getChild(), s = e.getChild();
840
796
  return r === s || r.equals(s);
841
797
  }
842
798
  function j$1(t, e) {
843
- if (!!t != !!e)
844
- return false;
845
- if (t.length !== e.length)
846
- return false;
799
+ if (!!t != !!e) return false;
800
+ if (t.length !== e.length) return false;
847
801
  for (let r = 0; r < t.length; r++) {
848
802
  const s = t[r], n = e[r];
849
- if (s.getChild() !== n.getChild() && !s.getChild().equals(n.getChild()))
850
- return false;
803
+ if (s.getChild() !== n.getChild() && !s.getChild().equals(n.getChild())) return false;
851
804
  }
852
805
  return true;
853
806
  }
854
807
  function D$1(t, e) {
855
- if (!!t != !!e)
856
- return false;
808
+ if (!!t != !!e) return false;
857
809
  const r = Object.keys(t), s = Object.keys(e);
858
- if (r.length !== s.length)
859
- return false;
810
+ if (r.length !== s.length) return false;
860
811
  for (const r2 in t) {
861
812
  const s2 = t[r2], n = e[r2];
862
- if (!!s2 != !!n)
863
- return false;
813
+ if (!!s2 != !!n) return false;
864
814
  const i = s2.getChild(), o = n.getChild();
865
- if (i !== o && !i.equals(o))
866
- return false;
815
+ if (i !== o && !i.equals(o)) return false;
867
816
  }
868
817
  return true;
869
818
  }
870
819
  function _$1(t, e) {
871
- if (t === e)
872
- return true;
873
- if (!!t != !!e || !t || !e)
874
- return false;
875
- if (t.length !== e.length)
876
- return false;
877
- for (let r = 0; r < t.length; r++)
878
- if (t[r] !== e[r])
879
- return false;
820
+ if (t === e) return true;
821
+ if (!!t != !!e || !t || !e) return false;
822
+ if (t.length !== e.length) return false;
823
+ for (let r = 0; r < t.length; r++) if (t[r] !== e[r]) return false;
880
824
  return true;
881
825
  }
882
826
  function k$1(t, e) {
883
- if (t === e)
884
- return true;
885
- if (!!t != !!e)
886
- return false;
887
- if (!C$1(t) || !C$1(e))
888
- return t === e;
827
+ if (t === e) return true;
828
+ if (!!t != !!e) return false;
829
+ if (!C$1(t) || !C$1(e)) return t === e;
889
830
  const r = t, s = e;
890
831
  let n, i = 0, o = 0;
891
- for (n in r)
892
- i++;
893
- for (n in s)
894
- o++;
895
- if (i !== o)
896
- return false;
832
+ for (n in r) i++;
833
+ for (n in s) o++;
834
+ if (i !== o) return false;
897
835
  for (n in r) {
898
836
  const t2 = r[n], e2 = s[n];
899
837
  if (z$1(t2) && z$1(e2)) {
900
- if (!_$1(t2, e2))
901
- return false;
838
+ if (!_$1(t2, e2)) return false;
902
839
  } else if (C$1(t2) && C$1(e2)) {
903
- if (!k$1(t2, e2))
904
- return false;
905
- } else if (t2 !== e2)
906
- return false;
840
+ if (!k$1(t2, e2)) return false;
841
+ } else if (t2 !== e2) return false;
907
842
  }
908
843
  return true;
909
844
  }
@@ -912,14 +847,12 @@
912
847
  }
913
848
  const G$1 = "23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ", J$1 = /* @__PURE__ */ new Set(), $$1 = function() {
914
849
  let t = "";
915
- for (let e = 0; e < 6; e++)
916
- t += G$1.charAt(Math.floor(Math.random() * G$1.length));
850
+ for (let e = 0; e < 6; e++) t += G$1.charAt(Math.floor(Math.random() * G$1.length));
917
851
  return t;
918
852
  }, V$1 = function() {
919
853
  for (let t = 0; t < 999; t++) {
920
854
  const t2 = $$1();
921
- if (!J$1.has(t2))
922
- return J$1.add(t2), t2;
855
+ if (!J$1.has(t2)) return J$1.add(t2), t2;
923
856
  }
924
857
  return "";
925
858
  };
@@ -935,12 +868,10 @@
935
868
  return N$1.extension(new URL(t, "https://null.example").pathname);
936
869
  }
937
870
  static resolve(t, e) {
938
- if (!this.isRelativePath(e))
939
- return e;
871
+ if (!this.isRelativePath(e)) return e;
940
872
  const r = t.split("/"), s = e.split("/");
941
873
  r.pop();
942
- for (let t2 = 0; t2 < s.length; t2++)
943
- "." !== s[t2] && (".." === s[t2] ? r.pop() : r.push(s[t2]));
874
+ for (let t2 = 0; t2 < s.length; t2++) "." !== s[t2] && (".." === s[t2] ? r.pop() : r.push(s[t2]));
944
875
  return r.join("/");
945
876
  }
946
877
  static isAbsoluteURL(t) {
@@ -983,58 +914,39 @@
983
914
  copy(t, o = q$1) {
984
915
  for (const t2 in this[$attributes]) {
985
916
  const o2 = this[$attributes][t2];
986
- if (o2 instanceof GraphEdge)
987
- this[$immutableKeys].has(t2) || o2.dispose();
988
- else if (isRefList(o2))
989
- for (const t3 of o2)
990
- t3.dispose();
991
- else if (isRefMap(o2))
992
- for (const t3 in o2)
993
- o2[t3].dispose();
917
+ if (o2 instanceof GraphEdge) this[$immutableKeys].has(t2) || o2.dispose();
918
+ else if (isRefList(o2)) for (const t3 of o2) t3.dispose();
919
+ else if (isRefMap(o2)) for (const t3 in o2) o2[t3].dispose();
994
920
  }
995
921
  for (const a in t[$attributes]) {
996
922
  const u = this[$attributes][a], c2 = t[$attributes][a];
997
- if (c2 instanceof GraphEdge)
998
- this[$immutableKeys].has(a) ? u.getChild().copy(o(c2.getChild()), o) : this.setRef(a, o(c2.getChild()), c2.getAttributes());
999
- else if (isRefList(c2))
1000
- for (const t2 of c2)
1001
- this.addRef(a, o(t2.getChild()), t2.getAttributes());
1002
- else if (isRefMap(c2))
1003
- for (const t2 in c2) {
1004
- const e = c2[t2];
1005
- this.setRefMap(a, t2, o(e.getChild()), e.getAttributes());
1006
- }
1007
- else
1008
- this[$attributes][a] = C$1(c2) ? JSON.parse(JSON.stringify(c2)) : Array.isArray(c2) || c2 instanceof ArrayBuffer || ArrayBuffer.isView(c2) ? c2.slice() : c2;
923
+ if (c2 instanceof GraphEdge) this[$immutableKeys].has(a) ? u.getChild().copy(o(c2.getChild()), o) : this.setRef(a, o(c2.getChild()), c2.getAttributes());
924
+ else if (isRefList(c2)) for (const t2 of c2) this.addRef(a, o(t2.getChild()), t2.getAttributes());
925
+ else if (isRefMap(c2)) for (const t2 in c2) {
926
+ const e = c2[t2];
927
+ this.setRefMap(a, t2, o(e.getChild()), e.getAttributes());
928
+ }
929
+ else this[$attributes][a] = C$1(c2) ? JSON.parse(JSON.stringify(c2)) : Array.isArray(c2) || c2 instanceof ArrayBuffer || ArrayBuffer.isView(c2) ? c2.slice() : c2;
1009
930
  }
1010
931
  return this;
1011
932
  }
1012
933
  equals(t, r = H$1) {
1013
- if (this === t)
1014
- return true;
1015
- if (this.propertyType !== t.propertyType)
1016
- return false;
934
+ if (this === t) return true;
935
+ if (this.propertyType !== t.propertyType) return false;
1017
936
  for (const s in this[$attributes]) {
1018
- if (r.has(s))
1019
- continue;
937
+ if (r.has(s)) continue;
1020
938
  const a = this[$attributes][s], u = t[$attributes][s];
1021
939
  if (isRef(a) || isRef(u)) {
1022
- if (!L$1(a, u))
1023
- return false;
940
+ if (!L$1(a, u)) return false;
1024
941
  } else if (isRefList(a) || isRefList(u)) {
1025
- if (!j$1(a, u))
1026
- return false;
942
+ if (!j$1(a, u)) return false;
1027
943
  } else if (isRefMap(a) || isRefMap(u)) {
1028
- if (!D$1(a, u))
1029
- return false;
944
+ if (!D$1(a, u)) return false;
1030
945
  } else if (C$1(a) || C$1(u)) {
1031
- if (!k$1(a, u))
1032
- return false;
946
+ if (!k$1(a, u)) return false;
1033
947
  } else if (z$1(a) || z$1(u)) {
1034
- if (!_$1(a, u))
1035
- return false;
1036
- } else if (a !== u)
1037
- return false;
948
+ if (!_$1(a, u)) return false;
949
+ } else if (a !== u) return false;
1038
950
  }
1039
951
  return true;
1040
952
  }
@@ -1109,37 +1021,31 @@
1109
1021
  getMinNormalized(t) {
1110
1022
  const e = this.getElementSize();
1111
1023
  this.getMin(t);
1112
- for (let r = 0; r < e; r++)
1113
- t[r] = this.o(t[r]);
1024
+ for (let r = 0; r < e; r++) t[r] = this.o(t[r]);
1114
1025
  return t;
1115
1026
  }
1116
1027
  getMin(t) {
1117
1028
  const e = this.get("array"), r = this.getCount(), s = this.getElementSize();
1118
- for (let e2 = 0; e2 < s; e2++)
1119
- t[e2] = Infinity;
1120
- for (let n = 0; n < r * s; n += s)
1121
- for (let r2 = 0; r2 < s; r2++) {
1122
- const s2 = e[n + r2];
1123
- Number.isFinite(s2) && (t[r2] = Math.min(t[r2], s2));
1124
- }
1029
+ for (let e2 = 0; e2 < s; e2++) t[e2] = Infinity;
1030
+ for (let n = 0; n < r * s; n += s) for (let r2 = 0; r2 < s; r2++) {
1031
+ const s2 = e[n + r2];
1032
+ Number.isFinite(s2) && (t[r2] = Math.min(t[r2], s2));
1033
+ }
1125
1034
  return t;
1126
1035
  }
1127
1036
  getMaxNormalized(t) {
1128
1037
  const e = this.getElementSize();
1129
1038
  this.getMax(t);
1130
- for (let r = 0; r < e; r++)
1131
- t[r] = this.o(t[r]);
1039
+ for (let r = 0; r < e; r++) t[r] = this.o(t[r]);
1132
1040
  return t;
1133
1041
  }
1134
1042
  getMax(t) {
1135
1043
  const e = this.get("array"), r = this.getCount(), s = this.getElementSize();
1136
- for (let e2 = 0; e2 < s; e2++)
1137
- t[e2] = -Infinity;
1138
- for (let n = 0; n < r * s; n += s)
1139
- for (let r2 = 0; r2 < s; r2++) {
1140
- const s2 = e[n + r2];
1141
- Number.isFinite(s2) && (t[r2] = Math.max(t[r2], s2));
1142
- }
1044
+ for (let e2 = 0; e2 < s; e2++) t[e2] = -Infinity;
1045
+ for (let n = 0; n < r * s; n += s) for (let r2 = 0; r2 < s; r2++) {
1046
+ const s2 = e[n + r2];
1047
+ Number.isFinite(s2) && (t[r2] = Math.max(t[r2], s2));
1048
+ }
1143
1049
  return t;
1144
1050
  }
1145
1051
  getCount() {
@@ -1176,14 +1082,12 @@
1176
1082
  }
1177
1083
  getElement(t, e) {
1178
1084
  const r = this.getElementSize(), s = this.get("array");
1179
- for (let n = 0; n < r; n++)
1180
- e[n] = this.o(s[t * r + n]);
1085
+ for (let n = 0; n < r; n++) e[n] = this.o(s[t * r + n]);
1181
1086
  return e;
1182
1087
  }
1183
1088
  setElement(t, e) {
1184
1089
  const r = this.getElementSize(), s = this.get("array");
1185
- for (let n = 0; n < r; n++)
1186
- s[t * r + n] = this.i(e[n]);
1090
+ for (let n = 0; n < r; n++) s[t * r + n] = this.i(e[n]);
1187
1091
  return this;
1188
1092
  }
1189
1093
  getSparse() {
@@ -1374,8 +1278,7 @@
1374
1278
  rt$1.Type = { PERSPECTIVE: "perspective", ORTHOGRAPHIC: "orthographic" };
1375
1279
  let st$1 = class st extends Y$1 {
1376
1280
  t(t) {
1377
- if (!this.parentTypes.includes(t.propertyType))
1378
- throw new Error(`Parent "${t.propertyType}" invalid for child "${this.propertyType}".`);
1281
+ if (!this.parentTypes.includes(t.propertyType)) throw new Error(`Parent "${t.propertyType}" invalid for child "${this.propertyType}".`);
1379
1282
  }
1380
1283
  };
1381
1284
  st$1.EXTENSION_NAME = void 0;
@@ -1582,8 +1485,7 @@
1582
1485
  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: [] });
1583
1486
  }
1584
1487
  copy(t, e = q$1) {
1585
- if (e === q$1)
1586
- throw new Error("Node cannot be copied.");
1488
+ if (e === q$1) throw new Error("Node cannot be copied.");
1587
1489
  return super.copy(t, e);
1588
1490
  }
1589
1491
  getTranslation() {
@@ -1625,12 +1527,10 @@
1625
1527
  }
1626
1528
  getWorldMatrix() {
1627
1529
  const t = [];
1628
- for (let e2 = this; null != e2; e2 = e2.u)
1629
- t.push(e2);
1530
+ for (let e2 = this; null != e2; e2 = e2.u) t.push(e2);
1630
1531
  let e;
1631
1532
  const r = t.pop().getMatrix();
1632
- for (; e = t.pop(); )
1633
- B$1(r, r, e.getMatrix());
1533
+ for (; e = t.pop(); ) B$1(r, r, e.getMatrix());
1634
1534
  return r;
1635
1535
  }
1636
1536
  addChild(t) {
@@ -1676,8 +1576,7 @@
1676
1576
  }
1677
1577
  traverse(t) {
1678
1578
  t(this);
1679
- for (const e of this.listChildren())
1680
- e.traverse(t);
1579
+ for (const e of this.listChildren()) e.traverse(t);
1681
1580
  return this;
1682
1581
  }
1683
1582
  };
@@ -1753,8 +1652,7 @@
1753
1652
  return (gt$1 = Object.assign || function(t) {
1754
1653
  for (var e = 1; e < arguments.length; e++) {
1755
1654
  var r = arguments[e];
1756
- for (var s in r)
1757
- Object.prototype.hasOwnProperty.call(r, s) && (t[s] = r[s]);
1655
+ for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (t[s] = r[s]);
1758
1656
  }
1759
1657
  return t;
1760
1658
  }).apply(this, arguments);
@@ -1767,8 +1665,7 @@
1767
1665
  return Object.assign(super.getDefaults(), { children: [] });
1768
1666
  }
1769
1667
  copy(t, e = q$1) {
1770
- if (e === q$1)
1771
- throw new Error("Scene cannot be copied.");
1668
+ if (e === q$1) throw new Error("Scene cannot be copied.");
1772
1669
  return super.copy(t, e);
1773
1670
  }
1774
1671
  addChild(t) {
@@ -1781,8 +1678,7 @@
1781
1678
  return this.listRefs("children");
1782
1679
  }
1783
1680
  traverse(t) {
1784
- for (const e of this.listChildren())
1785
- e.traverse(t);
1681
+ for (const e of this.listChildren()) e.traverse(t);
1786
1682
  return this;
1787
1683
  }
1788
1684
  };
@@ -1863,8 +1759,7 @@
1863
1759
  throw new Error("Root cannot be cloned.");
1864
1760
  }
1865
1761
  copy(t, e = q$1) {
1866
- if (e === q$1)
1867
- throw new Error("Root cannot be copied.");
1762
+ if (e === q$1) throw new Error("Root cannot be copied.");
1868
1763
  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);
1869
1764
  for (const r of t.listRefMapKeys("extensions")) {
1870
1765
  const s = t.getExtension(r);
@@ -1956,31 +1851,26 @@
1956
1851
  }
1957
1852
  const e = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
1958
1853
  e.add(t.T), r.set(t.T, this.T);
1959
- for (const s2 of t.v.listEdges())
1960
- for (const t2 of [s2.getParent(), s2.getChild()]) {
1961
- if (e.has(t2))
1962
- continue;
1963
- let s3;
1964
- s3 = t2.propertyType === h.TEXTURE_INFO ? t2 : new t2.constructor(this.v), r.set(t2, s3), e.add(t2);
1965
- }
1854
+ for (const s2 of t.v.listEdges()) for (const t2 of [s2.getParent(), s2.getChild()]) {
1855
+ if (e.has(t2)) continue;
1856
+ let s3;
1857
+ s3 = t2.propertyType === h.TEXTURE_INFO ? t2 : new t2.constructor(this.v), r.set(t2, s3), e.add(t2);
1858
+ }
1966
1859
  const s = (t2) => {
1967
1860
  const e2 = r.get(t2);
1968
- if (!e2)
1969
- throw new Error("Could resolve property.");
1861
+ if (!e2) throw new Error("Could resolve property.");
1970
1862
  return e2;
1971
1863
  };
1972
1864
  for (const t2 of e) {
1973
1865
  const e2 = r.get(t2);
1974
- if (!e2)
1975
- throw new Error("Could resolve property.");
1866
+ if (!e2) throw new Error("Could resolve property.");
1976
1867
  e2.propertyType !== h.TEXTURE_INFO && e2.copy(t2, s);
1977
1868
  }
1978
1869
  return this;
1979
1870
  }
1980
1871
  async transform(...t) {
1981
1872
  const e = t.map((t2) => t2.name);
1982
- for (const r of t)
1983
- await r(this, { stack: e });
1873
+ for (const r of t) await r(this, { stack: e });
1984
1874
  return this;
1985
1875
  }
1986
1876
  createExtension(t) {
@@ -2044,8 +1934,7 @@
2044
1934
  this.document.getRoot().p(this);
2045
1935
  const t = this.document.getGraph();
2046
1936
  t.removeEventListener("node:create", this.S), t.removeEventListener("node:dispose", this.S);
2047
- for (const t2 of this.properties)
2048
- t2.dispose();
1937
+ for (const t2 of this.properties) t2.dispose();
2049
1938
  }
2050
1939
  static register() {
2051
1940
  }
@@ -2082,8 +1971,7 @@
2082
1971
  setTextureInfo(t, e) {
2083
1972
  this.textureInfos.set(t, e), void 0 !== e.texCoord && t.setTexCoord(e.texCoord), void 0 !== e.extras && t.setExtras(e.extras);
2084
1973
  const r = this.jsonDoc.json.textures[e.index];
2085
- if (void 0 === r.sampler)
2086
- return;
1974
+ if (void 0 === r.sampler) return;
2087
1975
  const s = this.jsonDoc.json.samplers[r.sampler];
2088
1976
  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);
2089
1977
  }
@@ -2091,39 +1979,37 @@
2091
1979
  const xt$1 = { logger: U$1.DEFAULT_INSTANCE, extensions: [], dependencies: {} };
2092
1980
  function At$1(t, e) {
2093
1981
  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;
2094
- if (void 0 !== s.byteStride && s.byteStride !== i * o)
2095
- return function(t2, e2) {
2096
- 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;
2097
- for (let e3 = 0; e3 < t2.count; e3++)
2098
- for (let r3 = 0; r3 < i2; r3++) {
2099
- const s3 = a2 + e3 * h2 + r3 * o2;
2100
- let n3;
2101
- switch (t2.componentType) {
2102
- case K$1.ComponentType.FLOAT:
2103
- n3 = c2.getFloat32(s3, true);
2104
- break;
2105
- case K$1.ComponentType.UNSIGNED_INT:
2106
- n3 = c2.getUint32(s3, true);
2107
- break;
2108
- case K$1.ComponentType.UNSIGNED_SHORT:
2109
- n3 = c2.getUint16(s3, true);
2110
- break;
2111
- case K$1.ComponentType.UNSIGNED_BYTE:
2112
- n3 = c2.getUint8(s3);
2113
- break;
2114
- case K$1.ComponentType.SHORT:
2115
- n3 = c2.getInt16(s3, true);
2116
- break;
2117
- case K$1.ComponentType.BYTE:
2118
- n3 = c2.getInt8(s3);
2119
- break;
2120
- default:
2121
- throw new Error(`Unexpected componentType "${t2.componentType}".`);
2122
- }
2123
- u[e3 * i2 + r3] = n3;
2124
- }
2125
- return u;
2126
- }(t, e);
1982
+ if (void 0 !== s.byteStride && s.byteStride !== i * o) return function(t2, e2) {
1983
+ 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;
1984
+ for (let e3 = 0; e3 < t2.count; e3++) for (let r3 = 0; r3 < i2; r3++) {
1985
+ const s3 = a2 + e3 * h2 + r3 * o2;
1986
+ let n3;
1987
+ switch (t2.componentType) {
1988
+ case K$1.ComponentType.FLOAT:
1989
+ n3 = c2.getFloat32(s3, true);
1990
+ break;
1991
+ case K$1.ComponentType.UNSIGNED_INT:
1992
+ n3 = c2.getUint32(s3, true);
1993
+ break;
1994
+ case K$1.ComponentType.UNSIGNED_SHORT:
1995
+ n3 = c2.getUint16(s3, true);
1996
+ break;
1997
+ case K$1.ComponentType.UNSIGNED_BYTE:
1998
+ n3 = c2.getUint8(s3);
1999
+ break;
2000
+ case K$1.ComponentType.SHORT:
2001
+ n3 = c2.getInt16(s3, true);
2002
+ break;
2003
+ case K$1.ComponentType.BYTE:
2004
+ n3 = c2.getInt8(s3);
2005
+ break;
2006
+ default:
2007
+ throw new Error(`Unexpected componentType "${t2.componentType}".`);
2008
+ }
2009
+ u[e3 * i2 + r3] = n3;
2010
+ }
2011
+ return u;
2012
+ }(t, e);
2127
2013
  const a = r.byteOffset + (t.byteOffset || 0);
2128
2014
  return new n(r.buffer.slice(a, a + t.count * i * o));
2129
2015
  }
@@ -2157,8 +2043,7 @@
2157
2043
  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;
2158
2044
  }
2159
2045
  createImageData(t, e, r) {
2160
- if (this.options.format === g.GLB)
2161
- this.imageBufferViews.push(e), t.bufferView = this.jsonDoc.json.bufferViews.length, this.jsonDoc.json.bufferViews.push({ buffer: 0, byteOffset: -1, byteLength: e.byteLength });
2046
+ 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 });
2162
2047
  else {
2163
2048
  const s = I.mimeTypeToExtension(r.getMimeType());
2164
2049
  t.uri = this.imageURIGenerator.createURI(r, s), this.jsonDoc.resources[t.uri] = e;
@@ -2166,28 +2051,23 @@
2166
2051
  }
2167
2052
  getAccessorUsage(t) {
2168
2053
  const e = this.C.get(t);
2169
- if (e)
2170
- return e;
2171
- if (t.getSparse())
2172
- return l.SPARSE;
2054
+ if (e) return e;
2055
+ if (t.getSparse()) return l.SPARSE;
2173
2056
  for (const e2 of this.O.getGraph().listParentEdges(t)) {
2174
2057
  const { usage: t2 } = e2.getAttributes();
2175
- if (t2)
2176
- return t2;
2058
+ if (t2) return t2;
2177
2059
  e2.getParent().propertyType !== h.ROOT && this.logger.warn(`Missing attribute ".usage" on edge, "${e2.getName()}".`);
2178
2060
  }
2179
2061
  return l.OTHER;
2180
2062
  }
2181
2063
  addAccessorToUsageGroup(t, e) {
2182
2064
  const r = this.C.get(t);
2183
- if (r && r !== e)
2184
- throw new Error(`Accessor with usage "${r}" cannot be reused as "${e}".`);
2065
+ if (r && r !== e) throw new Error(`Accessor with usage "${r}" cannot be reused as "${e}".`);
2185
2066
  return this.C.set(t, e), this;
2186
2067
  }
2187
2068
  listAccessorUsageGroups() {
2188
2069
  const t = {};
2189
- for (const [e, r] of Array.from(this.C.entries()))
2190
- t[r] = t[r] || [], t[r].push(e);
2070
+ for (const [e, r] of Array.from(this.C.entries())) t[r] = t[r] || [], t[r].push(e);
2191
2071
  return t;
2192
2072
  }
2193
2073
  };
@@ -2197,8 +2077,7 @@
2197
2077
  this.multiple = void 0, this.basename = void 0, this.counter = {}, this.multiple = t, this.basename = e;
2198
2078
  }
2199
2079
  createURI(t, e) {
2200
- if (t.getURI())
2201
- return t.getURI();
2080
+ if (t.getURI()) return t.getURI();
2202
2081
  if (this.multiple) {
2203
2082
  const r = this.basename(t);
2204
2083
  return this.counter[r] = this.counter[r] || 1, `${r}_${this.counter[r]++}.${e}`;
@@ -2219,8 +2098,7 @@
2219
2098
  return this.M = t, this;
2220
2099
  }
2221
2100
  registerExtensions(t) {
2222
- for (const e of t)
2223
- this.h.add(e), e.register();
2101
+ for (const e of t) this.h.add(e), e.register();
2224
2102
  return this;
2225
2103
  }
2226
2104
  registerDependencies(t) {
@@ -2246,12 +2124,10 @@
2246
2124
  const i = new bt$1(t2), o = s.asset, a = n.getRoot().getAsset();
2247
2125
  o.copyright && (a.copyright = o.copyright), o.extras && (a.extras = o.extras), void 0 !== s.extras && n.getRoot().setExtras(gt$1({}, s.extras));
2248
2126
  const u = s.extensionsUsed || [], c2 = s.extensionsRequired || [];
2249
- for (const t3 of r.extensions)
2250
- if (u.includes(t3.EXTENSION_NAME)) {
2251
- const e2 = n.createExtension(t3).setRequired(c2.includes(t3.EXTENSION_NAME));
2252
- for (const t4 of e2.readDependencies)
2253
- e2.install(t4, r.dependencies[t4]);
2254
- }
2127
+ for (const t3 of r.extensions) if (u.includes(t3.EXTENSION_NAME)) {
2128
+ const e2 = n.createExtension(t3).setRequired(c2.includes(t3.EXTENSION_NAME));
2129
+ for (const t4 of e2.readDependencies) e2.install(t4, r.dependencies[t4]);
2130
+ }
2255
2131
  const f2 = s.buffers || [];
2256
2132
  n.getRoot().listExtensionsUsed().filter((t3) => t3.prereadTypes.includes(h.BUFFER)).forEach((t3) => t3.preread(i, h.BUFFER)), i.buffers = f2.map((t3) => {
2257
2133
  const e2 = n.createBuffer(t3.name);
@@ -2274,10 +2150,8 @@
2274
2150
  if (e2.extras && r2.setExtras(e2.extras), void 0 !== e2.bufferView) {
2275
2151
  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);
2276
2152
  r2.setImage(a2);
2277
- } else
2278
- void 0 !== e2.uri && (r2.setImage(t2.resources[e2.uri]), 0 !== e2.uri.indexOf("__") && r2.setURI(e2.uri));
2279
- if (void 0 !== e2.mimeType)
2280
- r2.setMimeType(e2.mimeType);
2153
+ } else void 0 !== e2.uri && (r2.setImage(t2.resources[e2.uri]), 0 !== e2.uri.indexOf("__") && r2.setURI(e2.uri));
2154
+ if (void 0 !== e2.mimeType) r2.setMimeType(e2.mimeType);
2281
2155
  else if (e2.uri) {
2282
2156
  const t3 = N$1.extension(e2.uri);
2283
2157
  r2.setMimeType(I.extensionToMimeType(t3));
@@ -2315,14 +2189,12 @@
2315
2189
  return t3.extras && e2.setExtras(t3.extras), void 0 !== t3.weights && e2.setWeights(t3.weights), (t3.primitives || []).forEach((r2) => {
2316
2190
  const s2 = n.createPrimitive();
2317
2191
  r2.extras && s2.setExtras(r2.extras), void 0 !== r2.material && s2.setMaterial(i.materials[r2.material]), void 0 !== r2.mode && s2.setMode(r2.mode);
2318
- for (const [t4, e3] of Object.entries(r2.attributes || {}))
2319
- s2.setAttribute(t4, i.accessors[e3]);
2192
+ for (const [t4, e3] of Object.entries(r2.attributes || {})) s2.setAttribute(t4, i.accessors[e3]);
2320
2193
  void 0 !== r2.indices && s2.setIndices(i.accessors[r2.indices]);
2321
2194
  const o2 = t3.extras && t3.extras.targetNames || [];
2322
2195
  (r2.targets || []).forEach((t4, e3) => {
2323
2196
  const r3 = o2[e3] || e3.toString(), a2 = n.createPrimitiveTarget(r3);
2324
- for (const [e4, r4] of Object.entries(t4))
2325
- a2.setAttribute(e4, i.accessors[r4]);
2197
+ for (const [e4, r4] of Object.entries(t4)) a2.setAttribute(e4, i.accessors[r4]);
2326
2198
  s2.addTarget(a2);
2327
2199
  }), e2.addPrimitive(s2);
2328
2200
  }), e2;
@@ -2348,8 +2220,7 @@
2348
2220
  }), i.skins = (s.skins || []).map((t3) => {
2349
2221
  const e2 = n.createSkin(t3.name);
2350
2222
  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]);
2351
- for (const r2 of t3.joints)
2352
- e2.addJoint(i.nodes[r2]);
2223
+ for (const r2 of t3.joints) e2.addJoint(i.nodes[r2]);
2353
2224
  return e2;
2354
2225
  }), w2.map((t3, e2) => {
2355
2226
  const r2 = i.nodes[e2];
@@ -2377,28 +2248,20 @@
2377
2248
  let n3;
2378
2249
  n3 = void 0 !== t4.bufferView ? At$1(t4, e3) : new r3(t4.count * s3);
2379
2250
  const i2 = t4.sparse;
2380
- if (!i2)
2381
- return n3;
2251
+ if (!i2) return n3;
2382
2252
  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);
2383
- for (let t5 = 0; t5 < a2.count; t5++)
2384
- for (let e4 = 0; e4 < s3; e4++)
2385
- n3[c3[t5] * s3 + e4] = h2[t5 * s3 + e4];
2253
+ for (let t5 = 0; t5 < a2.count; t5++) for (let e4 = 0; e4 < s3; e4++) n3[c3[t5] * s3 + e4] = h2[t5 * s3 + e4];
2386
2254
  return n3;
2387
2255
  }(t3, i));
2388
2256
  }), n;
2389
2257
  }
2390
2258
  static validate(t2, e) {
2391
2259
  const r = t2.json;
2392
- if ("2.0" !== r.asset.version)
2393
- throw new Error(`Unsupported glTF version, "${r.asset.version}".`);
2260
+ if ("2.0" !== r.asset.version) throw new Error(`Unsupported glTF version, "${r.asset.version}".`);
2394
2261
  if (r.extensionsRequired) {
2395
- for (const t3 of r.extensionsRequired)
2396
- if (!e.extensions.find((e2) => e2.EXTENSION_NAME === t3))
2397
- throw new Error(`Missing required extension, "${t3}".`);
2262
+ for (const t3 of r.extensionsRequired) if (!e.extensions.find((e2) => e2.EXTENSION_NAME === t3)) throw new Error(`Missing required extension, "${t3}".`);
2398
2263
  }
2399
- if (r.extensionsUsed)
2400
- for (const t3 of r.extensionsUsed)
2401
- e.extensions.find((e2) => e2.EXTENSION_NAME === t3) || e.logger.warn(`Missing optional extension, "${t3}".`);
2264
+ if (r.extensionsUsed) for (const t3 of r.extensionsUsed) e.extensions.find((e2) => e2.EXTENSION_NAME === t3) || e.logger.warn(`Missing optional extension, "${t3}".`);
2402
2265
  }
2403
2266
  }).read(t, { extensions: Array.from(this.h), dependencies: this.F, logger: this.M });
2404
2267
  }
@@ -2408,27 +2271,22 @@
2408
2271
  const r = e.json;
2409
2272
  if (r.buffers && r.buffers.some((t2) => function(t3, e2) {
2410
2273
  return void 0 !== e2.uri && !(e2.uri in t3.resources);
2411
- }(e, t2)))
2412
- throw new Error("Cannot resolve external buffers with binaryToJSON().");
2274
+ }(e, t2))) throw new Error("Cannot resolve external buffers with binaryToJSON().");
2413
2275
  if (r.images && r.images.some((t2) => function(t3, e2) {
2414
2276
  return void 0 !== e2.uri && !(e2.uri in t3.resources) && void 0 === e2.bufferView;
2415
- }(e, t2)))
2416
- throw new Error("Cannot resolve external images with binaryToJSON().");
2277
+ }(e, t2))) throw new Error("Cannot resolve external images with binaryToJSON().");
2417
2278
  return e;
2418
2279
  }
2419
2280
  async readBinary(t) {
2420
2281
  return this.readJSON(await this.binaryToJSON(E.assertView(t)));
2421
2282
  }
2422
2283
  async writeJSON(t, e = {}) {
2423
- if (e.format === g.GLB && t.getRoot().listBuffers().length > 1)
2424
- throw new Error("GLB must have 0–1 buffers.");
2284
+ if (e.format === g.GLB && t.getRoot().listBuffers().length > 1) throw new Error("GLB must have 0–1 buffers.");
2425
2285
  return (class {
2426
2286
  static write(t2, e2) {
2427
2287
  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));
2428
2288
  u.length < t2.getRoot().listExtensionsUsed().length && o.warn("Some extensions were not registered for I/O, and will not be written.");
2429
- for (const t3 of u)
2430
- for (const r2 of t3.writeDependencies)
2431
- t3.install(r2, e2.dependencies[r2]);
2289
+ for (const t3 of u) for (const r2 of t3.writeDependencies) t3.install(r2, e2.dependencies[r2]);
2432
2290
  function l2(t3, e3, r2, n2) {
2433
2291
  const o2 = [];
2434
2292
  let a2 = 0;
@@ -2494,15 +2352,12 @@
2494
2352
  const t4 = i.createAccessorDef(e4);
2495
2353
  s.accessors.push(t4), i.accessorIndexMap.set(e4, s.accessors.length - 1);
2496
2354
  const r3 = [], n3 = [], a3 = [], h3 = new Array(e4.getElementSize()).fill(0);
2497
- for (let t5 = 0, s2 = e4.getCount(); t5 < s2; t5++)
2498
- if (e4.getElement(t5, a3), !P$1.eq(a3, h3, 0)) {
2499
- c3 = Math.max(t5, c3), r3.push(t5);
2500
- for (let t6 = 0; t6 < a3.length; t6++)
2501
- n3.push(a3[t6]);
2502
- }
2355
+ for (let t5 = 0, s2 = e4.getCount(); t5 < s2; t5++) if (e4.getElement(t5, a3), !P$1.eq(a3, h3, 0)) {
2356
+ c3 = Math.max(t5, c3), r3.push(t5);
2357
+ for (let t6 = 0; t6 < a3.length; t6++) n3.push(a3[t6]);
2358
+ }
2503
2359
  const f3 = r3.length, l4 = { accessorDef: t4, count: f3 };
2504
- if (u2.set(e4, l4), 0 === f3)
2505
- continue;
2360
+ if (u2.set(e4, l4), 0 === f3) continue;
2506
2361
  if (f3 > e4.getCount() / 3) {
2507
2362
  const t5 = (100 * r3.length / e4.getCount()).toFixed(1);
2508
2363
  o.warn(`Sparse accessor with many non-zero elements (${t5}%) may increase file size.`);
@@ -2510,13 +2365,11 @@
2510
2365
  const d4 = p[e4.getComponentType()];
2511
2366
  l4.indices = r3, l4.values = new d4(n3);
2512
2367
  }
2513
- if (!Number.isFinite(c3))
2514
- return { buffers: n2, byteLength: a2 };
2368
+ if (!Number.isFinite(c3)) return { buffers: n2, byteLength: a2 };
2515
2369
  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 };
2516
2370
  for (const e4 of t3) {
2517
2371
  const t4 = u2.get(e4);
2518
- if (0 === t4.count)
2519
- continue;
2372
+ if (0 === t4.count) continue;
2520
2373
  t4.indicesByteOffset = l3.byteLength;
2521
2374
  const r3 = E.pad(E.toView(new h2(t4.indices)));
2522
2375
  n2.push(r3), a2 += r3.byteLength, l3.byteLength += r3.byteLength;
@@ -2525,8 +2378,7 @@
2525
2378
  const d3 = s.bufferViews.length - 1, g2 = { buffer: e3, byteOffset: r2 + a2, byteLength: 0 };
2526
2379
  for (const e4 of t3) {
2527
2380
  const t4 = u2.get(e4);
2528
- if (0 === t4.count)
2529
- continue;
2381
+ if (0 === t4.count) continue;
2530
2382
  t4.valuesByteOffset = g2.byteLength;
2531
2383
  const r3 = E.pad(E.toView(t4.values));
2532
2384
  n2.push(r3), a2 += r3.byteLength, g2.byteLength += r3.byteLength;
@@ -2541,8 +2393,7 @@
2541
2393
  }
2542
2394
  const w2 = /* @__PURE__ */ new Map();
2543
2395
  for (const e3 of t2.getGraph().listEdges()) {
2544
- if (e3.getParent() === r)
2545
- continue;
2396
+ if (e3.getParent() === r) continue;
2546
2397
  const t3 = e3.getChild();
2547
2398
  if (t3 instanceof K$1) {
2548
2399
  const r2 = w2.get(t3) || [];
@@ -2556,50 +2407,40 @@
2556
2407
  return s2 && i.createImageData(r2, s2, t3), i.imageIndexMap.set(t3, e3), r2;
2557
2408
  }), u.filter((t3) => t3.prewriteTypes.includes(h.ACCESSOR)).forEach((t3) => t3.prewrite(i, h.ACCESSOR)), r.listAccessors().forEach((t3) => {
2558
2409
  const e3 = i.accessorUsageGroupedByParent, r2 = i.accessorParents;
2559
- if (i.accessorIndexMap.has(t3))
2560
- return;
2410
+ if (i.accessorIndexMap.has(t3)) return;
2561
2411
  const s2 = w2.get(t3) || [], n2 = i.getAccessorUsage(t3);
2562
2412
  if (i.addAccessorToUsageGroup(t3, n2), e3.has(n2)) {
2563
2413
  const e4 = s2[0].getParent(), n3 = r2.get(e4) || /* @__PURE__ */ new Set();
2564
2414
  n3.add(t3), r2.set(e4, n3);
2565
2415
  }
2566
- }), 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)
2567
- throw new Error("Buffer required for Document resources, but none was found.");
2416
+ }), 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.");
2568
2417
  s.buffers = [], r.listBuffers().forEach((t3, r2) => {
2569
2418
  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;
2570
2419
  let y3 = 0;
2571
2420
  const v2 = i.listAccessorUsageGroups();
2572
- for (const t4 in v2)
2573
- if (a2.has(t4))
2574
- for (const r3 of Array.from(u2.values())) {
2575
- const s2 = Array.from(r3).filter((t5) => h2.has(t5)).filter((e3) => i.getAccessorUsage(e3) === t4);
2576
- if (s2.length)
2577
- if (t4 !== It$1.ARRAY_BUFFER || e2.vertexLayout === f.INTERLEAVED) {
2578
- const e3 = t4 === It$1.ARRAY_BUFFER ? d2(s2, w3, y3) : l2(s2, w3, y3);
2579
- y3 += e3.byteLength, p2.push(...e3.buffers);
2580
- } else
2581
- for (const t5 of s2) {
2582
- const e3 = d2([t5], w3, y3);
2583
- y3 += e3.byteLength, p2.push(...e3.buffers);
2584
- }
2585
- }
2586
- else {
2587
- const e3 = v2[t4].filter((t5) => h2.has(t5));
2588
- if (!e3.length)
2589
- continue;
2590
- 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);
2591
- y3 += s2.byteLength, p2.push(...s2.buffers);
2421
+ for (const t4 in v2) if (a2.has(t4)) for (const r3 of Array.from(u2.values())) {
2422
+ const s2 = Array.from(r3).filter((t5) => h2.has(t5)).filter((e3) => i.getAccessorUsage(e3) === t4);
2423
+ if (s2.length) if (t4 !== It$1.ARRAY_BUFFER || e2.vertexLayout === f.INTERLEAVED) {
2424
+ const e3 = t4 === It$1.ARRAY_BUFFER ? d2(s2, w3, y3) : l2(s2, w3, y3);
2425
+ y3 += e3.byteLength, p2.push(...e3.buffers);
2426
+ } else for (const t5 of s2) {
2427
+ const e3 = d2([t5], w3, y3);
2428
+ y3 += e3.byteLength, p2.push(...e3.buffers);
2592
2429
  }
2430
+ }
2431
+ else {
2432
+ const e3 = v2[t4].filter((t5) => h2.has(t5));
2433
+ if (!e3.length) continue;
2434
+ 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);
2435
+ y3 += s2.byteLength, p2.push(...s2.buffers);
2436
+ }
2593
2437
  if (i.imageBufferViews.length && 0 === r2) {
2594
- for (let t4 = 0; t4 < i.imageBufferViews.length; t4++)
2595
- if (s.bufferViews[s.images[t4].bufferView].byteOffset = y3, y3 += i.imageBufferViews[t4].byteLength, p2.push(i.imageBufferViews[t4]), y3 % 8) {
2596
- const t5 = 8 - y3 % 8;
2597
- y3 += t5, p2.push(new Uint8Array(t5));
2598
- }
2438
+ 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) {
2439
+ const t5 = 8 - y3 % 8;
2440
+ y3 += t5, p2.push(new Uint8Array(t5));
2441
+ }
2599
2442
  }
2600
- if (i.otherBufferViews.has(t3))
2601
- for (const e3 of i.otherBufferViews.get(t3))
2602
- s.bufferViews.push({ buffer: w3, byteOffset: y3, byteLength: e3.byteLength }), i.otherBufferViewsIndexMap.set(e3, s.bufferViews.length - 1), y3 += e3.byteLength, p2.push(e3);
2443
+ 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);
2603
2444
  if (y3) {
2604
2445
  let r3;
2605
2446
  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);
@@ -2638,12 +2479,10 @@
2638
2479
  r3 && (e4.material = i.materialIndexMap.get(r3)), Object.keys(t4.getExtras()).length && (e4.extras = t4.getExtras());
2639
2480
  const n2 = t4.getIndices();
2640
2481
  n2 && (e4.indices = i.accessorIndexMap.get(n2));
2641
- for (const r4 of t4.listSemantics())
2642
- e4.attributes[r4] = i.accessorIndexMap.get(t4.getAttribute(r4));
2482
+ for (const r4 of t4.listSemantics()) e4.attributes[r4] = i.accessorIndexMap.get(t4.getAttribute(r4));
2643
2483
  for (const r4 of t4.listTargets()) {
2644
2484
  const t5 = {};
2645
- for (const e5 of r4.listSemantics())
2646
- t5[e5] = i.accessorIndexMap.get(r4.getAttribute(e5));
2485
+ for (const e5 of r4.listSemantics()) t5[e5] = i.accessorIndexMap.get(r4.getAttribute(e5));
2647
2486
  e4.targets = e4.targets || [], e4.targets.push(t5);
2648
2487
  }
2649
2488
  return t4.listTargets().length && !s2 && (s2 = t4.listTargets().map((t5) => t5.getName())), e4;
@@ -2654,8 +2493,7 @@
2654
2493
  r2.perspective = { znear: t3.getZNear(), zfar: t3.getZFar(), yfov: t3.getYFov() };
2655
2494
  const e4 = t3.getAspectRatio();
2656
2495
  null !== e4 && (r2.perspective.aspectRatio = e4);
2657
- } else
2658
- r2.orthographic = { znear: t3.getZNear(), zfar: t3.getZFar(), xmag: t3.getXMag(), ymag: t3.getYMag() };
2496
+ } else r2.orthographic = { znear: t3.getZNear(), zfar: t3.getZFar(), xmag: t3.getXMag(), ymag: t3.getYMag() };
2659
2497
  return i.cameraIndexMap.set(t3, e3), r2;
2660
2498
  }), s.nodes = r.listNodes().map((t3, e3) => {
2661
2499
  const r2 = i.createPropertyDef(t3);
@@ -2692,8 +2530,7 @@
2692
2530
  const s2 = t3[r2];
2693
2531
  (Array.isArray(s2) && 0 === s2.length || null === s2 || "" === s2 || s2 && "object" == typeof s2 && 0 === Object.keys(s2).length) && e3.push(r2);
2694
2532
  }
2695
- for (const r2 of e3)
2696
- delete t3[r2];
2533
+ for (const r2 of e3) delete t3[r2];
2697
2534
  }(s), n;
2698
2535
  }
2699
2536
  }).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) });
@@ -2702,8 +2539,7 @@
2702
2539
  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]);
2703
2540
  s[s.length - 1] += a.byteLength;
2704
2541
  const u = Object.values(r)[0];
2705
- if (!u || !u.byteLength)
2706
- return E.concat([E.toView(s), a]);
2542
+ if (!u || !u.byteLength) return E.concat([E.toView(s), a]);
2707
2543
  const c2 = E.pad(u, 0), h2 = E.toView(new Uint32Array([c2.byteLength, 5130562])), f2 = E.concat([h2, c2]);
2708
2544
  return s[s.length - 1] += f2.byteLength, E.concat([E.toView(s), a, f2]);
2709
2545
  }
@@ -2711,8 +2547,7 @@
2711
2547
  var r = this;
2712
2548
  const s = [...t.json.images || [], ...t.json.buffers || []].map(async function(s2) {
2713
2549
  const n = s2.uri;
2714
- if (!n || n.match(/data:/))
2715
- return Promise.resolve();
2550
+ if (!n || n.match(/data:/)) return Promise.resolve();
2716
2551
  t.resources[n] = await r.readURI(r.resolve(e, n), "view"), r.lastReadBytes += t.resources[n].byteLength;
2717
2552
  });
2718
2553
  await Promise.all(s);
@@ -2720,8 +2555,7 @@
2720
2555
  j(t) {
2721
2556
  function e(e2) {
2722
2557
  if (e2.uri) {
2723
- if (e2.uri in t.resources)
2724
- E.assertView(t.resources[e2.uri]);
2558
+ if (e2.uri in t.resources) E.assertView(t.resources[e2.uri]);
2725
2559
  else if (e2.uri.match(/data:/)) {
2726
2560
  const r = `__${V$1()}.${N$1.extension(e2.uri)}`;
2727
2561
  t.resources[r] = E.createBufferFromDataURI(e2.uri), e2.uri = r;
@@ -2729,8 +2563,7 @@
2729
2563
  }
2730
2564
  }
2731
2565
  (t.json.images || []).forEach((t2) => {
2732
- if (void 0 === t2.bufferView && void 0 === t2.uri)
2733
- throw new Error("Missing resource URI or buffer view.");
2566
+ if (void 0 === t2.bufferView && void 0 === t2.uri) throw new Error("Missing resource URI or buffer view.");
2734
2567
  e(t2);
2735
2568
  }), (t.json.buffers || []).forEach(e);
2736
2569
  }
@@ -2739,23 +2572,18 @@
2739
2572
  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;
2740
2573
  }
2741
2574
  P(t) {
2742
- if (!Ut(t))
2743
- throw new Error("Invalid glTF 2.0 binary.");
2575
+ if (!Ut(t)) throw new Error("Invalid glTF 2.0 binary.");
2744
2576
  const e = new Uint32Array(t.buffer, t.byteOffset + 12, 2);
2745
- if (e[1] !== Ct$1.JSON)
2746
- throw new Error("Missing required GLB JSON chunk.");
2577
+ if (e[1] !== Ct$1.JSON) throw new Error("Missing required GLB JSON chunk.");
2747
2578
  const r = e[0], s = E.decodeText(E.toView(t, 20, r)), n = JSON.parse(s), i = 20 + r;
2748
- if (t.byteLength <= i)
2749
- return { json: n, resources: {} };
2579
+ if (t.byteLength <= i) return { json: n, resources: {} };
2750
2580
  const o = new Uint32Array(t.buffer, t.byteOffset + i, 2);
2751
- if (o[1] !== Ct$1.BIN)
2752
- throw new Error("Expected GLB BIN in second chunk.");
2581
+ if (o[1] !== Ct$1.BIN) throw new Error("Expected GLB BIN in second chunk.");
2753
2582
  return { json: n, resources: { "@glb.bin": E.toView(t, i + 8, o[0]) } };
2754
2583
  }
2755
2584
  };
2756
2585
  function Ut(t) {
2757
- if (t.byteLength < 3 * Uint32Array.BYTES_PER_ELEMENT)
2758
- return false;
2586
+ if (t.byteLength < 3 * Uint32Array.BYTES_PER_ELEMENT) return false;
2759
2587
  const e = new Uint32Array(t.buffer, t.byteOffset, 3);
2760
2588
  return 1179937895 === e[0] && 2 === e[1];
2761
2589
  }
@@ -2866,8 +2694,7 @@
2866
2694
  byteLength++;
2867
2695
  this._offset++;
2868
2696
  }
2869
- if (byteLength < maxByteLength)
2870
- this._offset++;
2697
+ if (byteLength < maxByteLength) this._offset++;
2871
2698
  return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
2872
2699
  }
2873
2700
  }
@@ -2981,11 +2808,9 @@
2981
2808
  const key = decodeText(keyData);
2982
2809
  const valueData = kvdReader._scan(keyValueByteLength - keyData.byteLength);
2983
2810
  container.keyValue[key] = key.match(/^ktx/i) ? decodeText(valueData) : valueData;
2984
- if (kvdReader._offset % 4)
2985
- kvdReader._skip(4 - kvdReader._offset % 4);
2811
+ if (kvdReader._offset % 4) kvdReader._skip(4 - kvdReader._offset % 4);
2986
2812
  }
2987
- if (sgdByteLength <= 0)
2988
- return container;
2813
+ if (sgdByteLength <= 0) return container;
2989
2814
  const sgdReader = new BufferReader(data, sgdByteOffset, sgdByteLength, true);
2990
2815
  const endpointCount = sgdReader._nextUint16();
2991
2816
  const selectorCount = sgdReader._nextUint16();
@@ -3053,19 +2878,15 @@
3053
2878
  }
3054
2879
  read(e) {
3055
2880
  return (e.jsonDoc.json.nodes || []).forEach((t, s) => {
3056
- if (!t.extensions || !t.extensions[N])
3057
- return;
2881
+ if (!t.extensions || !t.extensions[N]) return;
3058
2882
  const n = t.extensions[N], r = this.createInstancedMesh();
3059
- for (const t2 in n.attributes)
3060
- r.setAttribute(t2, e.accessors[n.attributes[t2]]);
2883
+ for (const t2 in n.attributes) r.setAttribute(t2, e.accessors[n.attributes[t2]]);
3061
2884
  e.nodes[s].setExtension(N, r);
3062
2885
  }), this;
3063
2886
  }
3064
2887
  prewrite(e) {
3065
2888
  e.accessorUsageGroupedByParent.add("INSTANCE_ATTRIBUTE");
3066
- for (const t of this.properties)
3067
- for (const s of t.listAttributes())
3068
- e.addAccessorToUsageGroup(s, "INSTANCE_ATTRIBUTE");
2889
+ for (const t of this.properties) for (const s of t.listAttributes()) e.addAccessorToUsageGroup(s, "INSTANCE_ATTRIBUTE");
3069
2890
  return this;
3070
2891
  }
3071
2892
  write(e) {
@@ -3086,8 +2907,7 @@
3086
2907
  return (_ = Object.assign || function(e) {
3087
2908
  for (var t = 1; t < arguments.length; t++) {
3088
2909
  var s = arguments[t];
3089
- for (var n in s)
3090
- Object.prototype.hasOwnProperty.call(s, n) && (e[n] = s[n]);
2910
+ for (var n in s) Object.prototype.hasOwnProperty.call(s, n) && (e[n] = s[n]);
3091
2911
  }
3092
2912
  return e;
3093
2913
  }).apply(this, arguments);
@@ -3103,13 +2923,11 @@
3103
2923
  const { BYTE: M, SHORT: O, FLOAT: w } = K$1.ComponentType, { encodeNormalizedInt: D, decodeNormalizedInt: b } = P$1;
3104
2924
  function F(e, t, s, r) {
3105
2925
  const { filter: o, bits: i } = r, a = { array: e.getArray(), byteStride: e.getElementSize() * e.getComponentSize(), componentType: e.getComponentType(), normalized: e.getNormalized() };
3106
- if (s !== S.ATTRIBUTES)
3107
- return a;
2926
+ if (s !== S.ATTRIBUTES) return a;
3108
2927
  if (o !== C.NONE) {
3109
2928
  let s2 = e.getNormalized() ? function(e2) {
3110
2929
  const t2 = e2.getComponentType(), s3 = e2.getArray(), n = new Float32Array(s3.length);
3111
- for (let e3 = 0; e3 < s3.length; e3++)
3112
- n[e3] = b(s3[e3], t2);
2930
+ for (let e3 = 0; e3 < s3.length; e3++) n[e3] = b(s3[e3], t2);
3113
2931
  return n;
3114
2932
  }(e) : new Float32Array(a.array);
3115
2933
  switch (o) {
@@ -3119,8 +2937,7 @@
3119
2937
  case C.OCTAHEDRAL:
3120
2938
  a.byteStride = i > 8 ? 8 : 4, a.componentType = i > 8 ? O : M, a.normalized = true, s2 = 3 === e.getElementSize() ? function(e2) {
3121
2939
  const t2 = new Float32Array(4 * e2.length / 3);
3122
- for (let s3 = 0, n = e2.length / 3; s3 < n; s3++)
3123
- t2[4 * s3] = e2[3 * s3], t2[4 * s3 + 1] = e2[3 * s3 + 1], t2[4 * s3 + 2] = e2[3 * s3 + 2];
2940
+ 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];
3124
2941
  return t2;
3125
2942
  }(s2) : s2, a.array = t.encodeFilterOct(s2, e.getCount(), a.byteStride, i);
3126
2943
  break;
@@ -3131,14 +2948,11 @@
3131
2948
  throw new Error("Invalid filter.");
3132
2949
  }
3133
2950
  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)));
3134
- } else
3135
- a.byteStride % 4 && (a.array = function(e2, t2) {
3136
- const s2 = E.padNumber(e2.BYTES_PER_ELEMENT * t2) / e2.BYTES_PER_ELEMENT, r2 = new e2.constructor(e2.length / t2 * s2);
3137
- for (let n = 0; n * t2 < e2.length; n++)
3138
- for (let o2 = 0; o2 < t2; o2++)
3139
- r2[n * s2 + o2] = e2[n * t2 + o2];
3140
- return r2;
3141
- }(a.array, e.getElementSize()), a.byteStride = a.array.byteLength / e.getCount());
2951
+ } else a.byteStride % 4 && (a.array = function(e2, t2) {
2952
+ const s2 = E.padNumber(e2.BYTES_PER_ELEMENT * t2) / e2.BYTES_PER_ELEMENT, r2 = new e2.constructor(e2.length / t2 * s2);
2953
+ for (let n = 0; n * t2 < e2.length; n++) for (let o2 = 0; o2 < t2; o2++) r2[n * s2 + o2] = e2[n * t2 + o2];
2954
+ return r2;
2955
+ }(a.array, e.getElementSize()), a.byteStride = a.array.byteLength / e.getCount());
3142
2956
  return a;
3143
2957
  }
3144
2958
  function j(e, t) {
@@ -3148,40 +2962,28 @@
3148
2962
  const s = t.getGraph().listParentEdges(e).filter((e2) => !(e2.getParent() instanceof yt$1));
3149
2963
  for (const t2 of s) {
3150
2964
  const s2 = t2.getName(), n = t2.getAttributes().key || "";
3151
- if ("indices" === s2)
3152
- return { filter: C.NONE };
2965
+ if ("indices" === s2) return { filter: C.NONE };
3153
2966
  if ("attributes" === s2) {
3154
- if ("POSITION" === n)
3155
- return { filter: C.NONE };
3156
- if ("TEXCOORD_0" === n)
3157
- return { filter: C.NONE };
3158
- if ("NORMAL" === n)
3159
- return { filter: C.OCTAHEDRAL, bits: 8 };
3160
- if ("TANGENT" === n)
3161
- return { filter: C.OCTAHEDRAL, bits: 8 };
3162
- if (n.startsWith("JOINTS_"))
3163
- return { filter: C.NONE };
3164
- if (n.startsWith("WEIGHTS_"))
3165
- return { filter: C.NONE };
2967
+ if ("POSITION" === n) return { filter: C.NONE };
2968
+ if ("TEXCOORD_0" === n) return { filter: C.NONE };
2969
+ if ("NORMAL" === n) return { filter: C.OCTAHEDRAL, bits: 8 };
2970
+ if ("TANGENT" === n) return { filter: C.OCTAHEDRAL, bits: 8 };
2971
+ if (n.startsWith("JOINTS_")) return { filter: C.NONE };
2972
+ if (n.startsWith("WEIGHTS_")) return { filter: C.NONE };
3166
2973
  }
3167
2974
  if ("output" === s2) {
3168
2975
  const t3 = k(e);
3169
2976
  return "rotation" === t3 ? { filter: C.QUATERNION, bits: 16 } : "translation" === t3 || "scale" === t3 ? { filter: C.EXPONENTIAL, bits: 12 } : { filter: C.NONE };
3170
2977
  }
3171
- if ("input" === s2)
3172
- return { filter: C.NONE };
3173
- if ("inverseBindMatrices" === s2)
3174
- return { filter: C.NONE };
2978
+ if ("input" === s2) return { filter: C.NONE };
2979
+ if ("inverseBindMatrices" === s2) return { filter: C.NONE };
3175
2980
  }
3176
2981
  return { filter: C.NONE };
3177
2982
  }
3178
2983
  function k(e) {
3179
- for (const t of e.listParents())
3180
- if (t instanceof tt$1) {
3181
- for (const e2 of t.listParents())
3182
- if (e2 instanceof X$1)
3183
- return e2.getTargetPath();
3184
- }
2984
+ for (const t of e.listParents()) if (t instanceof tt$1) {
2985
+ for (const e2 of t.listParents()) if (e2 instanceof X$1) return e2.getTargetPath();
2986
+ }
3185
2987
  return null;
3186
2988
  }
3187
2989
  const B = "EXT_meshopt_compression", G = { method: A.QUANTIZE };
@@ -3197,13 +2999,11 @@
3197
2999
  }
3198
3000
  preread(e, s) {
3199
3001
  if (!this._decoder) {
3200
- if (!this.isRequired())
3201
- return this;
3002
+ if (!this.isRequired()) return this;
3202
3003
  throw new Error(`[${B}] Please install extension dependency, "meshopt.decoder".`);
3203
3004
  }
3204
3005
  if (!this._decoder.supported) {
3205
- if (!this.isRequired())
3206
- return this;
3006
+ if (!this.isRequired()) return this;
3207
3007
  throw new Error(`[${B}]: Missing WASM support.`);
3208
3008
  }
3209
3009
  return s === h.BUFFER ? this._prereadBuffers(e) : s === h.PRIMITIVE && this._prereadPrimitives(e), this;
@@ -3211,8 +3011,7 @@
3211
3011
  _prereadBuffers(e) {
3212
3012
  const t = e.jsonDoc;
3213
3013
  (t.json.bufferViews || []).forEach((s, r) => {
3214
- if (!s.extensions || !s.extensions[B])
3215
- return;
3014
+ if (!s.extensions || !s.extensions[B]) return;
3216
3015
  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);
3217
3016
  this._decoder.decodeGltfBuffer(l2, c$1, u, g2, o.mode, o.filter), e.bufferViews[r] = l2;
3218
3017
  });
@@ -3225,11 +3024,9 @@
3225
3024
  });
3226
3025
  }
3227
3026
  read(e) {
3228
- if (!this.isRequired())
3229
- return this;
3027
+ if (!this.isRequired()) return this;
3230
3028
  for (const [e2, t] of this._decoderFallbackBufferMap) {
3231
- for (const s of e2.listParents())
3232
- s instanceof K$1 && s.swap(e2, t);
3029
+ for (const s of e2.listParents()) s instanceof K$1 && s.swap(e2, t);
3233
3030
  e2.dispose();
3234
3031
  }
3235
3032
  return this;
@@ -3241,13 +3038,10 @@
3241
3038
  const t = e.jsonDoc.json, s = this._encoder, n = this._encoderOptions, o = this.document.createBuffer(), i = this.document.getRoot().listBuffers().indexOf(o);
3242
3039
  this._encoderFallbackBuffer = o, this._encoderBufferViews = {}, this._encoderBufferViewData = {}, this._encoderBufferViewAccessors = {};
3243
3040
  for (const o2 of this.document.getRoot().listAccessors()) {
3244
- if ("weights" === k(o2))
3245
- continue;
3246
- if (o2.getSparse())
3247
- continue;
3041
+ if ("weights" === k(o2)) continue;
3042
+ if (o2.getSparse()) continue;
3248
3043
  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();
3249
- if (!g2)
3250
- throw new Error(`${B}: Missing buffer for accessor.`);
3044
+ if (!g2) throw new Error(`${B}: Missing buffer for accessor.`);
3251
3045
  const p2 = this.document.getRoot().listBuffers().indexOf(g2), x2 = [a, c2, u.filter, f2, p2].join(":");
3252
3046
  let d2 = this._encoderBufferViews[x2], T2 = this._encoderBufferViewData[x2], m2 = this._encoderBufferViewAccessors[x2];
3253
3047
  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 } } });
@@ -3266,8 +3060,7 @@
3266
3060
  let t = 0;
3267
3061
  for (const s2 in this._encoderBufferViews) {
3268
3062
  const r2 = this._encoderBufferViews[s2], o2 = e.otherBufferViewsIndexMap.get(this._encoderBufferViewData[s2][0]), i = this._encoderBufferViewAccessors[s2];
3269
- for (const e2 of i)
3270
- e2.bufferView = o2;
3063
+ for (const e2 of i) e2.bufferView = o2;
3271
3064
  const a = e.jsonDoc.json.bufferViews[o2], c2 = a.byteOffset || 0;
3272
3065
  Object.assign(a, r2), a.byteOffset = t, a.extensions[B].byteOffset = c2, t += E.padNumber(r2.byteLength);
3273
3066
  }
@@ -3282,25 +3075,18 @@
3282
3075
  return e.length >= 12 && "ftypavif" === E.decodeText(e.slice(4, 12));
3283
3076
  }
3284
3077
  getSize(e) {
3285
- if (!this.match(e))
3286
- return null;
3078
+ if (!this.match(e)) return null;
3287
3079
  const t = new DataView(e.buffer, e.byteOffset, e.byteLength);
3288
3080
  let s = P(t, 0);
3289
- if (!s)
3290
- return null;
3081
+ if (!s) return null;
3291
3082
  let n = s.end;
3292
- for (; s = P(t, n); )
3293
- if ("meta" === s.type)
3294
- n = s.start + 4;
3295
- else if ("iprp" === s.type || "ipco" === s.type)
3296
- n = s.start;
3297
- else {
3298
- if ("ispe" === s.type)
3299
- return [t.getUint32(s.start + 4), t.getUint32(s.start + 8)];
3300
- if ("mdat" === s.type)
3301
- break;
3302
- n = s.end;
3303
- }
3083
+ for (; s = P(t, n); ) if ("meta" === s.type) n = s.start + 4;
3084
+ else if ("iprp" === s.type || "ipco" === s.type) n = s.start;
3085
+ else {
3086
+ if ("ispe" === s.type) return [t.getUint32(s.start + 4), t.getUint32(s.start + 8)];
3087
+ if ("mdat" === s.type) break;
3088
+ n = s.end;
3089
+ }
3304
3090
  return null;
3305
3091
  }
3306
3092
  getChannels(e) {
@@ -3335,8 +3121,7 @@
3335
3121
  }
3336
3122
  }
3337
3123
  function P(e, t) {
3338
- if (e.byteLength < 4 + t)
3339
- return null;
3124
+ if (e.byteLength < 4 + t) return null;
3340
3125
  const s = e.getUint32(t);
3341
3126
  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 };
3342
3127
  }
@@ -3348,14 +3133,12 @@
3348
3133
  }
3349
3134
  getSize(e) {
3350
3135
  const t = E.decodeText(e.slice(0, 4)), s = E.decodeText(e.slice(8, 12));
3351
- if ("RIFF" !== t || "WEBP" !== s)
3352
- return null;
3136
+ if ("RIFF" !== t || "WEBP" !== s) return null;
3353
3137
  const r = new DataView(e.buffer, e.byteOffset);
3354
3138
  let o = 12;
3355
3139
  for (; o < r.byteLength; ) {
3356
3140
  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);
3357
- if ("VP8 " === e2)
3358
- return [16383 & r.getInt16(o + 14, true), 16383 & r.getInt16(o + 16, true)];
3141
+ if ("VP8 " === e2) return [16383 & r.getInt16(o + 14, true), 16383 & r.getInt16(o + 16, true)];
3359
3142
  if ("VP8L" === e2) {
3360
3143
  const e3 = r.getUint8(o + 9), t3 = r.getUint8(o + 10), s2 = r.getUint8(o + 11);
3361
3144
  return [1 + ((63 & t3) << 8 | e3), 1 + ((15 & r.getUint8(o + 12)) << 10 | s2 << 2 | (192 & t3) >> 6)];
@@ -3401,11 +3184,9 @@
3401
3184
  function J(e, t) {
3402
3185
  const s = new q.DecoderBuffer();
3403
3186
  try {
3404
- if (s.Init(t, t.length), e.GetEncodedGeometryType(s) !== q.TRIANGULAR_MESH)
3405
- throw new Error(`[${$}] Unknown geometry type.`);
3187
+ if (s.Init(t, t.length), e.GetEncodedGeometryType(s) !== q.TRIANGULAR_MESH) throw new Error(`[${$}] Unknown geometry type.`);
3406
3188
  const n = new q.Mesh();
3407
- if (!e.DecodeBufferToMesh(s, n).ok() || 0 === n.ptr)
3408
- throw new Error(`[${$}] Decoding failure.`);
3189
+ if (!e.DecodeBufferToMesh(s, n).ok() || 0 === n.ptr) throw new Error(`[${$}] Decoding failure.`);
3409
3190
  return n;
3410
3191
  } finally {
3411
3192
  q.destroy(s);
@@ -3448,13 +3229,10 @@
3448
3229
  continue;
3449
3230
  }
3450
3231
  const c3 = ie(t2), l3 = ae(r, a2.getComponentType(), o, W[c3], a2.getCount(), a2.getElementSize(), a2.getArray());
3451
- if (-1 === l3)
3452
- throw new Error(`Error compressing "${t2}" attribute.`);
3453
- if (i[t2] = l3, "mesh" === s.quantizationVolume || "POSITION" !== t2)
3454
- n.SetAttributeQuantization(W[c3], s.quantizationBits[c3]);
3232
+ if (-1 === l3) throw new Error(`Error compressing "${t2}" attribute.`);
3233
+ if (i[t2] = l3, "mesh" === s.quantizationVolume || "POSITION" !== t2) n.SetAttributeQuantization(W[c3], s.quantizationBits[c3]);
3455
3234
  else {
3456
- if ("object" != typeof s.quantizationVolume)
3457
- throw new Error("Invalid quantization volume state.");
3235
+ if ("object" != typeof s.quantizationVolume) throw new Error("Invalid quantization volume state.");
3458
3236
  {
3459
3237
  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]);
3460
3238
  n.SetAttributeExplicitQuantization(W[c3], s.quantizationBits[c3], a2.getElementSize(), e2.min, t3);
@@ -3462,18 +3240,14 @@
3462
3240
  }
3463
3241
  }
3464
3242
  const l2 = e.getIndices();
3465
- if (!l2)
3466
- throw new ce("Primitive must have indices.");
3243
+ if (!l2) throw new ce("Primitive must have indices.");
3467
3244
  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 ? W.MESH_SEQUENTIAL_ENCODING : W.MESH_EDGEBREAKER_ENCODING);
3468
3245
  const h2 = n.EncodeMeshToDracoBuffer(o, a);
3469
- if (h2 <= 0)
3470
- throw new ce("Error applying Draco compression.");
3246
+ if (h2 <= 0) throw new ce("Error applying Draco compression.");
3471
3247
  const f2 = new Uint8Array(h2);
3472
- for (let e2 = 0; e2 < h2; ++e2)
3473
- f2[e2] = a.GetValue(e2);
3248
+ for (let e2 = 0; e2 < h2; ++e2) f2[e2] = a.GetValue(e2);
3474
3249
  const g2 = e.getAttribute("POSITION").getCount(), p2 = n.GetNumberOfEncodedPoints(), x2 = 3 * n.GetNumberOfEncodedFaces();
3475
- if ((c2 || u) && p2 !== g2)
3476
- 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');
3250
+ 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');
3477
3251
  return W.destroy(a), W.destroy(o), W.destroy(r), W.destroy(n), { numVertices: p2, numIndices: x2, data: f2, attributeIDs: i };
3478
3252
  }
3479
3253
  function ie(e) {
@@ -3511,30 +3285,26 @@
3511
3285
  return this._encoderOptions = e, this;
3512
3286
  }
3513
3287
  preread(e) {
3514
- if (!this._decoderModule)
3515
- throw new Error(`[${ue}] Please install extension dependency, "draco3d.decoder".`);
3288
+ if (!this._decoderModule) throw new Error(`[${ue}] Please install extension dependency, "draco3d.decoder".`);
3516
3289
  const t = this.document.getLogger(), s = e.jsonDoc, r = /* @__PURE__ */ new Map();
3517
3290
  try {
3518
3291
  const o = s.json.meshes || [];
3519
- for (const i of o)
3520
- for (const o2 of i.primitives) {
3521
- if (!o2.extensions || !o2.extensions[ue])
3522
- continue;
3523
- const i2 = o2.extensions[ue];
3524
- let [a, c$1] = r.get(i2.bufferView) || [];
3525
- if (!c$1 || !a) {
3526
- 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);
3527
- a = new this._decoderModule.Decoder(), c$1 = J(a, u), r.set(i2.bufferView, [a, c$1]), t.debug(`[${ue}] Decompressed ${u.byteLength} bytes.`);
3528
- }
3529
- for (const t2 in o2.attributes) {
3530
- const s2 = e.jsonDoc.json.accessors[o2.attributes[t2]], n = a.GetAttributeByUniqueId(c$1, i2.attributes[t2]), r2 = ee(a, c$1, n, s2);
3531
- e.accessors[o2.attributes[t2]].setArray(r2);
3532
- }
3533
- void 0 !== o2.indices && e.accessors[o2.indices].setArray(Z(a, c$1));
3292
+ for (const i of o) for (const o2 of i.primitives) {
3293
+ if (!o2.extensions || !o2.extensions[ue]) continue;
3294
+ const i2 = o2.extensions[ue];
3295
+ let [a, c$1] = r.get(i2.bufferView) || [];
3296
+ if (!c$1 || !a) {
3297
+ 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);
3298
+ a = new this._decoderModule.Decoder(), c$1 = J(a, u), r.set(i2.bufferView, [a, c$1]), t.debug(`[${ue}] Decompressed ${u.byteLength} bytes.`);
3299
+ }
3300
+ for (const t2 in o2.attributes) {
3301
+ const s2 = e.jsonDoc.json.accessors[o2.attributes[t2]], n = a.GetAttributeByUniqueId(c$1, i2.attributes[t2]), r2 = ee(a, c$1, n, s2);
3302
+ e.accessors[o2.attributes[t2]].setArray(r2);
3534
3303
  }
3304
+ void 0 !== o2.indices && e.accessors[o2.indices].setArray(Z(a, c$1));
3305
+ }
3535
3306
  } finally {
3536
- for (const [e2, t2] of Array.from(r.values()))
3537
- this._decoderModule.destroy(e2), this._decoderModule.destroy(t2);
3307
+ for (const [e2, t2] of Array.from(r.values())) this._decoderModule.destroy(e2), this._decoderModule.destroy(t2);
3538
3308
  }
3539
3309
  return this;
3540
3310
  }
@@ -3542,52 +3312,42 @@
3542
3312
  return this;
3543
3313
  }
3544
3314
  prewrite(e, s) {
3545
- if (!this._encoderModule)
3546
- throw new Error(`[${ue}] Please install extension dependency, "draco3d.encoder".`);
3315
+ if (!this._encoderModule) throw new Error(`[${ue}] Please install extension dependency, "draco3d.encoder".`);
3547
3316
  const n = this.document.getLogger();
3548
3317
  n.debug(`[${ue}] Compression options: ${JSON.stringify(this._encoderOptions)}`);
3549
3318
  const r = function(e2) {
3550
3319
  const s2 = e2.getLogger(), n2 = /* @__PURE__ */ new Set(), r2 = /* @__PURE__ */ new Set();
3551
- for (const t of e2.getRoot().listMeshes())
3552
- for (const e3 of t.listPrimitives())
3553
- 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.`));
3320
+ 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.`));
3554
3321
  const i2 = e2.getRoot().listAccessors(), a2 = /* @__PURE__ */ new Map();
3555
- for (let e3 = 0; e3 < i2.length; e3++)
3556
- a2.set(i2[e3], e3);
3322
+ for (let e3 = 0; e3 < i2.length; e3++) a2.set(i2[e3], e3);
3557
3323
  const c2 = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), l2 = /* @__PURE__ */ new Map();
3558
3324
  for (const t of Array.from(n2)) {
3559
3325
  let s3 = he(t, a2);
3560
- if (u.has(s3))
3561
- l2.set(t, s3);
3326
+ if (u.has(s3)) l2.set(t, s3);
3562
3327
  else {
3563
3328
  if (c2.has(t.getIndices())) {
3564
3329
  const s4 = t.getIndices(), n3 = s4.clone();
3565
3330
  a2.set(n3, e2.getRoot().listAccessors().length - 1), t.swap(s4, n3);
3566
3331
  }
3567
- for (const s4 of t.listAttributes())
3568
- if (c2.has(s4)) {
3569
- const n3 = s4.clone();
3570
- a2.set(n3, e2.getRoot().listAccessors().length - 1), t.swap(s4, n3);
3571
- }
3332
+ for (const s4 of t.listAttributes()) if (c2.has(s4)) {
3333
+ const n3 = s4.clone();
3334
+ a2.set(n3, e2.getRoot().listAccessors().length - 1), t.swap(s4, n3);
3335
+ }
3572
3336
  s3 = he(t, a2), u.add(s3), l2.set(t, s3), c2.set(t.getIndices(), s3);
3573
- for (const e3 of t.listAttributes())
3574
- c2.set(e3, s3);
3337
+ for (const e3 of t.listAttributes()) c2.set(e3, s3);
3575
3338
  }
3576
3339
  }
3577
3340
  for (const e3 of Array.from(c2.keys())) {
3578
3341
  const s3 = new Set(e3.listParents().map((e4) => e4.propertyType));
3579
- if (2 !== s3.size || !s3.has(h.PRIMITIVE) || !s3.has(h.ROOT))
3580
- throw new Error(`[${ue}] Compressed accessors must only be used as indices or vertex attributes.`);
3342
+ 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.`);
3581
3343
  }
3582
3344
  for (const e3 of Array.from(n2)) {
3583
3345
  const t = l2.get(e3), s3 = e3.getIndices();
3584
- if (c2.get(s3) !== t || e3.listAttributes().some((e4) => c2.get(e4) !== t))
3585
- throw new Error(`[${ue}] Draco primitives must share all, or no, accessors.`);
3346
+ 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.`);
3586
3347
  }
3587
3348
  for (const e3 of Array.from(r2)) {
3588
3349
  const t = e3.getIndices();
3589
- if (c2.has(t) || e3.listAttributes().some((e4) => c2.has(e4)))
3590
- throw new Error(`[${ue}] Accessor cannot be shared by compressed and uncompressed primitives.`);
3350
+ if (c2.has(t) || e3.listAttributes().some((e4) => c2.has(e4))) throw new Error(`[${ue}] Accessor cannot be shared by compressed and uncompressed primitives.`);
3591
3351
  }
3592
3352
  return l2;
3593
3353
  }(this.document), i = /* @__PURE__ */ new Map();
@@ -3595,8 +3355,7 @@
3595
3355
  "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()));
3596
3356
  for (const t of Array.from(r.keys())) {
3597
3357
  const s2 = r.get(t);
3598
- if (!s2)
3599
- throw new Error("Unexpected primitive.");
3358
+ if (!s2) throw new Error("Unexpected primitive.");
3600
3359
  if (i.has(s2)) {
3601
3360
  i.set(s2, i.get(s2));
3602
3361
  continue;
@@ -3617,8 +3376,7 @@
3617
3376
  l2.count = u.numIndices, e.accessorIndexMap.set(o, c2.length), c2.push(l2);
3618
3377
  for (const s3 of t.listSemantics()) {
3619
3378
  const n2 = t.getAttribute(s3);
3620
- if (void 0 === u.attributeIDs[s3])
3621
- continue;
3379
+ if (void 0 === u.attributeIDs[s3]) continue;
3622
3380
  const r2 = e.createAccessorDef(n2);
3623
3381
  r2.count = u.numVertices, e.accessorIndexMap.set(n2, c2.length), c2.push(r2);
3624
3382
  }
@@ -3633,8 +3391,7 @@
3633
3391
  const n = e.jsonDoc.json.meshes[e.meshIndexMap.get(s)];
3634
3392
  for (let r = 0; r < s.listPrimitives().length; r++) {
3635
3393
  const o = s.listPrimitives()[r], i = n.primitives[r], a = t.primitiveHashMap.get(o);
3636
- if (!a)
3637
- continue;
3394
+ if (!a) continue;
3638
3395
  const c2 = t.primitiveEncodingMap.get(a);
3639
3396
  c2 && (i.extensions = i.extensions || {}, i.extensions[ue] = { bufferView: e.otherBufferViewsIndexMap.get(c2.data), attributes: c2.attributeIDs });
3640
3397
  }
@@ -3649,8 +3406,7 @@
3649
3406
  function he(e, t) {
3650
3407
  const s = [], n = e.getIndices();
3651
3408
  s.push(t.get(n));
3652
- for (const n2 of e.listAttributes())
3653
- s.push(t.get(n2));
3409
+ for (const n2 of e.listAttributes()) s.push(t.get(n2));
3654
3410
  return s.sort().join("|");
3655
3411
  }
3656
3412
  le.EXTENSION_NAME = ue, le.EncoderMethod = te;
@@ -3716,8 +3472,7 @@
3716
3472
  }
3717
3473
  read(e) {
3718
3474
  const t = e.jsonDoc;
3719
- if (!t.json.extensions || !t.json.extensions[ge])
3720
- return this;
3475
+ if (!t.json.extensions || !t.json.extensions[ge]) return this;
3721
3476
  const s = (t.json.extensions[ge].lights || []).map((e2) => {
3722
3477
  var t2, s2;
3723
3478
  const n = this.createLight().setName(e2.name || "").setType(e2.type);
@@ -3729,8 +3484,7 @@
3729
3484
  }
3730
3485
  write(e) {
3731
3486
  const t = e.jsonDoc;
3732
- if (0 === this.properties.size)
3733
- return this;
3487
+ if (0 === this.properties.size) return this;
3734
3488
  const s = [], n = /* @__PURE__ */ new Map();
3735
3489
  for (const e2 of this.properties) {
3736
3490
  const t2 = e2, r = { type: t2.getType() };
@@ -4564,20 +4318,17 @@
4564
4318
  }
4565
4319
  read(e) {
4566
4320
  const t = e.jsonDoc;
4567
- if (!t.json.extensions || !t.json.extensions[pt])
4568
- return this;
4321
+ if (!t.json.extensions || !t.json.extensions[pt]) return this;
4569
4322
  const s = (t.json.extensions[pt].variants || []).map((e2) => this.createVariant().setName(e2.name || ""));
4570
4323
  return (t.json.meshes || []).forEach((t2, n) => {
4571
4324
  const r = e.meshes[n];
4572
4325
  (t2.primitives || []).forEach((t3, n2) => {
4573
- if (!t3.extensions || !t3.extensions[pt])
4574
- return;
4326
+ if (!t3.extensions || !t3.extensions[pt]) return;
4575
4327
  const o = this.createMappingList(), i = t3.extensions[pt];
4576
4328
  for (const t4 of i.mappings) {
4577
4329
  const n3 = this.createMapping();
4578
4330
  void 0 !== t4.material && n3.setMaterial(e.materials[t4.material]);
4579
- for (const e2 of t4.variants || [])
4580
- n3.addVariant(s[e2]);
4331
+ for (const e2 of t4.variants || []) n3.addVariant(s[e2]);
4581
4332
  o.addMapping(n3);
4582
4333
  }
4583
4334
  r.listPrimitives()[n2].setExtension(pt, o);
@@ -4586,17 +4337,14 @@
4586
4337
  }
4587
4338
  write(e) {
4588
4339
  const t = e.jsonDoc, s = this.listVariants();
4589
- if (!s.length)
4590
- return this;
4340
+ if (!s.length) return this;
4591
4341
  const n = [], r = /* @__PURE__ */ new Map();
4592
- for (const t2 of s)
4593
- r.set(t2, n.length), n.push(e.createPropertyDef(t2));
4342
+ for (const t2 of s) r.set(t2, n.length), n.push(e.createPropertyDef(t2));
4594
4343
  for (const t2 of this.document.getRoot().listMeshes()) {
4595
4344
  const s2 = e.meshIndexMap.get(t2);
4596
4345
  t2.listPrimitives().forEach((t3, n2) => {
4597
4346
  const o = t3.getExtension(pt);
4598
- if (!o)
4599
- return;
4347
+ if (!o) return;
4600
4348
  const i = e.jsonDoc.json.meshes[s2].primitives[n2], a = o.listMappings().map((t4) => {
4601
4349
  const s3 = e.createPropertyDef(t4), n3 = t4.getMaterial();
4602
4350
  return n3 && (s3.material = e.materialIndexMap.get(n3)), s3.variants = t4.listVariants().map((e2) => r.get(e2)), s3;
@@ -4715,10 +4463,8 @@
4715
4463
  }
4716
4464
  getChannels(e) {
4717
4465
  const t = read(e).dataFormatDescriptor[0];
4718
- if (t.colorModel === KHR_DF_MODEL_ETC1S)
4719
- return 2 === t.samples.length && 15 == (15 & t.samples[1].channelType) ? 4 : 3;
4720
- if (t.colorModel === KHR_DF_MODEL_UASTC)
4721
- return 3 == (15 & t.samples[0].channelType) ? 4 : 3;
4466
+ if (t.colorModel === KHR_DF_MODEL_ETC1S) return 2 === t.samples.length && 15 == (15 & t.samples[1].channelType) ? 4 : 3;
4467
+ if (t.colorModel === KHR_DF_MODEL_UASTC) return 3 == (15 & t.samples[0].channelType) ? 4 : 3;
4722
4468
  throw new Error(`Unexpected KTX2 colorModel, "${t.colorModel}".`);
4723
4469
  }
4724
4470
  getVRAMByteLength(e) {
@@ -4802,8 +4548,7 @@
4802
4548
  }
4803
4549
  read(e) {
4804
4550
  for (const [t, s] of Array.from(e.textureInfos.entries())) {
4805
- if (!s.extensions || !s.extensions[St])
4806
- continue;
4551
+ if (!s.extensions || !s.extensions[St]) continue;
4807
4552
  const e2 = this.createTransform(), n = s.extensions[St];
4808
4553
  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(St, e2);
4809
4554
  }
@@ -4813,8 +4558,7 @@
4813
4558
  const t = Array.from(e.textureInfoDefMap.entries());
4814
4559
  for (const [e2, s] of t) {
4815
4560
  const t2 = e2.getExtension(St);
4816
- if (!t2)
4817
- continue;
4561
+ if (!t2) continue;
4818
4562
  s.extensions = s.extensions || {};
4819
4563
  const n = {}, r = P$1.eq;
4820
4564
  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[St] = n;
@@ -4857,8 +4601,7 @@
4857
4601
  return t && this.set("context", t), delete e["@context"], this.set("properties", e);
4858
4602
  }
4859
4603
  _assertContext(e) {
4860
- if (!(e.split(":")[0] in this.get("context")))
4861
- throw new Error(`KHR_xmp_json_ld: Missing context for term, "${e}".`);
4604
+ if (!(e.split(":")[0] in this.get("context"))) throw new Error(`KHR_xmp_json_ld: Missing context for term, "${e}".`);
4862
4605
  }
4863
4606
  }
4864
4607
  function wt(e) {
@@ -4879,8 +4622,7 @@
4879
4622
  read(e) {
4880
4623
  var t;
4881
4624
  const s = null == (t = e.jsonDoc.json.extensions) ? void 0 : t[Dt];
4882
- if (!s || !s.packets)
4883
- return this;
4625
+ if (!s || !s.packets) return this;
4884
4626
  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()];
4885
4627
  for (let e2 = 0; e2 < i.length; e2++) {
4886
4628
  const t2 = i[e2] || [];
@@ -4953,8 +4695,7 @@
4953
4695
  return this;
4954
4696
  }
4955
4697
  async _loadLibs() {
4956
- if (this._loadedLibs || !this.loader)
4957
- return;
4698
+ if (this._loadedLibs || !this.loader) return;
4958
4699
  const libs = await Promise.all([
4959
4700
  this.loader.initEncoder(),
4960
4701
  this.loader.initDecoder()
@@ -4966,7 +4707,7 @@
4966
4707
  });
4967
4708
  this._loadedLibs = true;
4968
4709
  }
4969
- async parseAsync(obj, { compress = false, dracoOptions, ...options }) {
4710
+ async parseAsync(obj, { compress = false, dracoOptions, ...options }, throwOnError = false) {
4970
4711
  if (!this.loader) {
4971
4712
  console.error("GLTFDracoExporter: No DRACOLoader2 instance provided");
4972
4713
  return super.parseAsync(obj, options);
@@ -4978,37 +4719,41 @@
4978
4719
  }
4979
4720
  const uncompressed = await new Promise((resolve, reject) => this.parse(obj, resolve, reject, ops));
4980
4721
  const uncompressedBlob = await super.parseAsync(uncompressed, ops);
4981
- if (!compress)
4982
- return uncompressedBlob;
4983
- if (!uncompressed)
4984
- throw new Error("GLTFDracoExporter: gltf is null");
4985
- let gltf = uncompressed;
4986
- const bytes = gltf.byteLength || Infinity;
4987
- const iDocument = await (typeof gltf === "object" && !gltf.byteLength ? this._io.readJSON({
4988
- json: gltf,
4989
- resources: {}
4990
- }) : this._io.readBinary(new Uint8Array(gltf)));
4991
- iDocument.createExtension(le).setRequired(true).setEncoderOptions({ ...this._encoderOptions, ...dracoOptions ?? {} });
4992
- if (ops.exportExt === "glb") {
4993
- gltf = await this._io.writeBinary(iDocument);
4994
- if (isFinite(bytes)) {
4995
- console.log("DRACO Compression ratio: " + (gltf.byteLength / bytes).toFixed(5));
4996
- }
4997
- } else {
4998
- const jDoc = await this._io.writeJSON(iDocument);
4999
- gltf = jDoc.json;
5000
- if (Object.values(jDoc.resources).filter((v2) => v2).length > 0) {
5001
- console.warn("DRACOExporter: extra resources in resources not supported properly");
5002
- gltf.resources = jDoc.resources;
4722
+ if (!compress) return uncompressedBlob;
4723
+ try {
4724
+ if (!uncompressed) throw new Error("GLTFDracoExporter: gltf is null");
4725
+ let gltf = uncompressed;
4726
+ const bytes = gltf.byteLength || Infinity;
4727
+ const iDocument = await (typeof gltf === "object" && !gltf.byteLength ? this._io.readJSON({
4728
+ json: gltf,
4729
+ resources: {}
4730
+ }) : this._io.readBinary(new Uint8Array(gltf)));
4731
+ iDocument.createExtension(le).setRequired(true).setEncoderOptions({ ...this._encoderOptions, ...dracoOptions ?? {} });
4732
+ if (ops.exportExt === "glb") {
4733
+ gltf = await this._io.writeBinary(iDocument);
4734
+ if (isFinite(bytes)) {
4735
+ console.log("DRACO Compression ratio: " + (gltf.byteLength / bytes).toFixed(5));
4736
+ }
4737
+ } else {
4738
+ const jDoc = await this._io.writeJSON(iDocument);
4739
+ gltf = jDoc.json;
4740
+ if (Object.values(jDoc.resources).filter((v2) => v2).length > 0) {
4741
+ console.warn("DRACOExporter: extra resources in resources not supported properly");
4742
+ gltf.resources = jDoc.resources;
4743
+ }
5003
4744
  }
4745
+ gltf.__isGLTFOutput = true;
4746
+ const blob = await super.parseAsync(gltf, ops);
4747
+ if (!blob) throw new Error("GLTFDracoExporter: blob is null");
4748
+ blob.ext = "glb";
4749
+ blob.__uncompressed = uncompressedBlob;
4750
+ return blob;
4751
+ } catch (e) {
4752
+ if (throwOnError) throw e;
4753
+ console.error("Unable to compress glb with DRACO extension, fallback to uncompressed");
4754
+ console.error(e);
4755
+ return uncompressedBlob;
5004
4756
  }
5005
- gltf.__isGLTFOutput = true;
5006
- const blob = await super.parseAsync(gltf, ops);
5007
- if (!blob)
5008
- throw new Error("GLTFDracoExporter: blob is null");
5009
- blob.ext = "glb";
5010
- blob.__uncompressed = uncompressedBlob;
5011
- return blob;
5012
4757
  }
5013
4758
  addExtension(extension) {
5014
4759
  this._io.registerExtensions([extension]);
@@ -5192,8 +4937,7 @@
5192
4937
  if (paramsExt) {
5193
4938
  const sceneIndex = context.jsonDoc.json.scene || 0;
5194
4939
  const sceneDef = jsonDoc.json.scenes[sceneIndex];
5195
- if (!sceneDef)
5196
- return;
4940
+ if (!sceneDef) return;
5197
4941
  sceneDef.extensions = sceneDef.extensions || {};
5198
4942
  sceneDef.extensions[this.extensionName] = paramsExt.getExtras();
5199
4943
  }
@@ -5203,14 +4947,10 @@
5203
4947
  }
5204
4948
  function stringToChannel(s) {
5205
4949
  let r = 0;
5206
- if (s.includes("R"))
5207
- r |= d.R;
5208
- if (s.includes("G"))
5209
- r |= d.G;
5210
- if (s.includes("B"))
5211
- r |= d.B;
5212
- if (s.includes("A"))
5213
- r |= d.A;
4950
+ if (s.includes("R")) r |= d.R;
4951
+ if (s.includes("G")) r |= d.G;
4952
+ if (s.includes("B")) r |= d.B;
4953
+ if (s.includes("A")) r |= d.A;
5214
4954
  return r;
5215
4955
  }
5216
4956
  function createGenericExtensionClass(name, textures) {
@@ -5234,6 +4974,45 @@
5234
4974
  constructor() {
5235
4975
  super(...arguments);
5236
4976
  this.enabled = true;
4977
+ this.extraExtensions = [
4978
+ [threepipe.GLTFMaterialsBumpMapExtension.WebGiMaterialsBumpMapExtension, threepipe.GLTFMaterialsBumpMapExtension.Textures],
4979
+ [threepipe.GLTFMaterialsLightMapExtension.WebGiMaterialsLightMapExtension, threepipe.GLTFMaterialsLightMapExtension.Textures],
4980
+ [threepipe.GLTFMaterialsAlphaMapExtension.WebGiMaterialsAlphaMapExtension, threepipe.GLTFMaterialsAlphaMapExtension.Textures],
4981
+ [threepipe.GLTFMaterialsDisplacementMapExtension.WebGiMaterialsDisplacementMapExtension, threepipe.GLTFMaterialsDisplacementMapExtension.Textures],
4982
+ [threepipe.customBumpMapGLTFExtension.name, threepipe.customBumpMapGLTFExtension.textures],
4983
+ [threepipe.GLTFLightExtrasExtension.WebGiLightExtrasExtension, threepipe.GLTFLightExtrasExtension.Textures],
4984
+ [threepipe.GLTFObject3DExtrasExtension.WebGiObject3DExtrasExtension, threepipe.GLTFObject3DExtrasExtension.Textures],
4985
+ [threepipe.GLTFMaterialExtrasExtension.WebGiMaterialExtrasExtension, threepipe.GLTFMaterialExtrasExtension.Textures],
4986
+ [threepipe.clearCoatTintGLTFExtension.name, threepipe.clearCoatTintGLTFExtension.textures],
4987
+ [threepipe.noiseBumpMaterialGLTFExtension.name, threepipe.noiseBumpMaterialGLTFExtension.textures],
4988
+ [threepipe.fragmentClippingGLTFExtension.name, threepipe.fragmentClippingGLTFExtension.textures],
4989
+ // extenal plugins
4990
+ // AnisotropyMaterialExtension
4991
+ ["WEBGI_materials_anisotropy", {
4992
+ anisotropyDirection: "RGB"
4993
+ }]
4994
+ // todo port
4995
+ // DiamondMaterialExtension
4996
+ // AnimationMarkersExtension
4997
+ // ThinFilmLayerMaterialExtension
4998
+ // TriplanarMappingMaterialExtension
4999
+ // SSBevelMaterialExtension
5000
+ ];
5001
+ this._lastExporter = void 0;
5002
+ this._ctor = (_2, _exporter) => {
5003
+ if (!this._viewer) throw new Error("Viewer not set");
5004
+ const tempFile = threepipe.generateUUID() + ".drc";
5005
+ const ex = new GLTFDracoExporter(
5006
+ {},
5007
+ // todo unregister on dispose
5008
+ this._viewer.assetManager.importer.registerFile(tempFile)
5009
+ );
5010
+ ex.setup(this._viewer, _exporter.extensions);
5011
+ for (const [ext, config] of this.extraExtensions) {
5012
+ ex.createAndAddExtension(ext, config);
5013
+ }
5014
+ return ex;
5015
+ };
5237
5016
  this._makeUi = (exporter) => {
5238
5017
  var _a;
5239
5018
  return [
@@ -5288,51 +5067,38 @@
5288
5067
  ];
5289
5068
  };
5290
5069
  }
5070
+ addExtension(name, textures) {
5071
+ const ext = this.extraExtensions.findIndex((e) => e[0] === name);
5072
+ if (ext >= 0) this.extraExtensions[ext] = [name, textures];
5073
+ else this.extraExtensions.push([name, textures]);
5074
+ }
5075
+ /**
5076
+ * Note - don't remove an extension when removing a plugin.
5077
+ *
5078
+ * 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.
5079
+ * @param name
5080
+ */
5081
+ removeExtension(name) {
5082
+ const ext = this.extraExtensions.findIndex((e) => e[0] === name);
5083
+ if (ext >= 0) this.extraExtensions.splice(ext, 1);
5084
+ }
5291
5085
  onAdded(viewer) {
5292
5086
  var _a;
5293
5087
  super.onAdded(viewer);
5294
- const importer = viewer.assetManager.importer;
5295
5088
  const exporter = viewer.assetManager.exporter;
5296
- const glbExporter = exporter.getExporter("glb");
5297
- if (glbExporter)
5298
- exporter.removeExporter(glbExporter);
5299
- exporter.addExporter({
5300
- ...glbExporter || {
5089
+ let glbExporter = exporter.getExporter("glb");
5090
+ this._lastExporter = glbExporter == null ? void 0 : glbExporter.ctor;
5091
+ if (!glbExporter) {
5092
+ console.error("GLTFDracoExportPlugin: GLB exporter not found in AssetManager.exporter, creating a new one.");
5093
+ glbExporter = {
5301
5094
  ext: ["glb", "gltf"],
5302
- extensions: []
5303
- },
5304
- // for extensions
5305
- ctor: (_2, _exporter) => {
5306
- const tempFile = threepipe.generateUUID() + ".drc";
5307
- const ex = new GLTFDracoExporter(
5308
- {},
5309
- // todo unregister on dispose
5310
- importer.registerFile(tempFile)
5311
- );
5312
- ex.setup(viewer, _exporter.extensions);
5313
- ex.createAndAddExtension(threepipe.GLTFMaterialsBumpMapExtension.WebGiMaterialsBumpMapExtension, {
5314
- bumpTexture: "R"
5315
- });
5316
- ex.createAndAddExtension(threepipe.GLTFMaterialsLightMapExtension.WebGiMaterialsLightMapExtension, {
5317
- lightMapTexture: "RGB"
5318
- });
5319
- ex.createAndAddExtension(threepipe.GLTFMaterialsAlphaMapExtension.WebGiMaterialsAlphaMapExtension, {
5320
- alphaTexture: "G"
5321
- });
5322
- ex.createAndAddExtension(threepipe.GLTFMaterialsDisplacementMapExtension.WebGiMaterialsDisplacementMapExtension, {
5323
- displacementTexture: "R"
5324
- });
5325
- ex.createAndAddExtension(threepipe.CustomBumpMapPlugin.CUSTOM_BUMP_MAP_GLTF_EXTENSION, {
5326
- customBumpMap: "RGB"
5327
- });
5328
- ex.createAndAddExtension(threepipe.GLTFLightExtrasExtension.WebGiLightExtrasExtension);
5329
- ex.createAndAddExtension(threepipe.GLTFObject3DExtrasExtension.WebGiObject3DExtrasExtension);
5330
- ex.createAndAddExtension(threepipe.GLTFMaterialExtrasExtension.WebGiMaterialExtrasExtension);
5331
- ex.createAndAddExtension(threepipe.ClearcoatTintPlugin.CLEARCOAT_TINT_GLTF_EXTENSION);
5332
- ex.createAndAddExtension(threepipe.NoiseBumpMaterialPlugin.NOISE_BUMP_MATERIAL_GLTF_EXTENSION);
5333
- return ex;
5334
- }
5335
- });
5095
+ extensions: [],
5096
+ ctor: this._ctor
5097
+ };
5098
+ exporter.addExporter(glbExporter);
5099
+ } else {
5100
+ glbExporter.ctor = this._ctor;
5101
+ }
5336
5102
  const exportPlugin = viewer.getPlugin(threepipe.AssetExporterPlugin);
5337
5103
  if (exportPlugin) {
5338
5104
  Object.assign(exportPlugin.exportOptions, {
@@ -5358,6 +5124,14 @@
5358
5124
  }
5359
5125
  }
5360
5126
  }
5127
+ onRemove(viewer) {
5128
+ const exporter = viewer.assetManager.exporter;
5129
+ const glbExporter = exporter.getExporter("glb");
5130
+ if (glbExporter && this._lastExporter) {
5131
+ glbExporter.ctor = this._lastExporter;
5132
+ }
5133
+ super.onRemove(viewer);
5134
+ }
5361
5135
  };
5362
5136
  _GLTFDracoExportPlugin.PluginType = "GLTFDracoExportPlugin";
5363
5137
  let GLTFDracoExportPlugin = _GLTFDracoExportPlugin;