Official Codebase of 3DCodeVerse
Python
scene_frames: a Blender hero that is loaded and never placed
gaoypeng02d961f8967f
diff --git a/harness/codeverse/spatial/frame_metrics.py b/harness/codeverse/spatial/frame_metrics.pyindex faa48cd9..2c64ba21 100644--- a/harness/codeverse/spatial/frame_metrics.py+++ b/harness/codeverse/spatial/frame_metrics.py@@ -242,6 +242,44 @@ def _motion_findings(rows: list[MotionRow]) -> list[GateFinding]:kind="motion", moving=[r.name for r in moving], n_moving=len(moving))]+_UNUSED_GLB_HINT = (+ "the GLB is fetched and then thrown away — either place it (add the loaded scene, or clone it: "+ "`const g = await loaders.gltf.loadAsync(url); zone.add(g.scene.clone())`) or stop loading it. "+ "If a refine round replaced the asset with a procedural rebuild, DELETE the dead load: leaving it in "+ "makes plan.json's `assets[].kind: blender_glb` claim a Blender hero the rendered scene does not contain."+)+++def _glb_findings(census: dict[str, Any]) -> list[GateFinding]:+ """A GLB that was loaded and contributed no geometry to the rendered scene.++ Measured 2026-08-25 on tsr_scn_boat_workshop_v2: ``src/scene.js`` loads+ ``/assets/clinker_skiff.glb`` — a real Blender hero, authored, built and copied into+ ``public/assets`` — while ``src/zones/central_bay.js`` calls a procedural+ ``buildClinkerSkiff(THREE)`` that a refine round wrote over the asset slot. The hull in+ every shipped frame is JavaScript. Nothing flagged it, and the check the wave was+ using to verify the multi-language claim (``plan.json`` -> ``assets[].kind``) still+ reported ``blender_glb``, because the plan records what was PLANNED.++ WARN, not ERROR: the picture is fine, and an author who deep-copies geometry+ (``geometry.clone()``) rather than cloning the object would read as unused here.+ """+ rows = census.get("glb_assets")+ if not isinstance(rows, list):+ return []+ out: list[GateFinding] = []+ for r in rows:+ if not isinstance(r, dict) or r.get("in_scene") is not False:+ continue+ url = str(r.get("url", "?"))+ out.append(_f(Severity.WARN, "overall",+ f"{url} is loaded but no geometry from it reaches the rendered scene "+ f"({r.get('meshes', 0)} mesh(es) in the file, 0 in the frame)",+ _UNUSED_GLB_HINT, kind="unused_glb_asset", url=url,+ meshes=r.get("meshes"), meshes_in_scene=r.get("meshes_in_scene")))+ return out++def frame_findings(metrics: dict[str, Any]) -> GateReport:"""``scene_frames`` gate from a ``metrics.json`` payload (``camera_checks`` + ``census`` + ``motion``)."""checks: list[dict[str, Any]] = [c for c in metrics.get("camera_checks") or [] if isinstance(c, dict)]@@ -261,6 +299,7 @@ def frame_findings(metrics: dict[str, Any]) -> GateReport:if cov is not None:findings.append(cov)findings += _motion_findings(stored_motion(metrics))+ findings += _glb_findings(metrics.get("census") or {})if checks and not [f for f in findings if f.severity != Severity.INFO]:n = len(checks)findings.append(_f(Severity.INFO, "overall", f"{n} camera frame(s) checked: exposure, geometry and coverage within limits", "",diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.mdindex 51e2c04c..9c7219b3 100644--- a/harness/docs/ARCHITECTURE.md+++ b/harness/docs/ARCHITECTURE.md@@ -350,7 +350,10 @@ too small, and **`no_motion`** — the frames of one camera at the first and lastime are diffed in `spatial/frame_motion.py` and the per-camera "% of pixels changed"goes to the judge as a fact, because two tiles in different montage images are notcomparable by eye and every scene judged before it was told "nothing moves" while its-water was rippling), graphics `gl_frames` (NaN/black/blown/static/flicker).+water was rippling, and **`unused_glb_asset`** — the scene host wraps `loaders.gltf` and+records each GLB's geometry UUIDs, so the census can say whether any of it reached the+rendered frame; `Object3D.clone()` shares geometry, so a cloned hero still counts and only+a discarded load does not), graphics `gl_frames` (NaN/black/blown/static/flicker).## 8. Texturing (derived asset pack)diff --git a/harness/runtime_js/lib/scene_host.mjs b/harness/runtime_js/lib/scene_host.mjsindex af427e07..ddcbb84f 100644--- a/harness/runtime_js/lib/scene_host.mjs+++ b/harness/runtime_js/lib/scene_host.mjs@@ -99,13 +99,43 @@ function validateCameras(raw) {return { cameras: out, problems };}+// Every GLB the scene asked for, with the geometry it brought: {url, geometry_uuids}.+// Reset per boot; read by census() to answer "was this asset actually USED?".+let loadedGlbs = [];+function makeLoaders(manager) {const gltf = new GLTFLoader(manager);+ // Record what each GLB load delivered. `Loader.loadAsync` is a promise wrapper around+ // `this.load`, so wrapping load alone covers both call styles.+ const origLoad = gltf.load.bind(gltf);+ gltf.load = (url, onLoad, onProgress, onError) => origLoad(url, (res) => {+ const uuids = [];+ try { res?.scene?.traverse((o) => { if (o.geometry && o.geometry.uuid) uuids.push(o.geometry.uuid); }); } catch { /* census is best-effort */ }+ loadedGlbs.push({ url: String(url), geometry_uuids: uuids });+ if (onLoad) onLoad(res);+ }, onProgress, onError);const texture = new THREE.TextureLoader(manager);const cube = new THREE.CubeTextureLoader(manager);return { gltf, texture, cube, manager };}+/** Per loaded GLB: did any of its geometry reach the rendered scene?+ *+ * `Object3D.clone()` SHARES BufferGeometry (Mesh.copy assigns the same reference), so an+ * asset used via clone still matches — which is how the scene track normally places a+ * hero. A procedural rebuild allocates its own geometry and matches nothing, which is+ * exactly the case this exists to catch. A deep `geometry.clone()` would read as unused;+ * that is why the finding is a WARN and says "no geometry from it", not "not used".+ */+function glbUsage(scene) {+ const used = new Set();+ try { scene.traverse((o) => { if (o.geometry && o.geometry.uuid) used.add(o.geometry.uuid); }); } catch { return []; }+ return loadedGlbs.map((g) => {+ const n = g.geometry_uuids.filter((u) => used.has(u)).length;+ return { url: g.url, meshes: g.geometry_uuids.length, meshes_in_scene: n, in_scene: n > 0 };+ });+}+function waitForLoads(manager, timeoutMs) {return new Promise((resolve) => {let done = false;@@ -131,6 +161,7 @@ async function boot(opts) {const info = { ok: false, stage: 'init', error: '', cameras: [], camera_problems: [], shape: {}, timings_ms: {}, renderer: '' };state.bootInfo = info;try {+ loadedGlbs = [];state.width = opts.width || 1024;state.height = opts.height || 576;window.requestAnimationFrame = () => { state.rafCalls += 1; return 0; };@@ -359,6 +390,7 @@ function fps(seconds, spec) {function census() {const c = sceneCensus(state.scene, THREE);+ c.glb_assets = glbUsage(state.scene);state.contentBox = c.content_bbox;state.fullBox = c.bbox;c.cameras = state.cameras.length;diff --git a/harness/tests/scene_gates/test_frame_metrics.py b/harness/tests/scene_gates/test_frame_metrics.pyindex 03032cc2..cd8e2459 100644--- a/harness/tests/scene_gates/test_frame_metrics.py+++ b/harness/tests/scene_gates/test_frame_metrics.py@@ -147,3 +147,34 @@ def test_frame_summary_text_table():assert lines[1].startswith("Establishing [authored]: lum 0.07 dark 41%") and lines[1].endswith("— DARK FRAME")assert "content 45%" in lines[2] and "—" not in lines[2]assert frame_summary_text({}) == "frame checks: no camera_checks in metrics"+++# ------------------------------------------------- a hero that is loaded and never placed+def test_a_loaded_glb_that_reaches_no_frame_is_flagged():+ """Measured 2026-08-25 on tsr_scn_boat_workshop_v2: src/scene.js loads+ /assets/clinker_skiff.glb — a real Blender hero, authored, built, copied into+ public/assets — while src/zones/central_bay.js calls a procedural buildClinkerSkiff().+ The hull in every shipped frame is JavaScript. Nothing flagged it, and the check the+ teaser wave used to verify the multi-language claim (plan.json -> assets[].kind) still+ said blender_glb, because the plan records what was PLANNED, not what rendered."""+ from codeverse.contracts.artifacts import Severity+ from codeverse.spatial.frame_metrics import frame_findings++ rep = frame_findings({"camera_checks": [], "census": {"glb_assets": [+ {"url": "/assets/clinker_skiff.glb", "meshes": 7, "meshes_in_scene": 0, "in_scene": False},+ {"url": "/assets/potbelly_stove.glb", "meshes": 5, "meshes_in_scene": 5, "in_scene": True},+ ]}})+ bad = [f for f in rep.findings if f.data["kind"] == "unused_glb_asset"]+ assert len(bad) == 1, "only the unused one is a finding"+ assert "clinker_skiff" in bad[0].message+ assert bad[0].severity is Severity.WARN, "the picture still renders; this must not fail the run"+ assert rep.passed, "a WARN must not fail the gate"+++def test_a_scene_with_no_glbs_says_nothing():+ """Most scenes load no GLB at all; they must not gain a finding for it."""+ from codeverse.spatial.frame_metrics import frame_findings++ for census in ({}, {"glb_assets": []}, {"glb_assets": "not a list"}):+ rep = frame_findings({"camera_checks": [], "census": census})+ assert not [f for f in rep.findings if f.data["kind"] == "unused_glb_asset"]