Official Codebase of 3DCodeVerse
Python
Blender self-check measures what exports; the three.js placement warning stops claiming the gate agrees
gaoypeng8a81538d9485
diff --git a/harness/codeverse3d/languages/blender/__init__.py b/harness/codeverse3d/languages/blender/__init__.pyindex e6b06621..220ee158 100644--- a/harness/codeverse3d/languages/blender/__init__.py+++ b/harness/codeverse3d/languages/blender/__init__.py@@ -494,9 +494,12 @@ def add_box(name, center, extents, material=None, bevel=0.0):SELFCHECK = '''def _selfcheck():- """What the harness checks first: meshes exist, no auto-suffixed names, stands on z=0."""+ """What the harness checks first: meshes exist, no auto-suffixed names, stands on z=0 —+ over the meshes that export (a hidden boolean cutter does not)."""bpy.context.view_layer.update()- meshes = [o for o in bpy.data.objects if o.type == "MESH"]+ shown = set(bpy.context.view_layer.objects.keys())+ meshes = [o for o in bpy.data.objects if o.type == "MESH" and o.name in shown+ and not (o.hide_render or o.hide_viewport or o.hide_get())]assert meshes, "no mesh objects built"for o in meshes:assert "." not in o.name, f"auto-suffixed name {o.name!r}: give every instance its own name"diff --git a/harness/codeverse3d/prompts/threejs/contract.md b/harness/codeverse3d/prompts/threejs/contract.mdindex c5a88dbd..2fc5aa06 100644--- a/harness/codeverse3d/prompts/threejs/contract.md+++ b/harness/codeverse3d/prompts/threejs/contract.md@@ -19,7 +19,7 @@ The harness loads `src/object.js` in node, calls `build(THREE)`, and exports* Lowest point at y = 0, footprint centred on the Y axis. Real-world dimensions.The harness exports the object **exactly where you put it** (no automatic drop tothe ground or re-centring): an off-ground / off-centre build only gets a build- warning plus a contract-gate finding, so place every part at its plan centre.+ warning, so place every part at its plan centre.## Naming* Part Group: `g.name = "<PartName>"` — PascalCase exactly as the plan (`SeatCushion`);diff --git a/harness/runtime_js/export_glb.mjs b/harness/runtime_js/export_glb.mjsindex 3c2c3fc3..85416076 100644--- a/harness/runtime_js/export_glb.mjs+++ b/harness/runtime_js/export_glb.mjs@@ -187,7 +187,7 @@ async function main() {if (tickPresent) delete group.userData.tick; // functions cannot be serialised into glTF extrasconst offset = placement(THREE, group);- if (offset) warnings.push(`object is off ground/centre: it needs a translation of ${JSON.stringify(offset)} m to stand on y=0 centred on the Y axis; exported as authored — fix the source (the contract gate reports this too)`);+ if (offset) warnings.push(`object is off ground/centre: it needs a translation of ${JSON.stringify(offset)} m to stand on y=0 centred on the Y axis; exported as authored — fix the source`);stripTextures(group, warnings);// what only the export knows; the object's measurements are read off the GLB (spatial/measure.py)diff --git a/harness/tests/blender_cadquery/test_blender_runtime.py b/harness/tests/blender_cadquery/test_blender_runtime.pyindex bc4d0bc7..f166c32e 100644--- a/harness/tests/blender_cadquery/test_blender_runtime.py+++ b/harness/tests/blender_cadquery/test_blender_runtime.py@@ -76,3 +76,20 @@ def test_live_timeout_and_memory_cap(tmp_ws, blender_bin) -> None:(tmp_ws.src / "model.py").write_text("import bpy\nimport numpy as np\nbpy.ops.mesh.primitive_cube_add(size=1)\nbig = np.ones((3_000_000_000,))\n")r = rt.build(tmp_ws, timeout_s=60)assert not r.ok and r.error_type == "MemoryError" and r.error_line == 4+++def test_live_selfcheck_skips_hidden_cutters(tmp_ws, blender_bin) -> None:+ """Audit 2026-09-24 N6a: the skeleton's self-check measured a hidden boolean cutter+ (`Cutter.001`, reaching z = -0.5) and failed a build whose GLB stands exactly on z = 0."""+ from codeverse3d.languages.blender import selfcheck_source++ (tmp_ws.src / "model.py").write_text(+ "import bpy\nfrom mathutils import Vector\n" + selfcheck_source() ++ "bpy.ops.mesh.primitive_cube_add(size=1, location=(0, 0, 0.5)); body = bpy.context.object; body.name = 'Body'\n"+ "bpy.ops.mesh.primitive_cylinder_add(radius=0.2, depth=2, location=(0, 0, 0.5)); cut = bpy.context.object\n"+ "cut.name = 'Cutter.001'; body.modifiers.new('Hole', 'BOOLEAN').object = cut\n"+ "cut.hide_set(True); cut.hide_render = True\n_selfcheck()\n")+ r = BlenderRuntime(blender=blender_bin).build(tmp_ws, timeout_s=120)+ assert r.ok, (r.error_type, r.error_message)+ assert "[selfcheck] 1 mesh objects, z_min=0.0000" in r.stdout_taildiff --git a/harness/tests/threejs_render/test_build.py b/harness/tests/threejs_render/test_build.pyindex 162b5e9f..e466d340 100644--- a/harness/tests/threejs_render/test_build.py+++ b/harness/tests/threejs_render/test_build.py@@ -87,7 +87,8 @@ def test_build_keeps_source_placement_and_warns(stool_ws: Workspace):assert res.ok and res.census["selfcheck_ran"] is Trueoff = res.census["placement_offset"]assert off is not None and abs(off[0] + 0.5) < 1e-4 and abs(off[1] + 0.2) < 1e-4- assert any("off ground/centre" in w and "exported as authored" in w for w in res.census["warnings"])+ warn = next(w for w in res.census["warnings"] if "off ground/centre" in w)+ assert "exported as authored" in warn and "contract gate" not in warn # N6b: the gate's tolerance differslo, _ = trimesh.load(res.glb_path, force="scene").boundsassert abs(lo[1] - 0.2) < 2e-3 and abs(lo[0] - 0.33) < 2e-3