vibedgames 0.10.1 → 0.10.2
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/assets/rebuild-object/.cache/spec-search/core_3d.json +1 -0
- package/assets/rebuild-object/.cache/spec-search/cs2.json +1 -0
- package/assets/rebuild-object/LICENSE +201 -0
- package/assets/rebuild-object/NOTICE +7 -0
- package/assets/rebuild-object/docs/materials/material-reference.json +2324 -0
- package/assets/rebuild-object/docs/specs/render-profile.v2.example.json +63 -0
- package/assets/rebuild-object/docs/specs/render-profile.v2.schema.json +56 -0
- package/assets/rebuild-object/docs/specs/vocabulary/README.md +86 -0
- package/assets/rebuild-object/docs/specs/vocabulary/core_3d.jsonl +12 -0
- package/assets/rebuild-object/docs/specs/vocabulary/core_3d_reconstruction.jsonl +37 -0
- package/assets/rebuild-object/docs/specs/vocabulary/cs2.jsonl +8 -0
- package/assets/rebuild-object/docs/specs/vocabulary/cs2_reconstruction.jsonl +62 -0
- package/assets/rebuild-object/forge/_shared/artifact_cache.py +54 -0
- package/assets/rebuild-object/forge/_shared/chirality.py +272 -0
- package/assets/rebuild-object/forge/_shared/color_metrics.py +107 -0
- package/assets/rebuild-object/forge/_shared/feature_acceptance_policy.py +113 -0
- package/assets/rebuild-object/forge/_shared/image_hash.py +113 -0
- package/assets/rebuild-object/forge/_shared/jpeg.py +448 -0
- package/assets/rebuild-object/forge/_shared/material_physics.py +253 -0
- package/assets/rebuild-object/forge/_shared/pipeline_routing.py +177 -0
- package/assets/rebuild-object/forge/_shared/scalp_field.py +302 -0
- package/assets/rebuild-object/forge/_shared/sdf_primitives.py +172 -0
- package/assets/rebuild-object/forge/_shared/spec_search.py +1792 -0
- package/assets/rebuild-object/forge/_shared/spec_search_profiles.json +58 -0
- package/assets/rebuild-object/forge/_shared/status_banner.py +35 -0
- package/assets/rebuild-object/forge/_shared/subdivision.py +232 -0
- package/assets/rebuild-object/forge/_shared/vertex_paint.py +236 -0
- package/assets/rebuild-object/forge/_shared/workflow_state.py +406 -0
- package/assets/rebuild-object/forge/materials/__init__.py +17 -0
- package/assets/rebuild-object/forge/materials/compatibility.py +106 -0
- package/assets/rebuild-object/forge/materials/reference.py +240 -0
- package/assets/rebuild-object/forge/next.py +116 -0
- package/assets/rebuild-object/forge/report.py +38 -0
- package/assets/rebuild-object/forge/requirements.txt +6 -0
- package/assets/rebuild-object/forge/stage1_intake/analyze_texture.py +255 -0
- package/assets/rebuild-object/forge/stage1_intake/bind_detail_properties.py +99 -0
- package/assets/rebuild-object/forge/stage1_intake/build_detail_inventory.py +349 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_fitting_math.py +133 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_fitting_solver.py +197 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_fitting_types.py +291 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_image_helpers.py +133 -0
- package/assets/rebuild-object/forge/stage1_intake/check_intake_correctness.py +116 -0
- package/assets/rebuild-object/forge/stage1_intake/check_reference_admission.py +203 -0
- package/assets/rebuild-object/forge/stage1_intake/cs2_foundation.py +139 -0
- package/assets/rebuild-object/forge/stage1_intake/cs2_manifest.py +230 -0
- package/assets/rebuild-object/forge/stage1_intake/cs2_review_contract.py +42 -0
- package/assets/rebuild-object/forge/stage1_intake/delight_albedo.py +352 -0
- package/assets/rebuild-object/forge/stage1_intake/detect_cs2.py +276 -0
- package/assets/rebuild-object/forge/stage1_intake/detect_reference_effects.py +275 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_cs2_textures.py +126 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_gradient_stops.py +149 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_hair_evidence.py +385 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_landmarks.py +456 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_part_color_recipe.py +496 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_pbr_evidence.py +843 -0
- package/assets/rebuild-object/forge/stage1_intake/fetch_cs2_metadata.py +147 -0
- package/assets/rebuild-object/forge/stage1_intake/label_glb_nodes.py +318 -0
- package/assets/rebuild-object/forge/stage1_intake/locate_cs2_vpk.py +73 -0
- package/assets/rebuild-object/forge/stage1_intake/material_region_analysis.py +227 -0
- package/assets/rebuild-object/forge/stage1_intake/probe_glb.py +357 -0
- package/assets/rebuild-object/forge/stage1_intake/probe_image.py +168 -0
- package/assets/rebuild-object/forge/stage1_intake/run_vision_adapter.py +45 -0
- package/assets/rebuild-object/forge/stage1_intake/search_specs.py +258 -0
- package/assets/rebuild-object/forge/stage1_intake/semantic_decomposition.py +119 -0
- package/assets/rebuild-object/forge/stage1_intake/solve_camera_pose.py +254 -0
- package/assets/rebuild-object/forge/stage2_spec/apply_material_analysis.py +192 -0
- package/assets/rebuild-object/forge/stage2_spec/cs2_adapters.py +62 -0
- package/assets/rebuild-object/forge/stage2_spec/derive_geometry.py +118 -0
- package/assets/rebuild-object/forge/stage2_spec/hair_profile.py +306 -0
- package/assets/rebuild-object/forge/stage2_spec/humanoid_proportions.py +214 -0
- package/assets/rebuild-object/forge/stage2_spec/new_pre_spec_assessment.py +343 -0
- package/assets/rebuild-object/forge/stage2_spec/new_sculpt_spec.py +2396 -0
- package/assets/rebuild-object/forge/stage2_spec/validate_sculpt_spec.py +2871 -0
- package/assets/rebuild-object/forge/stage3_build/bake_projected_texture.py +181 -0
- package/assets/rebuild-object/forge/stage3_build/decimate.py +272 -0
- package/assets/rebuild-object/forge/stage3_build/generate_threejs_factory.py +4099 -0
- package/assets/rebuild-object/forge/stage3_build/module_cache.py +155 -0
- package/assets/rebuild-object/forge/stage3_build/morph_targets.py +178 -0
- package/assets/rebuild-object/forge/stage3_build/orchestrate_passes.py +653 -0
- package/assets/rebuild-object/forge/stage3_build/uv_unwrap.py +622 -0
- package/assets/rebuild-object/forge/stage3_build/visual_hull.py +357 -0
- package/assets/rebuild-object/forge/stage4_review/_fit_divine_eye.py +64 -0
- package/assets/rebuild-object/forge/stage4_review/append_review.py +453 -0
- package/assets/rebuild-object/forge/stage4_review/attachment_anchor.py +349 -0
- package/assets/rebuild-object/forge/stage4_review/calibrate_eye.py +131 -0
- package/assets/rebuild-object/forge/stage4_review/check_part_coverage.py +298 -0
- package/assets/rebuild-object/forge/stage4_review/compare_region_passes.py +169 -0
- package/assets/rebuild-object/forge/stage4_review/correction_loop.py +258 -0
- package/assets/rebuild-object/forge/stage4_review/cs2_review.py +224 -0
- package/assets/rebuild-object/forge/stage4_review/diagnose_render.py +356 -0
- package/assets/rebuild-object/forge/stage4_review/diagnose_render_multi_angle.py +143 -0
- package/assets/rebuild-object/forge/stage4_review/divine_eye.py +461 -0
- package/assets/rebuild-object/forge/stage4_review/fit_params.py +381 -0
- package/assets/rebuild-object/forge/stage4_review/geometry_integrity.py +294 -0
- package/assets/rebuild-object/forge/stage4_review/hair_gate.py +216 -0
- package/assets/rebuild-object/forge/stage4_review/interior_difference.py +188 -0
- package/assets/rebuild-object/forge/stage4_review/joint_loops.py +209 -0
- package/assets/rebuild-object/forge/stage4_review/make_comparison_sheet.py +292 -0
- package/assets/rebuild-object/forge/stage4_review/material_comparator.py +181 -0
- package/assets/rebuild-object/forge/stage4_review/material_feedback.py +143 -0
- package/assets/rebuild-object/forge/stage4_review/material_gate.py +126 -0
- package/assets/rebuild-object/forge/stage4_review/material_views.py +184 -0
- package/assets/rebuild-object/forge/stage4_review/mesh_reference_compare.py +362 -0
- package/assets/rebuild-object/forge/stage4_review/multi_pass.py +102 -0
- package/assets/rebuild-object/forge/stage4_review/objectness.py +143 -0
- package/assets/rebuild-object/forge/stage4_review/pairwise_penetration.py +376 -0
- package/assets/rebuild-object/forge/stage4_review/per_feature.py +215 -0
- package/assets/rebuild-object/forge/stage4_review/render_bridge.py +556 -0
- package/assets/rebuild-object/forge/stage4_review/scalp_exposure.py +257 -0
- package/assets/rebuild-object/forge/stage4_review/self_intersection.py +592 -0
- package/assets/rebuild-object/forge/stage4_review/swept_arc_gate.py +336 -0
- package/assets/rebuild-object/forge/stage4_review/turntable_gate.py +415 -0
- package/assets/rebuild-object/forge/stage4_review/validate_render_profile.py +182 -0
- package/assets/rebuild-object/forge/stage4_review/vertex_region_gate.py +456 -0
- package/assets/rebuild-object/forge/stage4_review/vlm_gate.py +196 -0
- package/assets/rebuild-object/forge/stage5_rig/NOTES.md +149 -0
- package/assets/rebuild-object/forge/stage5_rig/__init__.py +6 -0
- package/assets/rebuild-object/forge/stage5_rig/emit_rig.py +420 -0
- package/assets/rebuild-object/forge/stage5_rig/geodesic_skinning.py +508 -0
- package/assets/rebuild-object/forge/stage5_rig/rig_spec.py +174 -0
- package/assets/rebuild-object/forge/stage5_rig/validate_rig_payload.py +195 -0
- package/assets/rebuild-object/forge/state.py +98 -0
- package/assets/rebuild-object/steps.json +381 -0
- package/dist/{chunk-FB3UDZAV.js → chunk-24TITAFS.js} +1 -1
- package/dist/{chunk-QNWCBPVO.js → chunk-2C5PG2QO.js} +1 -1
- package/dist/{chunk-4RYTTD4D.js → chunk-2DEVOKI7.js} +1 -1
- package/dist/{chunk-RRI23NK2.js → chunk-2GHPYT2P.js} +1 -1
- package/dist/{chunk-QEKVZ7BX.js → chunk-2HXGMXGC.js} +1 -1
- package/dist/{chunk-N2UHAQXC.js → chunk-36FORP7T.js} +0 -1
- package/dist/{chunk-DH6WPL3X.js → chunk-3IXRQTRF.js} +1 -1
- package/dist/{chunk-SXYQL4GK.js → chunk-4YHA32OE.js} +1 -1
- package/dist/{chunk-V5ADM3WC.js → chunk-4ZGQKPK5.js} +1 -1
- package/dist/{chunk-BJAN3RMY.js → chunk-6CLUPFQA.js} +1 -1
- package/dist/{chunk-52E6EKZV.js → chunk-7WTF2BA4.js} +1 -1
- package/dist/{chunk-P74GTK23.js → chunk-AAXZNK4Z.js} +1 -1
- package/dist/{chunk-F4J6XCHT.js → chunk-ALLBT4FB.js} +1 -1
- package/dist/{chunk-HRKVAXNN.js → chunk-BAZDPPIG.js} +5 -5
- package/dist/{chunk-RPJR3S5S.js → chunk-CYDENLZ4.js} +5 -8
- package/dist/{chunk-I5LELJSK.js → chunk-DKSUD44G.js} +1 -1
- package/dist/{chunk-43P4U7CB.js → chunk-DWWSJKTE.js} +1 -1
- package/dist/{chunk-6IUFHPMV.js → chunk-E72TFJZP.js} +1 -1
- package/dist/{chunk-E3FJUPLT.js → chunk-EUAAQMUA.js} +2 -0
- package/dist/{chunk-37LLKM73.js → chunk-F7LYJSZE.js} +1 -1
- package/dist/{chunk-MEAO33XW.js → chunk-FMON3C74.js} +8 -8
- package/dist/{chunk-YLUB6252.js → chunk-FPILHRLZ.js} +1 -1
- package/dist/{chunk-4UU622RK.js → chunk-GGO6ZYYI.js} +1 -3
- package/dist/{chunk-2ZKS7V72.js → chunk-GZCRYYS6.js} +5 -5
- package/dist/{chunk-E7NDOZ27.js → chunk-LE4GVTYI.js} +8 -8
- package/dist/{chunk-UTSSDFQL.js → chunk-NO6KPV64.js} +1 -1
- package/dist/{chunk-W2QPNAZ3.js → chunk-NXW3Z4Y4.js} +1 -1
- package/dist/{chunk-NG2X3SMF.js → chunk-OHOAZGO4.js} +1 -1
- package/dist/chunk-PYJNI5WD.js +83 -0
- package/dist/{chunk-VUV5U4J5.js → chunk-Q4XAGTFX.js} +1 -1
- package/dist/{chunk-3UGGMFJJ.js → chunk-QMZBSVKF.js} +1 -1
- package/dist/{chunk-ABTUEIRC.js → chunk-QO66UBOS.js} +2 -2
- package/dist/{chunk-LONQWRTR.js → chunk-S4KVGQQO.js} +8 -8
- package/dist/{chunk-FJXPMA63.js → chunk-T777EXAO.js} +1 -1
- package/dist/{chunk-YXOGRERG.js → chunk-TZZNRA3S.js} +1 -1
- package/dist/{chunk-CTY2WZQK.js → chunk-UC3QLWMQ.js} +1 -1
- package/dist/{chunk-MR5KIFI7.js → chunk-UDJH2RED.js} +3 -3
- package/dist/{chunk-FNJL6Z5C.js → chunk-UIKYK7KI.js} +1 -1
- package/dist/{chunk-PKM3JOKQ.js → chunk-UJRSQO2B.js} +1 -1
- package/dist/{chunk-ALPTHSUT.js → chunk-V7LEYVXB.js} +28 -24
- package/dist/{chunk-DPLFCKXP.js → chunk-WRMQEXUC.js} +1 -1
- package/dist/{chunk-HSMG6U7J.js → chunk-WXSBNC67.js} +3 -9
- package/dist/{chunk-HSCTPDEU.js → chunk-X4QIOXNQ.js} +1 -1
- package/dist/{chunk-72KHWZMN.js → chunk-Y6WHUK2O.js} +1 -1
- package/dist/{chunk-VZEJ2ZHE.js → chunk-Z3E7ORGQ.js} +5 -5
- package/dist/index.js +20 -20
- package/package.json +32 -22
- package/dist/{chunk-OFJIG4K3.js → chunk-4ENHS32B.js} +0 -0
- package/dist/{chunk-Q3XQPNF6.js → chunk-BN7TR6OR.js} +3 -3
- package/dist/{chunk-LORGE2NB.js → chunk-U2NCN5RO.js} +3 -3
- package/dist/{chunk-UPHB5HWO.js → chunk-VQTTSPA3.js} +3 -3
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Assembly gate: does the BUILT model actually contain the parts the spec promised?
|
|
3
|
+
|
|
4
|
+
Every other gate in this pipeline scores pixels. This one scores the part tree, because a
|
|
5
|
+
reconstruction can pass every silhouette and colour gate while being one fused mesh wearing a
|
|
6
|
+
photograph — and because a component that was specified and then quietly never built leaves no
|
|
7
|
+
trace in a render the reviewer is looking at from the reference angle.
|
|
8
|
+
|
|
9
|
+
Three independent checks:
|
|
10
|
+
|
|
11
|
+
A. componentTree -> model every specified component exists as a named, selectable part;
|
|
12
|
+
no two components collapse onto the same part (fused)
|
|
13
|
+
B. detailInventory -> spec every inventoried detail still resolves to a component or
|
|
14
|
+
material field (`mapsTo`), so an observed feature cannot be
|
|
15
|
+
dropped silently between intake and spec
|
|
16
|
+
C. model hygiene meshes that belong to no named part cannot be selected or
|
|
17
|
+
exploded, so they are reported with a count
|
|
18
|
+
|
|
19
|
+
WHAT THIS CANNOT DO: it compares the model against the spec, and the spec against the detail
|
|
20
|
+
inventory. It cannot invent domain knowledge that intake never captured. A Glock-18 whose fire
|
|
21
|
+
selector was never observed, never inventoried and never specified will pass every check here.
|
|
22
|
+
Closing that gap is the job of the detail inventory and the family adapter, not of this script.
|
|
23
|
+
|
|
24
|
+
Usage:
|
|
25
|
+
check_part_coverage.py --spec object-sculpt-spec.json --manifest parts.json
|
|
26
|
+
check_part_coverage.py --spec spec.json --manifest parts.json --json coverage.json
|
|
27
|
+
check_part_coverage.py --spec spec.json --manifest parts.json --require fire-selector,rear-sight
|
|
28
|
+
|
|
29
|
+
The manifest is a runtime dump of the built part tree, produced by the viewer:
|
|
30
|
+
|
|
31
|
+
{
|
|
32
|
+
"model": "glock-ghost-protocol",
|
|
33
|
+
"parts": [{"name": "slide", "kind": "part", "module": "slide", "triangles": 18588}],
|
|
34
|
+
"unnamedMeshes": 0,
|
|
35
|
+
"integralMeshes": 61
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Exit code 1 when any error-severity finding survives (use --warn-only to always exit 0).
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
from __future__ import annotations
|
|
42
|
+
|
|
43
|
+
import argparse
|
|
44
|
+
import json
|
|
45
|
+
import re
|
|
46
|
+
import sys
|
|
47
|
+
from pathlib import Path
|
|
48
|
+
from typing import Any
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def norm(text: str) -> str:
|
|
52
|
+
"""Fold naming conventions together: 'rear-sight', 'rearSight', 'Rear Sight' -> 'rearsight'."""
|
|
53
|
+
return re.sub(r"[^a-z0-9]", "", str(text).lower())
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def load(path: str) -> Any:
|
|
57
|
+
try:
|
|
58
|
+
return json.loads(Path(path).read_text(encoding="utf-8"))
|
|
59
|
+
except FileNotFoundError:
|
|
60
|
+
sys.exit(f"check_part_coverage: no such file: {path}")
|
|
61
|
+
except json.JSONDecodeError as exc:
|
|
62
|
+
sys.exit(f"check_part_coverage: {path} is not valid JSON: {exc}")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def severity_for(component: dict[str, Any]) -> str:
|
|
66
|
+
"""A macro component or an explicitly important one is a build failure when absent.
|
|
67
|
+
|
|
68
|
+
Micro detail is a warning: it is often legitimately folded into a parent's relief rather
|
|
69
|
+
than built as a separate mesh, and failing the build for that would punish the correct
|
|
70
|
+
choice.
|
|
71
|
+
"""
|
|
72
|
+
importance = component.get("importance")
|
|
73
|
+
if isinstance(importance, (int, float)):
|
|
74
|
+
return "error" if importance >= 0.7 else "warning"
|
|
75
|
+
return "error" if component.get("level", "meso") in {"macro", "meso"} else "warning"
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def collect_local_feature_keys(spec: dict[str, Any]) -> set[str]:
|
|
79
|
+
keys: set[str] = set()
|
|
80
|
+
for component in spec.get("componentTree", []):
|
|
81
|
+
if not isinstance(component, dict):
|
|
82
|
+
continue
|
|
83
|
+
for field in ("id", "name"):
|
|
84
|
+
if component.get(field):
|
|
85
|
+
keys.add(norm(component[field]))
|
|
86
|
+
for feature in component.get("localFeatures", []) or []:
|
|
87
|
+
if isinstance(feature, dict):
|
|
88
|
+
for field in ("id", "name", "feature"):
|
|
89
|
+
if feature.get(field):
|
|
90
|
+
keys.add(norm(feature[field]))
|
|
91
|
+
elif isinstance(feature, str):
|
|
92
|
+
keys.add(norm(feature))
|
|
93
|
+
for material in spec.get("materials", []) or []:
|
|
94
|
+
if not isinstance(material, dict):
|
|
95
|
+
continue
|
|
96
|
+
for override in material.get("localOverrides", []) or []:
|
|
97
|
+
if isinstance(override, dict):
|
|
98
|
+
for field in ("id", "name", "region"):
|
|
99
|
+
if override.get(field):
|
|
100
|
+
keys.add(norm(override[field]))
|
|
101
|
+
elif isinstance(override, str):
|
|
102
|
+
keys.add(norm(override))
|
|
103
|
+
return keys
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def find_inventory(spec: dict[str, Any], inventory_arg: str | None) -> list[dict[str, Any]]:
|
|
107
|
+
if inventory_arg:
|
|
108
|
+
blob = load(inventory_arg)
|
|
109
|
+
else:
|
|
110
|
+
blob = spec.get("preSpecAssessment", {}) or {}
|
|
111
|
+
entries = blob.get("detailInventory")
|
|
112
|
+
if isinstance(entries, dict):
|
|
113
|
+
entries = entries.get("details")
|
|
114
|
+
return [e for e in (entries or []) if isinstance(e, dict)]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def main() -> int:
|
|
118
|
+
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
119
|
+
ap.add_argument("--spec", required=True, help="object-sculpt-spec.json")
|
|
120
|
+
ap.add_argument("--manifest", required=True, help="runtime part-tree dump from the viewer")
|
|
121
|
+
ap.add_argument("--inventory", help="standalone detail-inventory.json (default: read from spec)")
|
|
122
|
+
ap.add_argument("--require", help="comma-separated part names that MUST exist, whatever the spec says")
|
|
123
|
+
ap.add_argument("--json", dest="json_out", help="write the findings as JSON")
|
|
124
|
+
ap.add_argument("--warn-only", action="store_true", help="always exit 0")
|
|
125
|
+
args = ap.parse_args()
|
|
126
|
+
|
|
127
|
+
spec = load(args.spec)
|
|
128
|
+
manifest = load(args.manifest)
|
|
129
|
+
|
|
130
|
+
parts = [p for p in manifest.get("parts", []) if isinstance(p, dict) and p.get("name")]
|
|
131
|
+
if not parts:
|
|
132
|
+
print("FAIL model exposes no named parts at all — nothing is selectable or separable")
|
|
133
|
+
print(" the factory must name its meshes; see the assembly contract in SKILL.md")
|
|
134
|
+
return 0 if args.warn_only else 1
|
|
135
|
+
|
|
136
|
+
by_norm: dict[str, list[str]] = {}
|
|
137
|
+
for part in parts:
|
|
138
|
+
by_norm.setdefault(norm(part["name"]), []).append(part["name"])
|
|
139
|
+
|
|
140
|
+
findings: list[dict[str, str]] = []
|
|
141
|
+
claimed: dict[str, list[str]] = {}
|
|
142
|
+
|
|
143
|
+
# ---- A. componentTree -> model -------------------------------------------------
|
|
144
|
+
all_components = [c for c in spec.get("componentTree", []) if isinstance(c, dict) and c.get("id")]
|
|
145
|
+
# Exclude only the TREE ROOT — a parentless component that everything else hangs off. It
|
|
146
|
+
# is the spec's stand-in for the model group, and the viewer likewise never lists its root
|
|
147
|
+
# as a part. Do NOT treat every parent as a container: in a real spec the blade and the
|
|
148
|
+
# grip are both genuine geometry AND the parents of their own relief features, so the
|
|
149
|
+
# broader rule silently drops the most important components from the check.
|
|
150
|
+
parent_ids = {c["parent"] for c in all_components if c.get("parent")}
|
|
151
|
+
roots = {c["id"] for c in all_components if not c.get("parent") and c["id"] in parent_ids}
|
|
152
|
+
components = [c for c in all_components if c["id"] not in roots]
|
|
153
|
+
|
|
154
|
+
missing: list[dict[str, Any]] = []
|
|
155
|
+
matched: dict[str, str] = {}
|
|
156
|
+
for component in components:
|
|
157
|
+
cid = component["id"]
|
|
158
|
+
candidates = [norm(cid)]
|
|
159
|
+
if component.get("name"):
|
|
160
|
+
candidates.append(norm(component["name"]))
|
|
161
|
+
hit = next((c for c in candidates if c in by_norm), None)
|
|
162
|
+
if hit is None:
|
|
163
|
+
missing.append(component)
|
|
164
|
+
else:
|
|
165
|
+
matched[cid] = hit
|
|
166
|
+
claimed.setdefault(hit, []).append(cid)
|
|
167
|
+
|
|
168
|
+
for component in missing:
|
|
169
|
+
cid = component["id"]
|
|
170
|
+
severity = severity_for(component)
|
|
171
|
+
parent = component.get("parent")
|
|
172
|
+
# The tree root is not a part and is never "missing" — treat it as present so the
|
|
173
|
+
# message below does not blame a top-level component's absence on its own root.
|
|
174
|
+
parent_built = bool(parent) and (parent in roots or parent in matched or norm(parent) in by_norm)
|
|
175
|
+
if parent_built and severity != "error":
|
|
176
|
+
# The normal, CORRECT case: a bevel, a jimping band or a choil is relief cut into
|
|
177
|
+
# the part it belongs to, not a mesh of its own. Report it so the coverage is
|
|
178
|
+
# visible, but do not call a right answer a defect.
|
|
179
|
+
findings.append({
|
|
180
|
+
"check": "component-folded",
|
|
181
|
+
"severity": "info",
|
|
182
|
+
"subject": cid,
|
|
183
|
+
"detail": f"no mesh of its own — folded into {parent!r}, which is built. Correct "
|
|
184
|
+
f"for relief; a real gap only if this needed to be separable.",
|
|
185
|
+
})
|
|
186
|
+
else:
|
|
187
|
+
findings.append({
|
|
188
|
+
"check": "component-missing",
|
|
189
|
+
"severity": severity,
|
|
190
|
+
"subject": cid,
|
|
191
|
+
"detail": f"specified component {cid!r} has no matching part in the built model"
|
|
192
|
+
+ ("" if not parent else f", and its parent {parent!r} is missing too"),
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
for part_key, owners in claimed.items():
|
|
196
|
+
if len(owners) > 1:
|
|
197
|
+
findings.append({
|
|
198
|
+
"check": "components-fused",
|
|
199
|
+
"severity": "error",
|
|
200
|
+
"subject": by_norm[part_key][0],
|
|
201
|
+
"detail": f"components {', '.join(sorted(owners))} all resolve to the single part "
|
|
202
|
+
f"{by_norm[part_key][0]!r} — they are fused, not separable",
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
for name in filter(None, (args.require or "").split(",")):
|
|
206
|
+
if norm(name) not in by_norm:
|
|
207
|
+
findings.append({
|
|
208
|
+
"check": "required-part-missing",
|
|
209
|
+
"severity": "error",
|
|
210
|
+
"subject": name.strip(),
|
|
211
|
+
"detail": f"required part {name.strip()!r} is absent from the built model",
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
# ---- B. detailInventory -> spec ------------------------------------------------
|
|
215
|
+
keys = collect_local_feature_keys(spec)
|
|
216
|
+
for index, entry in enumerate(find_inventory(spec, args.inventory)):
|
|
217
|
+
maps_to = entry.get("mapsTo")
|
|
218
|
+
# The scaffolder writes mapsTo as {"ref": ..., "via": ...}; hand-authored specs
|
|
219
|
+
# sometimes use a bare string. Accept both rather than failing the honest one.
|
|
220
|
+
if isinstance(maps_to, dict):
|
|
221
|
+
maps_to = maps_to.get("ref") or maps_to.get("id") or ""
|
|
222
|
+
label = entry.get("id") or entry.get("description") or f"detail[{index}]"
|
|
223
|
+
if not maps_to or not str(maps_to).strip():
|
|
224
|
+
findings.append({
|
|
225
|
+
"check": "detail-unmapped",
|
|
226
|
+
"severity": "warning",
|
|
227
|
+
"subject": str(label)[:60],
|
|
228
|
+
"detail": "inventoried detail has no mapsTo — it was observed but never assigned "
|
|
229
|
+
"to a component or material field",
|
|
230
|
+
})
|
|
231
|
+
elif norm(maps_to) not in keys:
|
|
232
|
+
findings.append({
|
|
233
|
+
"check": "detail-dangling",
|
|
234
|
+
"severity": "warning",
|
|
235
|
+
"subject": str(label)[:60],
|
|
236
|
+
"detail": f"mapsTo {maps_to!r} matches no component, localFeature or localOverride",
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
# ---- C. model hygiene ----------------------------------------------------------
|
|
240
|
+
unnamed = int(manifest.get("unnamedMeshes") or 0)
|
|
241
|
+
if unnamed:
|
|
242
|
+
findings.append({
|
|
243
|
+
"check": "unnamed-meshes",
|
|
244
|
+
"severity": "warning",
|
|
245
|
+
"subject": f"{unnamed} mesh(es)",
|
|
246
|
+
"detail": "meshes belonging to no named part: they cannot be selected, and each one "
|
|
247
|
+
"explodes on its own instead of riding the part it decorates",
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
extras = sorted(set(by_norm) - set(claimed))
|
|
251
|
+
for key in extras:
|
|
252
|
+
findings.append({
|
|
253
|
+
"check": "part-not-specified",
|
|
254
|
+
"severity": "info",
|
|
255
|
+
"subject": by_norm[key][0],
|
|
256
|
+
"detail": "built part has no matching component in the spec (fine for detail groups; "
|
|
257
|
+
"a sign of spec drift for anything larger)",
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
# ---- report --------------------------------------------------------------------
|
|
261
|
+
rank = {"error": 0, "warning": 1, "info": 2}
|
|
262
|
+
findings.sort(key=lambda f: rank[f["severity"]])
|
|
263
|
+
errors = sum(1 for f in findings if f["severity"] == "error")
|
|
264
|
+
warnings = sum(1 for f in findings if f["severity"] == "warning")
|
|
265
|
+
|
|
266
|
+
label = {"error": "FAIL", "warning": "WARN", "info": "note"}
|
|
267
|
+
for finding in findings:
|
|
268
|
+
print(f"{label[finding['severity']]:<5} {finding['check']}: {finding['subject']}")
|
|
269
|
+
print(f" {finding['detail']}")
|
|
270
|
+
|
|
271
|
+
print(
|
|
272
|
+
f"\ncheck_part_coverage: {len(components)} specified, {len(parts)} built, "
|
|
273
|
+
f"{errors} error(s), {warnings} warning(s)"
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
if args.json_out:
|
|
277
|
+
Path(args.json_out).write_text(
|
|
278
|
+
json.dumps(
|
|
279
|
+
{
|
|
280
|
+
"model": manifest.get("model"),
|
|
281
|
+
"specifiedComponents": len(components),
|
|
282
|
+
"builtParts": len(parts),
|
|
283
|
+
"errors": errors,
|
|
284
|
+
"warnings": warnings,
|
|
285
|
+
"result": "fail" if errors else "pass",
|
|
286
|
+
"findings": findings,
|
|
287
|
+
},
|
|
288
|
+
indent=2,
|
|
289
|
+
)
|
|
290
|
+
+ "\n",
|
|
291
|
+
encoding="utf-8",
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
return 1 if errors and not args.warn_only else 0
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
if __name__ == "__main__":
|
|
298
|
+
sys.exit(main())
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Compare browser-captured GLB/procedural diagnostic passes.
|
|
3
|
+
|
|
4
|
+
This is a deterministic companion to the agent/vision review. It never converts a
|
|
5
|
+
global pixel score into a likeness claim. Per-region scores are keyed by the GLB
|
|
6
|
+
semantic-ID pass when that pass exists; otherwise the output explicitly says that
|
|
7
|
+
region scoring is unavailable.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import argparse
|
|
13
|
+
import json
|
|
14
|
+
import sys
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "stage1_intake"))
|
|
19
|
+
from extract_pbr_evidence import load_image # type: ignore[import-not-found]
|
|
20
|
+
|
|
21
|
+
PASS_IDS = ("beauty", "alpha-silhouette", "semantic-id", "depth", "normal", "roughness-material-id")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _resolve(manifest_path: Path, value: str) -> Path:
|
|
25
|
+
path = Path(value).expanduser()
|
|
26
|
+
return path if path.is_absolute() else manifest_path.parent / path
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _load(path: Path) -> tuple[int, int, list[tuple[int, int, int, int]]]:
|
|
30
|
+
width, height, pixels, warnings = load_image(path)
|
|
31
|
+
if warnings:
|
|
32
|
+
# Warnings are not fatal; the result records paths and metrics only.
|
|
33
|
+
pass
|
|
34
|
+
return width, height, pixels
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _aligned_pixels(
|
|
38
|
+
reference: tuple[int, int, list[tuple[int, int, int, int]]],
|
|
39
|
+
render: tuple[int, int, list[tuple[int, int, int, int]]],
|
|
40
|
+
) -> list[tuple[tuple[int, int, int, int], tuple[int, int, int, int]]]:
|
|
41
|
+
rw, rh, rp = reference
|
|
42
|
+
ww, wh, wp = render
|
|
43
|
+
if (rw, rh) != (ww, wh):
|
|
44
|
+
raise ValueError(f"pass dimensions differ: reference={rw}x{rh}, render={ww}x{wh}")
|
|
45
|
+
return list(zip(rp, wp))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _mask_from_id(pixels: list[tuple[int, int, int, int]], color: tuple[int, int, int]) -> list[bool]:
|
|
49
|
+
return [(r, g, b) == color for r, g, b, _a in pixels]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _similarity(
|
|
53
|
+
pairs: list[tuple[tuple[int, int, int, int], tuple[int, int, int, int]]],
|
|
54
|
+
mask: list[bool] | None = None,
|
|
55
|
+
) -> dict[str, Any]:
|
|
56
|
+
selected = [pair for index, pair in enumerate(pairs) if mask is None or mask[index]]
|
|
57
|
+
if not selected:
|
|
58
|
+
return {"pixels": 0, "similarity": None, "meanAbsoluteError": None}
|
|
59
|
+
error = sum(
|
|
60
|
+
abs(reference[channel] - render[channel])
|
|
61
|
+
for reference, render in selected
|
|
62
|
+
for channel in range(3)
|
|
63
|
+
) / (len(selected) * 3 * 255.0)
|
|
64
|
+
return {
|
|
65
|
+
"pixels": len(selected),
|
|
66
|
+
"similarity": round(max(0.0, 1.0 - error), 6),
|
|
67
|
+
"meanAbsoluteError": round(error * 255.0, 4),
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _iou(reference_mask: list[bool], render_mask: list[bool], mask: list[bool] | None = None) -> dict[str, Any]:
|
|
72
|
+
indices = range(len(reference_mask)) if mask is None else (i for i, value in enumerate(mask) if value)
|
|
73
|
+
intersection = union = 0
|
|
74
|
+
for index in indices:
|
|
75
|
+
reference = reference_mask[index]
|
|
76
|
+
render = render_mask[index]
|
|
77
|
+
if reference or render:
|
|
78
|
+
union += 1
|
|
79
|
+
if reference and render:
|
|
80
|
+
intersection += 1
|
|
81
|
+
return {"intersection": intersection, "union": union, "iou": round(intersection / union, 6) if union else 1.0}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def compare_capture(manifest_path: Path, capture_id: str) -> dict[str, Any]:
|
|
85
|
+
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
|
86
|
+
capture = next(item for item in manifest.get("captures", []) if item.get("id") == capture_id)
|
|
87
|
+
reference = capture.get("reference")
|
|
88
|
+
if not isinstance(reference, dict):
|
|
89
|
+
raise ValueError("capture has no GLB reference record")
|
|
90
|
+
reference_passes = reference.get("passes")
|
|
91
|
+
render_passes = capture.get("passes")
|
|
92
|
+
if not isinstance(reference_passes, dict) or not isinstance(render_passes, dict):
|
|
93
|
+
raise ValueError("capture is missing v2 pass records")
|
|
94
|
+
|
|
95
|
+
profile_path = manifest.get("renderProfile", {}).get("path")
|
|
96
|
+
profile: dict[str, Any] = {}
|
|
97
|
+
if profile_path:
|
|
98
|
+
profile = json.loads(_resolve(manifest_path, profile_path).read_text(encoding="utf-8"))
|
|
99
|
+
region_colors: dict[str, tuple[int, int, int]] = {}
|
|
100
|
+
for region in profile.get("regions", []):
|
|
101
|
+
if not isinstance(region, dict) or not isinstance(region.get("idColor"), list) or len(region["idColor"]) != 3:
|
|
102
|
+
continue
|
|
103
|
+
region_colors[str(region["id"])] = tuple(int(value) for value in region["idColor"])
|
|
104
|
+
|
|
105
|
+
loaded: dict[str, tuple[tuple[int, int, list[tuple[int, int, int, int]]], tuple[int, int, list[tuple[int, int, int, int]]]]] = {}
|
|
106
|
+
for pass_id in PASS_IDS:
|
|
107
|
+
ref_record = reference_passes.get(pass_id, {})
|
|
108
|
+
render_record = render_passes.get(pass_id, {})
|
|
109
|
+
if ref_record.get("status") != "recorded" or render_record.get("status") != "recorded":
|
|
110
|
+
continue
|
|
111
|
+
loaded[pass_id] = (
|
|
112
|
+
_load(_resolve(manifest_path, str(ref_record["path"]))),
|
|
113
|
+
_load(_resolve(manifest_path, str(render_record["path"]))),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
semantic_masks: dict[str, list[bool]] = {}
|
|
117
|
+
if "semantic-id" in loaded:
|
|
118
|
+
reference_semantic = loaded["semantic-id"][0][2]
|
|
119
|
+
semantic_masks = {region: _mask_from_id(reference_semantic, color) for region, color in region_colors.items()}
|
|
120
|
+
|
|
121
|
+
results: dict[str, Any] = {}
|
|
122
|
+
for pass_id, (reference_image, render_image) in loaded.items():
|
|
123
|
+
pairs = _aligned_pixels(reference_image, render_image)
|
|
124
|
+
if pass_id == "alpha-silhouette":
|
|
125
|
+
reference_mask = [alpha > 0 and (red or green or blue) > 0 for red, green, blue, alpha in reference_image[2]]
|
|
126
|
+
render_mask = [alpha > 0 and (red or green or blue) > 0 for red, green, blue, alpha in render_image[2]]
|
|
127
|
+
global_result: dict[str, Any] = _iou(reference_mask, render_mask)
|
|
128
|
+
per_region = {region: _iou(reference_mask, render_mask, mask) for region, mask in semantic_masks.items()}
|
|
129
|
+
elif pass_id == "semantic-id":
|
|
130
|
+
global_result = {"pixels": len(pairs), "exactMatch": round(sum(ref[:3] == out[:3] for ref, out in pairs) / len(pairs), 6) if pairs else None}
|
|
131
|
+
per_region = {
|
|
132
|
+
region: {"pixels": sum(mask), "exactMatch": round(sum(ref[:3] == out[:3] for index, (ref, out) in enumerate(pairs) if mask[index]) / sum(mask), 6) if sum(mask) else None}
|
|
133
|
+
for region, mask in semantic_masks.items()
|
|
134
|
+
}
|
|
135
|
+
else:
|
|
136
|
+
global_result = _similarity(pairs)
|
|
137
|
+
per_region = {region: _similarity(pairs, mask) for region, mask in semantic_masks.items()}
|
|
138
|
+
results[pass_id] = {"global": global_result, "perRegion": per_region}
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
"schemaVersion": 1,
|
|
142
|
+
"captureId": capture_id,
|
|
143
|
+
"comparisonBasis": "browser-rendered-glb-vs-browser-rendered-procedural",
|
|
144
|
+
"passesCompared": sorted(results),
|
|
145
|
+
"regionEvidence": "semantic-id-reference-pass" if semantic_masks else "unavailable",
|
|
146
|
+
"results": results,
|
|
147
|
+
"blockedClaims": [] if semantic_masks else ["per-region scores are unavailable until semantic-id pass has region colors"],
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def main(argv: list[str]) -> int:
|
|
152
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
153
|
+
parser.add_argument("--manifest", type=Path, required=True)
|
|
154
|
+
parser.add_argument("--capture-id", default="hero")
|
|
155
|
+
parser.add_argument("--out", type=Path, required=True)
|
|
156
|
+
args = parser.parse_args(argv)
|
|
157
|
+
try:
|
|
158
|
+
result = compare_capture(args.manifest.expanduser().resolve(), args.capture_id)
|
|
159
|
+
args.out.expanduser().resolve().parent.mkdir(parents=True, exist_ok=True)
|
|
160
|
+
args.out.expanduser().resolve().write_text(json.dumps(result, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
161
|
+
print(json.dumps(result, indent=2, ensure_ascii=False))
|
|
162
|
+
return 0 if not result["blockedClaims"] else 1
|
|
163
|
+
except Exception as exc: # noqa: BLE001
|
|
164
|
+
print(json.dumps({"passed": False, "error": str(exc)}, ensure_ascii=False))
|
|
165
|
+
return 2
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
if __name__ == "__main__":
|
|
169
|
+
raise SystemExit(main(__import__("sys").argv[1:]))
|