stack3js 0.0.0-stage → 0.6.4

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.
Files changed (97) hide show
  1. package/COMMAND.md +145 -0
  2. package/LICENSE +21 -0
  3. package/README.md +304 -2
  4. package/THIRD-PARTY-LICENSES.md +100 -0
  5. package/bin/stack3.mjs +5437 -0
  6. package/blender/import_stack.py +89 -0
  7. package/examples/future-tank.stack3.json +1 -0
  8. package/examples/traffic-cone-4view.png +0 -0
  9. package/meshing/blocks.py +82 -0
  10. package/meshing/branches.py +62 -0
  11. package/meshing/dexel.py +67 -0
  12. package/meshing/field_data.py +19 -0
  13. package/meshing/finish_blender.py +203 -0
  14. package/meshing/finishing.py +155 -0
  15. package/meshing/geometry.py +71 -0
  16. package/meshing/guided.py +150 -0
  17. package/meshing/implicit.py +178 -0
  18. package/meshing/intersection.py +33 -0
  19. package/meshing/material.py +115 -0
  20. package/meshing/mesh.py +103 -0
  21. package/meshing/network.py +136 -0
  22. package/meshing/regularization.py +213 -0
  23. package/meshing/sections.py +165 -0
  24. package/meshing/signed_distance.py +93 -0
  25. package/package.json +32 -4
  26. package/references/hard-surface/README.md +40 -0
  27. package/references/hard-surface/atlas/concrete-barrier-4view.png +0 -0
  28. package/references/hard-surface/atlas/preview.pipeline.yaml +14 -0
  29. package/references/hard-surface/case-studies/benchmark/README.md +22 -0
  30. package/references/hard-surface/case-studies/benchmark/lod-bevel.pipeline.yaml +258 -0
  31. package/references/hard-surface/finishing/exports.yaml +10 -0
  32. package/references/hard-surface/finishing/finish-lod.pipeline.yaml +33 -0
  33. package/references/hard-surface/finishing/inputs/stack/stack.json +1 -0
  34. package/references/hard-surface/finishing/inputs/stack/stack.png +0 -0
  35. package/references/hard-surface/finishing/regularize.pipeline.yaml +46 -0
  36. package/references/hard-surface/measured-depth/sdf/compare.pipeline.yaml +12 -0
  37. package/references/hard-surface/measured-depth/sdf/inputs/field.npy +0 -0
  38. package/references/hard-surface/measured-depth/sdf/inputs/stack/stack.json +1 -0
  39. package/references/hard-surface/measured-depth/sdf/inputs/stack/stack.png +0 -0
  40. package/references/hard-surface/measured-depth/sdf/inputs/truth.json +1 -0
  41. package/references/hard-surface/measured-depth/sdf/sdf.guide.json +3 -0
  42. package/references/hard-surface/measured-depth/triple-dexel/compare.pipeline.yaml +12 -0
  43. package/references/hard-surface/measured-depth/triple-dexel/dexel.guide.json +3 -0
  44. package/references/hard-surface/measured-depth/triple-dexel/inputs/fixture.json +22 -0
  45. package/references/hard-surface/measured-depth/triple-dexel/inputs/stack/stack.json +22 -0
  46. package/references/hard-surface/measured-depth/triple-dexel/inputs/stack/stack.png +0 -0
  47. package/references/hard-surface/measured-depth/triple-dexel/inputs/triple-dexel.npz +0 -0
  48. package/references/hard-surface/schema/pipeline-fragment.schema.json +5 -0
  49. package/references/hard-surface/schema/pipeline.schema.json +181 -0
  50. package/schema/pipeline-fragment.schema.json +5 -0
  51. package/schema/pipeline.schema.json +181 -0
  52. package/verification/assembly.py +96 -0
  53. package/verification/landmarks.py +53 -0
  54. package/verification/panels.py +137 -0
  55. package/verification/projections.py +135 -0
  56. package/verification/verify.py +108 -0
  57. package/viewer/dist/THIRD-PARTY-LICENSES.md +174 -0
  58. package/viewer/dist/assets/GLTFExporter-xdVCArY-.js +1 -0
  59. package/viewer/dist/assets/ant-mech-angled-leg-4view-BO2qt1_k.png +0 -0
  60. package/viewer/dist/assets/ant-mech-body-4view-D9xVPpbc.png +0 -0
  61. package/viewer/dist/assets/ant-mech-center-leg-4view-BcphjF_G.png +0 -0
  62. package/viewer/dist/assets/compare-B6DWTZS9.css +1 -0
  63. package/viewer/dist/assets/compare-Du4RoRQO.js +6 -0
  64. package/viewer/dist/assets/compare.worker-CgJq-znx.js +21 -0
  65. package/viewer/dist/assets/concrete-barrier-4view-7PsO3Ftq.png +0 -0
  66. package/viewer/dist/assets/emscripten-module-uFzwHH0Y.wasm +0 -0
  67. package/viewer/dist/assets/emscripten-module.browser-BcR5qphc.js +1 -0
  68. package/viewer/dist/assets/ffi-Boa1QuFa.js +1 -0
  69. package/viewer/dist/assets/fillet-rover-body-4-view-Chk8Mx4R.png +0 -0
  70. package/viewer/dist/assets/fillet-rover-wheel-4-view-B-F8flOC.png +0 -0
  71. package/viewer/dist/assets/hull-4view-BPPqJYUz.png +0 -0
  72. package/viewer/dist/assets/hull-base-color-4view-DrQmdT3h.png +0 -0
  73. package/viewer/dist/assets/hull-clay-4view-3Cu-4Hvr.png +0 -0
  74. package/viewer/dist/assets/hull-depth-4view-DCOdT5ev.png +0 -0
  75. package/viewer/dist/assets/hull-normal-4view-CvLaFITy.png +0 -0
  76. package/viewer/dist/assets/inspection-robot-body-4-view-CLMaHFYm.png +0 -0
  77. package/viewer/dist/assets/inspection-robot-wheel-4-view-27wRsxcs.png +0 -0
  78. package/viewer/dist/assets/plastic-barrier-4view-DQkTBW_i.png +0 -0
  79. package/viewer/dist/assets/presets-jXE0t1fU.js +1 -0
  80. package/viewer/dist/assets/preview-cache-BKV0EZl9.js +1 -0
  81. package/viewer/dist/assets/project-BzR9Ensg.css +1 -0
  82. package/viewer/dist/assets/project-DtHHhfo-.js +17 -0
  83. package/viewer/dist/assets/reconstruct.worker-ONc9GyFO.js +21 -0
  84. package/viewer/dist/assets/script-engine-Bs3azDYZ.js +6 -0
  85. package/viewer/dist/assets/style-CMUT8CmM.css +1 -0
  86. package/viewer/dist/assets/style-D6eZHs3D.js +4004 -0
  87. package/viewer/dist/assets/tank-hull-4view-B4sMMkP5.png +0 -0
  88. package/viewer/dist/assets/tank-track-4view-DAIiMTy3.png +0 -0
  89. package/viewer/dist/assets/tank-turret-4view-Cx0FuNFu.png +0 -0
  90. package/viewer/dist/assets/traffic-cone-4view-DG-TkITx.png +0 -0
  91. package/viewer/dist/assets/viewer-DIjS0No7.js +2 -0
  92. package/viewer/dist/assets/wet-floor-sign-4view-CWJDyeTX.png +0 -0
  93. package/viewer/dist/compare.html +47 -0
  94. package/viewer/dist/examples/traffic-cone-4view.png +0 -0
  95. package/viewer/dist/index.html +148 -0
  96. package/viewer/dist/playground/index.html +3342 -0
  97. package/viewer/dist/project.html +83 -0
