Skip to content

Official Codebase of 3DCodeVerse

Python

rig: overview views lift the harness room shell's lid, the instruments see what the rig draws; a terrain overhead must be ground-NAMED (a 40 m 'Ceiling' is a roof)

gaoypengf83282a50e69
diff --git a/harness/runtime_js/lib/host_metrics.mjs b/harness/runtime_js/lib/host_metrics.mjs
index 66af9efd..bd4746f4 100644
--- a/harness/runtime_js/lib/host_metrics.mjs
+++ b/harness/runtime_js/lib/host_metrics.mjs
@@ -3,7 +3,7 @@
* readback of the render canvas and near-geometry tests for a camera.
*/
-import { classifyBackdrop, nonSolid } from './backdrop.mjs';
+import { GROUND_NAME_RE, classifyBackdrop, nonSolid } from './backdrop.mjs';
export const SAMPLE_W = 96;
export const SAMPLE_H = 54;
@@ -91,6 +91,11 @@ export const BLOCKED_M = 1.5;
/** A ground-classified mesh at least this wide is terrain, not a floor a shot may sit under. */
export const TERRAIN_SPAN_M = 40;
+/** Does the name carry a ground word? CamelCase split first: `HeadlandTerrain` is a terrain. */
+export function groundNamed(name) {
+ return GROUND_NAME_RE.test(String(name || '').replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' '));
+}
+
/**
* The lowest terrain-scale ground surface straight above `eye`, or null. Cast DOWN from
* 500 m up and take the last hit above the eye: a FrontSide terrain is back faces to a ray
@@ -148,7 +153,11 @@ export function nearGeometry(scene, camera, THREE, limitM = 0.3, lookAt = null)
if (!o.geometry.boundingBox) o.geometry.computeBoundingBox();
box.copy(o.geometry.boundingBox).applyMatrix4(o.matrixWorld);
const s = box.getSize(new THREE.Vector3());
- if (Math.max(s.x, s.z) >= TERRAIN_SPAN_M && classifyBackdrop(o, box) === 'ground') groundMeshes.push(o);
+ // terrain overhead must also be NAMED as ground: a 40 m 'Ceiling' is ground-shaped to the
+ // classifier, and loop 25's cathedral read "camera 17.8 m under Ceiling" on every interior
+ // camera (2026-09-09) — a lens under a roof is a shot, a lens under a terrain is a bug
+ if (Math.max(s.x, s.z) >= TERRAIN_SPAN_M && classifyBackdrop(o, box) === 'ground'
+ && groundNamed(o.name || o.parent?.name || '')) groundMeshes.push(o);
if (Math.max(s.x, s.y, s.z) > 60 || Math.min(s.x, s.y, s.z) < 0.05) continue; // ground/sky/flat decals
// The bbox is the cheap pre-filter; the verdict is the mesh's own volume. A windmill's
// 22 m lattice sails own a 22 x 22 m bbox that is nearly all air: measured 2026-09-07
diff --git a/harness/runtime_js/lib/scene_host.mjs b/harness/runtime_js/lib/scene_host.mjs
index 01e14934..70f0d802 100644
--- a/harness/runtime_js/lib/scene_host.mjs
+++ b/harness/runtime_js/lib/scene_host.mjs
@@ -458,12 +458,26 @@ function renderOnce(cam) {
try { const gl = state.renderer.getContext(); if (gl && gl.finish) gl.finish(); } catch (e) { /* ignore */ }
}
-/** Visible see-through meshes classified 'sky' (backdrop.mjs) whose whole box lies below `eye`. */
+/**
+ * What a rig view must not draw: visible see-through meshes classified 'sky' whose whole box
+ * lies below `eye` (a cloud deck seen from above), and the harness-injected room shell's
+ * ceiling when the eye is above it — an interior seen by the overview rig was a closed box,
+ * and the pairwise judge called the bakery "a tiny fragment in the overviews" against a
+ * one-shot whose room had no roof (cmp7, 2026-09-09). Lifting the shell's lid shows the
+ * layout the rig exists to show; an author's own roof stays, and so does every authored camera.
+ */
function skyLayersBelow(eye) {
const out = [];
const box = new THREE.Box3();
state.scene.traverse((o) => {
- if (!(o.isMesh || o.isInstancedMesh) || !o.visible || !o.geometry || !nonSolid(o)) return;
+ if (!(o.isMesh || o.isInstancedMesh) || !o.visible || !o.geometry) return;
+ if (o.parent && o.parent.name === 'RoomShell' && /^Ceiling/.test(o.name || '')) {
+ if (!o.geometry.boundingBox) o.geometry.computeBoundingBox();
+ box.copy(o.geometry.boundingBox).applyMatrix4(o.matrixWorld);
+ if (!box.isEmpty() && box.max.y < eye.y) out.push(o);
+ return;
+ }
+ if (!nonSolid(o)) return;
if (!o.geometry.boundingBox) o.geometry.computeBoundingBox();
if (o.geometry.boundingBox.isEmpty()) return;
box.copy(o.geometry.boundingBox).applyMatrix4(o.matrixWorld);
@@ -520,21 +534,29 @@ function cameraChecks(spec) {
const cam = buildCamera(spec);
state.scene.updateMatrixWorld(true);
const near = nearGeometry(state.scene, cam, THREE, undefined, Array.isArray(spec.lookAt) ? spec.lookAt : null);
- renderOnce(cam);
- const stats = frameStats(state.canvas);
+ // the instruments see what the rig view draws (a lifted lid, no cloud deck under the eye)
+ const hiddenLayers = spec.noFog ? skyLayersBelow(cam.position) : [];
+ for (const o of hiddenLayers) o.visible = false;
+ let stats = {};
let coverage = {};
- try {
- coverage = frameCoverage(state.renderer, state.scene, cam, state.canvas, THREE, state.contentBox);
- } catch (e) {
- state.hostWarnings.push(`coverage failed for ${spec.name}: ${e.message}`);
- }
let glbFrac = {};
- if (loadedGlbs.length) {
+ try {
+ renderOnce(cam);
+ stats = frameStats(state.canvas);
try {
- glbFrac = glbCoverage(state.renderer, state.scene, cam, state.canvas, THREE, loadedGlbs);
+ coverage = frameCoverage(state.renderer, state.scene, cam, state.canvas, THREE, state.contentBox);
} catch (e) {
- state.hostWarnings.push(`glb coverage failed for ${spec.name}: ${e.message}`);
+ state.hostWarnings.push(`coverage failed for ${spec.name}: ${e.message}`);
}
+ if (loadedGlbs.length) {
+ try {
+ glbFrac = glbCoverage(state.renderer, state.scene, cam, state.canvas, THREE, loadedGlbs);
+ } catch (e) {
+ state.hostWarnings.push(`glb coverage failed for ${spec.name}: ${e.message}`);
+ }
+ }
+ } finally {
+ for (const o of hiddenLayers) o.visible = true;
}
return { name: spec.name, ...near, ...stats, ...coverage, glb_frac: glbFrac };
}
diff --git a/harness/tests/scene_gates/test_live_hero_in_frame.py b/harness/tests/scene_gates/test_live_hero_in_frame.py
index ddfee145..15690575 100644
--- a/harness/tests/scene_gates/test_live_hero_in_frame.py
+++ b/harness/tests/scene_gates/test_live_hero_in_frame.py
@@ -30,7 +30,13 @@ WALL = """
"""
-def _with_hero(ws: Workspace, *, hidden: bool) -> None:
+ROOM = """
+ const shell = roomShell({ center: [10, 4, 14], extents: [12, 8, 12], thickness: 0.3 });
+ scene.add(shell);
+"""
+
+
+def _with_hero(ws: Workspace, *, hidden: bool, roofed: bool = False) -> None:
write_box_glb(ws.public / "assets" / "hero_cube.glb", size=(4.0, 4.0, 4.0))
scene = ws.src / "scene.js"
text = scene.read_text()
@@ -39,7 +45,11 @@ def _with_hero(ws: Workspace, *, hidden: bool) -> None:
" const hero = (await loaders.gltf.loadAsync('" + URL + "')).scene;\n"
" hero.name = 'HeroCube'; hero.position.set(10, 6, 14);\n"
" hero.traverse((o) => { if (o.geometry) o.geometry.computeVertexNormals(); });\n"
- " scene.add(hero);\n" + (WALL if hidden else ""), 1)
+ " scene.add(hero);\n" + (WALL if hidden else "") + (ROOM if roofed else ""), 1)
+ if roofed:
+ text = text.replace("import { buildEnv, heightAt, SUN_AZIMUTH_DEG } from './env.js';",
+ "import { buildEnv, heightAt, SUN_AZIMUTH_DEG } from './env.js';\nimport { roomShell } from './lib/environment.js';", 1)
+ assert "roomShell(" in text
assert "hero_cube.glb" in text and ("StoneWall" in text) == hidden
scene.write_text(text)
@@ -76,3 +86,21 @@ def test_a_hero_behind_a_wall_in_every_authored_frame_is_an_error(starter_ws: Wo
cut = [f for f in gate.findings if f.data["kind"] == "camera_target_blocked" and f.target == "overview"]
assert cut and "StoneWall" in cut[0].message, [f.message for f in gate.findings]
assert math.isfinite(cut[0].data["target_hit_m"])
+
+
+def test_the_overview_rig_lifts_the_room_shells_lid_but_an_authored_camera_keeps_it(starter_ws: Workspace):
+ """cmp7's bakery (2026-09-09): the pairwise judge saw the harness interior as "a tiny fragment
+ in the overviews" — a closed box. The rig hides the harness-injected shell's ceiling when
+ the eye is above it; the authored cameras (and the census) keep the room as built."""
+ _with_hero(starter_ws, hidden=False, roofed=True)
+ out = starter_ws.renders_dir(0)
+ rs = render_scene(starter_ws, out, times=(0.0,), width=640, height=360, fps_seconds=0.2)
+ assert rs.console_errors == []
+ m = read_metrics(out)
+ chk = {c["name"]: c for c in m["camera_checks"]}
+ # the lid is lifted for the rig: a 4 m cube from 100 m up is a few pixels, but it is there
+ assert chk["overview_top"]["glb_frac"].get(URL, 0.0) > 0.0005, chk["overview_top"]["glb_frac"]
+ # the authored overview looks at the room from outside and above: the roof stays, the cube is hidden
+ assert chk["overview"]["glb_frac"].get(URL, 0.0) < 0.002, chk["overview"]["glb_frac"]
+ names = [g["name"] for g in m["census"]["groups"]]
+ assert "RoomShell" in names # the census counts the shell as built
diff --git a/harness/tests/scene_runtime/test_camera_inside_volume.py b/harness/tests/scene_runtime/test_camera_inside_volume.py
index e005156b..023fdb88 100644
--- a/harness/tests/scene_runtime/test_camera_inside_volume.py
+++ b/harness/tests/scene_runtime/test_camera_inside_volume.py
@@ -123,3 +123,7 @@ def test_a_ground_surface_above_the_lens_is_reported():
assert abs(got["ground_below_m"] - 1.6) < 1e-3, got
open_air = _run(MOUND, "0, 1.6, 0")
assert open_air["ground_above_m"] is None, open_air
+ # a 60 m 'Ceiling' is ground-SHAPED to the classifier and still a roof: loop 25's cathedral
+ # (2026-09-09) read "camera 17.8 m under Ceiling" on every interior camera
+ roof = _run(HEADLAND.replace("HeadlandTerrain", "Ceiling"), "0, 1.6, 0")
+ assert roof["ground_above_m"] is None, roof