Skip to content

Official Codebase of 3DCodeVerse

Python

prompts: the cookbooks state no harness limits — self-checks no longer throw at 2e6 / 200 / 3 / 600 000

gaoypeng94508a4b61ee
diff --git a/harness/codeverse3d/prompts/blender/cookbook.md b/harness/codeverse3d/prompts/blender/cookbook.md
index d7afb75e..3d602a2e 100644
--- a/harness/codeverse3d/prompts/blender/cookbook.md
+++ b/harness/codeverse3d/prompts/blender/cookbook.md
@@ -590,7 +590,7 @@ Measured on this harness (183 judged rounds): **triangles inside a part are free
top-level parts are not** — ρ(tri_per_part, geometry_detail) ≈ +0.08 while ρ(n_plan_parts,
assembly_fit) = −0.48. Every recipe below adds density *inside* a part the plan already names.
-**Where the detail budget goes.** A viewer (and the judge's montage) looks, in order, at the
+**Where the detail goes.** A viewer (and the judge's montage) looks, in order, at the
silhouette, then the 2–3 largest faces, then whatever is at eye height and at the front, then the
places where two materials meet. Spend there and stop.
@@ -835,8 +835,8 @@ cast_part(housing)
Before you finish, ask of each part: *what would tell a photograph of the real thing from this?*
If the answer is "the edges are perfectly sharp" → bevel. "It is one flat face" → panel line or
inset. "It has no fixings" → bolt ring. "The repeats are identical" → `varied_copies`. "It is
-all one grey" → split the materials, per face if it is one part (`material_index`, above). Then measure: `measure` reports the triangle count — if you
-are under the detail budget's floor, you have not detailed anything yet.
+all one grey" → split the materials, per face if it is one part (`material_index`, above). Then measure: `measure` reports the triangle count — compare
+it part by part with what the density table adds.
## Common objects — dimensions (metres) and decomposition
@@ -949,7 +949,7 @@ def build_sail_rotor() -> bpy.types.Object:
for visuals; for booleans use `radius2=1e-4`.
18. **A curve object left un-converted** exports nothing (the harness converts meshes
only) → always `convert(target='MESH')` as in `make_tube_along`.
-19. **Huge scripts / per-vertex Python loops over 500 k verts** time out → use modifiers,
+19. **Huge scripts / per-vertex Python loops over big meshes** time out → use modifiers,
`foreach_set`, or fewer segments.
20. **Parenting with scaled parents** → children inherit scale; export bakes it, bevels go
elliptical. Do not parent parts at all — an Empty parent also merges its children into
@@ -980,7 +980,6 @@ def selfcheck(expected_names, bbox_hint=None, tol=0.01):
max(world_bbox(o)[1].z for o in meshes)))
assert abs(lo.z) < tol, f"lowest point z={lo.z:.4f}, expected 0"
tris = sum(sum(len(p.vertices) - 2 for p in o.data.polygons) for o in meshes)
- assert tris < 600_000, f"too many triangles: {tris}"
print(f"[selfcheck] parts={len(meshes)} tris={tris} extents={tuple(round(v, 3) for v in (hi - lo))}")
if bbox_hint:
for a, b in zip(hi - lo, bbox_hint):
diff --git a/harness/codeverse3d/prompts/cadquery/cookbook.md b/harness/codeverse3d/prompts/cadquery/cookbook.md
index e12658cb..ca0776f8 100644
--- a/harness/codeverse3d/prompts/cadquery/cookbook.md
+++ b/harness/codeverse3d/prompts/cadquery/cookbook.md
@@ -339,7 +339,7 @@ spending a render.
in place with `.rotate(...).translate(...)` and use `Location` only for translation +
one yaw.
17. **Very slow builds** → long loops of `.union` with fillets inside; fillet once at the
- end, use `rarray`/`polarArray`, keep ≤ 40 parts.
+ end, use `rarray`/`polarArray`.
18. **`hole()` on the wrong side** → it cuts in the −normal direction of the workplane;
stand on the top face (`faces(">Z").workplane()`).
diff --git a/harness/codeverse3d/prompts/scene_threejs/cookbook.md b/harness/codeverse3d/prompts/scene_threejs/cookbook.md
index 1805edcb..fd5db68c 100644
--- a/harness/codeverse3d/prompts/scene_threejs/cookbook.md
+++ b/harness/codeverse3d/prompts/scene_threejs/cookbook.md
@@ -301,13 +301,13 @@ must still be something: a haze gradient plus 5–10 silhouette shapes.
## Dusk / night lighting recipe (dark scenes are the #1 gate failure)
"Dusk", "night", "moonlit", "lantern-lit" means COLOURED darkness, never black. The harness
-measures every camera's frame; mean luminance < 0.12 or > 35 % near-black pixels is a gate
-ERROR (`scene_frames: dark_frame`) capping the score at 0.55. Take the `dusk` / `night`
+measures every camera's frame; a frame that is too dark is a gate ERROR
+(`scene_frames: dark_frame`) capping the score at 0.55. Take the `dusk` / `night`
row of the time-of-day table below for sky, sun, fill and fog, then add **practicals** —
every lantern, window and fire is an emissive surface plus a small PointLight:
```js
-function addPracticals(THREE, scene, spots) { // ≤ 12; none cast shadows
+function addPracticals(THREE, scene, spots) { // none cast shadows
const glowMat = new THREE.MeshStandardMaterial({ color: 0xffc070, emissive: 0xffa040, emissiveIntensity: 3.0 });
return spots.map(([x, y, z], i) => {
const bulb = new THREE.Mesh(new THREE.SphereGeometry(0.15, 12, 8), glowMat);
@@ -328,9 +328,8 @@ down is NOT how you make dusk, tinting it is (`sunColor`, `fillSky`, `fillGround
black `scene.background` (the sky gradient's horizon band is the brightest thing in the frame).
**Exposure self-check (after each build):** `scene_views` → the frame table
-(`camera_checks` in metrics.json) for every authored camera: `mean_lum` ≥ 0.15, `dark_frac`
-≤ 0.25, `blown_frac` ≤ 0.10, `content_frac` ≥ 0.25 on the establishing shot. Below that,
-raise `fill` by +0.3 and `intensity` by +0.8 in the `sunRig({...})` call and re-render —
+(`camera_checks` in metrics.json) for every authored camera: read `mean_lum` / `dark_frac` /
+`blown_frac` / `content_frac` and any finding it names. If a frame is dark, raise `fill` by +0.3 and `intensity` by +0.8 in the `sunRig({...})` call and re-render —
never a second DirectionalLight beside the rig (measured 2026-09-07: a blue-hour lighthouse
stacked a "TwilightKey" on the night rig and still read 0.13). Black shade is the most
common cause: at sun elevation < 25° keep `fill` ≥ 1.0.
@@ -643,7 +642,7 @@ function buildCampfire(THREE, { heightAt }) {
const campfireDemo = buildCampfire(THREE, { heightAt }); campfireDemo.userData.update(1.0);
```
-Rules: ≤ 3 shadow-casting lights per scene (the sun + 1–2 heroes); decorative lights get
+Rules: shadows come from the sun and the hero lights only; decorative lights get
`castShadow = false` and distance-limited falloff.
Placement is MEASURED (`check_placement`; the `scene_placement` gate runs on every build): each
@@ -847,13 +846,11 @@ bloom + a grade that is identity unless `scene.userData.grade` is set), and the
still read without it (`emissiveIntensity` ≤ 3, no white-out). Do not build an
`EffectComposer`: nothing reads one exported from `scene.js`.
-## Performance budget
+## Performance
-* ≤ 2 M triangles, ≤ 200 draw calls, ≤ 40 materials, ≤ 3 shadow-casting lights; anything
- placed > 5 × is an InstancedMesh, static one-material clutter is `mergeGeometries`.
-* Ground ≤ 160² segments; trees 300–800 tris each (instanced), hero assets ≤ 40 k;
- `update` < 4 ms (cache lists, mutate in place, no per-frame allocation).
-* `scene_probe` reports draws/tris/fps — run it before polishing. Under 20 fps the usual
+* Anything placed > 5 × is an InstancedMesh, static one-material clutter is `mergeGeometries`.
+* `update` caches lists, mutates in place, allocates nothing per frame.
+* `scene_probe` reports draws/tris/fps — run it before polishing. When it is slow the usual
criminals are un-instanced repeats, per-frame `traverse`, and 4096² shadow maps.
## Pitfalls (symptom → cause → fix)
@@ -869,7 +866,7 @@ still read without it (`emissiveIntensity` ≤ 3, no white-out). Do not build a
5. **Shadow acne / peter-panning** → `sun.shadow.bias = -0.0005`, keep mapSize 2048.
6. **`Math.random()` anywhere** → different geometry every build; renders not reproducible;
use `rand(i)` hashes with explicit seeds.
-7. **fps < 20** → count draw calls first (`scene_probe`); the usual criminals: hundreds of
+7. **Low fps** → count draw calls first (`scene_probe`); the usual criminals: hundreds of
Meshes that should be instances, per-frame `traverse`, 4096 shadow maps, fog off with a
500 m far plane.
8. **Fog hides everything** → `Fog(near, far)` in metres — near 45/far 160 for a 100 m
@@ -923,12 +920,9 @@ function sceneSelfcheck(THREE, scene, cameras) {
tris += n * (o.isInstancedMesh ? o.count : 1);
}
});
- if (tris > 2e6) throw new Error(`tri budget blown: ${tris}`);
- if (draws > 200) throw new Error(`draw calls: ${draws} > 200`);
- if (shadowLights > 3) throw new Error(`${shadowLights} shadow lights (max 3)`);
if (!scene.fog) throw new Error('scene.fog not set');
if (!cameras || cameras.length < 2) throw new Error('need 3-5 cameras');
- console.log(`[selfcheck] draws=${draws} tris=${Math.round(tris)} lights=${lights} cameras=${cameras.length}`);
+ console.log(`[selfcheck] draws=${draws} tris=${Math.round(tris)} lights=${lights} shadowLights=${shadowLights} cameras=${cameras.length}`);
}
const demoScene = new THREE.Scene(); buildEnv({ THREE, scene: demoScene });
demoScene.add(forestDemo, coverDemo, campfireDemo, ff);
@@ -947,7 +941,6 @@ Composition self-check on every authored frame (the judge grades exactly these):
Then: `build` → `check_placement` (floating/sunken/interpenetration + the fix per asset) → `scene_probe` (draws/tris/fps/console) → `scene_views` (authored cameras +
overview rig, with `camera_checks`) → `shader_probe` if you wrote GLSL → fix the worst →
-repeat. Look at every camera's frame AND its numbers: `mean_lum` ≥ 0.15 (no black frames),
-`blown_frac` ≤ 0.10 (no white-out), `content_frac` ≥ 0.25 on the establishing shot (the
-subject, not sky/ground, fills the frame), `camera_in_geometry` false, and `check_placement`
+repeat. Look at every camera's frame AND its numbers: no black frames, no white-out, the
+subject (not sky/ground) fills the establishing shot, `camera_in_geometry` false, and `check_placement`
clean (nothing floating, sunken or interpenetrating).
diff --git a/harness/codeverse3d/prompts/threejs/cookbook.md b/harness/codeverse3d/prompts/threejs/cookbook.md
index 4a14b6e7..c133bce2 100644
--- a/harness/codeverse3d/prompts/threejs/cookbook.md
+++ b/harness/codeverse3d/prompts/threejs/cookbook.md
@@ -336,8 +336,7 @@ handrail.name = 'Handrail';
// --- the density check: what would tell a photo of the real thing from this?
// "edges are perfectly sharp" -> RoundedBoxGeometry / bevelEnabled. "one flat face" -> panelLines.
// "no fixings" -> instanceRing. "repeats are identical" -> repeatMerged with jitter/tilt/scale.
-// "all one grey" -> split the materials. Then count: `measure` prints the triangle total —
-// under the detail budget's floor means nothing has been detailed yet.
+// "all one grey" -> split the materials. Then count: `measure` prints the triangle total.
const density = [spokes, bolts, housing, handrail];
let densityTris = 0;
for (const o of density) o.traverse((m) => { if (m.isMesh) densityTris += (m.geometry.index ? m.geometry.index.count : m.geometry.attributes.position.count) / 3 * (m.count || 1); });
@@ -461,7 +460,6 @@ export function selfcheck(THREE, root, expectedNames = [], extentsHint = null) {
if (missing.length) throw new Error(`missing parts: ${missing.join(', ')}`);
const box = new THREE.Box3().setFromObject(root); const size = box.getSize(new THREE.Vector3());
if (Math.abs(box.min.y) > 0.002) throw new Error(`lowest point y=${box.min.y.toFixed(4)} (expected 0)`);
- if (tris > 600000) throw new Error(`too many triangles: ${tris}`);
if (extentsHint) extentsHint.forEach((e, i) => { if (Math.abs(size.getComponent(i) - e) > 0.05) throw new Error(`extents ${size.toArray()} vs plan ${extentsHint}`); });
console.log(`[selfcheck] parts=${names.size} tris=${tris} extents=${size.toArray().map(v => v.toFixed(3))}`);
return { tris, size };