ldr 0.25.0 → 0.26.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 +2 -1
- package/dist/cli.js +33 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +38 -18
- package/dist/load-worker.gen.d.ts +1 -1
- package/dist/node/index.js +46 -26
- package/dist/spec.d.ts +14 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -93,7 +93,7 @@ Light the scene (or set `scene.environment`) as you would for any `MeshStandardM
|
|
|
93
93
|
| `looseSteps` / `looseFile` / `looseSource` / `loosePartName` | A model's own type 2–5 geometry, per step, as synthetic parts named `<file>#<step>`. |
|
|
94
94
|
| `rotStepMatrix` / `stepViewMatrix` / `fileStepViews` | ROTSTEP views, following MLCad: `REL`, `ADD`, `ABS`, `END`. A ROTSTEP ends its step. |
|
|
95
95
|
| `parseTexMap` / `texmapUV` / `texmapTriangleUV` / `transformTexMap` / `resolveTexture` / `texWrapper` | `!TEXMAP` support (`PLANAR`, `CYLINDRICAL`, `SPHERICAL`). UV conventions follow LDView: v = 0 is the image's top row. |
|
|
96
|
-
| `parseColor`, `isDirectColor`, `colorToken`, `mul`, `invert`, `IDENTITY`, `norm`, `smoothNormals`, `hash32` | Low-level helpers. |
|
|
96
|
+
| `parseColor`, `isDirectColor`, `namedColorCode`, `isNamedColor`, `colorToken`, `mul`, `invert`, `IDENTITY`, `norm`, `smoothNormals`, `hash32` | Low-level helpers. |
|
|
97
97
|
|
|
98
98
|
`FlattenOptions`:
|
|
99
99
|
|
|
@@ -211,6 +211,7 @@ Reproduce: `cd bench && bun run setup && bun run perf` (regression gate) or `bun
|
|
|
211
211
|
- `!TEXMAP` `START`/`NEXT`/`FALLBACK`/`END`, with `PLANAR`, `CYLINDRICAL` and `SPHERICAL` projections (orientation matches LDView), `GLOSSMAP` (alpha = gloss amount, same UVs), and model-level `!TEXMAP` around part references.
|
|
212
212
|
- Colours: LDConfig `!COLOUR`, edge colours, main/edge colour inheritance (16/24), and direct colours (`0x2RRGGBB`).
|
|
213
213
|
- `!COLOUR` lines in a model follow the spec's scope rule. A definition applies from its line to the end of its file and to the files that file references, and it never leaks back to the parent. It sets the instance colour and finish. Colours hard-coded inside parts (printed parts, MPD-embedded parts) always come from LDConfig, because parts are precompiled.
|
|
214
|
+
- Named colour codes: a `!COLOUR` CODE may be an identifier instead of a number (`0 !COLOUR My_Red CODE MyRed VALUE #FF0000 EDGE #333333`, then `1 myred ...`), which the spec allows outside strict LDraw compatibility. Identifiers are case-insensitive and follow the same scope rule. `parseColor` turns one into a stable negative code (`namedColorCode`, `isNamedColor`), and `colorToken` turns it back into the identifier. A named code with no definition in scope draws the fallback colour.
|
|
214
215
|
- Blended colour codes 256-511 that LDConfig doesn't define (used by old models, e.g. 382 in Datsville) render as the spec's average of two ldraw.exe colours instead of the fallback grey.
|
|
215
216
|
- Case-insensitive, backslash-normalized file lookup; `~Moved to` alias parts.
|
|
216
217
|
|
package/dist/cli.js
CHANGED
|
@@ -1,20 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/cli.ts
|
|
4
4
|
import fs4 from "node:fs";
|
|
5
5
|
import zlib from "node:zlib";
|
|
6
6
|
|
|
7
|
-
// ../../../../../../../tmp/ldr-build-
|
|
7
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/build-pack.ts
|
|
8
8
|
import fs3 from "node:fs";
|
|
9
9
|
import path3 from "node:path";
|
|
10
10
|
|
|
11
|
-
// ../../../../../../../tmp/ldr-build-
|
|
11
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/resolver.ts
|
|
12
12
|
import fs from "node:fs";
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
|
|
15
|
-
// ../../../../../../../tmp/ldr-build-
|
|
15
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/spec.ts
|
|
16
16
|
var norm = (s) => s.trim().toLowerCase().replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
17
|
+
var COLOUR_ID_RE = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
18
|
+
var namedCodes = new Map;
|
|
19
|
+
function namedColorCode(id) {
|
|
20
|
+
const s = id.toLowerCase();
|
|
21
|
+
let h = 2166136261;
|
|
22
|
+
for (let i = 0;i < s.length; i++) {
|
|
23
|
+
h ^= s.charCodeAt(i);
|
|
24
|
+
h = Math.imul(h, 16777619);
|
|
25
|
+
}
|
|
26
|
+
const c = -1 - (h >>> 0 & 1073741823);
|
|
27
|
+
if (!namedCodes.has(c))
|
|
28
|
+
namedCodes.set(c, s);
|
|
29
|
+
return c;
|
|
30
|
+
}
|
|
31
|
+
var isNamedColor = (c) => c < 0 && Number.isInteger(c);
|
|
17
32
|
function parseColor(tok) {
|
|
33
|
+
const c0 = tok.charCodeAt(0) | 32;
|
|
34
|
+
if (c0 >= 97 && c0 <= 122 && COLOUR_ID_RE.test(tok))
|
|
35
|
+
return namedColorCode(tok);
|
|
18
36
|
if (/^0x/i.test(tok))
|
|
19
37
|
return parseInt(tok, 16);
|
|
20
38
|
return +tok;
|
|
@@ -590,7 +608,7 @@ function looseSteps(f) {
|
|
|
590
608
|
looseMemo.set(f, r);
|
|
591
609
|
return r;
|
|
592
610
|
}
|
|
593
|
-
var colorToken = (c) => c > 16777215 ? "0x" + c.toString(16).toUpperCase() : String(c);
|
|
611
|
+
var colorToken = (c) => c > 16777215 ? "0x" + c.toString(16).toUpperCase() : c < 0 ? namedCodes.get(c) ?? String(c) : String(c);
|
|
594
612
|
var lineOf = (c) => c.t === 0 ? "0 " + c.text : c.t === 1 ? `1 ${colorToken(c.color)} ${c.m.join(" ")} ${c.file}` : c.src ? c.src : `${c.t} ${colorToken(c.color)} ${c.p.join(" ")}`;
|
|
595
613
|
var loosePartName = (file, step) => `${norm(file)}#${step}`;
|
|
596
614
|
function looseFile(f, step) {
|
|
@@ -705,7 +723,7 @@ function fileStepViews(f) {
|
|
|
705
723
|
return out;
|
|
706
724
|
}
|
|
707
725
|
|
|
708
|
-
// ../../../../../../../tmp/ldr-build-
|
|
726
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/model.ts
|
|
709
727
|
var CALLOUT_END = 999999;
|
|
710
728
|
var stepKey = (steps) => steps.map((x) => String(x).padStart(6, "0")).join(".") + "~";
|
|
711
729
|
function flatten(doc, opts = {}) {
|
|
@@ -917,14 +935,14 @@ function parseColourLine(line) {
|
|
|
917
935
|
if (tokens.length < 2)
|
|
918
936
|
return null;
|
|
919
937
|
const name = tokens[0];
|
|
920
|
-
let code =
|
|
938
|
+
let code = NaN, hex = "#FF00FF", edge = "#333333", alpha = 255, luminance = 0;
|
|
921
939
|
let finish = { type: "default" };
|
|
922
940
|
let i = 1;
|
|
923
941
|
while (i < tokens.length) {
|
|
924
942
|
const t = tokens[i].toUpperCase();
|
|
925
943
|
const n = tokens[i + 1];
|
|
926
944
|
if (t === "CODE") {
|
|
927
|
-
code = +n;
|
|
945
|
+
code = n !== undefined && COLOUR_ID_RE.test(n) ? namedColorCode(n) : n !== undefined && /^\d+$/.test(n) ? +n : NaN;
|
|
928
946
|
i += 2;
|
|
929
947
|
} else if (t === "VALUE") {
|
|
930
948
|
const h = parseHexColor(n);
|
|
@@ -979,7 +997,7 @@ function parseColourLine(line) {
|
|
|
979
997
|
} else
|
|
980
998
|
i += 1;
|
|
981
999
|
}
|
|
982
|
-
if (code
|
|
1000
|
+
if (Number.isNaN(code) || !hex)
|
|
983
1001
|
return null;
|
|
984
1002
|
return { code, name, hex, edge, alpha: Number.isFinite(alpha) ? alpha : 255, luminance: Number.isFinite(luminance) ? luminance : 0, finish };
|
|
985
1003
|
}
|
|
@@ -1088,7 +1106,7 @@ function blendedColourHex(code) {
|
|
|
1088
1106
|
return "#" + [0, 1, 2].map((k) => (a[k] + b[k] >> 1).toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
1089
1107
|
}
|
|
1090
1108
|
|
|
1091
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1109
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/resolver.ts
|
|
1092
1110
|
var TOP_STUD_RE = /^(stud|studa|stud2|stud2a|stud6|stud6a|stud10|stud15|stud2s|stud2s2|stud-logo\d*|stud2-logo\d*)\.dat$/i;
|
|
1093
1111
|
var UNDER_STUD_RE = /^(stud3|stud3a|stud4.*|stud12|stud16.*|stud18a)\.dat$/i;
|
|
1094
1112
|
var norm2 = (ref) => ref.trim().replace(/\\/g, "/").toLowerCase();
|
|
@@ -1358,11 +1376,11 @@ function collectDeps(lib, refs) {
|
|
|
1358
1376
|
return out;
|
|
1359
1377
|
}
|
|
1360
1378
|
|
|
1361
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1379
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/compile.ts
|
|
1362
1380
|
import fs2 from "node:fs";
|
|
1363
1381
|
import path2 from "node:path";
|
|
1364
1382
|
|
|
1365
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1383
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/lod.ts
|
|
1366
1384
|
import { MeshoptSimplifier, MeshoptEncoder } from "meshoptimizer";
|
|
1367
1385
|
await Promise.all([MeshoptSimplifier.ready, MeshoptEncoder.ready]);
|
|
1368
1386
|
function reorderMesh(P, N, C, I) {
|
|
@@ -1554,7 +1572,7 @@ function lodChain(P, C, I) {
|
|
|
1554
1572
|
return out;
|
|
1555
1573
|
}
|
|
1556
1574
|
|
|
1557
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1575
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/compile.ts
|
|
1558
1576
|
function loadColors(root) {
|
|
1559
1577
|
const map = new Map;
|
|
1560
1578
|
for (const l of fs2.readFileSync(path2.join(root, "LDConfig.ldr"), "latin1").split(/\r?\n/)) {
|
|
@@ -2191,7 +2209,7 @@ function encodePack(parts, studKinds, weld, extra, options = {}) {
|
|
|
2191
2209
|
return Buffer.concat([head, ...chunks.map((c) => new Uint8Array(c.buffer, c.byteOffset, c.byteLength))]);
|
|
2192
2210
|
}
|
|
2193
2211
|
|
|
2194
|
-
// ../../../../../../../tmp/ldr-build-
|
|
2212
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/build-pack.ts
|
|
2195
2213
|
function buildPack(o) {
|
|
2196
2214
|
const lib = new Library(o.ldrawRoot);
|
|
2197
2215
|
const refs = new Map;
|
|
@@ -2259,7 +2277,7 @@ function buildPack(o) {
|
|
|
2259
2277
|
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 } : {} };
|
|
2260
2278
|
}
|
|
2261
2279
|
|
|
2262
|
-
// ../../../../../../../tmp/ldr-build-
|
|
2280
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/cli.ts
|
|
2263
2281
|
var HELP = `ldr pack — build a parts pack for the ldr three.js renderer
|
|
2264
2282
|
|
|
2265
2283
|
Usage:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { parse, parseColor, isDirectColor, mul, I as IDENTITY, norm, smoothNormals, parseTexMap, texmapUV, texmapTriangleUV, transformTexMap, resolveTexture, fileKind, looseSteps, looseSource, looseFile, loosePartName, texWrapper, invert, hash32, colorToken, rotStepMatrix, stepViewMatrix, fileStepViews } from "./spec.js";
|
|
1
|
+
export { parse, parseColor, isDirectColor, namedColorCode, isNamedColor, mul, I as IDENTITY, norm, smoothNormals, parseTexMap, texmapUV, texmapTriangleUV, transformTexMap, resolveTexture, fileKind, looseSteps, looseSource, looseFile, loosePartName, texWrapper, invert, hash32, colorToken, rotStepMatrix, stepViewMatrix, fileStepViews } from "./spec.js";
|
|
2
2
|
export type { M as Matrix12, Doc, LFile, Cmd, RotStep, BufExchg, TexMap, TexMapCmd, TexMapMethod, TexAnno, DataBlock, PartMesh, FileKind, StepView } from "./spec.js";
|
|
3
3
|
export { flatten, parseModel, sequenceSteps, stepKey, parseLDConfig, parseColourLine, colourSurface, colourMaterialKey, blendedColourHex, CALLOUT_END } from "./model.js";
|
|
4
4
|
export { planStepViews, isolateMask, viewDir, instanceBoxes, MIN_VIS, REORIENT } from "./instructions.js";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/spec.ts
|
|
2
2
|
var norm = (s) => s.trim().toLowerCase().replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
3
|
+
var COLOUR_ID_RE = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
4
|
+
var namedCodes = new Map;
|
|
5
|
+
function namedColorCode(id) {
|
|
6
|
+
const s = id.toLowerCase();
|
|
7
|
+
let h = 2166136261;
|
|
8
|
+
for (let i = 0;i < s.length; i++) {
|
|
9
|
+
h ^= s.charCodeAt(i);
|
|
10
|
+
h = Math.imul(h, 16777619);
|
|
11
|
+
}
|
|
12
|
+
const c = -1 - (h >>> 0 & 1073741823);
|
|
13
|
+
if (!namedCodes.has(c))
|
|
14
|
+
namedCodes.set(c, s);
|
|
15
|
+
return c;
|
|
16
|
+
}
|
|
17
|
+
var isNamedColor = (c) => c < 0 && Number.isInteger(c);
|
|
3
18
|
function parseColor(tok) {
|
|
19
|
+
const c0 = tok.charCodeAt(0) | 32;
|
|
20
|
+
if (c0 >= 97 && c0 <= 122 && COLOUR_ID_RE.test(tok))
|
|
21
|
+
return namedColorCode(tok);
|
|
4
22
|
if (/^0x/i.test(tok))
|
|
5
23
|
return parseInt(tok, 16);
|
|
6
24
|
return +tok;
|
|
@@ -575,7 +593,7 @@ function looseSteps(f) {
|
|
|
575
593
|
looseMemo.set(f, r);
|
|
576
594
|
return r;
|
|
577
595
|
}
|
|
578
|
-
var colorToken = (c) => c > 16777215 ? "0x" + c.toString(16).toUpperCase() : String(c);
|
|
596
|
+
var colorToken = (c) => c > 16777215 ? "0x" + c.toString(16).toUpperCase() : c < 0 ? namedCodes.get(c) ?? String(c) : String(c);
|
|
579
597
|
var lineOf = (c) => c.t === 0 ? "0 " + c.text : c.t === 1 ? `1 ${colorToken(c.color)} ${c.m.join(" ")} ${c.file}` : c.src ? c.src : `${c.t} ${colorToken(c.color)} ${c.p.join(" ")}`;
|
|
580
598
|
var loosePartName = (file, step) => `${norm(file)}#${step}`;
|
|
581
599
|
function looseFile(f, step) {
|
|
@@ -689,7 +707,7 @@ function fileStepViews(f) {
|
|
|
689
707
|
viewMemo.set(f, out);
|
|
690
708
|
return out;
|
|
691
709
|
}
|
|
692
|
-
// ../../../../../../../tmp/ldr-build-
|
|
710
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/model.ts
|
|
693
711
|
var CALLOUT_END = 999999;
|
|
694
712
|
var stepKey = (steps) => steps.map((x) => String(x).padStart(6, "0")).join(".") + "~";
|
|
695
713
|
function flatten(doc, opts = {}) {
|
|
@@ -901,14 +919,14 @@ function parseColourLine(line) {
|
|
|
901
919
|
if (tokens.length < 2)
|
|
902
920
|
return null;
|
|
903
921
|
const name = tokens[0];
|
|
904
|
-
let code =
|
|
922
|
+
let code = NaN, hex = "#FF00FF", edge = "#333333", alpha = 255, luminance = 0;
|
|
905
923
|
let finish = { type: "default" };
|
|
906
924
|
let i = 1;
|
|
907
925
|
while (i < tokens.length) {
|
|
908
926
|
const t = tokens[i].toUpperCase();
|
|
909
927
|
const n = tokens[i + 1];
|
|
910
928
|
if (t === "CODE") {
|
|
911
|
-
code = +n;
|
|
929
|
+
code = n !== undefined && COLOUR_ID_RE.test(n) ? namedColorCode(n) : n !== undefined && /^\d+$/.test(n) ? +n : NaN;
|
|
912
930
|
i += 2;
|
|
913
931
|
} else if (t === "VALUE") {
|
|
914
932
|
const h = parseHexColor(n);
|
|
@@ -963,7 +981,7 @@ function parseColourLine(line) {
|
|
|
963
981
|
} else
|
|
964
982
|
i += 1;
|
|
965
983
|
}
|
|
966
|
-
if (code
|
|
984
|
+
if (Number.isNaN(code) || !hex)
|
|
967
985
|
return null;
|
|
968
986
|
return { code, name, hex, edge, alpha: Number.isFinite(alpha) ? alpha : 255, luminance: Number.isFinite(luminance) ? luminance : 0, finish };
|
|
969
987
|
}
|
|
@@ -1071,7 +1089,7 @@ function blendedColourHex(code) {
|
|
|
1071
1089
|
const a = LDRAW_EXE_16[code - 256 >> 4], b = LDRAW_EXE_16[code - 256 & 15];
|
|
1072
1090
|
return "#" + [0, 1, 2].map((k) => (a[k] + b[k] >> 1).toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
1073
1091
|
}
|
|
1074
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1092
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/instructions.ts
|
|
1075
1093
|
var MIN_VIS = 0.5;
|
|
1076
1094
|
var REORIENT = 0.35;
|
|
1077
1095
|
var deg = Math.PI / 180;
|
|
@@ -1439,10 +1457,10 @@ function planStepViews(insts, parts, stepOf, nSteps, o = {}) {
|
|
|
1439
1457
|
}
|
|
1440
1458
|
};
|
|
1441
1459
|
}
|
|
1442
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1460
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/render.ts
|
|
1443
1461
|
import * as THREE from "three";
|
|
1444
1462
|
|
|
1445
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1463
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/pack-io.ts
|
|
1446
1464
|
import { decompress } from "fzstd";
|
|
1447
1465
|
async function decompressPack(data) {
|
|
1448
1466
|
const u = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
@@ -1465,7 +1483,7 @@ function decodePack(buf) {
|
|
|
1465
1483
|
return { header, arr, bytes: buf.byteLength, buffer: buf };
|
|
1466
1484
|
}
|
|
1467
1485
|
|
|
1468
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1486
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/cull.ts
|
|
1469
1487
|
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;
|
|
1470
1488
|
var prepCache = new WeakMap;
|
|
1471
1489
|
function prepPart(H, part) {
|
|
@@ -1800,7 +1818,7 @@ function precomputeCull(instances, H, useTex = true) {
|
|
|
1800
1818
|
return cullCore(s.all, H, s.nSteps > 1 ? s.stepOf : undefined);
|
|
1801
1819
|
}
|
|
1802
1820
|
|
|
1803
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1821
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/render.ts
|
|
1804
1822
|
async function loadPack(url) {
|
|
1805
1823
|
const res = await fetch(url);
|
|
1806
1824
|
if (!res.ok)
|
|
@@ -3608,7 +3626,7 @@ async function warmPackGeometry(pack, stop = () => false, sliceMs = 8) {
|
|
|
3608
3626
|
await new Promise((r) => setTimeout(r, 0));
|
|
3609
3627
|
}
|
|
3610
3628
|
}
|
|
3611
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3629
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/scene.ts
|
|
3612
3630
|
import * as THREE2 from "three";
|
|
3613
3631
|
function colorFn(src, pack, fallback) {
|
|
3614
3632
|
const table = new Map;
|
|
@@ -3835,10 +3853,10 @@ function createLdrObjectInner(instances, pack, options, progressive) {
|
|
|
3835
3853
|
return finish();
|
|
3836
3854
|
})();
|
|
3837
3855
|
}
|
|
3838
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3856
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/parts-cdn.ts
|
|
3839
3857
|
import { decompress as decompress2 } from "fzstd";
|
|
3840
3858
|
|
|
3841
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3859
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/embedded.ts
|
|
3842
3860
|
function splitFiles(text, fallback) {
|
|
3843
3861
|
const files = new Map;
|
|
3844
3862
|
let cur = null, saw = false;
|
|
@@ -3910,7 +3928,7 @@ function embeddedKeys(text, names, fallback = "main.ldr") {
|
|
|
3910
3928
|
return out;
|
|
3911
3929
|
}
|
|
3912
3930
|
|
|
3913
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3931
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/parts-cdn.ts
|
|
3914
3932
|
var DEFAULT_PARTS_CDN = "https://ldr-demo.vercel.app/cdn/v1/";
|
|
3915
3933
|
var indexCache = new Map;
|
|
3916
3934
|
var shardCache = new Map;
|
|
@@ -4142,10 +4160,10 @@ async function prepareModel(source, o = {}) {
|
|
|
4142
4160
|
return { insts, pack, missing, requests, bytes, cull, timings: { fetchModel: t1 - t0, parse: t2 - t1, parts: t3 - t2, ...cull ? { cull: performance.now() - t3 } : {} } };
|
|
4143
4161
|
}
|
|
4144
4162
|
|
|
4145
|
-
// ../../../../../../../tmp/ldr-build-
|
|
4146
|
-
var load_worker_gen_default = 'var wt=ArrayBuffer,Z=Uint8Array,de=Uint16Array,At=Int16Array;var be=Int32Array,Le=function(e,t,n){if(Z.prototype.slice)return Z.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 Z(n-t);return r.set(e.subarray(t,n)),r},ce=function(e,t,n,r){if(Z.prototype.fill)return Z.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},Mt=function(e,t,n,r){if(Z.prototype.copyWithin)return Z.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 vt=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],J=function(e,t,n){var r=Error(t||vt[e]);if(r.code=e,Error.captureStackTrace)Error.captureStackTrace(r,J);if(!n)throw r;return r},He=function(e,t,n){var r=0,s=0;for(;r<n;++r)s|=e[t++]<<(r<<3);return s},Ct=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Tt=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,a=r>>6;if(r&8)J(0);var u=6-s,c=i==3?4:i,f=He(e,u,c);u+=c;var l=a?1<<a:s,p=He(e,u,l)+(a==1&&256),d=p;if(!s){var w=1<<10+(e[5]>>3);d=w+(w>>3)*(e[5]&7)}if(d>2145386496)J(1);var y=new Z((t==1?p||d:t?0:d)+12);return y[0]=1,y[4]=4,y[8]=8,{b:u+l,y:0,l:0,d:f,w:t&&t!=1?t:y.subarray(12),e:d,o:new be(y.buffer,0,3),u:p,c:o,m:Math.min(131072,d)}}else if((n>>4|e[3]<<20)==25481893)return Ct(e,4)+8;J(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)J(3);var o=1<<s,i=o,a=-1,u=-1,c=-1,f=o,l=new wt(512+(o<<2)),p=new At(l,0,256),d=new de(l,0,256),w=new de(l,512,o),y=512+(o<<1),L=new Z(l,y,o),g=new Z(l,y+o);while(a<255&&i>0){var m=re(i+1),b=r>>3,h=(1<<m+1)-1,P=(e[b]|e[b+1]<<8|e[b+2]<<16)>>(r&7)&h,A=(1<<m)-1,S=h-i-1,T=P&A;if(T<S)r+=m,P=T;else if(r+=m+1,P>A)P-=S;if(p[++a]=--P,P==-1)i+=P,L[--f]=a;else i-=P;if(!P)do{var B=r>>3;u=(e[B]|e[B+1]<<8)>>(r&7)&3,r+=2,a+=u}while(u==3)}if(a>255||i)J(0);var v=0,F=(o>>1)+(o>>3)+3,Y=o-1;for(var H=0;H<=a;++H){var C=p[H];if(C<1){d[H]=-C;continue}for(c=0;c<C;++c){L[v]=H;do v=v+F&Y;while(v>=f)}}if(v)J(0);for(c=0;c<o;++c){var M=d[L[c]]++,k=g[c]=s-re(M);w[c]=(M<<k)-o}return[r+7>>3,{b:s,s:L,n:g,t:w}]},Lt=function(e,t){var n=0,r=-1,s=new Z(292),o=e[t],i=s.subarray(0,256),a=s.subarray(256,268),u=new de(s.buffer,268);if(o<128){var c=ue(e,t+1,6),f=c[0],l=c[1];t+=o;var p=f<<3,d=e[t];if(!d)J(0);var w=0,y=0,L=l.b,g=L,m=(++t<<3)-8+re(d);for(;;){if(m-=L,m<p)break;var b=m>>3;if(w+=(e[b]|e[b+1]<<8)>>(m&7)&(1<<L)-1,i[++r]=l.s[w],m-=g,m<p)break;b=m>>3,y+=(e[b]|e[b+1]<<8)>>(m&7)&(1<<g)-1,i[++r]=l.s[y],L=l.n[w],w=l.t[w],g=l.n[y],y=l.t[y]}if(++r>255)J(0)}else{r=o-127;for(;n<r;n+=2){var h=e[++t];i[n]=h>>4,i[n+1]=h&15}++t}var P=0;for(n=0;n<r;++n){var A=i[n];if(A>11)J(0);P+=A&&1<<A-1}var S=re(P)+1,T=1<<S,B=T-P;if(B&B-1)J(0);i[r++]=re(B)+1;for(n=0;n<r;++n){var A=i[n];++a[i[n]=A&&S+1-A]}var v=new Z(T<<1),F=v.subarray(0,T),Y=v.subarray(T);u[S]=0;for(n=S;n>0;--n){var H=u[n];ce(Y,n,H,u[n-1]=H+a[n]*(1<<S-n))}if(u[0]!=T)J(0);for(n=0;n<r;++n){var C=i[n];if(C){var M=u[C];ce(F,n,M,u[C]=M+(1<<S-C))}}return[t,{n:Y,b:S,s:F}]},St=ue(new Z([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],Et=ue(new Z([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],Pt=ue(new Z([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],Ge=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},Se=new Z(new be([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),kt=Ge(Se,0),Ee=new Z(new be([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),It=Ge(Ee,3),le=function(e,t,n){var r=e.length,s=t.length,o=e[r-1],i=(1<<n.b)-1,a=-n.b;if(!o)J(0);var u=0,c=n.b,f=(r<<3)-8+re(o)-c,l=-1;for(;f>a&&l<s;){var p=f>>3,d=(e[p]|e[p+1]<<8|e[p+2]<<16)>>(f&7);u=(u<<c|d)&i,t[++l]=n.s[u],f-=c=n.n[u]}if(f!=a||l+1!=s)J(0)},Bt=function(e,t,n){var r=6,s=t.length,o=s+3>>2,i=o<<1,a=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,a),n),le(e.subarray(r),t.subarray(a),n)},Ft=function(e,t,n){var r,s=t.b,o=e[s],i=o>>1&3;t.l=o&1;var a=o>>3|e[s+1]<<5|e[s+2]<<13,u=(s+=3)+a;if(i==1){if(s>=e.length)return;if(t.b=s+1,n)return ce(n,e[s],t.y,t.y+=a),n;return ce(new Z(a),e[s])}if(u>e.length)return;if(i==0){if(t.b=u,n)return n.set(e.subarray(s,u),t.y),t.y+=a,n;return Le(e,s,u)}if(i==2){var c=e[s],f=c&3,l=c>>2&3,p=c>>4,d=0,w=0;if(f<2)if(l&1)p|=e[++s]<<4|(l&2&&e[++s]<<12);else p=c>>3;else if(w=l,l<2)p|=(e[++s]&63)<<4,d=e[s]>>6|e[++s]<<2;else if(l==2)p|=e[++s]<<4|(e[++s]&3)<<12,d=e[s]>>2|e[++s]<<6;else p|=e[++s]<<4|(e[++s]&63)<<12,d=e[s]>>6|e[++s]<<2|e[++s]<<10;++s;var y=n?n.subarray(t.y,t.y+t.m):new Z(t.m),L=y.length-p;if(f==0)y.set(e.subarray(s,s+=p),L);else if(f==1)ce(y,e[s++],L);else{var g=t.h;if(f==2){var m=Lt(e,s);d+=s-(s=m[0]),t.h=g=m[1]}else if(!g)J(0);(w?Bt:le)(e.subarray(s,s+=d),y.subarray(L),g)}var b=e[s++];if(b){if(b==255)b=(e[s++]|e[s++]<<8)+32512;else if(b>127)b=b-128<<8|e[s++];var h=e[s++];if(h&3)J(0);var P=[Et,Pt,St];for(var A=2;A>-1;--A){var S=h>>(A<<1)+2&3;if(S==1){var T=new Z([0,0,e[s++]]);P[A]={s:T.subarray(2,3),n:T.subarray(0,1),t:new de(T.buffer,0,1),b:0}}else if(S==2)r=ue(e,s,9-(A&1)),s=r[0],P[A]=r[1];else if(S==3){if(!t.t)J(0);P[A]=t.t[A]}}var B=t.t=P,v=B[0],F=B[1],Y=B[2],H=e[u-1];if(!H)J(0);var C=(u<<3)-8+re(H)-Y.b,M=C>>3,k=0,_=(e[M]|e[M+1]<<8)>>(C&7)&(1<<Y.b)-1;M=(C-=F.b)>>3;var I=(e[M]|e[M+1]<<8)>>(C&7)&(1<<F.b)-1;M=(C-=v.b)>>3;var O=(e[M]|e[M+1]<<8)>>(C&7)&(1<<v.b)-1;for(++b;--b;){var j=Y.s[_],X=Y.n[_],W=v.s[O],E=v.n[O],x=F.s[I],R=F.n[I];M=(C-=x)>>3;var D=1<<x,U=D+((e[M]|e[M+1]<<8|e[M+2]<<16|e[M+3]<<24)>>>(C&7)&D-1);M=(C-=Ee[W])>>3;var G=It[W]+((e[M]|e[M+1]<<8|e[M+2]<<16)>>(C&7)&(1<<Ee[W])-1);M=(C-=Se[j])>>3;var N=kt[j]+((e[M]|e[M+1]<<8|e[M+2]<<16)>>(C&7)&(1<<Se[j])-1);if(M=(C-=X)>>3,_=Y.t[_]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<X)-1),M=(C-=E)>>3,O=v.t[O]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<E)-1),M=(C-=R)>>3,I=F.t[I]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<R)-1),U>3)t.o[2]=t.o[1],t.o[1]=t.o[0],t.o[0]=U-=3;else{var V=U-(N!=0);if(V){if(U=V==3?t.o[0]-1:t.o[V],V>1)t.o[2]=t.o[1];t.o[1]=t.o[0],t.o[0]=U}else U=t.o[0]}for(var A=0;A<N;++A)y[k+A]=y[L+A];k+=N,L+=N;var z=k-U;if(z<0){var K=-z,q=t.e+z;if(K>G)K=G;for(var A=0;A<K;++A)y[k+A]=t.w[q+A];k+=K,G-=K,z=0}for(var A=0;A<G;++A)y[k+A]=y[z+A];k+=G}if(k!=L)while(L<y.length)y[k++]=y[L++];else k=y.length;if(n)t.y+=k;else y=Le(y,0,k)}else if(n){if(t.y+=p,L)for(var A=0;A<p;++A)y[A]=y[L+A]}else if(L)y=Le(y,L);return t.b=u,y}J(2)},Rt=function(e,t){if(e.length==1)return e[0];var n=new Z(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 ye(e,t){var n=[],r=+!t,s=0,o=0;for(;e.length;){var i=Tt(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 a=Ft(e,i,t);if(!a)J(5);if(t)i.e=i.y;else n.push(a),o+=a.length,Mt(i.w,0,a.length),i.w.set(a,i.w.length-a.length)}s=i.b+i.c*4}else s=i;e=e.subarray(s)}return Rt(n,o)}async function Dt(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=(r)=>r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);if(t[0]===40&&t[1]===181&&t[2]===47&&t[3]===253)return n(ye(t));if(t[0]===31&&t[1]===139)return new Response(new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip"))).arrayBuffer();return n(t)}async function _e(e){return new TextDecoder().decode(await Dt(e))}var Ke=(e)=>decodeURIComponent(e.split(/[?#]/)[0].split("/").pop()||"main.ldr").replace(/\\.(zst|gz)$/i,"")||"main.ldr";function xe(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 Q=(e)=>e.trim().toLowerCase().replace(/\\\\/g,"/").replace(/\\/+/g,"/");function Pe(e){if(/^0x/i.test(e))return parseInt(e,16);return+e}var We=/^~?\\s*moved\\s+to\\s+(.+)$/i,Ut=new Set(["FILE","NOFILE","!DATA","!:","STEP","BFC","ROTSTEP","BUFEXCHG","!TEXMAP"]),tt=new Set(["part","subpart","primitive","8_primitive","48_primitive","shortcut","helper"]),zt=new Set(["model","submodel","configuration"]),Ot=/^(?:!?LDRAW_ORG|Unofficial|Official\\s+LCAD)\\s+(\\S+)/i;function Xe(e){let t=Ot.exec(e);if(!t)return;let n=t[1].toLowerCase().replace(/^unofficial_/,"");return tt.has(n)||zt.has(n)?n:void 0}function Nt(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 $t(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 a=n[2].trim();for(let l=0;l<s;l++)a=a.replace(/^\\S+\\s*/,"");let u=Nt(a);if(!u.length)return null;let c={method:r,p1:i.slice(0,3),p2:i.slice(3,6),p3:i.slice(6,9),texture:u[0]};if(s>=10)c.a=i[9];if(s===11)c.b=i[10];let f=u.findIndex((l,p)=>p>0&&l.toUpperCase()==="GLOSSMAP");if(f>0&&u[f+1])c.glossmap=u[f+1];if(t)c.next=!0;return c}var jt=(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 Vt(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 f=s();if(f===null)return null;i[c]=+f}while(n<t&&r(e.charCodeAt(n)))n++;if(n>=t)return null;let a=e.slice(n),u=/[ \\t]{2,}|\\t/.test(a)?a.split(/\\s+/).join(" "):a;return{t:1,color:Pe(o),m:i,file:Q(u)}}function Ze(e){let t=+e[0];if(!(t>=1&&t<=5)||e.length<2)return null;let n=Pe(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 nt(e,t="main.ldr",n={}){let r=!!n.geometryText,s=new Map,o=null,i="",a,u=null,c=[],f=null,l=()=>{if(!u)return;let m=jt(u.chunks.join("")),b=m[0]===137&&m[1]===80&&m[2]===78&&m[3]===71;(a??=new Map).set(Q(u.name),{name:u.name,bytes:m,...b?{mime:"image/png"}:{}}),u=null},p=!0,d=(m)=>{if(l(),o={name:Q(m),cmds:[]},s.set(o.name,o),!i)i=o.name;c=[],f=null,p=!0},w=!1,y=!1,L=()=>{if(y)return;y=!0,s.clear(),o=null,i=""},g=(m,b)=>{if(f){m.tex=f,f=null;return}let h=c[c.length-1];if(!h)return;if(h.fallback){if(!b)m.fallback=!0}else m.tex=h.map};for(let m of e.split(`\n`)){let b=m.trim();if(!b)continue;if(r&&b.charCodeAt(0)>=50&&b.charCodeAt(0)<=53&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)){if(u||w)continue;if(!o)d(t);let S=b.slice(2).trimStart(),T=S.search(/\\s/),B={t:b.charCodeAt(0)-48,color:Pe(T<0?S:S.slice(0,T)),p:[],src:b};g(B,!1),o.cmds.push(B),p=!1;continue}if(b.charCodeAt(0)===48&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)){let S=2;while(b.charCodeAt(S)===32||b.charCodeAt(S)===9)S++;let T=S;while(T<b.length&&b.charCodeAt(T)!==32&&b.charCodeAt(T)!==9)T++;let B=b.slice(S,T);if(!Ut.has(B)){if(w||u)continue;if(!o)d(t);let v=b.slice(S),F={t:0,text:v};if(B.charCodeAt(0)===33)F.meta=B;if(f=null,p&&!o.org){let H=Xe(v);if(H)o.org=H}let Y=v.match(We);if(Y&&!o.movedTo){let H=Y[1].trim().replace(/\\\\/g,"/");if(!/\\.(dat|ldr|mpd)$/i.test(H))H+=".dat";o.movedTo=Q(H)}o.cmds.push(F);continue}}if(b.charCodeAt(0)===49&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)&&!u&&!w){let S=Vt(b);if(S){if(!o)d(t);g(S,!1),o.cmds.push(S),p=!1;continue}}let h=b.split(/\\s+/);if(+h[0]===0){let S=b.slice(1).trim();if(h[1]==="FILE"){L(),w=!1,d(S.slice(5));continue}if(h[1]==="NOFILE"){l(),o=null,w=!0;continue}if(h[1]==="!DATA"){L(),l(),o=null,w=!1,u={name:S.slice(5).trim(),chunks:[]};continue}if(w)continue;if(u){if(h[1]==="!:")u.chunks.push(h.slice(2).join(""));continue}if(!o)d(t);let T={t:0,text:S};if(h[1]==="STEP")T.step=!0,c=[],f=null;else if(h[1]==="BFC")T.bfc=h.slice(2).join(" ");else if(h[1]==="ROTSTEP")if(T.meta="ROTSTEP",T.step=!0,c=[],f=null,(h[2]??"").toUpperCase()==="END")T.rotstep={x:0,y:0,z:0,mode:"END"};else{let v=(h[5]??"REL").toUpperCase();T.rotstep={x:+h[2]||0,y:+h[3]||0,z:+h[4]||0,mode:["REL","ABS","ADD"].includes(v)?v:"REL"}}else if(h[1]==="BUFEXCHG"){T.meta="BUFEXCHG";let v=(h[2]??"").toUpperCase();T.bufexchg={op:v==="RETRIEVE"?"RETRIEVE":"STORE",buf:h[3]??"A"}}else if(h[1]?.startsWith("!"))T.meta=h[1];if(p&&!o.org){let v=Xe(S);if(v)o.org=v}if(h[1]==="!TEXMAP"){let v=(h[2]??"").toUpperCase();if(f=null,v==="START"||v==="NEXT"){let F=$t(S.replace(/^!TEXMAP\\s+\\S+/i,""),v==="NEXT");if(T.texmap={op:v,...F?{map:F}:{}},F)if((o.texmaps??=[]).push(F),v==="START")c.push({map:F,fallback:!1});else f=F}else if(v==="FALLBACK"){T.texmap={op:v};let F=c[c.length-1];if(F)F.fallback=!0}else if(v==="END")T.texmap={op:v},c.pop()}else if(h[1]==="!:"){f=null;let v=Ze(h.slice(2));if(v)g(v,!0),T.geom=v}else f=null;let B=S.match(We);if(B&&!o.movedTo){let v=B[1].trim().replace(/\\\\/g,"/");if(!/\\.(dat|ldr|mpd)$/i.test(v))v+=".dat";o.movedTo=Q(v)}o.cmds.push(T);continue}if(u||w)continue;if(!o)d(t);let A=Ze(h);if(!A)continue;g(A,!1),o.cmds.push(A),p=!1}return l(),a?{main:i,files:s,data:a}:{main:i,files:s}}var gn=Math.PI/180;function rt(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 st(e,t){let[n,r,s,o,i,a,u,c,f,l,p,d]=e,[w,y,L,g,m,b,h,P,A,S,T,B]=t;return[o*w+i*y+a*L+n,u*w+c*y+f*L+r,l*w+p*y+d*L+s,o*g+i*h+a*S,o*m+i*P+a*T,o*b+i*A+a*B,u*g+c*h+f*S,u*m+c*P+f*T,u*b+c*A+f*B,l*g+p*h+d*S,l*m+p*P+d*T,l*b+p*A+d*B]}var ke=[0,0,0,1,0,0,0,1,0,0,0,1];var Ye=new WeakMap,Ht=/^(s|8|48)\\//;function Ie(e,t){let n=e.files.get(Q(t));if(!n)return"part";let r=Ye.get(n);if(r)return r;if(n.org)r=tt.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&&Ht.test(s.file))?"part":"model";return Ye.set(n,r),r}var Je=new WeakMap;function ot(e){let t=Je.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 Je.set(e,t),t}var qe=(e)=>e>16777215?"0x"+e.toString(16).toUpperCase():String(e),Gt=(e)=>e.t===0?"0 "+e.text:e.t===1?`1 ${qe(e.color)} ${e.m.join(" ")} ${e.file}`:e.src?e.src:`${e.t} ${qe(e.color)} ${e.p.join(" ")}`,Be=(e,t)=>`${Q(e)}#${t}`;function _t(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:Be(e.name,t),cmds:n}}function it(e,t){return[`0 ldr: own geometry of ${e.name}, step ${t}`,..._t(e,t).cmds.map(Gt)].join(`\n`)+`\n`}function Kt(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 at(e){let[t,n,r,s,o,i,a,u,c,f,l,p]=e,d=u*p-c*l,w=-(a*p-c*f),y=a*l-u*f,L=s*d+o*w+i*y;if(!Number.isFinite(L)||Math.abs(L)<0.000000000001)return null;let g=1/L,m=[d*g,-(o*p-i*l)*g,(o*c-i*u)*g,w*g,(s*p-i*f)*g,-(s*c-i*a)*g,y*g,-(s*l-o*f)*g,(s*u-o*a)*g];return[-(m[0]*t+m[1]*n+m[2]*r),-(m[3]*t+m[4]*n+m[5]*r),-(m[6]*t+m[7]*n+m[8]*r),...m]}var Wt=(e)=>String(+e.toFixed(6)||0),Qe=(e)=>\'"\'+e.replace(/\\\\/g,"\\\\\\\\").replace(/"/g,"\\\\\\"")+\'"\';function lt(e,t){let n=[...t.p1,...t.p2,...t.p3,...t.method!=="PLANAR"?[t.a??360]:[],...t.method==="SPHERICAL"?[t.b??180]:[]].map(Wt).join(" "),r=`0 ldr: ${e} with a model-level !TEXMAP\n0 BFC CERTIFY CCW\n0 !TEXMAP START ${t.method} ${n} ${Qe(t.texture)}${t.glossmap?" GLOSSMAP "+Qe(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-${Kt(r)}`,source:r}}var Xt=(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 Zt(e,t,n){let r=Math.PI/180,s=Math.sin(e*r),o=Math.cos(e*r),i=Math.sin(t*r),a=Math.cos(t*r),u=Math.sin(n*r),c=Math.cos(n*r);return[a*c,-a*u,i,o*u+s*i*c,o*c-s*i*u,-s*a,s*u-o*i*c,s*c+o*i*u,o*a]}var et=new WeakMap;function ct(e){let t=et.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=Zt(o.x,o.y,o.z);r=o.mode==="ABS"?{abs:!0,m:i,rotstep:o}:o.mode==="ADD"&&r?{abs:r.abs,m:Xt(r.m,i),rotstep:o}:{abs:!1,m:i,rotstep:o}}n.push(r)}return n.push(r),et.set(e,n),n}var ut=999999,pt=(e)=>e.map((t)=>String(t).padStart(6,"0")).join(".")+"~";function Yt(e,t={}){let n=[],r=t.maxDepth??64,s=t.looseGeometry!==!1,o=!!t.textures,i=!!t.callouts,a=new Map,u=0,c=(l,p)=>{let d=l.name+"#"+p,w=a.get(d);if(!w){let y;w=Object.assign(()=>y??=it(l,p),{file:l,step:p}),a.set(d,w)}return w},f=(l,p,d,w,y,L,g,m,b=null,h=[],P=[],A=void 0,S=null)=>{let T=l.files.get(p);if(!T||g>r)return;let B=S,v=0,F=g>0?++u:0,Y=i&&F?[...h,F]:h,H=i&&F?[...P,d]:P,C=i&&!b?new Map:null,M=-1,k=0,_=(E,x,R,D,U,G,N)=>{if(M!==v)M=v,k=0;let V=C?.get(v+"|"+x);if(V)return V.n++,f(E,E===l?x:E.main,R,D,y+"/"+x,[...U,ut],g+1,G,[...U,ut],Y,H,N,B);let z=[...U,k++],K=n.length;f(E,E===l?x:E.main,R,D,y+"/"+x,z,g+1,G,b,Y,H,N,B),C?.set(v+"|"+x,{n:1,from:K,to:n.length})},I=ct(T),O=s?ot(T):[],j=0,X=(E,x,R,D,U,G,N,V)=>{if(b)D=b;let z={part:E,color:x,m:R,step:D[0],steps:D,localStep:U,path:y};if(V)z.colour=V;if(F){if(z.sub=F,i)z.subPath=Y,z.subMats=H}if(G)z.embedded=!0;if(N){let q=lt(E,N);z.texPart=q.name,z.texSource=q.source}let K=I[U];if(K)z.view=K;return n.push(z),z},W=(E)=>{while(j<O.length&&O[j]<=E){let x=O[j++];X(Be(T.name,x),w,d,[...L,x],x,!1,null,A).source=c(T,x)}};for(let E of T.cmds){if(E.t===0&&E.step){v++;continue}let x=E;if(x.t>=2||x.t===0&&x.geom&&x.geom.t>=2){W(v);continue}if(x.t===0){if(x.meta==="!COLOUR"){let q=qt(x.text);if(q&&q.code!==16&&q.code!==24)(B=new Map(B??[])).set(q.code,q);continue}if(o&&x.geom?.t===1)x=x.geom;else continue}if(x.t!==1)continue;if(o&&x.fallback)continue;let R=x.color===16?w:x.color,D=x.color===16?A:B?.get(x.color),U=st(d,x.m),G=[...L,v],N=o?x.tex??m:null,V=N?at(x.m):null,z=N&&V?rt(N,V):null;if(l.files.has(x.file)){if(Ie(l,x.file)==="model"){_(l,x.file,U,R,G,z,D);continue}X(x.file,R,U,G,v,!0,z,D);continue}let K=t.resolveModel?.(x.file);if(K){_(K,x.file,U,R,G,z,D);continue}X(x.file,R,U,G,v,!1,z,D)}if(W(1/0),C){for(let E of C.values())if(E.n>1)for(let x=E.from;x<E.to;x++)n[x].mult??=E.n}};if(Ie(e,e.main)==="part"){if(e.files.get(e.main))n.push({part:e.main,color:16,m:[...ke],step:0,steps:[0],localStep:0,path:e.main,embedded:!0});return n}return f(e,e.main,ke,16,e.main,[],0,null),n}function mt(e,t="main.ldr",n){return Yt(nt(e,t,{geometryText:!0}),n)}var Jt=new Set(["CHROME","PEARLESCENT","RUBBER","MATTE_METALLIC","METAL","MATERIAL"]);function Fe(e){if(!e)return null;if(e.startsWith("#")&&/^#[0-9A-Fa-f]{6}$/.test(e))return e.toUpperCase();if(/^0x[0-9A-Fa-f]{6}$/i.test(e))return("#"+e.slice(2)).toUpperCase();return null}function ft(e,t){let n={value:"#FFFFFF",fraction:0.5};while(t<e.length){let r=e[t].toUpperCase(),s=e[t+1];if(r==="VALUE"){let o=Fe(s);if(o)n.value=o;t+=2}else if(r==="ALPHA")n.alpha=+s,t+=2;else if(r==="LUMINANCE")n.luminance=+s,t+=2;else if(r==="FRACTION")n.fraction=+s,t+=2;else if(r==="VFRACTION")n.vfraction=+s,t+=2;else if(r==="SIZE")n.size=+s,t+=2;else if(r==="MINSIZE")n.minsize=+s,t+=2;else if(r==="MAXSIZE")n.maxsize=+s,t+=2;else break}return{grain:n,next:t}}function qt(e){let t=e.indexOf("!COLOUR");if(t<0)return null;let n=e.slice(t+7).trim().split(/\\s+/).filter(Boolean);if(n.length<2)return null;let r=n[0],s=-1,o="#FF00FF",i="#333333",a=255,u=0,c={type:"default"},f=1;while(f<n.length){let l=n[f].toUpperCase(),p=n[f+1];if(l==="CODE")s=+p,f+=2;else if(l==="VALUE"){let d=Fe(p);if(d)o=d;f+=2}else if(l==="EDGE")i=Fe(p)??p,f+=2;else if(l==="ALPHA")a=+p,f+=2;else if(l==="LUMINANCE")u=+p,f+=2;else if(l==="CHROME")c={type:"chrome"},f+=1;else if(l==="PEARLESCENT")c={type:"pearlescent"},f+=1;else if(l==="RUBBER")c={type:"rubber"},f+=1;else if(l==="MATTE_METALLIC")c={type:"matte_metallic"},f+=1;else if(l==="METAL")c={type:"metal"},f+=1;else if(l==="MATERIAL"){let d=(n[f+1]||"").toUpperCase();if(d==="GLITTER"){let{grain:w,next:y}=ft(n,f+2);c={type:"glitter",material:w},f=y}else if(d==="SPECKLE"){let{grain:w,next:y}=ft(n,f+2);c={type:"speckle",material:w},f=y}else if(d==="FABRIC"){let w=(n[f+2]||"").toUpperCase(),y=["VELVET","CANVAS","STRING","FUR"].includes(w)?w.toLowerCase():void 0;c={type:"fabric",kind:y},f+=y?3:2}else f=n.length}else if(Jt.has(l))f+=1;else f+=1}if(s<0||!o)return null;return{code:s,name:r,hex:o,edge:i,alpha:Number.isFinite(a)?a:255,luminance:Number.isFinite(u)?u:0,finish:c}}function Qt(e){let t=Math.max(0,Math.min(1,(e.alpha??255)/255)),n=t<1,r=Math.max(0,Math.min(1,(e.luminance??0)/255)),s={opacity:t,transparent:n,depthWrite:!n,emissive:r,clearcoat:0,clearcoatRoughness:0,sheen:0,sheenRoughness:0};switch(e.finish?.type??"default"){case"chrome":return{...s,metalness:1,roughness:0,finish:"chrome"};case"pearlescent":return{...s,metalness:0.25,roughness:0.3,clearcoat:0.5,clearcoatRoughness:0.25,sheen:0.4,sheenRoughness:0.35,finish:"pearlescent"};case"rubber":return{...s,metalness:0,roughness:0.9,finish:"rubber"};case"matte_metallic":return{...s,metalness:0.4,roughness:0.8,finish:"matte_metallic"};case"metal":return{...s,metalness:0.85,roughness:0.2,finish:"metal"};case"glitter":{let i=e.finish.material,a=i.size??(i.minsize!=null&&i.maxsize!=null?(i.minsize+i.maxsize)/2:1);return{...s,metalness:0.35,roughness:0.25,clearcoat:1,clearcoatRoughness:0.08,particleHex:i.value,particleFraction:i.fraction,particleSize:a,finish:"glitter"}}case"speckle":{let i=e.finish.material,a=i.size??(i.minsize!=null&&i.maxsize!=null?(i.minsize+i.maxsize)/2:1);return{...s,metalness:0.2,roughness:0.55,particleHex:i.value,particleFraction:i.fraction,particleSize:a,finish:"speckle"}}case"fabric":return{...s,metalness:0,roughness:0.85,sheen:0.65,sheenRoughness:0.75,finish:"fabric"};default:return{...s,metalness:0,roughness:0.45,finish:"default"}}}function Re(e){let t=Qt(e),n=!t.transparent?"op":t.opacity>=0.75?"a200":t.opacity>=0.4?"a128":`a${Math.round(t.opacity*255)}`,r=t.emissive>0?`L${Math.round(t.emissive*16)}`:"",s=`${t.finish}:${n}${r}`;if(t.particleHex)s+=`:${t.particleHex}:${(t.particleFraction??0).toFixed(2)}`;return s}function en(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(Q(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(Q(t),r)}let a=o.trim().replace(/\\s+/g," ");if(a)r.push(a)}return n}var tn=(e)=>{if(!e.startsWith("1 "))return null;let t=e.split(" ");return t.length>=15?Q(t.slice(14).join(" ")):null};function nn(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 ht(e,t,n="main.ldr"){let r=en(e,n),s=new Map;for(let o of t){let i=Q(o);if(!r.has(i)||s.has(i))continue;let a=new Set([i]),u=[i];while(u.length)for(let f of r.get(u.pop())){let l=tn(f);if(l&&r.has(l)&&!a.has(l))a.add(l),u.push(l)}let c=[i,...[...a].filter((f)=>f!==i).sort()].map((f)=>"0 FILE "+(f===i?"":f)+`\n`+r.get(f).join(`\n`)).join(`\n`);s.set(i,`emb/${nn(c)}.dat`)}return s}var gt=(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,dt=new WeakMap;function De(e,t){let n=dt.get(e);if(!n)dt.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),a=[],u=[];s.studs.forEach((p,d)=>{a.push(p[0]),u.push(p[1]);for(let w=0;w<12;w++)i[d*12+w]=p[2+w]});let c=null,f=0,l=0;if(s.mask){f=s.mask[0],l=s.mask[1];let p=s.mask[2];c=new Uint8Array(p.length);for(let d=0;d<p.length;d++)c[d]=p.charCodeAt(d)===49?1:0}return n.set(t,r={nStuds:o,studM:i,kind:a,color:u,mask:c,nx:f,nz:l}),r}var ie=1073741824;class Ue{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,a=this.c;for(;;){if(!s[r])return-1;if(o[r]===e&&i[r]===t&&a[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,a=this.b,u=this.c;for(;;){if(!o[s])return o[s]=1,i[s]=e,a[s]=t,u[s]=n,this.vals[s]=r,this.size++,-1;if(i[s]===e&&a[s]===t&&u[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 we=(e,t,n)=>e>-ie&&e<ie&&t>-ie&&t<ie&&n>-ie&&n<ie,fe=2147483647;function rn(e,t,n){let s=[],o=[],i=[],a=[],u=[],c=[],f=[],l=[],p=new Ue(e.length*2),d=[],w=[];for(let C=0;C<e.length;C++){let M=e[C],k=M.m,_=t.parts[M.part];if(!_||!_.mask||!gt(k))continue;let I=_.bbox,O=1/0,j=-1/0,X=1/0,W=-1/0;for(let R=0;R<2;R++)for(let D=0;D<2;D++){let U=R?I[3]:I[0],G=D?I[5]:I[2],N=k[0]+k[3]*U+k[5]*G,V=k[2]+k[9]*U+k[11]*G;if(N<O)O=N;if(N>j)j=N;if(V<X)X=V;if(V>W)W=V}let E=u.length;s.push(O),o.push(j),i.push(X),a.push(W),u.push(C),c.push(De(t,M.part)),f.push(I[0]),l.push(I[2]);let x=Math.round((k[1]+I[4])*2);for(let R=Math.floor(O/40);R<=Math.floor(j/40);R++)for(let D=Math.floor(X/40);D<=Math.floor(W/40);D++){if(!we(x,R,D))continue;let U=w.length;w.push(E),d.push(p.put(x,R,D,U))}}let y=[0,5,-5,5,-5],L=[0,5,5,-5,-5],g=NaN,m=NaN,b=NaN,h=-1,P=(C,M,k,_)=>{let I=Math.round(M*2),O=Math.floor(C/40),j=Math.floor(k/40);if(!we(I,O,j))return fe;let X=fe;if(I!==g||O!==m||j!==b)g=I,m=O,b=j,h=p.get(I,O,j);for(let W=h;W>=0;W=d[W]){let E=w[W];if(u[E]===_||!(C-6>=s[E]-0.5&&C+6<=o[E]+0.5&&k-6>=i[E]-0.5&&k+6<=a[E]+0.5))continue;let x=e[u[E]].m,R=c[E],D=f[E],U=l[E],G=C-x[0],N=M-x[1],V=k-x[2],z=x[3]*G+x[6]*N+x[9]*V,K=x[5]*G+x[8]*N+x[11]*V,{nx:q,nz:se,mask:ae}=R,oe=!0;for(let ee=0;ee<5;ee++){let te=Math.floor((z+y[ee]-D)/20),ne=Math.floor((K+L[ee]-U)/20);if(te<0||ne<0||te>=q||ne>=se||ae[te*se+ne]!==1){oe=!1;break}}if(oe){if(!n)return 0;let ee=n[u[E]];if(ee<X)X=ee}}return X},A=0;for(let C of e){let M=De(t,C.part);if(M)A+=M.nStuds}let S=new Uint8Array(A),T=new Uint8Array(A),B=new Ue(A),v=0,F=n?new Int32Array(A).fill(fe):void 0;for(let C=0,M=0;C<e.length;C++){let k=e[C],_=De(t,k.part);if(!_)continue;let I=k.m,O=_.studM,j=I[0],X=I[1],W=I[2],E=I[3],x=I[4],R=I[5],D=I[6],U=I[7],G=I[8],N=I[9],V=I[10],z=I[11];for(let K=0;K<_.nStuds;K++,M++){let q=K*12,se=O[q+4],ae=O[q+7],oe=O[q+10];if(!(Math.abs(D*se+U*ae+G*oe-1)<0.001&&Math.abs(E*se+x*ae+R*oe)<0.001&&Math.abs(N*se+V*ae+z*oe)<0.001))continue;T[M]=1;let ee=O[q],te=O[q+1],ne=O[q+2],ze=j+E*ee+x*te+R*ne,Oe=X+D*ee+U*te+G*ne,Ne=W+N*ee+V*te+z*ne,$e=P(ze,Oe,Ne,C);if($e!==fe){if(S[M]=1,v++,F)F[M]=$e}let me=Math.round(ze),he=Math.round(Oe),ge=Math.round(Ne);if(!we(me,he,ge))continue;if(!n){B.put(me,he,ge,1);continue}let je=n[C],Ve=B.get(me,he,ge);if(Ve<0||je<Ve)B.put(me,he,ge,je)}}let Y=new Uint8Array(e.length),H=n?new Int32Array(e.length).fill(fe):void 0;for(let C=0;C<e.length;C++){let M=e[C],k=t.parts[M.part];if(!k||!k.under||!gt(M.m))continue;let _=k.bbox,I=Math.round((_[3]-_[0])/20),O=Math.round((_[5]-_[2])/20);if(!I||!O||I*O>4096)continue;let j=M.m,X=!0,W=0;for(let E=0;E<I&&X;E++)for(let x=0;x<O;x++){let R=_[0]+10+20*E,D=_[2]+10+20*x,U=j[0]+j[3]*R+j[5]*D,G=j[2]+j[9]*R+j[11]*D,N=Math.round(U),V=Math.round(j[1]+_[4]),z=Math.round(G),K=we(N,V,z)?B.get(N,V,z):-1;if(K<0){X=!1;break}if(K>W)W=K}if(X){if(Y[C]=1,H)H[C]=W}}return{nStuds:A,studHidden:S,studUp:T,underHidden:Y,studsHidden:v,studHideStep:F,underHideStep:H}}function sn(e,t,n){let r=(l)=>n&&l.texPart&&t.parts[l.texPart]?l.texPart:l.part,s=new Map,o=new Map,i=(l)=>{let p=l.colour;if(!p)return String(l.color);let d=o.get(p);if(d!==void 0)return d;let w=t.colorTable?.[l.color],y=w?.hex??t.colors?.[l.color],L=w?Re({alpha:w.alpha??255,luminance:w.luminance??0,finish:w.finish??{type:"default"}}):"default:op",g=Re(p);if(d=y&&y.toUpperCase()===p.hex.toUpperCase()&&L===g?String(l.color):p.hex.toUpperCase()+"/"+g,d!==String(l.color))s.set(d,p);return o.set(p,d),d},a=e.map((l)=>({part:r(l),color:i(l),m:l.m,steps:l.steps})),u=a.map((l)=>pt(l.steps)),c=[...new Set(u)].sort(),f=new Map(c.map((l,p)=>[l,p]));return{all:a,stepOf:u.map((l)=>f.get(l)),nSteps:c.length,localColours:s}}function Ae(e,t,n=!0){let r=sn(e,t,n);return rn(r.all,t,r.nSteps>1?r.stepOf:void 0)}var Te="https://ldr-demo.vercel.app/cdn/v1/",ve=new Map,Me=new Map;function yt(e=Te,t=fetch){let n=ve.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(()=>ve.delete(e)),ve.set(e,n);return n}var on=(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"),Ce=(e,t)=>on(e)?[e[0]+t,e[1],e[2]]:Array.isArray(e)?e.map((n)=>Ce(n,t)):e&&typeof e==="object"?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,Ce(r,t)])):e;function an(e,t={}){let n=[],r=0,s={},o={};for(let p of e){let d=p.buffer;if(!d)throw Error("ldr: mergePacks needs packs from decodePack/loadPack");let w=new DataView(d).getUint32(0,!0),y=new Uint8Array(d,4+w),L=r;n.push(y),r+=y.byteLength;let g=(4-r%4)%4;if(g)n.push(new Uint8Array(g)),r+=g;for(let[m,b]of Object.entries(p.header.parts??{}))if(!(m in s))s[m]=Ce(b,L);for(let[m,b]of Object.entries(p.header.studKinds??{}))if(!(m in o))o[m]=Ce(b,L)}let i=e[0]?.header??{version:1,weld:!0},a=new TextEncoder().encode(JSON.stringify({...i,parts:s,studKinds:o,...t})),u=(4-(4+a.length)%4)%4,c=4+a.length+u,f=new Uint8Array(c+r);new DataView(f.buffer).setUint32(0,a.length+u,!0),f.set(a,4),f.fill(32,4+a.length,c);let l=c;for(let p of n)f.set(p,l),l+=p.byteLength;return xe(f.buffer)}async function ln(e,t={}){e=[...e];try{return await bt(e,t)}catch(n){let r=t.cdn??Te,s=t.fetch??fetch;ve.delete(r);let o=(i,a)=>s(i,{...a,cache:"reload"});try{return await bt(e,{...t,fetch:o})}catch{throw n}}}async function bt(e,t){let n=t.cdn??Te,r=t.fetch??fetch,s=t.gap??16384,o=await yt(n,r),i=[...new Set([...e].map(Q))],a=[],u=[];for(let g of i){if(Me.has(n+g))continue;let m=o.parts[g];if(m)u.push({name:g,off:m[0],len:m[1],file:m[2]??0});else a.push(g)}u.sort((g,m)=>g.file-m.file||g.off-m.off);let c=[];for(let g of u){let m=c[c.length-1];if(m&&m.file===g.file&&g.off-m.end<=s)m.end=Math.max(m.end,g.off+g.len),m.items.push(g);else c.push({file:g.file,start:g.off,end:g.off+g.len,items:[g]})}let f=0,l=0,p=0,d=new Map,w=async()=>{while(p<c.length){let g=c[p++],m=d.get(g.file);if(m)m=m.subarray(g.start,g.end);else{let b=await r(new URL(o.archives[g.file],n).href,{headers:{Range:`bytes=${g.start}-${g.end-1}`,"Accept-Encoding":"identity"}});if(!b.ok)throw Error(`ldr: parts CDN ${b.status}`);if(l++,m=new Uint8Array(await b.arrayBuffer()),f+=m.byteLength,b.status===200)d.set(g.file,m),m=m.subarray(g.start,g.end)}for(let b of g.items){let h=ye(m.subarray(b.off-g.start,b.off-g.start+b.len)),P=h.buffer.slice(h.byteOffset,h.byteOffset+h.byteLength);Me.set(n+b.name,xe(P))}}};await Promise.all(Array.from({length:Math.min(t.concurrency??24,c.length)},w));let y=i.filter((g)=>Me.has(n+g)).map((g)=>Me.get(n+g));return{pack:y.length?an(y,{colors:o.colors}):xe(cn(o.colors)),missing:a,requests:l,bytes:f}}function cn(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}function un(e,t){let n=t.header.parts;if(!n)return 0;let r=0;for(let s of e){let o=n[s.part]?.body?.tris;if(o)r+=o}return r}function fn(e,t,n){let r=0,s=0,o=!1,i=new Set;for(let a of e){let u=a.embedded?t.get(a.part):Q(a.part),c=u?n.parts[u]:void 0;if(!c)continue;if(c[3]!=null)o=!0,r+=c[3];if(!i.has(u))i.add(u),s+=c[1]}return{bodyTris:r,packBytes:s,known:o}}class pe extends Error{code="ldr-budget";bodyTris;packBytes;maxBodyTris;maxPackBytes;constructor(e){let t=[e.maxBodyTris!=null&&e.bodyTris>e.maxBodyTris?`${e.bodyTris} triangles (limit ${e.maxBodyTris})`:"",e.maxPackBytes!=null&&e.packBytes>e.maxPackBytes?`${(e.packBytes/1e6).toFixed(1)} MB parts pack (limit ${(e.maxPackBytes/1e6).toFixed(0)} MB)`:""].filter(Boolean).join(", ");super(`ldr: model exceeds device budget: ${t}`);this.name="BudgetError",this.bodyTris=e.bodyTris,this.packBytes=e.packBytes,this.maxBodyTris=e.maxBodyTris,this.maxPackBytes=e.maxPackBytes}}async function xt(e,t={}){let n=performance.now(),r=t.fetch??fetch,s=yt(t.cdn??Te,r);s.catch(()=>{});let o=t.text?e:await r(e).then(async(h)=>{if(!h.ok)throw Error(`ldr: ${h.status} fetching ${e}`);return _e(await h.arrayBuffer())}),i=performance.now(),a=t.name??(t.text?"main.ldr":Ke(e)),u=mt(o,a,{looseGeometry:!1,callouts:t.callouts}),c=performance.now();t.onParsed?.(u),await s;let f=ht(o,new Set(u.filter((h)=>h.embedded).map((h)=>h.part)),a),l=(h,P)=>t.maxBodyTris!=null&&h>t.maxBodyTris||t.maxPackBytes!=null&&P>t.maxPackBytes;if(t.maxBodyTris!=null||t.maxPackBytes!=null){let h=fn(u,f,await s);if(l(h.known?h.bodyTris:0,h.packBytes))throw new pe({bodyTris:h.bodyTris,packBytes:h.packBytes,maxBodyTris:t.maxBodyTris,maxPackBytes:t.maxPackBytes})}let{pack:p,missing:d,requests:w,bytes:y}=await ln([...u.filter((h)=>!h.embedded).map((h)=>h.part),...f.values()],t),L=new Map([...f].map(([h,P])=>[P,h])),g=d.map((h)=>L.get(h)??h);for(let[h,P]of f){let A=p.header.parts[P];if(A)p.header.parts[h]=A}let m=performance.now();if(t.maxBodyTris!=null||t.maxPackBytes!=null){let h=p.buffer?.byteLength??p.bytes??0,P=un(u,p);if(l(P,h))throw new pe({bodyTris:P,packBytes:h,maxBodyTris:t.maxBodyTris,maxPackBytes:t.maxPackBytes})}let b=t.cull?Ae(u,p.header,t.textures!==!1):void 0;return{insts:u,pack:p,missing:g,requests:w,bytes:y,cull:b,timings:{fetchModel:i-n,parse:c-i,parts:m-c,...b?{cull:performance.now()-m}:{}}}}self.onmessage=async(e)=>{let{id:t,source:n,opts:r}=e.data;try{let s=await xt(n,{...r,cull:!1,onParsed:(f)=>self.postMessage({id:t,insts:f})}),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(),a=Ae(s.insts,s.pack.header,r.textures!==!1),u=performance.now()-i,c=[];for(let f of[a.studHidden,a.studUp,a.underHidden,a.studHideStep,a.underHideStep])if(f)c.push(f.buffer);self.postMessage({id:t,cull:a,ms:u},c)}catch(s){if(s instanceof pe||s?.code==="ldr-budget")self.postMessage({id:t,phase:"error",error:String(s?.message??s),budget:{bodyTris:s.bodyTris,packBytes:s.packBytes,maxBodyTris:s.maxBodyTris,maxPackBytes:s.maxPackBytes}});else self.postMessage({id:t,phase:"error",error:String(s?.message??s)})}};\n';
|
|
4163
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/load-worker.gen.ts
|
|
4164
|
+
var load_worker_gen_default = 'var vt=ArrayBuffer,Z=Uint8Array,de=Uint16Array,Ct=Int16Array;var be=Int32Array,Le=function(e,t,n){if(Z.prototype.slice)return Z.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 Z(n-t);return r.set(e.subarray(t,n)),r},ce=function(e,t,n,r){if(Z.prototype.fill)return Z.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},Tt=function(e,t,n,r){if(Z.prototype.copyWithin)return Z.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 Lt=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],J=function(e,t,n){var r=Error(t||Lt[e]);if(r.code=e,Error.captureStackTrace)Error.captureStackTrace(r,J);if(!n)throw r;return r},Ke=function(e,t,n){var r=0,s=0;for(;r<n;++r)s|=e[t++]<<(r<<3);return s},Et=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},St=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,a=r>>6;if(r&8)J(0);var u=6-s,c=i==3?4:i,f=Ke(e,u,c);u+=c;var l=a?1<<a:s,p=Ke(e,u,l)+(a==1&&256),d=p;if(!s){var w=1<<10+(e[5]>>3);d=w+(w>>3)*(e[5]&7)}if(d>2145386496)J(1);var y=new Z((t==1?p||d:t?0:d)+12);return y[0]=1,y[4]=4,y[8]=8,{b:u+l,y:0,l:0,d:f,w:t&&t!=1?t:y.subarray(12),e:d,o:new be(y.buffer,0,3),u:p,c:o,m:Math.min(131072,d)}}else if((n>>4|e[3]<<20)==25481893)return Et(e,4)+8;J(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)J(3);var o=1<<s,i=o,a=-1,u=-1,c=-1,f=o,l=new vt(512+(o<<2)),p=new Ct(l,0,256),d=new de(l,0,256),w=new de(l,512,o),y=512+(o<<1),L=new Z(l,y,o),g=new Z(l,y+o);while(a<255&&i>0){var m=re(i+1),b=r>>3,h=(1<<m+1)-1,P=(e[b]|e[b+1]<<8|e[b+2]<<16)>>(r&7)&h,A=(1<<m)-1,E=h-i-1,T=P&A;if(T<E)r+=m,P=T;else if(r+=m+1,P>A)P-=E;if(p[++a]=--P,P==-1)i+=P,L[--f]=a;else i-=P;if(!P)do{var B=r>>3;u=(e[B]|e[B+1]<<8)>>(r&7)&3,r+=2,a+=u}while(u==3)}if(a>255||i)J(0);var v=0,F=(o>>1)+(o>>3)+3,Y=o-1;for(var _=0;_<=a;++_){var C=p[_];if(C<1){d[_]=-C;continue}for(c=0;c<C;++c){L[v]=_;do v=v+F&Y;while(v>=f)}}if(v)J(0);for(c=0;c<o;++c){var M=d[L[c]]++,k=g[c]=s-re(M);w[c]=(M<<k)-o}return[r+7>>3,{b:s,s:L,n:g,t:w}]},Pt=function(e,t){var n=0,r=-1,s=new Z(292),o=e[t],i=s.subarray(0,256),a=s.subarray(256,268),u=new de(s.buffer,268);if(o<128){var c=ue(e,t+1,6),f=c[0],l=c[1];t+=o;var p=f<<3,d=e[t];if(!d)J(0);var w=0,y=0,L=l.b,g=L,m=(++t<<3)-8+re(d);for(;;){if(m-=L,m<p)break;var b=m>>3;if(w+=(e[b]|e[b+1]<<8)>>(m&7)&(1<<L)-1,i[++r]=l.s[w],m-=g,m<p)break;b=m>>3,y+=(e[b]|e[b+1]<<8)>>(m&7)&(1<<g)-1,i[++r]=l.s[y],L=l.n[w],w=l.t[w],g=l.n[y],y=l.t[y]}if(++r>255)J(0)}else{r=o-127;for(;n<r;n+=2){var h=e[++t];i[n]=h>>4,i[n+1]=h&15}++t}var P=0;for(n=0;n<r;++n){var A=i[n];if(A>11)J(0);P+=A&&1<<A-1}var E=re(P)+1,T=1<<E,B=T-P;if(B&B-1)J(0);i[r++]=re(B)+1;for(n=0;n<r;++n){var A=i[n];++a[i[n]=A&&E+1-A]}var v=new Z(T<<1),F=v.subarray(0,T),Y=v.subarray(T);u[E]=0;for(n=E;n>0;--n){var _=u[n];ce(Y,n,_,u[n-1]=_+a[n]*(1<<E-n))}if(u[0]!=T)J(0);for(n=0;n<r;++n){var C=i[n];if(C){var M=u[C];ce(F,n,M,u[C]=M+(1<<E-C))}}return[t,{n:Y,b:E,s:F}]},kt=ue(new Z([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],It=ue(new Z([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],Bt=ue(new Z([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],We=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},Ee=new Z(new be([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),Ft=We(Ee,0),Se=new Z(new be([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),Rt=We(Se,3),le=function(e,t,n){var r=e.length,s=t.length,o=e[r-1],i=(1<<n.b)-1,a=-n.b;if(!o)J(0);var u=0,c=n.b,f=(r<<3)-8+re(o)-c,l=-1;for(;f>a&&l<s;){var p=f>>3,d=(e[p]|e[p+1]<<8|e[p+2]<<16)>>(f&7);u=(u<<c|d)&i,t[++l]=n.s[u],f-=c=n.n[u]}if(f!=a||l+1!=s)J(0)},Dt=function(e,t,n){var r=6,s=t.length,o=s+3>>2,i=o<<1,a=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,a),n),le(e.subarray(r),t.subarray(a),n)},Ut=function(e,t,n){var r,s=t.b,o=e[s],i=o>>1&3;t.l=o&1;var a=o>>3|e[s+1]<<5|e[s+2]<<13,u=(s+=3)+a;if(i==1){if(s>=e.length)return;if(t.b=s+1,n)return ce(n,e[s],t.y,t.y+=a),n;return ce(new Z(a),e[s])}if(u>e.length)return;if(i==0){if(t.b=u,n)return n.set(e.subarray(s,u),t.y),t.y+=a,n;return Le(e,s,u)}if(i==2){var c=e[s],f=c&3,l=c>>2&3,p=c>>4,d=0,w=0;if(f<2)if(l&1)p|=e[++s]<<4|(l&2&&e[++s]<<12);else p=c>>3;else if(w=l,l<2)p|=(e[++s]&63)<<4,d=e[s]>>6|e[++s]<<2;else if(l==2)p|=e[++s]<<4|(e[++s]&3)<<12,d=e[s]>>2|e[++s]<<6;else p|=e[++s]<<4|(e[++s]&63)<<12,d=e[s]>>6|e[++s]<<2|e[++s]<<10;++s;var y=n?n.subarray(t.y,t.y+t.m):new Z(t.m),L=y.length-p;if(f==0)y.set(e.subarray(s,s+=p),L);else if(f==1)ce(y,e[s++],L);else{var g=t.h;if(f==2){var m=Pt(e,s);d+=s-(s=m[0]),t.h=g=m[1]}else if(!g)J(0);(w?Dt:le)(e.subarray(s,s+=d),y.subarray(L),g)}var b=e[s++];if(b){if(b==255)b=(e[s++]|e[s++]<<8)+32512;else if(b>127)b=b-128<<8|e[s++];var h=e[s++];if(h&3)J(0);var P=[It,Bt,kt];for(var A=2;A>-1;--A){var E=h>>(A<<1)+2&3;if(E==1){var T=new Z([0,0,e[s++]]);P[A]={s:T.subarray(2,3),n:T.subarray(0,1),t:new de(T.buffer,0,1),b:0}}else if(E==2)r=ue(e,s,9-(A&1)),s=r[0],P[A]=r[1];else if(E==3){if(!t.t)J(0);P[A]=t.t[A]}}var B=t.t=P,v=B[0],F=B[1],Y=B[2],_=e[u-1];if(!_)J(0);var C=(u<<3)-8+re(_)-Y.b,M=C>>3,k=0,G=(e[M]|e[M+1]<<8)>>(C&7)&(1<<Y.b)-1;M=(C-=F.b)>>3;var I=(e[M]|e[M+1]<<8)>>(C&7)&(1<<F.b)-1;M=(C-=v.b)>>3;var N=(e[M]|e[M+1]<<8)>>(C&7)&(1<<v.b)-1;for(++b;--b;){var j=Y.s[G],X=Y.n[G],W=v.s[N],S=v.n[N],x=F.s[I],R=F.n[I];M=(C-=x)>>3;var D=1<<x,U=D+((e[M]|e[M+1]<<8|e[M+2]<<16|e[M+3]<<24)>>>(C&7)&D-1);M=(C-=Se[W])>>3;var H=Rt[W]+((e[M]|e[M+1]<<8|e[M+2]<<16)>>(C&7)&(1<<Se[W])-1);M=(C-=Ee[j])>>3;var z=Ft[j]+((e[M]|e[M+1]<<8|e[M+2]<<16)>>(C&7)&(1<<Ee[j])-1);if(M=(C-=X)>>3,G=Y.t[G]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<X)-1),M=(C-=S)>>3,N=v.t[N]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<S)-1),M=(C-=R)>>3,I=F.t[I]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<R)-1),U>3)t.o[2]=t.o[1],t.o[1]=t.o[0],t.o[0]=U-=3;else{var V=U-(z!=0);if(V){if(U=V==3?t.o[0]-1:t.o[V],V>1)t.o[2]=t.o[1];t.o[1]=t.o[0],t.o[0]=U}else U=t.o[0]}for(var A=0;A<z;++A)y[k+A]=y[L+A];k+=z,L+=z;var O=k-U;if(O<0){var K=-O,q=t.e+O;if(K>H)K=H;for(var A=0;A<K;++A)y[k+A]=t.w[q+A];k+=K,H-=K,O=0}for(var A=0;A<H;++A)y[k+A]=y[O+A];k+=H}if(k!=L)while(L<y.length)y[k++]=y[L++];else k=y.length;if(n)t.y+=k;else y=Le(y,0,k)}else if(n){if(t.y+=p,L)for(var A=0;A<p;++A)y[A]=y[L+A]}else if(L)y=Le(y,L);return t.b=u,y}J(2)},Ot=function(e,t){if(e.length==1)return e[0];var n=new Z(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 ye(e,t){var n=[],r=+!t,s=0,o=0;for(;e.length;){var i=St(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 a=Ut(e,i,t);if(!a)J(5);if(t)i.e=i.y;else n.push(a),o+=a.length,Tt(i.w,0,a.length),i.w.set(a,i.w.length-a.length)}s=i.b+i.c*4}else s=i;e=e.subarray(s)}return Ot(n,o)}async function Nt(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=(r)=>r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);if(t[0]===40&&t[1]===181&&t[2]===47&&t[3]===253)return n(ye(t));if(t[0]===31&&t[1]===139)return new Response(new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip"))).arrayBuffer();return n(t)}async function Xe(e){return new TextDecoder().decode(await Nt(e))}var Ze=(e)=>decodeURIComponent(e.split(/[?#]/)[0].split("/").pop()||"main.ldr").replace(/\\.(zst|gz)$/i,"")||"main.ldr";function xe(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 Q=(e)=>e.trim().toLowerCase().replace(/\\\\/g,"/").replace(/\\/+/g,"/"),ke=/^[A-Za-z][A-Za-z0-9_]*$/,Pe=new Map;function Ie(e){let t=e.toLowerCase(),n=2166136261;for(let s=0;s<t.length;s++)n^=t.charCodeAt(s),n=Math.imul(n,16777619);let r=-1-(n>>>0&1073741823);if(!Pe.has(r))Pe.set(r,t);return r}function Be(e){let t=e.charCodeAt(0)|32;if(t>=97&&t<=122&&ke.test(e))return Ie(e);if(/^0x/i.test(e))return parseInt(e,16);return+e}var Ye=/^~?\\s*moved\\s+to\\s+(.+)$/i,zt=new Set(["FILE","NOFILE","!DATA","!:","STEP","BFC","ROTSTEP","BUFEXCHG","!TEXMAP"]),st=new Set(["part","subpart","primitive","8_primitive","48_primitive","shortcut","helper"]),$t=new Set(["model","submodel","configuration"]),jt=/^(?:!?LDRAW_ORG|Unofficial|Official\\s+LCAD)\\s+(\\S+)/i;function Je(e){let t=jt.exec(e);if(!t)return;let n=t[1].toLowerCase().replace(/^unofficial_/,"");return st.has(n)||$t.has(n)?n:void 0}function Vt(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 _t(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 a=n[2].trim();for(let l=0;l<s;l++)a=a.replace(/^\\S+\\s*/,"");let u=Vt(a);if(!u.length)return null;let c={method:r,p1:i.slice(0,3),p2:i.slice(3,6),p3:i.slice(6,9),texture:u[0]};if(s>=10)c.a=i[9];if(s===11)c.b=i[10];let f=u.findIndex((l,p)=>p>0&&l.toUpperCase()==="GLOSSMAP");if(f>0&&u[f+1])c.glossmap=u[f+1];if(t)c.next=!0;return c}var Ht=(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 Gt(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 f=s();if(f===null)return null;i[c]=+f}while(n<t&&r(e.charCodeAt(n)))n++;if(n>=t)return null;let a=e.slice(n),u=/[ \\t]{2,}|\\t/.test(a)?a.split(/\\s+/).join(" "):a;return{t:1,color:Be(o),m:i,file:Q(u)}}function qe(e){let t=+e[0];if(!(t>=1&&t<=5)||e.length<2)return null;let n=Be(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 ot(e,t="main.ldr",n={}){let r=!!n.geometryText,s=new Map,o=null,i="",a,u=null,c=[],f=null,l=()=>{if(!u)return;let m=Ht(u.chunks.join("")),b=m[0]===137&&m[1]===80&&m[2]===78&&m[3]===71;(a??=new Map).set(Q(u.name),{name:u.name,bytes:m,...b?{mime:"image/png"}:{}}),u=null},p=!0,d=(m)=>{if(l(),o={name:Q(m),cmds:[]},s.set(o.name,o),!i)i=o.name;c=[],f=null,p=!0},w=!1,y=!1,L=()=>{if(y)return;y=!0,s.clear(),o=null,i=""},g=(m,b)=>{if(f){m.tex=f,f=null;return}let h=c[c.length-1];if(!h)return;if(h.fallback){if(!b)m.fallback=!0}else m.tex=h.map};for(let m of e.split(`\n`)){let b=m.trim();if(!b)continue;if(r&&b.charCodeAt(0)>=50&&b.charCodeAt(0)<=53&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)){if(u||w)continue;if(!o)d(t);let E=b.slice(2).trimStart(),T=E.search(/\\s/),B={t:b.charCodeAt(0)-48,color:Be(T<0?E:E.slice(0,T)),p:[],src:b};g(B,!1),o.cmds.push(B),p=!1;continue}if(b.charCodeAt(0)===48&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)){let E=2;while(b.charCodeAt(E)===32||b.charCodeAt(E)===9)E++;let T=E;while(T<b.length&&b.charCodeAt(T)!==32&&b.charCodeAt(T)!==9)T++;let B=b.slice(E,T);if(!zt.has(B)){if(w||u)continue;if(!o)d(t);let v=b.slice(E),F={t:0,text:v};if(B.charCodeAt(0)===33)F.meta=B;if(f=null,p&&!o.org){let _=Je(v);if(_)o.org=_}let Y=v.match(Ye);if(Y&&!o.movedTo){let _=Y[1].trim().replace(/\\\\/g,"/");if(!/\\.(dat|ldr|mpd)$/i.test(_))_+=".dat";o.movedTo=Q(_)}o.cmds.push(F);continue}}if(b.charCodeAt(0)===49&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)&&!u&&!w){let E=Gt(b);if(E){if(!o)d(t);g(E,!1),o.cmds.push(E),p=!1;continue}}let h=b.split(/\\s+/);if(+h[0]===0){let E=b.slice(1).trim();if(h[1]==="FILE"){L(),w=!1,d(E.slice(5));continue}if(h[1]==="NOFILE"){l(),o=null,w=!0;continue}if(h[1]==="!DATA"){L(),l(),o=null,w=!1,u={name:E.slice(5).trim(),chunks:[]};continue}if(w)continue;if(u){if(h[1]==="!:")u.chunks.push(h.slice(2).join(""));continue}if(!o)d(t);let T={t:0,text:E};if(h[1]==="STEP")T.step=!0,c=[],f=null;else if(h[1]==="BFC")T.bfc=h.slice(2).join(" ");else if(h[1]==="ROTSTEP")if(T.meta="ROTSTEP",T.step=!0,c=[],f=null,(h[2]??"").toUpperCase()==="END")T.rotstep={x:0,y:0,z:0,mode:"END"};else{let v=(h[5]??"REL").toUpperCase();T.rotstep={x:+h[2]||0,y:+h[3]||0,z:+h[4]||0,mode:["REL","ABS","ADD"].includes(v)?v:"REL"}}else if(h[1]==="BUFEXCHG"){T.meta="BUFEXCHG";let v=(h[2]??"").toUpperCase();T.bufexchg={op:v==="RETRIEVE"?"RETRIEVE":"STORE",buf:h[3]??"A"}}else if(h[1]?.startsWith("!"))T.meta=h[1];if(p&&!o.org){let v=Je(E);if(v)o.org=v}if(h[1]==="!TEXMAP"){let v=(h[2]??"").toUpperCase();if(f=null,v==="START"||v==="NEXT"){let F=_t(E.replace(/^!TEXMAP\\s+\\S+/i,""),v==="NEXT");if(T.texmap={op:v,...F?{map:F}:{}},F)if((o.texmaps??=[]).push(F),v==="START")c.push({map:F,fallback:!1});else f=F}else if(v==="FALLBACK"){T.texmap={op:v};let F=c[c.length-1];if(F)F.fallback=!0}else if(v==="END")T.texmap={op:v},c.pop()}else if(h[1]==="!:"){f=null;let v=qe(h.slice(2));if(v)g(v,!0),T.geom=v}else f=null;let B=E.match(Ye);if(B&&!o.movedTo){let v=B[1].trim().replace(/\\\\/g,"/");if(!/\\.(dat|ldr|mpd)$/i.test(v))v+=".dat";o.movedTo=Q(v)}o.cmds.push(T);continue}if(u||w)continue;if(!o)d(t);let A=qe(h);if(!A)continue;g(A,!1),o.cmds.push(A),p=!1}return l(),a?{main:i,files:s,data:a}:{main:i,files:s}}var yn=Math.PI/180;function it(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 at(e,t){let[n,r,s,o,i,a,u,c,f,l,p,d]=e,[w,y,L,g,m,b,h,P,A,E,T,B]=t;return[o*w+i*y+a*L+n,u*w+c*y+f*L+r,l*w+p*y+d*L+s,o*g+i*h+a*E,o*m+i*P+a*T,o*b+i*A+a*B,u*g+c*h+f*E,u*m+c*P+f*T,u*b+c*A+f*B,l*g+p*h+d*E,l*m+p*P+d*T,l*b+p*A+d*B]}var Fe=[0,0,0,1,0,0,0,1,0,0,0,1];var Qe=new WeakMap,Kt=/^(s|8|48)\\//;function Re(e,t){let n=e.files.get(Q(t));if(!n)return"part";let r=Qe.get(n);if(r)return r;if(n.org)r=st.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&&Kt.test(s.file))?"part":"model";return Qe.set(n,r),r}var et=new WeakMap;function lt(e){let t=et.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 et.set(e,t),t}var tt=(e)=>e>16777215?"0x"+e.toString(16).toUpperCase():e<0?Pe.get(e)??String(e):String(e),Wt=(e)=>e.t===0?"0 "+e.text:e.t===1?`1 ${tt(e.color)} ${e.m.join(" ")} ${e.file}`:e.src?e.src:`${e.t} ${tt(e.color)} ${e.p.join(" ")}`,De=(e,t)=>`${Q(e)}#${t}`;function Xt(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:De(e.name,t),cmds:n}}function ct(e,t){return[`0 ldr: own geometry of ${e.name}, step ${t}`,...Xt(e,t).cmds.map(Wt)].join(`\n`)+`\n`}function Zt(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 ut(e){let[t,n,r,s,o,i,a,u,c,f,l,p]=e,d=u*p-c*l,w=-(a*p-c*f),y=a*l-u*f,L=s*d+o*w+i*y;if(!Number.isFinite(L)||Math.abs(L)<0.000000000001)return null;let g=1/L,m=[d*g,-(o*p-i*l)*g,(o*c-i*u)*g,w*g,(s*p-i*f)*g,-(s*c-i*a)*g,y*g,-(s*l-o*f)*g,(s*u-o*a)*g];return[-(m[0]*t+m[1]*n+m[2]*r),-(m[3]*t+m[4]*n+m[5]*r),-(m[6]*t+m[7]*n+m[8]*r),...m]}var Yt=(e)=>String(+e.toFixed(6)||0),nt=(e)=>\'"\'+e.replace(/\\\\/g,"\\\\\\\\").replace(/"/g,"\\\\\\"")+\'"\';function ft(e,t){let n=[...t.p1,...t.p2,...t.p3,...t.method!=="PLANAR"?[t.a??360]:[],...t.method==="SPHERICAL"?[t.b??180]:[]].map(Yt).join(" "),r=`0 ldr: ${e} with a model-level !TEXMAP\n0 BFC CERTIFY CCW\n0 !TEXMAP START ${t.method} ${n} ${nt(t.texture)}${t.glossmap?" GLOSSMAP "+nt(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-${Zt(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 qt(e,t,n){let r=Math.PI/180,s=Math.sin(e*r),o=Math.cos(e*r),i=Math.sin(t*r),a=Math.cos(t*r),u=Math.sin(n*r),c=Math.cos(n*r);return[a*c,-a*u,i,o*u+s*i*c,o*c-s*i*u,-s*a,s*u-o*i*c,s*c+o*i*u,o*a]}var rt=new WeakMap;function pt(e){let t=rt.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=qt(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),rt.set(e,n),n}var mt=999999,gt=(e)=>e.map((t)=>String(t).padStart(6,"0")).join(".")+"~";function Qt(e,t={}){let n=[],r=t.maxDepth??64,s=t.looseGeometry!==!1,o=!!t.textures,i=!!t.callouts,a=new Map,u=0,c=(l,p)=>{let d=l.name+"#"+p,w=a.get(d);if(!w){let y;w=Object.assign(()=>y??=ct(l,p),{file:l,step:p}),a.set(d,w)}return w},f=(l,p,d,w,y,L,g,m,b=null,h=[],P=[],A=void 0,E=null)=>{let T=l.files.get(p);if(!T||g>r)return;let B=E,v=0,F=g>0?++u:0,Y=i&&F?[...h,F]:h,_=i&&F?[...P,d]:P,C=i&&!b?new Map:null,M=-1,k=0,G=(S,x,R,D,U,H,z)=>{if(M!==v)M=v,k=0;let V=C?.get(v+"|"+x);if(V)return V.n++,f(S,S===l?x:S.main,R,D,y+"/"+x,[...U,mt],g+1,H,[...U,mt],Y,_,z,B);let O=[...U,k++],K=n.length;f(S,S===l?x:S.main,R,D,y+"/"+x,O,g+1,H,b,Y,_,z,B),C?.set(v+"|"+x,{n:1,from:K,to:n.length})},I=pt(T),N=s?lt(T):[],j=0,X=(S,x,R,D,U,H,z,V)=>{if(b)D=b;let O={part:S,color:x,m:R,step:D[0],steps:D,localStep:U,path:y};if(V)O.colour=V;if(F){if(O.sub=F,i)O.subPath=Y,O.subMats=_}if(H)O.embedded=!0;if(z){let q=ft(S,z);O.texPart=q.name,O.texSource=q.source}let K=I[U];if(K)O.view=K;return n.push(O),O},W=(S)=>{while(j<N.length&&N[j]<=S){let x=N[j++];X(De(T.name,x),w,d,[...L,x],x,!1,null,A).source=c(T,x)}};for(let S of T.cmds){if(S.t===0&&S.step){v++;continue}let x=S;if(x.t>=2||x.t===0&&x.geom&&x.geom.t>=2){W(v);continue}if(x.t===0){if(x.meta==="!COLOUR"){let q=tn(x.text);if(q&&q.code!==16&&q.code!==24)(B=new Map(B??[])).set(q.code,q);continue}if(o&&x.geom?.t===1)x=x.geom;else continue}if(x.t!==1)continue;if(o&&x.fallback)continue;let R=x.color===16?w:x.color,D=x.color===16?A:B?.get(x.color),U=at(d,x.m),H=[...L,v],z=o?x.tex??m:null,V=z?ut(x.m):null,O=z&&V?it(z,V):null;if(l.files.has(x.file)){if(Re(l,x.file)==="model"){G(l,x.file,U,R,H,O,D);continue}X(x.file,R,U,H,v,!0,O,D);continue}let K=t.resolveModel?.(x.file);if(K){G(K,x.file,U,R,H,O,D);continue}X(x.file,R,U,H,v,!1,O,D)}if(W(1/0),C){for(let S of C.values())if(S.n>1)for(let x=S.from;x<S.to;x++)n[x].mult??=S.n}};if(Re(e,e.main)==="part"){if(e.files.get(e.main))n.push({part:e.main,color:16,m:[...Fe],step:0,steps:[0],localStep:0,path:e.main,embedded:!0});return n}return f(e,e.main,Fe,16,e.main,[],0,null),n}function dt(e,t="main.ldr",n){return Qt(ot(e,t,{geometryText:!0}),n)}var en=new Set(["CHROME","PEARLESCENT","RUBBER","MATTE_METALLIC","METAL","MATERIAL"]);function Ue(e){if(!e)return null;if(e.startsWith("#")&&/^#[0-9A-Fa-f]{6}$/.test(e))return e.toUpperCase();if(/^0x[0-9A-Fa-f]{6}$/i.test(e))return("#"+e.slice(2)).toUpperCase();return null}function ht(e,t){let n={value:"#FFFFFF",fraction:0.5};while(t<e.length){let r=e[t].toUpperCase(),s=e[t+1];if(r==="VALUE"){let o=Ue(s);if(o)n.value=o;t+=2}else if(r==="ALPHA")n.alpha=+s,t+=2;else if(r==="LUMINANCE")n.luminance=+s,t+=2;else if(r==="FRACTION")n.fraction=+s,t+=2;else if(r==="VFRACTION")n.vfraction=+s,t+=2;else if(r==="SIZE")n.size=+s,t+=2;else if(r==="MINSIZE")n.minsize=+s,t+=2;else if(r==="MAXSIZE")n.maxsize=+s,t+=2;else break}return{grain:n,next:t}}function tn(e){let t=e.indexOf("!COLOUR");if(t<0)return null;let n=e.slice(t+7).trim().split(/\\s+/).filter(Boolean);if(n.length<2)return null;let r=n[0],s=NaN,o="#FF00FF",i="#333333",a=255,u=0,c={type:"default"},f=1;while(f<n.length){let l=n[f].toUpperCase(),p=n[f+1];if(l==="CODE")s=p!==void 0&&ke.test(p)?Ie(p):p!==void 0&&/^\\d+$/.test(p)?+p:NaN,f+=2;else if(l==="VALUE"){let d=Ue(p);if(d)o=d;f+=2}else if(l==="EDGE")i=Ue(p)??p,f+=2;else if(l==="ALPHA")a=+p,f+=2;else if(l==="LUMINANCE")u=+p,f+=2;else if(l==="CHROME")c={type:"chrome"},f+=1;else if(l==="PEARLESCENT")c={type:"pearlescent"},f+=1;else if(l==="RUBBER")c={type:"rubber"},f+=1;else if(l==="MATTE_METALLIC")c={type:"matte_metallic"},f+=1;else if(l==="METAL")c={type:"metal"},f+=1;else if(l==="MATERIAL"){let d=(n[f+1]||"").toUpperCase();if(d==="GLITTER"){let{grain:w,next:y}=ht(n,f+2);c={type:"glitter",material:w},f=y}else if(d==="SPECKLE"){let{grain:w,next:y}=ht(n,f+2);c={type:"speckle",material:w},f=y}else if(d==="FABRIC"){let w=(n[f+2]||"").toUpperCase(),y=["VELVET","CANVAS","STRING","FUR"].includes(w)?w.toLowerCase():void 0;c={type:"fabric",kind:y},f+=y?3:2}else f=n.length}else if(en.has(l))f+=1;else f+=1}if(Number.isNaN(s)||!o)return null;return{code:s,name:r,hex:o,edge:i,alpha:Number.isFinite(a)?a:255,luminance:Number.isFinite(u)?u:0,finish:c}}function nn(e){let t=Math.max(0,Math.min(1,(e.alpha??255)/255)),n=t<1,r=Math.max(0,Math.min(1,(e.luminance??0)/255)),s={opacity:t,transparent:n,depthWrite:!n,emissive:r,clearcoat:0,clearcoatRoughness:0,sheen:0,sheenRoughness:0};switch(e.finish?.type??"default"){case"chrome":return{...s,metalness:1,roughness:0,finish:"chrome"};case"pearlescent":return{...s,metalness:0.25,roughness:0.3,clearcoat:0.5,clearcoatRoughness:0.25,sheen:0.4,sheenRoughness:0.35,finish:"pearlescent"};case"rubber":return{...s,metalness:0,roughness:0.9,finish:"rubber"};case"matte_metallic":return{...s,metalness:0.4,roughness:0.8,finish:"matte_metallic"};case"metal":return{...s,metalness:0.85,roughness:0.2,finish:"metal"};case"glitter":{let i=e.finish.material,a=i.size??(i.minsize!=null&&i.maxsize!=null?(i.minsize+i.maxsize)/2:1);return{...s,metalness:0.35,roughness:0.25,clearcoat:1,clearcoatRoughness:0.08,particleHex:i.value,particleFraction:i.fraction,particleSize:a,finish:"glitter"}}case"speckle":{let i=e.finish.material,a=i.size??(i.minsize!=null&&i.maxsize!=null?(i.minsize+i.maxsize)/2:1);return{...s,metalness:0.2,roughness:0.55,particleHex:i.value,particleFraction:i.fraction,particleSize:a,finish:"speckle"}}case"fabric":return{...s,metalness:0,roughness:0.85,sheen:0.65,sheenRoughness:0.75,finish:"fabric"};default:return{...s,metalness:0,roughness:0.45,finish:"default"}}}function Oe(e){let t=nn(e),n=!t.transparent?"op":t.opacity>=0.75?"a200":t.opacity>=0.4?"a128":`a${Math.round(t.opacity*255)}`,r=t.emissive>0?`L${Math.round(t.emissive*16)}`:"",s=`${t.finish}:${n}${r}`;if(t.particleHex)s+=`:${t.particleHex}:${(t.particleFraction??0).toFixed(2)}`;return s}function rn(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(Q(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(Q(t),r)}let a=o.trim().replace(/\\s+/g," ");if(a)r.push(a)}return n}var sn=(e)=>{if(!e.startsWith("1 "))return null;let t=e.split(" ");return t.length>=15?Q(t.slice(14).join(" ")):null};function on(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 bt(e,t,n="main.ldr"){let r=rn(e,n),s=new Map;for(let o of t){let i=Q(o);if(!r.has(i)||s.has(i))continue;let a=new Set([i]),u=[i];while(u.length)for(let f of r.get(u.pop())){let l=sn(f);if(l&&r.has(l)&&!a.has(l))a.add(l),u.push(l)}let c=[i,...[...a].filter((f)=>f!==i).sort()].map((f)=>"0 FILE "+(f===i?"":f)+`\n`+r.get(f).join(`\n`)).join(`\n`);s.set(i,`emb/${on(c)}.dat`)}return s}var yt=(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,xt=new WeakMap;function Ne(e,t){let n=xt.get(e);if(!n)xt.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),a=[],u=[];s.studs.forEach((p,d)=>{a.push(p[0]),u.push(p[1]);for(let w=0;w<12;w++)i[d*12+w]=p[2+w]});let c=null,f=0,l=0;if(s.mask){f=s.mask[0],l=s.mask[1];let p=s.mask[2];c=new Uint8Array(p.length);for(let d=0;d<p.length;d++)c[d]=p.charCodeAt(d)===49?1:0}return n.set(t,r={nStuds:o,studM:i,kind:a,color:u,mask:c,nx:f,nz:l}),r}var ie=1073741824;class ze{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,a=this.c;for(;;){if(!s[r])return-1;if(o[r]===e&&i[r]===t&&a[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,a=this.b,u=this.c;for(;;){if(!o[s])return o[s]=1,i[s]=e,a[s]=t,u[s]=n,this.vals[s]=r,this.size++,-1;if(i[s]===e&&a[s]===t&&u[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 we=(e,t,n)=>e>-ie&&e<ie&&t>-ie&&t<ie&&n>-ie&&n<ie,fe=2147483647;function an(e,t,n){let s=[],o=[],i=[],a=[],u=[],c=[],f=[],l=[],p=new ze(e.length*2),d=[],w=[];for(let C=0;C<e.length;C++){let M=e[C],k=M.m,G=t.parts[M.part];if(!G||!G.mask||!yt(k))continue;let I=G.bbox,N=1/0,j=-1/0,X=1/0,W=-1/0;for(let R=0;R<2;R++)for(let D=0;D<2;D++){let U=R?I[3]:I[0],H=D?I[5]:I[2],z=k[0]+k[3]*U+k[5]*H,V=k[2]+k[9]*U+k[11]*H;if(z<N)N=z;if(z>j)j=z;if(V<X)X=V;if(V>W)W=V}let S=u.length;s.push(N),o.push(j),i.push(X),a.push(W),u.push(C),c.push(Ne(t,M.part)),f.push(I[0]),l.push(I[2]);let x=Math.round((k[1]+I[4])*2);for(let R=Math.floor(N/40);R<=Math.floor(j/40);R++)for(let D=Math.floor(X/40);D<=Math.floor(W/40);D++){if(!we(x,R,D))continue;let U=w.length;w.push(S),d.push(p.put(x,R,D,U))}}let y=[0,5,-5,5,-5],L=[0,5,5,-5,-5],g=NaN,m=NaN,b=NaN,h=-1,P=(C,M,k,G)=>{let I=Math.round(M*2),N=Math.floor(C/40),j=Math.floor(k/40);if(!we(I,N,j))return fe;let X=fe;if(I!==g||N!==m||j!==b)g=I,m=N,b=j,h=p.get(I,N,j);for(let W=h;W>=0;W=d[W]){let S=w[W];if(u[S]===G||!(C-6>=s[S]-0.5&&C+6<=o[S]+0.5&&k-6>=i[S]-0.5&&k+6<=a[S]+0.5))continue;let x=e[u[S]].m,R=c[S],D=f[S],U=l[S],H=C-x[0],z=M-x[1],V=k-x[2],O=x[3]*H+x[6]*z+x[9]*V,K=x[5]*H+x[8]*z+x[11]*V,{nx:q,nz:se,mask:ae}=R,oe=!0;for(let ee=0;ee<5;ee++){let te=Math.floor((O+y[ee]-D)/20),ne=Math.floor((K+L[ee]-U)/20);if(te<0||ne<0||te>=q||ne>=se||ae[te*se+ne]!==1){oe=!1;break}}if(oe){if(!n)return 0;let ee=n[u[S]];if(ee<X)X=ee}}return X},A=0;for(let C of e){let M=Ne(t,C.part);if(M)A+=M.nStuds}let E=new Uint8Array(A),T=new Uint8Array(A),B=new ze(A),v=0,F=n?new Int32Array(A).fill(fe):void 0;for(let C=0,M=0;C<e.length;C++){let k=e[C],G=Ne(t,k.part);if(!G)continue;let I=k.m,N=G.studM,j=I[0],X=I[1],W=I[2],S=I[3],x=I[4],R=I[5],D=I[6],U=I[7],H=I[8],z=I[9],V=I[10],O=I[11];for(let K=0;K<G.nStuds;K++,M++){let q=K*12,se=N[q+4],ae=N[q+7],oe=N[q+10];if(!(Math.abs(D*se+U*ae+H*oe-1)<0.001&&Math.abs(S*se+x*ae+R*oe)<0.001&&Math.abs(z*se+V*ae+O*oe)<0.001))continue;T[M]=1;let ee=N[q],te=N[q+1],ne=N[q+2],$e=j+S*ee+x*te+R*ne,je=X+D*ee+U*te+H*ne,Ve=W+z*ee+V*te+O*ne,_e=P($e,je,Ve,C);if(_e!==fe){if(E[M]=1,v++,F)F[M]=_e}let me=Math.round($e),he=Math.round(je),ge=Math.round(Ve);if(!we(me,he,ge))continue;if(!n){B.put(me,he,ge,1);continue}let He=n[C],Ge=B.get(me,he,ge);if(Ge<0||He<Ge)B.put(me,he,ge,He)}}let Y=new Uint8Array(e.length),_=n?new Int32Array(e.length).fill(fe):void 0;for(let C=0;C<e.length;C++){let M=e[C],k=t.parts[M.part];if(!k||!k.under||!yt(M.m))continue;let G=k.bbox,I=Math.round((G[3]-G[0])/20),N=Math.round((G[5]-G[2])/20);if(!I||!N||I*N>4096)continue;let j=M.m,X=!0,W=0;for(let S=0;S<I&&X;S++)for(let x=0;x<N;x++){let R=G[0]+10+20*S,D=G[2]+10+20*x,U=j[0]+j[3]*R+j[5]*D,H=j[2]+j[9]*R+j[11]*D,z=Math.round(U),V=Math.round(j[1]+G[4]),O=Math.round(H),K=we(z,V,O)?B.get(z,V,O):-1;if(K<0){X=!1;break}if(K>W)W=K}if(X){if(Y[C]=1,_)_[C]=W}}return{nStuds:A,studHidden:E,studUp:T,underHidden:Y,studsHidden:v,studHideStep:F,underHideStep:_}}function ln(e,t,n){let r=(l)=>n&&l.texPart&&t.parts[l.texPart]?l.texPart:l.part,s=new Map,o=new Map,i=(l)=>{let p=l.colour;if(!p)return String(l.color);let d=o.get(p);if(d!==void 0)return d;let w=t.colorTable?.[l.color],y=w?.hex??t.colors?.[l.color],L=w?Oe({alpha:w.alpha??255,luminance:w.luminance??0,finish:w.finish??{type:"default"}}):"default:op",g=Oe(p);if(d=y&&y.toUpperCase()===p.hex.toUpperCase()&&L===g?String(l.color):p.hex.toUpperCase()+"/"+g,d!==String(l.color))s.set(d,p);return o.set(p,d),d},a=e.map((l)=>({part:r(l),color:i(l),m:l.m,steps:l.steps})),u=a.map((l)=>gt(l.steps)),c=[...new Set(u)].sort(),f=new Map(c.map((l,p)=>[l,p]));return{all:a,stepOf:u.map((l)=>f.get(l)),nSteps:c.length,localColours:s}}function Ae(e,t,n=!0){let r=ln(e,t,n);return an(r.all,t,r.nSteps>1?r.stepOf:void 0)}var Te="https://ldr-demo.vercel.app/cdn/v1/",ve=new Map,Me=new Map;function At(e=Te,t=fetch){let n=ve.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(()=>ve.delete(e)),ve.set(e,n);return n}var cn=(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"),Ce=(e,t)=>cn(e)?[e[0]+t,e[1],e[2]]:Array.isArray(e)?e.map((n)=>Ce(n,t)):e&&typeof e==="object"?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,Ce(r,t)])):e;function un(e,t={}){let n=[],r=0,s={},o={};for(let p of e){let d=p.buffer;if(!d)throw Error("ldr: mergePacks needs packs from decodePack/loadPack");let w=new DataView(d).getUint32(0,!0),y=new Uint8Array(d,4+w),L=r;n.push(y),r+=y.byteLength;let g=(4-r%4)%4;if(g)n.push(new Uint8Array(g)),r+=g;for(let[m,b]of Object.entries(p.header.parts??{}))if(!(m in s))s[m]=Ce(b,L);for(let[m,b]of Object.entries(p.header.studKinds??{}))if(!(m in o))o[m]=Ce(b,L)}let i=e[0]?.header??{version:1,weld:!0},a=new TextEncoder().encode(JSON.stringify({...i,parts:s,studKinds:o,...t})),u=(4-(4+a.length)%4)%4,c=4+a.length+u,f=new Uint8Array(c+r);new DataView(f.buffer).setUint32(0,a.length+u,!0),f.set(a,4),f.fill(32,4+a.length,c);let l=c;for(let p of n)f.set(p,l),l+=p.byteLength;return xe(f.buffer)}async function fn(e,t={}){e=[...e];try{return await wt(e,t)}catch(n){let r=t.cdn??Te,s=t.fetch??fetch;ve.delete(r);let o=(i,a)=>s(i,{...a,cache:"reload"});try{return await wt(e,{...t,fetch:o})}catch{throw n}}}async function wt(e,t){let n=t.cdn??Te,r=t.fetch??fetch,s=t.gap??16384,o=await At(n,r),i=[...new Set([...e].map(Q))],a=[],u=[];for(let g of i){if(Me.has(n+g))continue;let m=o.parts[g];if(m)u.push({name:g,off:m[0],len:m[1],file:m[2]??0});else a.push(g)}u.sort((g,m)=>g.file-m.file||g.off-m.off);let c=[];for(let g of u){let m=c[c.length-1];if(m&&m.file===g.file&&g.off-m.end<=s)m.end=Math.max(m.end,g.off+g.len),m.items.push(g);else c.push({file:g.file,start:g.off,end:g.off+g.len,items:[g]})}let f=0,l=0,p=0,d=new Map,w=async()=>{while(p<c.length){let g=c[p++],m=d.get(g.file);if(m)m=m.subarray(g.start,g.end);else{let b=await r(new URL(o.archives[g.file],n).href,{headers:{Range:`bytes=${g.start}-${g.end-1}`,"Accept-Encoding":"identity"}});if(!b.ok)throw Error(`ldr: parts CDN ${b.status}`);if(l++,m=new Uint8Array(await b.arrayBuffer()),f+=m.byteLength,b.status===200)d.set(g.file,m),m=m.subarray(g.start,g.end)}for(let b of g.items){let h=ye(m.subarray(b.off-g.start,b.off-g.start+b.len)),P=h.buffer.slice(h.byteOffset,h.byteOffset+h.byteLength);Me.set(n+b.name,xe(P))}}};await Promise.all(Array.from({length:Math.min(t.concurrency??24,c.length)},w));let y=i.filter((g)=>Me.has(n+g)).map((g)=>Me.get(n+g));return{pack:y.length?un(y,{colors:o.colors}):xe(pn(o.colors)),missing:a,requests:l,bytes:f}}function pn(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}function mn(e,t){let n=t.header.parts;if(!n)return 0;let r=0;for(let s of e){let o=n[s.part]?.body?.tris;if(o)r+=o}return r}function hn(e,t,n){let r=0,s=0,o=!1,i=new Set;for(let a of e){let u=a.embedded?t.get(a.part):Q(a.part),c=u?n.parts[u]:void 0;if(!c)continue;if(c[3]!=null)o=!0,r+=c[3];if(!i.has(u))i.add(u),s+=c[1]}return{bodyTris:r,packBytes:s,known:o}}class pe extends Error{code="ldr-budget";bodyTris;packBytes;maxBodyTris;maxPackBytes;constructor(e){let t=[e.maxBodyTris!=null&&e.bodyTris>e.maxBodyTris?`${e.bodyTris} triangles (limit ${e.maxBodyTris})`:"",e.maxPackBytes!=null&&e.packBytes>e.maxPackBytes?`${(e.packBytes/1e6).toFixed(1)} MB parts pack (limit ${(e.maxPackBytes/1e6).toFixed(0)} MB)`:""].filter(Boolean).join(", ");super(`ldr: model exceeds device budget: ${t}`);this.name="BudgetError",this.bodyTris=e.bodyTris,this.packBytes=e.packBytes,this.maxBodyTris=e.maxBodyTris,this.maxPackBytes=e.maxPackBytes}}async function Mt(e,t={}){let n=performance.now(),r=t.fetch??fetch,s=At(t.cdn??Te,r);s.catch(()=>{});let o=t.text?e:await r(e).then(async(h)=>{if(!h.ok)throw Error(`ldr: ${h.status} fetching ${e}`);return Xe(await h.arrayBuffer())}),i=performance.now(),a=t.name??(t.text?"main.ldr":Ze(e)),u=dt(o,a,{looseGeometry:!1,callouts:t.callouts}),c=performance.now();t.onParsed?.(u),await s;let f=bt(o,new Set(u.filter((h)=>h.embedded).map((h)=>h.part)),a),l=(h,P)=>t.maxBodyTris!=null&&h>t.maxBodyTris||t.maxPackBytes!=null&&P>t.maxPackBytes;if(t.maxBodyTris!=null||t.maxPackBytes!=null){let h=hn(u,f,await s);if(l(h.known?h.bodyTris:0,h.packBytes))throw new pe({bodyTris:h.bodyTris,packBytes:h.packBytes,maxBodyTris:t.maxBodyTris,maxPackBytes:t.maxPackBytes})}let{pack:p,missing:d,requests:w,bytes:y}=await fn([...u.filter((h)=>!h.embedded).map((h)=>h.part),...f.values()],t),L=new Map([...f].map(([h,P])=>[P,h])),g=d.map((h)=>L.get(h)??h);for(let[h,P]of f){let A=p.header.parts[P];if(A)p.header.parts[h]=A}let m=performance.now();if(t.maxBodyTris!=null||t.maxPackBytes!=null){let h=p.buffer?.byteLength??p.bytes??0,P=mn(u,p);if(l(P,h))throw new pe({bodyTris:P,packBytes:h,maxBodyTris:t.maxBodyTris,maxPackBytes:t.maxPackBytes})}let b=t.cull?Ae(u,p.header,t.textures!==!1):void 0;return{insts:u,pack:p,missing:g,requests:w,bytes:y,cull:b,timings:{fetchModel:i-n,parse:c-i,parts:m-c,...b?{cull:performance.now()-m}:{}}}}self.onmessage=async(e)=>{let{id:t,source:n,opts:r}=e.data;try{let s=await Mt(n,{...r,cull:!1,onParsed:(f)=>self.postMessage({id:t,insts:f})}),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(),a=Ae(s.insts,s.pack.header,r.textures!==!1),u=performance.now()-i,c=[];for(let f of[a.studHidden,a.studUp,a.underHidden,a.studHideStep,a.underHideStep])if(f)c.push(f.buffer);self.postMessage({id:t,cull:a,ms:u},c)}catch(s){if(s instanceof pe||s?.code==="ldr-budget")self.postMessage({id:t,phase:"error",error:String(s?.message??s),budget:{bodyTris:s.bodyTris,packBytes:s.packBytes,maxBodyTris:s.maxBodyTris,maxPackBytes:s.maxPackBytes}});else self.postMessage({id:t,phase:"error",error:String(s?.message??s)})}};\n';
|
|
4147
4165
|
|
|
4148
|
-
// ../../../../../../../tmp/ldr-build-
|
|
4166
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/cdn.ts
|
|
4149
4167
|
var worker;
|
|
4150
4168
|
var seq = 0;
|
|
4151
4169
|
var pending = new Map;
|
|
@@ -4293,6 +4311,7 @@ export {
|
|
|
4293
4311
|
instanceBoxes,
|
|
4294
4312
|
invert,
|
|
4295
4313
|
isDirectColor,
|
|
4314
|
+
isNamedColor,
|
|
4296
4315
|
isolateMask,
|
|
4297
4316
|
loadModel,
|
|
4298
4317
|
loadPack,
|
|
@@ -4308,6 +4327,7 @@ export {
|
|
|
4308
4327
|
mergePacks,
|
|
4309
4328
|
modelFileName,
|
|
4310
4329
|
mul,
|
|
4330
|
+
namedColorCode,
|
|
4311
4331
|
norm,
|
|
4312
4332
|
packTexture,
|
|
4313
4333
|
parse,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "var wt=ArrayBuffer,Z=Uint8Array,de=Uint16Array,At=Int16Array;var be=Int32Array,Le=function(e,t,n){if(Z.prototype.slice)return Z.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 Z(n-t);return r.set(e.subarray(t,n)),r},ce=function(e,t,n,r){if(Z.prototype.fill)return Z.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},Mt=function(e,t,n,r){if(Z.prototype.copyWithin)return Z.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 vt=[\"invalid zstd data\",\"window size too large (>2046MB)\",\"invalid block type\",\"FSE accuracy too high\",\"match distance too far back\",\"unexpected EOF\"],J=function(e,t,n){var r=Error(t||vt[e]);if(r.code=e,Error.captureStackTrace)Error.captureStackTrace(r,J);if(!n)throw r;return r},He=function(e,t,n){var r=0,s=0;for(;r<n;++r)s|=e[t++]<<(r<<3);return s},Ct=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Tt=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,a=r>>6;if(r&8)J(0);var u=6-s,c=i==3?4:i,f=He(e,u,c);u+=c;var l=a?1<<a:s,p=He(e,u,l)+(a==1&&256),d=p;if(!s){var w=1<<10+(e[5]>>3);d=w+(w>>3)*(e[5]&7)}if(d>2145386496)J(1);var y=new Z((t==1?p||d:t?0:d)+12);return y[0]=1,y[4]=4,y[8]=8,{b:u+l,y:0,l:0,d:f,w:t&&t!=1?t:y.subarray(12),e:d,o:new be(y.buffer,0,3),u:p,c:o,m:Math.min(131072,d)}}else if((n>>4|e[3]<<20)==25481893)return Ct(e,4)+8;J(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)J(3);var o=1<<s,i=o,a=-1,u=-1,c=-1,f=o,l=new wt(512+(o<<2)),p=new At(l,0,256),d=new de(l,0,256),w=new de(l,512,o),y=512+(o<<1),L=new Z(l,y,o),g=new Z(l,y+o);while(a<255&&i>0){var m=re(i+1),b=r>>3,h=(1<<m+1)-1,P=(e[b]|e[b+1]<<8|e[b+2]<<16)>>(r&7)&h,A=(1<<m)-1,S=h-i-1,T=P&A;if(T<S)r+=m,P=T;else if(r+=m+1,P>A)P-=S;if(p[++a]=--P,P==-1)i+=P,L[--f]=a;else i-=P;if(!P)do{var B=r>>3;u=(e[B]|e[B+1]<<8)>>(r&7)&3,r+=2,a+=u}while(u==3)}if(a>255||i)J(0);var v=0,F=(o>>1)+(o>>3)+3,Y=o-1;for(var H=0;H<=a;++H){var C=p[H];if(C<1){d[H]=-C;continue}for(c=0;c<C;++c){L[v]=H;do v=v+F&Y;while(v>=f)}}if(v)J(0);for(c=0;c<o;++c){var M=d[L[c]]++,k=g[c]=s-re(M);w[c]=(M<<k)-o}return[r+7>>3,{b:s,s:L,n:g,t:w}]},Lt=function(e,t){var n=0,r=-1,s=new Z(292),o=e[t],i=s.subarray(0,256),a=s.subarray(256,268),u=new de(s.buffer,268);if(o<128){var c=ue(e,t+1,6),f=c[0],l=c[1];t+=o;var p=f<<3,d=e[t];if(!d)J(0);var w=0,y=0,L=l.b,g=L,m=(++t<<3)-8+re(d);for(;;){if(m-=L,m<p)break;var b=m>>3;if(w+=(e[b]|e[b+1]<<8)>>(m&7)&(1<<L)-1,i[++r]=l.s[w],m-=g,m<p)break;b=m>>3,y+=(e[b]|e[b+1]<<8)>>(m&7)&(1<<g)-1,i[++r]=l.s[y],L=l.n[w],w=l.t[w],g=l.n[y],y=l.t[y]}if(++r>255)J(0)}else{r=o-127;for(;n<r;n+=2){var h=e[++t];i[n]=h>>4,i[n+1]=h&15}++t}var P=0;for(n=0;n<r;++n){var A=i[n];if(A>11)J(0);P+=A&&1<<A-1}var S=re(P)+1,T=1<<S,B=T-P;if(B&B-1)J(0);i[r++]=re(B)+1;for(n=0;n<r;++n){var A=i[n];++a[i[n]=A&&S+1-A]}var v=new Z(T<<1),F=v.subarray(0,T),Y=v.subarray(T);u[S]=0;for(n=S;n>0;--n){var H=u[n];ce(Y,n,H,u[n-1]=H+a[n]*(1<<S-n))}if(u[0]!=T)J(0);for(n=0;n<r;++n){var C=i[n];if(C){var M=u[C];ce(F,n,M,u[C]=M+(1<<S-C))}}return[t,{n:Y,b:S,s:F}]},St=ue(new Z([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],Et=ue(new Z([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],Pt=ue(new Z([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],Ge=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},Se=new Z(new be([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),kt=Ge(Se,0),Ee=new Z(new be([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),It=Ge(Ee,3),le=function(e,t,n){var r=e.length,s=t.length,o=e[r-1],i=(1<<n.b)-1,a=-n.b;if(!o)J(0);var u=0,c=n.b,f=(r<<3)-8+re(o)-c,l=-1;for(;f>a&&l<s;){var p=f>>3,d=(e[p]|e[p+1]<<8|e[p+2]<<16)>>(f&7);u=(u<<c|d)&i,t[++l]=n.s[u],f-=c=n.n[u]}if(f!=a||l+1!=s)J(0)},Bt=function(e,t,n){var r=6,s=t.length,o=s+3>>2,i=o<<1,a=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,a),n),le(e.subarray(r),t.subarray(a),n)},Ft=function(e,t,n){var r,s=t.b,o=e[s],i=o>>1&3;t.l=o&1;var a=o>>3|e[s+1]<<5|e[s+2]<<13,u=(s+=3)+a;if(i==1){if(s>=e.length)return;if(t.b=s+1,n)return ce(n,e[s],t.y,t.y+=a),n;return ce(new Z(a),e[s])}if(u>e.length)return;if(i==0){if(t.b=u,n)return n.set(e.subarray(s,u),t.y),t.y+=a,n;return Le(e,s,u)}if(i==2){var c=e[s],f=c&3,l=c>>2&3,p=c>>4,d=0,w=0;if(f<2)if(l&1)p|=e[++s]<<4|(l&2&&e[++s]<<12);else p=c>>3;else if(w=l,l<2)p|=(e[++s]&63)<<4,d=e[s]>>6|e[++s]<<2;else if(l==2)p|=e[++s]<<4|(e[++s]&3)<<12,d=e[s]>>2|e[++s]<<6;else p|=e[++s]<<4|(e[++s]&63)<<12,d=e[s]>>6|e[++s]<<2|e[++s]<<10;++s;var y=n?n.subarray(t.y,t.y+t.m):new Z(t.m),L=y.length-p;if(f==0)y.set(e.subarray(s,s+=p),L);else if(f==1)ce(y,e[s++],L);else{var g=t.h;if(f==2){var m=Lt(e,s);d+=s-(s=m[0]),t.h=g=m[1]}else if(!g)J(0);(w?Bt:le)(e.subarray(s,s+=d),y.subarray(L),g)}var b=e[s++];if(b){if(b==255)b=(e[s++]|e[s++]<<8)+32512;else if(b>127)b=b-128<<8|e[s++];var h=e[s++];if(h&3)J(0);var P=[Et,Pt,St];for(var A=2;A>-1;--A){var S=h>>(A<<1)+2&3;if(S==1){var T=new Z([0,0,e[s++]]);P[A]={s:T.subarray(2,3),n:T.subarray(0,1),t:new de(T.buffer,0,1),b:0}}else if(S==2)r=ue(e,s,9-(A&1)),s=r[0],P[A]=r[1];else if(S==3){if(!t.t)J(0);P[A]=t.t[A]}}var B=t.t=P,v=B[0],F=B[1],Y=B[2],H=e[u-1];if(!H)J(0);var C=(u<<3)-8+re(H)-Y.b,M=C>>3,k=0,_=(e[M]|e[M+1]<<8)>>(C&7)&(1<<Y.b)-1;M=(C-=F.b)>>3;var I=(e[M]|e[M+1]<<8)>>(C&7)&(1<<F.b)-1;M=(C-=v.b)>>3;var O=(e[M]|e[M+1]<<8)>>(C&7)&(1<<v.b)-1;for(++b;--b;){var j=Y.s[_],X=Y.n[_],W=v.s[O],E=v.n[O],x=F.s[I],R=F.n[I];M=(C-=x)>>3;var D=1<<x,U=D+((e[M]|e[M+1]<<8|e[M+2]<<16|e[M+3]<<24)>>>(C&7)&D-1);M=(C-=Ee[W])>>3;var G=It[W]+((e[M]|e[M+1]<<8|e[M+2]<<16)>>(C&7)&(1<<Ee[W])-1);M=(C-=Se[j])>>3;var N=kt[j]+((e[M]|e[M+1]<<8|e[M+2]<<16)>>(C&7)&(1<<Se[j])-1);if(M=(C-=X)>>3,_=Y.t[_]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<X)-1),M=(C-=E)>>3,O=v.t[O]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<E)-1),M=(C-=R)>>3,I=F.t[I]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<R)-1),U>3)t.o[2]=t.o[1],t.o[1]=t.o[0],t.o[0]=U-=3;else{var V=U-(N!=0);if(V){if(U=V==3?t.o[0]-1:t.o[V],V>1)t.o[2]=t.o[1];t.o[1]=t.o[0],t.o[0]=U}else U=t.o[0]}for(var A=0;A<N;++A)y[k+A]=y[L+A];k+=N,L+=N;var z=k-U;if(z<0){var K=-z,q=t.e+z;if(K>G)K=G;for(var A=0;A<K;++A)y[k+A]=t.w[q+A];k+=K,G-=K,z=0}for(var A=0;A<G;++A)y[k+A]=y[z+A];k+=G}if(k!=L)while(L<y.length)y[k++]=y[L++];else k=y.length;if(n)t.y+=k;else y=Le(y,0,k)}else if(n){if(t.y+=p,L)for(var A=0;A<p;++A)y[A]=y[L+A]}else if(L)y=Le(y,L);return t.b=u,y}J(2)},Rt=function(e,t){if(e.length==1)return e[0];var n=new Z(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 ye(e,t){var n=[],r=+!t,s=0,o=0;for(;e.length;){var i=Tt(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 a=Ft(e,i,t);if(!a)J(5);if(t)i.e=i.y;else n.push(a),o+=a.length,Mt(i.w,0,a.length),i.w.set(a,i.w.length-a.length)}s=i.b+i.c*4}else s=i;e=e.subarray(s)}return Rt(n,o)}async function Dt(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=(r)=>r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);if(t[0]===40&&t[1]===181&&t[2]===47&&t[3]===253)return n(ye(t));if(t[0]===31&&t[1]===139)return new Response(new Blob([t]).stream().pipeThrough(new DecompressionStream(\"gzip\"))).arrayBuffer();return n(t)}async function _e(e){return new TextDecoder().decode(await Dt(e))}var Ke=(e)=>decodeURIComponent(e.split(/[?#]/)[0].split(\"/\").pop()||\"main.ldr\").replace(/\\.(zst|gz)$/i,\"\")||\"main.ldr\";function xe(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 Q=(e)=>e.trim().toLowerCase().replace(/\\\\/g,\"/\").replace(/\\/+/g,\"/\");function Pe(e){if(/^0x/i.test(e))return parseInt(e,16);return+e}var We=/^~?\\s*moved\\s+to\\s+(.+)$/i,Ut=new Set([\"FILE\",\"NOFILE\",\"!DATA\",\"!:\",\"STEP\",\"BFC\",\"ROTSTEP\",\"BUFEXCHG\",\"!TEXMAP\"]),tt=new Set([\"part\",\"subpart\",\"primitive\",\"8_primitive\",\"48_primitive\",\"shortcut\",\"helper\"]),zt=new Set([\"model\",\"submodel\",\"configuration\"]),Ot=/^(?:!?LDRAW_ORG|Unofficial|Official\\s+LCAD)\\s+(\\S+)/i;function Xe(e){let t=Ot.exec(e);if(!t)return;let n=t[1].toLowerCase().replace(/^unofficial_/,\"\");return tt.has(n)||zt.has(n)?n:void 0}function Nt(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 $t(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 a=n[2].trim();for(let l=0;l<s;l++)a=a.replace(/^\\S+\\s*/,\"\");let u=Nt(a);if(!u.length)return null;let c={method:r,p1:i.slice(0,3),p2:i.slice(3,6),p3:i.slice(6,9),texture:u[0]};if(s>=10)c.a=i[9];if(s===11)c.b=i[10];let f=u.findIndex((l,p)=>p>0&&l.toUpperCase()===\"GLOSSMAP\");if(f>0&&u[f+1])c.glossmap=u[f+1];if(t)c.next=!0;return c}var jt=(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 Vt(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 f=s();if(f===null)return null;i[c]=+f}while(n<t&&r(e.charCodeAt(n)))n++;if(n>=t)return null;let a=e.slice(n),u=/[ \\t]{2,}|\\t/.test(a)?a.split(/\\s+/).join(\" \"):a;return{t:1,color:Pe(o),m:i,file:Q(u)}}function Ze(e){let t=+e[0];if(!(t>=1&&t<=5)||e.length<2)return null;let n=Pe(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 nt(e,t=\"main.ldr\",n={}){let r=!!n.geometryText,s=new Map,o=null,i=\"\",a,u=null,c=[],f=null,l=()=>{if(!u)return;let m=jt(u.chunks.join(\"\")),b=m[0]===137&&m[1]===80&&m[2]===78&&m[3]===71;(a??=new Map).set(Q(u.name),{name:u.name,bytes:m,...b?{mime:\"image/png\"}:{}}),u=null},p=!0,d=(m)=>{if(l(),o={name:Q(m),cmds:[]},s.set(o.name,o),!i)i=o.name;c=[],f=null,p=!0},w=!1,y=!1,L=()=>{if(y)return;y=!0,s.clear(),o=null,i=\"\"},g=(m,b)=>{if(f){m.tex=f,f=null;return}let h=c[c.length-1];if(!h)return;if(h.fallback){if(!b)m.fallback=!0}else m.tex=h.map};for(let m of e.split(`\n`)){let b=m.trim();if(!b)continue;if(r&&b.charCodeAt(0)>=50&&b.charCodeAt(0)<=53&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)){if(u||w)continue;if(!o)d(t);let S=b.slice(2).trimStart(),T=S.search(/\\s/),B={t:b.charCodeAt(0)-48,color:Pe(T<0?S:S.slice(0,T)),p:[],src:b};g(B,!1),o.cmds.push(B),p=!1;continue}if(b.charCodeAt(0)===48&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)){let S=2;while(b.charCodeAt(S)===32||b.charCodeAt(S)===9)S++;let T=S;while(T<b.length&&b.charCodeAt(T)!==32&&b.charCodeAt(T)!==9)T++;let B=b.slice(S,T);if(!Ut.has(B)){if(w||u)continue;if(!o)d(t);let v=b.slice(S),F={t:0,text:v};if(B.charCodeAt(0)===33)F.meta=B;if(f=null,p&&!o.org){let H=Xe(v);if(H)o.org=H}let Y=v.match(We);if(Y&&!o.movedTo){let H=Y[1].trim().replace(/\\\\/g,\"/\");if(!/\\.(dat|ldr|mpd)$/i.test(H))H+=\".dat\";o.movedTo=Q(H)}o.cmds.push(F);continue}}if(b.charCodeAt(0)===49&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)&&!u&&!w){let S=Vt(b);if(S){if(!o)d(t);g(S,!1),o.cmds.push(S),p=!1;continue}}let h=b.split(/\\s+/);if(+h[0]===0){let S=b.slice(1).trim();if(h[1]===\"FILE\"){L(),w=!1,d(S.slice(5));continue}if(h[1]===\"NOFILE\"){l(),o=null,w=!0;continue}if(h[1]===\"!DATA\"){L(),l(),o=null,w=!1,u={name:S.slice(5).trim(),chunks:[]};continue}if(w)continue;if(u){if(h[1]===\"!:\")u.chunks.push(h.slice(2).join(\"\"));continue}if(!o)d(t);let T={t:0,text:S};if(h[1]===\"STEP\")T.step=!0,c=[],f=null;else if(h[1]===\"BFC\")T.bfc=h.slice(2).join(\" \");else if(h[1]===\"ROTSTEP\")if(T.meta=\"ROTSTEP\",T.step=!0,c=[],f=null,(h[2]??\"\").toUpperCase()===\"END\")T.rotstep={x:0,y:0,z:0,mode:\"END\"};else{let v=(h[5]??\"REL\").toUpperCase();T.rotstep={x:+h[2]||0,y:+h[3]||0,z:+h[4]||0,mode:[\"REL\",\"ABS\",\"ADD\"].includes(v)?v:\"REL\"}}else if(h[1]===\"BUFEXCHG\"){T.meta=\"BUFEXCHG\";let v=(h[2]??\"\").toUpperCase();T.bufexchg={op:v===\"RETRIEVE\"?\"RETRIEVE\":\"STORE\",buf:h[3]??\"A\"}}else if(h[1]?.startsWith(\"!\"))T.meta=h[1];if(p&&!o.org){let v=Xe(S);if(v)o.org=v}if(h[1]===\"!TEXMAP\"){let v=(h[2]??\"\").toUpperCase();if(f=null,v===\"START\"||v===\"NEXT\"){let F=$t(S.replace(/^!TEXMAP\\s+\\S+/i,\"\"),v===\"NEXT\");if(T.texmap={op:v,...F?{map:F}:{}},F)if((o.texmaps??=[]).push(F),v===\"START\")c.push({map:F,fallback:!1});else f=F}else if(v===\"FALLBACK\"){T.texmap={op:v};let F=c[c.length-1];if(F)F.fallback=!0}else if(v===\"END\")T.texmap={op:v},c.pop()}else if(h[1]===\"!:\"){f=null;let v=Ze(h.slice(2));if(v)g(v,!0),T.geom=v}else f=null;let B=S.match(We);if(B&&!o.movedTo){let v=B[1].trim().replace(/\\\\/g,\"/\");if(!/\\.(dat|ldr|mpd)$/i.test(v))v+=\".dat\";o.movedTo=Q(v)}o.cmds.push(T);continue}if(u||w)continue;if(!o)d(t);let A=Ze(h);if(!A)continue;g(A,!1),o.cmds.push(A),p=!1}return l(),a?{main:i,files:s,data:a}:{main:i,files:s}}var gn=Math.PI/180;function rt(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 st(e,t){let[n,r,s,o,i,a,u,c,f,l,p,d]=e,[w,y,L,g,m,b,h,P,A,S,T,B]=t;return[o*w+i*y+a*L+n,u*w+c*y+f*L+r,l*w+p*y+d*L+s,o*g+i*h+a*S,o*m+i*P+a*T,o*b+i*A+a*B,u*g+c*h+f*S,u*m+c*P+f*T,u*b+c*A+f*B,l*g+p*h+d*S,l*m+p*P+d*T,l*b+p*A+d*B]}var ke=[0,0,0,1,0,0,0,1,0,0,0,1];var Ye=new WeakMap,Ht=/^(s|8|48)\\//;function Ie(e,t){let n=e.files.get(Q(t));if(!n)return\"part\";let r=Ye.get(n);if(r)return r;if(n.org)r=tt.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&&Ht.test(s.file))?\"part\":\"model\";return Ye.set(n,r),r}var Je=new WeakMap;function ot(e){let t=Je.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 Je.set(e,t),t}var qe=(e)=>e>16777215?\"0x\"+e.toString(16).toUpperCase():String(e),Gt=(e)=>e.t===0?\"0 \"+e.text:e.t===1?`1 ${qe(e.color)} ${e.m.join(\" \")} ${e.file}`:e.src?e.src:`${e.t} ${qe(e.color)} ${e.p.join(\" \")}`,Be=(e,t)=>`${Q(e)}#${t}`;function _t(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:Be(e.name,t),cmds:n}}function it(e,t){return[`0 ldr: own geometry of ${e.name}, step ${t}`,..._t(e,t).cmds.map(Gt)].join(`\n`)+`\n`}function Kt(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 at(e){let[t,n,r,s,o,i,a,u,c,f,l,p]=e,d=u*p-c*l,w=-(a*p-c*f),y=a*l-u*f,L=s*d+o*w+i*y;if(!Number.isFinite(L)||Math.abs(L)<0.000000000001)return null;let g=1/L,m=[d*g,-(o*p-i*l)*g,(o*c-i*u)*g,w*g,(s*p-i*f)*g,-(s*c-i*a)*g,y*g,-(s*l-o*f)*g,(s*u-o*a)*g];return[-(m[0]*t+m[1]*n+m[2]*r),-(m[3]*t+m[4]*n+m[5]*r),-(m[6]*t+m[7]*n+m[8]*r),...m]}var Wt=(e)=>String(+e.toFixed(6)||0),Qe=(e)=>'\"'+e.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,\"\\\\\\\"\")+'\"';function lt(e,t){let n=[...t.p1,...t.p2,...t.p3,...t.method!==\"PLANAR\"?[t.a??360]:[],...t.method===\"SPHERICAL\"?[t.b??180]:[]].map(Wt).join(\" \"),r=`0 ldr: ${e} with a model-level !TEXMAP\n0 BFC CERTIFY CCW\n0 !TEXMAP START ${t.method} ${n} ${Qe(t.texture)}${t.glossmap?\" GLOSSMAP \"+Qe(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-${Kt(r)}`,source:r}}var Xt=(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 Zt(e,t,n){let r=Math.PI/180,s=Math.sin(e*r),o=Math.cos(e*r),i=Math.sin(t*r),a=Math.cos(t*r),u=Math.sin(n*r),c=Math.cos(n*r);return[a*c,-a*u,i,o*u+s*i*c,o*c-s*i*u,-s*a,s*u-o*i*c,s*c+o*i*u,o*a]}var et=new WeakMap;function ct(e){let t=et.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=Zt(o.x,o.y,o.z);r=o.mode===\"ABS\"?{abs:!0,m:i,rotstep:o}:o.mode===\"ADD\"&&r?{abs:r.abs,m:Xt(r.m,i),rotstep:o}:{abs:!1,m:i,rotstep:o}}n.push(r)}return n.push(r),et.set(e,n),n}var ut=999999,pt=(e)=>e.map((t)=>String(t).padStart(6,\"0\")).join(\".\")+\"~\";function Yt(e,t={}){let n=[],r=t.maxDepth??64,s=t.looseGeometry!==!1,o=!!t.textures,i=!!t.callouts,a=new Map,u=0,c=(l,p)=>{let d=l.name+\"#\"+p,w=a.get(d);if(!w){let y;w=Object.assign(()=>y??=it(l,p),{file:l,step:p}),a.set(d,w)}return w},f=(l,p,d,w,y,L,g,m,b=null,h=[],P=[],A=void 0,S=null)=>{let T=l.files.get(p);if(!T||g>r)return;let B=S,v=0,F=g>0?++u:0,Y=i&&F?[...h,F]:h,H=i&&F?[...P,d]:P,C=i&&!b?new Map:null,M=-1,k=0,_=(E,x,R,D,U,G,N)=>{if(M!==v)M=v,k=0;let V=C?.get(v+\"|\"+x);if(V)return V.n++,f(E,E===l?x:E.main,R,D,y+\"/\"+x,[...U,ut],g+1,G,[...U,ut],Y,H,N,B);let z=[...U,k++],K=n.length;f(E,E===l?x:E.main,R,D,y+\"/\"+x,z,g+1,G,b,Y,H,N,B),C?.set(v+\"|\"+x,{n:1,from:K,to:n.length})},I=ct(T),O=s?ot(T):[],j=0,X=(E,x,R,D,U,G,N,V)=>{if(b)D=b;let z={part:E,color:x,m:R,step:D[0],steps:D,localStep:U,path:y};if(V)z.colour=V;if(F){if(z.sub=F,i)z.subPath=Y,z.subMats=H}if(G)z.embedded=!0;if(N){let q=lt(E,N);z.texPart=q.name,z.texSource=q.source}let K=I[U];if(K)z.view=K;return n.push(z),z},W=(E)=>{while(j<O.length&&O[j]<=E){let x=O[j++];X(Be(T.name,x),w,d,[...L,x],x,!1,null,A).source=c(T,x)}};for(let E of T.cmds){if(E.t===0&&E.step){v++;continue}let x=E;if(x.t>=2||x.t===0&&x.geom&&x.geom.t>=2){W(v);continue}if(x.t===0){if(x.meta===\"!COLOUR\"){let q=qt(x.text);if(q&&q.code!==16&&q.code!==24)(B=new Map(B??[])).set(q.code,q);continue}if(o&&x.geom?.t===1)x=x.geom;else continue}if(x.t!==1)continue;if(o&&x.fallback)continue;let R=x.color===16?w:x.color,D=x.color===16?A:B?.get(x.color),U=st(d,x.m),G=[...L,v],N=o?x.tex??m:null,V=N?at(x.m):null,z=N&&V?rt(N,V):null;if(l.files.has(x.file)){if(Ie(l,x.file)===\"model\"){_(l,x.file,U,R,G,z,D);continue}X(x.file,R,U,G,v,!0,z,D);continue}let K=t.resolveModel?.(x.file);if(K){_(K,x.file,U,R,G,z,D);continue}X(x.file,R,U,G,v,!1,z,D)}if(W(1/0),C){for(let E of C.values())if(E.n>1)for(let x=E.from;x<E.to;x++)n[x].mult??=E.n}};if(Ie(e,e.main)===\"part\"){if(e.files.get(e.main))n.push({part:e.main,color:16,m:[...ke],step:0,steps:[0],localStep:0,path:e.main,embedded:!0});return n}return f(e,e.main,ke,16,e.main,[],0,null),n}function mt(e,t=\"main.ldr\",n){return Yt(nt(e,t,{geometryText:!0}),n)}var Jt=new Set([\"CHROME\",\"PEARLESCENT\",\"RUBBER\",\"MATTE_METALLIC\",\"METAL\",\"MATERIAL\"]);function Fe(e){if(!e)return null;if(e.startsWith(\"#\")&&/^#[0-9A-Fa-f]{6}$/.test(e))return e.toUpperCase();if(/^0x[0-9A-Fa-f]{6}$/i.test(e))return(\"#\"+e.slice(2)).toUpperCase();return null}function ft(e,t){let n={value:\"#FFFFFF\",fraction:0.5};while(t<e.length){let r=e[t].toUpperCase(),s=e[t+1];if(r===\"VALUE\"){let o=Fe(s);if(o)n.value=o;t+=2}else if(r===\"ALPHA\")n.alpha=+s,t+=2;else if(r===\"LUMINANCE\")n.luminance=+s,t+=2;else if(r===\"FRACTION\")n.fraction=+s,t+=2;else if(r===\"VFRACTION\")n.vfraction=+s,t+=2;else if(r===\"SIZE\")n.size=+s,t+=2;else if(r===\"MINSIZE\")n.minsize=+s,t+=2;else if(r===\"MAXSIZE\")n.maxsize=+s,t+=2;else break}return{grain:n,next:t}}function qt(e){let t=e.indexOf(\"!COLOUR\");if(t<0)return null;let n=e.slice(t+7).trim().split(/\\s+/).filter(Boolean);if(n.length<2)return null;let r=n[0],s=-1,o=\"#FF00FF\",i=\"#333333\",a=255,u=0,c={type:\"default\"},f=1;while(f<n.length){let l=n[f].toUpperCase(),p=n[f+1];if(l===\"CODE\")s=+p,f+=2;else if(l===\"VALUE\"){let d=Fe(p);if(d)o=d;f+=2}else if(l===\"EDGE\")i=Fe(p)??p,f+=2;else if(l===\"ALPHA\")a=+p,f+=2;else if(l===\"LUMINANCE\")u=+p,f+=2;else if(l===\"CHROME\")c={type:\"chrome\"},f+=1;else if(l===\"PEARLESCENT\")c={type:\"pearlescent\"},f+=1;else if(l===\"RUBBER\")c={type:\"rubber\"},f+=1;else if(l===\"MATTE_METALLIC\")c={type:\"matte_metallic\"},f+=1;else if(l===\"METAL\")c={type:\"metal\"},f+=1;else if(l===\"MATERIAL\"){let d=(n[f+1]||\"\").toUpperCase();if(d===\"GLITTER\"){let{grain:w,next:y}=ft(n,f+2);c={type:\"glitter\",material:w},f=y}else if(d===\"SPECKLE\"){let{grain:w,next:y}=ft(n,f+2);c={type:\"speckle\",material:w},f=y}else if(d===\"FABRIC\"){let w=(n[f+2]||\"\").toUpperCase(),y=[\"VELVET\",\"CANVAS\",\"STRING\",\"FUR\"].includes(w)?w.toLowerCase():void 0;c={type:\"fabric\",kind:y},f+=y?3:2}else f=n.length}else if(Jt.has(l))f+=1;else f+=1}if(s<0||!o)return null;return{code:s,name:r,hex:o,edge:i,alpha:Number.isFinite(a)?a:255,luminance:Number.isFinite(u)?u:0,finish:c}}function Qt(e){let t=Math.max(0,Math.min(1,(e.alpha??255)/255)),n=t<1,r=Math.max(0,Math.min(1,(e.luminance??0)/255)),s={opacity:t,transparent:n,depthWrite:!n,emissive:r,clearcoat:0,clearcoatRoughness:0,sheen:0,sheenRoughness:0};switch(e.finish?.type??\"default\"){case\"chrome\":return{...s,metalness:1,roughness:0,finish:\"chrome\"};case\"pearlescent\":return{...s,metalness:0.25,roughness:0.3,clearcoat:0.5,clearcoatRoughness:0.25,sheen:0.4,sheenRoughness:0.35,finish:\"pearlescent\"};case\"rubber\":return{...s,metalness:0,roughness:0.9,finish:\"rubber\"};case\"matte_metallic\":return{...s,metalness:0.4,roughness:0.8,finish:\"matte_metallic\"};case\"metal\":return{...s,metalness:0.85,roughness:0.2,finish:\"metal\"};case\"glitter\":{let i=e.finish.material,a=i.size??(i.minsize!=null&&i.maxsize!=null?(i.minsize+i.maxsize)/2:1);return{...s,metalness:0.35,roughness:0.25,clearcoat:1,clearcoatRoughness:0.08,particleHex:i.value,particleFraction:i.fraction,particleSize:a,finish:\"glitter\"}}case\"speckle\":{let i=e.finish.material,a=i.size??(i.minsize!=null&&i.maxsize!=null?(i.minsize+i.maxsize)/2:1);return{...s,metalness:0.2,roughness:0.55,particleHex:i.value,particleFraction:i.fraction,particleSize:a,finish:\"speckle\"}}case\"fabric\":return{...s,metalness:0,roughness:0.85,sheen:0.65,sheenRoughness:0.75,finish:\"fabric\"};default:return{...s,metalness:0,roughness:0.45,finish:\"default\"}}}function Re(e){let t=Qt(e),n=!t.transparent?\"op\":t.opacity>=0.75?\"a200\":t.opacity>=0.4?\"a128\":`a${Math.round(t.opacity*255)}`,r=t.emissive>0?`L${Math.round(t.emissive*16)}`:\"\",s=`${t.finish}:${n}${r}`;if(t.particleHex)s+=`:${t.particleHex}:${(t.particleFraction??0).toFixed(2)}`;return s}function en(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(Q(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(Q(t),r)}let a=o.trim().replace(/\\s+/g,\" \");if(a)r.push(a)}return n}var tn=(e)=>{if(!e.startsWith(\"1 \"))return null;let t=e.split(\" \");return t.length>=15?Q(t.slice(14).join(\" \")):null};function nn(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 ht(e,t,n=\"main.ldr\"){let r=en(e,n),s=new Map;for(let o of t){let i=Q(o);if(!r.has(i)||s.has(i))continue;let a=new Set([i]),u=[i];while(u.length)for(let f of r.get(u.pop())){let l=tn(f);if(l&&r.has(l)&&!a.has(l))a.add(l),u.push(l)}let c=[i,...[...a].filter((f)=>f!==i).sort()].map((f)=>\"0 FILE \"+(f===i?\"\":f)+`\n`+r.get(f).join(`\n`)).join(`\n`);s.set(i,`emb/${nn(c)}.dat`)}return s}var gt=(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,dt=new WeakMap;function De(e,t){let n=dt.get(e);if(!n)dt.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),a=[],u=[];s.studs.forEach((p,d)=>{a.push(p[0]),u.push(p[1]);for(let w=0;w<12;w++)i[d*12+w]=p[2+w]});let c=null,f=0,l=0;if(s.mask){f=s.mask[0],l=s.mask[1];let p=s.mask[2];c=new Uint8Array(p.length);for(let d=0;d<p.length;d++)c[d]=p.charCodeAt(d)===49?1:0}return n.set(t,r={nStuds:o,studM:i,kind:a,color:u,mask:c,nx:f,nz:l}),r}var ie=1073741824;class Ue{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,a=this.c;for(;;){if(!s[r])return-1;if(o[r]===e&&i[r]===t&&a[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,a=this.b,u=this.c;for(;;){if(!o[s])return o[s]=1,i[s]=e,a[s]=t,u[s]=n,this.vals[s]=r,this.size++,-1;if(i[s]===e&&a[s]===t&&u[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 we=(e,t,n)=>e>-ie&&e<ie&&t>-ie&&t<ie&&n>-ie&&n<ie,fe=2147483647;function rn(e,t,n){let s=[],o=[],i=[],a=[],u=[],c=[],f=[],l=[],p=new Ue(e.length*2),d=[],w=[];for(let C=0;C<e.length;C++){let M=e[C],k=M.m,_=t.parts[M.part];if(!_||!_.mask||!gt(k))continue;let I=_.bbox,O=1/0,j=-1/0,X=1/0,W=-1/0;for(let R=0;R<2;R++)for(let D=0;D<2;D++){let U=R?I[3]:I[0],G=D?I[5]:I[2],N=k[0]+k[3]*U+k[5]*G,V=k[2]+k[9]*U+k[11]*G;if(N<O)O=N;if(N>j)j=N;if(V<X)X=V;if(V>W)W=V}let E=u.length;s.push(O),o.push(j),i.push(X),a.push(W),u.push(C),c.push(De(t,M.part)),f.push(I[0]),l.push(I[2]);let x=Math.round((k[1]+I[4])*2);for(let R=Math.floor(O/40);R<=Math.floor(j/40);R++)for(let D=Math.floor(X/40);D<=Math.floor(W/40);D++){if(!we(x,R,D))continue;let U=w.length;w.push(E),d.push(p.put(x,R,D,U))}}let y=[0,5,-5,5,-5],L=[0,5,5,-5,-5],g=NaN,m=NaN,b=NaN,h=-1,P=(C,M,k,_)=>{let I=Math.round(M*2),O=Math.floor(C/40),j=Math.floor(k/40);if(!we(I,O,j))return fe;let X=fe;if(I!==g||O!==m||j!==b)g=I,m=O,b=j,h=p.get(I,O,j);for(let W=h;W>=0;W=d[W]){let E=w[W];if(u[E]===_||!(C-6>=s[E]-0.5&&C+6<=o[E]+0.5&&k-6>=i[E]-0.5&&k+6<=a[E]+0.5))continue;let x=e[u[E]].m,R=c[E],D=f[E],U=l[E],G=C-x[0],N=M-x[1],V=k-x[2],z=x[3]*G+x[6]*N+x[9]*V,K=x[5]*G+x[8]*N+x[11]*V,{nx:q,nz:se,mask:ae}=R,oe=!0;for(let ee=0;ee<5;ee++){let te=Math.floor((z+y[ee]-D)/20),ne=Math.floor((K+L[ee]-U)/20);if(te<0||ne<0||te>=q||ne>=se||ae[te*se+ne]!==1){oe=!1;break}}if(oe){if(!n)return 0;let ee=n[u[E]];if(ee<X)X=ee}}return X},A=0;for(let C of e){let M=De(t,C.part);if(M)A+=M.nStuds}let S=new Uint8Array(A),T=new Uint8Array(A),B=new Ue(A),v=0,F=n?new Int32Array(A).fill(fe):void 0;for(let C=0,M=0;C<e.length;C++){let k=e[C],_=De(t,k.part);if(!_)continue;let I=k.m,O=_.studM,j=I[0],X=I[1],W=I[2],E=I[3],x=I[4],R=I[5],D=I[6],U=I[7],G=I[8],N=I[9],V=I[10],z=I[11];for(let K=0;K<_.nStuds;K++,M++){let q=K*12,se=O[q+4],ae=O[q+7],oe=O[q+10];if(!(Math.abs(D*se+U*ae+G*oe-1)<0.001&&Math.abs(E*se+x*ae+R*oe)<0.001&&Math.abs(N*se+V*ae+z*oe)<0.001))continue;T[M]=1;let ee=O[q],te=O[q+1],ne=O[q+2],ze=j+E*ee+x*te+R*ne,Oe=X+D*ee+U*te+G*ne,Ne=W+N*ee+V*te+z*ne,$e=P(ze,Oe,Ne,C);if($e!==fe){if(S[M]=1,v++,F)F[M]=$e}let me=Math.round(ze),he=Math.round(Oe),ge=Math.round(Ne);if(!we(me,he,ge))continue;if(!n){B.put(me,he,ge,1);continue}let je=n[C],Ve=B.get(me,he,ge);if(Ve<0||je<Ve)B.put(me,he,ge,je)}}let Y=new Uint8Array(e.length),H=n?new Int32Array(e.length).fill(fe):void 0;for(let C=0;C<e.length;C++){let M=e[C],k=t.parts[M.part];if(!k||!k.under||!gt(M.m))continue;let _=k.bbox,I=Math.round((_[3]-_[0])/20),O=Math.round((_[5]-_[2])/20);if(!I||!O||I*O>4096)continue;let j=M.m,X=!0,W=0;for(let E=0;E<I&&X;E++)for(let x=0;x<O;x++){let R=_[0]+10+20*E,D=_[2]+10+20*x,U=j[0]+j[3]*R+j[5]*D,G=j[2]+j[9]*R+j[11]*D,N=Math.round(U),V=Math.round(j[1]+_[4]),z=Math.round(G),K=we(N,V,z)?B.get(N,V,z):-1;if(K<0){X=!1;break}if(K>W)W=K}if(X){if(Y[C]=1,H)H[C]=W}}return{nStuds:A,studHidden:S,studUp:T,underHidden:Y,studsHidden:v,studHideStep:F,underHideStep:H}}function sn(e,t,n){let r=(l)=>n&&l.texPart&&t.parts[l.texPart]?l.texPart:l.part,s=new Map,o=new Map,i=(l)=>{let p=l.colour;if(!p)return String(l.color);let d=o.get(p);if(d!==void 0)return d;let w=t.colorTable?.[l.color],y=w?.hex??t.colors?.[l.color],L=w?Re({alpha:w.alpha??255,luminance:w.luminance??0,finish:w.finish??{type:\"default\"}}):\"default:op\",g=Re(p);if(d=y&&y.toUpperCase()===p.hex.toUpperCase()&&L===g?String(l.color):p.hex.toUpperCase()+\"/\"+g,d!==String(l.color))s.set(d,p);return o.set(p,d),d},a=e.map((l)=>({part:r(l),color:i(l),m:l.m,steps:l.steps})),u=a.map((l)=>pt(l.steps)),c=[...new Set(u)].sort(),f=new Map(c.map((l,p)=>[l,p]));return{all:a,stepOf:u.map((l)=>f.get(l)),nSteps:c.length,localColours:s}}function Ae(e,t,n=!0){let r=sn(e,t,n);return rn(r.all,t,r.nSteps>1?r.stepOf:void 0)}var Te=\"https://ldr-demo.vercel.app/cdn/v1/\",ve=new Map,Me=new Map;function yt(e=Te,t=fetch){let n=ve.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(()=>ve.delete(e)),ve.set(e,n);return n}var on=(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\"),Ce=(e,t)=>on(e)?[e[0]+t,e[1],e[2]]:Array.isArray(e)?e.map((n)=>Ce(n,t)):e&&typeof e===\"object\"?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,Ce(r,t)])):e;function an(e,t={}){let n=[],r=0,s={},o={};for(let p of e){let d=p.buffer;if(!d)throw Error(\"ldr: mergePacks needs packs from decodePack/loadPack\");let w=new DataView(d).getUint32(0,!0),y=new Uint8Array(d,4+w),L=r;n.push(y),r+=y.byteLength;let g=(4-r%4)%4;if(g)n.push(new Uint8Array(g)),r+=g;for(let[m,b]of Object.entries(p.header.parts??{}))if(!(m in s))s[m]=Ce(b,L);for(let[m,b]of Object.entries(p.header.studKinds??{}))if(!(m in o))o[m]=Ce(b,L)}let i=e[0]?.header??{version:1,weld:!0},a=new TextEncoder().encode(JSON.stringify({...i,parts:s,studKinds:o,...t})),u=(4-(4+a.length)%4)%4,c=4+a.length+u,f=new Uint8Array(c+r);new DataView(f.buffer).setUint32(0,a.length+u,!0),f.set(a,4),f.fill(32,4+a.length,c);let l=c;for(let p of n)f.set(p,l),l+=p.byteLength;return xe(f.buffer)}async function ln(e,t={}){e=[...e];try{return await bt(e,t)}catch(n){let r=t.cdn??Te,s=t.fetch??fetch;ve.delete(r);let o=(i,a)=>s(i,{...a,cache:\"reload\"});try{return await bt(e,{...t,fetch:o})}catch{throw n}}}async function bt(e,t){let n=t.cdn??Te,r=t.fetch??fetch,s=t.gap??16384,o=await yt(n,r),i=[...new Set([...e].map(Q))],a=[],u=[];for(let g of i){if(Me.has(n+g))continue;let m=o.parts[g];if(m)u.push({name:g,off:m[0],len:m[1],file:m[2]??0});else a.push(g)}u.sort((g,m)=>g.file-m.file||g.off-m.off);let c=[];for(let g of u){let m=c[c.length-1];if(m&&m.file===g.file&&g.off-m.end<=s)m.end=Math.max(m.end,g.off+g.len),m.items.push(g);else c.push({file:g.file,start:g.off,end:g.off+g.len,items:[g]})}let f=0,l=0,p=0,d=new Map,w=async()=>{while(p<c.length){let g=c[p++],m=d.get(g.file);if(m)m=m.subarray(g.start,g.end);else{let b=await r(new URL(o.archives[g.file],n).href,{headers:{Range:`bytes=${g.start}-${g.end-1}`,\"Accept-Encoding\":\"identity\"}});if(!b.ok)throw Error(`ldr: parts CDN ${b.status}`);if(l++,m=new Uint8Array(await b.arrayBuffer()),f+=m.byteLength,b.status===200)d.set(g.file,m),m=m.subarray(g.start,g.end)}for(let b of g.items){let h=ye(m.subarray(b.off-g.start,b.off-g.start+b.len)),P=h.buffer.slice(h.byteOffset,h.byteOffset+h.byteLength);Me.set(n+b.name,xe(P))}}};await Promise.all(Array.from({length:Math.min(t.concurrency??24,c.length)},w));let y=i.filter((g)=>Me.has(n+g)).map((g)=>Me.get(n+g));return{pack:y.length?an(y,{colors:o.colors}):xe(cn(o.colors)),missing:a,requests:l,bytes:f}}function cn(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}function un(e,t){let n=t.header.parts;if(!n)return 0;let r=0;for(let s of e){let o=n[s.part]?.body?.tris;if(o)r+=o}return r}function fn(e,t,n){let r=0,s=0,o=!1,i=new Set;for(let a of e){let u=a.embedded?t.get(a.part):Q(a.part),c=u?n.parts[u]:void 0;if(!c)continue;if(c[3]!=null)o=!0,r+=c[3];if(!i.has(u))i.add(u),s+=c[1]}return{bodyTris:r,packBytes:s,known:o}}class pe extends Error{code=\"ldr-budget\";bodyTris;packBytes;maxBodyTris;maxPackBytes;constructor(e){let t=[e.maxBodyTris!=null&&e.bodyTris>e.maxBodyTris?`${e.bodyTris} triangles (limit ${e.maxBodyTris})`:\"\",e.maxPackBytes!=null&&e.packBytes>e.maxPackBytes?`${(e.packBytes/1e6).toFixed(1)} MB parts pack (limit ${(e.maxPackBytes/1e6).toFixed(0)} MB)`:\"\"].filter(Boolean).join(\", \");super(`ldr: model exceeds device budget: ${t}`);this.name=\"BudgetError\",this.bodyTris=e.bodyTris,this.packBytes=e.packBytes,this.maxBodyTris=e.maxBodyTris,this.maxPackBytes=e.maxPackBytes}}async function xt(e,t={}){let n=performance.now(),r=t.fetch??fetch,s=yt(t.cdn??Te,r);s.catch(()=>{});let o=t.text?e:await r(e).then(async(h)=>{if(!h.ok)throw Error(`ldr: ${h.status} fetching ${e}`);return _e(await h.arrayBuffer())}),i=performance.now(),a=t.name??(t.text?\"main.ldr\":Ke(e)),u=mt(o,a,{looseGeometry:!1,callouts:t.callouts}),c=performance.now();t.onParsed?.(u),await s;let f=ht(o,new Set(u.filter((h)=>h.embedded).map((h)=>h.part)),a),l=(h,P)=>t.maxBodyTris!=null&&h>t.maxBodyTris||t.maxPackBytes!=null&&P>t.maxPackBytes;if(t.maxBodyTris!=null||t.maxPackBytes!=null){let h=fn(u,f,await s);if(l(h.known?h.bodyTris:0,h.packBytes))throw new pe({bodyTris:h.bodyTris,packBytes:h.packBytes,maxBodyTris:t.maxBodyTris,maxPackBytes:t.maxPackBytes})}let{pack:p,missing:d,requests:w,bytes:y}=await ln([...u.filter((h)=>!h.embedded).map((h)=>h.part),...f.values()],t),L=new Map([...f].map(([h,P])=>[P,h])),g=d.map((h)=>L.get(h)??h);for(let[h,P]of f){let A=p.header.parts[P];if(A)p.header.parts[h]=A}let m=performance.now();if(t.maxBodyTris!=null||t.maxPackBytes!=null){let h=p.buffer?.byteLength??p.bytes??0,P=un(u,p);if(l(P,h))throw new pe({bodyTris:P,packBytes:h,maxBodyTris:t.maxBodyTris,maxPackBytes:t.maxPackBytes})}let b=t.cull?Ae(u,p.header,t.textures!==!1):void 0;return{insts:u,pack:p,missing:g,requests:w,bytes:y,cull:b,timings:{fetchModel:i-n,parse:c-i,parts:m-c,...b?{cull:performance.now()-m}:{}}}}self.onmessage=async(e)=>{let{id:t,source:n,opts:r}=e.data;try{let s=await xt(n,{...r,cull:!1,onParsed:(f)=>self.postMessage({id:t,insts:f})}),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(),a=Ae(s.insts,s.pack.header,r.textures!==!1),u=performance.now()-i,c=[];for(let f of[a.studHidden,a.studUp,a.underHidden,a.studHideStep,a.underHideStep])if(f)c.push(f.buffer);self.postMessage({id:t,cull:a,ms:u},c)}catch(s){if(s instanceof pe||s?.code===\"ldr-budget\")self.postMessage({id:t,phase:\"error\",error:String(s?.message??s),budget:{bodyTris:s.bodyTris,packBytes:s.packBytes,maxBodyTris:s.maxBodyTris,maxPackBytes:s.maxPackBytes}});else self.postMessage({id:t,phase:\"error\",error:String(s?.message??s)})}};\n";
|
|
1
|
+
declare const _default: "var vt=ArrayBuffer,Z=Uint8Array,de=Uint16Array,Ct=Int16Array;var be=Int32Array,Le=function(e,t,n){if(Z.prototype.slice)return Z.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 Z(n-t);return r.set(e.subarray(t,n)),r},ce=function(e,t,n,r){if(Z.prototype.fill)return Z.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},Tt=function(e,t,n,r){if(Z.prototype.copyWithin)return Z.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 Lt=[\"invalid zstd data\",\"window size too large (>2046MB)\",\"invalid block type\",\"FSE accuracy too high\",\"match distance too far back\",\"unexpected EOF\"],J=function(e,t,n){var r=Error(t||Lt[e]);if(r.code=e,Error.captureStackTrace)Error.captureStackTrace(r,J);if(!n)throw r;return r},Ke=function(e,t,n){var r=0,s=0;for(;r<n;++r)s|=e[t++]<<(r<<3);return s},Et=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},St=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,a=r>>6;if(r&8)J(0);var u=6-s,c=i==3?4:i,f=Ke(e,u,c);u+=c;var l=a?1<<a:s,p=Ke(e,u,l)+(a==1&&256),d=p;if(!s){var w=1<<10+(e[5]>>3);d=w+(w>>3)*(e[5]&7)}if(d>2145386496)J(1);var y=new Z((t==1?p||d:t?0:d)+12);return y[0]=1,y[4]=4,y[8]=8,{b:u+l,y:0,l:0,d:f,w:t&&t!=1?t:y.subarray(12),e:d,o:new be(y.buffer,0,3),u:p,c:o,m:Math.min(131072,d)}}else if((n>>4|e[3]<<20)==25481893)return Et(e,4)+8;J(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)J(3);var o=1<<s,i=o,a=-1,u=-1,c=-1,f=o,l=new vt(512+(o<<2)),p=new Ct(l,0,256),d=new de(l,0,256),w=new de(l,512,o),y=512+(o<<1),L=new Z(l,y,o),g=new Z(l,y+o);while(a<255&&i>0){var m=re(i+1),b=r>>3,h=(1<<m+1)-1,P=(e[b]|e[b+1]<<8|e[b+2]<<16)>>(r&7)&h,A=(1<<m)-1,E=h-i-1,T=P&A;if(T<E)r+=m,P=T;else if(r+=m+1,P>A)P-=E;if(p[++a]=--P,P==-1)i+=P,L[--f]=a;else i-=P;if(!P)do{var B=r>>3;u=(e[B]|e[B+1]<<8)>>(r&7)&3,r+=2,a+=u}while(u==3)}if(a>255||i)J(0);var v=0,F=(o>>1)+(o>>3)+3,Y=o-1;for(var _=0;_<=a;++_){var C=p[_];if(C<1){d[_]=-C;continue}for(c=0;c<C;++c){L[v]=_;do v=v+F&Y;while(v>=f)}}if(v)J(0);for(c=0;c<o;++c){var M=d[L[c]]++,k=g[c]=s-re(M);w[c]=(M<<k)-o}return[r+7>>3,{b:s,s:L,n:g,t:w}]},Pt=function(e,t){var n=0,r=-1,s=new Z(292),o=e[t],i=s.subarray(0,256),a=s.subarray(256,268),u=new de(s.buffer,268);if(o<128){var c=ue(e,t+1,6),f=c[0],l=c[1];t+=o;var p=f<<3,d=e[t];if(!d)J(0);var w=0,y=0,L=l.b,g=L,m=(++t<<3)-8+re(d);for(;;){if(m-=L,m<p)break;var b=m>>3;if(w+=(e[b]|e[b+1]<<8)>>(m&7)&(1<<L)-1,i[++r]=l.s[w],m-=g,m<p)break;b=m>>3,y+=(e[b]|e[b+1]<<8)>>(m&7)&(1<<g)-1,i[++r]=l.s[y],L=l.n[w],w=l.t[w],g=l.n[y],y=l.t[y]}if(++r>255)J(0)}else{r=o-127;for(;n<r;n+=2){var h=e[++t];i[n]=h>>4,i[n+1]=h&15}++t}var P=0;for(n=0;n<r;++n){var A=i[n];if(A>11)J(0);P+=A&&1<<A-1}var E=re(P)+1,T=1<<E,B=T-P;if(B&B-1)J(0);i[r++]=re(B)+1;for(n=0;n<r;++n){var A=i[n];++a[i[n]=A&&E+1-A]}var v=new Z(T<<1),F=v.subarray(0,T),Y=v.subarray(T);u[E]=0;for(n=E;n>0;--n){var _=u[n];ce(Y,n,_,u[n-1]=_+a[n]*(1<<E-n))}if(u[0]!=T)J(0);for(n=0;n<r;++n){var C=i[n];if(C){var M=u[C];ce(F,n,M,u[C]=M+(1<<E-C))}}return[t,{n:Y,b:E,s:F}]},kt=ue(new Z([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],It=ue(new Z([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],Bt=ue(new Z([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],We=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},Ee=new Z(new be([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),Ft=We(Ee,0),Se=new Z(new be([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),Rt=We(Se,3),le=function(e,t,n){var r=e.length,s=t.length,o=e[r-1],i=(1<<n.b)-1,a=-n.b;if(!o)J(0);var u=0,c=n.b,f=(r<<3)-8+re(o)-c,l=-1;for(;f>a&&l<s;){var p=f>>3,d=(e[p]|e[p+1]<<8|e[p+2]<<16)>>(f&7);u=(u<<c|d)&i,t[++l]=n.s[u],f-=c=n.n[u]}if(f!=a||l+1!=s)J(0)},Dt=function(e,t,n){var r=6,s=t.length,o=s+3>>2,i=o<<1,a=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,a),n),le(e.subarray(r),t.subarray(a),n)},Ut=function(e,t,n){var r,s=t.b,o=e[s],i=o>>1&3;t.l=o&1;var a=o>>3|e[s+1]<<5|e[s+2]<<13,u=(s+=3)+a;if(i==1){if(s>=e.length)return;if(t.b=s+1,n)return ce(n,e[s],t.y,t.y+=a),n;return ce(new Z(a),e[s])}if(u>e.length)return;if(i==0){if(t.b=u,n)return n.set(e.subarray(s,u),t.y),t.y+=a,n;return Le(e,s,u)}if(i==2){var c=e[s],f=c&3,l=c>>2&3,p=c>>4,d=0,w=0;if(f<2)if(l&1)p|=e[++s]<<4|(l&2&&e[++s]<<12);else p=c>>3;else if(w=l,l<2)p|=(e[++s]&63)<<4,d=e[s]>>6|e[++s]<<2;else if(l==2)p|=e[++s]<<4|(e[++s]&3)<<12,d=e[s]>>2|e[++s]<<6;else p|=e[++s]<<4|(e[++s]&63)<<12,d=e[s]>>6|e[++s]<<2|e[++s]<<10;++s;var y=n?n.subarray(t.y,t.y+t.m):new Z(t.m),L=y.length-p;if(f==0)y.set(e.subarray(s,s+=p),L);else if(f==1)ce(y,e[s++],L);else{var g=t.h;if(f==2){var m=Pt(e,s);d+=s-(s=m[0]),t.h=g=m[1]}else if(!g)J(0);(w?Dt:le)(e.subarray(s,s+=d),y.subarray(L),g)}var b=e[s++];if(b){if(b==255)b=(e[s++]|e[s++]<<8)+32512;else if(b>127)b=b-128<<8|e[s++];var h=e[s++];if(h&3)J(0);var P=[It,Bt,kt];for(var A=2;A>-1;--A){var E=h>>(A<<1)+2&3;if(E==1){var T=new Z([0,0,e[s++]]);P[A]={s:T.subarray(2,3),n:T.subarray(0,1),t:new de(T.buffer,0,1),b:0}}else if(E==2)r=ue(e,s,9-(A&1)),s=r[0],P[A]=r[1];else if(E==3){if(!t.t)J(0);P[A]=t.t[A]}}var B=t.t=P,v=B[0],F=B[1],Y=B[2],_=e[u-1];if(!_)J(0);var C=(u<<3)-8+re(_)-Y.b,M=C>>3,k=0,G=(e[M]|e[M+1]<<8)>>(C&7)&(1<<Y.b)-1;M=(C-=F.b)>>3;var I=(e[M]|e[M+1]<<8)>>(C&7)&(1<<F.b)-1;M=(C-=v.b)>>3;var N=(e[M]|e[M+1]<<8)>>(C&7)&(1<<v.b)-1;for(++b;--b;){var j=Y.s[G],X=Y.n[G],W=v.s[N],S=v.n[N],x=F.s[I],R=F.n[I];M=(C-=x)>>3;var D=1<<x,U=D+((e[M]|e[M+1]<<8|e[M+2]<<16|e[M+3]<<24)>>>(C&7)&D-1);M=(C-=Se[W])>>3;var H=Rt[W]+((e[M]|e[M+1]<<8|e[M+2]<<16)>>(C&7)&(1<<Se[W])-1);M=(C-=Ee[j])>>3;var z=Ft[j]+((e[M]|e[M+1]<<8|e[M+2]<<16)>>(C&7)&(1<<Ee[j])-1);if(M=(C-=X)>>3,G=Y.t[G]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<X)-1),M=(C-=S)>>3,N=v.t[N]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<S)-1),M=(C-=R)>>3,I=F.t[I]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<R)-1),U>3)t.o[2]=t.o[1],t.o[1]=t.o[0],t.o[0]=U-=3;else{var V=U-(z!=0);if(V){if(U=V==3?t.o[0]-1:t.o[V],V>1)t.o[2]=t.o[1];t.o[1]=t.o[0],t.o[0]=U}else U=t.o[0]}for(var A=0;A<z;++A)y[k+A]=y[L+A];k+=z,L+=z;var O=k-U;if(O<0){var K=-O,q=t.e+O;if(K>H)K=H;for(var A=0;A<K;++A)y[k+A]=t.w[q+A];k+=K,H-=K,O=0}for(var A=0;A<H;++A)y[k+A]=y[O+A];k+=H}if(k!=L)while(L<y.length)y[k++]=y[L++];else k=y.length;if(n)t.y+=k;else y=Le(y,0,k)}else if(n){if(t.y+=p,L)for(var A=0;A<p;++A)y[A]=y[L+A]}else if(L)y=Le(y,L);return t.b=u,y}J(2)},Ot=function(e,t){if(e.length==1)return e[0];var n=new Z(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 ye(e,t){var n=[],r=+!t,s=0,o=0;for(;e.length;){var i=St(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 a=Ut(e,i,t);if(!a)J(5);if(t)i.e=i.y;else n.push(a),o+=a.length,Tt(i.w,0,a.length),i.w.set(a,i.w.length-a.length)}s=i.b+i.c*4}else s=i;e=e.subarray(s)}return Ot(n,o)}async function Nt(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=(r)=>r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);if(t[0]===40&&t[1]===181&&t[2]===47&&t[3]===253)return n(ye(t));if(t[0]===31&&t[1]===139)return new Response(new Blob([t]).stream().pipeThrough(new DecompressionStream(\"gzip\"))).arrayBuffer();return n(t)}async function Xe(e){return new TextDecoder().decode(await Nt(e))}var Ze=(e)=>decodeURIComponent(e.split(/[?#]/)[0].split(\"/\").pop()||\"main.ldr\").replace(/\\.(zst|gz)$/i,\"\")||\"main.ldr\";function xe(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 Q=(e)=>e.trim().toLowerCase().replace(/\\\\/g,\"/\").replace(/\\/+/g,\"/\"),ke=/^[A-Za-z][A-Za-z0-9_]*$/,Pe=new Map;function Ie(e){let t=e.toLowerCase(),n=2166136261;for(let s=0;s<t.length;s++)n^=t.charCodeAt(s),n=Math.imul(n,16777619);let r=-1-(n>>>0&1073741823);if(!Pe.has(r))Pe.set(r,t);return r}function Be(e){let t=e.charCodeAt(0)|32;if(t>=97&&t<=122&&ke.test(e))return Ie(e);if(/^0x/i.test(e))return parseInt(e,16);return+e}var Ye=/^~?\\s*moved\\s+to\\s+(.+)$/i,zt=new Set([\"FILE\",\"NOFILE\",\"!DATA\",\"!:\",\"STEP\",\"BFC\",\"ROTSTEP\",\"BUFEXCHG\",\"!TEXMAP\"]),st=new Set([\"part\",\"subpart\",\"primitive\",\"8_primitive\",\"48_primitive\",\"shortcut\",\"helper\"]),$t=new Set([\"model\",\"submodel\",\"configuration\"]),jt=/^(?:!?LDRAW_ORG|Unofficial|Official\\s+LCAD)\\s+(\\S+)/i;function Je(e){let t=jt.exec(e);if(!t)return;let n=t[1].toLowerCase().replace(/^unofficial_/,\"\");return st.has(n)||$t.has(n)?n:void 0}function Vt(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 _t(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 a=n[2].trim();for(let l=0;l<s;l++)a=a.replace(/^\\S+\\s*/,\"\");let u=Vt(a);if(!u.length)return null;let c={method:r,p1:i.slice(0,3),p2:i.slice(3,6),p3:i.slice(6,9),texture:u[0]};if(s>=10)c.a=i[9];if(s===11)c.b=i[10];let f=u.findIndex((l,p)=>p>0&&l.toUpperCase()===\"GLOSSMAP\");if(f>0&&u[f+1])c.glossmap=u[f+1];if(t)c.next=!0;return c}var Ht=(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 Gt(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 f=s();if(f===null)return null;i[c]=+f}while(n<t&&r(e.charCodeAt(n)))n++;if(n>=t)return null;let a=e.slice(n),u=/[ \\t]{2,}|\\t/.test(a)?a.split(/\\s+/).join(\" \"):a;return{t:1,color:Be(o),m:i,file:Q(u)}}function qe(e){let t=+e[0];if(!(t>=1&&t<=5)||e.length<2)return null;let n=Be(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 ot(e,t=\"main.ldr\",n={}){let r=!!n.geometryText,s=new Map,o=null,i=\"\",a,u=null,c=[],f=null,l=()=>{if(!u)return;let m=Ht(u.chunks.join(\"\")),b=m[0]===137&&m[1]===80&&m[2]===78&&m[3]===71;(a??=new Map).set(Q(u.name),{name:u.name,bytes:m,...b?{mime:\"image/png\"}:{}}),u=null},p=!0,d=(m)=>{if(l(),o={name:Q(m),cmds:[]},s.set(o.name,o),!i)i=o.name;c=[],f=null,p=!0},w=!1,y=!1,L=()=>{if(y)return;y=!0,s.clear(),o=null,i=\"\"},g=(m,b)=>{if(f){m.tex=f,f=null;return}let h=c[c.length-1];if(!h)return;if(h.fallback){if(!b)m.fallback=!0}else m.tex=h.map};for(let m of e.split(`\n`)){let b=m.trim();if(!b)continue;if(r&&b.charCodeAt(0)>=50&&b.charCodeAt(0)<=53&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)){if(u||w)continue;if(!o)d(t);let E=b.slice(2).trimStart(),T=E.search(/\\s/),B={t:b.charCodeAt(0)-48,color:Be(T<0?E:E.slice(0,T)),p:[],src:b};g(B,!1),o.cmds.push(B),p=!1;continue}if(b.charCodeAt(0)===48&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)){let E=2;while(b.charCodeAt(E)===32||b.charCodeAt(E)===9)E++;let T=E;while(T<b.length&&b.charCodeAt(T)!==32&&b.charCodeAt(T)!==9)T++;let B=b.slice(E,T);if(!zt.has(B)){if(w||u)continue;if(!o)d(t);let v=b.slice(E),F={t:0,text:v};if(B.charCodeAt(0)===33)F.meta=B;if(f=null,p&&!o.org){let _=Je(v);if(_)o.org=_}let Y=v.match(Ye);if(Y&&!o.movedTo){let _=Y[1].trim().replace(/\\\\/g,\"/\");if(!/\\.(dat|ldr|mpd)$/i.test(_))_+=\".dat\";o.movedTo=Q(_)}o.cmds.push(F);continue}}if(b.charCodeAt(0)===49&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)&&!u&&!w){let E=Gt(b);if(E){if(!o)d(t);g(E,!1),o.cmds.push(E),p=!1;continue}}let h=b.split(/\\s+/);if(+h[0]===0){let E=b.slice(1).trim();if(h[1]===\"FILE\"){L(),w=!1,d(E.slice(5));continue}if(h[1]===\"NOFILE\"){l(),o=null,w=!0;continue}if(h[1]===\"!DATA\"){L(),l(),o=null,w=!1,u={name:E.slice(5).trim(),chunks:[]};continue}if(w)continue;if(u){if(h[1]===\"!:\")u.chunks.push(h.slice(2).join(\"\"));continue}if(!o)d(t);let T={t:0,text:E};if(h[1]===\"STEP\")T.step=!0,c=[],f=null;else if(h[1]===\"BFC\")T.bfc=h.slice(2).join(\" \");else if(h[1]===\"ROTSTEP\")if(T.meta=\"ROTSTEP\",T.step=!0,c=[],f=null,(h[2]??\"\").toUpperCase()===\"END\")T.rotstep={x:0,y:0,z:0,mode:\"END\"};else{let v=(h[5]??\"REL\").toUpperCase();T.rotstep={x:+h[2]||0,y:+h[3]||0,z:+h[4]||0,mode:[\"REL\",\"ABS\",\"ADD\"].includes(v)?v:\"REL\"}}else if(h[1]===\"BUFEXCHG\"){T.meta=\"BUFEXCHG\";let v=(h[2]??\"\").toUpperCase();T.bufexchg={op:v===\"RETRIEVE\"?\"RETRIEVE\":\"STORE\",buf:h[3]??\"A\"}}else if(h[1]?.startsWith(\"!\"))T.meta=h[1];if(p&&!o.org){let v=Je(E);if(v)o.org=v}if(h[1]===\"!TEXMAP\"){let v=(h[2]??\"\").toUpperCase();if(f=null,v===\"START\"||v===\"NEXT\"){let F=_t(E.replace(/^!TEXMAP\\s+\\S+/i,\"\"),v===\"NEXT\");if(T.texmap={op:v,...F?{map:F}:{}},F)if((o.texmaps??=[]).push(F),v===\"START\")c.push({map:F,fallback:!1});else f=F}else if(v===\"FALLBACK\"){T.texmap={op:v};let F=c[c.length-1];if(F)F.fallback=!0}else if(v===\"END\")T.texmap={op:v},c.pop()}else if(h[1]===\"!:\"){f=null;let v=qe(h.slice(2));if(v)g(v,!0),T.geom=v}else f=null;let B=E.match(Ye);if(B&&!o.movedTo){let v=B[1].trim().replace(/\\\\/g,\"/\");if(!/\\.(dat|ldr|mpd)$/i.test(v))v+=\".dat\";o.movedTo=Q(v)}o.cmds.push(T);continue}if(u||w)continue;if(!o)d(t);let A=qe(h);if(!A)continue;g(A,!1),o.cmds.push(A),p=!1}return l(),a?{main:i,files:s,data:a}:{main:i,files:s}}var yn=Math.PI/180;function it(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 at(e,t){let[n,r,s,o,i,a,u,c,f,l,p,d]=e,[w,y,L,g,m,b,h,P,A,E,T,B]=t;return[o*w+i*y+a*L+n,u*w+c*y+f*L+r,l*w+p*y+d*L+s,o*g+i*h+a*E,o*m+i*P+a*T,o*b+i*A+a*B,u*g+c*h+f*E,u*m+c*P+f*T,u*b+c*A+f*B,l*g+p*h+d*E,l*m+p*P+d*T,l*b+p*A+d*B]}var Fe=[0,0,0,1,0,0,0,1,0,0,0,1];var Qe=new WeakMap,Kt=/^(s|8|48)\\//;function Re(e,t){let n=e.files.get(Q(t));if(!n)return\"part\";let r=Qe.get(n);if(r)return r;if(n.org)r=st.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&&Kt.test(s.file))?\"part\":\"model\";return Qe.set(n,r),r}var et=new WeakMap;function lt(e){let t=et.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 et.set(e,t),t}var tt=(e)=>e>16777215?\"0x\"+e.toString(16).toUpperCase():e<0?Pe.get(e)??String(e):String(e),Wt=(e)=>e.t===0?\"0 \"+e.text:e.t===1?`1 ${tt(e.color)} ${e.m.join(\" \")} ${e.file}`:e.src?e.src:`${e.t} ${tt(e.color)} ${e.p.join(\" \")}`,De=(e,t)=>`${Q(e)}#${t}`;function Xt(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:De(e.name,t),cmds:n}}function ct(e,t){return[`0 ldr: own geometry of ${e.name}, step ${t}`,...Xt(e,t).cmds.map(Wt)].join(`\n`)+`\n`}function Zt(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 ut(e){let[t,n,r,s,o,i,a,u,c,f,l,p]=e,d=u*p-c*l,w=-(a*p-c*f),y=a*l-u*f,L=s*d+o*w+i*y;if(!Number.isFinite(L)||Math.abs(L)<0.000000000001)return null;let g=1/L,m=[d*g,-(o*p-i*l)*g,(o*c-i*u)*g,w*g,(s*p-i*f)*g,-(s*c-i*a)*g,y*g,-(s*l-o*f)*g,(s*u-o*a)*g];return[-(m[0]*t+m[1]*n+m[2]*r),-(m[3]*t+m[4]*n+m[5]*r),-(m[6]*t+m[7]*n+m[8]*r),...m]}var Yt=(e)=>String(+e.toFixed(6)||0),nt=(e)=>'\"'+e.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,\"\\\\\\\"\")+'\"';function ft(e,t){let n=[...t.p1,...t.p2,...t.p3,...t.method!==\"PLANAR\"?[t.a??360]:[],...t.method===\"SPHERICAL\"?[t.b??180]:[]].map(Yt).join(\" \"),r=`0 ldr: ${e} with a model-level !TEXMAP\n0 BFC CERTIFY CCW\n0 !TEXMAP START ${t.method} ${n} ${nt(t.texture)}${t.glossmap?\" GLOSSMAP \"+nt(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-${Zt(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 qt(e,t,n){let r=Math.PI/180,s=Math.sin(e*r),o=Math.cos(e*r),i=Math.sin(t*r),a=Math.cos(t*r),u=Math.sin(n*r),c=Math.cos(n*r);return[a*c,-a*u,i,o*u+s*i*c,o*c-s*i*u,-s*a,s*u-o*i*c,s*c+o*i*u,o*a]}var rt=new WeakMap;function pt(e){let t=rt.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=qt(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),rt.set(e,n),n}var mt=999999,gt=(e)=>e.map((t)=>String(t).padStart(6,\"0\")).join(\".\")+\"~\";function Qt(e,t={}){let n=[],r=t.maxDepth??64,s=t.looseGeometry!==!1,o=!!t.textures,i=!!t.callouts,a=new Map,u=0,c=(l,p)=>{let d=l.name+\"#\"+p,w=a.get(d);if(!w){let y;w=Object.assign(()=>y??=ct(l,p),{file:l,step:p}),a.set(d,w)}return w},f=(l,p,d,w,y,L,g,m,b=null,h=[],P=[],A=void 0,E=null)=>{let T=l.files.get(p);if(!T||g>r)return;let B=E,v=0,F=g>0?++u:0,Y=i&&F?[...h,F]:h,_=i&&F?[...P,d]:P,C=i&&!b?new Map:null,M=-1,k=0,G=(S,x,R,D,U,H,z)=>{if(M!==v)M=v,k=0;let V=C?.get(v+\"|\"+x);if(V)return V.n++,f(S,S===l?x:S.main,R,D,y+\"/\"+x,[...U,mt],g+1,H,[...U,mt],Y,_,z,B);let O=[...U,k++],K=n.length;f(S,S===l?x:S.main,R,D,y+\"/\"+x,O,g+1,H,b,Y,_,z,B),C?.set(v+\"|\"+x,{n:1,from:K,to:n.length})},I=pt(T),N=s?lt(T):[],j=0,X=(S,x,R,D,U,H,z,V)=>{if(b)D=b;let O={part:S,color:x,m:R,step:D[0],steps:D,localStep:U,path:y};if(V)O.colour=V;if(F){if(O.sub=F,i)O.subPath=Y,O.subMats=_}if(H)O.embedded=!0;if(z){let q=ft(S,z);O.texPart=q.name,O.texSource=q.source}let K=I[U];if(K)O.view=K;return n.push(O),O},W=(S)=>{while(j<N.length&&N[j]<=S){let x=N[j++];X(De(T.name,x),w,d,[...L,x],x,!1,null,A).source=c(T,x)}};for(let S of T.cmds){if(S.t===0&&S.step){v++;continue}let x=S;if(x.t>=2||x.t===0&&x.geom&&x.geom.t>=2){W(v);continue}if(x.t===0){if(x.meta===\"!COLOUR\"){let q=tn(x.text);if(q&&q.code!==16&&q.code!==24)(B=new Map(B??[])).set(q.code,q);continue}if(o&&x.geom?.t===1)x=x.geom;else continue}if(x.t!==1)continue;if(o&&x.fallback)continue;let R=x.color===16?w:x.color,D=x.color===16?A:B?.get(x.color),U=at(d,x.m),H=[...L,v],z=o?x.tex??m:null,V=z?ut(x.m):null,O=z&&V?it(z,V):null;if(l.files.has(x.file)){if(Re(l,x.file)===\"model\"){G(l,x.file,U,R,H,O,D);continue}X(x.file,R,U,H,v,!0,O,D);continue}let K=t.resolveModel?.(x.file);if(K){G(K,x.file,U,R,H,O,D);continue}X(x.file,R,U,H,v,!1,O,D)}if(W(1/0),C){for(let S of C.values())if(S.n>1)for(let x=S.from;x<S.to;x++)n[x].mult??=S.n}};if(Re(e,e.main)===\"part\"){if(e.files.get(e.main))n.push({part:e.main,color:16,m:[...Fe],step:0,steps:[0],localStep:0,path:e.main,embedded:!0});return n}return f(e,e.main,Fe,16,e.main,[],0,null),n}function dt(e,t=\"main.ldr\",n){return Qt(ot(e,t,{geometryText:!0}),n)}var en=new Set([\"CHROME\",\"PEARLESCENT\",\"RUBBER\",\"MATTE_METALLIC\",\"METAL\",\"MATERIAL\"]);function Ue(e){if(!e)return null;if(e.startsWith(\"#\")&&/^#[0-9A-Fa-f]{6}$/.test(e))return e.toUpperCase();if(/^0x[0-9A-Fa-f]{6}$/i.test(e))return(\"#\"+e.slice(2)).toUpperCase();return null}function ht(e,t){let n={value:\"#FFFFFF\",fraction:0.5};while(t<e.length){let r=e[t].toUpperCase(),s=e[t+1];if(r===\"VALUE\"){let o=Ue(s);if(o)n.value=o;t+=2}else if(r===\"ALPHA\")n.alpha=+s,t+=2;else if(r===\"LUMINANCE\")n.luminance=+s,t+=2;else if(r===\"FRACTION\")n.fraction=+s,t+=2;else if(r===\"VFRACTION\")n.vfraction=+s,t+=2;else if(r===\"SIZE\")n.size=+s,t+=2;else if(r===\"MINSIZE\")n.minsize=+s,t+=2;else if(r===\"MAXSIZE\")n.maxsize=+s,t+=2;else break}return{grain:n,next:t}}function tn(e){let t=e.indexOf(\"!COLOUR\");if(t<0)return null;let n=e.slice(t+7).trim().split(/\\s+/).filter(Boolean);if(n.length<2)return null;let r=n[0],s=NaN,o=\"#FF00FF\",i=\"#333333\",a=255,u=0,c={type:\"default\"},f=1;while(f<n.length){let l=n[f].toUpperCase(),p=n[f+1];if(l===\"CODE\")s=p!==void 0&&ke.test(p)?Ie(p):p!==void 0&&/^\\d+$/.test(p)?+p:NaN,f+=2;else if(l===\"VALUE\"){let d=Ue(p);if(d)o=d;f+=2}else if(l===\"EDGE\")i=Ue(p)??p,f+=2;else if(l===\"ALPHA\")a=+p,f+=2;else if(l===\"LUMINANCE\")u=+p,f+=2;else if(l===\"CHROME\")c={type:\"chrome\"},f+=1;else if(l===\"PEARLESCENT\")c={type:\"pearlescent\"},f+=1;else if(l===\"RUBBER\")c={type:\"rubber\"},f+=1;else if(l===\"MATTE_METALLIC\")c={type:\"matte_metallic\"},f+=1;else if(l===\"METAL\")c={type:\"metal\"},f+=1;else if(l===\"MATERIAL\"){let d=(n[f+1]||\"\").toUpperCase();if(d===\"GLITTER\"){let{grain:w,next:y}=ht(n,f+2);c={type:\"glitter\",material:w},f=y}else if(d===\"SPECKLE\"){let{grain:w,next:y}=ht(n,f+2);c={type:\"speckle\",material:w},f=y}else if(d===\"FABRIC\"){let w=(n[f+2]||\"\").toUpperCase(),y=[\"VELVET\",\"CANVAS\",\"STRING\",\"FUR\"].includes(w)?w.toLowerCase():void 0;c={type:\"fabric\",kind:y},f+=y?3:2}else f=n.length}else if(en.has(l))f+=1;else f+=1}if(Number.isNaN(s)||!o)return null;return{code:s,name:r,hex:o,edge:i,alpha:Number.isFinite(a)?a:255,luminance:Number.isFinite(u)?u:0,finish:c}}function nn(e){let t=Math.max(0,Math.min(1,(e.alpha??255)/255)),n=t<1,r=Math.max(0,Math.min(1,(e.luminance??0)/255)),s={opacity:t,transparent:n,depthWrite:!n,emissive:r,clearcoat:0,clearcoatRoughness:0,sheen:0,sheenRoughness:0};switch(e.finish?.type??\"default\"){case\"chrome\":return{...s,metalness:1,roughness:0,finish:\"chrome\"};case\"pearlescent\":return{...s,metalness:0.25,roughness:0.3,clearcoat:0.5,clearcoatRoughness:0.25,sheen:0.4,sheenRoughness:0.35,finish:\"pearlescent\"};case\"rubber\":return{...s,metalness:0,roughness:0.9,finish:\"rubber\"};case\"matte_metallic\":return{...s,metalness:0.4,roughness:0.8,finish:\"matte_metallic\"};case\"metal\":return{...s,metalness:0.85,roughness:0.2,finish:\"metal\"};case\"glitter\":{let i=e.finish.material,a=i.size??(i.minsize!=null&&i.maxsize!=null?(i.minsize+i.maxsize)/2:1);return{...s,metalness:0.35,roughness:0.25,clearcoat:1,clearcoatRoughness:0.08,particleHex:i.value,particleFraction:i.fraction,particleSize:a,finish:\"glitter\"}}case\"speckle\":{let i=e.finish.material,a=i.size??(i.minsize!=null&&i.maxsize!=null?(i.minsize+i.maxsize)/2:1);return{...s,metalness:0.2,roughness:0.55,particleHex:i.value,particleFraction:i.fraction,particleSize:a,finish:\"speckle\"}}case\"fabric\":return{...s,metalness:0,roughness:0.85,sheen:0.65,sheenRoughness:0.75,finish:\"fabric\"};default:return{...s,metalness:0,roughness:0.45,finish:\"default\"}}}function Oe(e){let t=nn(e),n=!t.transparent?\"op\":t.opacity>=0.75?\"a200\":t.opacity>=0.4?\"a128\":`a${Math.round(t.opacity*255)}`,r=t.emissive>0?`L${Math.round(t.emissive*16)}`:\"\",s=`${t.finish}:${n}${r}`;if(t.particleHex)s+=`:${t.particleHex}:${(t.particleFraction??0).toFixed(2)}`;return s}function rn(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(Q(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(Q(t),r)}let a=o.trim().replace(/\\s+/g,\" \");if(a)r.push(a)}return n}var sn=(e)=>{if(!e.startsWith(\"1 \"))return null;let t=e.split(\" \");return t.length>=15?Q(t.slice(14).join(\" \")):null};function on(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 bt(e,t,n=\"main.ldr\"){let r=rn(e,n),s=new Map;for(let o of t){let i=Q(o);if(!r.has(i)||s.has(i))continue;let a=new Set([i]),u=[i];while(u.length)for(let f of r.get(u.pop())){let l=sn(f);if(l&&r.has(l)&&!a.has(l))a.add(l),u.push(l)}let c=[i,...[...a].filter((f)=>f!==i).sort()].map((f)=>\"0 FILE \"+(f===i?\"\":f)+`\n`+r.get(f).join(`\n`)).join(`\n`);s.set(i,`emb/${on(c)}.dat`)}return s}var yt=(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,xt=new WeakMap;function Ne(e,t){let n=xt.get(e);if(!n)xt.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),a=[],u=[];s.studs.forEach((p,d)=>{a.push(p[0]),u.push(p[1]);for(let w=0;w<12;w++)i[d*12+w]=p[2+w]});let c=null,f=0,l=0;if(s.mask){f=s.mask[0],l=s.mask[1];let p=s.mask[2];c=new Uint8Array(p.length);for(let d=0;d<p.length;d++)c[d]=p.charCodeAt(d)===49?1:0}return n.set(t,r={nStuds:o,studM:i,kind:a,color:u,mask:c,nx:f,nz:l}),r}var ie=1073741824;class ze{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,a=this.c;for(;;){if(!s[r])return-1;if(o[r]===e&&i[r]===t&&a[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,a=this.b,u=this.c;for(;;){if(!o[s])return o[s]=1,i[s]=e,a[s]=t,u[s]=n,this.vals[s]=r,this.size++,-1;if(i[s]===e&&a[s]===t&&u[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 we=(e,t,n)=>e>-ie&&e<ie&&t>-ie&&t<ie&&n>-ie&&n<ie,fe=2147483647;function an(e,t,n){let s=[],o=[],i=[],a=[],u=[],c=[],f=[],l=[],p=new ze(e.length*2),d=[],w=[];for(let C=0;C<e.length;C++){let M=e[C],k=M.m,G=t.parts[M.part];if(!G||!G.mask||!yt(k))continue;let I=G.bbox,N=1/0,j=-1/0,X=1/0,W=-1/0;for(let R=0;R<2;R++)for(let D=0;D<2;D++){let U=R?I[3]:I[0],H=D?I[5]:I[2],z=k[0]+k[3]*U+k[5]*H,V=k[2]+k[9]*U+k[11]*H;if(z<N)N=z;if(z>j)j=z;if(V<X)X=V;if(V>W)W=V}let S=u.length;s.push(N),o.push(j),i.push(X),a.push(W),u.push(C),c.push(Ne(t,M.part)),f.push(I[0]),l.push(I[2]);let x=Math.round((k[1]+I[4])*2);for(let R=Math.floor(N/40);R<=Math.floor(j/40);R++)for(let D=Math.floor(X/40);D<=Math.floor(W/40);D++){if(!we(x,R,D))continue;let U=w.length;w.push(S),d.push(p.put(x,R,D,U))}}let y=[0,5,-5,5,-5],L=[0,5,5,-5,-5],g=NaN,m=NaN,b=NaN,h=-1,P=(C,M,k,G)=>{let I=Math.round(M*2),N=Math.floor(C/40),j=Math.floor(k/40);if(!we(I,N,j))return fe;let X=fe;if(I!==g||N!==m||j!==b)g=I,m=N,b=j,h=p.get(I,N,j);for(let W=h;W>=0;W=d[W]){let S=w[W];if(u[S]===G||!(C-6>=s[S]-0.5&&C+6<=o[S]+0.5&&k-6>=i[S]-0.5&&k+6<=a[S]+0.5))continue;let x=e[u[S]].m,R=c[S],D=f[S],U=l[S],H=C-x[0],z=M-x[1],V=k-x[2],O=x[3]*H+x[6]*z+x[9]*V,K=x[5]*H+x[8]*z+x[11]*V,{nx:q,nz:se,mask:ae}=R,oe=!0;for(let ee=0;ee<5;ee++){let te=Math.floor((O+y[ee]-D)/20),ne=Math.floor((K+L[ee]-U)/20);if(te<0||ne<0||te>=q||ne>=se||ae[te*se+ne]!==1){oe=!1;break}}if(oe){if(!n)return 0;let ee=n[u[S]];if(ee<X)X=ee}}return X},A=0;for(let C of e){let M=Ne(t,C.part);if(M)A+=M.nStuds}let E=new Uint8Array(A),T=new Uint8Array(A),B=new ze(A),v=0,F=n?new Int32Array(A).fill(fe):void 0;for(let C=0,M=0;C<e.length;C++){let k=e[C],G=Ne(t,k.part);if(!G)continue;let I=k.m,N=G.studM,j=I[0],X=I[1],W=I[2],S=I[3],x=I[4],R=I[5],D=I[6],U=I[7],H=I[8],z=I[9],V=I[10],O=I[11];for(let K=0;K<G.nStuds;K++,M++){let q=K*12,se=N[q+4],ae=N[q+7],oe=N[q+10];if(!(Math.abs(D*se+U*ae+H*oe-1)<0.001&&Math.abs(S*se+x*ae+R*oe)<0.001&&Math.abs(z*se+V*ae+O*oe)<0.001))continue;T[M]=1;let ee=N[q],te=N[q+1],ne=N[q+2],$e=j+S*ee+x*te+R*ne,je=X+D*ee+U*te+H*ne,Ve=W+z*ee+V*te+O*ne,_e=P($e,je,Ve,C);if(_e!==fe){if(E[M]=1,v++,F)F[M]=_e}let me=Math.round($e),he=Math.round(je),ge=Math.round(Ve);if(!we(me,he,ge))continue;if(!n){B.put(me,he,ge,1);continue}let He=n[C],Ge=B.get(me,he,ge);if(Ge<0||He<Ge)B.put(me,he,ge,He)}}let Y=new Uint8Array(e.length),_=n?new Int32Array(e.length).fill(fe):void 0;for(let C=0;C<e.length;C++){let M=e[C],k=t.parts[M.part];if(!k||!k.under||!yt(M.m))continue;let G=k.bbox,I=Math.round((G[3]-G[0])/20),N=Math.round((G[5]-G[2])/20);if(!I||!N||I*N>4096)continue;let j=M.m,X=!0,W=0;for(let S=0;S<I&&X;S++)for(let x=0;x<N;x++){let R=G[0]+10+20*S,D=G[2]+10+20*x,U=j[0]+j[3]*R+j[5]*D,H=j[2]+j[9]*R+j[11]*D,z=Math.round(U),V=Math.round(j[1]+G[4]),O=Math.round(H),K=we(z,V,O)?B.get(z,V,O):-1;if(K<0){X=!1;break}if(K>W)W=K}if(X){if(Y[C]=1,_)_[C]=W}}return{nStuds:A,studHidden:E,studUp:T,underHidden:Y,studsHidden:v,studHideStep:F,underHideStep:_}}function ln(e,t,n){let r=(l)=>n&&l.texPart&&t.parts[l.texPart]?l.texPart:l.part,s=new Map,o=new Map,i=(l)=>{let p=l.colour;if(!p)return String(l.color);let d=o.get(p);if(d!==void 0)return d;let w=t.colorTable?.[l.color],y=w?.hex??t.colors?.[l.color],L=w?Oe({alpha:w.alpha??255,luminance:w.luminance??0,finish:w.finish??{type:\"default\"}}):\"default:op\",g=Oe(p);if(d=y&&y.toUpperCase()===p.hex.toUpperCase()&&L===g?String(l.color):p.hex.toUpperCase()+\"/\"+g,d!==String(l.color))s.set(d,p);return o.set(p,d),d},a=e.map((l)=>({part:r(l),color:i(l),m:l.m,steps:l.steps})),u=a.map((l)=>gt(l.steps)),c=[...new Set(u)].sort(),f=new Map(c.map((l,p)=>[l,p]));return{all:a,stepOf:u.map((l)=>f.get(l)),nSteps:c.length,localColours:s}}function Ae(e,t,n=!0){let r=ln(e,t,n);return an(r.all,t,r.nSteps>1?r.stepOf:void 0)}var Te=\"https://ldr-demo.vercel.app/cdn/v1/\",ve=new Map,Me=new Map;function At(e=Te,t=fetch){let n=ve.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(()=>ve.delete(e)),ve.set(e,n);return n}var cn=(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\"),Ce=(e,t)=>cn(e)?[e[0]+t,e[1],e[2]]:Array.isArray(e)?e.map((n)=>Ce(n,t)):e&&typeof e===\"object\"?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,Ce(r,t)])):e;function un(e,t={}){let n=[],r=0,s={},o={};for(let p of e){let d=p.buffer;if(!d)throw Error(\"ldr: mergePacks needs packs from decodePack/loadPack\");let w=new DataView(d).getUint32(0,!0),y=new Uint8Array(d,4+w),L=r;n.push(y),r+=y.byteLength;let g=(4-r%4)%4;if(g)n.push(new Uint8Array(g)),r+=g;for(let[m,b]of Object.entries(p.header.parts??{}))if(!(m in s))s[m]=Ce(b,L);for(let[m,b]of Object.entries(p.header.studKinds??{}))if(!(m in o))o[m]=Ce(b,L)}let i=e[0]?.header??{version:1,weld:!0},a=new TextEncoder().encode(JSON.stringify({...i,parts:s,studKinds:o,...t})),u=(4-(4+a.length)%4)%4,c=4+a.length+u,f=new Uint8Array(c+r);new DataView(f.buffer).setUint32(0,a.length+u,!0),f.set(a,4),f.fill(32,4+a.length,c);let l=c;for(let p of n)f.set(p,l),l+=p.byteLength;return xe(f.buffer)}async function fn(e,t={}){e=[...e];try{return await wt(e,t)}catch(n){let r=t.cdn??Te,s=t.fetch??fetch;ve.delete(r);let o=(i,a)=>s(i,{...a,cache:\"reload\"});try{return await wt(e,{...t,fetch:o})}catch{throw n}}}async function wt(e,t){let n=t.cdn??Te,r=t.fetch??fetch,s=t.gap??16384,o=await At(n,r),i=[...new Set([...e].map(Q))],a=[],u=[];for(let g of i){if(Me.has(n+g))continue;let m=o.parts[g];if(m)u.push({name:g,off:m[0],len:m[1],file:m[2]??0});else a.push(g)}u.sort((g,m)=>g.file-m.file||g.off-m.off);let c=[];for(let g of u){let m=c[c.length-1];if(m&&m.file===g.file&&g.off-m.end<=s)m.end=Math.max(m.end,g.off+g.len),m.items.push(g);else c.push({file:g.file,start:g.off,end:g.off+g.len,items:[g]})}let f=0,l=0,p=0,d=new Map,w=async()=>{while(p<c.length){let g=c[p++],m=d.get(g.file);if(m)m=m.subarray(g.start,g.end);else{let b=await r(new URL(o.archives[g.file],n).href,{headers:{Range:`bytes=${g.start}-${g.end-1}`,\"Accept-Encoding\":\"identity\"}});if(!b.ok)throw Error(`ldr: parts CDN ${b.status}`);if(l++,m=new Uint8Array(await b.arrayBuffer()),f+=m.byteLength,b.status===200)d.set(g.file,m),m=m.subarray(g.start,g.end)}for(let b of g.items){let h=ye(m.subarray(b.off-g.start,b.off-g.start+b.len)),P=h.buffer.slice(h.byteOffset,h.byteOffset+h.byteLength);Me.set(n+b.name,xe(P))}}};await Promise.all(Array.from({length:Math.min(t.concurrency??24,c.length)},w));let y=i.filter((g)=>Me.has(n+g)).map((g)=>Me.get(n+g));return{pack:y.length?un(y,{colors:o.colors}):xe(pn(o.colors)),missing:a,requests:l,bytes:f}}function pn(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}function mn(e,t){let n=t.header.parts;if(!n)return 0;let r=0;for(let s of e){let o=n[s.part]?.body?.tris;if(o)r+=o}return r}function hn(e,t,n){let r=0,s=0,o=!1,i=new Set;for(let a of e){let u=a.embedded?t.get(a.part):Q(a.part),c=u?n.parts[u]:void 0;if(!c)continue;if(c[3]!=null)o=!0,r+=c[3];if(!i.has(u))i.add(u),s+=c[1]}return{bodyTris:r,packBytes:s,known:o}}class pe extends Error{code=\"ldr-budget\";bodyTris;packBytes;maxBodyTris;maxPackBytes;constructor(e){let t=[e.maxBodyTris!=null&&e.bodyTris>e.maxBodyTris?`${e.bodyTris} triangles (limit ${e.maxBodyTris})`:\"\",e.maxPackBytes!=null&&e.packBytes>e.maxPackBytes?`${(e.packBytes/1e6).toFixed(1)} MB parts pack (limit ${(e.maxPackBytes/1e6).toFixed(0)} MB)`:\"\"].filter(Boolean).join(\", \");super(`ldr: model exceeds device budget: ${t}`);this.name=\"BudgetError\",this.bodyTris=e.bodyTris,this.packBytes=e.packBytes,this.maxBodyTris=e.maxBodyTris,this.maxPackBytes=e.maxPackBytes}}async function Mt(e,t={}){let n=performance.now(),r=t.fetch??fetch,s=At(t.cdn??Te,r);s.catch(()=>{});let o=t.text?e:await r(e).then(async(h)=>{if(!h.ok)throw Error(`ldr: ${h.status} fetching ${e}`);return Xe(await h.arrayBuffer())}),i=performance.now(),a=t.name??(t.text?\"main.ldr\":Ze(e)),u=dt(o,a,{looseGeometry:!1,callouts:t.callouts}),c=performance.now();t.onParsed?.(u),await s;let f=bt(o,new Set(u.filter((h)=>h.embedded).map((h)=>h.part)),a),l=(h,P)=>t.maxBodyTris!=null&&h>t.maxBodyTris||t.maxPackBytes!=null&&P>t.maxPackBytes;if(t.maxBodyTris!=null||t.maxPackBytes!=null){let h=hn(u,f,await s);if(l(h.known?h.bodyTris:0,h.packBytes))throw new pe({bodyTris:h.bodyTris,packBytes:h.packBytes,maxBodyTris:t.maxBodyTris,maxPackBytes:t.maxPackBytes})}let{pack:p,missing:d,requests:w,bytes:y}=await fn([...u.filter((h)=>!h.embedded).map((h)=>h.part),...f.values()],t),L=new Map([...f].map(([h,P])=>[P,h])),g=d.map((h)=>L.get(h)??h);for(let[h,P]of f){let A=p.header.parts[P];if(A)p.header.parts[h]=A}let m=performance.now();if(t.maxBodyTris!=null||t.maxPackBytes!=null){let h=p.buffer?.byteLength??p.bytes??0,P=mn(u,p);if(l(P,h))throw new pe({bodyTris:P,packBytes:h,maxBodyTris:t.maxBodyTris,maxPackBytes:t.maxPackBytes})}let b=t.cull?Ae(u,p.header,t.textures!==!1):void 0;return{insts:u,pack:p,missing:g,requests:w,bytes:y,cull:b,timings:{fetchModel:i-n,parse:c-i,parts:m-c,...b?{cull:performance.now()-m}:{}}}}self.onmessage=async(e)=>{let{id:t,source:n,opts:r}=e.data;try{let s=await Mt(n,{...r,cull:!1,onParsed:(f)=>self.postMessage({id:t,insts:f})}),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(),a=Ae(s.insts,s.pack.header,r.textures!==!1),u=performance.now()-i,c=[];for(let f of[a.studHidden,a.studUp,a.underHidden,a.studHideStep,a.underHideStep])if(f)c.push(f.buffer);self.postMessage({id:t,cull:a,ms:u},c)}catch(s){if(s instanceof pe||s?.code===\"ldr-budget\")self.postMessage({id:t,phase:\"error\",error:String(s?.message??s),budget:{bodyTris:s.bodyTris,packBytes:s.packBytes,maxBodyTris:s.maxBodyTris,maxPackBytes:s.maxPackBytes}});else self.postMessage({id:t,phase:\"error\",error:String(s?.message??s)})}};\n";
|
|
2
2
|
export default _default;
|
package/dist/node/index.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/spec.ts
|
|
2
2
|
var norm = (s) => s.trim().toLowerCase().replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
3
|
+
var COLOUR_ID_RE = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
4
|
+
var namedCodes = new Map;
|
|
5
|
+
function namedColorCode(id) {
|
|
6
|
+
const s = id.toLowerCase();
|
|
7
|
+
let h = 2166136261;
|
|
8
|
+
for (let i = 0;i < s.length; i++) {
|
|
9
|
+
h ^= s.charCodeAt(i);
|
|
10
|
+
h = Math.imul(h, 16777619);
|
|
11
|
+
}
|
|
12
|
+
const c = -1 - (h >>> 0 & 1073741823);
|
|
13
|
+
if (!namedCodes.has(c))
|
|
14
|
+
namedCodes.set(c, s);
|
|
15
|
+
return c;
|
|
16
|
+
}
|
|
17
|
+
var isNamedColor = (c) => c < 0 && Number.isInteger(c);
|
|
3
18
|
function parseColor(tok) {
|
|
19
|
+
const c0 = tok.charCodeAt(0) | 32;
|
|
20
|
+
if (c0 >= 97 && c0 <= 122 && COLOUR_ID_RE.test(tok))
|
|
21
|
+
return namedColorCode(tok);
|
|
4
22
|
if (/^0x/i.test(tok))
|
|
5
23
|
return parseInt(tok, 16);
|
|
6
24
|
return +tok;
|
|
@@ -576,7 +594,7 @@ function looseSteps(f) {
|
|
|
576
594
|
looseMemo.set(f, r);
|
|
577
595
|
return r;
|
|
578
596
|
}
|
|
579
|
-
var colorToken = (c) => c > 16777215 ? "0x" + c.toString(16).toUpperCase() : String(c);
|
|
597
|
+
var colorToken = (c) => c > 16777215 ? "0x" + c.toString(16).toUpperCase() : c < 0 ? namedCodes.get(c) ?? String(c) : String(c);
|
|
580
598
|
var lineOf = (c) => c.t === 0 ? "0 " + c.text : c.t === 1 ? `1 ${colorToken(c.color)} ${c.m.join(" ")} ${c.file}` : c.src ? c.src : `${c.t} ${colorToken(c.color)} ${c.p.join(" ")}`;
|
|
581
599
|
var loosePartName = (file, step) => `${norm(file)}#${step}`;
|
|
582
600
|
function looseFile(f, step) {
|
|
@@ -690,7 +708,7 @@ function fileStepViews(f) {
|
|
|
690
708
|
viewMemo.set(f, out);
|
|
691
709
|
return out;
|
|
692
710
|
}
|
|
693
|
-
// ../../../../../../../tmp/ldr-build-
|
|
711
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/model.ts
|
|
694
712
|
var CALLOUT_END = 999999;
|
|
695
713
|
var stepKey = (steps) => steps.map((x) => String(x).padStart(6, "0")).join(".") + "~";
|
|
696
714
|
function flatten(doc, opts = {}) {
|
|
@@ -902,14 +920,14 @@ function parseColourLine(line) {
|
|
|
902
920
|
if (tokens.length < 2)
|
|
903
921
|
return null;
|
|
904
922
|
const name = tokens[0];
|
|
905
|
-
let code =
|
|
923
|
+
let code = NaN, hex = "#FF00FF", edge = "#333333", alpha = 255, luminance = 0;
|
|
906
924
|
let finish = { type: "default" };
|
|
907
925
|
let i = 1;
|
|
908
926
|
while (i < tokens.length) {
|
|
909
927
|
const t = tokens[i].toUpperCase();
|
|
910
928
|
const n = tokens[i + 1];
|
|
911
929
|
if (t === "CODE") {
|
|
912
|
-
code = +n;
|
|
930
|
+
code = n !== undefined && COLOUR_ID_RE.test(n) ? namedColorCode(n) : n !== undefined && /^\d+$/.test(n) ? +n : NaN;
|
|
913
931
|
i += 2;
|
|
914
932
|
} else if (t === "VALUE") {
|
|
915
933
|
const h = parseHexColor(n);
|
|
@@ -964,7 +982,7 @@ function parseColourLine(line) {
|
|
|
964
982
|
} else
|
|
965
983
|
i += 1;
|
|
966
984
|
}
|
|
967
|
-
if (code
|
|
985
|
+
if (Number.isNaN(code) || !hex)
|
|
968
986
|
return null;
|
|
969
987
|
return { code, name, hex, edge, alpha: Number.isFinite(alpha) ? alpha : 255, luminance: Number.isFinite(luminance) ? luminance : 0, finish };
|
|
970
988
|
}
|
|
@@ -1072,7 +1090,7 @@ function blendedColourHex(code) {
|
|
|
1072
1090
|
const a = LDRAW_EXE_16[code - 256 >> 4], b = LDRAW_EXE_16[code - 256 & 15];
|
|
1073
1091
|
return "#" + [0, 1, 2].map((k) => (a[k] + b[k] >> 1).toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
1074
1092
|
}
|
|
1075
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1093
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/instructions.ts
|
|
1076
1094
|
var MIN_VIS = 0.5;
|
|
1077
1095
|
var REORIENT = 0.35;
|
|
1078
1096
|
var deg = Math.PI / 180;
|
|
@@ -1440,10 +1458,10 @@ function planStepViews(insts, parts, stepOf, nSteps, o = {}) {
|
|
|
1440
1458
|
}
|
|
1441
1459
|
};
|
|
1442
1460
|
}
|
|
1443
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1461
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/render.ts
|
|
1444
1462
|
import * as THREE from "three";
|
|
1445
1463
|
|
|
1446
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1464
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/pack-io.ts
|
|
1447
1465
|
import { decompress } from "fzstd";
|
|
1448
1466
|
async function decompressPack(data) {
|
|
1449
1467
|
const u = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
@@ -1466,7 +1484,7 @@ function decodePack(buf) {
|
|
|
1466
1484
|
return { header, arr, bytes: buf.byteLength, buffer: buf };
|
|
1467
1485
|
}
|
|
1468
1486
|
|
|
1469
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1487
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/cull.ts
|
|
1470
1488
|
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;
|
|
1471
1489
|
var prepCache = new WeakMap;
|
|
1472
1490
|
function prepPart(H, part) {
|
|
@@ -1801,7 +1819,7 @@ function precomputeCull(instances, H, useTex = true) {
|
|
|
1801
1819
|
return cullCore(s.all, H, s.nSteps > 1 ? s.stepOf : undefined);
|
|
1802
1820
|
}
|
|
1803
1821
|
|
|
1804
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1822
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/render.ts
|
|
1805
1823
|
async function loadPack(url) {
|
|
1806
1824
|
const res = await fetch(url);
|
|
1807
1825
|
if (!res.ok)
|
|
@@ -3609,7 +3627,7 @@ async function warmPackGeometry(pack, stop = () => false, sliceMs = 8) {
|
|
|
3609
3627
|
await new Promise((r) => setTimeout(r, 0));
|
|
3610
3628
|
}
|
|
3611
3629
|
}
|
|
3612
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3630
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/scene.ts
|
|
3613
3631
|
import * as THREE2 from "three";
|
|
3614
3632
|
function colorFn(src, pack, fallback) {
|
|
3615
3633
|
const table = new Map;
|
|
@@ -3836,10 +3854,10 @@ function createLdrObjectInner(instances, pack, options, progressive) {
|
|
|
3836
3854
|
return finish();
|
|
3837
3855
|
})();
|
|
3838
3856
|
}
|
|
3839
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3857
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/parts-cdn.ts
|
|
3840
3858
|
import { decompress as decompress2 } from "fzstd";
|
|
3841
3859
|
|
|
3842
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3860
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/embedded.ts
|
|
3843
3861
|
function splitFiles(text, fallback) {
|
|
3844
3862
|
const files = new Map;
|
|
3845
3863
|
let cur = null, saw = false;
|
|
@@ -3911,7 +3929,7 @@ function embeddedKeys(text, names, fallback = "main.ldr") {
|
|
|
3911
3929
|
return out;
|
|
3912
3930
|
}
|
|
3913
3931
|
|
|
3914
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3932
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/parts-cdn.ts
|
|
3915
3933
|
var DEFAULT_PARTS_CDN = "https://ldr-demo.vercel.app/cdn/v1/";
|
|
3916
3934
|
var indexCache = new Map;
|
|
3917
3935
|
var shardCache = new Map;
|
|
@@ -4143,10 +4161,10 @@ async function prepareModel(source, o = {}) {
|
|
|
4143
4161
|
return { insts, pack, missing, requests, bytes, cull, timings: { fetchModel: t1 - t0, parse: t2 - t1, parts: t3 - t2, ...cull ? { cull: performance.now() - t3 } : {} } };
|
|
4144
4162
|
}
|
|
4145
4163
|
|
|
4146
|
-
// ../../../../../../../tmp/ldr-build-
|
|
4147
|
-
var load_worker_gen_default = 'var wt=ArrayBuffer,Z=Uint8Array,de=Uint16Array,At=Int16Array;var be=Int32Array,Le=function(e,t,n){if(Z.prototype.slice)return Z.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 Z(n-t);return r.set(e.subarray(t,n)),r},ce=function(e,t,n,r){if(Z.prototype.fill)return Z.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},Mt=function(e,t,n,r){if(Z.prototype.copyWithin)return Z.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 vt=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],J=function(e,t,n){var r=Error(t||vt[e]);if(r.code=e,Error.captureStackTrace)Error.captureStackTrace(r,J);if(!n)throw r;return r},He=function(e,t,n){var r=0,s=0;for(;r<n;++r)s|=e[t++]<<(r<<3);return s},Ct=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Tt=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,a=r>>6;if(r&8)J(0);var u=6-s,c=i==3?4:i,f=He(e,u,c);u+=c;var l=a?1<<a:s,p=He(e,u,l)+(a==1&&256),d=p;if(!s){var w=1<<10+(e[5]>>3);d=w+(w>>3)*(e[5]&7)}if(d>2145386496)J(1);var y=new Z((t==1?p||d:t?0:d)+12);return y[0]=1,y[4]=4,y[8]=8,{b:u+l,y:0,l:0,d:f,w:t&&t!=1?t:y.subarray(12),e:d,o:new be(y.buffer,0,3),u:p,c:o,m:Math.min(131072,d)}}else if((n>>4|e[3]<<20)==25481893)return Ct(e,4)+8;J(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)J(3);var o=1<<s,i=o,a=-1,u=-1,c=-1,f=o,l=new wt(512+(o<<2)),p=new At(l,0,256),d=new de(l,0,256),w=new de(l,512,o),y=512+(o<<1),L=new Z(l,y,o),g=new Z(l,y+o);while(a<255&&i>0){var m=re(i+1),b=r>>3,h=(1<<m+1)-1,P=(e[b]|e[b+1]<<8|e[b+2]<<16)>>(r&7)&h,A=(1<<m)-1,S=h-i-1,T=P&A;if(T<S)r+=m,P=T;else if(r+=m+1,P>A)P-=S;if(p[++a]=--P,P==-1)i+=P,L[--f]=a;else i-=P;if(!P)do{var B=r>>3;u=(e[B]|e[B+1]<<8)>>(r&7)&3,r+=2,a+=u}while(u==3)}if(a>255||i)J(0);var v=0,F=(o>>1)+(o>>3)+3,Y=o-1;for(var H=0;H<=a;++H){var C=p[H];if(C<1){d[H]=-C;continue}for(c=0;c<C;++c){L[v]=H;do v=v+F&Y;while(v>=f)}}if(v)J(0);for(c=0;c<o;++c){var M=d[L[c]]++,k=g[c]=s-re(M);w[c]=(M<<k)-o}return[r+7>>3,{b:s,s:L,n:g,t:w}]},Lt=function(e,t){var n=0,r=-1,s=new Z(292),o=e[t],i=s.subarray(0,256),a=s.subarray(256,268),u=new de(s.buffer,268);if(o<128){var c=ue(e,t+1,6),f=c[0],l=c[1];t+=o;var p=f<<3,d=e[t];if(!d)J(0);var w=0,y=0,L=l.b,g=L,m=(++t<<3)-8+re(d);for(;;){if(m-=L,m<p)break;var b=m>>3;if(w+=(e[b]|e[b+1]<<8)>>(m&7)&(1<<L)-1,i[++r]=l.s[w],m-=g,m<p)break;b=m>>3,y+=(e[b]|e[b+1]<<8)>>(m&7)&(1<<g)-1,i[++r]=l.s[y],L=l.n[w],w=l.t[w],g=l.n[y],y=l.t[y]}if(++r>255)J(0)}else{r=o-127;for(;n<r;n+=2){var h=e[++t];i[n]=h>>4,i[n+1]=h&15}++t}var P=0;for(n=0;n<r;++n){var A=i[n];if(A>11)J(0);P+=A&&1<<A-1}var S=re(P)+1,T=1<<S,B=T-P;if(B&B-1)J(0);i[r++]=re(B)+1;for(n=0;n<r;++n){var A=i[n];++a[i[n]=A&&S+1-A]}var v=new Z(T<<1),F=v.subarray(0,T),Y=v.subarray(T);u[S]=0;for(n=S;n>0;--n){var H=u[n];ce(Y,n,H,u[n-1]=H+a[n]*(1<<S-n))}if(u[0]!=T)J(0);for(n=0;n<r;++n){var C=i[n];if(C){var M=u[C];ce(F,n,M,u[C]=M+(1<<S-C))}}return[t,{n:Y,b:S,s:F}]},St=ue(new Z([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],Et=ue(new Z([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],Pt=ue(new Z([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],Ge=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},Se=new Z(new be([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),kt=Ge(Se,0),Ee=new Z(new be([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),It=Ge(Ee,3),le=function(e,t,n){var r=e.length,s=t.length,o=e[r-1],i=(1<<n.b)-1,a=-n.b;if(!o)J(0);var u=0,c=n.b,f=(r<<3)-8+re(o)-c,l=-1;for(;f>a&&l<s;){var p=f>>3,d=(e[p]|e[p+1]<<8|e[p+2]<<16)>>(f&7);u=(u<<c|d)&i,t[++l]=n.s[u],f-=c=n.n[u]}if(f!=a||l+1!=s)J(0)},Bt=function(e,t,n){var r=6,s=t.length,o=s+3>>2,i=o<<1,a=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,a),n),le(e.subarray(r),t.subarray(a),n)},Ft=function(e,t,n){var r,s=t.b,o=e[s],i=o>>1&3;t.l=o&1;var a=o>>3|e[s+1]<<5|e[s+2]<<13,u=(s+=3)+a;if(i==1){if(s>=e.length)return;if(t.b=s+1,n)return ce(n,e[s],t.y,t.y+=a),n;return ce(new Z(a),e[s])}if(u>e.length)return;if(i==0){if(t.b=u,n)return n.set(e.subarray(s,u),t.y),t.y+=a,n;return Le(e,s,u)}if(i==2){var c=e[s],f=c&3,l=c>>2&3,p=c>>4,d=0,w=0;if(f<2)if(l&1)p|=e[++s]<<4|(l&2&&e[++s]<<12);else p=c>>3;else if(w=l,l<2)p|=(e[++s]&63)<<4,d=e[s]>>6|e[++s]<<2;else if(l==2)p|=e[++s]<<4|(e[++s]&3)<<12,d=e[s]>>2|e[++s]<<6;else p|=e[++s]<<4|(e[++s]&63)<<12,d=e[s]>>6|e[++s]<<2|e[++s]<<10;++s;var y=n?n.subarray(t.y,t.y+t.m):new Z(t.m),L=y.length-p;if(f==0)y.set(e.subarray(s,s+=p),L);else if(f==1)ce(y,e[s++],L);else{var g=t.h;if(f==2){var m=Lt(e,s);d+=s-(s=m[0]),t.h=g=m[1]}else if(!g)J(0);(w?Bt:le)(e.subarray(s,s+=d),y.subarray(L),g)}var b=e[s++];if(b){if(b==255)b=(e[s++]|e[s++]<<8)+32512;else if(b>127)b=b-128<<8|e[s++];var h=e[s++];if(h&3)J(0);var P=[Et,Pt,St];for(var A=2;A>-1;--A){var S=h>>(A<<1)+2&3;if(S==1){var T=new Z([0,0,e[s++]]);P[A]={s:T.subarray(2,3),n:T.subarray(0,1),t:new de(T.buffer,0,1),b:0}}else if(S==2)r=ue(e,s,9-(A&1)),s=r[0],P[A]=r[1];else if(S==3){if(!t.t)J(0);P[A]=t.t[A]}}var B=t.t=P,v=B[0],F=B[1],Y=B[2],H=e[u-1];if(!H)J(0);var C=(u<<3)-8+re(H)-Y.b,M=C>>3,k=0,_=(e[M]|e[M+1]<<8)>>(C&7)&(1<<Y.b)-1;M=(C-=F.b)>>3;var I=(e[M]|e[M+1]<<8)>>(C&7)&(1<<F.b)-1;M=(C-=v.b)>>3;var O=(e[M]|e[M+1]<<8)>>(C&7)&(1<<v.b)-1;for(++b;--b;){var j=Y.s[_],X=Y.n[_],W=v.s[O],E=v.n[O],x=F.s[I],R=F.n[I];M=(C-=x)>>3;var D=1<<x,U=D+((e[M]|e[M+1]<<8|e[M+2]<<16|e[M+3]<<24)>>>(C&7)&D-1);M=(C-=Ee[W])>>3;var G=It[W]+((e[M]|e[M+1]<<8|e[M+2]<<16)>>(C&7)&(1<<Ee[W])-1);M=(C-=Se[j])>>3;var N=kt[j]+((e[M]|e[M+1]<<8|e[M+2]<<16)>>(C&7)&(1<<Se[j])-1);if(M=(C-=X)>>3,_=Y.t[_]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<X)-1),M=(C-=E)>>3,O=v.t[O]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<E)-1),M=(C-=R)>>3,I=F.t[I]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<R)-1),U>3)t.o[2]=t.o[1],t.o[1]=t.o[0],t.o[0]=U-=3;else{var V=U-(N!=0);if(V){if(U=V==3?t.o[0]-1:t.o[V],V>1)t.o[2]=t.o[1];t.o[1]=t.o[0],t.o[0]=U}else U=t.o[0]}for(var A=0;A<N;++A)y[k+A]=y[L+A];k+=N,L+=N;var z=k-U;if(z<0){var K=-z,q=t.e+z;if(K>G)K=G;for(var A=0;A<K;++A)y[k+A]=t.w[q+A];k+=K,G-=K,z=0}for(var A=0;A<G;++A)y[k+A]=y[z+A];k+=G}if(k!=L)while(L<y.length)y[k++]=y[L++];else k=y.length;if(n)t.y+=k;else y=Le(y,0,k)}else if(n){if(t.y+=p,L)for(var A=0;A<p;++A)y[A]=y[L+A]}else if(L)y=Le(y,L);return t.b=u,y}J(2)},Rt=function(e,t){if(e.length==1)return e[0];var n=new Z(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 ye(e,t){var n=[],r=+!t,s=0,o=0;for(;e.length;){var i=Tt(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 a=Ft(e,i,t);if(!a)J(5);if(t)i.e=i.y;else n.push(a),o+=a.length,Mt(i.w,0,a.length),i.w.set(a,i.w.length-a.length)}s=i.b+i.c*4}else s=i;e=e.subarray(s)}return Rt(n,o)}async function Dt(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=(r)=>r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);if(t[0]===40&&t[1]===181&&t[2]===47&&t[3]===253)return n(ye(t));if(t[0]===31&&t[1]===139)return new Response(new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip"))).arrayBuffer();return n(t)}async function _e(e){return new TextDecoder().decode(await Dt(e))}var Ke=(e)=>decodeURIComponent(e.split(/[?#]/)[0].split("/").pop()||"main.ldr").replace(/\\.(zst|gz)$/i,"")||"main.ldr";function xe(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 Q=(e)=>e.trim().toLowerCase().replace(/\\\\/g,"/").replace(/\\/+/g,"/");function Pe(e){if(/^0x/i.test(e))return parseInt(e,16);return+e}var We=/^~?\\s*moved\\s+to\\s+(.+)$/i,Ut=new Set(["FILE","NOFILE","!DATA","!:","STEP","BFC","ROTSTEP","BUFEXCHG","!TEXMAP"]),tt=new Set(["part","subpart","primitive","8_primitive","48_primitive","shortcut","helper"]),zt=new Set(["model","submodel","configuration"]),Ot=/^(?:!?LDRAW_ORG|Unofficial|Official\\s+LCAD)\\s+(\\S+)/i;function Xe(e){let t=Ot.exec(e);if(!t)return;let n=t[1].toLowerCase().replace(/^unofficial_/,"");return tt.has(n)||zt.has(n)?n:void 0}function Nt(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 $t(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 a=n[2].trim();for(let l=0;l<s;l++)a=a.replace(/^\\S+\\s*/,"");let u=Nt(a);if(!u.length)return null;let c={method:r,p1:i.slice(0,3),p2:i.slice(3,6),p3:i.slice(6,9),texture:u[0]};if(s>=10)c.a=i[9];if(s===11)c.b=i[10];let f=u.findIndex((l,p)=>p>0&&l.toUpperCase()==="GLOSSMAP");if(f>0&&u[f+1])c.glossmap=u[f+1];if(t)c.next=!0;return c}var jt=(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 Vt(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 f=s();if(f===null)return null;i[c]=+f}while(n<t&&r(e.charCodeAt(n)))n++;if(n>=t)return null;let a=e.slice(n),u=/[ \\t]{2,}|\\t/.test(a)?a.split(/\\s+/).join(" "):a;return{t:1,color:Pe(o),m:i,file:Q(u)}}function Ze(e){let t=+e[0];if(!(t>=1&&t<=5)||e.length<2)return null;let n=Pe(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 nt(e,t="main.ldr",n={}){let r=!!n.geometryText,s=new Map,o=null,i="",a,u=null,c=[],f=null,l=()=>{if(!u)return;let m=jt(u.chunks.join("")),b=m[0]===137&&m[1]===80&&m[2]===78&&m[3]===71;(a??=new Map).set(Q(u.name),{name:u.name,bytes:m,...b?{mime:"image/png"}:{}}),u=null},p=!0,d=(m)=>{if(l(),o={name:Q(m),cmds:[]},s.set(o.name,o),!i)i=o.name;c=[],f=null,p=!0},w=!1,y=!1,L=()=>{if(y)return;y=!0,s.clear(),o=null,i=""},g=(m,b)=>{if(f){m.tex=f,f=null;return}let h=c[c.length-1];if(!h)return;if(h.fallback){if(!b)m.fallback=!0}else m.tex=h.map};for(let m of e.split(`\n`)){let b=m.trim();if(!b)continue;if(r&&b.charCodeAt(0)>=50&&b.charCodeAt(0)<=53&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)){if(u||w)continue;if(!o)d(t);let S=b.slice(2).trimStart(),T=S.search(/\\s/),B={t:b.charCodeAt(0)-48,color:Pe(T<0?S:S.slice(0,T)),p:[],src:b};g(B,!1),o.cmds.push(B),p=!1;continue}if(b.charCodeAt(0)===48&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)){let S=2;while(b.charCodeAt(S)===32||b.charCodeAt(S)===9)S++;let T=S;while(T<b.length&&b.charCodeAt(T)!==32&&b.charCodeAt(T)!==9)T++;let B=b.slice(S,T);if(!Ut.has(B)){if(w||u)continue;if(!o)d(t);let v=b.slice(S),F={t:0,text:v};if(B.charCodeAt(0)===33)F.meta=B;if(f=null,p&&!o.org){let H=Xe(v);if(H)o.org=H}let Y=v.match(We);if(Y&&!o.movedTo){let H=Y[1].trim().replace(/\\\\/g,"/");if(!/\\.(dat|ldr|mpd)$/i.test(H))H+=".dat";o.movedTo=Q(H)}o.cmds.push(F);continue}}if(b.charCodeAt(0)===49&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)&&!u&&!w){let S=Vt(b);if(S){if(!o)d(t);g(S,!1),o.cmds.push(S),p=!1;continue}}let h=b.split(/\\s+/);if(+h[0]===0){let S=b.slice(1).trim();if(h[1]==="FILE"){L(),w=!1,d(S.slice(5));continue}if(h[1]==="NOFILE"){l(),o=null,w=!0;continue}if(h[1]==="!DATA"){L(),l(),o=null,w=!1,u={name:S.slice(5).trim(),chunks:[]};continue}if(w)continue;if(u){if(h[1]==="!:")u.chunks.push(h.slice(2).join(""));continue}if(!o)d(t);let T={t:0,text:S};if(h[1]==="STEP")T.step=!0,c=[],f=null;else if(h[1]==="BFC")T.bfc=h.slice(2).join(" ");else if(h[1]==="ROTSTEP")if(T.meta="ROTSTEP",T.step=!0,c=[],f=null,(h[2]??"").toUpperCase()==="END")T.rotstep={x:0,y:0,z:0,mode:"END"};else{let v=(h[5]??"REL").toUpperCase();T.rotstep={x:+h[2]||0,y:+h[3]||0,z:+h[4]||0,mode:["REL","ABS","ADD"].includes(v)?v:"REL"}}else if(h[1]==="BUFEXCHG"){T.meta="BUFEXCHG";let v=(h[2]??"").toUpperCase();T.bufexchg={op:v==="RETRIEVE"?"RETRIEVE":"STORE",buf:h[3]??"A"}}else if(h[1]?.startsWith("!"))T.meta=h[1];if(p&&!o.org){let v=Xe(S);if(v)o.org=v}if(h[1]==="!TEXMAP"){let v=(h[2]??"").toUpperCase();if(f=null,v==="START"||v==="NEXT"){let F=$t(S.replace(/^!TEXMAP\\s+\\S+/i,""),v==="NEXT");if(T.texmap={op:v,...F?{map:F}:{}},F)if((o.texmaps??=[]).push(F),v==="START")c.push({map:F,fallback:!1});else f=F}else if(v==="FALLBACK"){T.texmap={op:v};let F=c[c.length-1];if(F)F.fallback=!0}else if(v==="END")T.texmap={op:v},c.pop()}else if(h[1]==="!:"){f=null;let v=Ze(h.slice(2));if(v)g(v,!0),T.geom=v}else f=null;let B=S.match(We);if(B&&!o.movedTo){let v=B[1].trim().replace(/\\\\/g,"/");if(!/\\.(dat|ldr|mpd)$/i.test(v))v+=".dat";o.movedTo=Q(v)}o.cmds.push(T);continue}if(u||w)continue;if(!o)d(t);let A=Ze(h);if(!A)continue;g(A,!1),o.cmds.push(A),p=!1}return l(),a?{main:i,files:s,data:a}:{main:i,files:s}}var gn=Math.PI/180;function rt(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 st(e,t){let[n,r,s,o,i,a,u,c,f,l,p,d]=e,[w,y,L,g,m,b,h,P,A,S,T,B]=t;return[o*w+i*y+a*L+n,u*w+c*y+f*L+r,l*w+p*y+d*L+s,o*g+i*h+a*S,o*m+i*P+a*T,o*b+i*A+a*B,u*g+c*h+f*S,u*m+c*P+f*T,u*b+c*A+f*B,l*g+p*h+d*S,l*m+p*P+d*T,l*b+p*A+d*B]}var ke=[0,0,0,1,0,0,0,1,0,0,0,1];var Ye=new WeakMap,Ht=/^(s|8|48)\\//;function Ie(e,t){let n=e.files.get(Q(t));if(!n)return"part";let r=Ye.get(n);if(r)return r;if(n.org)r=tt.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&&Ht.test(s.file))?"part":"model";return Ye.set(n,r),r}var Je=new WeakMap;function ot(e){let t=Je.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 Je.set(e,t),t}var qe=(e)=>e>16777215?"0x"+e.toString(16).toUpperCase():String(e),Gt=(e)=>e.t===0?"0 "+e.text:e.t===1?`1 ${qe(e.color)} ${e.m.join(" ")} ${e.file}`:e.src?e.src:`${e.t} ${qe(e.color)} ${e.p.join(" ")}`,Be=(e,t)=>`${Q(e)}#${t}`;function _t(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:Be(e.name,t),cmds:n}}function it(e,t){return[`0 ldr: own geometry of ${e.name}, step ${t}`,..._t(e,t).cmds.map(Gt)].join(`\n`)+`\n`}function Kt(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 at(e){let[t,n,r,s,o,i,a,u,c,f,l,p]=e,d=u*p-c*l,w=-(a*p-c*f),y=a*l-u*f,L=s*d+o*w+i*y;if(!Number.isFinite(L)||Math.abs(L)<0.000000000001)return null;let g=1/L,m=[d*g,-(o*p-i*l)*g,(o*c-i*u)*g,w*g,(s*p-i*f)*g,-(s*c-i*a)*g,y*g,-(s*l-o*f)*g,(s*u-o*a)*g];return[-(m[0]*t+m[1]*n+m[2]*r),-(m[3]*t+m[4]*n+m[5]*r),-(m[6]*t+m[7]*n+m[8]*r),...m]}var Wt=(e)=>String(+e.toFixed(6)||0),Qe=(e)=>\'"\'+e.replace(/\\\\/g,"\\\\\\\\").replace(/"/g,"\\\\\\"")+\'"\';function lt(e,t){let n=[...t.p1,...t.p2,...t.p3,...t.method!=="PLANAR"?[t.a??360]:[],...t.method==="SPHERICAL"?[t.b??180]:[]].map(Wt).join(" "),r=`0 ldr: ${e} with a model-level !TEXMAP\n0 BFC CERTIFY CCW\n0 !TEXMAP START ${t.method} ${n} ${Qe(t.texture)}${t.glossmap?" GLOSSMAP "+Qe(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-${Kt(r)}`,source:r}}var Xt=(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 Zt(e,t,n){let r=Math.PI/180,s=Math.sin(e*r),o=Math.cos(e*r),i=Math.sin(t*r),a=Math.cos(t*r),u=Math.sin(n*r),c=Math.cos(n*r);return[a*c,-a*u,i,o*u+s*i*c,o*c-s*i*u,-s*a,s*u-o*i*c,s*c+o*i*u,o*a]}var et=new WeakMap;function ct(e){let t=et.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=Zt(o.x,o.y,o.z);r=o.mode==="ABS"?{abs:!0,m:i,rotstep:o}:o.mode==="ADD"&&r?{abs:r.abs,m:Xt(r.m,i),rotstep:o}:{abs:!1,m:i,rotstep:o}}n.push(r)}return n.push(r),et.set(e,n),n}var ut=999999,pt=(e)=>e.map((t)=>String(t).padStart(6,"0")).join(".")+"~";function Yt(e,t={}){let n=[],r=t.maxDepth??64,s=t.looseGeometry!==!1,o=!!t.textures,i=!!t.callouts,a=new Map,u=0,c=(l,p)=>{let d=l.name+"#"+p,w=a.get(d);if(!w){let y;w=Object.assign(()=>y??=it(l,p),{file:l,step:p}),a.set(d,w)}return w},f=(l,p,d,w,y,L,g,m,b=null,h=[],P=[],A=void 0,S=null)=>{let T=l.files.get(p);if(!T||g>r)return;let B=S,v=0,F=g>0?++u:0,Y=i&&F?[...h,F]:h,H=i&&F?[...P,d]:P,C=i&&!b?new Map:null,M=-1,k=0,_=(E,x,R,D,U,G,N)=>{if(M!==v)M=v,k=0;let V=C?.get(v+"|"+x);if(V)return V.n++,f(E,E===l?x:E.main,R,D,y+"/"+x,[...U,ut],g+1,G,[...U,ut],Y,H,N,B);let z=[...U,k++],K=n.length;f(E,E===l?x:E.main,R,D,y+"/"+x,z,g+1,G,b,Y,H,N,B),C?.set(v+"|"+x,{n:1,from:K,to:n.length})},I=ct(T),O=s?ot(T):[],j=0,X=(E,x,R,D,U,G,N,V)=>{if(b)D=b;let z={part:E,color:x,m:R,step:D[0],steps:D,localStep:U,path:y};if(V)z.colour=V;if(F){if(z.sub=F,i)z.subPath=Y,z.subMats=H}if(G)z.embedded=!0;if(N){let q=lt(E,N);z.texPart=q.name,z.texSource=q.source}let K=I[U];if(K)z.view=K;return n.push(z),z},W=(E)=>{while(j<O.length&&O[j]<=E){let x=O[j++];X(Be(T.name,x),w,d,[...L,x],x,!1,null,A).source=c(T,x)}};for(let E of T.cmds){if(E.t===0&&E.step){v++;continue}let x=E;if(x.t>=2||x.t===0&&x.geom&&x.geom.t>=2){W(v);continue}if(x.t===0){if(x.meta==="!COLOUR"){let q=qt(x.text);if(q&&q.code!==16&&q.code!==24)(B=new Map(B??[])).set(q.code,q);continue}if(o&&x.geom?.t===1)x=x.geom;else continue}if(x.t!==1)continue;if(o&&x.fallback)continue;let R=x.color===16?w:x.color,D=x.color===16?A:B?.get(x.color),U=st(d,x.m),G=[...L,v],N=o?x.tex??m:null,V=N?at(x.m):null,z=N&&V?rt(N,V):null;if(l.files.has(x.file)){if(Ie(l,x.file)==="model"){_(l,x.file,U,R,G,z,D);continue}X(x.file,R,U,G,v,!0,z,D);continue}let K=t.resolveModel?.(x.file);if(K){_(K,x.file,U,R,G,z,D);continue}X(x.file,R,U,G,v,!1,z,D)}if(W(1/0),C){for(let E of C.values())if(E.n>1)for(let x=E.from;x<E.to;x++)n[x].mult??=E.n}};if(Ie(e,e.main)==="part"){if(e.files.get(e.main))n.push({part:e.main,color:16,m:[...ke],step:0,steps:[0],localStep:0,path:e.main,embedded:!0});return n}return f(e,e.main,ke,16,e.main,[],0,null),n}function mt(e,t="main.ldr",n){return Yt(nt(e,t,{geometryText:!0}),n)}var Jt=new Set(["CHROME","PEARLESCENT","RUBBER","MATTE_METALLIC","METAL","MATERIAL"]);function Fe(e){if(!e)return null;if(e.startsWith("#")&&/^#[0-9A-Fa-f]{6}$/.test(e))return e.toUpperCase();if(/^0x[0-9A-Fa-f]{6}$/i.test(e))return("#"+e.slice(2)).toUpperCase();return null}function ft(e,t){let n={value:"#FFFFFF",fraction:0.5};while(t<e.length){let r=e[t].toUpperCase(),s=e[t+1];if(r==="VALUE"){let o=Fe(s);if(o)n.value=o;t+=2}else if(r==="ALPHA")n.alpha=+s,t+=2;else if(r==="LUMINANCE")n.luminance=+s,t+=2;else if(r==="FRACTION")n.fraction=+s,t+=2;else if(r==="VFRACTION")n.vfraction=+s,t+=2;else if(r==="SIZE")n.size=+s,t+=2;else if(r==="MINSIZE")n.minsize=+s,t+=2;else if(r==="MAXSIZE")n.maxsize=+s,t+=2;else break}return{grain:n,next:t}}function qt(e){let t=e.indexOf("!COLOUR");if(t<0)return null;let n=e.slice(t+7).trim().split(/\\s+/).filter(Boolean);if(n.length<2)return null;let r=n[0],s=-1,o="#FF00FF",i="#333333",a=255,u=0,c={type:"default"},f=1;while(f<n.length){let l=n[f].toUpperCase(),p=n[f+1];if(l==="CODE")s=+p,f+=2;else if(l==="VALUE"){let d=Fe(p);if(d)o=d;f+=2}else if(l==="EDGE")i=Fe(p)??p,f+=2;else if(l==="ALPHA")a=+p,f+=2;else if(l==="LUMINANCE")u=+p,f+=2;else if(l==="CHROME")c={type:"chrome"},f+=1;else if(l==="PEARLESCENT")c={type:"pearlescent"},f+=1;else if(l==="RUBBER")c={type:"rubber"},f+=1;else if(l==="MATTE_METALLIC")c={type:"matte_metallic"},f+=1;else if(l==="METAL")c={type:"metal"},f+=1;else if(l==="MATERIAL"){let d=(n[f+1]||"").toUpperCase();if(d==="GLITTER"){let{grain:w,next:y}=ft(n,f+2);c={type:"glitter",material:w},f=y}else if(d==="SPECKLE"){let{grain:w,next:y}=ft(n,f+2);c={type:"speckle",material:w},f=y}else if(d==="FABRIC"){let w=(n[f+2]||"").toUpperCase(),y=["VELVET","CANVAS","STRING","FUR"].includes(w)?w.toLowerCase():void 0;c={type:"fabric",kind:y},f+=y?3:2}else f=n.length}else if(Jt.has(l))f+=1;else f+=1}if(s<0||!o)return null;return{code:s,name:r,hex:o,edge:i,alpha:Number.isFinite(a)?a:255,luminance:Number.isFinite(u)?u:0,finish:c}}function Qt(e){let t=Math.max(0,Math.min(1,(e.alpha??255)/255)),n=t<1,r=Math.max(0,Math.min(1,(e.luminance??0)/255)),s={opacity:t,transparent:n,depthWrite:!n,emissive:r,clearcoat:0,clearcoatRoughness:0,sheen:0,sheenRoughness:0};switch(e.finish?.type??"default"){case"chrome":return{...s,metalness:1,roughness:0,finish:"chrome"};case"pearlescent":return{...s,metalness:0.25,roughness:0.3,clearcoat:0.5,clearcoatRoughness:0.25,sheen:0.4,sheenRoughness:0.35,finish:"pearlescent"};case"rubber":return{...s,metalness:0,roughness:0.9,finish:"rubber"};case"matte_metallic":return{...s,metalness:0.4,roughness:0.8,finish:"matte_metallic"};case"metal":return{...s,metalness:0.85,roughness:0.2,finish:"metal"};case"glitter":{let i=e.finish.material,a=i.size??(i.minsize!=null&&i.maxsize!=null?(i.minsize+i.maxsize)/2:1);return{...s,metalness:0.35,roughness:0.25,clearcoat:1,clearcoatRoughness:0.08,particleHex:i.value,particleFraction:i.fraction,particleSize:a,finish:"glitter"}}case"speckle":{let i=e.finish.material,a=i.size??(i.minsize!=null&&i.maxsize!=null?(i.minsize+i.maxsize)/2:1);return{...s,metalness:0.2,roughness:0.55,particleHex:i.value,particleFraction:i.fraction,particleSize:a,finish:"speckle"}}case"fabric":return{...s,metalness:0,roughness:0.85,sheen:0.65,sheenRoughness:0.75,finish:"fabric"};default:return{...s,metalness:0,roughness:0.45,finish:"default"}}}function Re(e){let t=Qt(e),n=!t.transparent?"op":t.opacity>=0.75?"a200":t.opacity>=0.4?"a128":`a${Math.round(t.opacity*255)}`,r=t.emissive>0?`L${Math.round(t.emissive*16)}`:"",s=`${t.finish}:${n}${r}`;if(t.particleHex)s+=`:${t.particleHex}:${(t.particleFraction??0).toFixed(2)}`;return s}function en(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(Q(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(Q(t),r)}let a=o.trim().replace(/\\s+/g," ");if(a)r.push(a)}return n}var tn=(e)=>{if(!e.startsWith("1 "))return null;let t=e.split(" ");return t.length>=15?Q(t.slice(14).join(" ")):null};function nn(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 ht(e,t,n="main.ldr"){let r=en(e,n),s=new Map;for(let o of t){let i=Q(o);if(!r.has(i)||s.has(i))continue;let a=new Set([i]),u=[i];while(u.length)for(let f of r.get(u.pop())){let l=tn(f);if(l&&r.has(l)&&!a.has(l))a.add(l),u.push(l)}let c=[i,...[...a].filter((f)=>f!==i).sort()].map((f)=>"0 FILE "+(f===i?"":f)+`\n`+r.get(f).join(`\n`)).join(`\n`);s.set(i,`emb/${nn(c)}.dat`)}return s}var gt=(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,dt=new WeakMap;function De(e,t){let n=dt.get(e);if(!n)dt.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),a=[],u=[];s.studs.forEach((p,d)=>{a.push(p[0]),u.push(p[1]);for(let w=0;w<12;w++)i[d*12+w]=p[2+w]});let c=null,f=0,l=0;if(s.mask){f=s.mask[0],l=s.mask[1];let p=s.mask[2];c=new Uint8Array(p.length);for(let d=0;d<p.length;d++)c[d]=p.charCodeAt(d)===49?1:0}return n.set(t,r={nStuds:o,studM:i,kind:a,color:u,mask:c,nx:f,nz:l}),r}var ie=1073741824;class Ue{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,a=this.c;for(;;){if(!s[r])return-1;if(o[r]===e&&i[r]===t&&a[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,a=this.b,u=this.c;for(;;){if(!o[s])return o[s]=1,i[s]=e,a[s]=t,u[s]=n,this.vals[s]=r,this.size++,-1;if(i[s]===e&&a[s]===t&&u[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 we=(e,t,n)=>e>-ie&&e<ie&&t>-ie&&t<ie&&n>-ie&&n<ie,fe=2147483647;function rn(e,t,n){let s=[],o=[],i=[],a=[],u=[],c=[],f=[],l=[],p=new Ue(e.length*2),d=[],w=[];for(let C=0;C<e.length;C++){let M=e[C],k=M.m,_=t.parts[M.part];if(!_||!_.mask||!gt(k))continue;let I=_.bbox,O=1/0,j=-1/0,X=1/0,W=-1/0;for(let R=0;R<2;R++)for(let D=0;D<2;D++){let U=R?I[3]:I[0],G=D?I[5]:I[2],N=k[0]+k[3]*U+k[5]*G,V=k[2]+k[9]*U+k[11]*G;if(N<O)O=N;if(N>j)j=N;if(V<X)X=V;if(V>W)W=V}let E=u.length;s.push(O),o.push(j),i.push(X),a.push(W),u.push(C),c.push(De(t,M.part)),f.push(I[0]),l.push(I[2]);let x=Math.round((k[1]+I[4])*2);for(let R=Math.floor(O/40);R<=Math.floor(j/40);R++)for(let D=Math.floor(X/40);D<=Math.floor(W/40);D++){if(!we(x,R,D))continue;let U=w.length;w.push(E),d.push(p.put(x,R,D,U))}}let y=[0,5,-5,5,-5],L=[0,5,5,-5,-5],g=NaN,m=NaN,b=NaN,h=-1,P=(C,M,k,_)=>{let I=Math.round(M*2),O=Math.floor(C/40),j=Math.floor(k/40);if(!we(I,O,j))return fe;let X=fe;if(I!==g||O!==m||j!==b)g=I,m=O,b=j,h=p.get(I,O,j);for(let W=h;W>=0;W=d[W]){let E=w[W];if(u[E]===_||!(C-6>=s[E]-0.5&&C+6<=o[E]+0.5&&k-6>=i[E]-0.5&&k+6<=a[E]+0.5))continue;let x=e[u[E]].m,R=c[E],D=f[E],U=l[E],G=C-x[0],N=M-x[1],V=k-x[2],z=x[3]*G+x[6]*N+x[9]*V,K=x[5]*G+x[8]*N+x[11]*V,{nx:q,nz:se,mask:ae}=R,oe=!0;for(let ee=0;ee<5;ee++){let te=Math.floor((z+y[ee]-D)/20),ne=Math.floor((K+L[ee]-U)/20);if(te<0||ne<0||te>=q||ne>=se||ae[te*se+ne]!==1){oe=!1;break}}if(oe){if(!n)return 0;let ee=n[u[E]];if(ee<X)X=ee}}return X},A=0;for(let C of e){let M=De(t,C.part);if(M)A+=M.nStuds}let S=new Uint8Array(A),T=new Uint8Array(A),B=new Ue(A),v=0,F=n?new Int32Array(A).fill(fe):void 0;for(let C=0,M=0;C<e.length;C++){let k=e[C],_=De(t,k.part);if(!_)continue;let I=k.m,O=_.studM,j=I[0],X=I[1],W=I[2],E=I[3],x=I[4],R=I[5],D=I[6],U=I[7],G=I[8],N=I[9],V=I[10],z=I[11];for(let K=0;K<_.nStuds;K++,M++){let q=K*12,se=O[q+4],ae=O[q+7],oe=O[q+10];if(!(Math.abs(D*se+U*ae+G*oe-1)<0.001&&Math.abs(E*se+x*ae+R*oe)<0.001&&Math.abs(N*se+V*ae+z*oe)<0.001))continue;T[M]=1;let ee=O[q],te=O[q+1],ne=O[q+2],ze=j+E*ee+x*te+R*ne,Oe=X+D*ee+U*te+G*ne,Ne=W+N*ee+V*te+z*ne,$e=P(ze,Oe,Ne,C);if($e!==fe){if(S[M]=1,v++,F)F[M]=$e}let me=Math.round(ze),he=Math.round(Oe),ge=Math.round(Ne);if(!we(me,he,ge))continue;if(!n){B.put(me,he,ge,1);continue}let je=n[C],Ve=B.get(me,he,ge);if(Ve<0||je<Ve)B.put(me,he,ge,je)}}let Y=new Uint8Array(e.length),H=n?new Int32Array(e.length).fill(fe):void 0;for(let C=0;C<e.length;C++){let M=e[C],k=t.parts[M.part];if(!k||!k.under||!gt(M.m))continue;let _=k.bbox,I=Math.round((_[3]-_[0])/20),O=Math.round((_[5]-_[2])/20);if(!I||!O||I*O>4096)continue;let j=M.m,X=!0,W=0;for(let E=0;E<I&&X;E++)for(let x=0;x<O;x++){let R=_[0]+10+20*E,D=_[2]+10+20*x,U=j[0]+j[3]*R+j[5]*D,G=j[2]+j[9]*R+j[11]*D,N=Math.round(U),V=Math.round(j[1]+_[4]),z=Math.round(G),K=we(N,V,z)?B.get(N,V,z):-1;if(K<0){X=!1;break}if(K>W)W=K}if(X){if(Y[C]=1,H)H[C]=W}}return{nStuds:A,studHidden:S,studUp:T,underHidden:Y,studsHidden:v,studHideStep:F,underHideStep:H}}function sn(e,t,n){let r=(l)=>n&&l.texPart&&t.parts[l.texPart]?l.texPart:l.part,s=new Map,o=new Map,i=(l)=>{let p=l.colour;if(!p)return String(l.color);let d=o.get(p);if(d!==void 0)return d;let w=t.colorTable?.[l.color],y=w?.hex??t.colors?.[l.color],L=w?Re({alpha:w.alpha??255,luminance:w.luminance??0,finish:w.finish??{type:"default"}}):"default:op",g=Re(p);if(d=y&&y.toUpperCase()===p.hex.toUpperCase()&&L===g?String(l.color):p.hex.toUpperCase()+"/"+g,d!==String(l.color))s.set(d,p);return o.set(p,d),d},a=e.map((l)=>({part:r(l),color:i(l),m:l.m,steps:l.steps})),u=a.map((l)=>pt(l.steps)),c=[...new Set(u)].sort(),f=new Map(c.map((l,p)=>[l,p]));return{all:a,stepOf:u.map((l)=>f.get(l)),nSteps:c.length,localColours:s}}function Ae(e,t,n=!0){let r=sn(e,t,n);return rn(r.all,t,r.nSteps>1?r.stepOf:void 0)}var Te="https://ldr-demo.vercel.app/cdn/v1/",ve=new Map,Me=new Map;function yt(e=Te,t=fetch){let n=ve.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(()=>ve.delete(e)),ve.set(e,n);return n}var on=(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"),Ce=(e,t)=>on(e)?[e[0]+t,e[1],e[2]]:Array.isArray(e)?e.map((n)=>Ce(n,t)):e&&typeof e==="object"?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,Ce(r,t)])):e;function an(e,t={}){let n=[],r=0,s={},o={};for(let p of e){let d=p.buffer;if(!d)throw Error("ldr: mergePacks needs packs from decodePack/loadPack");let w=new DataView(d).getUint32(0,!0),y=new Uint8Array(d,4+w),L=r;n.push(y),r+=y.byteLength;let g=(4-r%4)%4;if(g)n.push(new Uint8Array(g)),r+=g;for(let[m,b]of Object.entries(p.header.parts??{}))if(!(m in s))s[m]=Ce(b,L);for(let[m,b]of Object.entries(p.header.studKinds??{}))if(!(m in o))o[m]=Ce(b,L)}let i=e[0]?.header??{version:1,weld:!0},a=new TextEncoder().encode(JSON.stringify({...i,parts:s,studKinds:o,...t})),u=(4-(4+a.length)%4)%4,c=4+a.length+u,f=new Uint8Array(c+r);new DataView(f.buffer).setUint32(0,a.length+u,!0),f.set(a,4),f.fill(32,4+a.length,c);let l=c;for(let p of n)f.set(p,l),l+=p.byteLength;return xe(f.buffer)}async function ln(e,t={}){e=[...e];try{return await bt(e,t)}catch(n){let r=t.cdn??Te,s=t.fetch??fetch;ve.delete(r);let o=(i,a)=>s(i,{...a,cache:"reload"});try{return await bt(e,{...t,fetch:o})}catch{throw n}}}async function bt(e,t){let n=t.cdn??Te,r=t.fetch??fetch,s=t.gap??16384,o=await yt(n,r),i=[...new Set([...e].map(Q))],a=[],u=[];for(let g of i){if(Me.has(n+g))continue;let m=o.parts[g];if(m)u.push({name:g,off:m[0],len:m[1],file:m[2]??0});else a.push(g)}u.sort((g,m)=>g.file-m.file||g.off-m.off);let c=[];for(let g of u){let m=c[c.length-1];if(m&&m.file===g.file&&g.off-m.end<=s)m.end=Math.max(m.end,g.off+g.len),m.items.push(g);else c.push({file:g.file,start:g.off,end:g.off+g.len,items:[g]})}let f=0,l=0,p=0,d=new Map,w=async()=>{while(p<c.length){let g=c[p++],m=d.get(g.file);if(m)m=m.subarray(g.start,g.end);else{let b=await r(new URL(o.archives[g.file],n).href,{headers:{Range:`bytes=${g.start}-${g.end-1}`,"Accept-Encoding":"identity"}});if(!b.ok)throw Error(`ldr: parts CDN ${b.status}`);if(l++,m=new Uint8Array(await b.arrayBuffer()),f+=m.byteLength,b.status===200)d.set(g.file,m),m=m.subarray(g.start,g.end)}for(let b of g.items){let h=ye(m.subarray(b.off-g.start,b.off-g.start+b.len)),P=h.buffer.slice(h.byteOffset,h.byteOffset+h.byteLength);Me.set(n+b.name,xe(P))}}};await Promise.all(Array.from({length:Math.min(t.concurrency??24,c.length)},w));let y=i.filter((g)=>Me.has(n+g)).map((g)=>Me.get(n+g));return{pack:y.length?an(y,{colors:o.colors}):xe(cn(o.colors)),missing:a,requests:l,bytes:f}}function cn(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}function un(e,t){let n=t.header.parts;if(!n)return 0;let r=0;for(let s of e){let o=n[s.part]?.body?.tris;if(o)r+=o}return r}function fn(e,t,n){let r=0,s=0,o=!1,i=new Set;for(let a of e){let u=a.embedded?t.get(a.part):Q(a.part),c=u?n.parts[u]:void 0;if(!c)continue;if(c[3]!=null)o=!0,r+=c[3];if(!i.has(u))i.add(u),s+=c[1]}return{bodyTris:r,packBytes:s,known:o}}class pe extends Error{code="ldr-budget";bodyTris;packBytes;maxBodyTris;maxPackBytes;constructor(e){let t=[e.maxBodyTris!=null&&e.bodyTris>e.maxBodyTris?`${e.bodyTris} triangles (limit ${e.maxBodyTris})`:"",e.maxPackBytes!=null&&e.packBytes>e.maxPackBytes?`${(e.packBytes/1e6).toFixed(1)} MB parts pack (limit ${(e.maxPackBytes/1e6).toFixed(0)} MB)`:""].filter(Boolean).join(", ");super(`ldr: model exceeds device budget: ${t}`);this.name="BudgetError",this.bodyTris=e.bodyTris,this.packBytes=e.packBytes,this.maxBodyTris=e.maxBodyTris,this.maxPackBytes=e.maxPackBytes}}async function xt(e,t={}){let n=performance.now(),r=t.fetch??fetch,s=yt(t.cdn??Te,r);s.catch(()=>{});let o=t.text?e:await r(e).then(async(h)=>{if(!h.ok)throw Error(`ldr: ${h.status} fetching ${e}`);return _e(await h.arrayBuffer())}),i=performance.now(),a=t.name??(t.text?"main.ldr":Ke(e)),u=mt(o,a,{looseGeometry:!1,callouts:t.callouts}),c=performance.now();t.onParsed?.(u),await s;let f=ht(o,new Set(u.filter((h)=>h.embedded).map((h)=>h.part)),a),l=(h,P)=>t.maxBodyTris!=null&&h>t.maxBodyTris||t.maxPackBytes!=null&&P>t.maxPackBytes;if(t.maxBodyTris!=null||t.maxPackBytes!=null){let h=fn(u,f,await s);if(l(h.known?h.bodyTris:0,h.packBytes))throw new pe({bodyTris:h.bodyTris,packBytes:h.packBytes,maxBodyTris:t.maxBodyTris,maxPackBytes:t.maxPackBytes})}let{pack:p,missing:d,requests:w,bytes:y}=await ln([...u.filter((h)=>!h.embedded).map((h)=>h.part),...f.values()],t),L=new Map([...f].map(([h,P])=>[P,h])),g=d.map((h)=>L.get(h)??h);for(let[h,P]of f){let A=p.header.parts[P];if(A)p.header.parts[h]=A}let m=performance.now();if(t.maxBodyTris!=null||t.maxPackBytes!=null){let h=p.buffer?.byteLength??p.bytes??0,P=un(u,p);if(l(P,h))throw new pe({bodyTris:P,packBytes:h,maxBodyTris:t.maxBodyTris,maxPackBytes:t.maxPackBytes})}let b=t.cull?Ae(u,p.header,t.textures!==!1):void 0;return{insts:u,pack:p,missing:g,requests:w,bytes:y,cull:b,timings:{fetchModel:i-n,parse:c-i,parts:m-c,...b?{cull:performance.now()-m}:{}}}}self.onmessage=async(e)=>{let{id:t,source:n,opts:r}=e.data;try{let s=await xt(n,{...r,cull:!1,onParsed:(f)=>self.postMessage({id:t,insts:f})}),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(),a=Ae(s.insts,s.pack.header,r.textures!==!1),u=performance.now()-i,c=[];for(let f of[a.studHidden,a.studUp,a.underHidden,a.studHideStep,a.underHideStep])if(f)c.push(f.buffer);self.postMessage({id:t,cull:a,ms:u},c)}catch(s){if(s instanceof pe||s?.code==="ldr-budget")self.postMessage({id:t,phase:"error",error:String(s?.message??s),budget:{bodyTris:s.bodyTris,packBytes:s.packBytes,maxBodyTris:s.maxBodyTris,maxPackBytes:s.maxPackBytes}});else self.postMessage({id:t,phase:"error",error:String(s?.message??s)})}};\n';
|
|
4164
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/load-worker.gen.ts
|
|
4165
|
+
var load_worker_gen_default = 'var vt=ArrayBuffer,Z=Uint8Array,de=Uint16Array,Ct=Int16Array;var be=Int32Array,Le=function(e,t,n){if(Z.prototype.slice)return Z.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 Z(n-t);return r.set(e.subarray(t,n)),r},ce=function(e,t,n,r){if(Z.prototype.fill)return Z.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},Tt=function(e,t,n,r){if(Z.prototype.copyWithin)return Z.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 Lt=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],J=function(e,t,n){var r=Error(t||Lt[e]);if(r.code=e,Error.captureStackTrace)Error.captureStackTrace(r,J);if(!n)throw r;return r},Ke=function(e,t,n){var r=0,s=0;for(;r<n;++r)s|=e[t++]<<(r<<3);return s},Et=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},St=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,a=r>>6;if(r&8)J(0);var u=6-s,c=i==3?4:i,f=Ke(e,u,c);u+=c;var l=a?1<<a:s,p=Ke(e,u,l)+(a==1&&256),d=p;if(!s){var w=1<<10+(e[5]>>3);d=w+(w>>3)*(e[5]&7)}if(d>2145386496)J(1);var y=new Z((t==1?p||d:t?0:d)+12);return y[0]=1,y[4]=4,y[8]=8,{b:u+l,y:0,l:0,d:f,w:t&&t!=1?t:y.subarray(12),e:d,o:new be(y.buffer,0,3),u:p,c:o,m:Math.min(131072,d)}}else if((n>>4|e[3]<<20)==25481893)return Et(e,4)+8;J(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)J(3);var o=1<<s,i=o,a=-1,u=-1,c=-1,f=o,l=new vt(512+(o<<2)),p=new Ct(l,0,256),d=new de(l,0,256),w=new de(l,512,o),y=512+(o<<1),L=new Z(l,y,o),g=new Z(l,y+o);while(a<255&&i>0){var m=re(i+1),b=r>>3,h=(1<<m+1)-1,P=(e[b]|e[b+1]<<8|e[b+2]<<16)>>(r&7)&h,A=(1<<m)-1,E=h-i-1,T=P&A;if(T<E)r+=m,P=T;else if(r+=m+1,P>A)P-=E;if(p[++a]=--P,P==-1)i+=P,L[--f]=a;else i-=P;if(!P)do{var B=r>>3;u=(e[B]|e[B+1]<<8)>>(r&7)&3,r+=2,a+=u}while(u==3)}if(a>255||i)J(0);var v=0,F=(o>>1)+(o>>3)+3,Y=o-1;for(var _=0;_<=a;++_){var C=p[_];if(C<1){d[_]=-C;continue}for(c=0;c<C;++c){L[v]=_;do v=v+F&Y;while(v>=f)}}if(v)J(0);for(c=0;c<o;++c){var M=d[L[c]]++,k=g[c]=s-re(M);w[c]=(M<<k)-o}return[r+7>>3,{b:s,s:L,n:g,t:w}]},Pt=function(e,t){var n=0,r=-1,s=new Z(292),o=e[t],i=s.subarray(0,256),a=s.subarray(256,268),u=new de(s.buffer,268);if(o<128){var c=ue(e,t+1,6),f=c[0],l=c[1];t+=o;var p=f<<3,d=e[t];if(!d)J(0);var w=0,y=0,L=l.b,g=L,m=(++t<<3)-8+re(d);for(;;){if(m-=L,m<p)break;var b=m>>3;if(w+=(e[b]|e[b+1]<<8)>>(m&7)&(1<<L)-1,i[++r]=l.s[w],m-=g,m<p)break;b=m>>3,y+=(e[b]|e[b+1]<<8)>>(m&7)&(1<<g)-1,i[++r]=l.s[y],L=l.n[w],w=l.t[w],g=l.n[y],y=l.t[y]}if(++r>255)J(0)}else{r=o-127;for(;n<r;n+=2){var h=e[++t];i[n]=h>>4,i[n+1]=h&15}++t}var P=0;for(n=0;n<r;++n){var A=i[n];if(A>11)J(0);P+=A&&1<<A-1}var E=re(P)+1,T=1<<E,B=T-P;if(B&B-1)J(0);i[r++]=re(B)+1;for(n=0;n<r;++n){var A=i[n];++a[i[n]=A&&E+1-A]}var v=new Z(T<<1),F=v.subarray(0,T),Y=v.subarray(T);u[E]=0;for(n=E;n>0;--n){var _=u[n];ce(Y,n,_,u[n-1]=_+a[n]*(1<<E-n))}if(u[0]!=T)J(0);for(n=0;n<r;++n){var C=i[n];if(C){var M=u[C];ce(F,n,M,u[C]=M+(1<<E-C))}}return[t,{n:Y,b:E,s:F}]},kt=ue(new Z([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],It=ue(new Z([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],Bt=ue(new Z([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],We=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},Ee=new Z(new be([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),Ft=We(Ee,0),Se=new Z(new be([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),Rt=We(Se,3),le=function(e,t,n){var r=e.length,s=t.length,o=e[r-1],i=(1<<n.b)-1,a=-n.b;if(!o)J(0);var u=0,c=n.b,f=(r<<3)-8+re(o)-c,l=-1;for(;f>a&&l<s;){var p=f>>3,d=(e[p]|e[p+1]<<8|e[p+2]<<16)>>(f&7);u=(u<<c|d)&i,t[++l]=n.s[u],f-=c=n.n[u]}if(f!=a||l+1!=s)J(0)},Dt=function(e,t,n){var r=6,s=t.length,o=s+3>>2,i=o<<1,a=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,a),n),le(e.subarray(r),t.subarray(a),n)},Ut=function(e,t,n){var r,s=t.b,o=e[s],i=o>>1&3;t.l=o&1;var a=o>>3|e[s+1]<<5|e[s+2]<<13,u=(s+=3)+a;if(i==1){if(s>=e.length)return;if(t.b=s+1,n)return ce(n,e[s],t.y,t.y+=a),n;return ce(new Z(a),e[s])}if(u>e.length)return;if(i==0){if(t.b=u,n)return n.set(e.subarray(s,u),t.y),t.y+=a,n;return Le(e,s,u)}if(i==2){var c=e[s],f=c&3,l=c>>2&3,p=c>>4,d=0,w=0;if(f<2)if(l&1)p|=e[++s]<<4|(l&2&&e[++s]<<12);else p=c>>3;else if(w=l,l<2)p|=(e[++s]&63)<<4,d=e[s]>>6|e[++s]<<2;else if(l==2)p|=e[++s]<<4|(e[++s]&3)<<12,d=e[s]>>2|e[++s]<<6;else p|=e[++s]<<4|(e[++s]&63)<<12,d=e[s]>>6|e[++s]<<2|e[++s]<<10;++s;var y=n?n.subarray(t.y,t.y+t.m):new Z(t.m),L=y.length-p;if(f==0)y.set(e.subarray(s,s+=p),L);else if(f==1)ce(y,e[s++],L);else{var g=t.h;if(f==2){var m=Pt(e,s);d+=s-(s=m[0]),t.h=g=m[1]}else if(!g)J(0);(w?Dt:le)(e.subarray(s,s+=d),y.subarray(L),g)}var b=e[s++];if(b){if(b==255)b=(e[s++]|e[s++]<<8)+32512;else if(b>127)b=b-128<<8|e[s++];var h=e[s++];if(h&3)J(0);var P=[It,Bt,kt];for(var A=2;A>-1;--A){var E=h>>(A<<1)+2&3;if(E==1){var T=new Z([0,0,e[s++]]);P[A]={s:T.subarray(2,3),n:T.subarray(0,1),t:new de(T.buffer,0,1),b:0}}else if(E==2)r=ue(e,s,9-(A&1)),s=r[0],P[A]=r[1];else if(E==3){if(!t.t)J(0);P[A]=t.t[A]}}var B=t.t=P,v=B[0],F=B[1],Y=B[2],_=e[u-1];if(!_)J(0);var C=(u<<3)-8+re(_)-Y.b,M=C>>3,k=0,G=(e[M]|e[M+1]<<8)>>(C&7)&(1<<Y.b)-1;M=(C-=F.b)>>3;var I=(e[M]|e[M+1]<<8)>>(C&7)&(1<<F.b)-1;M=(C-=v.b)>>3;var N=(e[M]|e[M+1]<<8)>>(C&7)&(1<<v.b)-1;for(++b;--b;){var j=Y.s[G],X=Y.n[G],W=v.s[N],S=v.n[N],x=F.s[I],R=F.n[I];M=(C-=x)>>3;var D=1<<x,U=D+((e[M]|e[M+1]<<8|e[M+2]<<16|e[M+3]<<24)>>>(C&7)&D-1);M=(C-=Se[W])>>3;var H=Rt[W]+((e[M]|e[M+1]<<8|e[M+2]<<16)>>(C&7)&(1<<Se[W])-1);M=(C-=Ee[j])>>3;var z=Ft[j]+((e[M]|e[M+1]<<8|e[M+2]<<16)>>(C&7)&(1<<Ee[j])-1);if(M=(C-=X)>>3,G=Y.t[G]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<X)-1),M=(C-=S)>>3,N=v.t[N]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<S)-1),M=(C-=R)>>3,I=F.t[I]+((e[M]|e[M+1]<<8)>>(C&7)&(1<<R)-1),U>3)t.o[2]=t.o[1],t.o[1]=t.o[0],t.o[0]=U-=3;else{var V=U-(z!=0);if(V){if(U=V==3?t.o[0]-1:t.o[V],V>1)t.o[2]=t.o[1];t.o[1]=t.o[0],t.o[0]=U}else U=t.o[0]}for(var A=0;A<z;++A)y[k+A]=y[L+A];k+=z,L+=z;var O=k-U;if(O<0){var K=-O,q=t.e+O;if(K>H)K=H;for(var A=0;A<K;++A)y[k+A]=t.w[q+A];k+=K,H-=K,O=0}for(var A=0;A<H;++A)y[k+A]=y[O+A];k+=H}if(k!=L)while(L<y.length)y[k++]=y[L++];else k=y.length;if(n)t.y+=k;else y=Le(y,0,k)}else if(n){if(t.y+=p,L)for(var A=0;A<p;++A)y[A]=y[L+A]}else if(L)y=Le(y,L);return t.b=u,y}J(2)},Ot=function(e,t){if(e.length==1)return e[0];var n=new Z(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 ye(e,t){var n=[],r=+!t,s=0,o=0;for(;e.length;){var i=St(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 a=Ut(e,i,t);if(!a)J(5);if(t)i.e=i.y;else n.push(a),o+=a.length,Tt(i.w,0,a.length),i.w.set(a,i.w.length-a.length)}s=i.b+i.c*4}else s=i;e=e.subarray(s)}return Ot(n,o)}async function Nt(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=(r)=>r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);if(t[0]===40&&t[1]===181&&t[2]===47&&t[3]===253)return n(ye(t));if(t[0]===31&&t[1]===139)return new Response(new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip"))).arrayBuffer();return n(t)}async function Xe(e){return new TextDecoder().decode(await Nt(e))}var Ze=(e)=>decodeURIComponent(e.split(/[?#]/)[0].split("/").pop()||"main.ldr").replace(/\\.(zst|gz)$/i,"")||"main.ldr";function xe(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 Q=(e)=>e.trim().toLowerCase().replace(/\\\\/g,"/").replace(/\\/+/g,"/"),ke=/^[A-Za-z][A-Za-z0-9_]*$/,Pe=new Map;function Ie(e){let t=e.toLowerCase(),n=2166136261;for(let s=0;s<t.length;s++)n^=t.charCodeAt(s),n=Math.imul(n,16777619);let r=-1-(n>>>0&1073741823);if(!Pe.has(r))Pe.set(r,t);return r}function Be(e){let t=e.charCodeAt(0)|32;if(t>=97&&t<=122&&ke.test(e))return Ie(e);if(/^0x/i.test(e))return parseInt(e,16);return+e}var Ye=/^~?\\s*moved\\s+to\\s+(.+)$/i,zt=new Set(["FILE","NOFILE","!DATA","!:","STEP","BFC","ROTSTEP","BUFEXCHG","!TEXMAP"]),st=new Set(["part","subpart","primitive","8_primitive","48_primitive","shortcut","helper"]),$t=new Set(["model","submodel","configuration"]),jt=/^(?:!?LDRAW_ORG|Unofficial|Official\\s+LCAD)\\s+(\\S+)/i;function Je(e){let t=jt.exec(e);if(!t)return;let n=t[1].toLowerCase().replace(/^unofficial_/,"");return st.has(n)||$t.has(n)?n:void 0}function Vt(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 _t(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 a=n[2].trim();for(let l=0;l<s;l++)a=a.replace(/^\\S+\\s*/,"");let u=Vt(a);if(!u.length)return null;let c={method:r,p1:i.slice(0,3),p2:i.slice(3,6),p3:i.slice(6,9),texture:u[0]};if(s>=10)c.a=i[9];if(s===11)c.b=i[10];let f=u.findIndex((l,p)=>p>0&&l.toUpperCase()==="GLOSSMAP");if(f>0&&u[f+1])c.glossmap=u[f+1];if(t)c.next=!0;return c}var Ht=(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 Gt(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 f=s();if(f===null)return null;i[c]=+f}while(n<t&&r(e.charCodeAt(n)))n++;if(n>=t)return null;let a=e.slice(n),u=/[ \\t]{2,}|\\t/.test(a)?a.split(/\\s+/).join(" "):a;return{t:1,color:Be(o),m:i,file:Q(u)}}function qe(e){let t=+e[0];if(!(t>=1&&t<=5)||e.length<2)return null;let n=Be(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 ot(e,t="main.ldr",n={}){let r=!!n.geometryText,s=new Map,o=null,i="",a,u=null,c=[],f=null,l=()=>{if(!u)return;let m=Ht(u.chunks.join("")),b=m[0]===137&&m[1]===80&&m[2]===78&&m[3]===71;(a??=new Map).set(Q(u.name),{name:u.name,bytes:m,...b?{mime:"image/png"}:{}}),u=null},p=!0,d=(m)=>{if(l(),o={name:Q(m),cmds:[]},s.set(o.name,o),!i)i=o.name;c=[],f=null,p=!0},w=!1,y=!1,L=()=>{if(y)return;y=!0,s.clear(),o=null,i=""},g=(m,b)=>{if(f){m.tex=f,f=null;return}let h=c[c.length-1];if(!h)return;if(h.fallback){if(!b)m.fallback=!0}else m.tex=h.map};for(let m of e.split(`\n`)){let b=m.trim();if(!b)continue;if(r&&b.charCodeAt(0)>=50&&b.charCodeAt(0)<=53&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)){if(u||w)continue;if(!o)d(t);let E=b.slice(2).trimStart(),T=E.search(/\\s/),B={t:b.charCodeAt(0)-48,color:Be(T<0?E:E.slice(0,T)),p:[],src:b};g(B,!1),o.cmds.push(B),p=!1;continue}if(b.charCodeAt(0)===48&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)){let E=2;while(b.charCodeAt(E)===32||b.charCodeAt(E)===9)E++;let T=E;while(T<b.length&&b.charCodeAt(T)!==32&&b.charCodeAt(T)!==9)T++;let B=b.slice(E,T);if(!zt.has(B)){if(w||u)continue;if(!o)d(t);let v=b.slice(E),F={t:0,text:v};if(B.charCodeAt(0)===33)F.meta=B;if(f=null,p&&!o.org){let _=Je(v);if(_)o.org=_}let Y=v.match(Ye);if(Y&&!o.movedTo){let _=Y[1].trim().replace(/\\\\/g,"/");if(!/\\.(dat|ldr|mpd)$/i.test(_))_+=".dat";o.movedTo=Q(_)}o.cmds.push(F);continue}}if(b.charCodeAt(0)===49&&(b.charCodeAt(1)===32||b.charCodeAt(1)===9)&&!u&&!w){let E=Gt(b);if(E){if(!o)d(t);g(E,!1),o.cmds.push(E),p=!1;continue}}let h=b.split(/\\s+/);if(+h[0]===0){let E=b.slice(1).trim();if(h[1]==="FILE"){L(),w=!1,d(E.slice(5));continue}if(h[1]==="NOFILE"){l(),o=null,w=!0;continue}if(h[1]==="!DATA"){L(),l(),o=null,w=!1,u={name:E.slice(5).trim(),chunks:[]};continue}if(w)continue;if(u){if(h[1]==="!:")u.chunks.push(h.slice(2).join(""));continue}if(!o)d(t);let T={t:0,text:E};if(h[1]==="STEP")T.step=!0,c=[],f=null;else if(h[1]==="BFC")T.bfc=h.slice(2).join(" ");else if(h[1]==="ROTSTEP")if(T.meta="ROTSTEP",T.step=!0,c=[],f=null,(h[2]??"").toUpperCase()==="END")T.rotstep={x:0,y:0,z:0,mode:"END"};else{let v=(h[5]??"REL").toUpperCase();T.rotstep={x:+h[2]||0,y:+h[3]||0,z:+h[4]||0,mode:["REL","ABS","ADD"].includes(v)?v:"REL"}}else if(h[1]==="BUFEXCHG"){T.meta="BUFEXCHG";let v=(h[2]??"").toUpperCase();T.bufexchg={op:v==="RETRIEVE"?"RETRIEVE":"STORE",buf:h[3]??"A"}}else if(h[1]?.startsWith("!"))T.meta=h[1];if(p&&!o.org){let v=Je(E);if(v)o.org=v}if(h[1]==="!TEXMAP"){let v=(h[2]??"").toUpperCase();if(f=null,v==="START"||v==="NEXT"){let F=_t(E.replace(/^!TEXMAP\\s+\\S+/i,""),v==="NEXT");if(T.texmap={op:v,...F?{map:F}:{}},F)if((o.texmaps??=[]).push(F),v==="START")c.push({map:F,fallback:!1});else f=F}else if(v==="FALLBACK"){T.texmap={op:v};let F=c[c.length-1];if(F)F.fallback=!0}else if(v==="END")T.texmap={op:v},c.pop()}else if(h[1]==="!:"){f=null;let v=qe(h.slice(2));if(v)g(v,!0),T.geom=v}else f=null;let B=E.match(Ye);if(B&&!o.movedTo){let v=B[1].trim().replace(/\\\\/g,"/");if(!/\\.(dat|ldr|mpd)$/i.test(v))v+=".dat";o.movedTo=Q(v)}o.cmds.push(T);continue}if(u||w)continue;if(!o)d(t);let A=qe(h);if(!A)continue;g(A,!1),o.cmds.push(A),p=!1}return l(),a?{main:i,files:s,data:a}:{main:i,files:s}}var yn=Math.PI/180;function it(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 at(e,t){let[n,r,s,o,i,a,u,c,f,l,p,d]=e,[w,y,L,g,m,b,h,P,A,E,T,B]=t;return[o*w+i*y+a*L+n,u*w+c*y+f*L+r,l*w+p*y+d*L+s,o*g+i*h+a*E,o*m+i*P+a*T,o*b+i*A+a*B,u*g+c*h+f*E,u*m+c*P+f*T,u*b+c*A+f*B,l*g+p*h+d*E,l*m+p*P+d*T,l*b+p*A+d*B]}var Fe=[0,0,0,1,0,0,0,1,0,0,0,1];var Qe=new WeakMap,Kt=/^(s|8|48)\\//;function Re(e,t){let n=e.files.get(Q(t));if(!n)return"part";let r=Qe.get(n);if(r)return r;if(n.org)r=st.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&&Kt.test(s.file))?"part":"model";return Qe.set(n,r),r}var et=new WeakMap;function lt(e){let t=et.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 et.set(e,t),t}var tt=(e)=>e>16777215?"0x"+e.toString(16).toUpperCase():e<0?Pe.get(e)??String(e):String(e),Wt=(e)=>e.t===0?"0 "+e.text:e.t===1?`1 ${tt(e.color)} ${e.m.join(" ")} ${e.file}`:e.src?e.src:`${e.t} ${tt(e.color)} ${e.p.join(" ")}`,De=(e,t)=>`${Q(e)}#${t}`;function Xt(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:De(e.name,t),cmds:n}}function ct(e,t){return[`0 ldr: own geometry of ${e.name}, step ${t}`,...Xt(e,t).cmds.map(Wt)].join(`\n`)+`\n`}function Zt(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 ut(e){let[t,n,r,s,o,i,a,u,c,f,l,p]=e,d=u*p-c*l,w=-(a*p-c*f),y=a*l-u*f,L=s*d+o*w+i*y;if(!Number.isFinite(L)||Math.abs(L)<0.000000000001)return null;let g=1/L,m=[d*g,-(o*p-i*l)*g,(o*c-i*u)*g,w*g,(s*p-i*f)*g,-(s*c-i*a)*g,y*g,-(s*l-o*f)*g,(s*u-o*a)*g];return[-(m[0]*t+m[1]*n+m[2]*r),-(m[3]*t+m[4]*n+m[5]*r),-(m[6]*t+m[7]*n+m[8]*r),...m]}var Yt=(e)=>String(+e.toFixed(6)||0),nt=(e)=>\'"\'+e.replace(/\\\\/g,"\\\\\\\\").replace(/"/g,"\\\\\\"")+\'"\';function ft(e,t){let n=[...t.p1,...t.p2,...t.p3,...t.method!=="PLANAR"?[t.a??360]:[],...t.method==="SPHERICAL"?[t.b??180]:[]].map(Yt).join(" "),r=`0 ldr: ${e} with a model-level !TEXMAP\n0 BFC CERTIFY CCW\n0 !TEXMAP START ${t.method} ${n} ${nt(t.texture)}${t.glossmap?" GLOSSMAP "+nt(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-${Zt(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 qt(e,t,n){let r=Math.PI/180,s=Math.sin(e*r),o=Math.cos(e*r),i=Math.sin(t*r),a=Math.cos(t*r),u=Math.sin(n*r),c=Math.cos(n*r);return[a*c,-a*u,i,o*u+s*i*c,o*c-s*i*u,-s*a,s*u-o*i*c,s*c+o*i*u,o*a]}var rt=new WeakMap;function pt(e){let t=rt.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=qt(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),rt.set(e,n),n}var mt=999999,gt=(e)=>e.map((t)=>String(t).padStart(6,"0")).join(".")+"~";function Qt(e,t={}){let n=[],r=t.maxDepth??64,s=t.looseGeometry!==!1,o=!!t.textures,i=!!t.callouts,a=new Map,u=0,c=(l,p)=>{let d=l.name+"#"+p,w=a.get(d);if(!w){let y;w=Object.assign(()=>y??=ct(l,p),{file:l,step:p}),a.set(d,w)}return w},f=(l,p,d,w,y,L,g,m,b=null,h=[],P=[],A=void 0,E=null)=>{let T=l.files.get(p);if(!T||g>r)return;let B=E,v=0,F=g>0?++u:0,Y=i&&F?[...h,F]:h,_=i&&F?[...P,d]:P,C=i&&!b?new Map:null,M=-1,k=0,G=(S,x,R,D,U,H,z)=>{if(M!==v)M=v,k=0;let V=C?.get(v+"|"+x);if(V)return V.n++,f(S,S===l?x:S.main,R,D,y+"/"+x,[...U,mt],g+1,H,[...U,mt],Y,_,z,B);let O=[...U,k++],K=n.length;f(S,S===l?x:S.main,R,D,y+"/"+x,O,g+1,H,b,Y,_,z,B),C?.set(v+"|"+x,{n:1,from:K,to:n.length})},I=pt(T),N=s?lt(T):[],j=0,X=(S,x,R,D,U,H,z,V)=>{if(b)D=b;let O={part:S,color:x,m:R,step:D[0],steps:D,localStep:U,path:y};if(V)O.colour=V;if(F){if(O.sub=F,i)O.subPath=Y,O.subMats=_}if(H)O.embedded=!0;if(z){let q=ft(S,z);O.texPart=q.name,O.texSource=q.source}let K=I[U];if(K)O.view=K;return n.push(O),O},W=(S)=>{while(j<N.length&&N[j]<=S){let x=N[j++];X(De(T.name,x),w,d,[...L,x],x,!1,null,A).source=c(T,x)}};for(let S of T.cmds){if(S.t===0&&S.step){v++;continue}let x=S;if(x.t>=2||x.t===0&&x.geom&&x.geom.t>=2){W(v);continue}if(x.t===0){if(x.meta==="!COLOUR"){let q=tn(x.text);if(q&&q.code!==16&&q.code!==24)(B=new Map(B??[])).set(q.code,q);continue}if(o&&x.geom?.t===1)x=x.geom;else continue}if(x.t!==1)continue;if(o&&x.fallback)continue;let R=x.color===16?w:x.color,D=x.color===16?A:B?.get(x.color),U=at(d,x.m),H=[...L,v],z=o?x.tex??m:null,V=z?ut(x.m):null,O=z&&V?it(z,V):null;if(l.files.has(x.file)){if(Re(l,x.file)==="model"){G(l,x.file,U,R,H,O,D);continue}X(x.file,R,U,H,v,!0,O,D);continue}let K=t.resolveModel?.(x.file);if(K){G(K,x.file,U,R,H,O,D);continue}X(x.file,R,U,H,v,!1,O,D)}if(W(1/0),C){for(let S of C.values())if(S.n>1)for(let x=S.from;x<S.to;x++)n[x].mult??=S.n}};if(Re(e,e.main)==="part"){if(e.files.get(e.main))n.push({part:e.main,color:16,m:[...Fe],step:0,steps:[0],localStep:0,path:e.main,embedded:!0});return n}return f(e,e.main,Fe,16,e.main,[],0,null),n}function dt(e,t="main.ldr",n){return Qt(ot(e,t,{geometryText:!0}),n)}var en=new Set(["CHROME","PEARLESCENT","RUBBER","MATTE_METALLIC","METAL","MATERIAL"]);function Ue(e){if(!e)return null;if(e.startsWith("#")&&/^#[0-9A-Fa-f]{6}$/.test(e))return e.toUpperCase();if(/^0x[0-9A-Fa-f]{6}$/i.test(e))return("#"+e.slice(2)).toUpperCase();return null}function ht(e,t){let n={value:"#FFFFFF",fraction:0.5};while(t<e.length){let r=e[t].toUpperCase(),s=e[t+1];if(r==="VALUE"){let o=Ue(s);if(o)n.value=o;t+=2}else if(r==="ALPHA")n.alpha=+s,t+=2;else if(r==="LUMINANCE")n.luminance=+s,t+=2;else if(r==="FRACTION")n.fraction=+s,t+=2;else if(r==="VFRACTION")n.vfraction=+s,t+=2;else if(r==="SIZE")n.size=+s,t+=2;else if(r==="MINSIZE")n.minsize=+s,t+=2;else if(r==="MAXSIZE")n.maxsize=+s,t+=2;else break}return{grain:n,next:t}}function tn(e){let t=e.indexOf("!COLOUR");if(t<0)return null;let n=e.slice(t+7).trim().split(/\\s+/).filter(Boolean);if(n.length<2)return null;let r=n[0],s=NaN,o="#FF00FF",i="#333333",a=255,u=0,c={type:"default"},f=1;while(f<n.length){let l=n[f].toUpperCase(),p=n[f+1];if(l==="CODE")s=p!==void 0&&ke.test(p)?Ie(p):p!==void 0&&/^\\d+$/.test(p)?+p:NaN,f+=2;else if(l==="VALUE"){let d=Ue(p);if(d)o=d;f+=2}else if(l==="EDGE")i=Ue(p)??p,f+=2;else if(l==="ALPHA")a=+p,f+=2;else if(l==="LUMINANCE")u=+p,f+=2;else if(l==="CHROME")c={type:"chrome"},f+=1;else if(l==="PEARLESCENT")c={type:"pearlescent"},f+=1;else if(l==="RUBBER")c={type:"rubber"},f+=1;else if(l==="MATTE_METALLIC")c={type:"matte_metallic"},f+=1;else if(l==="METAL")c={type:"metal"},f+=1;else if(l==="MATERIAL"){let d=(n[f+1]||"").toUpperCase();if(d==="GLITTER"){let{grain:w,next:y}=ht(n,f+2);c={type:"glitter",material:w},f=y}else if(d==="SPECKLE"){let{grain:w,next:y}=ht(n,f+2);c={type:"speckle",material:w},f=y}else if(d==="FABRIC"){let w=(n[f+2]||"").toUpperCase(),y=["VELVET","CANVAS","STRING","FUR"].includes(w)?w.toLowerCase():void 0;c={type:"fabric",kind:y},f+=y?3:2}else f=n.length}else if(en.has(l))f+=1;else f+=1}if(Number.isNaN(s)||!o)return null;return{code:s,name:r,hex:o,edge:i,alpha:Number.isFinite(a)?a:255,luminance:Number.isFinite(u)?u:0,finish:c}}function nn(e){let t=Math.max(0,Math.min(1,(e.alpha??255)/255)),n=t<1,r=Math.max(0,Math.min(1,(e.luminance??0)/255)),s={opacity:t,transparent:n,depthWrite:!n,emissive:r,clearcoat:0,clearcoatRoughness:0,sheen:0,sheenRoughness:0};switch(e.finish?.type??"default"){case"chrome":return{...s,metalness:1,roughness:0,finish:"chrome"};case"pearlescent":return{...s,metalness:0.25,roughness:0.3,clearcoat:0.5,clearcoatRoughness:0.25,sheen:0.4,sheenRoughness:0.35,finish:"pearlescent"};case"rubber":return{...s,metalness:0,roughness:0.9,finish:"rubber"};case"matte_metallic":return{...s,metalness:0.4,roughness:0.8,finish:"matte_metallic"};case"metal":return{...s,metalness:0.85,roughness:0.2,finish:"metal"};case"glitter":{let i=e.finish.material,a=i.size??(i.minsize!=null&&i.maxsize!=null?(i.minsize+i.maxsize)/2:1);return{...s,metalness:0.35,roughness:0.25,clearcoat:1,clearcoatRoughness:0.08,particleHex:i.value,particleFraction:i.fraction,particleSize:a,finish:"glitter"}}case"speckle":{let i=e.finish.material,a=i.size??(i.minsize!=null&&i.maxsize!=null?(i.minsize+i.maxsize)/2:1);return{...s,metalness:0.2,roughness:0.55,particleHex:i.value,particleFraction:i.fraction,particleSize:a,finish:"speckle"}}case"fabric":return{...s,metalness:0,roughness:0.85,sheen:0.65,sheenRoughness:0.75,finish:"fabric"};default:return{...s,metalness:0,roughness:0.45,finish:"default"}}}function Oe(e){let t=nn(e),n=!t.transparent?"op":t.opacity>=0.75?"a200":t.opacity>=0.4?"a128":`a${Math.round(t.opacity*255)}`,r=t.emissive>0?`L${Math.round(t.emissive*16)}`:"",s=`${t.finish}:${n}${r}`;if(t.particleHex)s+=`:${t.particleHex}:${(t.particleFraction??0).toFixed(2)}`;return s}function rn(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(Q(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(Q(t),r)}let a=o.trim().replace(/\\s+/g," ");if(a)r.push(a)}return n}var sn=(e)=>{if(!e.startsWith("1 "))return null;let t=e.split(" ");return t.length>=15?Q(t.slice(14).join(" ")):null};function on(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 bt(e,t,n="main.ldr"){let r=rn(e,n),s=new Map;for(let o of t){let i=Q(o);if(!r.has(i)||s.has(i))continue;let a=new Set([i]),u=[i];while(u.length)for(let f of r.get(u.pop())){let l=sn(f);if(l&&r.has(l)&&!a.has(l))a.add(l),u.push(l)}let c=[i,...[...a].filter((f)=>f!==i).sort()].map((f)=>"0 FILE "+(f===i?"":f)+`\n`+r.get(f).join(`\n`)).join(`\n`);s.set(i,`emb/${on(c)}.dat`)}return s}var yt=(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,xt=new WeakMap;function Ne(e,t){let n=xt.get(e);if(!n)xt.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),a=[],u=[];s.studs.forEach((p,d)=>{a.push(p[0]),u.push(p[1]);for(let w=0;w<12;w++)i[d*12+w]=p[2+w]});let c=null,f=0,l=0;if(s.mask){f=s.mask[0],l=s.mask[1];let p=s.mask[2];c=new Uint8Array(p.length);for(let d=0;d<p.length;d++)c[d]=p.charCodeAt(d)===49?1:0}return n.set(t,r={nStuds:o,studM:i,kind:a,color:u,mask:c,nx:f,nz:l}),r}var ie=1073741824;class ze{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,a=this.c;for(;;){if(!s[r])return-1;if(o[r]===e&&i[r]===t&&a[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,a=this.b,u=this.c;for(;;){if(!o[s])return o[s]=1,i[s]=e,a[s]=t,u[s]=n,this.vals[s]=r,this.size++,-1;if(i[s]===e&&a[s]===t&&u[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 we=(e,t,n)=>e>-ie&&e<ie&&t>-ie&&t<ie&&n>-ie&&n<ie,fe=2147483647;function an(e,t,n){let s=[],o=[],i=[],a=[],u=[],c=[],f=[],l=[],p=new ze(e.length*2),d=[],w=[];for(let C=0;C<e.length;C++){let M=e[C],k=M.m,G=t.parts[M.part];if(!G||!G.mask||!yt(k))continue;let I=G.bbox,N=1/0,j=-1/0,X=1/0,W=-1/0;for(let R=0;R<2;R++)for(let D=0;D<2;D++){let U=R?I[3]:I[0],H=D?I[5]:I[2],z=k[0]+k[3]*U+k[5]*H,V=k[2]+k[9]*U+k[11]*H;if(z<N)N=z;if(z>j)j=z;if(V<X)X=V;if(V>W)W=V}let S=u.length;s.push(N),o.push(j),i.push(X),a.push(W),u.push(C),c.push(Ne(t,M.part)),f.push(I[0]),l.push(I[2]);let x=Math.round((k[1]+I[4])*2);for(let R=Math.floor(N/40);R<=Math.floor(j/40);R++)for(let D=Math.floor(X/40);D<=Math.floor(W/40);D++){if(!we(x,R,D))continue;let U=w.length;w.push(S),d.push(p.put(x,R,D,U))}}let y=[0,5,-5,5,-5],L=[0,5,5,-5,-5],g=NaN,m=NaN,b=NaN,h=-1,P=(C,M,k,G)=>{let I=Math.round(M*2),N=Math.floor(C/40),j=Math.floor(k/40);if(!we(I,N,j))return fe;let X=fe;if(I!==g||N!==m||j!==b)g=I,m=N,b=j,h=p.get(I,N,j);for(let W=h;W>=0;W=d[W]){let S=w[W];if(u[S]===G||!(C-6>=s[S]-0.5&&C+6<=o[S]+0.5&&k-6>=i[S]-0.5&&k+6<=a[S]+0.5))continue;let x=e[u[S]].m,R=c[S],D=f[S],U=l[S],H=C-x[0],z=M-x[1],V=k-x[2],O=x[3]*H+x[6]*z+x[9]*V,K=x[5]*H+x[8]*z+x[11]*V,{nx:q,nz:se,mask:ae}=R,oe=!0;for(let ee=0;ee<5;ee++){let te=Math.floor((O+y[ee]-D)/20),ne=Math.floor((K+L[ee]-U)/20);if(te<0||ne<0||te>=q||ne>=se||ae[te*se+ne]!==1){oe=!1;break}}if(oe){if(!n)return 0;let ee=n[u[S]];if(ee<X)X=ee}}return X},A=0;for(let C of e){let M=Ne(t,C.part);if(M)A+=M.nStuds}let E=new Uint8Array(A),T=new Uint8Array(A),B=new ze(A),v=0,F=n?new Int32Array(A).fill(fe):void 0;for(let C=0,M=0;C<e.length;C++){let k=e[C],G=Ne(t,k.part);if(!G)continue;let I=k.m,N=G.studM,j=I[0],X=I[1],W=I[2],S=I[3],x=I[4],R=I[5],D=I[6],U=I[7],H=I[8],z=I[9],V=I[10],O=I[11];for(let K=0;K<G.nStuds;K++,M++){let q=K*12,se=N[q+4],ae=N[q+7],oe=N[q+10];if(!(Math.abs(D*se+U*ae+H*oe-1)<0.001&&Math.abs(S*se+x*ae+R*oe)<0.001&&Math.abs(z*se+V*ae+O*oe)<0.001))continue;T[M]=1;let ee=N[q],te=N[q+1],ne=N[q+2],$e=j+S*ee+x*te+R*ne,je=X+D*ee+U*te+H*ne,Ve=W+z*ee+V*te+O*ne,_e=P($e,je,Ve,C);if(_e!==fe){if(E[M]=1,v++,F)F[M]=_e}let me=Math.round($e),he=Math.round(je),ge=Math.round(Ve);if(!we(me,he,ge))continue;if(!n){B.put(me,he,ge,1);continue}let He=n[C],Ge=B.get(me,he,ge);if(Ge<0||He<Ge)B.put(me,he,ge,He)}}let Y=new Uint8Array(e.length),_=n?new Int32Array(e.length).fill(fe):void 0;for(let C=0;C<e.length;C++){let M=e[C],k=t.parts[M.part];if(!k||!k.under||!yt(M.m))continue;let G=k.bbox,I=Math.round((G[3]-G[0])/20),N=Math.round((G[5]-G[2])/20);if(!I||!N||I*N>4096)continue;let j=M.m,X=!0,W=0;for(let S=0;S<I&&X;S++)for(let x=0;x<N;x++){let R=G[0]+10+20*S,D=G[2]+10+20*x,U=j[0]+j[3]*R+j[5]*D,H=j[2]+j[9]*R+j[11]*D,z=Math.round(U),V=Math.round(j[1]+G[4]),O=Math.round(H),K=we(z,V,O)?B.get(z,V,O):-1;if(K<0){X=!1;break}if(K>W)W=K}if(X){if(Y[C]=1,_)_[C]=W}}return{nStuds:A,studHidden:E,studUp:T,underHidden:Y,studsHidden:v,studHideStep:F,underHideStep:_}}function ln(e,t,n){let r=(l)=>n&&l.texPart&&t.parts[l.texPart]?l.texPart:l.part,s=new Map,o=new Map,i=(l)=>{let p=l.colour;if(!p)return String(l.color);let d=o.get(p);if(d!==void 0)return d;let w=t.colorTable?.[l.color],y=w?.hex??t.colors?.[l.color],L=w?Oe({alpha:w.alpha??255,luminance:w.luminance??0,finish:w.finish??{type:"default"}}):"default:op",g=Oe(p);if(d=y&&y.toUpperCase()===p.hex.toUpperCase()&&L===g?String(l.color):p.hex.toUpperCase()+"/"+g,d!==String(l.color))s.set(d,p);return o.set(p,d),d},a=e.map((l)=>({part:r(l),color:i(l),m:l.m,steps:l.steps})),u=a.map((l)=>gt(l.steps)),c=[...new Set(u)].sort(),f=new Map(c.map((l,p)=>[l,p]));return{all:a,stepOf:u.map((l)=>f.get(l)),nSteps:c.length,localColours:s}}function Ae(e,t,n=!0){let r=ln(e,t,n);return an(r.all,t,r.nSteps>1?r.stepOf:void 0)}var Te="https://ldr-demo.vercel.app/cdn/v1/",ve=new Map,Me=new Map;function At(e=Te,t=fetch){let n=ve.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(()=>ve.delete(e)),ve.set(e,n);return n}var cn=(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"),Ce=(e,t)=>cn(e)?[e[0]+t,e[1],e[2]]:Array.isArray(e)?e.map((n)=>Ce(n,t)):e&&typeof e==="object"?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,Ce(r,t)])):e;function un(e,t={}){let n=[],r=0,s={},o={};for(let p of e){let d=p.buffer;if(!d)throw Error("ldr: mergePacks needs packs from decodePack/loadPack");let w=new DataView(d).getUint32(0,!0),y=new Uint8Array(d,4+w),L=r;n.push(y),r+=y.byteLength;let g=(4-r%4)%4;if(g)n.push(new Uint8Array(g)),r+=g;for(let[m,b]of Object.entries(p.header.parts??{}))if(!(m in s))s[m]=Ce(b,L);for(let[m,b]of Object.entries(p.header.studKinds??{}))if(!(m in o))o[m]=Ce(b,L)}let i=e[0]?.header??{version:1,weld:!0},a=new TextEncoder().encode(JSON.stringify({...i,parts:s,studKinds:o,...t})),u=(4-(4+a.length)%4)%4,c=4+a.length+u,f=new Uint8Array(c+r);new DataView(f.buffer).setUint32(0,a.length+u,!0),f.set(a,4),f.fill(32,4+a.length,c);let l=c;for(let p of n)f.set(p,l),l+=p.byteLength;return xe(f.buffer)}async function fn(e,t={}){e=[...e];try{return await wt(e,t)}catch(n){let r=t.cdn??Te,s=t.fetch??fetch;ve.delete(r);let o=(i,a)=>s(i,{...a,cache:"reload"});try{return await wt(e,{...t,fetch:o})}catch{throw n}}}async function wt(e,t){let n=t.cdn??Te,r=t.fetch??fetch,s=t.gap??16384,o=await At(n,r),i=[...new Set([...e].map(Q))],a=[],u=[];for(let g of i){if(Me.has(n+g))continue;let m=o.parts[g];if(m)u.push({name:g,off:m[0],len:m[1],file:m[2]??0});else a.push(g)}u.sort((g,m)=>g.file-m.file||g.off-m.off);let c=[];for(let g of u){let m=c[c.length-1];if(m&&m.file===g.file&&g.off-m.end<=s)m.end=Math.max(m.end,g.off+g.len),m.items.push(g);else c.push({file:g.file,start:g.off,end:g.off+g.len,items:[g]})}let f=0,l=0,p=0,d=new Map,w=async()=>{while(p<c.length){let g=c[p++],m=d.get(g.file);if(m)m=m.subarray(g.start,g.end);else{let b=await r(new URL(o.archives[g.file],n).href,{headers:{Range:`bytes=${g.start}-${g.end-1}`,"Accept-Encoding":"identity"}});if(!b.ok)throw Error(`ldr: parts CDN ${b.status}`);if(l++,m=new Uint8Array(await b.arrayBuffer()),f+=m.byteLength,b.status===200)d.set(g.file,m),m=m.subarray(g.start,g.end)}for(let b of g.items){let h=ye(m.subarray(b.off-g.start,b.off-g.start+b.len)),P=h.buffer.slice(h.byteOffset,h.byteOffset+h.byteLength);Me.set(n+b.name,xe(P))}}};await Promise.all(Array.from({length:Math.min(t.concurrency??24,c.length)},w));let y=i.filter((g)=>Me.has(n+g)).map((g)=>Me.get(n+g));return{pack:y.length?un(y,{colors:o.colors}):xe(pn(o.colors)),missing:a,requests:l,bytes:f}}function pn(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}function mn(e,t){let n=t.header.parts;if(!n)return 0;let r=0;for(let s of e){let o=n[s.part]?.body?.tris;if(o)r+=o}return r}function hn(e,t,n){let r=0,s=0,o=!1,i=new Set;for(let a of e){let u=a.embedded?t.get(a.part):Q(a.part),c=u?n.parts[u]:void 0;if(!c)continue;if(c[3]!=null)o=!0,r+=c[3];if(!i.has(u))i.add(u),s+=c[1]}return{bodyTris:r,packBytes:s,known:o}}class pe extends Error{code="ldr-budget";bodyTris;packBytes;maxBodyTris;maxPackBytes;constructor(e){let t=[e.maxBodyTris!=null&&e.bodyTris>e.maxBodyTris?`${e.bodyTris} triangles (limit ${e.maxBodyTris})`:"",e.maxPackBytes!=null&&e.packBytes>e.maxPackBytes?`${(e.packBytes/1e6).toFixed(1)} MB parts pack (limit ${(e.maxPackBytes/1e6).toFixed(0)} MB)`:""].filter(Boolean).join(", ");super(`ldr: model exceeds device budget: ${t}`);this.name="BudgetError",this.bodyTris=e.bodyTris,this.packBytes=e.packBytes,this.maxBodyTris=e.maxBodyTris,this.maxPackBytes=e.maxPackBytes}}async function Mt(e,t={}){let n=performance.now(),r=t.fetch??fetch,s=At(t.cdn??Te,r);s.catch(()=>{});let o=t.text?e:await r(e).then(async(h)=>{if(!h.ok)throw Error(`ldr: ${h.status} fetching ${e}`);return Xe(await h.arrayBuffer())}),i=performance.now(),a=t.name??(t.text?"main.ldr":Ze(e)),u=dt(o,a,{looseGeometry:!1,callouts:t.callouts}),c=performance.now();t.onParsed?.(u),await s;let f=bt(o,new Set(u.filter((h)=>h.embedded).map((h)=>h.part)),a),l=(h,P)=>t.maxBodyTris!=null&&h>t.maxBodyTris||t.maxPackBytes!=null&&P>t.maxPackBytes;if(t.maxBodyTris!=null||t.maxPackBytes!=null){let h=hn(u,f,await s);if(l(h.known?h.bodyTris:0,h.packBytes))throw new pe({bodyTris:h.bodyTris,packBytes:h.packBytes,maxBodyTris:t.maxBodyTris,maxPackBytes:t.maxPackBytes})}let{pack:p,missing:d,requests:w,bytes:y}=await fn([...u.filter((h)=>!h.embedded).map((h)=>h.part),...f.values()],t),L=new Map([...f].map(([h,P])=>[P,h])),g=d.map((h)=>L.get(h)??h);for(let[h,P]of f){let A=p.header.parts[P];if(A)p.header.parts[h]=A}let m=performance.now();if(t.maxBodyTris!=null||t.maxPackBytes!=null){let h=p.buffer?.byteLength??p.bytes??0,P=mn(u,p);if(l(P,h))throw new pe({bodyTris:P,packBytes:h,maxBodyTris:t.maxBodyTris,maxPackBytes:t.maxPackBytes})}let b=t.cull?Ae(u,p.header,t.textures!==!1):void 0;return{insts:u,pack:p,missing:g,requests:w,bytes:y,cull:b,timings:{fetchModel:i-n,parse:c-i,parts:m-c,...b?{cull:performance.now()-m}:{}}}}self.onmessage=async(e)=>{let{id:t,source:n,opts:r}=e.data;try{let s=await Mt(n,{...r,cull:!1,onParsed:(f)=>self.postMessage({id:t,insts:f})}),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(),a=Ae(s.insts,s.pack.header,r.textures!==!1),u=performance.now()-i,c=[];for(let f of[a.studHidden,a.studUp,a.underHidden,a.studHideStep,a.underHideStep])if(f)c.push(f.buffer);self.postMessage({id:t,cull:a,ms:u},c)}catch(s){if(s instanceof pe||s?.code==="ldr-budget")self.postMessage({id:t,phase:"error",error:String(s?.message??s),budget:{bodyTris:s.bodyTris,packBytes:s.packBytes,maxBodyTris:s.maxBodyTris,maxPackBytes:s.maxPackBytes}});else self.postMessage({id:t,phase:"error",error:String(s?.message??s)})}};\n';
|
|
4148
4166
|
|
|
4149
|
-
// ../../../../../../../tmp/ldr-build-
|
|
4167
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/cdn.ts
|
|
4150
4168
|
var worker;
|
|
4151
4169
|
var seq = 0;
|
|
4152
4170
|
var pending = new Map;
|
|
@@ -4259,7 +4277,7 @@ async function loadModel(source, o = {}) {
|
|
|
4259
4277
|
timings: { ...prep.timings, parts: t3 - t0 - prep.timings.fetchModel - prep.timings.parse, build: t4 - t3, total: t4 - t0 }
|
|
4260
4278
|
});
|
|
4261
4279
|
}
|
|
4262
|
-
// ../../../../../../../tmp/ldr-build-
|
|
4280
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/library.ts
|
|
4263
4281
|
import { existsSync, readFileSync } from "fs";
|
|
4264
4282
|
import { join } from "path";
|
|
4265
4283
|
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]];
|
|
@@ -4513,11 +4531,11 @@ class Library {
|
|
|
4513
4531
|
return insts;
|
|
4514
4532
|
}
|
|
4515
4533
|
}
|
|
4516
|
-
// ../../../../../../../tmp/ldr-build-
|
|
4534
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/build-pack.ts
|
|
4517
4535
|
import fs3 from "node:fs";
|
|
4518
4536
|
import path3 from "node:path";
|
|
4519
4537
|
|
|
4520
|
-
// ../../../../../../../tmp/ldr-build-
|
|
4538
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/resolver.ts
|
|
4521
4539
|
import fs from "node:fs";
|
|
4522
4540
|
import path from "node:path";
|
|
4523
4541
|
var TOP_STUD_RE = /^(stud|studa|stud2|stud2a|stud6|stud6a|stud10|stud15|stud2s|stud2s2|stud-logo\d*|stud2-logo\d*)\.dat$/i;
|
|
@@ -4789,11 +4807,11 @@ function collectDeps(lib, refs) {
|
|
|
4789
4807
|
return out;
|
|
4790
4808
|
}
|
|
4791
4809
|
|
|
4792
|
-
// ../../../../../../../tmp/ldr-build-
|
|
4810
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/compile.ts
|
|
4793
4811
|
import fs2 from "node:fs";
|
|
4794
4812
|
import path2 from "node:path";
|
|
4795
4813
|
|
|
4796
|
-
// ../../../../../../../tmp/ldr-build-
|
|
4814
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/lod.ts
|
|
4797
4815
|
import { MeshoptSimplifier, MeshoptEncoder } from "meshoptimizer";
|
|
4798
4816
|
await Promise.all([MeshoptSimplifier.ready, MeshoptEncoder.ready]);
|
|
4799
4817
|
function reorderMesh(P, N, C, I) {
|
|
@@ -4985,7 +5003,7 @@ function lodChain(P, C, I) {
|
|
|
4985
5003
|
return out;
|
|
4986
5004
|
}
|
|
4987
5005
|
|
|
4988
|
-
// ../../../../../../../tmp/ldr-build-
|
|
5006
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/compile.ts
|
|
4989
5007
|
function loadColors(root) {
|
|
4990
5008
|
const map = new Map;
|
|
4991
5009
|
for (const l of fs2.readFileSync(path2.join(root, "LDConfig.ldr"), "latin1").split(/\r?\n/)) {
|
|
@@ -5622,7 +5640,7 @@ function encodePack(parts, studKinds, weld, extra, options = {}) {
|
|
|
5622
5640
|
return Buffer.concat([head, ...chunks.map((c) => new Uint8Array(c.buffer, c.byteOffset, c.byteLength))]);
|
|
5623
5641
|
}
|
|
5624
5642
|
|
|
5625
|
-
// ../../../../../../../tmp/ldr-build-
|
|
5643
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/build-pack.ts
|
|
5626
5644
|
function buildPack(o) {
|
|
5627
5645
|
const lib = new Library2(o.ldrawRoot);
|
|
5628
5646
|
const refs = new Map;
|
|
@@ -5689,7 +5707,7 @@ function buildPack(o) {
|
|
|
5689
5707
|
const warnings = [...lib.conflicts].map((n) => `${n}: defined differently by two models; the first definition is used`);
|
|
5690
5708
|
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 } : {} };
|
|
5691
5709
|
}
|
|
5692
|
-
// ../../../../../../../tmp/ldr-build-
|
|
5710
|
+
// ../../../../../../../tmp/ldr-build-tYthc8/src/node/promote.ts
|
|
5693
5711
|
var GEOM = /^\s*[2-5]\s/;
|
|
5694
5712
|
var REF = /^\s*1\s/;
|
|
5695
5713
|
var FILE = /^\s*0\s+FILE\s+(.+?)\s*$/i;
|
|
@@ -5972,6 +5990,7 @@ export {
|
|
|
5972
5990
|
instanceBoxes,
|
|
5973
5991
|
invert,
|
|
5974
5992
|
isDirectColor,
|
|
5993
|
+
isNamedColor,
|
|
5975
5994
|
isolateMask,
|
|
5976
5995
|
loadColors,
|
|
5977
5996
|
loadModel,
|
|
@@ -5988,6 +6007,7 @@ export {
|
|
|
5988
6007
|
mergePacks,
|
|
5989
6008
|
modelFileName,
|
|
5990
6009
|
mul,
|
|
6010
|
+
namedColorCode,
|
|
5991
6011
|
norm,
|
|
5992
6012
|
packTexture,
|
|
5993
6013
|
parse,
|
package/dist/spec.d.ts
CHANGED
|
@@ -87,7 +87,19 @@ export interface Doc {
|
|
|
87
87
|
data?: Map<string, DataBlock>;
|
|
88
88
|
}
|
|
89
89
|
export declare const norm: (s: string) => string;
|
|
90
|
-
/**
|
|
90
|
+
/** `!COLOUR` identifier (article 299, "Syntax"): a-zA-Z0-9_, first character alphabetic; case-insensitive. */
|
|
91
|
+
export declare const COLOUR_ID_RE: RegExp;
|
|
92
|
+
/**
|
|
93
|
+
* Number for a named colour code: `0 !COLOUR name CODE x` where x is an identifier instead of 0-511 ("if strict LDraw compatibility
|
|
94
|
+
* is not required, x is any identifier recognized by a rendering program as a color code", article 299). Identifiers are
|
|
95
|
+
* case-insensitive, so `MyRed` and `myred` are one code. The number is negative (-1 - 30-bit FNV-1a of the lower-case text), so it
|
|
96
|
+
* never collides with a real code (0-511, direct colours 0x2RRGGBB...) and is the same in every thread / worker. `colorToken`
|
|
97
|
+
* turns it back into the identifier.
|
|
98
|
+
*/
|
|
99
|
+
export declare function namedColorCode(id: string): number;
|
|
100
|
+
/** True for a named colour code from `namedColorCode` (negative), not a numeric LDraw code. */
|
|
101
|
+
export declare const isNamedColor: (c: number) => boolean;
|
|
102
|
+
/** Parse LDraw color token: decimal code, direct color 0x2RRGGBB (and related 0xN…… forms), or a `!COLOUR` identifier (see `namedColorCode`). */
|
|
91
103
|
export declare function parseColor(tok: string): number;
|
|
92
104
|
/** Parse the tail of `0 !TEXMAP START|NEXT <method> <params> <png> [GLOSSMAP <png>]`. Returns null when malformed. */
|
|
93
105
|
export declare function parseTexMap(tail: string, next?: boolean): TexMap | null;
|
|
@@ -192,7 +204,7 @@ export type FileKind = "part" | "model";
|
|
|
192
204
|
export declare function fileKind(doc: Doc, name: string): FileKind;
|
|
193
205
|
/** Local steps (as counted by `flatten`) in which a file has its own type 2-5 lines or `0 !:` geometry, ascending. */
|
|
194
206
|
export declare function looseSteps(f: LFile): number[];
|
|
195
|
-
/** LDraw colour token for a colour code: decimal,
|
|
207
|
+
/** LDraw colour token for a colour code: decimal, `0x2RRGGBB` for direct colours, or the (lower-case) identifier of a named code. */
|
|
196
208
|
export declare const colorToken: (c: number) => string;
|
|
197
209
|
/** Name of the synthetic part holding a model file's own geometry in local step `step`: `<file>#<step>`. */
|
|
198
210
|
export declare const loosePartName: (file: string, step: number) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ldr",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "High-performance LEGO (LDraw) rendering for three.js: instanced parts packs, hidden stud/tube culling, low-detail studs, indexed edges, build steps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Evan Bacon",
|