@@ -0,0 +1,137 @@
1
+ """Orthographic registration in pixel-center coordinates, without resampling source pixels."""
2
+ from pathlib import Path
3
+ import math
4
+
5
+ import cv2
6
+ import numpy as np
7
+ import yaml
8
+ from PIL import Image, ImageDraw
9
+
10
+ AXES = {"top": ("x", "y"), "left": ("y", "z"), "front": ("x", "z"), "rear": ("x", "z")}
11
+ SIGNS = {"top": (1, 1), "left": (-1, -1), "front": (1, -1), "rear": (-1, -1)}
12
+ RED, CYAN, GOLD, GREEN = (205, 38, 58), (0, 152, 177), (241, 139, 0), (41, 155, 81)
13
+
14
+
15
+ def read_manifest(path):
16
+ data = yaml.safe_load(Path(path).read_text(encoding="utf8"))
17
+ if not isinstance(data, dict):
18
+ raise ValueError(f"{path}: expected a YAML mapping")
19
+ return data
20
+
21
+
22
+ def scalar(value, label):
23
+ if isinstance(value, bool) or not isinstance(value, (int, float)) or not math.isfinite(value):
24
+ raise ValueError(f"{label}: expected a finite number")
25
+ return float(value)
26
+
27
+
28
+ def point(value, label):
29
+ if not isinstance(value, list) or len(value) != 2:
30
+ raise ValueError(f"{label}: expected [u, v]")
31
+ return [scalar(v, label) for v in value]
32
+
33
+
34
+ class Panel:
35
+ def __init__(self, view, config, folder, images):
36
+ self.view = view
37
+ self.axes, self.signs = AXES[view], SIGNS[view]
38
+ path = folder / config["image"]
39
+ if path not in images:
40
+ with Image.open(path) as source:
41
+ images[path] = source.convert("RGBA")
42
+ img = images[path]
43
+ if "crop" in config:
44
+ x, y, w, h = config["crop"]
45
+ if any(type(n) is not int for n in (x, y, w, h)) or min(x, y) < 0 or min(w, h) < 1 or x+w > img.width or y+h > img.height:
46
+ raise ValueError(f"{view}: invalid crop [x,y,width,height]")
47
+ img = img.crop((x, y, x+w, y+h))
48
+ pixels = np.asarray(img)
49
+ mode = config.get("mask", "alpha")
50
+ self.mask = pixels[:, :, 3] >= 128
51
+ if mode == "white":
52
+ threshold = scalar(config.get("threshold", 238), "threshold")
53
+ if not 0 <= threshold <= 255:
54
+ raise ValueError("threshold must be in [0,255]")
55
+ self.mask &= pixels[:, :, :3].min(axis=2) < threshold
56
+ elif mode == "alpha" and self.mask.all() and "mask" not in config:
57
+ raise ValueError(f"{view}: opaque panel; choose mask: white or explicitly confirm mask: alpha")
58
+ elif mode != "alpha":
59
+ raise ValueError(f"{view}: mask must be alpha or white")
60
+ if not self.mask.any():
61
+ raise ValueError(f"{view}: empty foreground")
62
+ self.image = Image.new("RGB", img.size, "white")
63
+ self.image.paste(img, mask=img.getchannel("A"))
64
+ self.origin = point(config["origin"], f"{view}.origin") if "origin" in config else None
65
+ self.scale = scalar(config["scale"], f"{view}.scale") if "scale" in config else None
66
+ if self.scale is not None and self.scale <= 0:
67
+ raise ValueError(f"{view}: scale must be positive")
68
+ self.contours = [c[:, 0, :] for c in cv2.findContours(self.mask.astype("uint8"), cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)[0]]
69
+ self.lines = {}
70
+
71
+ def world(self, pixel):
72
+ return {a: (pixel[i] - self.origin[i]) * self.signs[i] / self.scale for i, a in enumerate(self.axes)}
73
+
74
+ def pixel(self, world):
75
+ return [self.origin[i] + world[a] * self.signs[i] * self.scale for i, a in enumerate(self.axes)]
76
+
77
+ def annotation(self, value, label):
78
+ coord = point(value, label)
79
+ if not all(0 <= c < limit for c, limit in zip(coord, self.image.size)):
80
+ raise ValueError(f"{label}: point outside {self.view} panel")
81
+ return coord
82
+
83
+ def intervals(self, axis, constant):
84
+ """All foreground pixel footprints on one scanline, in increasing world coordinates."""
85
+ i = self.axes.index(axis)
86
+ index = math.floor(self.origin[i] + constant*self.scale*self.signs[i] + .5)
87
+ key = (i, index)
88
+ if key not in self.lines:
89
+ result = []
90
+ if 0 <= index < self.image.size[i]:
91
+ line = self.mask[:, index] if i == 0 else self.mask[index, :]
92
+ runs = np.flatnonzero(np.diff(np.pad(line.astype(np.int8), 1))).reshape(-1, 2)
93
+ j = 1-i
94
+ for start, end in runs:
95
+ pair = [((float(n)-.5)-self.origin[j])*self.signs[j]/self.scale for n in (start, end)]
96
+ result.append(sorted(pair))
97
+ self.lines[key] = sorted(result)
98
+ return self.lines[key]
99
+
100
+
101
+ def atlas(path, data=None):
102
+ if data is None:
103
+ data = read_manifest(path)
104
+ configs = data["views"]
105
+ if not isinstance(configs, dict) or set(configs) != set(AXES):
106
+ raise ValueError("views must map top, left, front and rear")
107
+ images = {}
108
+ panels = {v: Panel(v, configs[v], path.parent, images) for v in AXES}
109
+ return data, panels
110
+
111
+
112
+ def unregistered(panels):
113
+ return [v for v, p in panels.items() if p.origin is None or p.scale is None]
114
+
115
+
116
+ def dot(draw, xy, color, radius=4):
117
+ x, y = xy
118
+ draw.ellipse((x-radius, y-radius, x+radius, y+radius), outline=color, width=2)
119
+
120
+
121
+ def sheet(images, title, legend):
122
+ # Keep pixel geometry untouched in each panel; pad cells only.
123
+ width = max(360, max(im.width for im in images.values()) + 16)
124
+ height = max(im.height for im in images.values()) + 32
125
+ result = Image.new("RGB", (2*width, 2*height+54), (235, 238, 241))
126
+ d = ImageDraw.Draw(result)
127
+ d.text((8, 5), title, fill="black")
128
+ d.text((8, 26), legend, fill="black")
129
+ for i, (v, im) in enumerate(images.items()):
130
+ x, y = i%2*width+8, i//2*height+56
131
+ d.text((x, y), v.upper(), fill="black")
132
+ result.paste(im, (x, y+16))
133
+ return result
134
+
135
+
136
+ def canvas(panels):
137
+ return {v: p.image.copy() for v, p in panels.items()}
@@ -0,0 +1,135 @@
1
+ import math
2
+
3
+ import cv2
4
+ import numpy as np
5
+ from PIL import ImageDraw
6
+
7
+ from panels import RED, CYAN, GOLD, canvas, dot, sheet
8
+
9
+
10
+ def gap(intervals):
11
+ """Smallest gap between a simultaneous choice of one interval per row."""
12
+ if any(not row for row in intervals):
13
+ return None
14
+ at = [0]*len(intervals)
15
+ best = math.inf
16
+ while True:
17
+ current = [row[pos] for row, pos in zip(intervals, at)]
18
+ first_end = min(range(len(current)), key=lambda i: current[i][1])
19
+ separation = max(a for a, _ in current) - current[first_end][1]
20
+ if separation <= 1e-9:
21
+ return 0
22
+ best = min(best, separation)
23
+ at[first_end] += 1
24
+ if at[first_end] == len(intervals[first_end]):
25
+ return best
26
+
27
+
28
+ def sample(source, xy, panels, distances):
29
+ world = source.world(xy)
30
+ lines, parallel = {}, []
31
+ missing = next(a for a in "xyz" if a not in world)
32
+ for name, target in panels.items():
33
+ if target is source:
34
+ continue
35
+ if missing not in target.axes:
36
+ u, v = target.pixel(world)
37
+ i, j = math.floor(u+.5), math.floor(v+.5)
38
+ if not (0 <= i < target.image.width and 0 <= j < target.image.height):
39
+ parallel.append(dict(view=name, pixel=[u, v], gapPx=None, reason="outside panel"))
40
+ elif not target.mask[j, i]:
41
+ parallel.append(dict(view=name, pixel=[u, v], gapPx=float(distances[name][j, i])*source.scale/target.scale,
42
+ reason="outside silhouette"))
43
+ else:
44
+ axis = next(a for a in target.axes if a in world)
45
+ lines[name] = dict(axis=axis, coordinate=world[axis], intervals=target.intervals(axis, world[axis]))
46
+ separation = gap([line["intervals"] for line in lines.values()])
47
+ return dict(pixel=xy, missingAxis=missing, scanlines=lines,
48
+ gapPx=None if separation is None else separation*source.scale, opposingView=parallel)
49
+
50
+
51
+ def failed(detail, tolerance):
52
+ return (detail["gapPx"] is None or detail["gapPx"] > tolerance or
53
+ any(p["gapPx"] is None or p["gapPx"] > tolerance for p in detail["opposingView"]))
54
+
55
+
56
+ def severity(detail):
57
+ values = [detail["gapPx"], *(p["gapPx"] for p in detail["opposingView"])]
58
+ return math.inf if None in values else max(values)
59
+
60
+
61
+ def runs(flags):
62
+ """Consecutive failed contour samples, including a run crossing index zero."""
63
+ if all(flags):
64
+ yield list(range(len(flags)))
65
+ return
66
+ start = flags.index(False)
67
+ run = []
68
+ for delta in range(1, len(flags)+1):
69
+ i = (start+delta) % len(flags)
70
+ if flags[i]:
71
+ run.append(i)
72
+ elif run:
73
+ yield run
74
+ run = []
75
+
76
+
77
+ def mark_lines(detail, panels, images):
78
+ for name, line in detail["scanlines"].items():
79
+ panel = panels[name]
80
+ i = panel.axes.index(line["axis"])
81
+ fixed = panel.origin[i]+line["coordinate"]*panel.signs[i]*panel.scale
82
+ def xy(free):
83
+ return (fixed, free) if i == 0 else (free, fixed)
84
+ d = ImageDraw.Draw(images[name])
85
+ d.line([xy(0), xy(panel.image.size[1-i]-1)], fill=GOLD, width=1)
86
+ for start, end in line["intervals"]:
87
+ d.line([xy(panel.origin[1-i]+n*panel.signs[1-i]*panel.scale) for n in (start, end)], fill=CYAN, width=2)
88
+ for other in detail["opposingView"]:
89
+ dot(ImageDraw.Draw(images[other["view"]]), other["pixel"], GOLD)
90
+
91
+
92
+ def projections(panels, tolerance):
93
+ images = canvas(panels)
94
+ distances = {v: cv2.distanceTransform((~p.mask).astype("uint8"), cv2.DIST_L2, cv2.DIST_MASK_PRECISE)
95
+ for v, p in panels.items() if v in ("front", "rear")}
96
+ findings = {}
97
+ selected = None
98
+ for name, p in panels.items():
99
+ groups = []
100
+ failed_count = total = 0
101
+ d = ImageDraw.Draw(images[name])
102
+ for contour_id, contour in enumerate(p.contours):
103
+ details = [sample(p, xy, panels, distances) for xy in contour.tolist()]
104
+ flags = [failed(s, tolerance) for s in details]
105
+ total += len(flags)
106
+ failed_count += sum(flags)
107
+ for run in runs(flags):
108
+ worst = max((details[i] for i in run), key=severity)
109
+ points = [tuple(details[i]["pixel"]) for i in run]
110
+ if len(points) > 1:
111
+ d.line(points, fill=RED, width=3)
112
+ else:
113
+ dot(d, points[0], RED, 2)
114
+ available = [details[i]["gapPx"] for i in run if details[i]["gapPx"] is not None]
115
+ numeric = [severity(details[i]) for i in run if math.isfinite(severity(details[i]))]
116
+ groups.append(dict(minSeparationPx=min(numeric, default=None), contour=contour_id, start=points[0], end=points[-1],
117
+ count=len(run), minScanlineGapPx=min(available, default=None), sample=worst))
118
+ # Prefer an actual finite gap between occupied intervals for the illustration.
119
+ finite_gaps = [details[i] for i in run if (details[i]["gapPx"] or 0) > tolerance]
120
+ illustration = max(finite_gaps, key=lambda row: row["gapPx"]) if finite_gaps else worst
121
+ rank = (bool(finite_gaps), len(run))
122
+ if selected is None or rank > selected[0]:
123
+ selected = (rank, name, illustration)
124
+ findings[name] = dict(boundarySamples=total, unsupportedSamples=failed_count, runs=groups)
125
+ if selected:
126
+ _, name, detail = selected
127
+ mark_lines(detail, panels, images)
128
+ dot(ImageDraw.Draw(images[name]), detail["pixel"], GOLD, 7)
129
+ count = sum(item["boundarySamples"] for item in findings.values())
130
+ unsupported = sum(item["unsupportedSamples"] for item in findings.values())
131
+ return (dict(status="measured", views=findings,
132
+ boundarySamples=count, unsupportedSamples=unsupported, unsupportedFraction=unsupported/count,
133
+ illustrated=None if not selected else dict(view=selected[1], **selected[2])),
134
+ sheet(images, "Silhouette projection consistency",
135
+ "Red: unsupported contour Gold: selected point / scanline Cyan: occupied intervals"))
@@ -0,0 +1,108 @@
1
+ # /// script
2
+ # requires-python = ">=3.11,<3.14"
3
+ # dependencies = ["numpy==2.2.6", "pillow==11.3.0", "opencv-python-headless==4.11.0.86", "pyyaml==6.0.2"]
4
+ # ///
5
+ """Verification entry point shared by the workspace CLI and the packaged executable."""
6
+ import argparse
7
+ import json
8
+ from pathlib import Path
9
+ import sys
10
+
11
+ import yaml
12
+ from assembly import assemble
13
+ from landmarks import landmarks
14
+ from panels import atlas, read_manifest, scalar, unregistered
15
+ from projections import projections
16
+
17
+
18
+ def tolerance(config):
19
+ value = scalar(config.get("tolerancePx", 1), "tolerancePx")
20
+ if value < 0:
21
+ raise ValueError("tolerancePx must be nonnegative")
22
+ return value
23
+
24
+
25
+ def measure_atlas(data, panels, save_overlay, prefix="", check=None):
26
+ tol = tolerance(data)
27
+ missing = unregistered(panels)
28
+ results = {}
29
+ for name in ([check] if check else ["projections", "landmarks"]):
30
+ if name == "landmarks" and not data.get("landmarks"):
31
+ result, image = dict(status="skipped", reason="No annotated landmarks"), None
32
+ elif name == "projections" and missing:
33
+ result, image = dict(status="registration-needed", reason="Missing origin or scale", views=missing), None
34
+ elif name == "projections":
35
+ result, image = projections(panels, tol)
36
+ else:
37
+ result, image = landmarks(panels, data["landmarks"], tol)
38
+ save_overlay(prefix + name, result, image)
39
+ results[name] = result
40
+ return dict(kind="atlas", tolerancePx=tol, results=results)
41
+
42
+
43
+ def run(args):
44
+ path = Path(args.file).resolve()
45
+ config = read_manifest(path)
46
+ kind = config.get("kind")
47
+ if kind is None:
48
+ is_atlas = "views" in config
49
+ is_assembly = "whole" in config and "parts" in config
50
+ if is_atlas == is_assembly:
51
+ raise ValueError("specify kind: atlas or assembly for this manifest")
52
+ kind = "atlas" if is_atlas else "assembly"
53
+ if kind not in ("atlas", "assembly") or (args.kind and kind != args.kind):
54
+ raise ValueError("expected an atlas or assembly manifest matching the requested resource")
55
+
56
+ out = Path(args.output_dir) if args.output_dir else None
57
+ overlays = []
58
+ def save_overlay(name, result, image):
59
+ if out and image is not None:
60
+ out.mkdir(parents=True, exist_ok=True)
61
+ filename = name + ".png"
62
+ image.save(out / filename)
63
+ result["overlay"] = filename
64
+ overlays.append(filename)
65
+
66
+ if kind == "atlas":
67
+ data, panels = atlas(path, config)
68
+ report = measure_atlas(data, panels, save_overlay, check=args.check)
69
+ else:
70
+ parts = config["parts"]
71
+ if not isinstance(parts, dict) or not parts or (args.part and args.part not in parts):
72
+ raise ValueError("expected a manifest with matching named parts")
73
+ whole_data, whole = atlas(path.parent / config["whole"])
74
+ atlases = dict(whole=measure_atlas(whole_data, whole, save_overlay, "whole-"), parts={})
75
+ tol = tolerance(config)
76
+ results = {}
77
+ missing = unregistered(whole)
78
+ for i, (name, spec) in enumerate(parts.items(), start=1):
79
+ if args.part and name != args.part:
80
+ continue
81
+ part_data, local = atlas(path.parent / spec["atlas"])
82
+ atlases["parts"][name] = measure_atlas(part_data, local, save_overlay, f"part-{i}-")
83
+ if missing:
84
+ result, image = dict(status="registration-needed", reason="Missing whole registration", views=missing), None
85
+ else:
86
+ result, image = assemble(whole, local, spec, tol)
87
+ save_overlay(f"assembly-{i}", result, image)
88
+ results[name] = result
89
+ report = dict(kind=kind, tolerancePx=tol, atlases=atlases, results=results)
90
+ if out:
91
+ out.mkdir(parents=True, exist_ok=True)
92
+ report["overlays"] = overlays
93
+ output = json.dumps(report, ensure_ascii=False, indent=2, allow_nan=False)
94
+ if out:
95
+ (out/"report.json").write_text(output+"\n", encoding="utf8")
96
+ print(output)
97
+
98
+
99
+ if __name__ == "__main__":
100
+ parser = argparse.ArgumentParser()
101
+ parser.add_argument("--kind", choices=["atlas", "assembly"])
102
+ parser.add_argument("file")
103
+ for option in ("check","part","output-dir"):
104
+ parser.add_argument("--"+option)
105
+ try:
106
+ run(parser.parse_args())
107
+ except (ValueError, KeyError, TypeError, OSError, yaml.YAMLError) as error:
108
+ sys.exit(f"Invalid verification input: {error}")
@@ -0,0 +1,174 @@
1
+ # Licenses
2
+
3
+ The app bundles dependencies which contain the following licenses:
4
+
5
+ ## @jitl/quickjs-ffi-types - 0.32.0 (MIT)
6
+
7
+ The MIT License
8
+
9
+ quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ ## @jitl/quickjs-wasmfile-release-sync - 0.32.0 (MIT)
30
+
31
+ quickjs-emscripten:
32
+ The MIT License
33
+
34
+ quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis
35
+
36
+ Permission is hereby granted, free of charge, to any person obtaining a copy
37
+ of this software and associated documentation files (the "Software"), to deal
38
+ in the Software without restriction, including without limitation the rights
39
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
40
+ copies of the Software, and to permit persons to whom the Software is
41
+ furnished to do so, subject to the following conditions:
42
+
43
+ The above copyright notice and this permission notice shall be included in all
44
+ copies or substantial portions of the Software.
45
+
46
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
52
+ SOFTWARE.
53
+
54
+
55
+ quickjs:
56
+ QuickJS Javascript Engine
57
+
58
+ Copyright (c) 2017-2021 Fabrice Bellard
59
+ Copyright (c) 2017-2021 Charlie Gordon
60
+
61
+ Permission is hereby granted, free of charge, to any person obtaining a copy
62
+ of this software and associated documentation files (the "Software"), to deal
63
+ in the Software without restriction, including without limitation the rights
64
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
65
+ copies of the Software, and to permit persons to whom the Software is
66
+ furnished to do so, subject to the following conditions:
67
+
68
+ The above copyright notice and this permission notice shall be included in
69
+ all copies or substantial portions of the Software.
70
+
71
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
72
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
73
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
74
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
75
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
76
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
77
+ THE SOFTWARE.
78
+
79
+ ## fflate - 0.8.3 (MIT)
80
+
81
+ MIT License
82
+
83
+ Copyright (c) 2026 Arjun Barrett
84
+
85
+ Permission is hereby granted, free of charge, to any person obtaining a copy
86
+ of this software and associated documentation files (the "Software"), to deal
87
+ in the Software without restriction, including without limitation the rights
88
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
89
+ copies of the Software, and to permit persons to whom the Software is
90
+ furnished to do so, subject to the following conditions:
91
+
92
+ The above copyright notice and this permission notice shall be included in all
93
+ copies or substantial portions of the Software.
94
+
95
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
96
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
97
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
98
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
99
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
100
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
101
+ SOFTWARE.
102
+
103
+ ## quickjs-emscripten-core - 0.32.0 (MIT)
104
+
105
+ The MIT License
106
+
107
+ quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis
108
+
109
+ Permission is hereby granted, free of charge, to any person obtaining a copy
110
+ of this software and associated documentation files (the "Software"), to deal
111
+ in the Software without restriction, including without limitation the rights
112
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
113
+ copies of the Software, and to permit persons to whom the Software is
114
+ furnished to do so, subject to the following conditions:
115
+
116
+ The above copyright notice and this permission notice shall be included in all
117
+ copies or substantial portions of the Software.
118
+
119
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
120
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
121
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
122
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
123
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
124
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
125
+ SOFTWARE.
126
+
127
+ ## simplify-js - 1.2.4 (BSD-2-Clause)
128
+
129
+ Copyright (c) 2017, Vladimir Agafonkin
130
+ All rights reserved.
131
+
132
+ Redistribution and use in source and binary forms, with or without modification, are
133
+ permitted provided that the following conditions are met:
134
+
135
+ 1. Redistributions of source code must retain the above copyright notice, this list of
136
+ conditions and the following disclaimer.
137
+
138
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list
139
+ of conditions and the following disclaimer in the documentation and/or other materials
140
+ provided with the distribution.
141
+
142
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
143
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
144
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
145
+ COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
146
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
147
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
148
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
149
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
150
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
151
+
152
+ ## three - 0.181.2 (MIT)
153
+
154
+ The MIT License
155
+
156
+ Copyright © 2010-2025 three.js authors
157
+
158
+ Permission is hereby granted, free of charge, to any person obtaining a copy
159
+ of this software and associated documentation files (the "Software"), to deal
160
+ in the Software without restriction, including without limitation the rights
161
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
162
+ copies of the Software, and to permit persons to whom the Software is
163
+ furnished to do so, subject to the following conditions:
164
+
165
+ The above copyright notice and this permission notice shall be included in
166
+ all copies or substantial portions of the Software.
167
+
168
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
169
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
170
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
171
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
172
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
173
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
174
+ THE SOFTWARE.
@@ -0,0 +1 @@
1
+ import{C as $,M as J,V as v,Q as ee,B as S,R as se,a as D,S as te,N as ne,b as k,c as ie,I as re,D as oe,P as z,d as ae,e as Y,f as ce,g as ue,h as le,i as fe,L as he,j as pe,k as de,l as xe,m as ye,n as ge,o as Te}from"./style-D6eZHs3D.js";const j={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class H{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new Le(e)}),this.register(function(e){return new _e(e)}),this.register(function(e){return new Oe(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new ze(e)}),this.register(function(e){return new Be(e)}),this.register(function(e){return new Ce(e)}),this.register(function(e){return new Ue(e)}),this.register(function(e){return new Fe(e)}),this.register(function(e){return new De(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new Pe(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new He(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}setTextureUtils(e){return this.textureUtils=e,this}parse(e,s,n,t){const i=new Se,r=[];for(let o=0,c=this.pluginCallbacks.length;o<c;o++)r.push(this.pluginCallbacks[o](i));i.setPlugins(r),i.setTextureUtils(this.textureUtils),i.writeAsync(e,s,t).catch(n)}parseAsync(e,s){const n=this;return new Promise(function(t,i){n.parse(e,t,i,s)})}}const g={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},G="KHR_mesh_quantization",R={};R[ue]=g.NEAREST;R[le]=g.NEAREST_MIPMAP_NEAREST;R[fe]=g.NEAREST_MIPMAP_LINEAR;R[he]=g.LINEAR;R[pe]=g.LINEAR_MIPMAP_NEAREST;R[de]=g.LINEAR_MIPMAP_LINEAR;R[xe]=g.CLAMP_TO_EDGE;R[ye]=g.REPEAT;R[ge]=g.MIRRORED_REPEAT;const K={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},we=new $,q=12,me=1179937895,Me=2,W=8,Ae=1313821514,Ee=5130562;function F(a,e){return a.length===e.length&&a.every(function(s,n){return s===e[n]})}function Ie(a){return new TextEncoder().encode(a).buffer}function Re(a){return F(a.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Ne(a,e,s){const n={min:new Array(a.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(a.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let t=e;t<e+s;t++)for(let i=0;i<a.itemSize;i++){let r;a.itemSize>4?r=a.array[t*a.itemSize+i]:(i===0?r=a.getX(t):i===1?r=a.getY(t):i===2?r=a.getZ(t):i===3&&(r=a.getW(t)),a.normalized===!0&&(r=k.normalize(r,a.array))),n.min[i]=Math.min(n.min[i],r),n.max[i]=Math.max(n.max[i],r)}return n}function Z(a){return Math.ceil(a/4)*4}function P(a,e=0){const s=Z(a.byteLength);if(s!==a.byteLength){const n=new Uint8Array(s);if(n.set(new Uint8Array(a)),e!==0)for(let t=a.byteLength;t<s;t++)n[t]=e;return n.buffer}return a}function X(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function be(a,e){if(typeof OffscreenCanvas<"u"&&a instanceof OffscreenCanvas){let s;return e==="image/jpeg"?s=.92:e==="image/webp"&&(s=.8),a.convertToBlob({type:e,quality:s})}else return new Promise(s=>a.toBlob(s,e))}class Se{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+se}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,s,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);const t=this,i=t.buffers,r=t.json;n=t.options;const o=t.extensionsUsed,c=t.extensionsRequired,l=new Blob(i,{type:"application/octet-stream"}),h=Object.keys(o),u=Object.keys(c);if(h.length>0&&(r.extensionsUsed=h),u.length>0&&(r.extensionsRequired=u),r.buffers&&r.buffers.length>0&&(r.buffers[0].byteLength=l.size),n.binary===!0){const T=new FileReader;T.readAsArrayBuffer(l),T.onloadend=function(){const f=P(T.result),d=new DataView(new ArrayBuffer(W));d.setUint32(0,f.byteLength,!0),d.setUint32(4,Ee,!0);const x=P(Ie(JSON.stringify(r)),32),y=new DataView(new ArrayBuffer(W));y.setUint32(0,x.byteLength,!0),y.setUint32(4,Ae,!0);const M=new ArrayBuffer(q),N=new DataView(M);N.setUint32(0,me,!0),N.setUint32(4,Me,!0);const O=q+y.byteLength+x.byteLength+d.byteLength+f.byteLength;N.setUint32(8,O,!0);const p=new Blob([M,y,x,d,f],{type:"application/octet-stream"}),w=new FileReader;w.readAsArrayBuffer(p),w.onloadend=function(){s(w.result)}}}else if(r.buffers&&r.buffers.length>0){const T=new FileReader;T.readAsDataURL(l),T.onloadend=function(){const f=T.result;r.buffers[0].uri=f,s(r)}}else s(r)}serializeUserData(e,s){if(Object.keys(e.userData).length===0)return;const n=this.options,t=this.extensionsUsed;try{const i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){s.extensions===void 0&&(s.extensions={});for(const r in i.gltfExtensions)s.extensions[r]=i.gltfExtensions[r],t[r]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(s.extras=i)}catch(i){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+i.message)}}getUID(e,s=!1){if(this.uids.has(e)===!1){const t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(s)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new v;for(let t=0,i=e.count;t<i;t++)if(Math.abs(n.fromBufferAttribute(e,t).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const s=this.cache;if(s.attributesNormalized.has(e))return s.attributesNormalized.get(e);const n=e.clone(),t=new v;for(let i=0,r=n.count;i<r;i++)t.fromBufferAttribute(n,i),t.x===0&&t.y===0&&t.z===0?t.setX(1):t.normalize(),n.setXYZ(i,t.x,t.y,t.z);return s.attributesNormalized.set(e,n),n}applyTextureTransform(e,s){let n=!1;const t={};(s.offset.x!==0||s.offset.y!==0)&&(t.offset=s.offset.toArray(),n=!0),s.rotation!==0&&(t.rotation=s.rotation,n=!0),(s.repeat.x!==1||s.repeat.y!==1)&&(t.scale=s.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=t,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(e,s){if(e===s)return e;function n(f){return f.colorSpace===ce?function(x){return x<.04045?x*.0773993808:Math.pow(x*.9478672986+.0521327014,2.4)}:function(x){return x}}e instanceof D&&(e=await this.decompressTextureAsync(e)),s instanceof D&&(s=await this.decompressTextureAsync(s));const t=e?e.image:null,i=s?s.image:null,r=Math.max(t?t.width:0,i?i.width:0),o=Math.max(t?t.height:0,i?i.height:0),c=X();c.width=r,c.height=o;const l=c.getContext("2d",{willReadFrequently:!0});l.fillStyle="#00ffff",l.fillRect(0,0,r,o);const h=l.getImageData(0,0,r,o);if(t){l.drawImage(t,0,0,r,o);const f=n(e),d=l.getImageData(0,0,r,o).data;for(let x=2;x<d.length;x+=4)h.data[x]=f(d[x]/256)*256}if(i){l.drawImage(i,0,0,r,o);const f=n(s),d=l.getImageData(0,0,r,o).data;for(let x=1;x<d.length;x+=4)h.data[x]=f(d[x]/256)*256}l.putImageData(h,0,0);const T=(e||s).clone();return T.source=new te(c),T.colorSpace=ne,T.channel=(e||s).channel,e&&s&&e.channel!==s.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),T}async decompressTextureAsync(e,s=1/0){if(this.textureUtils===null)throw new Error("THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.");return await this.textureUtils.decompress(e,s)}processBuffer(e){const s=this.json,n=this.buffers;return s.buffers||(s.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,s,n,t,i){const r=this.json;r.bufferViews||(r.bufferViews=[]);let o;switch(s){case g.BYTE:case g.UNSIGNED_BYTE:o=1;break;case g.SHORT:case g.UNSIGNED_SHORT:o=2;break;default:o=4}let c=e.itemSize*o;i===g.ARRAY_BUFFER&&(c=Math.ceil(c/4)*4);const l=Z(t*c),h=new DataView(new ArrayBuffer(l));let u=0;for(let d=n;d<n+t;d++){for(let x=0;x<e.itemSize;x++){let y;e.itemSize>4?y=e.array[d*e.itemSize+x]:(x===0?y=e.getX(d):x===1?y=e.getY(d):x===2?y=e.getZ(d):x===3&&(y=e.getW(d)),e.normalized===!0&&(y=k.normalize(y,e.array))),s===g.FLOAT?h.setFloat32(u,y,!0):s===g.INT?h.setInt32(u,y,!0):s===g.UNSIGNED_INT?h.setUint32(u,y,!0):s===g.SHORT?h.setInt16(u,y,!0):s===g.UNSIGNED_SHORT?h.setUint16(u,y,!0):s===g.BYTE?h.setInt8(u,y):s===g.UNSIGNED_BYTE&&h.setUint8(u,y),u+=o}u%c!==0&&(u+=c-u%c)}const T={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:l};return i!==void 0&&(T.target=i),i===g.ARRAY_BUFFER&&(T.byteStride=c),this.byteOffset+=l,r.bufferViews.push(T),{id:r.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const s=this,n=s.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(t){const i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){const r=P(i.result),o={buffer:s.processBuffer(r),byteOffset:s.byteOffset,byteLength:r.byteLength};s.byteOffset+=r.byteLength,t(n.bufferViews.push(o)-1)}})}processAccessor(e,s,n,t){const i=this.json,r={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let o;if(e.array.constructor===Float32Array)o=g.FLOAT;else if(e.array.constructor===Int32Array)o=g.INT;else if(e.array.constructor===Uint32Array)o=g.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=g.SHORT;else if(e.array.constructor===Uint16Array)o=g.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=g.BYTE;else if(e.array.constructor===Uint8Array)o=g.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),(t===void 0||t===1/0)&&(t=e.count),t===0)return null;const c=Ne(e,n,t);let l;s!==void 0&&(l=e===s.index?g.ELEMENT_ARRAY_BUFFER:g.ARRAY_BUFFER);const h=this.processBufferView(e,o,n,t,l),u={bufferView:h.id,byteOffset:h.byteOffset,componentType:o,count:t,max:c.max,min:c.min,type:r[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(u)-1}processImage(e,s,n,t="image/png"){if(e!==null){const i=this,r=i.cache,o=i.json,c=i.options,l=i.pending;r.images.has(e)||r.images.set(e,{});const h=r.images.get(e),u=t+":flipY/"+n.toString();if(h[u]!==void 0)return h[u];o.images||(o.images=[]);const T={mimeType:t},f=X();f.width=Math.min(e.width,c.maxTextureSize),f.height=Math.min(e.height,c.maxTextureSize);const d=f.getContext("2d",{willReadFrequently:!0});if(n===!0&&(d.translate(0,f.height),d.scale(1,-1)),e.data!==void 0){s!==ie&&console.error("GLTFExporter: Only RGBAFormat is supported.",s),(e.width>c.maxTextureSize||e.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const y=new Uint8ClampedArray(e.height*e.width*4);for(let M=0;M<y.length;M+=4)y[M+0]=e.data[M+0],y[M+1]=e.data[M+1],y[M+2]=e.data[M+2],y[M+3]=e.data[M+3];d.putImageData(new ImageData(y,e.width,e.height),0,0)}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)d.drawImage(e,0,0,f.width,f.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");c.binary===!0?l.push(be(f,t).then(y=>i.processBufferViewImage(y)).then(y=>{T.bufferView=y})):T.uri=re.getDataURL(f,t);const x=o.images.push(T)-1;return h[u]=x,x}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const s=this.json;s.samplers||(s.samplers=[]);const n={magFilter:R[e.magFilter],minFilter:R[e.minFilter],wrapS:R[e.wrapS],wrapT:R[e.wrapT]};return s.samplers.push(n)-1}async processTextureAsync(e){const n=this.options,t=this.cache,i=this.json;if(t.textures.has(e))return t.textures.get(e);i.textures||(i.textures=[]),e instanceof D&&(e=await this.decompressTextureAsync(e,n.maxTextureSize));let r=e.userData.mimeType;r==="image/webp"&&(r="image/png");const o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(o.name=e.name),await this._invokeAllAsync(async function(l){l.writeTexture&&await l.writeTexture(e,o)});const c=i.textures.push(o)-1;return t.textures.set(e,c),c}async processMaterialAsync(e){const s=this.cache,n=this.json;if(s.materials.has(e))return s.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const t={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const i=e.color.toArray().concat([e.opacity]);if(F(i,[1,1,1,1])||(t.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(t.pbrMetallicRoughness.metallicFactor=e.metalness,t.pbrMetallicRoughness.roughnessFactor=e.roughness):(t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){const o=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),c={index:await this.processTextureAsync(o),texCoord:o.channel};this.applyTextureTransform(c,o),t.pbrMetallicRoughness.metallicRoughnessTexture=c}if(e.map){const o={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(o,e.map),t.pbrMetallicRoughness.baseColorTexture=o}if(e.emissive){const o=e.emissive;if(Math.max(o.r,o.g,o.b)>0&&(t.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const l={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(l,e.emissiveMap),t.emissiveTexture=l}}if(e.normalMap){const o={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(o.scale=e.normalScale.x),this.applyTextureTransform(o,e.normalMap),t.normalTexture=o}if(e.aoMap){const o={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(o.strength=e.aoMapIntensity),this.applyTextureTransform(o,e.aoMap),t.occlusionTexture=o}e.transparent?t.alphaMode="BLEND":e.alphaTest>0&&(t.alphaMode="MASK",t.alphaCutoff=e.alphaTest),e.side===oe&&(t.doubleSided=!0),e.name!==""&&(t.name=e.name),this.serializeUserData(e,t),await this._invokeAllAsync(async function(o){o.writeMaterialAsync&&await o.writeMaterialAsync(e,t)});const r=n.materials.push(t)-1;return s.materials.set(e,r),r}async processMeshAsync(e){const s=this.cache,n=this.json,t=[e.geometry.uuid];if(Array.isArray(e.material))for(let p=0,w=e.material.length;p<w;p++)t.push(e.material[p].uuid);else t.push(e.material.uuid);const i=t.join(":");if(s.meshes.has(i))return s.meshes.get(i);const r=e.geometry;let o;e.isLineSegments?o=g.LINES:e.isLineLoop?o=g.LINE_LOOP:e.isLine?o=g.LINE_STRIP:e.isPoints?o=g.POINTS:o=e.material.wireframe?g.LINES:g.TRIANGLES;const c={},l={},h=[],u=[],T={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},f=r.getAttribute("normal");f!==void 0&&!this.isNormalizedNormalAttribute(f)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),r.setAttribute("normal",this.createNormalizedNormalAttribute(f)));let d=null;for(let p in r.attributes){if(p.slice(0,5)==="morph")continue;const w=r.attributes[p];if(p=T[p]||p.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(p)||(p="_"+p),s.attributes.has(this.getUID(w))){l[p]=s.attributes.get(this.getUID(w));continue}d=null;const m=w.array;p==="JOINTS_0"&&!(m instanceof Uint16Array)&&!(m instanceof Uint8Array)?(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),d=new S(new Uint16Array(m),w.itemSize,w.normalized)):(m instanceof Uint32Array||m instanceof Int32Array)&&!p.startsWith("_")&&(console.warn(`GLTFExporter: Attribute "${p}" converted to type FLOAT.`),d=H.Utils.toFloat32BufferAttribute(w));const I=this.processAccessor(d||w,r);I!==null&&(p.startsWith("_")||this.detectMeshQuantization(p,w),l[p]=I,s.attributes.set(this.getUID(w),I))}if(f!==void 0&&r.setAttribute("normal",f),Object.keys(l).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const p=[],w=[],A={};if(e.morphTargetDictionary!==void 0)for(const m in e.morphTargetDictionary)A[e.morphTargetDictionary[m]]=m;for(let m=0;m<e.morphTargetInfluences.length;++m){const I={};let V=!1;for(const _ in r.morphAttributes){if(_!=="position"&&_!=="normal"){V||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),V=!0);continue}const b=r.morphAttributes[_][m],B=_.toUpperCase(),C=r.attributes[_];if(s.attributes.has(this.getUID(b,!0))){I[B]=s.attributes.get(this.getUID(b,!0));continue}const U=b.clone();if(!r.morphTargetsRelative)for(let E=0,Q=b.count;E<Q;E++)for(let L=0;L<b.itemSize;L++)L===0&&U.setX(E,b.getX(E)-C.getX(E)),L===1&&U.setY(E,b.getY(E)-C.getY(E)),L===2&&U.setZ(E,b.getZ(E)-C.getZ(E)),L===3&&U.setW(E,b.getW(E)-C.getW(E));I[B]=this.processAccessor(U,r),s.attributes.set(this.getUID(C,!0),I[B])}u.push(I),p.push(e.morphTargetInfluences[m]),e.morphTargetDictionary!==void 0&&w.push(A[m])}c.weights=p,w.length>0&&(c.extras={},c.extras.targetNames=w)}const x=Array.isArray(e.material);if(x&&r.groups.length===0)return null;let y=!1;if(x&&r.index===null){const p=[];for(let w=0,A=r.attributes.position.count;w<A;w++)p[w]=w;r.setIndex(p),y=!0}const M=x?e.material:[e.material],N=x?r.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let p=0,w=N.length;p<w;p++){const A={mode:o,attributes:l};if(this.serializeUserData(r,A),u.length>0&&(A.targets=u),r.index!==null){let I=this.getUID(r.index);(N[p].start!==void 0||N[p].count!==void 0)&&(I+=":"+N[p].start+":"+N[p].count),s.attributes.has(I)?A.indices=s.attributes.get(I):(A.indices=this.processAccessor(r.index,r,N[p].start,N[p].count),s.attributes.set(I,A.indices)),A.indices===null&&delete A.indices}const m=await this.processMaterialAsync(M[N[p].materialIndex]);m!==null&&(A.material=m),h.push(A)}y===!0&&r.setIndex(null),c.primitives=h,n.meshes||(n.meshes=[]),await this._invokeAllAsync(function(p){p.writeMesh&&p.writeMesh(e,c)});const O=n.meshes.push(c)-1;return s.meshes.set(i,O),O}detectMeshQuantization(e,s){if(this.extensionsUsed[G])return;let n;switch(s.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}s.normalized&&(n+=" normalized");const t=e.split("_",1)[0];j[t]&&j[t].includes(n)&&(this.extensionsUsed[G]=!0,this.extensionsRequired[G]=!0)}processCamera(e){const s=this.json;s.cameras||(s.cameras=[]);const n=e.isOrthographicCamera,t={type:n?"orthographic":"perspective"};return n?t.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:t.perspective={aspectRatio:e.aspect,yfov:k.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(t.name=e.type),s.cameras.push(t)-1}processAnimation(e,s){const n=this.json,t=this.nodeMap;n.animations||(n.animations=[]),e=H.Utils.mergeMorphTargetTracks(e.clone(),s);const i=e.tracks,r=[],o=[];for(let l=0;l<i.length;++l){const h=i[l],u=z.parseTrackName(h.name);let T=z.findNode(s,u.nodeName);const f=K[u.propertyName];if(u.objectName==="bones"&&(T.isSkinnedMesh===!0?T=T.skeleton.getBoneByName(u.objectIndex):T=void 0),!T||!f){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',h.name);continue}const d=1;let x=h.values.length/h.times.length;f===K.morphTargetInfluences&&(x/=T.morphTargetInfluences.length);let y;h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(y="CUBICSPLINE",x/=3):h.getInterpolation()===ae?y="STEP":y="LINEAR",o.push({input:this.processAccessor(new S(h.times,d)),output:this.processAccessor(new S(h.values,x)),interpolation:y}),r.push({sampler:o.length-1,target:{node:t.get(T),path:f}})}const c={name:e.name||"clip_"+n.animations.length,samplers:o,channels:r};return this.serializeUserData(e,c),n.animations.push(c),n.animations.length-1}processSkin(e){const s=this.json,n=this.nodeMap,t=s.nodes[n.get(e)],i=e.skeleton;if(i===void 0)return null;const r=e.skeleton.bones[0];if(r===void 0)return null;const o=[],c=new Float32Array(i.bones.length*16),l=new J;for(let u=0;u<i.bones.length;++u)o.push(n.get(i.bones[u])),l.copy(i.boneInverses[u]),l.multiply(e.bindMatrix).toArray(c,u*16);return s.skins===void 0&&(s.skins=[]),s.skins.push({inverseBindMatrices:this.processAccessor(new S(c,16)),joints:o,skeleton:n.get(r)}),t.skin=s.skins.length-1}async processNodeAsync(e){const s=this.json,n=this.options,t=this.nodeMap;s.nodes||(s.nodes=[]);const i={};if(n.trs){const o=e.quaternion.toArray(),c=e.position.toArray(),l=e.scale.toArray();F(o,[0,0,0,1])||(i.rotation=o),F(c,[0,0,0])||(i.translation=c),F(l,[1,1,1])||(i.scale=l)}else e.matrixAutoUpdate&&e.updateMatrix(),Re(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==""&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){const o=await this.processMeshAsync(e);o!==null&&(i.mesh=o)}else e.isCamera&&(i.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);const r=s.nodes.push(i)-1;if(t.set(e,r),e.children.length>0){const o=[];for(let c=0,l=e.children.length;c<l;c++){const h=e.children[c];if(h.visible||n.onlyVisible===!1){const u=await this.processNodeAsync(h);u!==null&&o.push(u)}}o.length>0&&(i.children=o)}return await this._invokeAllAsync(function(o){o.writeNode&&o.writeNode(e,i)}),r}async processSceneAsync(e){const s=this.json,n=this.options;s.scenes||(s.scenes=[],s.scene=0);const t={};e.name!==""&&(t.name=e.name),s.scenes.push(t);const i=[];for(let r=0,o=e.children.length;r<o;r++){const c=e.children[r];if(c.visible||n.onlyVisible===!1){const l=await this.processNodeAsync(c);l!==null&&i.push(l)}}i.length>0&&(t.nodes=i),this.serializeUserData(e,t)}async processObjectsAsync(e){const s=new Y;s.name="AuxScene";for(let n=0;n<e.length;n++)s.children.push(e[n]);await this.processSceneAsync(s)}async processInputAsync(e){const s=this.options;e=e instanceof Array?e:[e],await this._invokeAllAsync(function(t){t.beforeParse&&t.beforeParse(e)});const n=[];for(let t=0;t<e.length;t++)e[t]instanceof Y?await this.processSceneAsync(e[t]):n.push(e[t]);n.length>0&&await this.processObjectsAsync(n);for(let t=0;t<this.skins.length;++t)this.processSkin(this.skins[t]);for(let t=0;t<s.animations.length;++t)this.processAnimation(s.animations[t],e[0]);await this._invokeAllAsync(function(t){t.afterParse&&t.afterParse(e)})}async _invokeAllAsync(e){for(let s=0,n=this.plugins.length;s<n;s++)await e(this.plugins[s])}}class Le{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,s){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}const n=this.writer,t=n.json,i=n.extensionsUsed,r={};e.name&&(r.name=e.name),r.color=e.color.toArray(),r.intensity=e.intensity,e.isDirectionalLight?r.type="directional":e.isPointLight?(r.type="point",e.distance>0&&(r.range=e.distance)):e.isSpotLight&&(r.type="spot",e.distance>0&&(r.range=e.distance),r.spot={},r.spot.innerConeAngle=(1-e.penumbra)*e.angle,r.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),i[this.name]||(t.extensions=t.extensions||{},t.extensions[this.name]={lights:[]},i[this.name]=!0);const o=t.extensions[this.name].lights;o.push(r),s.extensions=s.extensions||{},s.extensions[this.name]={light:o.length-1}}}class _e{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,s){if(!e.isMeshBasicMaterial)return;const t=this.writer.extensionsUsed;s.extensions=s.extensions||{},s.extensions[this.name]={},t[this.name]=!0,s.pbrMetallicRoughness.metallicFactor=0,s.pbrMetallicRoughness.roughnessFactor=.9}}class Ce{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const n=this.writer,t=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){const r={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(r,e.clearcoatMap),i.clearcoatTexture=r}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const r={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(r,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=r}if(e.clearcoatNormalMap){const r={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(r.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(r,e.clearcoatNormalMap),i.clearcoatNormalTexture=r}s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class Ue{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;const t=this.writer.extensionsUsed,i={};i.dispersion=e.dispersion,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class Fe{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const n=this.writer,t=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){const r={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(r,e.iridescenceMap),i.iridescenceTexture=r}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const r={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(r,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=r}s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class Oe{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,t=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){const r={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(r,e.transmissionMap),i.transmissionTexture=r}s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class ve{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,t=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){const r={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(r,e.thicknessMap),i.thicknessTexture=r}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class ze{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const t=this.writer.extensionsUsed,i={};i.ior=e.ior,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class Be{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(we)&&!e.specularIntensityMap&&!e.specularColorMap)return;const n=this.writer,t=n.extensionsUsed,i={};if(e.specularIntensityMap){const r={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(r,e.specularIntensityMap),i.specularTexture=r}if(e.specularColorMap){const r={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(r,e.specularColorMap),i.specularColorTexture=r}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class De{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const n=this.writer,t=n.extensionsUsed,i={};if(e.sheenRoughnessMap){const r={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(r,e.sheenRoughnessMap),i.sheenRoughnessTexture=r}if(e.sheenColorMap){const r={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(r,e.sheenColorMap),i.sheenColorTexture=r}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class Ge{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const n=this.writer,t=n.extensionsUsed,i={};if(e.anisotropyMap){const r={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(r,e.anisotropyMap),i.anisotropyTexture=r}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class Pe{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,s){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const t=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class ke{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,s){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const n=this.writer,t=n.extensionsUsed,i={};if(e.bumpMap){const r={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(r,e.bumpMap),i.bumpTexture=r}i.bumpFactor=e.bumpScale,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class He{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,s){if(!e.isInstancedMesh)return;const n=this.writer,t=e,i=new Float32Array(t.count*3),r=new Float32Array(t.count*4),o=new Float32Array(t.count*3),c=new J,l=new v,h=new ee,u=new v;for(let f=0;f<t.count;f++)t.getMatrixAt(f,c),c.decompose(l,h,u),l.toArray(i,f*3),h.toArray(r,f*4),u.toArray(o,f*3);const T={TRANSLATION:n.processAccessor(new S(i,3)),ROTATION:n.processAccessor(new S(r,4)),SCALE:n.processAccessor(new S(o,3))};t.instanceColor&&(T._COLOR_0=n.processAccessor(t.instanceColor)),s.extensions=s.extensions||{},s.extensions[this.name]={attributes:T},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}}H.Utils={insertKeyframe:function(a,e){const n=a.getValueSize(),t=new a.TimeBufferType(a.times.length+1),i=new a.ValueBufferType(a.values.length+n),r=a.createInterpolant(new a.ValueBufferType(n));let o;if(a.times.length===0){t[0]=e;for(let c=0;c<n;c++)i[c]=0;o=0}else if(e<a.times[0]){if(Math.abs(a.times[0]-e)<.001)return 0;t[0]=e,t.set(a.times,1),i.set(r.evaluate(e),0),i.set(a.values,n),o=0}else if(e>a.times[a.times.length-1]){if(Math.abs(a.times[a.times.length-1]-e)<.001)return a.times.length-1;t[t.length-1]=e,t.set(a.times,0),i.set(a.values,0),i.set(r.evaluate(e),a.values.length),o=t.length-1}else for(let c=0;c<a.times.length;c++){if(Math.abs(a.times[c]-e)<.001)return c;if(a.times[c]<e&&a.times[c+1]>e){t.set(a.times.slice(0,c+1),0),t[c+1]=e,t.set(a.times.slice(c+1),c+2),i.set(a.values.slice(0,(c+1)*n),0),i.set(r.evaluate(e),(c+1)*n),i.set(a.values.slice((c+1)*n),(c+2)*n),o=c+1;break}}return a.times=t,a.values=i,o},mergeMorphTargetTracks:function(a,e){const s=[],n={},t=a.tracks;for(let i=0;i<t.length;++i){let r=t[i];const o=z.parseTrackName(r.name),c=z.findNode(e,o.nodeName);if(o.propertyName!=="morphTargetInfluences"||o.propertyIndex===void 0){s.push(r);continue}if(r.createInterpolant!==r.InterpolantFactoryMethodDiscrete&&r.createInterpolant!==r.InterpolantFactoryMethodLinear){if(r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),r=r.clone(),r.setInterpolation(Te)}const l=c.morphTargetInfluences.length,h=c.morphTargetDictionary[o.propertyIndex];if(h===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let u;if(n[c.uuid]===void 0){u=r.clone();const f=new u.ValueBufferType(l*u.times.length);for(let d=0;d<u.times.length;d++)f[d*l+h]=u.values[d];u.name=(o.nodeName||"")+".morphTargetInfluences",u.values=f,n[c.uuid]=u,s.push(u);continue}const T=r.createInterpolant(new r.ValueBufferType(1));u=n[c.uuid];for(let f=0;f<u.times.length;f++)u.values[f*l+h]=T.evaluate(u.times[f]);for(let f=0;f<r.times.length;f++){const d=this.insertKeyframe(u,r.times[f]);u.values[d*l+h]=r.values[f]}}return a.tracks=s,a},toFloat32BufferAttribute:function(a){const e=new S(new Float32Array(a.count*a.itemSize),a.itemSize,!1);if(!a.normalized&&!a.isInterleavedBufferAttribute)return e.array.set(a.array),e;for(let s=0,n=a.count;s<n;s++)for(let t=0;t<a.itemSize;t++)e.setComponent(s,t,a.getComponent(s,t));return e}};export{H as GLTFExporter};
@@ -0,0 +1 @@
1
+ .comparison{display:block}.compare-controls{display:flex;flex-wrap:wrap;align-items:end;gap:10px 16px;margin-bottom:14px}.compare-controls>div{min-width:105px}.compare-controls>div:has(input[type=file]){width:190px}.compare-controls>div:has(input[type=range]){flex:0 1 105px}.compare-controls input[type=range]{min-height:36px}.compare-actions{display:flex;gap:6px}.compare-results{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.compare-results section{min-width:0;overflow:hidden;background:var(--surface);border:1px solid var(--border);border-radius:7px}.compare-results h2,.compare-results p{padding:9px 11px;margin:0}.compare-results p{color:var(--muted);font-size:13px}.compare-results figure{min-width:0;margin:0}.model{display:block;width:100%;height:auto;aspect-ratio:4 / 3;background:#121923}.compare-results figcaption{padding:7px 10px;overflow-wrap:anywhere;font-size:12px}.compare-results small{display:block;margin-top:3px;color:var(--muted);font-variant-numeric:tabular-nums}#comparison-status{display:block;margin-bottom:12px}#comparison-status[data-error=true]{color:#ffbfa6}#comparison-warnings{color:#f3c778;margin-bottom:12px}#comparison-warnings:empty{display:none}@media(min-width:825px){.compare-controls{position:sticky;top:0;z-index:1;padding-bottom:8px;background:#151b22}}@media(max-width:910px){.compare-results{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:570px){.compare-results{grid-template-columns:1fr}}.depth-fit>strong{display:block;padding:12px 11px 0;font-size:26px;font-variant-numeric:tabular-nums}.depth-fit table{width:calc(100% - 22px);margin:7px 11px;border-collapse:collapse;font-size:13px}.depth-fit th,.depth-fit td{border-bottom:1px solid var(--border);padding:6px 4px;text-align:right;font-variant-numeric:tabular-nums}.depth-fit th:first-child,.depth-fit td:first-child{text-align:left}