ldr 0.6.0 → 0.8.0
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/README.md +12 -3
- package/dist/cdn.d.ts +2 -1
- package/dist/cli.js +55 -17
- package/dist/embedded.d.ts +2 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +539 -25
- package/dist/instructions.d.ts +80 -0
- package/dist/load-worker.gen.d.ts +1 -1
- package/dist/model.d.ts +23 -1
- package/dist/node/index.js +556 -34
- package/dist/parts-cdn.d.ts +2 -0
- package/dist/render.d.ts +1 -1
- package/dist/scene.d.ts +3 -2
- package/dist/spec.d.ts +7 -0
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/spec.ts
|
|
2
2
|
var norm = (s) => s.trim().toLowerCase().replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
3
3
|
function parseColor(tok) {
|
|
4
4
|
if (/^0x/i.test(tok))
|
|
@@ -455,6 +455,7 @@ function transformTexMap(map, m) {
|
|
|
455
455
|
const x = (q) => [m[3] * q[0] + m[4] * q[1] + m[5] * q[2] + m[0], m[6] * q[0] + m[7] * q[1] + m[8] * q[2] + m[1], m[9] * q[0] + m[10] * q[1] + m[11] * q[2] + m[2]];
|
|
456
456
|
return { ...map, p1: x(map.p1), p2: x(map.p2), p3: x(map.p3) };
|
|
457
457
|
}
|
|
458
|
+
var STUB_OVERRIDES = { "32531.dat": "32531a.dat" };
|
|
458
459
|
function mul(a, b) {
|
|
459
460
|
const [ax, ay, az, a0, a1, a2, a3, a4, a5, a6, a7, a8] = a, [bx, by, bz, b0, b1, b2, b3, b4, b5, b6, b7, b8] = b;
|
|
460
461
|
return [
|
|
@@ -689,12 +690,15 @@ function fileStepViews(f) {
|
|
|
689
690
|
viewMemo.set(f, out);
|
|
690
691
|
return out;
|
|
691
692
|
}
|
|
692
|
-
// ../../../../../../../tmp/ldr-build-
|
|
693
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/model.ts
|
|
694
|
+
var CALLOUT_END = 999999;
|
|
695
|
+
var stepKey = (steps) => steps.map((x) => String(x).padStart(6, "0")).join(".") + "~";
|
|
693
696
|
function flatten(doc, opts = {}) {
|
|
694
697
|
const out = [];
|
|
695
698
|
const maxDepth = opts.maxDepth ?? 64;
|
|
696
|
-
const loose = opts.looseGeometry !== false, tx = !!opts.textures;
|
|
699
|
+
const loose = opts.looseGeometry !== false, tx = !!opts.textures, co = !!opts.callouts;
|
|
697
700
|
const src = new Map;
|
|
701
|
+
let subs = 0;
|
|
698
702
|
const lazy = (f, k) => {
|
|
699
703
|
const key = f.name + "#" + k;
|
|
700
704
|
let fn = src.get(key);
|
|
@@ -705,16 +709,44 @@ function flatten(doc, opts = {}) {
|
|
|
705
709
|
}
|
|
706
710
|
return fn;
|
|
707
711
|
};
|
|
708
|
-
const walk = (d, fname, m, color, path, stepPath, depth, texIn) => {
|
|
712
|
+
const walk = (d, fname, m, color, path, stepPath, depth, texIn, fixed = null, subPath = [], subMats = []) => {
|
|
709
713
|
const f = d.files.get(fname);
|
|
710
714
|
if (!f || depth > maxDepth)
|
|
711
715
|
return;
|
|
712
716
|
let s = 0;
|
|
717
|
+
const subId = depth > 0 ? ++subs : 0;
|
|
718
|
+
const sp0 = co && subId ? [...subPath, subId] : subPath;
|
|
719
|
+
const sm0 = co && subId ? [...subMats, m] : subMats;
|
|
720
|
+
const groups = co && !fixed ? new Map : null;
|
|
721
|
+
let ordStep = -1, ord = 0;
|
|
722
|
+
const sub = (sd, file, mm, col, sp, lt) => {
|
|
723
|
+
if (ordStep !== s) {
|
|
724
|
+
ordStep = s;
|
|
725
|
+
ord = 0;
|
|
726
|
+
}
|
|
727
|
+
const g = groups?.get(s + "|" + file);
|
|
728
|
+
if (g) {
|
|
729
|
+
g.n++;
|
|
730
|
+
return walk(sd, sd === d ? file : sd.main, mm, col, path + "/" + file, [...sp, CALLOUT_END], depth + 1, lt, [...sp, CALLOUT_END], sp0, sm0);
|
|
731
|
+
}
|
|
732
|
+
const spo = [...sp, ord++], from = out.length;
|
|
733
|
+
walk(sd, sd === d ? file : sd.main, mm, col, path + "/" + file, spo, depth + 1, lt, fixed, sp0, sm0);
|
|
734
|
+
groups?.set(s + "|" + file, { n: 1, from, to: out.length });
|
|
735
|
+
};
|
|
713
736
|
const views = fileStepViews(f);
|
|
714
737
|
const ls = loose ? looseSteps(f) : [];
|
|
715
738
|
let li = 0;
|
|
716
739
|
const emit = (part, col, mm, sp, k, embedded, tex) => {
|
|
740
|
+
if (fixed)
|
|
741
|
+
sp = fixed;
|
|
717
742
|
const i = { part, color: col, m: mm, step: sp[0], steps: sp, localStep: k, path };
|
|
743
|
+
if (subId) {
|
|
744
|
+
i.sub = subId;
|
|
745
|
+
if (co) {
|
|
746
|
+
i.subPath = sp0;
|
|
747
|
+
i.subMats = sm0;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
718
750
|
if (embedded)
|
|
719
751
|
i.embedded = true;
|
|
720
752
|
if (tex) {
|
|
@@ -760,7 +792,7 @@ function flatten(doc, opts = {}) {
|
|
|
760
792
|
const lt = tex && local ? transformTexMap(tex, local) : null;
|
|
761
793
|
if (d.files.has(c.file)) {
|
|
762
794
|
if (fileKind(d, c.file) === "model") {
|
|
763
|
-
|
|
795
|
+
sub(d, c.file, mm, col, sp, lt);
|
|
764
796
|
continue;
|
|
765
797
|
}
|
|
766
798
|
emit(c.file, col, mm, sp, s, true, lt);
|
|
@@ -768,12 +800,18 @@ function flatten(doc, opts = {}) {
|
|
|
768
800
|
}
|
|
769
801
|
const ext = opts.resolveModel?.(c.file);
|
|
770
802
|
if (ext) {
|
|
771
|
-
|
|
803
|
+
sub(ext, c.file, mm, col, sp, lt);
|
|
772
804
|
continue;
|
|
773
805
|
}
|
|
774
806
|
emit(c.file, col, mm, sp, s, false, lt);
|
|
775
807
|
}
|
|
776
808
|
flushLoose(Infinity);
|
|
809
|
+
if (groups) {
|
|
810
|
+
for (const g of groups.values())
|
|
811
|
+
if (g.n > 1)
|
|
812
|
+
for (let j = g.from;j < g.to; j++)
|
|
813
|
+
out[j].mult ??= g.n;
|
|
814
|
+
}
|
|
777
815
|
};
|
|
778
816
|
if (fileKind(doc, doc.main) === "part") {
|
|
779
817
|
const f = doc.files.get(doc.main);
|
|
@@ -788,7 +826,7 @@ function parseModel(text, name = "main.ldr", opts) {
|
|
|
788
826
|
return flatten(parse(text, name, { geometryText: true }), opts);
|
|
789
827
|
}
|
|
790
828
|
function sequenceSteps(insts) {
|
|
791
|
-
const key = (i) => i.steps
|
|
829
|
+
const key = (i) => stepKey(i.steps);
|
|
792
830
|
const uniq = [...new Set(insts.map(key))].sort();
|
|
793
831
|
const rank = new Map(uniq.map((k, j) => [k, j]));
|
|
794
832
|
const stepOf = new Int32Array(insts.length);
|
|
@@ -810,10 +848,378 @@ function parseLDConfig(text) {
|
|
|
810
848
|
}
|
|
811
849
|
return out;
|
|
812
850
|
}
|
|
813
|
-
// ../../../../../../../tmp/ldr-build-
|
|
851
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/instructions.ts
|
|
852
|
+
var MIN_VIS = 0.5;
|
|
853
|
+
var REORIENT = 0.35;
|
|
854
|
+
var deg = Math.PI / 180;
|
|
855
|
+
function viewDir(azimuthDeg, elevationDeg) {
|
|
856
|
+
const a = azimuthDeg * deg, e = elevationDeg * deg;
|
|
857
|
+
return [Math.sin(a) * Math.cos(e), -Math.sin(e), -Math.cos(a) * Math.cos(e)];
|
|
858
|
+
}
|
|
859
|
+
function isolateMask(insts, sub) {
|
|
860
|
+
const m = new Uint8Array(insts.length);
|
|
861
|
+
insts.forEach((i, k) => {
|
|
862
|
+
if (i.subPath?.includes(sub))
|
|
863
|
+
m[k] = 1;
|
|
864
|
+
});
|
|
865
|
+
return m;
|
|
866
|
+
}
|
|
867
|
+
function commonSub(insts, ids, whole) {
|
|
868
|
+
const path = insts[ids[0]]?.subPath;
|
|
869
|
+
if (!path)
|
|
870
|
+
return;
|
|
871
|
+
let n = path.length;
|
|
872
|
+
for (const id of ids) {
|
|
873
|
+
const p = insts[id].subPath;
|
|
874
|
+
if (!p)
|
|
875
|
+
return;
|
|
876
|
+
let j = 0;
|
|
877
|
+
while (j < n && j < p.length && p[j] === path[j])
|
|
878
|
+
j++;
|
|
879
|
+
n = j;
|
|
880
|
+
if (!n)
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
return whole(path[n - 1]) ? undefined : path[n - 1];
|
|
884
|
+
}
|
|
885
|
+
function instanceBoxes(insts, parts) {
|
|
886
|
+
return insts.map((i) => {
|
|
887
|
+
const b = parts[i.part]?.bbox;
|
|
888
|
+
if (!b)
|
|
889
|
+
return null;
|
|
890
|
+
const m = i.m;
|
|
891
|
+
const o = new Float64Array([Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity]);
|
|
892
|
+
for (let c = 0;c < 8; c++) {
|
|
893
|
+
const x = c & 1 ? b[3] : b[0], y = c & 2 ? b[4] : b[1], z = c & 4 ? b[5] : b[2];
|
|
894
|
+
const w = [m[0] + m[3] * x + m[4] * y + m[5] * z, m[1] + m[6] * x + m[7] * y + m[8] * z, m[2] + m[9] * x + m[10] * y + m[11] * z];
|
|
895
|
+
for (let k = 0;k < 3; k++) {
|
|
896
|
+
if (w[k] < o[k])
|
|
897
|
+
o[k] = w[k];
|
|
898
|
+
if (w[k] > o[k + 3])
|
|
899
|
+
o[k + 3] = w[k];
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
return o;
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
class BoxGrid {
|
|
907
|
+
cells = new Map;
|
|
908
|
+
boxes;
|
|
909
|
+
cell;
|
|
910
|
+
stamp;
|
|
911
|
+
q = 0;
|
|
912
|
+
lo;
|
|
913
|
+
hi;
|
|
914
|
+
constructor(boxes, cell) {
|
|
915
|
+
this.boxes = boxes;
|
|
916
|
+
this.cell = cell;
|
|
917
|
+
this.stamp = new Int32Array(boxes.length);
|
|
918
|
+
this.lo = [Infinity, Infinity, Infinity];
|
|
919
|
+
this.hi = [-Infinity, -Infinity, -Infinity];
|
|
920
|
+
for (const b of boxes)
|
|
921
|
+
if (b)
|
|
922
|
+
for (let k = 0;k < 3; k++) {
|
|
923
|
+
this.lo[k] = Math.min(this.lo[k], b[k]);
|
|
924
|
+
this.hi[k] = Math.max(this.hi[k], b[k + 3]);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
key(i, j, k) {
|
|
928
|
+
return (i + 1024) * 4194304 + (j + 1024) * 2048 + (k + 1024);
|
|
929
|
+
}
|
|
930
|
+
add(id) {
|
|
931
|
+
const b = this.boxes[id];
|
|
932
|
+
if (!b)
|
|
933
|
+
return;
|
|
934
|
+
const c = this.cell;
|
|
935
|
+
for (let i = Math.floor(b[0] / c);i <= Math.floor(b[3] / c); i++)
|
|
936
|
+
for (let j = Math.floor(b[1] / c);j <= Math.floor(b[4] / c); j++)
|
|
937
|
+
for (let k = Math.floor(b[2] / c);k <= Math.floor(b[5] / c); k++) {
|
|
938
|
+
const key = this.key(i, j, k);
|
|
939
|
+
let l = this.cells.get(key);
|
|
940
|
+
if (!l)
|
|
941
|
+
this.cells.set(key, l = []);
|
|
942
|
+
l.push(id);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
inside(p, self) {
|
|
946
|
+
const c = this.cell;
|
|
947
|
+
const l = this.cells.get(this.key(Math.floor(p[0] / c), Math.floor(p[1] / c), Math.floor(p[2] / c)));
|
|
948
|
+
if (!l)
|
|
949
|
+
return false;
|
|
950
|
+
for (const id of l) {
|
|
951
|
+
if (id === self)
|
|
952
|
+
continue;
|
|
953
|
+
const b = this.boxes[id];
|
|
954
|
+
if (p[0] > b[0] && p[0] < b[3] && p[1] > b[1] && p[1] < b[4] && p[2] > b[2] && p[2] < b[5])
|
|
955
|
+
return true;
|
|
956
|
+
}
|
|
957
|
+
return false;
|
|
958
|
+
}
|
|
959
|
+
hits(p, d, self, eps = 0.5) {
|
|
960
|
+
const c = this.cell, q = ++this.q;
|
|
961
|
+
let i = Math.floor(p[0] / c), j = Math.floor(p[1] / c), k = Math.floor(p[2] / c);
|
|
962
|
+
const step = d.map((v) => v > 0 ? 1 : v < 0 ? -1 : 0);
|
|
963
|
+
const idx = [i, j, k];
|
|
964
|
+
const tMax = [0, 1, 2].map((a) => d[a] === 0 ? Infinity : ((idx[a] + (d[a] > 0 ? 1 : 0)) * c - p[a]) / d[a]);
|
|
965
|
+
const tDelta = [0, 1, 2].map((a) => d[a] === 0 ? Infinity : c / Math.abs(d[a]));
|
|
966
|
+
const bound = [0, 1, 2].map((a) => d[a] > 0 ? Math.floor(this.hi[a] / c) + 1 : d[a] < 0 ? Math.floor(this.lo[a] / c) - 1 : 0);
|
|
967
|
+
for (let n = 0;n < 4096; n++) {
|
|
968
|
+
const l = this.cells.get(this.key(idx[0], idx[1], idx[2]));
|
|
969
|
+
if (l)
|
|
970
|
+
for (const id of l) {
|
|
971
|
+
if (id === self || this.stamp[id] === q)
|
|
972
|
+
continue;
|
|
973
|
+
this.stamp[id] = q;
|
|
974
|
+
if (rayBox(p, d, this.boxes[id], eps))
|
|
975
|
+
return true;
|
|
976
|
+
}
|
|
977
|
+
const a = tMax[0] < tMax[1] ? tMax[0] < tMax[2] ? 0 : 2 : tMax[1] < tMax[2] ? 1 : 2;
|
|
978
|
+
idx[a] += step[a];
|
|
979
|
+
tMax[a] += tDelta[a];
|
|
980
|
+
if (step[a] === 0 || idx[a] === bound[a])
|
|
981
|
+
return false;
|
|
982
|
+
}
|
|
983
|
+
return false;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
function rayBox(p, d, b, eps) {
|
|
987
|
+
let t0 = 0.000001, t1 = Infinity;
|
|
988
|
+
for (let a = 0;a < 3; a++) {
|
|
989
|
+
const lo = b[a] + eps, hi = b[a + 3] - eps;
|
|
990
|
+
if (d[a] === 0) {
|
|
991
|
+
if (p[a] <= lo || p[a] >= hi)
|
|
992
|
+
return false;
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
let ta = (lo - p[a]) / d[a], tb = (hi - p[a]) / d[a];
|
|
996
|
+
if (ta > tb)
|
|
997
|
+
[ta, tb] = [tb, ta];
|
|
998
|
+
if (ta > t0)
|
|
999
|
+
t0 = ta;
|
|
1000
|
+
if (tb < t1)
|
|
1001
|
+
t1 = tb;
|
|
1002
|
+
if (t0 > t1)
|
|
1003
|
+
return false;
|
|
1004
|
+
}
|
|
1005
|
+
return true;
|
|
1006
|
+
}
|
|
1007
|
+
function boxVisibility(grid, id, d, n = 3) {
|
|
1008
|
+
const b = grid.boxes[id];
|
|
1009
|
+
let vis = 0, tot = 0;
|
|
1010
|
+
for (let a = 0;a < 3; a++)
|
|
1011
|
+
for (const side of [-1, 1]) {
|
|
1012
|
+
const cos = side * d[a];
|
|
1013
|
+
if (cos <= 0.02)
|
|
1014
|
+
continue;
|
|
1015
|
+
const u = (a + 1) % 3, v = (a + 2) % 3;
|
|
1016
|
+
const area = (b[u + 3] - b[u]) * (b[v + 3] - b[v]);
|
|
1017
|
+
if (area <= 0)
|
|
1018
|
+
continue;
|
|
1019
|
+
const w = area * cos / (n * n);
|
|
1020
|
+
const p = [0, 0, 0], q = [0, 0, 0];
|
|
1021
|
+
p[a] = side > 0 ? b[a + 3] + 0.25 : b[a] - 0.25;
|
|
1022
|
+
q[a] = side > 0 ? b[a + 3] + 1 : b[a] - 1;
|
|
1023
|
+
for (let s = 0;s < n; s++)
|
|
1024
|
+
for (let t = 0;t < n; t++) {
|
|
1025
|
+
p[u] = q[u] = b[u] + (s + 0.5) / n * (b[u + 3] - b[u]);
|
|
1026
|
+
p[v] = q[v] = b[v] + (t + 0.5) / n * (b[v + 3] - b[v]);
|
|
1027
|
+
if (grid.inside(q, id))
|
|
1028
|
+
continue;
|
|
1029
|
+
tot += w;
|
|
1030
|
+
if (!grid.hits(p, d, id))
|
|
1031
|
+
vis += w;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
return tot ? vis / tot : -1;
|
|
1035
|
+
}
|
|
1036
|
+
var angle = (a, b) => Math.acos(Math.max(-1, Math.min(1, a[0] * b[0] + a[1] * b[1] + a[2] * b[2]))) / deg;
|
|
1037
|
+
var spread = (l, max) => l.length <= max ? l : Array.from({ length: max }, (_, i) => l[Math.floor((i + 0.5) * l.length / max)]);
|
|
1038
|
+
function planStepViews(insts, parts, stepOf, nSteps, o = {}) {
|
|
1039
|
+
const boxes = instanceBoxes(insts, parts);
|
|
1040
|
+
const byStep = Array.from({ length: nSteps }, () => []);
|
|
1041
|
+
for (let k = 0;k < insts.length; k++)
|
|
1042
|
+
if (boxes[k])
|
|
1043
|
+
byStep[stepOf[k]]?.push(k);
|
|
1044
|
+
let nBoxed = 0;
|
|
1045
|
+
for (const b of boxes)
|
|
1046
|
+
if (b)
|
|
1047
|
+
nBoxed++;
|
|
1048
|
+
const isoCache = new Map;
|
|
1049
|
+
const isoParts = (u) => {
|
|
1050
|
+
let l = isoCache.get(u);
|
|
1051
|
+
if (!l) {
|
|
1052
|
+
l = [];
|
|
1053
|
+
for (let k = 0;k < insts.length; k++)
|
|
1054
|
+
if (boxes[k] && insts[k].subPath?.includes(u))
|
|
1055
|
+
l.push(k);
|
|
1056
|
+
isoCache.set(u, l);
|
|
1057
|
+
}
|
|
1058
|
+
return l;
|
|
1059
|
+
};
|
|
1060
|
+
const subParts = new Map;
|
|
1061
|
+
for (let k = 0;k < insts.length; k++) {
|
|
1062
|
+
const u = insts[k].sub;
|
|
1063
|
+
if (u !== undefined && boxes[k])
|
|
1064
|
+
(subParts.get(u) ?? subParts.set(u, []).get(u)).push(k);
|
|
1065
|
+
}
|
|
1066
|
+
let size = 0;
|
|
1067
|
+
for (const b of boxes)
|
|
1068
|
+
if (b)
|
|
1069
|
+
size = Math.max(size, b[3] - b[0], b[4] - b[1], b[5] - b[2]);
|
|
1070
|
+
let ext = 0;
|
|
1071
|
+
for (const b of boxes)
|
|
1072
|
+
if (b)
|
|
1073
|
+
ext = Math.max(ext, Math.abs(b[0]), Math.abs(b[2]), Math.abs(b[3]), Math.abs(b[5]), Math.abs(b[1]), Math.abs(b[4]));
|
|
1074
|
+
const grid = new BoxGrid(boxes, Math.max(20, Math.min(160, size || 40), ext / 1000));
|
|
1075
|
+
const def = viewDir(o.azimuth ?? 45, o.elevation ?? 30), minVis = o.minVis ?? MIN_VIS, reorient = o.reorient ?? REORIENT, turn = o.turnCost ?? 0.002;
|
|
1076
|
+
const above = [], below = [];
|
|
1077
|
+
for (let az = 0;az < 360; az += 45) {
|
|
1078
|
+
for (const el of [15, 30, 50])
|
|
1079
|
+
above.push(viewDir(az, el));
|
|
1080
|
+
below.push(viewDir(az, -30));
|
|
1081
|
+
}
|
|
1082
|
+
const built = [Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity];
|
|
1083
|
+
const views = [];
|
|
1084
|
+
let prevMain = def;
|
|
1085
|
+
const prevIso = new Map;
|
|
1086
|
+
const local = new Map;
|
|
1087
|
+
const localOf = (u) => {
|
|
1088
|
+
let l = local.get(u);
|
|
1089
|
+
if (l)
|
|
1090
|
+
return l;
|
|
1091
|
+
const k0 = isoParts(u)[0];
|
|
1092
|
+
const i0 = insts[k0];
|
|
1093
|
+
const P = i0.subMats?.[i0.subPath.indexOf(u)] ?? null;
|
|
1094
|
+
const inv = P ? invert(P) : null;
|
|
1095
|
+
const lb = new Array(insts.length).fill(null);
|
|
1096
|
+
const own = isoParts(u);
|
|
1097
|
+
const loc = instanceBoxes(own.map((k) => ({ part: insts[k].part, m: inv ? mul(inv, insts[k].m) : insts[k].m })), parts);
|
|
1098
|
+
own.forEach((k, j) => lb[k] = loc[j]);
|
|
1099
|
+
local.set(u, l = { boxes: lb, P: P && inv ? [...P] : [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1] });
|
|
1100
|
+
return l;
|
|
1101
|
+
};
|
|
1102
|
+
let g = grid;
|
|
1103
|
+
const score = (ids, d) => {
|
|
1104
|
+
let mn = 1, sum = 0, n = 0;
|
|
1105
|
+
for (const id of ids) {
|
|
1106
|
+
const v = boxVisibility(g, id, d);
|
|
1107
|
+
if (v < 0)
|
|
1108
|
+
continue;
|
|
1109
|
+
mn = Math.min(mn, v);
|
|
1110
|
+
sum += v;
|
|
1111
|
+
n++;
|
|
1112
|
+
}
|
|
1113
|
+
return { mn: n ? mn : 1, mean: n ? sum / n : 1 };
|
|
1114
|
+
};
|
|
1115
|
+
const pref = (d) => {
|
|
1116
|
+
const h = Math.hypot(d[0], d[2]) || 1, el = Math.asin(Math.max(-1, Math.min(1, -d[1]))) / deg;
|
|
1117
|
+
return Math.abs(d[0] / h * (d[2] / h)) + 0.5 * Math.max(0, -d[2] / h) - Math.abs(el - 30) / 90;
|
|
1118
|
+
};
|
|
1119
|
+
const next = () => {
|
|
1120
|
+
const s = views.length, add = byStep[s];
|
|
1121
|
+
for (const id of add) {
|
|
1122
|
+
grid.add(id);
|
|
1123
|
+
const b = boxes[id];
|
|
1124
|
+
for (let k = 0;k < 3; k++) {
|
|
1125
|
+
built[k] = Math.min(built[k], b[k]);
|
|
1126
|
+
built[k + 3] = Math.max(built[k + 3], b[k + 3]);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
const iso = add.length ? commonSub(insts, add, (u) => isoParts(u).length >= nBoxed) : undefined;
|
|
1130
|
+
let isoBox = null;
|
|
1131
|
+
g = grid;
|
|
1132
|
+
if (iso !== undefined) {
|
|
1133
|
+
const L = localOf(iso);
|
|
1134
|
+
const own = isoParts(iso).filter((id) => stepOf[id] <= s);
|
|
1135
|
+
g = new BoxGrid(L.boxes, grid.cell);
|
|
1136
|
+
for (const id of own)
|
|
1137
|
+
g.add(id);
|
|
1138
|
+
isoBox = [Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity];
|
|
1139
|
+
for (const id of own) {
|
|
1140
|
+
const b = L.boxes[id];
|
|
1141
|
+
for (let k = 0;k < 3; k++) {
|
|
1142
|
+
isoBox[k] = Math.min(isoBox[k], b[k]);
|
|
1143
|
+
isoBox[k + 3] = Math.max(isoBox[k + 3], b[k + 3]);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
const prev = iso !== undefined ? prevIso.get(iso) ?? def : prevMain, ref = isoBox ?? built;
|
|
1148
|
+
const ids = spread(add, 24);
|
|
1149
|
+
let dir = o.fixed?.(s) ?? null, r = dir ? score(ids, dir) : score(ids, prev);
|
|
1150
|
+
if (!dir) {
|
|
1151
|
+
dir = prev;
|
|
1152
|
+
if (r.mean >= minVis && prev !== def) {
|
|
1153
|
+
const v = score(ids, def);
|
|
1154
|
+
if (v.mean >= minVis) {
|
|
1155
|
+
dir = def;
|
|
1156
|
+
r = v;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
if (r.mean < minVis) {
|
|
1160
|
+
let best = -Infinity;
|
|
1161
|
+
const ex = [ref[3] - ref[0], ref[4] - ref[1], ref[5] - ref[2]], area = (d) => Math.abs(d[0]) * ex[1] * ex[2] + Math.abs(d[1]) * ex[0] * ex[2] + Math.abs(d[2]) * ex[0] * ex[1];
|
|
1162
|
+
let amax = 0;
|
|
1163
|
+
for (const d of above)
|
|
1164
|
+
amax = Math.max(amax, area(d));
|
|
1165
|
+
const consider = (cands) => {
|
|
1166
|
+
for (const d of cands) {
|
|
1167
|
+
const v = score(ids, d);
|
|
1168
|
+
const sc = v.mean + 0.3 * v.mn + 0.25 * pref(d) + 0.15 * (amax ? area(d) / amax : 1) - turn * angle(prev, d);
|
|
1169
|
+
if (sc > best) {
|
|
1170
|
+
best = sc;
|
|
1171
|
+
dir = d;
|
|
1172
|
+
r = v;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
consider([prev, ...above]);
|
|
1177
|
+
if (r.mean < reorient)
|
|
1178
|
+
consider(below);
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
const diag = (b) => Math.hypot(b[3] - b[0], b[4] - b[1], b[5] - b[2]);
|
|
1182
|
+
let fb = built;
|
|
1183
|
+
const sub = add.length ? insts[add[0]].sub : undefined;
|
|
1184
|
+
if (isoBox)
|
|
1185
|
+
fb = isoBox;
|
|
1186
|
+
else if (sub !== undefined && add.every((id) => insts[id].sub === sub)) {
|
|
1187
|
+
const sb = [Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity];
|
|
1188
|
+
for (const id of subParts.get(sub) ?? []) {
|
|
1189
|
+
if (stepOf[id] > s)
|
|
1190
|
+
continue;
|
|
1191
|
+
const b = boxes[id];
|
|
1192
|
+
for (let k = 0;k < 3; k++) {
|
|
1193
|
+
sb[k] = Math.min(sb[k], b[k]);
|
|
1194
|
+
sb[k + 3] = Math.max(sb[k + 3], b[k + 3]);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
if (isFinite(sb[0]) && diag(sb) * 2.5 < diag(built)) {
|
|
1198
|
+
const g = diag(sb) * 0.35;
|
|
1199
|
+
fb = sb.map((v, k) => k < 3 ? v - g : v + g);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
const target = isFinite(fb[0]) ? [(fb[0] + fb[3]) / 2, (fb[1] + fb[4]) / 2, (fb[2] + fb[5]) / 2] : [0, 0, 0];
|
|
1203
|
+
views.push({ dir, target, radius: isFinite(fb[0]) ? diag(fb) / 2 : 1, minVis: r.mn, meanVis: r.mean, below: dir[1] > 0, ...iso !== undefined ? { isolate: iso, frame: localOf(iso).P } : {} });
|
|
1204
|
+
if (iso !== undefined)
|
|
1205
|
+
prevIso.set(iso, dir);
|
|
1206
|
+
else
|
|
1207
|
+
prevMain = dir;
|
|
1208
|
+
};
|
|
1209
|
+
return {
|
|
1210
|
+
stepCount: nSteps,
|
|
1211
|
+
view(step) {
|
|
1212
|
+
step = Math.max(0, Math.min(nSteps - 1, step));
|
|
1213
|
+
while (views.length <= step)
|
|
1214
|
+
next();
|
|
1215
|
+
return views[step];
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/render.ts
|
|
814
1220
|
import * as THREE from "three";
|
|
815
1221
|
|
|
816
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1222
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/pack-io.ts
|
|
817
1223
|
import { decompress } from "fzstd";
|
|
818
1224
|
async function decompressPack(data) {
|
|
819
1225
|
const u = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
@@ -832,7 +1238,7 @@ function decodePack(buf) {
|
|
|
832
1238
|
return { header, arr, bytes: buf.byteLength, buffer: buf };
|
|
833
1239
|
}
|
|
834
1240
|
|
|
835
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1241
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/cull.ts
|
|
836
1242
|
var upright = (m, o = 0) => Math.abs(m[o + 7] - 1) < 0.001 && Math.abs(m[o + 4]) < 0.001 && Math.abs(m[o + 10]) < 0.001;
|
|
837
1243
|
var prepCache = new WeakMap;
|
|
838
1244
|
function prepPart(H, part) {
|
|
@@ -1139,7 +1545,7 @@ function cullCore(insts, H, steps) {
|
|
|
1139
1545
|
function sceneInstances(instances, H, useTex) {
|
|
1140
1546
|
const pick = (i) => useTex && i.texPart && H.parts[i.texPart] ? i.texPart : i.part;
|
|
1141
1547
|
const all = instances.map((i) => ({ part: pick(i), color: String(i.color), m: i.m, steps: i.steps }));
|
|
1142
|
-
const keys = all.map((i) => i.steps
|
|
1548
|
+
const keys = all.map((i) => stepKey(i.steps));
|
|
1143
1549
|
const uniq = [...new Set(keys)].sort();
|
|
1144
1550
|
const rank = new Map(uniq.map((k, j) => [k, j]));
|
|
1145
1551
|
return { all, stepOf: keys.map((k) => rank.get(k)), nSteps: uniq.length };
|
|
@@ -1149,7 +1555,7 @@ function precomputeCull(instances, H, useTex = true) {
|
|
|
1149
1555
|
return cullCore(s.all, H, s.nSteps > 1 ? s.stepOf : undefined);
|
|
1150
1556
|
}
|
|
1151
1557
|
|
|
1152
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1558
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/render.ts
|
|
1153
1559
|
async function loadPack(url) {
|
|
1154
1560
|
const res = await fetch(url);
|
|
1155
1561
|
if (!res.ok)
|
|
@@ -2065,9 +2471,10 @@ function buildLdrScene(insts, pack, P, color, mark) {
|
|
|
2065
2471
|
stats.clusters = root.clusters.length;
|
|
2066
2472
|
const texturesReady = Promise.all(pending).then(() => {});
|
|
2067
2473
|
let stepS = STEP_NEVER - 1, cullS = !!P.cullStuds, cullU = !!P.cullUnder;
|
|
2474
|
+
let only = null;
|
|
2068
2475
|
const applySteps = () => {
|
|
2069
2476
|
const st = { studsTotal: 0, studsHidden: 0, undersTotal: 0, undersHidden: 0 };
|
|
2070
|
-
const S = stepS;
|
|
2477
|
+
const S = stepS, O = only;
|
|
2071
2478
|
const wm = new Float64Array(12);
|
|
2072
2479
|
for (const b of stepBatches) {
|
|
2073
2480
|
const MA = b.im.instanceMatrix.array, CA = b.im.instanceColor.array;
|
|
@@ -2090,6 +2497,8 @@ function buildLdrScene(insts, pack, P, color, mark) {
|
|
|
2090
2497
|
if (useHide && hid)
|
|
2091
2498
|
continue;
|
|
2092
2499
|
const n = inst[i];
|
|
2500
|
+
if (O && !O[n])
|
|
2501
|
+
continue;
|
|
2093
2502
|
if (stud) {
|
|
2094
2503
|
mul12To(instM, instPP[n].studM, stud[i] * 12, wm, n * 12);
|
|
2095
2504
|
writeM4(MA, w * 16, wm);
|
|
@@ -2119,10 +2528,11 @@ function buildLdrScene(insts, pack, P, color, mark) {
|
|
|
2119
2528
|
for (const t of toggles)
|
|
2120
2529
|
t.mesh.count = (t.flag === "studs" ? studs : under) ? t.visible : t.all;
|
|
2121
2530
|
};
|
|
2122
|
-
const setStep = (s) => {
|
|
2531
|
+
const setStep = (s, mask = null) => {
|
|
2123
2532
|
if (!steps)
|
|
2124
2533
|
throw new Error("buildLdrScene: setStep needs P.steps");
|
|
2125
2534
|
stepS = s == null ? STEP_NEVER - 1 : s;
|
|
2535
|
+
only = mask;
|
|
2126
2536
|
return applySteps();
|
|
2127
2537
|
};
|
|
2128
2538
|
const box = new THREE.Box3;
|
|
@@ -2192,7 +2602,7 @@ async function warmPackGeometry(pack, stop = () => false, sliceMs = 8) {
|
|
|
2192
2602
|
await new Promise((r) => setTimeout(r, 0));
|
|
2193
2603
|
}
|
|
2194
2604
|
}
|
|
2195
|
-
// ../../../../../../../tmp/ldr-build-
|
|
2605
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/scene.ts
|
|
2196
2606
|
import * as THREE2 from "three";
|
|
2197
2607
|
function colorFn(src, pack, fallback) {
|
|
2198
2608
|
const table = new Map;
|
|
@@ -2274,7 +2684,7 @@ function createLdrObject(instances, pack, options = {}) {
|
|
|
2274
2684
|
cur = null;
|
|
2275
2685
|
};
|
|
2276
2686
|
const multiStep = uniq.length > 1;
|
|
2277
|
-
const drawnAt = (step) => all.filter((i, k) => (step == null || stepOf[k] <= step) && pack.header.parts[i.part]).length;
|
|
2687
|
+
const drawnAt = (step, mask) => all.filter((i, k) => (step == null || stepOf[k] <= step) && (!mask || mask[k]) && pack.header.parts[i.part]).length;
|
|
2278
2688
|
const build = () => {
|
|
2279
2689
|
const t0 = performance.now();
|
|
2280
2690
|
cur = buildLdrScene(all, pack, { cullStuds: cs, cullUnder: cu, edges, side, cond, condStuds: o.conditionalStudLines !== false, tex: o.textures !== false, lod: o.lod !== false, lodPx: o.lodPx, lodEdgePx: o.lodEdgePx, lodEdgeMinPx: o.lodEdgeMinPx, lodUnder: o.lodUnder, steps: multiStep ? stepOf : undefined, cull: o.precomputedCull }, color, () => {});
|
|
@@ -2295,11 +2705,11 @@ function createLdrObject(instances, pack, options = {}) {
|
|
|
2295
2705
|
Object.assign(stats, { drawn: drawnAt(null), studsTotal: cur.stats.studsTotal, studsHidden: cur.stats.studsHidden, undersTotal: cur.stats.undersTotal, undersHidden: cur.stats.undersHidden, condBatches: cur.stats.condBatches ?? 0, texBatches: cur.stats.texBatches ?? 0, textures: cur.stats.textures ?? 0, clusters: cur.stats.clusters ?? 0, buildMs: performance.now() - t0 });
|
|
2296
2706
|
api.texturesReady = cur.texturesReady;
|
|
2297
2707
|
};
|
|
2298
|
-
const setStep = (step) => {
|
|
2708
|
+
const setStep = (step, mask = null) => {
|
|
2299
2709
|
if (!multiStep)
|
|
2300
2710
|
return;
|
|
2301
2711
|
const t0 = performance.now();
|
|
2302
|
-
Object.assign(stats, cur.setStep(step), { drawn: drawnAt(step), buildMs: performance.now() - t0 });
|
|
2712
|
+
Object.assign(stats, cur.setStep(step, mask), { drawn: drawnAt(step, mask), buildMs: performance.now() - t0 });
|
|
2303
2713
|
};
|
|
2304
2714
|
const api = { texturesReady: Promise.resolve() };
|
|
2305
2715
|
build();
|
|
@@ -2348,8 +2758,82 @@ function createLdrObject(instances, pack, options = {}) {
|
|
|
2348
2758
|
dispose: disposeCur
|
|
2349
2759
|
});
|
|
2350
2760
|
}
|
|
2351
|
-
// ../../../../../../../tmp/ldr-build-
|
|
2761
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/parts-cdn.ts
|
|
2352
2762
|
import { decompress as decompress2 } from "fzstd";
|
|
2763
|
+
|
|
2764
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/embedded.ts
|
|
2765
|
+
function splitFiles(text, fallback) {
|
|
2766
|
+
const files = new Map;
|
|
2767
|
+
let cur = null, saw = false;
|
|
2768
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
2769
|
+
const m = /^\s*0\s+FILE\s+(.+)$/i.exec(raw);
|
|
2770
|
+
if (m) {
|
|
2771
|
+
if (!saw)
|
|
2772
|
+
files.clear();
|
|
2773
|
+
saw = true;
|
|
2774
|
+
cur = [];
|
|
2775
|
+
files.set(norm(m[1]), cur);
|
|
2776
|
+
continue;
|
|
2777
|
+
}
|
|
2778
|
+
if (/^\s*0\s+(NOFILE|!DATA)(\s|$)/i.test(raw)) {
|
|
2779
|
+
if (!saw)
|
|
2780
|
+
files.clear();
|
|
2781
|
+
saw = true;
|
|
2782
|
+
cur = null;
|
|
2783
|
+
continue;
|
|
2784
|
+
}
|
|
2785
|
+
if (!cur) {
|
|
2786
|
+
if (saw)
|
|
2787
|
+
continue;
|
|
2788
|
+
cur = [];
|
|
2789
|
+
files.set(norm(fallback), cur);
|
|
2790
|
+
}
|
|
2791
|
+
const line = raw.trim().replace(/\s+/g, " ");
|
|
2792
|
+
if (line)
|
|
2793
|
+
cur.push(line);
|
|
2794
|
+
}
|
|
2795
|
+
return files;
|
|
2796
|
+
}
|
|
2797
|
+
var refOf = (line) => {
|
|
2798
|
+
if (!line.startsWith("1 "))
|
|
2799
|
+
return null;
|
|
2800
|
+
const t = line.split(" ");
|
|
2801
|
+
return t.length >= 15 ? norm(t.slice(14).join(" ")) : null;
|
|
2802
|
+
};
|
|
2803
|
+
function hash(s) {
|
|
2804
|
+
let a = 2166136261, b = 16777619 ^ 1540483477;
|
|
2805
|
+
for (let i = 0;i < s.length; i++) {
|
|
2806
|
+
const c = s.charCodeAt(i);
|
|
2807
|
+
a = Math.imul(a ^ c, 16777619);
|
|
2808
|
+
b = Math.imul(b ^ c, 16777629) ^ b >>> 15;
|
|
2809
|
+
}
|
|
2810
|
+
return (a >>> 0).toString(16).padStart(8, "0") + (b >>> 0).toString(16).padStart(8, "0");
|
|
2811
|
+
}
|
|
2812
|
+
function embeddedKeys(text, names, fallback = "main.ldr") {
|
|
2813
|
+
const files = splitFiles(text, fallback), out = new Map;
|
|
2814
|
+
for (const n0 of names) {
|
|
2815
|
+
const n = norm(n0);
|
|
2816
|
+
if (!files.has(n) || out.has(n))
|
|
2817
|
+
continue;
|
|
2818
|
+
const used = new Set([n]), stack = [n];
|
|
2819
|
+
while (stack.length)
|
|
2820
|
+
for (const l of files.get(stack.pop())) {
|
|
2821
|
+
const r = refOf(l);
|
|
2822
|
+
if (r && files.has(r) && !used.has(r)) {
|
|
2823
|
+
used.add(r);
|
|
2824
|
+
stack.push(r);
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
const canon = [n, ...[...used].filter((u) => u !== n).sort()].map((u) => "0 FILE " + (u === n ? "" : u) + `
|
|
2828
|
+
` + files.get(u).join(`
|
|
2829
|
+
`)).join(`
|
|
2830
|
+
`);
|
|
2831
|
+
out.set(n, `emb/${hash(canon)}.dat`);
|
|
2832
|
+
}
|
|
2833
|
+
return out;
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/parts-cdn.ts
|
|
2353
2837
|
var DEFAULT_PARTS_CDN = "https://ldr-demo.vercel.app/cdn/v1/";
|
|
2354
2838
|
var indexCache = new Map;
|
|
2355
2839
|
var shardCache = new Map;
|
|
@@ -2409,6 +2893,21 @@ function mergePacks(packs, extra = {}) {
|
|
|
2409
2893
|
return decodePack(out.buffer);
|
|
2410
2894
|
}
|
|
2411
2895
|
async function loadParts(names, o = {}) {
|
|
2896
|
+
names = [...names];
|
|
2897
|
+
try {
|
|
2898
|
+
return await loadPartsOnce(names, o);
|
|
2899
|
+
} catch (e) {
|
|
2900
|
+
const cdn = o.cdn ?? DEFAULT_PARTS_CDN, f = o.fetch ?? fetch;
|
|
2901
|
+
indexCache.delete(cdn);
|
|
2902
|
+
const fresh = (u, i) => f(u, { ...i, cache: "reload" });
|
|
2903
|
+
try {
|
|
2904
|
+
return await loadPartsOnce(names, { ...o, fetch: fresh });
|
|
2905
|
+
} catch {
|
|
2906
|
+
throw e;
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
async function loadPartsOnce(names, o) {
|
|
2412
2911
|
const cdn = o.cdn ?? DEFAULT_PARTS_CDN, f = o.fetch ?? fetch, gap = o.gap ?? 16384;
|
|
2413
2912
|
const idx = await loadPartsIndex(cdn, f);
|
|
2414
2913
|
const want = [...new Set([...names].map(norm))];
|
|
@@ -2477,20 +2976,27 @@ async function prepareModel(source, o = {}) {
|
|
|
2477
2976
|
});
|
|
2478
2977
|
const t1 = performance.now();
|
|
2479
2978
|
const name = o.name ?? (o.text ? "main.ldr" : decodeURIComponent(source.split(/[?#]/)[0].split("/").pop() || "main.ldr"));
|
|
2480
|
-
const insts = parseModel(text, name, { looseGeometry: false });
|
|
2979
|
+
const insts = parseModel(text, name, { looseGeometry: false, callouts: o.callouts });
|
|
2481
2980
|
const t2 = performance.now();
|
|
2482
2981
|
o.onParsed?.(insts);
|
|
2483
2982
|
await idxP;
|
|
2484
|
-
const
|
|
2983
|
+
const emb = embeddedKeys(text, new Set(insts.filter((i) => i.embedded).map((i) => i.part)), name);
|
|
2984
|
+
const { pack, missing: miss, requests, bytes } = await loadParts([...insts.filter((i) => !i.embedded).map((i) => i.part), ...emb.values()], o);
|
|
2985
|
+
const back = new Map([...emb].map(([n, k]) => [k, n])), missing = miss.map((m) => back.get(m) ?? m);
|
|
2986
|
+
for (const [n, k] of emb) {
|
|
2987
|
+
const e = pack.header.parts[k];
|
|
2988
|
+
if (e)
|
|
2989
|
+
pack.header.parts[n] = e;
|
|
2990
|
+
}
|
|
2485
2991
|
const t3 = performance.now();
|
|
2486
2992
|
const cull = o.cull ? precomputeCull(insts, pack.header, o.textures !== false) : undefined;
|
|
2487
2993
|
return { insts, pack, missing, requests, bytes, cull, timings: { fetchModel: t1 - t0, parse: t2 - t1, parts: t3 - t2, ...cull ? { cull: performance.now() - t3 } : {} } };
|
|
2488
2994
|
}
|
|
2489
2995
|
|
|
2490
|
-
// ../../../../../../../tmp/ldr-build-
|
|
2491
|
-
var load_worker_gen_default = 'var ut=ArrayBuffer,j=Uint8Array,ge=Uint16Array,ft=Int16Array;var be=Int32Array,Ae=function(e,t,n){if(j.prototype.slice)return j.prototype.slice.call(e,t,n);if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;var r=new j(n-t);return r.set(e.subarray(t,n)),r},ce=function(e,t,n,r){if(j.prototype.fill)return j.prototype.fill.call(e,t,n,r);if(n==null||n<0)n=0;if(r==null||r>e.length)r=e.length;for(;n<r;++n)e[n]=t;return e},pt=function(e,t,n,r){if(j.prototype.copyWithin)return j.prototype.copyWithin.call(e,t,n,r);if(n==null||n<0)n=0;if(r==null||r>e.length)r=e.length;while(n<r)e[t++]=e[n++]};var mt=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],V=function(e,t,n){var r=Error(t||mt[e]);if(r.code=e,Error.captureStackTrace)Error.captureStackTrace(r,V);if(!n)throw r;return r},Ne=function(e,t,n){var r=0,o=0;for(;r<n;++r)o|=e[t++]<<(r<<3);return o},ht=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},gt=function(e,t){var n=e[0]|e[1]<<8|e[2]<<16;if(n==3126568&&e[3]==253){var r=e[4],o=r>>5&1,s=r>>2&1,i=r&3,c=r>>6;if(r&8)V(0);var a=6-o,l=i==3?4:i,f=Ne(e,a,l);a+=l;var g=c?1<<c:o,p=Ne(e,a,g)+(c==1&&256),y=p;if(!o){var C=1<<10+(e[5]>>3);y=C+(C>>3)*(e[5]&7)}if(y>2145386496)V(1);var u=new j((t==1?p||y:t?0:y)+12);return u[0]=1,u[4]=4,u[8]=8,{b:a+g,y:0,l:0,d:f,w:t&&t!=1?t:u.subarray(12),e:y,o:new be(u.buffer,0,3),u:p,c:s,m:Math.min(131072,y)}}else if((n>>4|e[3]<<20)==25481893)return ht(e,4)+8;V(0)},re=function(e){var t=0;for(;1<<t<=e;++t);return t-1},ue=function(e,t,n){var r=(t<<3)+4,o=(e[t]&15)+5;if(o>n)V(3);var s=1<<o,i=s,c=-1,a=-1,l=-1,f=s,g=new ut(512+(s<<2)),p=new ft(g,0,256),y=new ge(g,0,256),C=new ge(g,512,s),u=512+(s<<1),m=new j(g,u,s),P=new j(g,u+s);while(c<255&&i>0){var b=re(i+1),d=r>>3,S=(1<<b+1)-1,k=(e[d]|e[d+1]<<8|e[d+2]<<16)>>(r&7)&S,w=(1<<b)-1,E=S-i-1,M=k&w;if(M<E)r+=b,k=M;else if(r+=b+1,k>w)k-=E;if(p[++c]=--k,k==-1)i+=k,m[--f]=c;else i-=k;if(!k)do{var x=r>>3;a=(e[x]|e[x+1]<<8)>>(r&7)&3,r+=2,c+=a}while(a==3)}if(c>255||i)V(0);var A=0,L=(s>>1)+(s>>3)+3,D=s-1;for(var F=0;F<=c;++F){var v=p[F];if(v<1){y[F]=-v;continue}for(l=0;l<v;++l){m[A]=F;do A=A+L&D;while(A>=f)}}if(A)V(0);for(l=0;l<s;++l){var h=y[m[l]]++,T=P[l]=o-re(h);C[l]=(h<<T)-s}return[r+7>>3,{b:o,s:m,n:P,t:C}]},bt=function(e,t){var n=0,r=-1,o=new j(292),s=e[t],i=o.subarray(0,256),c=o.subarray(256,268),a=new ge(o.buffer,268);if(s<128){var l=ue(e,t+1,6),f=l[0],g=l[1];t+=s;var p=f<<3,y=e[t];if(!y)V(0);var C=0,u=0,m=g.b,P=m,b=(++t<<3)-8+re(y);for(;;){if(b-=m,b<p)break;var d=b>>3;if(C+=(e[d]|e[d+1]<<8)>>(b&7)&(1<<m)-1,i[++r]=g.s[C],b-=P,b<p)break;d=b>>3,u+=(e[d]|e[d+1]<<8)>>(b&7)&(1<<P)-1,i[++r]=g.s[u],m=g.n[C],C=g.t[C],P=g.n[u],u=g.t[u]}if(++r>255)V(0)}else{r=s-127;for(;n<r;n+=2){var S=e[++t];i[n]=S>>4,i[n+1]=S&15}++t}var k=0;for(n=0;n<r;++n){var w=i[n];if(w>11)V(0);k+=w&&1<<w-1}var E=re(k)+1,M=1<<E,x=M-k;if(x&x-1)V(0);i[r++]=re(x)+1;for(n=0;n<r;++n){var w=i[n];++c[i[n]=w&&E+1-w]}var A=new j(M<<1),L=A.subarray(0,M),D=A.subarray(M);a[E]=0;for(n=E;n>0;--n){var F=a[n];ce(D,n,F,a[n-1]=F+c[n]*(1<<E-n))}if(a[0]!=M)V(0);for(n=0;n<r;++n){var v=i[n];if(v){var h=a[v];ce(L,n,h,a[v]=h+(1<<E-v))}}return[t,{n:D,b:E,s:L}]},dt=ue(new j([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],yt=ue(new j([33,20,196,24,99,140,33,132,16,66,8,33,132,16,66,8,33,68,68,68,68,68,68,68,68,36,9]),0,6)[1],xt=ue(new j([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],$e=function(e,t){var n=e.length,r=new be(n);for(var o=0;o<n;++o)r[o]=t,t+=1<<e[o];return r},Me=new j(new be([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),wt=$e(Me,0),Se=new j(new be([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),vt=$e(Se,3),le=function(e,t,n){var r=e.length,o=t.length,s=e[r-1],i=(1<<n.b)-1,c=-n.b;if(!s)V(0);var a=0,l=n.b,f=(r<<3)-8+re(s)-l,g=-1;for(;f>c&&g<o;){var p=f>>3,y=(e[p]|e[p+1]<<8|e[p+2]<<16)>>(f&7);a=(a<<l|y)&i,t[++g]=n.s[a],f-=l=n.n[a]}if(f!=c||g+1!=o)V(0)},At=function(e,t,n){var r=6,o=t.length,s=o+3>>2,i=s<<1,c=s+i;le(e.subarray(r,r+=e[0]|e[1]<<8),t.subarray(0,s),n),le(e.subarray(r,r+=e[2]|e[3]<<8),t.subarray(s,i),n),le(e.subarray(r,r+=e[4]|e[5]<<8),t.subarray(i,c),n),le(e.subarray(r),t.subarray(c),n)},Mt=function(e,t,n){var r,o=t.b,s=e[o],i=s>>1&3;t.l=s&1;var c=s>>3|e[o+1]<<5|e[o+2]<<13,a=(o+=3)+c;if(i==1){if(o>=e.length)return;if(t.b=o+1,n)return ce(n,e[o],t.y,t.y+=c),n;return ce(new j(c),e[o])}if(a>e.length)return;if(i==0){if(t.b=a,n)return n.set(e.subarray(o,a),t.y),t.y+=c,n;return Ae(e,o,a)}if(i==2){var l=e[o],f=l&3,g=l>>2&3,p=l>>4,y=0,C=0;if(f<2)if(g&1)p|=e[++o]<<4|(g&2&&e[++o]<<12);else p=l>>3;else if(C=g,g<2)p|=(e[++o]&63)<<4,y=e[o]>>6|e[++o]<<2;else if(g==2)p|=e[++o]<<4|(e[++o]&3)<<12,y=e[o]>>2|e[++o]<<6;else p|=e[++o]<<4|(e[++o]&63)<<12,y=e[o]>>6|e[++o]<<2|e[++o]<<10;++o;var u=n?n.subarray(t.y,t.y+t.m):new j(t.m),m=u.length-p;if(f==0)u.set(e.subarray(o,o+=p),m);else if(f==1)ce(u,e[o++],m);else{var P=t.h;if(f==2){var b=bt(e,o);y+=o-(o=b[0]),t.h=P=b[1]}else if(!P)V(0);(C?At:le)(e.subarray(o,o+=y),u.subarray(m),P)}var d=e[o++];if(d){if(d==255)d=(e[o++]|e[o++]<<8)+32512;else if(d>127)d=d-128<<8|e[o++];var S=e[o++];if(S&3)V(0);var k=[yt,xt,dt];for(var w=2;w>-1;--w){var E=S>>(w<<1)+2&3;if(E==1){var M=new j([0,0,e[o++]]);k[w]={s:M.subarray(2,3),n:M.subarray(0,1),t:new ge(M.buffer,0,1),b:0}}else if(E==2)r=ue(e,o,9-(w&1)),o=r[0],k[w]=r[1];else if(E==3){if(!t.t)V(0);k[w]=t.t[w]}}var x=t.t=k,A=x[0],L=x[1],D=x[2],F=e[a-1];if(!F)V(0);var v=(a<<3)-8+re(F)-D.b,h=v>>3,T=0,R=(e[h]|e[h+1]<<8)>>(v&7)&(1<<D.b)-1;h=(v-=L.b)>>3;var I=(e[h]|e[h+1]<<8)>>(v&7)&(1<<L.b)-1;h=(v-=A.b)>>3;var U=(e[h]|e[h+1]<<8)>>(v&7)&(1<<A.b)-1;for(++d;--d;){var O=D.s[R],K=D.n[R],H=A.s[U],z=A.n[U],B=L.s[I],N=L.n[I];h=(v-=B)>>3;var G=1<<B,X=G+((e[h]|e[h+1]<<8|e[h+2]<<16|e[h+3]<<24)>>>(v&7)&G-1);h=(v-=Se[H])>>3;var Y=vt[H]+((e[h]|e[h+1]<<8|e[h+2]<<16)>>(v&7)&(1<<Se[H])-1);h=(v-=Me[O])>>3;var W=wt[O]+((e[h]|e[h+1]<<8|e[h+2]<<16)>>(v&7)&(1<<Me[O])-1);if(h=(v-=K)>>3,R=D.t[R]+((e[h]|e[h+1]<<8)>>(v&7)&(1<<K)-1),h=(v-=z)>>3,U=A.t[U]+((e[h]|e[h+1]<<8)>>(v&7)&(1<<z)-1),h=(v-=N)>>3,I=L.t[I]+((e[h]|e[h+1]<<8)>>(v&7)&(1<<N)-1),X>3)t.o[2]=t.o[1],t.o[1]=t.o[0],t.o[0]=X-=3;else{var _=X-(W!=0);if(_){if(X=_==3?t.o[0]-1:t.o[_],_>1)t.o[2]=t.o[1];t.o[1]=t.o[0],t.o[0]=X}else X=t.o[0]}for(var w=0;w<W;++w)u[T+w]=u[m+w];T+=W,m+=W;var Z=T-X;if(Z<0){var J=-Z,ee=t.e+Z;if(J>Y)J=Y;for(var w=0;w<J;++w)u[T+w]=t.w[ee+w];T+=J,Y-=J,Z=0}for(var w=0;w<Y;++w)u[T+w]=u[Z+w];T+=Y}if(T!=m)while(m<u.length)u[T++]=u[m++];else T=u.length;if(n)t.y+=T;else u=Ae(u,0,T)}else if(n){if(t.y+=p,m)for(var w=0;w<p;++w)u[w]=u[m+w]}else if(m)u=Ae(u,m);return t.b=a,u}V(2)},St=function(e,t){if(e.length==1)return e[0];var n=new j(t);for(var r=0,o=0;r<e.length;++r){var s=e[r];n.set(s,o),o+=s.length}return n};function je(e,t){var n=[],r=+!t,o=0,s=0;for(;e.length;){var i=gt(e,r||t);if(typeof i=="object"){if(r){if(t=null,i.w.length==i.u)n.push(t=i.w),s+=i.u}else n.push(t),i.e=0;for(;!i.l;){var c=Mt(e,i,t);if(!c)V(5);if(t)i.e=i.y;else n.push(c),s+=c.length,pt(i.w,0,c.length),i.w.set(c,i.w.length-c.length)}o=i.b+i.c*4}else o=i;e=e.subarray(o)}return St(n,s)}function de(e){let t=new DataView(e).getUint32(0,!0),n=JSON.parse(new TextDecoder().decode(new Uint8Array(e,4,t))),r=4+t;return{header:n,arr:(s)=>s&&(s[2]==="f32"?new Float32Array(e,r+s[0],s[1]):s[2]==="u16"?new Uint16Array(e,r+s[0],s[1]):s[2]==="u8"?new Uint8Array(e,r+s[0],s[1]):new Uint32Array(e,r+s[0],s[1])),bytes:e.byteLength,buffer:e}}var q=(e)=>e.trim().toLowerCase().replace(/\\\\/g,"/").replace(/\\/+/g,"/");function Ce(e){if(/^0x/i.test(e))return parseInt(e,16);return+e}var Ve=/^~?\\s*moved\\s+to\\s+(.+)$/i,Ct=new Set(["FILE","NOFILE","!DATA","!:","STEP","BFC","ROTSTEP","BUFEXCHG","!TEXMAP"]),Je=new Set(["part","subpart","primitive","8_primitive","48_primitive","shortcut","helper"]),Pt=new Set(["model","submodel","configuration"]),Et=/^(?:!?LDRAW_ORG|Unofficial|Official\\s+LCAD)\\s+(\\S+)/i;function He(e){let t=Et.exec(e);if(!t)return;let n=t[1].toLowerCase().replace(/^unofficial_/,"");return Je.has(n)||Pt.has(n)?n:void 0}function Tt(e){let t=[],n=0;while(n<e.length){while(e[n]===" "||e[n]==="\\t")n++;if(n>=e.length)break;if(e[n]===\'"\'){let r="";n++;while(n<e.length&&e[n]!==\'"\'){if(e[n]==="\\\\"&&n+1<e.length)n++;r+=e[n++]}n++,t.push(r)}else{let r=n;while(r<e.length&&e[r]!==" "&&e[r]!=="\\t")r++;t.push(e.slice(n,r)),n=r}}return t}function Lt(e,t=!1){let n=/^\\s*(\\S+)\\s+(.*)$/.exec(e);if(!n)return null;let r=n[1].toUpperCase(),o=r==="PLANAR"?9:r==="CYLINDRICAL"?10:r==="SPHERICAL"?11:0;if(!o)return null;let s=n[2].trim().split(/\\s+/);if(s.length<o+1)return null;let i=s.slice(0,o).map(Number);if(!i.every(Number.isFinite))return null;let c=n[2].trim();for(let g=0;g<o;g++)c=c.replace(/^\\S+\\s*/,"");let a=Tt(c);if(!a.length)return null;let l={method:r,p1:i.slice(0,3),p2:i.slice(3,6),p3:i.slice(6,9),texture:a[0]};if(o>=10)l.a=i[9];if(o===11)l.b=i[10];let f=a.findIndex((g,p)=>p>0&&g.toUpperCase()==="GLOSSMAP");if(f>0&&a[f+1])l.glossmap=a[f+1];if(t)l.next=!0;return l}var It=(e)=>{let t=e.replace(/[^A-Za-z0-9+/]/g,""),n=t+"=".repeat((4-t.length%4)%4),r=atob(n),o=new Uint8Array(r.length);for(let s=0;s<r.length;s++)o[s]=r.charCodeAt(s);return o};function kt(e){let t=e.length,n=1,r=(l)=>l===32||l===9,o=()=>{while(n<t&&r(e.charCodeAt(n)))n++;let l=n;while(n<t&&!r(e.charCodeAt(n)))n++;return l<n?e.slice(l,n):null},s=o();if(s===null)return null;let i=Array(12);for(let l=0;l<12;l++){let f=o();if(f===null)return null;i[l]=+f}while(n<t&&r(e.charCodeAt(n)))n++;if(n>=t)return null;let c=e.slice(n),a=/[ \\t]{2,}|\\t/.test(c)?c.split(/\\s+/).join(" "):c;return{t:1,color:Ce(s),m:i,file:q(a)}}function Ge(e){let t=+e[0];if(!(t>=1&&t<=5)||e.length<2)return null;let n=Ce(e[1]),r=e.slice(2).map(Number);if(t===1)return{t:1,color:n,m:r.slice(0,12),file:q(e.slice(14).join(" "))};if(t===2)return{t:2,color:n,p:r.slice(0,6)};if(t===3)return{t:3,color:n,p:r.slice(0,9)};if(t===4)return{t:4,color:n,p:r.slice(0,12)};return{t:5,color:n,p:r.slice(0,12)}}function Ze(e,t="main.ldr",n={}){let r=!!n.geometryText,o=new Map,s=null,i="",c,a=null,l=[],f=null,g=()=>{if(!a)return;let b=It(a.chunks.join("")),d=b[0]===137&&b[1]===80&&b[2]===78&&b[3]===71;(c??=new Map).set(q(a.name),{name:a.name,bytes:b,...d?{mime:"image/png"}:{}}),a=null},p=!0,y=(b)=>{if(g(),s={name:q(b),cmds:[]},o.set(s.name,s),!i)i=s.name;l=[],f=null,p=!0},C=!1,u=!1,m=()=>{if(u)return;u=!0,o.clear(),s=null,i=""},P=(b,d)=>{if(f){b.tex=f,f=null;return}let S=l[l.length-1];if(!S)return;if(S.fallback){if(!d)b.fallback=!0}else b.tex=S.map};for(let b of e.split(`\n`)){let d=b.trim();if(!d)continue;if(r&&d.charCodeAt(0)>=50&&d.charCodeAt(0)<=53&&(d.charCodeAt(1)===32||d.charCodeAt(1)===9)){if(a||C)continue;if(!s)y(t);let E=d.slice(2).trimStart(),M=E.search(/\\s/),x={t:d.charCodeAt(0)-48,color:Ce(M<0?E:E.slice(0,M)),p:[],src:d};P(x,!1),s.cmds.push(x),p=!1;continue}if(d.charCodeAt(0)===48&&(d.charCodeAt(1)===32||d.charCodeAt(1)===9)){let E=2;while(d.charCodeAt(E)===32||d.charCodeAt(E)===9)E++;let M=E;while(M<d.length&&d.charCodeAt(M)!==32&&d.charCodeAt(M)!==9)M++;let x=d.slice(E,M);if(!Ct.has(x)){if(C||a)continue;if(!s)y(t);let A=d.slice(E),L={t:0,text:A};if(x.charCodeAt(0)===33)L.meta=x;if(f=null,p&&!s.org){let F=He(A);if(F)s.org=F}let D=A.match(Ve);if(D&&!s.movedTo){let F=D[1].trim().replace(/\\\\/g,"/");if(!/\\.(dat|ldr|mpd)$/i.test(F))F+=".dat";s.movedTo=q(F)}s.cmds.push(L);continue}}if(d.charCodeAt(0)===49&&(d.charCodeAt(1)===32||d.charCodeAt(1)===9)&&!a&&!C){let E=kt(d);if(E){if(!s)y(t);P(E,!1),s.cmds.push(E),p=!1;continue}}let S=d.split(/\\s+/);if(+S[0]===0){let E=d.slice(1).trim();if(S[1]==="FILE"){m(),C=!1,y(E.slice(5));continue}if(S[1]==="NOFILE"){g(),s=null,C=!0;continue}if(S[1]==="!DATA"){m(),g(),s=null,C=!1,a={name:E.slice(5).trim(),chunks:[]};continue}if(C)continue;if(a){if(S[1]==="!:")a.chunks.push(S.slice(2).join(""));continue}if(!s)y(t);let M={t:0,text:E};if(S[1]==="STEP")M.step=!0,l=[],f=null;else if(S[1]==="BFC")M.bfc=S.slice(2).join(" ");else if(S[1]==="ROTSTEP")if(M.meta="ROTSTEP",M.step=!0,l=[],f=null,(S[2]??"").toUpperCase()==="END")M.rotstep={x:0,y:0,z:0,mode:"END"};else{let A=(S[5]??"REL").toUpperCase();M.rotstep={x:+S[2]||0,y:+S[3]||0,z:+S[4]||0,mode:["REL","ABS","ADD"].includes(A)?A:"REL"}}else if(S[1]==="BUFEXCHG"){M.meta="BUFEXCHG";let A=(S[2]??"").toUpperCase();M.bufexchg={op:A==="RETRIEVE"?"RETRIEVE":"STORE",buf:S[3]??"A"}}else if(S[1]?.startsWith("!"))M.meta=S[1];if(p&&!s.org){let A=He(E);if(A)s.org=A}if(S[1]==="!TEXMAP"){let A=(S[2]??"").toUpperCase();if(f=null,A==="START"||A==="NEXT"){let L=Lt(E.replace(/^!TEXMAP\\s+\\S+/i,""),A==="NEXT");if(M.texmap={op:A,...L?{map:L}:{}},L)if((s.texmaps??=[]).push(L),A==="START")l.push({map:L,fallback:!1});else f=L}else if(A==="FALLBACK"){M.texmap={op:A};let L=l[l.length-1];if(L)L.fallback=!0}else if(A==="END")M.texmap={op:A},l.pop()}else if(S[1]==="!:"){f=null;let A=Ge(S.slice(2));if(A)P(A,!0),M.geom=A}else f=null;let x=E.match(Ve);if(x&&!s.movedTo){let A=x[1].trim().replace(/\\\\/g,"/");if(!/\\.(dat|ldr|mpd)$/i.test(A))A+=".dat";s.movedTo=q(A)}s.cmds.push(M);continue}if(a||C)continue;if(!s)y(t);let w=Ge(S);if(!w)continue;P(w,!1),s.cmds.push(w),p=!1}return g(),c?{main:i,files:o,data:c}:{main:i,files:o}}var Kt=Math.PI/180;function qe(e,t){let n=(r)=>[t[3]*r[0]+t[4]*r[1]+t[5]*r[2]+t[0],t[6]*r[0]+t[7]*r[1]+t[8]*r[2]+t[1],t[9]*r[0]+t[10]*r[1]+t[11]*r[2]+t[2]];return{...e,p1:n(e.p1),p2:n(e.p2),p3:n(e.p3)}}function Qe(e,t){let[n,r,o,s,i,c,a,l,f,g,p,y]=e,[C,u,m,P,b,d,S,k,w,E,M,x]=t;return[s*C+i*u+c*m+n,a*C+l*u+f*m+r,g*C+p*u+y*m+o,s*P+i*S+c*E,s*b+i*k+c*M,s*d+i*w+c*x,a*P+l*S+f*E,a*b+l*k+f*M,a*d+l*w+f*x,g*P+p*S+y*E,g*b+p*k+y*M,g*d+p*w+y*x]}var Pe=[0,0,0,1,0,0,0,1,0,0,0,1];var Xe=new WeakMap,Ft=/^(s|8|48)\\//;function Ee(e,t){let n=e.files.get(q(t));if(!n)return"part";let r=Xe.get(n);if(r)return r;if(n.org)r=Je.has(n.org)?"part":"model";else if(n.name===e.main)r="model";else r=n.cmds.some((o)=>o.t>=2||o.t===0&&!!o.geom||o.t===1&&Ft.test(o.file))?"part":"model";return Xe.set(n,r),r}var We=new WeakMap;function et(e){let t=We.get(e);if(t)return t;t=[];let n=0;for(let r of e.cmds){if(r.t===0&&r.step){n++;continue}if((r.t>=2||r.t===0&&r.geom&&r.geom.t>=2)&&t[t.length-1]!==n)t.push(n)}return We.set(e,t),t}var _e=(e)=>e>16777215?"0x"+e.toString(16).toUpperCase():String(e),Rt=(e)=>e.t===0?"0 "+e.text:e.t===1?`1 ${_e(e.color)} ${e.m.join(" ")} ${e.file}`:e.src?e.src:`${e.t} ${_e(e.color)} ${e.p.join(" ")}`,Te=(e,t)=>`${q(e)}#${t}`;function Ut(e,t){let n=[],r=0,o=(s)=>!!s&&s.t===0&&s.texmap?.op==="NEXT";for(let s of e.cmds){if(s.t===0){if(s.step){r++;continue}if(s.bfc!==void 0){n.push(s);continue}if(r!==t)continue;if(s.texmap)n.push(s);else if(s.geom){if(s.geom.t>=2)n.push(s);else if(o(n[n.length-1]))n.pop()}continue}if(r!==t)continue;if(s.t===1){if(o(n[n.length-1]))n.pop();continue}n.push(s)}return{name:Te(e.name,t),cmds:n}}function tt(e,t){return[`0 ldr: own geometry of ${e.name}, step ${t}`,...Ut(e,t).cmds.map(Rt)].join(`\n`)+`\n`}function Dt(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function nt(e){let[t,n,r,o,s,i,c,a,l,f,g,p]=e,y=a*p-l*g,C=-(c*p-l*f),u=c*g-a*f,m=o*y+s*C+i*u;if(!Number.isFinite(m)||Math.abs(m)<0.000000000001)return null;let P=1/m,b=[y*P,-(s*p-i*g)*P,(s*l-i*a)*P,C*P,(o*p-i*f)*P,-(o*l-i*c)*P,u*P,-(o*g-s*f)*P,(o*a-s*c)*P];return[-(b[0]*t+b[1]*n+b[2]*r),-(b[3]*t+b[4]*n+b[5]*r),-(b[6]*t+b[7]*n+b[8]*r),...b]}var Ot=(e)=>String(+e.toFixed(6)||0),Ke=(e)=>\'"\'+e.replace(/\\\\/g,"\\\\\\\\").replace(/"/g,"\\\\\\"")+\'"\';function rt(e,t){let n=[...t.p1,...t.p2,...t.p3,...t.method!=="PLANAR"?[t.a??360]:[],...t.method==="SPHERICAL"?[t.b??180]:[]].map(Ot).join(" "),r=`0 ldr: ${e} with a model-level !TEXMAP\n0 BFC CERTIFY CCW\n0 !TEXMAP START ${t.method} ${n} ${Ke(t.texture)}${t.glossmap?" GLOSSMAP "+Ke(t.glossmap):""}\n1 16 0 0 0 1 0 0 0 1 0 0 0 1 ${q(e)}\n0 !TEXMAP END\n`;return{name:`${q(e)}#tex-${Dt(r)}`,source:r}}var zt=(e,t)=>{let n=[,,,,,,,,,];for(let r=0;r<3;r++)for(let o=0;o<3;o++)n[r*3+o]=e[r*3]*t[o]+e[r*3+1]*t[3+o]+e[r*3+2]*t[6+o];return n};function Bt(e,t,n){let r=Math.PI/180,o=Math.sin(e*r),s=Math.cos(e*r),i=Math.sin(t*r),c=Math.cos(t*r),a=Math.sin(n*r),l=Math.cos(n*r);return[c*l,-c*a,i,s*a+o*i*l,s*l-o*i*a,-o*c,o*a-s*i*l,o*l+s*i*a,s*c]}var Ye=new WeakMap;function ot(e){let t=Ye.get(e);if(t)return t;let n=[],r=null;for(let o of e.cmds){if(o.t!==0||!o.step)continue;let s=o.rotstep;if(s)if(s.mode==="END")r=null;else{let i=Bt(s.x,s.y,s.z);r=s.mode==="ABS"?{abs:!0,m:i,rotstep:s}:s.mode==="ADD"&&r?{abs:r.abs,m:zt(r.m,i),rotstep:s}:{abs:!1,m:i,rotstep:s}}n.push(r)}return n.push(r),Ye.set(e,n),n}function Nt(e,t={}){let n=[],r=t.maxDepth??64,o=t.looseGeometry!==!1,s=!!t.textures,i=new Map,c=(l,f)=>{let g=l.name+"#"+f,p=i.get(g);if(!p){let y;p=Object.assign(()=>y??=tt(l,f),{file:l,step:f}),i.set(g,p)}return p},a=(l,f,g,p,y,C,u,m)=>{let P=l.files.get(f);if(!P||u>r)return;let b=0,d=ot(P),S=o?et(P):[],k=0,w=(M,x,A,L,D,F,v)=>{let h={part:M,color:x,m:A,step:L[0],steps:L,localStep:D,path:y};if(F)h.embedded=!0;if(v){let R=rt(M,v);h.texPart=R.name,h.texSource=R.source}let T=d[D];if(T)h.view=T;return n.push(h),h},E=(M)=>{while(k<S.length&&S[k]<=M){let x=S[k++];w(Te(P.name,x),p,g,[...C,x],x,!1,null).source=c(P,x)}};for(let M of P.cmds){if(M.t===0&&M.step){b++;continue}let x=M;if(x.t>=2||x.t===0&&x.geom&&x.geom.t>=2){E(b);continue}if(x.t===0)if(s&&x.geom?.t===1)x=x.geom;else continue;if(x.t!==1)continue;if(s&&x.fallback)continue;let A=x.color===16?p:x.color,L=Qe(g,x.m),D=[...C,b],F=s?x.tex??m:null,v=F?nt(x.m):null,h=F&&v?qe(F,v):null;if(l.files.has(x.file)){if(Ee(l,x.file)==="model"){a(l,x.file,L,A,y+"/"+x.file,D,u+1,h);continue}w(x.file,A,L,D,b,!0,h);continue}let T=t.resolveModel?.(x.file);if(T){a(T,T.main,L,A,y+"/"+x.file,D,u+1,h);continue}w(x.file,A,L,D,b,!1,h)}E(1/0)};if(Ee(e,e.main)==="part"){if(e.files.get(e.main))n.push({part:e.main,color:16,m:[...Pe],step:0,steps:[0],localStep:0,path:e.main,embedded:!0});return n}return a(e,e.main,Pe,16,e.main,[],0,null),n}function st(e,t="main.ldr",n){return Nt(Ze(e,t,{geometryText:!0}),n)}var it=(e,t=0)=>Math.abs(e[t+7]-1)<0.001&&Math.abs(e[t+4])<0.001&&Math.abs(e[t+10])<0.001,at=new WeakMap;function Le(e,t){let n=at.get(e);if(!n)at.set(e,n=new Map);let r=n.get(t);if(r!==void 0)return r;let o=e.parts[t];if(!o)return n.set(t,null),null;let s=o.studs.length,i=new Float64Array(s*12),c=[],a=[];o.studs.forEach((p,y)=>{c.push(p[0]),a.push(p[1]);for(let C=0;C<12;C++)i[y*12+C]=p[2+C]});let l=null,f=0,g=0;if(o.mask){f=o.mask[0],g=o.mask[1];let p=o.mask[2];l=new Uint8Array(p.length);for(let y=0;y<p.length;y++)l[y]=p.charCodeAt(y)===49?1:0}return n.set(t,r={nStuds:s,studM:i,kind:c,color:a,mask:l,nx:f,nz:g}),r}var ie=1073741824;class Ie{a;b;c;vals;used;mask;size=0;constructor(e=1024){let t=1024;while(t<e*2)t*=2;this.a=new Int32Array(t),this.b=new Int32Array(t),this.c=new Int32Array(t),this.vals=new Int32Array(t),this.used=new Uint8Array(t),this.mask=t-1}slot(e,t,n){let r=Math.imul(e,2654435761)^Math.imul(t,2246822507)^Math.imul(n,3266489909);return r^=r>>>15,r=Math.imul(r,739982445),r^=r>>>12,r&this.mask}get(e,t,n){let r=this.slot(e,t,n),o=this.used,s=this.a,i=this.b,c=this.c;for(;;){if(!o[r])return-1;if(s[r]===e&&i[r]===t&&c[r]===n)return this.vals[r];r=r+1&this.mask}}put(e,t,n,r){if((this.size+1)*2>this.used.length)this.grow();let o=this.slot(e,t,n),s=this.used,i=this.a,c=this.b,a=this.c;for(;;){if(!s[o])return s[o]=1,i[o]=e,c[o]=t,a[o]=n,this.vals[o]=r,this.size++,-1;if(i[o]===e&&c[o]===t&&a[o]===n){let l=this.vals[o];return this.vals[o]=r,l}o=o+1&this.mask}}grow(){let{a:e,b:t,c:n,vals:r,used:o}=this,s=o.length*2;this.a=new Int32Array(s),this.b=new Int32Array(s),this.c=new Int32Array(s),this.vals=new Int32Array(s),this.used=new Uint8Array(s),this.mask=s-1,this.size=0;for(let i=0;i<o.length;i++)if(o[i])this.put(e[i],t[i],n[i],r[i])}}var ye=(e,t,n)=>e>-ie&&e<ie&&t>-ie&&t<ie&&n>-ie&&n<ie,fe=2147483647;function $t(e,t,n){let o=[],s=[],i=[],c=[],a=[],l=[],f=[],g=[],p=new Ie(e.length*2),y=[],C=[];for(let v=0;v<e.length;v++){let h=e[v],T=h.m,R=t.parts[h.part];if(!R||!R.mask||!it(T))continue;let I=R.bbox,U=1/0,O=-1/0,K=1/0,H=-1/0;for(let N=0;N<2;N++)for(let G=0;G<2;G++){let X=N?I[3]:I[0],Y=G?I[5]:I[2],W=T[0]+T[3]*X+T[5]*Y,_=T[2]+T[9]*X+T[11]*Y;if(W<U)U=W;if(W>O)O=W;if(_<K)K=_;if(_>H)H=_}let z=a.length;o.push(U),s.push(O),i.push(K),c.push(H),a.push(v),l.push(Le(t,h.part)),f.push(I[0]),g.push(I[2]);let B=Math.round((T[1]+I[4])*2);for(let N=Math.floor(U/40);N<=Math.floor(O/40);N++)for(let G=Math.floor(K/40);G<=Math.floor(H/40);G++){if(!ye(B,N,G))continue;let X=C.length;C.push(z),y.push(p.put(B,N,G,X))}}let u=[0,5,-5,5,-5],m=[0,5,5,-5,-5],P=NaN,b=NaN,d=NaN,S=-1,k=(v,h,T,R)=>{let I=Math.round(h*2),U=Math.floor(v/40),O=Math.floor(T/40);if(!ye(I,U,O))return fe;let K=fe;if(I!==P||U!==b||O!==d)P=I,b=U,d=O,S=p.get(I,U,O);for(let H=S;H>=0;H=y[H]){let z=C[H];if(a[z]===R||!(v-6>=o[z]-0.5&&v+6<=s[z]+0.5&&T-6>=i[z]-0.5&&T+6<=c[z]+0.5))continue;let B=e[a[z]].m,N=l[z],G=f[z],X=g[z],Y=v-B[0],W=h-B[1],_=T-B[2],Z=B[3]*Y+B[6]*W+B[9]*_,J=B[5]*Y+B[8]*W+B[11]*_,{nx:ee,nz:oe,mask:ae}=N,se=!0;for(let Q=0;Q<5;Q++){let te=Math.floor((Z+u[Q]-G)/20),ne=Math.floor((J+m[Q]-X)/20);if(te<0||ne<0||te>=ee||ne>=oe||ae[te*oe+ne]!==1){se=!1;break}}if(se){if(!n)return 0;let Q=n[a[z]];if(Q<K)K=Q}}return K},w=0;for(let v of e){let h=Le(t,v.part);if(h)w+=h.nStuds}let E=new Uint8Array(w),M=new Uint8Array(w),x=new Ie(w),A=0,L=n?new Int32Array(w).fill(fe):void 0;for(let v=0,h=0;v<e.length;v++){let T=e[v],R=Le(t,T.part);if(!R)continue;let I=T.m,U=R.studM,O=I[0],K=I[1],H=I[2],z=I[3],B=I[4],N=I[5],G=I[6],X=I[7],Y=I[8],W=I[9],_=I[10],Z=I[11];for(let J=0;J<R.nStuds;J++,h++){let ee=J*12,oe=U[ee+4],ae=U[ee+7],se=U[ee+10];if(!(Math.abs(G*oe+X*ae+Y*se-1)<0.001&&Math.abs(z*oe+B*ae+N*se)<0.001&&Math.abs(W*oe+_*ae+Z*se)<0.001))continue;M[h]=1;let Q=U[ee],te=U[ee+1],ne=U[ee+2],Re=O+z*Q+B*te+N*ne,Ue=K+G*Q+X*te+Y*ne,De=H+W*Q+_*te+Z*ne,Oe=k(Re,Ue,De,v);if(Oe!==fe){if(E[h]=1,A++,L)L[h]=Oe}let pe=Math.round(Re),me=Math.round(Ue),he=Math.round(De);if(!ye(pe,me,he))continue;if(!n){x.put(pe,me,he,1);continue}let ze=n[v],Be=x.get(pe,me,he);if(Be<0||ze<Be)x.put(pe,me,he,ze)}}let D=new Uint8Array(e.length),F=n?new Int32Array(e.length).fill(fe):void 0;for(let v=0;v<e.length;v++){let h=e[v],T=t.parts[h.part];if(!T||!T.under||!it(h.m))continue;let R=T.bbox,I=Math.round((R[3]-R[0])/20),U=Math.round((R[5]-R[2])/20);if(!I||!U||I*U>4096)continue;let O=h.m,K=!0,H=0;for(let z=0;z<I&&K;z++)for(let B=0;B<U;B++){let N=R[0]+10+20*z,G=R[2]+10+20*B,X=O[0]+O[3]*N+O[5]*G,Y=O[2]+O[9]*N+O[11]*G,W=Math.round(X),_=Math.round(O[1]+R[4]),Z=Math.round(Y),J=ye(W,_,Z)?x.get(W,_,Z):-1;if(J<0){K=!1;break}if(J>H)H=J}if(K){if(D[v]=1,F)F[v]=H}}return{nStuds:w,studHidden:E,studUp:M,underHidden:D,studsHidden:A,studHideStep:L,underHideStep:F}}function jt(e,t,n){let r=(a)=>n&&a.texPart&&t.parts[a.texPart]?a.texPart:a.part,o=e.map((a)=>({part:r(a),color:String(a.color),m:a.m,steps:a.steps})),s=o.map((a)=>a.steps.map((l)=>String(l).padStart(6,"0")).join(".")),i=[...new Set(s)].sort(),c=new Map(i.map((a,l)=>[a,l]));return{all:o,stepOf:s.map((a)=>c.get(a)),nSteps:i.length}}function xe(e,t,n=!0){let r=jt(e,t,n);return $t(r.all,t,r.nSteps>1?r.stepOf:void 0)}var Fe="https://ldr-demo.vercel.app/cdn/v1/",ke=new Map,we=new Map;function lt(e=Fe,t=fetch){let n=ke.get(e);if(!n)n=t(e+"parts.json").then((r)=>{if(!r.ok)throw Error(`ldr: parts CDN index ${r.status} (${e}parts.json)`);return r.json()}),n.catch(()=>ke.delete(e)),ke.set(e,n);return n}var Vt=(e)=>Array.isArray(e)&&e.length===3&&typeof e[0]==="number"&&typeof e[1]==="number"&&(e[2]==="f32"||e[2]==="u16"||e[2]==="u8"||e[2]==="u32"),ve=(e,t)=>Vt(e)?[e[0]+t,e[1],e[2]]:Array.isArray(e)?e.map((n)=>ve(n,t)):e&&typeof e==="object"?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,ve(r,t)])):e;function Ht(e,t={}){let n=[],r=0,o={},s={};for(let p of e){let y=p.buffer;if(!y)throw Error("ldr: mergePacks needs packs from decodePack/loadPack");let C=new DataView(y).getUint32(0,!0),u=new Uint8Array(y,4+C),m=r;n.push(u),r+=u.byteLength;let P=(4-r%4)%4;if(P)n.push(new Uint8Array(P)),r+=P;for(let[b,d]of Object.entries(p.header.parts??{}))if(!(b in o))o[b]=ve(d,m);for(let[b,d]of Object.entries(p.header.studKinds??{}))if(!(b in s))s[b]=ve(d,m)}let i=e[0]?.header??{version:1,weld:!0},c=new TextEncoder().encode(JSON.stringify({...i,parts:o,studKinds:s,...t})),a=(4-(4+c.length)%4)%4,l=4+c.length+a,f=new Uint8Array(l+r);new DataView(f.buffer).setUint32(0,c.length+a,!0),f.set(c,4),f.fill(32,4+c.length,l);let g=l;for(let p of n)f.set(p,g),g+=p.byteLength;return de(f.buffer)}async function Gt(e,t={}){let n=t.cdn??Fe,r=t.fetch??fetch,o=t.gap??16384,s=await lt(n,r),i=[...new Set([...e].map(q))],c=[],a=[];for(let u of i){if(we.has(n+u))continue;let m=s.parts[u];if(m)a.push({name:u,off:m[0],len:m[1],file:m[2]??0});else c.push(u)}a.sort((u,m)=>u.file-m.file||u.off-m.off);let l=[];for(let u of a){let m=l[l.length-1];if(m&&m.file===u.file&&u.off-m.end<=o)m.end=Math.max(m.end,u.off+u.len),m.items.push(u);else l.push({file:u.file,start:u.off,end:u.off+u.len,items:[u]})}let f=0,g=0,p=async()=>{while(g<l.length){let u=l[g++],m=await r(new URL(s.archives[u.file],n).href,{headers:{Range:`bytes=${u.start}-${u.end-1}`}});if(!m.ok)throw Error(`ldr: parts CDN ${m.status}`);let P=new Uint8Array(await m.arrayBuffer());if(m.status===200)P=P.subarray(u.start,u.end);f+=P.byteLength;for(let b of u.items){let d=je(P.subarray(b.off-u.start,b.off-u.start+b.len)),S=d.buffer.slice(d.byteOffset,d.byteOffset+d.byteLength);we.set(n+b.name,de(S))}}};await Promise.all(Array.from({length:Math.min(t.concurrency??24,l.length)},p));let y=i.filter((u)=>we.has(n+u)).map((u)=>we.get(n+u));return{pack:y.length?Ht(y,{colors:s.colors}):de(Xt(s.colors)),missing:c,requests:l.length,bytes:f}}function Xt(e){let t=new TextEncoder().encode(JSON.stringify({version:1,weld:!0,parts:{},studKinds:{},colors:e})),n=(4-(4+t.length)%4)%4,r=new Uint8Array(4+t.length+n).fill(32);return new DataView(r.buffer).setUint32(0,t.length+n,!0),r.set(t,4),r.buffer}async function ct(e,t={}){let n=performance.now(),r=t.fetch??fetch,o=lt(t.cdn??Fe,r);o.catch(()=>{});let s=t.text?e:await r(e).then((m)=>{if(!m.ok)throw Error(`ldr: ${m.status} fetching ${e}`);return m.text()}),i=performance.now(),c=t.name??(t.text?"main.ldr":decodeURIComponent(e.split(/[?#]/)[0].split("/").pop()||"main.ldr")),a=st(s,c,{looseGeometry:!1}),l=performance.now();t.onParsed?.(a),await o;let{pack:f,missing:g,requests:p,bytes:y}=await Gt(a.filter((m)=>!m.embedded).map((m)=>m.part),t),C=performance.now(),u=t.cull?xe(a,f.header,t.textures!==!1):void 0;return{insts:a,pack:f,missing:g,requests:p,bytes:y,cull:u,timings:{fetchModel:i-n,parse:l-i,parts:C-l,...u?{cull:performance.now()-C}:{}}}}self.onmessage=async(e)=>{let{id:t,source:n,opts:r}=e.data;try{let o=await ct(n,{...r,cull:!1,onParsed:(f)=>self.postMessage({id:t,insts:f})}),s=o.pack.buffer;if(self.postMessage({id:t,buffer:s,missing:o.missing,requests:o.requests,bytes:o.bytes,timings:o.timings},[s]),!r.cull)return;let i=performance.now(),c=xe(o.insts,o.pack.header,r.textures!==!1),a=performance.now()-i,l=[];for(let f of[c.studHidden,c.studUp,c.underHidden,c.studHideStep,c.underHideStep])if(f)l.push(f.buffer);self.postMessage({id:t,cull:c,ms:a},l)}catch(o){self.postMessage({id:t,phase:"error",error:String(o?.message??o)})}};\n';
|
|
2996
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/load-worker.gen.ts
|
|
2997
|
+
var load_worker_gen_default = 'var ht=ArrayBuffer,X=Uint8Array,ge=Uint16Array,gt=Int16Array;var be=Int32Array,Se=function(e,t,n){if(X.prototype.slice)return X.prototype.slice.call(e,t,n);if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;var r=new X(n-t);return r.set(e.subarray(t,n)),r},ce=function(e,t,n,r){if(X.prototype.fill)return X.prototype.fill.call(e,t,n,r);if(n==null||n<0)n=0;if(r==null||r>e.length)r=e.length;for(;n<r;++n)e[n]=t;return e},bt=function(e,t,n,r){if(X.prototype.copyWithin)return X.prototype.copyWithin.call(e,t,n,r);if(n==null||n<0)n=0;if(r==null||r>e.length)r=e.length;while(n<r)e[t++]=e[n++]};var dt=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],W=function(e,t,n){var r=Error(t||dt[e]);if(r.code=e,Error.captureStackTrace)Error.captureStackTrace(r,W);if(!n)throw r;return r},Be=function(e,t,n){var r=0,s=0;for(;r<n;++r)s|=e[t++]<<(r<<3);return s},yt=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},xt=function(e,t){var n=e[0]|e[1]<<8|e[2]<<16;if(n==3126568&&e[3]==253){var r=e[4],s=r>>5&1,o=r>>2&1,i=r&3,l=r>>6;if(r&8)W(0);var a=6-s,c=i==3?4:i,p=Be(e,a,c);a+=c;var m=l?1<<l:s,h=Be(e,a,m)+(l==1&&256),d=h;if(!s){var S=1<<10+(e[5]>>3);d=S+(S>>3)*(e[5]&7)}if(d>2145386496)W(1);var u=new X((t==1?h||d:t?0:d)+12);return u[0]=1,u[4]=4,u[8]=8,{b:a+m,y:0,l:0,d:p,w:t&&t!=1?t:u.subarray(12),e:d,o:new be(u.buffer,0,3),u:h,c:o,m:Math.min(131072,d)}}else if((n>>4|e[3]<<20)==25481893)return yt(e,4)+8;W(0)},re=function(e){var t=0;for(;1<<t<=e;++t);return t-1},ue=function(e,t,n){var r=(t<<3)+4,s=(e[t]&15)+5;if(s>n)W(3);var o=1<<s,i=o,l=-1,a=-1,c=-1,p=o,m=new ht(512+(o<<2)),h=new gt(m,0,256),d=new ge(m,0,256),S=new ge(m,512,o),u=512+(o<<1),b=new X(m,u,o),P=new X(m,u+o);while(l<255&&i>0){var g=re(i+1),f=r>>3,A=(1<<g+1)-1,O=(e[f]|e[f+1]<<8|e[f+2]<<16)>>(r&7)&A,y=(1<<g)-1,M=A-i-1,E=O&y;if(E<M)r+=g,O=E;else if(r+=g+1,O>y)O-=M;if(h[++l]=--O,O==-1)i+=O,b[--p]=l;else i-=O;if(!O)do{var D=r>>3;a=(e[D]|e[D+1]<<8)>>(r&7)&3,r+=2,l+=a}while(a==3)}if(l>255||i)W(0);var C=0,U=(o>>1)+(o>>3)+3,_=o-1;for(var H=0;H<=l;++H){var v=h[H];if(v<1){d[H]=-v;continue}for(c=0;c<v;++c){b[C]=H;do C=C+U&_;while(C>=p)}}if(C)W(0);for(c=0;c<o;++c){var w=d[b[c]]++,L=P[c]=s-re(w);S[c]=(w<<L)-o}return[r+7>>3,{b:s,s:b,n:P,t:S}]},wt=function(e,t){var n=0,r=-1,s=new X(292),o=e[t],i=s.subarray(0,256),l=s.subarray(256,268),a=new ge(s.buffer,268);if(o<128){var c=ue(e,t+1,6),p=c[0],m=c[1];t+=o;var h=p<<3,d=e[t];if(!d)W(0);var S=0,u=0,b=m.b,P=b,g=(++t<<3)-8+re(d);for(;;){if(g-=b,g<h)break;var f=g>>3;if(S+=(e[f]|e[f+1]<<8)>>(g&7)&(1<<b)-1,i[++r]=m.s[S],g-=P,g<h)break;f=g>>3,u+=(e[f]|e[f+1]<<8)>>(g&7)&(1<<P)-1,i[++r]=m.s[u],b=m.n[S],S=m.t[S],P=m.n[u],u=m.t[u]}if(++r>255)W(0)}else{r=o-127;for(;n<r;n+=2){var A=e[++t];i[n]=A>>4,i[n+1]=A&15}++t}var O=0;for(n=0;n<r;++n){var y=i[n];if(y>11)W(0);O+=y&&1<<y-1}var M=re(O)+1,E=1<<M,D=E-O;if(D&D-1)W(0);i[r++]=re(D)+1;for(n=0;n<r;++n){var y=i[n];++l[i[n]=y&&M+1-y]}var C=new X(E<<1),U=C.subarray(0,E),_=C.subarray(E);a[M]=0;for(n=M;n>0;--n){var H=a[n];ce(_,n,H,a[n-1]=H+l[n]*(1<<M-n))}if(a[0]!=E)W(0);for(n=0;n<r;++n){var v=i[n];if(v){var w=a[v];ce(U,n,w,a[v]=w+(1<<M-v))}}return[t,{n:_,b:M,s:U}]},At=ue(new X([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],vt=ue(new X([33,20,196,24,99,140,33,132,16,66,8,33,132,16,66,8,33,68,68,68,68,68,68,68,68,36,9]),0,6)[1],Mt=ue(new X([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],$e=function(e,t){var n=e.length,r=new be(n);for(var s=0;s<n;++s)r[s]=t,t+=1<<e[s];return r},Ce=new X(new be([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),St=$e(Ce,0),Pe=new X(new be([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),Ct=$e(Pe,3),le=function(e,t,n){var r=e.length,s=t.length,o=e[r-1],i=(1<<n.b)-1,l=-n.b;if(!o)W(0);var a=0,c=n.b,p=(r<<3)-8+re(o)-c,m=-1;for(;p>l&&m<s;){var h=p>>3,d=(e[h]|e[h+1]<<8|e[h+2]<<16)>>(p&7);a=(a<<c|d)&i,t[++m]=n.s[a],p-=c=n.n[a]}if(p!=l||m+1!=s)W(0)},Pt=function(e,t,n){var r=6,s=t.length,o=s+3>>2,i=o<<1,l=o+i;le(e.subarray(r,r+=e[0]|e[1]<<8),t.subarray(0,o),n),le(e.subarray(r,r+=e[2]|e[3]<<8),t.subarray(o,i),n),le(e.subarray(r,r+=e[4]|e[5]<<8),t.subarray(i,l),n),le(e.subarray(r),t.subarray(l),n)},Et=function(e,t,n){var r,s=t.b,o=e[s],i=o>>1&3;t.l=o&1;var l=o>>3|e[s+1]<<5|e[s+2]<<13,a=(s+=3)+l;if(i==1){if(s>=e.length)return;if(t.b=s+1,n)return ce(n,e[s],t.y,t.y+=l),n;return ce(new X(l),e[s])}if(a>e.length)return;if(i==0){if(t.b=a,n)return n.set(e.subarray(s,a),t.y),t.y+=l,n;return Se(e,s,a)}if(i==2){var c=e[s],p=c&3,m=c>>2&3,h=c>>4,d=0,S=0;if(p<2)if(m&1)h|=e[++s]<<4|(m&2&&e[++s]<<12);else h=c>>3;else if(S=m,m<2)h|=(e[++s]&63)<<4,d=e[s]>>6|e[++s]<<2;else if(m==2)h|=e[++s]<<4|(e[++s]&3)<<12,d=e[s]>>2|e[++s]<<6;else h|=e[++s]<<4|(e[++s]&63)<<12,d=e[s]>>6|e[++s]<<2|e[++s]<<10;++s;var u=n?n.subarray(t.y,t.y+t.m):new X(t.m),b=u.length-h;if(p==0)u.set(e.subarray(s,s+=h),b);else if(p==1)ce(u,e[s++],b);else{var P=t.h;if(p==2){var g=wt(e,s);d+=s-(s=g[0]),t.h=P=g[1]}else if(!P)W(0);(S?Pt:le)(e.subarray(s,s+=d),u.subarray(b),P)}var f=e[s++];if(f){if(f==255)f=(e[s++]|e[s++]<<8)+32512;else if(f>127)f=f-128<<8|e[s++];var A=e[s++];if(A&3)W(0);var O=[vt,Mt,At];for(var y=2;y>-1;--y){var M=A>>(y<<1)+2&3;if(M==1){var E=new X([0,0,e[s++]]);O[y]={s:E.subarray(2,3),n:E.subarray(0,1),t:new ge(E.buffer,0,1),b:0}}else if(M==2)r=ue(e,s,9-(y&1)),s=r[0],O[y]=r[1];else if(M==3){if(!t.t)W(0);O[y]=t.t[y]}}var D=t.t=O,C=D[0],U=D[1],_=D[2],H=e[a-1];if(!H)W(0);var v=(a<<3)-8+re(H)-_.b,w=v>>3,L=0,V=(e[w]|e[w+1]<<8)>>(v&7)&(1<<_.b)-1;w=(v-=U.b)>>3;var I=(e[w]|e[w+1]<<8)>>(v&7)&(1<<U.b)-1;w=(v-=C.b)>>3;var B=(e[w]|e[w+1]<<8)>>(v&7)&(1<<C.b)-1;for(++f;--f;){var T=_.s[V],x=_.n[V],N=C.s[B],F=C.n[B],R=U.s[I],z=U.n[I];w=(v-=R)>>3;var j=1<<R,k=j+((e[w]|e[w+1]<<8|e[w+2]<<16|e[w+3]<<24)>>>(v&7)&j-1);w=(v-=Pe[N])>>3;var G=Ct[N]+((e[w]|e[w+1]<<8|e[w+2]<<16)>>(v&7)&(1<<Pe[N])-1);w=(v-=Ce[T])>>3;var K=St[T]+((e[w]|e[w+1]<<8|e[w+2]<<16)>>(v&7)&(1<<Ce[T])-1);if(w=(v-=x)>>3,V=_.t[V]+((e[w]|e[w+1]<<8)>>(v&7)&(1<<x)-1),w=(v-=F)>>3,B=C.t[B]+((e[w]|e[w+1]<<8)>>(v&7)&(1<<F)-1),w=(v-=z)>>3,I=U.t[I]+((e[w]|e[w+1]<<8)>>(v&7)&(1<<z)-1),k>3)t.o[2]=t.o[1],t.o[1]=t.o[0],t.o[0]=k-=3;else{var Y=k-(K!=0);if(Y){if(k=Y==3?t.o[0]-1:t.o[Y],Y>1)t.o[2]=t.o[1];t.o[1]=t.o[0],t.o[0]=k}else k=t.o[0]}for(var y=0;y<K;++y)u[L+y]=u[b+y];L+=K,b+=K;var q=L-k;if(q<0){var Z=-q,ee=t.e+q;if(Z>G)Z=G;for(var y=0;y<Z;++y)u[L+y]=t.w[ee+y];L+=Z,G-=Z,q=0}for(var y=0;y<G;++y)u[L+y]=u[q+y];L+=G}if(L!=b)while(b<u.length)u[L++]=u[b++];else L=u.length;if(n)t.y+=L;else u=Se(u,0,L)}else if(n){if(t.y+=h,b)for(var y=0;y<h;++y)u[y]=u[b+y]}else if(b)u=Se(u,b);return t.b=a,u}W(2)},Tt=function(e,t){if(e.length==1)return e[0];var n=new X(t);for(var r=0,s=0;r<e.length;++r){var o=e[r];n.set(o,s),s+=o.length}return n};function je(e,t){var n=[],r=+!t,s=0,o=0;for(;e.length;){var i=xt(e,r||t);if(typeof i=="object"){if(r){if(t=null,i.w.length==i.u)n.push(t=i.w),o+=i.u}else n.push(t),i.e=0;for(;!i.l;){var l=Et(e,i,t);if(!l)W(5);if(t)i.e=i.y;else n.push(l),o+=l.length,bt(i.w,0,l.length),i.w.set(l,i.w.length-l.length)}s=i.b+i.c*4}else s=i;e=e.subarray(s)}return Tt(n,o)}function de(e){let t=new DataView(e).getUint32(0,!0),n=JSON.parse(new TextDecoder().decode(new Uint8Array(e,4,t))),r=4+t;return{header:n,arr:(o)=>o&&(o[2]==="f32"?new Float32Array(e,r+o[0],o[1]):o[2]==="u16"?new Uint16Array(e,r+o[0],o[1]):o[2]==="u8"?new Uint8Array(e,r+o[0],o[1]):new Uint32Array(e,r+o[0],o[1])),bytes:e.byteLength,buffer:e}}var J=(e)=>e.trim().toLowerCase().replace(/\\\\/g,"/").replace(/\\/+/g,"/");function Ee(e){if(/^0x/i.test(e))return parseInt(e,16);return+e}var Ve=/^~?\\s*moved\\s+to\\s+(.+)$/i,Lt=new Set(["FILE","NOFILE","!DATA","!:","STEP","BFC","ROTSTEP","BUFEXCHG","!TEXMAP"]),Je=new Set(["part","subpart","primitive","8_primitive","48_primitive","shortcut","helper"]),It=new Set(["model","submodel","configuration"]),kt=/^(?:!?LDRAW_ORG|Unofficial|Official\\s+LCAD)\\s+(\\S+)/i;function He(e){let t=kt.exec(e);if(!t)return;let n=t[1].toLowerCase().replace(/^unofficial_/,"");return Je.has(n)||It.has(n)?n:void 0}function Ft(e){let t=[],n=0;while(n<e.length){while(e[n]===" "||e[n]==="\\t")n++;if(n>=e.length)break;if(e[n]===\'"\'){let r="";n++;while(n<e.length&&e[n]!==\'"\'){if(e[n]==="\\\\"&&n+1<e.length)n++;r+=e[n++]}n++,t.push(r)}else{let r=n;while(r<e.length&&e[r]!==" "&&e[r]!=="\\t")r++;t.push(e.slice(n,r)),n=r}}return t}function Rt(e,t=!1){let n=/^\\s*(\\S+)\\s+(.*)$/.exec(e);if(!n)return null;let r=n[1].toUpperCase(),s=r==="PLANAR"?9:r==="CYLINDRICAL"?10:r==="SPHERICAL"?11:0;if(!s)return null;let o=n[2].trim().split(/\\s+/);if(o.length<s+1)return null;let i=o.slice(0,s).map(Number);if(!i.every(Number.isFinite))return null;let l=n[2].trim();for(let m=0;m<s;m++)l=l.replace(/^\\S+\\s*/,"");let a=Ft(l);if(!a.length)return null;let c={method:r,p1:i.slice(0,3),p2:i.slice(3,6),p3:i.slice(6,9),texture:a[0]};if(s>=10)c.a=i[9];if(s===11)c.b=i[10];let p=a.findIndex((m,h)=>h>0&&m.toUpperCase()==="GLOSSMAP");if(p>0&&a[p+1])c.glossmap=a[p+1];if(t)c.next=!0;return c}var Dt=(e)=>{let t=e.replace(/[^A-Za-z0-9+/]/g,""),n=t+"=".repeat((4-t.length%4)%4),r=atob(n),s=new Uint8Array(r.length);for(let o=0;o<r.length;o++)s[o]=r.charCodeAt(o);return s};function Ut(e){let t=e.length,n=1,r=(c)=>c===32||c===9,s=()=>{while(n<t&&r(e.charCodeAt(n)))n++;let c=n;while(n<t&&!r(e.charCodeAt(n)))n++;return c<n?e.slice(c,n):null},o=s();if(o===null)return null;let i=Array(12);for(let c=0;c<12;c++){let p=s();if(p===null)return null;i[c]=+p}while(n<t&&r(e.charCodeAt(n)))n++;if(n>=t)return null;let l=e.slice(n),a=/[ \\t]{2,}|\\t/.test(l)?l.split(/\\s+/).join(" "):l;return{t:1,color:Ee(o),m:i,file:J(a)}}function Ge(e){let t=+e[0];if(!(t>=1&&t<=5)||e.length<2)return null;let n=Ee(e[1]),r=e.slice(2).map(Number);if(t===1)return{t:1,color:n,m:r.slice(0,12),file:J(e.slice(14).join(" "))};if(t===2)return{t:2,color:n,p:r.slice(0,6)};if(t===3)return{t:3,color:n,p:r.slice(0,9)};if(t===4)return{t:4,color:n,p:r.slice(0,12)};return{t:5,color:n,p:r.slice(0,12)}}function Ze(e,t="main.ldr",n={}){let r=!!n.geometryText,s=new Map,o=null,i="",l,a=null,c=[],p=null,m=()=>{if(!a)return;let g=Dt(a.chunks.join("")),f=g[0]===137&&g[1]===80&&g[2]===78&&g[3]===71;(l??=new Map).set(J(a.name),{name:a.name,bytes:g,...f?{mime:"image/png"}:{}}),a=null},h=!0,d=(g)=>{if(m(),o={name:J(g),cmds:[]},s.set(o.name,o),!i)i=o.name;c=[],p=null,h=!0},S=!1,u=!1,b=()=>{if(u)return;u=!0,s.clear(),o=null,i=""},P=(g,f)=>{if(p){g.tex=p,p=null;return}let A=c[c.length-1];if(!A)return;if(A.fallback){if(!f)g.fallback=!0}else g.tex=A.map};for(let g of e.split(`\n`)){let f=g.trim();if(!f)continue;if(r&&f.charCodeAt(0)>=50&&f.charCodeAt(0)<=53&&(f.charCodeAt(1)===32||f.charCodeAt(1)===9)){if(a||S)continue;if(!o)d(t);let M=f.slice(2).trimStart(),E=M.search(/\\s/),D={t:f.charCodeAt(0)-48,color:Ee(E<0?M:M.slice(0,E)),p:[],src:f};P(D,!1),o.cmds.push(D),h=!1;continue}if(f.charCodeAt(0)===48&&(f.charCodeAt(1)===32||f.charCodeAt(1)===9)){let M=2;while(f.charCodeAt(M)===32||f.charCodeAt(M)===9)M++;let E=M;while(E<f.length&&f.charCodeAt(E)!==32&&f.charCodeAt(E)!==9)E++;let D=f.slice(M,E);if(!Lt.has(D)){if(S||a)continue;if(!o)d(t);let C=f.slice(M),U={t:0,text:C};if(D.charCodeAt(0)===33)U.meta=D;if(p=null,h&&!o.org){let H=He(C);if(H)o.org=H}let _=C.match(Ve);if(_&&!o.movedTo){let H=_[1].trim().replace(/\\\\/g,"/");if(!/\\.(dat|ldr|mpd)$/i.test(H))H+=".dat";o.movedTo=J(H)}o.cmds.push(U);continue}}if(f.charCodeAt(0)===49&&(f.charCodeAt(1)===32||f.charCodeAt(1)===9)&&!a&&!S){let M=Ut(f);if(M){if(!o)d(t);P(M,!1),o.cmds.push(M),h=!1;continue}}let A=f.split(/\\s+/);if(+A[0]===0){let M=f.slice(1).trim();if(A[1]==="FILE"){b(),S=!1,d(M.slice(5));continue}if(A[1]==="NOFILE"){m(),o=null,S=!0;continue}if(A[1]==="!DATA"){b(),m(),o=null,S=!1,a={name:M.slice(5).trim(),chunks:[]};continue}if(S)continue;if(a){if(A[1]==="!:")a.chunks.push(A.slice(2).join(""));continue}if(!o)d(t);let E={t:0,text:M};if(A[1]==="STEP")E.step=!0,c=[],p=null;else if(A[1]==="BFC")E.bfc=A.slice(2).join(" ");else if(A[1]==="ROTSTEP")if(E.meta="ROTSTEP",E.step=!0,c=[],p=null,(A[2]??"").toUpperCase()==="END")E.rotstep={x:0,y:0,z:0,mode:"END"};else{let C=(A[5]??"REL").toUpperCase();E.rotstep={x:+A[2]||0,y:+A[3]||0,z:+A[4]||0,mode:["REL","ABS","ADD"].includes(C)?C:"REL"}}else if(A[1]==="BUFEXCHG"){E.meta="BUFEXCHG";let C=(A[2]??"").toUpperCase();E.bufexchg={op:C==="RETRIEVE"?"RETRIEVE":"STORE",buf:A[3]??"A"}}else if(A[1]?.startsWith("!"))E.meta=A[1];if(h&&!o.org){let C=He(M);if(C)o.org=C}if(A[1]==="!TEXMAP"){let C=(A[2]??"").toUpperCase();if(p=null,C==="START"||C==="NEXT"){let U=Rt(M.replace(/^!TEXMAP\\s+\\S+/i,""),C==="NEXT");if(E.texmap={op:C,...U?{map:U}:{}},U)if((o.texmaps??=[]).push(U),C==="START")c.push({map:U,fallback:!1});else p=U}else if(C==="FALLBACK"){E.texmap={op:C};let U=c[c.length-1];if(U)U.fallback=!0}else if(C==="END")E.texmap={op:C},c.pop()}else if(A[1]==="!:"){p=null;let C=Ge(A.slice(2));if(C)P(C,!0),E.geom=C}else p=null;let D=M.match(Ve);if(D&&!o.movedTo){let C=D[1].trim().replace(/\\\\/g,"/");if(!/\\.(dat|ldr|mpd)$/i.test(C))C+=".dat";o.movedTo=J(C)}o.cmds.push(E);continue}if(a||S)continue;if(!o)d(t);let y=Ge(A);if(!y)continue;P(y,!1),o.cmds.push(y),h=!1}return m(),l?{main:i,files:s,data:l}:{main:i,files:s}}var tn=Math.PI/180;function qe(e,t){let n=(r)=>[t[3]*r[0]+t[4]*r[1]+t[5]*r[2]+t[0],t[6]*r[0]+t[7]*r[1]+t[8]*r[2]+t[1],t[9]*r[0]+t[10]*r[1]+t[11]*r[2]+t[2]];return{...e,p1:n(e.p1),p2:n(e.p2),p3:n(e.p3)}}function Qe(e,t){let[n,r,s,o,i,l,a,c,p,m,h,d]=e,[S,u,b,P,g,f,A,O,y,M,E,D]=t;return[o*S+i*u+l*b+n,a*S+c*u+p*b+r,m*S+h*u+d*b+s,o*P+i*A+l*M,o*g+i*O+l*E,o*f+i*y+l*D,a*P+c*A+p*M,a*g+c*O+p*E,a*f+c*y+p*D,m*P+h*A+d*M,m*g+h*O+d*E,m*f+h*y+d*D]}var Te=[0,0,0,1,0,0,0,1,0,0,0,1];var Ke=new WeakMap,Ot=/^(s|8|48)\\//;function Le(e,t){let n=e.files.get(J(t));if(!n)return"part";let r=Ke.get(n);if(r)return r;if(n.org)r=Je.has(n.org)?"part":"model";else if(n.name===e.main)r="model";else r=n.cmds.some((s)=>s.t>=2||s.t===0&&!!s.geom||s.t===1&&Ot.test(s.file))?"part":"model";return Ke.set(n,r),r}var Xe=new WeakMap;function et(e){let t=Xe.get(e);if(t)return t;t=[];let n=0;for(let r of e.cmds){if(r.t===0&&r.step){n++;continue}if((r.t>=2||r.t===0&&r.geom&&r.geom.t>=2)&&t[t.length-1]!==n)t.push(n)}return Xe.set(e,t),t}var We=(e)=>e>16777215?"0x"+e.toString(16).toUpperCase():String(e),zt=(e)=>e.t===0?"0 "+e.text:e.t===1?`1 ${We(e.color)} ${e.m.join(" ")} ${e.file}`:e.src?e.src:`${e.t} ${We(e.color)} ${e.p.join(" ")}`,Ie=(e,t)=>`${J(e)}#${t}`;function Nt(e,t){let n=[],r=0,s=(o)=>!!o&&o.t===0&&o.texmap?.op==="NEXT";for(let o of e.cmds){if(o.t===0){if(o.step){r++;continue}if(o.bfc!==void 0){n.push(o);continue}if(r!==t)continue;if(o.texmap)n.push(o);else if(o.geom){if(o.geom.t>=2)n.push(o);else if(s(n[n.length-1]))n.pop()}continue}if(r!==t)continue;if(o.t===1){if(s(n[n.length-1]))n.pop();continue}n.push(o)}return{name:Ie(e.name,t),cmds:n}}function tt(e,t){return[`0 ldr: own geometry of ${e.name}, step ${t}`,...Nt(e,t).cmds.map(zt)].join(`\n`)+`\n`}function Bt(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function nt(e){let[t,n,r,s,o,i,l,a,c,p,m,h]=e,d=a*h-c*m,S=-(l*h-c*p),u=l*m-a*p,b=s*d+o*S+i*u;if(!Number.isFinite(b)||Math.abs(b)<0.000000000001)return null;let P=1/b,g=[d*P,-(o*h-i*m)*P,(o*c-i*a)*P,S*P,(s*h-i*p)*P,-(s*c-i*l)*P,u*P,-(s*m-o*p)*P,(s*a-o*l)*P];return[-(g[0]*t+g[1]*n+g[2]*r),-(g[3]*t+g[4]*n+g[5]*r),-(g[6]*t+g[7]*n+g[8]*r),...g]}var $t=(e)=>String(+e.toFixed(6)||0),_e=(e)=>\'"\'+e.replace(/\\\\/g,"\\\\\\\\").replace(/"/g,"\\\\\\"")+\'"\';function rt(e,t){let n=[...t.p1,...t.p2,...t.p3,...t.method!=="PLANAR"?[t.a??360]:[],...t.method==="SPHERICAL"?[t.b??180]:[]].map($t).join(" "),r=`0 ldr: ${e} with a model-level !TEXMAP\n0 BFC CERTIFY CCW\n0 !TEXMAP START ${t.method} ${n} ${_e(t.texture)}${t.glossmap?" GLOSSMAP "+_e(t.glossmap):""}\n1 16 0 0 0 1 0 0 0 1 0 0 0 1 ${J(e)}\n0 !TEXMAP END\n`;return{name:`${J(e)}#tex-${Bt(r)}`,source:r}}var jt=(e,t)=>{let n=[,,,,,,,,,];for(let r=0;r<3;r++)for(let s=0;s<3;s++)n[r*3+s]=e[r*3]*t[s]+e[r*3+1]*t[3+s]+e[r*3+2]*t[6+s];return n};function Vt(e,t,n){let r=Math.PI/180,s=Math.sin(e*r),o=Math.cos(e*r),i=Math.sin(t*r),l=Math.cos(t*r),a=Math.sin(n*r),c=Math.cos(n*r);return[l*c,-l*a,i,o*a+s*i*c,o*c-s*i*a,-s*l,s*a-o*i*c,s*c+o*i*a,o*l]}var Ye=new WeakMap;function st(e){let t=Ye.get(e);if(t)return t;let n=[],r=null;for(let s of e.cmds){if(s.t!==0||!s.step)continue;let o=s.rotstep;if(o)if(o.mode==="END")r=null;else{let i=Vt(o.x,o.y,o.z);r=o.mode==="ABS"?{abs:!0,m:i,rotstep:o}:o.mode==="ADD"&&r?{abs:r.abs,m:jt(r.m,i),rotstep:o}:{abs:!1,m:i,rotstep:o}}n.push(r)}return n.push(r),Ye.set(e,n),n}var ot=999999,it=(e)=>e.map((t)=>String(t).padStart(6,"0")).join(".")+"~";function Ht(e,t={}){let n=[],r=t.maxDepth??64,s=t.looseGeometry!==!1,o=!!t.textures,i=!!t.callouts,l=new Map,a=0,c=(m,h)=>{let d=m.name+"#"+h,S=l.get(d);if(!S){let u;S=Object.assign(()=>u??=tt(m,h),{file:m,step:h}),l.set(d,S)}return S},p=(m,h,d,S,u,b,P,g,f=null,A=[],O=[])=>{let y=m.files.get(h);if(!y||P>r)return;let M=0,E=P>0?++a:0,D=i&&E?[...A,E]:A,C=i&&E?[...O,d]:O,U=i&&!f?new Map:null,_=-1,H=0,v=(T,x,N,F,R,z)=>{if(_!==M)_=M,H=0;let j=U?.get(M+"|"+x);if(j)return j.n++,p(T,T===m?x:T.main,N,F,u+"/"+x,[...R,ot],P+1,z,[...R,ot],D,C);let k=[...R,H++],G=n.length;p(T,T===m?x:T.main,N,F,u+"/"+x,k,P+1,z,f,D,C),U?.set(M+"|"+x,{n:1,from:G,to:n.length})},w=st(y),L=s?et(y):[],V=0,I=(T,x,N,F,R,z,j)=>{if(f)F=f;let k={part:T,color:x,m:N,step:F[0],steps:F,localStep:R,path:u};if(E){if(k.sub=E,i)k.subPath=D,k.subMats=C}if(z)k.embedded=!0;if(j){let K=rt(T,j);k.texPart=K.name,k.texSource=K.source}let G=w[R];if(G)k.view=G;return n.push(k),k},B=(T)=>{while(V<L.length&&L[V]<=T){let x=L[V++];I(Ie(y.name,x),S,d,[...b,x],x,!1,null).source=c(y,x)}};for(let T of y.cmds){if(T.t===0&&T.step){M++;continue}let x=T;if(x.t>=2||x.t===0&&x.geom&&x.geom.t>=2){B(M);continue}if(x.t===0)if(o&&x.geom?.t===1)x=x.geom;else continue;if(x.t!==1)continue;if(o&&x.fallback)continue;let N=x.color===16?S:x.color,F=Qe(d,x.m),R=[...b,M],z=o?x.tex??g:null,j=z?nt(x.m):null,k=z&&j?qe(z,j):null;if(m.files.has(x.file)){if(Le(m,x.file)==="model"){v(m,x.file,F,N,R,k);continue}I(x.file,N,F,R,M,!0,k);continue}let G=t.resolveModel?.(x.file);if(G){v(G,x.file,F,N,R,k);continue}I(x.file,N,F,R,M,!1,k)}if(B(1/0),U){for(let T of U.values())if(T.n>1)for(let x=T.from;x<T.to;x++)n[x].mult??=T.n}};if(Le(e,e.main)==="part"){if(e.files.get(e.main))n.push({part:e.main,color:16,m:[...Te],step:0,steps:[0],localStep:0,path:e.main,embedded:!0});return n}return p(e,e.main,Te,16,e.main,[],0,null),n}function at(e,t="main.ldr",n){return Ht(Ze(e,t,{geometryText:!0}),n)}function Gt(e,t){let n=new Map,r=null,s=!1;for(let o of e.split(/\\r?\\n/)){let i=/^\\s*0\\s+FILE\\s+(.+)$/i.exec(o);if(i){if(!s)n.clear();s=!0,r=[],n.set(J(i[1]),r);continue}if(/^\\s*0\\s+(NOFILE|!DATA)(\\s|$)/i.test(o)){if(!s)n.clear();s=!0,r=null;continue}if(!r){if(s)continue;r=[],n.set(J(t),r)}let l=o.trim().replace(/\\s+/g," ");if(l)r.push(l)}return n}var Kt=(e)=>{if(!e.startsWith("1 "))return null;let t=e.split(" ");return t.length>=15?J(t.slice(14).join(" ")):null};function Xt(e){let t=2166136261,n=1523705862;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);t=Math.imul(t^s,16777619),n=Math.imul(n^s,16777629)^n>>>15}return(t>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")}function lt(e,t,n="main.ldr"){let r=Gt(e,n),s=new Map;for(let o of t){let i=J(o);if(!r.has(i)||s.has(i))continue;let l=new Set([i]),a=[i];while(a.length)for(let p of r.get(a.pop())){let m=Kt(p);if(m&&r.has(m)&&!l.has(m))l.add(m),a.push(m)}let c=[i,...[...l].filter((p)=>p!==i).sort()].map((p)=>"0 FILE "+(p===i?"":p)+`\n`+r.get(p).join(`\n`)).join(`\n`);s.set(i,`emb/${Xt(c)}.dat`)}return s}var ct=(e,t=0)=>Math.abs(e[t+7]-1)<0.001&&Math.abs(e[t+4])<0.001&&Math.abs(e[t+10])<0.001,ut=new WeakMap;function ke(e,t){let n=ut.get(e);if(!n)ut.set(e,n=new Map);let r=n.get(t);if(r!==void 0)return r;let s=e.parts[t];if(!s)return n.set(t,null),null;let o=s.studs.length,i=new Float64Array(o*12),l=[],a=[];s.studs.forEach((h,d)=>{l.push(h[0]),a.push(h[1]);for(let S=0;S<12;S++)i[d*12+S]=h[2+S]});let c=null,p=0,m=0;if(s.mask){p=s.mask[0],m=s.mask[1];let h=s.mask[2];c=new Uint8Array(h.length);for(let d=0;d<h.length;d++)c[d]=h.charCodeAt(d)===49?1:0}return n.set(t,r={nStuds:o,studM:i,kind:l,color:a,mask:c,nx:p,nz:m}),r}var ie=1073741824;class Fe{a;b;c;vals;used;mask;size=0;constructor(e=1024){let t=1024;while(t<e*2)t*=2;this.a=new Int32Array(t),this.b=new Int32Array(t),this.c=new Int32Array(t),this.vals=new Int32Array(t),this.used=new Uint8Array(t),this.mask=t-1}slot(e,t,n){let r=Math.imul(e,2654435761)^Math.imul(t,2246822507)^Math.imul(n,3266489909);return r^=r>>>15,r=Math.imul(r,739982445),r^=r>>>12,r&this.mask}get(e,t,n){let r=this.slot(e,t,n),s=this.used,o=this.a,i=this.b,l=this.c;for(;;){if(!s[r])return-1;if(o[r]===e&&i[r]===t&&l[r]===n)return this.vals[r];r=r+1&this.mask}}put(e,t,n,r){if((this.size+1)*2>this.used.length)this.grow();let s=this.slot(e,t,n),o=this.used,i=this.a,l=this.b,a=this.c;for(;;){if(!o[s])return o[s]=1,i[s]=e,l[s]=t,a[s]=n,this.vals[s]=r,this.size++,-1;if(i[s]===e&&l[s]===t&&a[s]===n){let c=this.vals[s];return this.vals[s]=r,c}s=s+1&this.mask}}grow(){let{a:e,b:t,c:n,vals:r,used:s}=this,o=s.length*2;this.a=new Int32Array(o),this.b=new Int32Array(o),this.c=new Int32Array(o),this.vals=new Int32Array(o),this.used=new Uint8Array(o),this.mask=o-1,this.size=0;for(let i=0;i<s.length;i++)if(s[i])this.put(e[i],t[i],n[i],r[i])}}var ye=(e,t,n)=>e>-ie&&e<ie&&t>-ie&&t<ie&&n>-ie&&n<ie,fe=2147483647;function Wt(e,t,n){let s=[],o=[],i=[],l=[],a=[],c=[],p=[],m=[],h=new Fe(e.length*2),d=[],S=[];for(let v=0;v<e.length;v++){let w=e[v],L=w.m,V=t.parts[w.part];if(!V||!V.mask||!ct(L))continue;let I=V.bbox,B=1/0,T=-1/0,x=1/0,N=-1/0;for(let z=0;z<2;z++)for(let j=0;j<2;j++){let k=z?I[3]:I[0],G=j?I[5]:I[2],K=L[0]+L[3]*k+L[5]*G,Y=L[2]+L[9]*k+L[11]*G;if(K<B)B=K;if(K>T)T=K;if(Y<x)x=Y;if(Y>N)N=Y}let F=a.length;s.push(B),o.push(T),i.push(x),l.push(N),a.push(v),c.push(ke(t,w.part)),p.push(I[0]),m.push(I[2]);let R=Math.round((L[1]+I[4])*2);for(let z=Math.floor(B/40);z<=Math.floor(T/40);z++)for(let j=Math.floor(x/40);j<=Math.floor(N/40);j++){if(!ye(R,z,j))continue;let k=S.length;S.push(F),d.push(h.put(R,z,j,k))}}let u=[0,5,-5,5,-5],b=[0,5,5,-5,-5],P=NaN,g=NaN,f=NaN,A=-1,O=(v,w,L,V)=>{let I=Math.round(w*2),B=Math.floor(v/40),T=Math.floor(L/40);if(!ye(I,B,T))return fe;let x=fe;if(I!==P||B!==g||T!==f)P=I,g=B,f=T,A=h.get(I,B,T);for(let N=A;N>=0;N=d[N]){let F=S[N];if(a[F]===V||!(v-6>=s[F]-0.5&&v+6<=o[F]+0.5&&L-6>=i[F]-0.5&&L+6<=l[F]+0.5))continue;let R=e[a[F]].m,z=c[F],j=p[F],k=m[F],G=v-R[0],K=w-R[1],Y=L-R[2],q=R[3]*G+R[6]*K+R[9]*Y,Z=R[5]*G+R[8]*K+R[11]*Y,{nx:ee,nz:se,mask:ae}=z,oe=!0;for(let Q=0;Q<5;Q++){let te=Math.floor((q+u[Q]-j)/20),ne=Math.floor((Z+b[Q]-k)/20);if(te<0||ne<0||te>=ee||ne>=se||ae[te*se+ne]!==1){oe=!1;break}}if(oe){if(!n)return 0;let Q=n[a[F]];if(Q<x)x=Q}}return x},y=0;for(let v of e){let w=ke(t,v.part);if(w)y+=w.nStuds}let M=new Uint8Array(y),E=new Uint8Array(y),D=new Fe(y),C=0,U=n?new Int32Array(y).fill(fe):void 0;for(let v=0,w=0;v<e.length;v++){let L=e[v],V=ke(t,L.part);if(!V)continue;let I=L.m,B=V.studM,T=I[0],x=I[1],N=I[2],F=I[3],R=I[4],z=I[5],j=I[6],k=I[7],G=I[8],K=I[9],Y=I[10],q=I[11];for(let Z=0;Z<V.nStuds;Z++,w++){let ee=Z*12,se=B[ee+4],ae=B[ee+7],oe=B[ee+10];if(!(Math.abs(j*se+k*ae+G*oe-1)<0.001&&Math.abs(F*se+R*ae+z*oe)<0.001&&Math.abs(K*se+Y*ae+q*oe)<0.001))continue;E[w]=1;let Q=B[ee],te=B[ee+1],ne=B[ee+2],Re=T+F*Q+R*te+z*ne,De=x+j*Q+k*te+G*ne,Ue=N+K*Q+Y*te+q*ne,Oe=O(Re,De,Ue,v);if(Oe!==fe){if(M[w]=1,C++,U)U[w]=Oe}let pe=Math.round(Re),me=Math.round(De),he=Math.round(Ue);if(!ye(pe,me,he))continue;if(!n){D.put(pe,me,he,1);continue}let ze=n[v],Ne=D.get(pe,me,he);if(Ne<0||ze<Ne)D.put(pe,me,he,ze)}}let _=new Uint8Array(e.length),H=n?new Int32Array(e.length).fill(fe):void 0;for(let v=0;v<e.length;v++){let w=e[v],L=t.parts[w.part];if(!L||!L.under||!ct(w.m))continue;let V=L.bbox,I=Math.round((V[3]-V[0])/20),B=Math.round((V[5]-V[2])/20);if(!I||!B||I*B>4096)continue;let T=w.m,x=!0,N=0;for(let F=0;F<I&&x;F++)for(let R=0;R<B;R++){let z=V[0]+10+20*F,j=V[2]+10+20*R,k=T[0]+T[3]*z+T[5]*j,G=T[2]+T[9]*z+T[11]*j,K=Math.round(k),Y=Math.round(T[1]+V[4]),q=Math.round(G),Z=ye(K,Y,q)?D.get(K,Y,q):-1;if(Z<0){x=!1;break}if(Z>N)N=Z}if(x){if(_[v]=1,H)H[v]=N}}return{nStuds:y,studHidden:M,studUp:E,underHidden:_,studsHidden:C,studHideStep:U,underHideStep:H}}function _t(e,t,n){let r=(a)=>n&&a.texPart&&t.parts[a.texPart]?a.texPart:a.part,s=e.map((a)=>({part:r(a),color:String(a.color),m:a.m,steps:a.steps})),o=s.map((a)=>it(a.steps)),i=[...new Set(o)].sort(),l=new Map(i.map((a,c)=>[a,c]));return{all:s,stepOf:o.map((a)=>l.get(a)),nSteps:i.length}}function xe(e,t,n=!0){let r=_t(e,t,n);return Wt(r.all,t,r.nSteps>1?r.stepOf:void 0)}var Me="https://ldr-demo.vercel.app/cdn/v1/",Ae=new Map,we=new Map;function pt(e=Me,t=fetch){let n=Ae.get(e);if(!n)n=t(e+"parts.json").then((r)=>{if(!r.ok)throw Error(`ldr: parts CDN index ${r.status} (${e}parts.json)`);return r.json()}),n.catch(()=>Ae.delete(e)),Ae.set(e,n);return n}var Yt=(e)=>Array.isArray(e)&&e.length===3&&typeof e[0]==="number"&&typeof e[1]==="number"&&(e[2]==="f32"||e[2]==="u16"||e[2]==="u8"||e[2]==="u32"),ve=(e,t)=>Yt(e)?[e[0]+t,e[1],e[2]]:Array.isArray(e)?e.map((n)=>ve(n,t)):e&&typeof e==="object"?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,ve(r,t)])):e;function Jt(e,t={}){let n=[],r=0,s={},o={};for(let h of e){let d=h.buffer;if(!d)throw Error("ldr: mergePacks needs packs from decodePack/loadPack");let S=new DataView(d).getUint32(0,!0),u=new Uint8Array(d,4+S),b=r;n.push(u),r+=u.byteLength;let P=(4-r%4)%4;if(P)n.push(new Uint8Array(P)),r+=P;for(let[g,f]of Object.entries(h.header.parts??{}))if(!(g in s))s[g]=ve(f,b);for(let[g,f]of Object.entries(h.header.studKinds??{}))if(!(g in o))o[g]=ve(f,b)}let i=e[0]?.header??{version:1,weld:!0},l=new TextEncoder().encode(JSON.stringify({...i,parts:s,studKinds:o,...t})),a=(4-(4+l.length)%4)%4,c=4+l.length+a,p=new Uint8Array(c+r);new DataView(p.buffer).setUint32(0,l.length+a,!0),p.set(l,4),p.fill(32,4+l.length,c);let m=c;for(let h of n)p.set(h,m),m+=h.byteLength;return de(p.buffer)}async function Zt(e,t={}){e=[...e];try{return await ft(e,t)}catch(n){let r=t.cdn??Me,s=t.fetch??fetch;Ae.delete(r);let o=(i,l)=>s(i,{...l,cache:"reload"});try{return await ft(e,{...t,fetch:o})}catch{throw n}}}async function ft(e,t){let n=t.cdn??Me,r=t.fetch??fetch,s=t.gap??16384,o=await pt(n,r),i=[...new Set([...e].map(J))],l=[],a=[];for(let u of i){if(we.has(n+u))continue;let b=o.parts[u];if(b)a.push({name:u,off:b[0],len:b[1],file:b[2]??0});else l.push(u)}a.sort((u,b)=>u.file-b.file||u.off-b.off);let c=[];for(let u of a){let b=c[c.length-1];if(b&&b.file===u.file&&u.off-b.end<=s)b.end=Math.max(b.end,u.off+u.len),b.items.push(u);else c.push({file:u.file,start:u.off,end:u.off+u.len,items:[u]})}let p=0,m=0,h=async()=>{while(m<c.length){let u=c[m++],b=await r(new URL(o.archives[u.file],n).href,{headers:{Range:`bytes=${u.start}-${u.end-1}`}});if(!b.ok)throw Error(`ldr: parts CDN ${b.status}`);let P=new Uint8Array(await b.arrayBuffer());if(b.status===200)P=P.subarray(u.start,u.end);p+=P.byteLength;for(let g of u.items){let f=je(P.subarray(g.off-u.start,g.off-u.start+g.len)),A=f.buffer.slice(f.byteOffset,f.byteOffset+f.byteLength);we.set(n+g.name,de(A))}}};await Promise.all(Array.from({length:Math.min(t.concurrency??24,c.length)},h));let d=i.filter((u)=>we.has(n+u)).map((u)=>we.get(n+u));return{pack:d.length?Jt(d,{colors:o.colors}):de(qt(o.colors)),missing:l,requests:c.length,bytes:p}}function qt(e){let t=new TextEncoder().encode(JSON.stringify({version:1,weld:!0,parts:{},studKinds:{},colors:e})),n=(4-(4+t.length)%4)%4,r=new Uint8Array(4+t.length+n).fill(32);return new DataView(r.buffer).setUint32(0,t.length+n,!0),r.set(t,4),r.buffer}async function mt(e,t={}){let n=performance.now(),r=t.fetch??fetch,s=pt(t.cdn??Me,r);s.catch(()=>{});let o=t.text?e:await r(e).then((f)=>{if(!f.ok)throw Error(`ldr: ${f.status} fetching ${e}`);return f.text()}),i=performance.now(),l=t.name??(t.text?"main.ldr":decodeURIComponent(e.split(/[?#]/)[0].split("/").pop()||"main.ldr")),a=at(o,l,{looseGeometry:!1,callouts:t.callouts}),c=performance.now();t.onParsed?.(a),await s;let p=lt(o,new Set(a.filter((f)=>f.embedded).map((f)=>f.part)),l),{pack:m,missing:h,requests:d,bytes:S}=await Zt([...a.filter((f)=>!f.embedded).map((f)=>f.part),...p.values()],t),u=new Map([...p].map(([f,A])=>[A,f])),b=h.map((f)=>u.get(f)??f);for(let[f,A]of p){let O=m.header.parts[A];if(O)m.header.parts[f]=O}let P=performance.now(),g=t.cull?xe(a,m.header,t.textures!==!1):void 0;return{insts:a,pack:m,missing:b,requests:d,bytes:S,cull:g,timings:{fetchModel:i-n,parse:c-i,parts:P-c,...g?{cull:performance.now()-P}:{}}}}self.onmessage=async(e)=>{let{id:t,source:n,opts:r}=e.data;try{let s=await mt(n,{...r,cull:!1,onParsed:(p)=>self.postMessage({id:t,insts:p})}),o=s.pack.buffer;if(self.postMessage({id:t,buffer:o,missing:s.missing,requests:s.requests,bytes:s.bytes,timings:s.timings},[o]),!r.cull)return;let i=performance.now(),l=xe(s.insts,s.pack.header,r.textures!==!1),a=performance.now()-i,c=[];for(let p of[l.studHidden,l.studUp,l.underHidden,l.studHideStep,l.underHideStep])if(p)c.push(p.buffer);self.postMessage({id:t,cull:l,ms:a},c)}catch(s){self.postMessage({id:t,phase:"error",error:String(s?.message??s)})}};\n';
|
|
2492
2998
|
|
|
2493
|
-
// ../../../../../../../tmp/ldr-build-
|
|
2999
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/cdn.ts
|
|
2494
3000
|
var worker;
|
|
2495
3001
|
var seq = 0;
|
|
2496
3002
|
var pending = new Map;
|
|
@@ -2544,7 +3050,7 @@ var abs = (u) => {
|
|
|
2544
3050
|
};
|
|
2545
3051
|
function prepareInWorker(w, source, o) {
|
|
2546
3052
|
const id = ++seq;
|
|
2547
|
-
const opts = { cdn: abs(o.cdn ?? DEFAULT_PARTS_CDN), gap: o.gap, concurrency: o.concurrency, text: o.text, name: o.name, cull: true, textures: o.textures };
|
|
3053
|
+
const opts = { cdn: abs(o.cdn ?? DEFAULT_PARTS_CDN), gap: o.gap, concurrency: o.concurrency, text: o.text, name: o.name, cull: true, textures: o.textures, callouts: o.callouts };
|
|
2548
3054
|
const name = o.name ?? (o.text ? undefined : decodeURIComponent(source.split(/[?#]/)[0].split("/").pop() || "main.ldr"));
|
|
2549
3055
|
let insts;
|
|
2550
3056
|
pendingInsts.set(id, (v) => {
|
|
@@ -2599,11 +3105,18 @@ async function loadModel(source, o = {}) {
|
|
|
2599
3105
|
timings: { ...prep.timings, parts: t3 - t0 - prep.timings.fetchModel - prep.timings.parse, build: t4 - t3, total: t4 - t0 }
|
|
2600
3106
|
});
|
|
2601
3107
|
}
|
|
2602
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3108
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/node/library.ts
|
|
2603
3109
|
import { existsSync, readFileSync } from "fs";
|
|
2604
3110
|
import { join } from "path";
|
|
2605
3111
|
var xf = (m, x, y, z) => [m[3] * x + m[4] * y + m[5] * z + m[0], m[6] * x + m[7] * y + m[8] * z + m[1], m[9] * x + m[10] * y + m[11] * z + m[2]];
|
|
2606
3112
|
var det = (m) => m[3] * (m[7] * m[11] - m[8] * m[10]) - m[4] * (m[6] * m[11] - m[8] * m[9]) + m[5] * (m[6] * m[10] - m[7] * m[9]);
|
|
3113
|
+
var IDENTITY12 = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1];
|
|
3114
|
+
function isPlainAlias(f, target) {
|
|
3115
|
+
if (STUB_OVERRIDES[norm(f.name)] === target)
|
|
3116
|
+
return true;
|
|
3117
|
+
const refs = f.cmds.filter((c) => c.t === 1);
|
|
3118
|
+
return refs.length <= 1 && refs.every((c) => norm(c.file) === target && c.m.every((v, k) => Math.abs(v - IDENTITY12[k]) < 0.000001));
|
|
3119
|
+
}
|
|
2607
3120
|
|
|
2608
3121
|
class Library {
|
|
2609
3122
|
root;
|
|
@@ -2637,7 +3150,7 @@ class Library {
|
|
|
2637
3150
|
if (!hit)
|
|
2638
3151
|
return null;
|
|
2639
3152
|
const file = hit.doc.files.get(hit.doc.main);
|
|
2640
|
-
if (file?.movedTo && file.movedTo !== name) {
|
|
3153
|
+
if (file?.movedTo && file.movedTo !== name && isPlainAlias(file, file.movedTo)) {
|
|
2641
3154
|
const target = this.where(file.movedTo, seen);
|
|
2642
3155
|
if (target)
|
|
2643
3156
|
return { ...target, aliasOf: name };
|
|
@@ -2851,11 +3364,11 @@ class Library {
|
|
|
2851
3364
|
return insts;
|
|
2852
3365
|
}
|
|
2853
3366
|
}
|
|
2854
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3367
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/node/build-pack.ts
|
|
2855
3368
|
import fs3 from "node:fs";
|
|
2856
3369
|
import path3 from "node:path";
|
|
2857
3370
|
|
|
2858
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3371
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/node/resolver.ts
|
|
2859
3372
|
import fs from "node:fs";
|
|
2860
3373
|
import path from "node:path";
|
|
2861
3374
|
var TOP_STUD_RE = /^(stud|studa|stud2|stud2a|stud6|stud6a|stud10|stud15|stud2s|stud2s2|stud-logo\d*|stud2-logo\d*)\.dat$/i;
|
|
@@ -2927,7 +3440,7 @@ class Library2 {
|
|
|
2927
3440
|
return key;
|
|
2928
3441
|
}
|
|
2929
3442
|
resolve(ref) {
|
|
2930
|
-
const
|
|
3443
|
+
const n0 = norm2(ref), n = STUB_OVERRIDES[n0] ?? n0;
|
|
2931
3444
|
if (this.virtual.size && this.virtual.has(n))
|
|
2932
3445
|
return "mpd/" + n;
|
|
2933
3446
|
for (const pre of ["parts/", "p/", "models/"])
|
|
@@ -3127,11 +3640,11 @@ function collectDeps(lib, refs) {
|
|
|
3127
3640
|
return out;
|
|
3128
3641
|
}
|
|
3129
3642
|
|
|
3130
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3643
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/node/compile.ts
|
|
3131
3644
|
import fs2 from "node:fs";
|
|
3132
3645
|
import path2 from "node:path";
|
|
3133
3646
|
|
|
3134
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3647
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/node/lod.ts
|
|
3135
3648
|
import { MeshoptSimplifier, MeshoptEncoder } from "meshoptimizer";
|
|
3136
3649
|
await Promise.all([MeshoptSimplifier.ready, MeshoptEncoder.ready]);
|
|
3137
3650
|
function reorderMesh(P, N, C, I) {
|
|
@@ -3323,7 +3836,7 @@ function lodChain(P, C, I) {
|
|
|
3323
3836
|
return out;
|
|
3324
3837
|
}
|
|
3325
3838
|
|
|
3326
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3839
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/node/compile.ts
|
|
3327
3840
|
function loadColors(root) {
|
|
3328
3841
|
const map = new Map;
|
|
3329
3842
|
for (const l of fs2.readFileSync(path2.join(root, "LDConfig.ldr"), "latin1").split(/\r?\n/)) {
|
|
@@ -3906,7 +4419,7 @@ function encodePack(parts, studKinds, weld, extra, options = {}) {
|
|
|
3906
4419
|
return Buffer.concat([head, ...chunks.map((c) => new Uint8Array(c.buffer, c.byteOffset, c.byteLength))]);
|
|
3907
4420
|
}
|
|
3908
4421
|
|
|
3909
|
-
// ../../../../../../../tmp/ldr-build-
|
|
4422
|
+
// ../../../../../../../tmp/ldr-build-eZnTdy/src/node/build-pack.ts
|
|
3910
4423
|
function buildPack(o) {
|
|
3911
4424
|
const lib = new Library2(o.ldrawRoot);
|
|
3912
4425
|
const refs = new Map;
|
|
@@ -3969,10 +4482,13 @@ function buildPack(o) {
|
|
|
3969
4482
|
return { data: encodePack(parts, kinds, comp.opts.weld, extra, { texture, lod: o.lod !== false, reorder: !!o.reorder }), parts: parts.size, studKinds: kinds.size, missing: [...missing], ...warnings.length ? { warnings } : {} };
|
|
3970
4483
|
}
|
|
3971
4484
|
export {
|
|
4485
|
+
CALLOUT_END,
|
|
3972
4486
|
Compiler,
|
|
3973
4487
|
DEFAULT_PARTS_CDN,
|
|
3974
4488
|
I as IDENTITY,
|
|
3975
4489
|
Library,
|
|
4490
|
+
MIN_VIS,
|
|
4491
|
+
REORIENT,
|
|
3976
4492
|
Library2 as ResolverLibrary,
|
|
3977
4493
|
buildLdrScene,
|
|
3978
4494
|
buildPack,
|
|
@@ -3987,6 +4503,7 @@ export {
|
|
|
3987
4503
|
cullCore,
|
|
3988
4504
|
decodePack,
|
|
3989
4505
|
decompressPack,
|
|
4506
|
+
embeddedKeys,
|
|
3990
4507
|
encodePack,
|
|
3991
4508
|
fileKind,
|
|
3992
4509
|
fileStepViews,
|
|
@@ -3994,8 +4511,10 @@ export {
|
|
|
3994
4511
|
flatten2 as flattenWithLibrary,
|
|
3995
4512
|
forEachStud,
|
|
3996
4513
|
hash32,
|
|
4514
|
+
instanceBoxes,
|
|
3997
4515
|
invert,
|
|
3998
4516
|
isDirectColor,
|
|
4517
|
+
isolateMask,
|
|
3999
4518
|
loadColors,
|
|
4000
4519
|
loadModel,
|
|
4001
4520
|
loadPack,
|
|
@@ -4014,6 +4533,7 @@ export {
|
|
|
4014
4533
|
parseLDConfig,
|
|
4015
4534
|
parseModel,
|
|
4016
4535
|
parseTexMap,
|
|
4536
|
+
planStepViews,
|
|
4017
4537
|
precomputeCull,
|
|
4018
4538
|
prepareModel,
|
|
4019
4539
|
resolveTexture,
|
|
@@ -4022,11 +4542,13 @@ export {
|
|
|
4022
4542
|
sequenceSteps,
|
|
4023
4543
|
smoothNormals,
|
|
4024
4544
|
splitModel,
|
|
4545
|
+
stepKey,
|
|
4025
4546
|
stepViewMatrix,
|
|
4026
4547
|
texWrapper,
|
|
4027
4548
|
texmapTriangleUV,
|
|
4028
4549
|
texmapUV,
|
|
4029
4550
|
transformTexMap,
|
|
4551
|
+
viewDir,
|
|
4030
4552
|
warmPackGeometry,
|
|
4031
4553
|
writePack
|
|
4032
4554
|
};
|