Skip to content

Official Codebase of 3DCodeVerse

Python

Delete scene_blender's plan-less example scene; cover keyframes and VolumeBox fog in the fixture instead

gaoypeng5157e830d426
diff --git a/harness/codeverse3d/languages/scene_blender/__init__.py b/harness/codeverse3d/languages/scene_blender/__init__.py
index f7a21fdb..4f23da46 100644
--- a/harness/codeverse3d/languages/scene_blender/__init__.py
+++ b/harness/codeverse3d/languages/scene_blender/__init__.py
@@ -368,8 +368,6 @@ def lint(ws: Workspace) -> GateReport:
return GateReport.of(GATE, findings, duration_ms=int((time.monotonic() - t0) * 1000))
-# ===================================================================== starter tree
-STARTER_DIR = Path(__file__).resolve().parent / "starter" / "src"
ENV_FILE = "src/env.py"
@@ -399,22 +397,6 @@ def _put(path: Path, text: str, written: list[Path]) -> None:
written.append(path)
-def write_example(ws: Workspace) -> list[Path]:
- """Write the plan-less starter scene (``starter/src/**/*.py``) into ``ws.src``; raises when the
- starter tree is missing (an rglob over an absent directory would silently write nothing)."""
- if not STARTER_DIR.is_dir():
- raise FileNotFoundError(
- f"scene_blender starter tree missing: {STARTER_DIR} — this install has no package data "
- f"(a non-editable install needs [tool.setuptools.package-data] to ship languages/**/starter/**/*)")
- written: list[Path] = []
- for src in sorted(STARTER_DIR.rglob("*.py")):
- _put(ws.src / src.relative_to(STARTER_DIR), src.read_text(), written)
- if not written:
- raise FileNotFoundError(f"scene_blender starter tree at {STARTER_DIR} contains no .py files")
- (ws.public / "assets").mkdir(parents=True, exist_ok=True)
- return written
-
-
# ===================================================================== skeleton
def _v(v: Sequence[float], *, extents: bool = False) -> tuple[float, float, float]:
return tuple(round(c, 3) for c in to_authoring_frame(v, LANGUAGE.value, extents=extents))
@@ -609,9 +591,9 @@ CAMERAS = [
def write_skeleton(ws: Workspace, plan: Plan | None = None) -> list[Path]:
- """Starter files for a scene plan; without a plan the complete example scene."""
+ """Starter files for a scene plan; none without one."""
if plan is None:
- return write_example(ws)
+ return []
if not isinstance(plan, ScenePlan):
raise TypeError(f"scene_blender needs a ScenePlan, got {type(plan).__name__}")
written: list[Path] = []
diff --git a/harness/codeverse3d/languages/scene_blender/starter/src/assets/crate.py b/harness/codeverse3d/languages/scene_blender/starter/src/assets/crate.py
deleted file mode 100644
index 217eef19..00000000
--- a/harness/codeverse3d/languages/scene_blender/starter/src/assets/crate.py
+++ /dev/null
@@ -1,44 +0,0 @@
-"""src/assets/crate.py — asset "Crate": a slatted wooden crate, 0.9 m, corner posts and boards.
-
-CONTRACT: build_crate(ctx, variant=0) -> bpy.types.Collection — link every part into ctx.collection
- (named 'Crate'), built ONCE at the origin with its base on z = 0, front facing -Y. Zones place
- collection instances of it (ctx.assets['crate']); never link it anywhere else. An asset module is
- self-contained: it is built and checked without `env`.
-"""
-import bmesh
-import bpy
-
-SIZE = 0.9
-
-
-def _box(bm, center, size):
- geom = bmesh.ops.create_cube(bm, size=1.0)["verts"]
- bmesh.ops.scale(bm, vec=size, verts=geom)
- bmesh.ops.translate(bm, vec=center, verts=geom)
-
-
-def build_crate(ctx, variant=0):
- wood = bpy.data.materials.new("CrateWood")
- bsdf = wood.node_tree.nodes["Principled BSDF"]
- bsdf.inputs["Base Color"].default_value = (0.54, 0.42, 0.25, 1.0)
- bsdf.inputs["Roughness"].default_value = 0.8
- s = SIZE * (1.0 + 0.08 * (variant % 3))
- post, slat = 0.06, 0.05
- rim = s * 0.87 + 0.14 # the top slat's top: the posts reach it, so a stacked crate rests on all four corners
- bm = bmesh.new()
- for sx in (-1, 1):
- for sy in (-1, 1):
- _box(bm, (sx * (s / 2 - post / 2), sy * (s / 2 - post / 2), rim / 2), (post, post, rim))
- for k in range(4): # three slats per side, a gap between them
- z = s * (0.12 + 0.25 * k) + 0.07
- for sy in (-1, 1):
- _box(bm, (0.0, sy * (s / 2 - slat / 2), z), (s - 2 * post, slat, 0.14))
- for sx in (-1, 1):
- _box(bm, (sx * (s / 2 - slat / 2), 0.0, z), (slat, s - 2 * post, 0.14))
- _box(bm, (0.0, 0.0, 0.025), (s - 0.02, s - 0.02, 0.05)) # the floor board
- me = bpy.data.meshes.new("Crate")
- bm.to_mesh(me)
- bm.free()
- me.materials.append(wood)
- ctx.collection.objects.link(bpy.data.objects.new("Crate", me))
- return ctx.collection
diff --git a/harness/codeverse3d/languages/scene_blender/starter/src/assets/lantern_post.py b/harness/codeverse3d/languages/scene_blender/starter/src/assets/lantern_post.py
deleted file mode 100644
index 6a645a30..00000000
--- a/harness/codeverse3d/languages/scene_blender/starter/src/assets/lantern_post.py
+++ /dev/null
@@ -1,60 +0,0 @@
-"""src/assets/lantern_post.py — asset "LanternPost": a 2.4 m timber post with a bracket arm and a
-glowing paper lantern, plus the light it throws.
-
-CONTRACT: build_lantern_post(ctx, variant=0) -> bpy.types.Collection — built ONCE at the origin
- with its base on z = 0; zones place collection instances (ctx.assets['lantern_post']). A lamp
- inside the collection is instanced with it, so every post lights its own patch.
-"""
-import bmesh
-import bpy
-from mathutils import Matrix
-
-
-def _principled(name, rgb, roughness=0.8, emission=0.0):
- mat = bpy.data.materials.new(name)
- bsdf = mat.node_tree.nodes["Principled BSDF"]
- bsdf.inputs["Base Color"].default_value = (*rgb, 1.0)
- bsdf.inputs["Roughness"].default_value = roughness
- if emission:
- bsdf.inputs["Emission Color"].default_value = (*rgb, 1.0)
- bsdf.inputs["Emission Strength"].default_value = emission
- return mat
-
-
-def _beam(bm, start, end, radius, slot, sides=8):
- """A cylinder from `start` to `end` (vertical, or horizontal along X), its faces on material `slot`."""
- sx, sy, sz = start
- ex, ey, ez = end
- length = ((ex - sx) ** 2 + (ey - sy) ** 2 + (ez - sz) ** 2) ** 0.5
- geom = bmesh.ops.create_cone(bm, segments=sides, radius1=radius, radius2=radius, depth=length, cap_ends=True)["verts"]
- faces = {f for v in geom for f in v.link_faces}
- if abs(ez - sz) < 1e-6: # a horizontal arm: lie the cylinder along X
- bmesh.ops.rotate(bm, cent=(0, 0, 0), matrix=Matrix.Rotation(1.5707963, 3, "Y"), verts=geom)
- bmesh.ops.translate(bm, vec=((sx + ex) / 2, (sy + ey) / 2, (sz + ez) / 2), verts=geom)
- for f in faces:
- f.material_index = slot
-
-
-def build_lantern_post(ctx, variant=0):
- wood = _principled("PostWood", (0.23, 0.16, 0.10), roughness=0.85)
- glow = _principled("LanternGlow", (1.0, 0.70, 0.44), roughness=0.6, emission=5.0)
- bm = bmesh.new()
- _beam(bm, (0.0, 0.0, 0.0), (0.0, 0.0, 2.4), 0.06, 0) # the post
- _beam(bm, (0.0, 0.0, 2.3), (0.45, 0.0, 2.3), 0.035, 0, sides=6) # the bracket arm
- lantern = bmesh.ops.create_cube(bm, size=1.0)["verts"] # the paper lantern, hung from the arm's end
- bmesh.ops.scale(bm, vec=(0.26, 0.26, 0.34), verts=lantern)
- bmesh.ops.translate(bm, vec=(0.45, 0.0, 2.05), verts=lantern)
- for f in {f for v in lantern for f in v.link_faces}:
- f.material_index = 1
- me = bpy.data.meshes.new("LanternPost")
- bm.to_mesh(me)
- bm.free()
- me.materials.append(wood)
- me.materials.append(glow)
- ctx.collection.objects.link(bpy.data.objects.new("LanternPost", me))
- light = bpy.data.lights.new("LanternPostLight", "POINT") # the glow is the look; the lamp is the light
- light.energy, light.color, light.shadow_soft_size = 25.0, (1.0, 0.70, 0.44), 0.25
- lamp = bpy.data.objects.new("LanternPostLight", light)
- lamp.location = (0.45, 0.0, 1.85)
- ctx.collection.objects.link(lamp)
- return ctx.collection
diff --git a/harness/codeverse3d/languages/scene_blender/starter/src/env.py b/harness/codeverse3d/languages/scene_blender/starter/src/env.py
deleted file mode 100644
index 6edb59ff..00000000
--- a/harness/codeverse3d/languages/scene_blender/starter/src/env.py
+++ /dev/null
@@ -1,119 +0,0 @@
-"""src/env.py — the environment of the EXAMPLE scene (a lakeside hamlet): a low warm sun, rolling
-meadow beyond a level pad, a lake basin, haze. The landform is this example's, not a rule.
-
-Frame: Z up, -Y front, metres.
-CONTRACT: height_at(x, y) -> z is THE ground: the terrain mesh and every zone's seat use it.
- build_env(ctx) -> dict builds the world, lamps, ground and atmosphere into ctx.collection and
- returns what zones may share (materials, water level, sun direction ...) — they read it as
- ctx.env. Code the zones share (`material`, `linked`, `seat`) lives here: `from env import ...`.
-"""
-import math
-
-import bmesh
-import bpy
-
-GROUND_SIZE = 160.0
-FLAT_RADIUS = 44.0 # THIS example's landform: level under its hamlet, hills beyond — one landform among many; yours is the brief's
-SUN_AZIMUTH_DEG = 215.0 # compass angle of the sun: 0 = +X, 90 = +Y (the sky and the lamp share it)
-SUN_ELEVATION_DEG = 22.0
-BASIN = (-24.0, 2.0, 15.0, 1.2) # the lake's (x, y, radius, depth): zones/lakeside.py fills it to WATER_LEVEL
-WATER_LEVEL = -0.3
-
-
-def _smooth(t):
- t = max(0.0, min(1.0, t))
- return t * t * (3.0 - 2.0 * t)
-
-
-def height_at(x, y):
- """z of the ground at (x, y): level inside FLAT_RADIUS, rolling hills beyond, minus a smooth-rimmed bowl under the lake."""
- hills = 1.2 * math.sin(x / 23.0) * math.cos(y / 19.0) + 0.8 * math.sin((x + y) / 31.0)
- rise = _smooth((math.hypot(x, y) - FLAT_RADIUS) / 30.0)
- bx, by, br, bd = BASIN
- bowl = bd * (1.0 - _smooth((math.hypot(x - bx, y - by) / br - 0.3) / 0.7)) # a wide rim: banks under 15 % so props seat on them
- return rise * (hills + 2.5 * rise) - bowl
-
-
-def material(name, rgb, roughness=0.8, noise_scale=3.0, darker=0.6):
- """A Principled material varied at two scales: a noise mixes `rgb` with a darker tone over metres and bumps it over centimetres."""
- mat = bpy.data.materials.new(name)
- nodes, links = mat.node_tree.nodes, mat.node_tree.links
- bsdf = nodes["Principled BSDF"]
- bsdf.inputs["Roughness"].default_value = roughness
- tone = nodes.new("ShaderNodeTexNoise")
- tone.inputs["Scale"].default_value = noise_scale * 0.1
- mix = nodes.new("ShaderNodeMix")
- mix.data_type = "RGBA"
- mix.inputs[6].default_value = (*rgb, 1.0)
- mix.inputs[7].default_value = (*(c * darker for c in rgb), 1.0)
- links.new(tone.outputs["Fac"], mix.inputs["Factor"])
- links.new(mix.outputs[2], bsdf.inputs["Base Color"])
- grain = nodes.new("ShaderNodeTexNoise")
- grain.inputs["Scale"].default_value = noise_scale * 12.0
- bump = nodes.new("ShaderNodeBump")
- bump.inputs["Strength"].default_value = 0.12
- links.new(grain.outputs["Fac"], bump.inputs["Height"])
- links.new(bump.outputs["Normal"], bsdf.inputs["Normal"])
- return mat
-
-
-def linked(ctx, name, bm, *mats):
- """`bm` as a mesh object named `name` with material slots `mats`, linked into ctx.collection (`bm` is freed)."""
- me = bpy.data.meshes.new(name)
- bm.to_mesh(me)
- bm.free()
- for mat in mats:
- me.materials.append(mat)
- ob = bpy.data.objects.new(name, me)
- ctx.collection.objects.link(ob)
- return ob
-
-
-def seat(ob, height_at, sink=0.0):
- """Rest a root built with its base on local z = 0 on the ground: the lowest ground under its footprint corners, minus `sink`."""
- r = max(ob.dimensions.x, ob.dimensions.y) / 2.0 if ob.type == "MESH" else 0.5
- x, y = ob.location.x, ob.location.y
- ob.location.z = min(height_at(x + dx, y + dy) for dx in (-r, 0.0, r) for dy in (-r, 0.0, r)) - sink
- return ob
-
-
-def build_env(ctx):
- world = bpy.data.worlds.new("GoldenHour")
- ctx.scene.world = world
- nodes, links = world.node_tree.nodes, world.node_tree.links
- sky = nodes.new("ShaderNodeTexSky")
- sky.sky_type = "MULTIPLE_SCATTERING"
- sky.sun_disc = False # the Sun lamp below casts the shadows: one sun, not two
- sky.sun_elevation = math.radians(SUN_ELEVATION_DEG)
- sky.sun_rotation = math.radians(SUN_AZIMUTH_DEG)
- sky.aerosol_density = 2.5
- nodes["Background"].inputs["Strength"].default_value = 0.35
- links.new(sky.outputs["Color"], nodes["Background"].inputs["Color"])
-
- sun = bpy.data.lights.new("Sun", "SUN")
- sun.energy, sun.color, sun.angle = 3.5, (1.0, 0.79, 0.54), math.radians(1.5)
- lamp = bpy.data.objects.new("Sun", sun) # a Sun shines down its own -Z
- lamp.rotation_euler = (math.radians(90.0 - SUN_ELEVATION_DEG), 0.0, math.radians(SUN_AZIMUTH_DEG + 90.0))
- ctx.collection.objects.link(lamp)
- el, az = math.radians(SUN_ELEVATION_DEG), math.radians(SUN_AZIMUTH_DEG)
- towards_sun = (math.cos(el) * math.cos(az), math.cos(el) * math.sin(az), math.sin(el))
-
- ground_mat = material("GroundMat", (0.31, 0.37, 0.22), roughness=0.92, noise_scale=5.0)
- bm = bmesh.new()
- bmesh.ops.create_grid(bm, x_segments=112, y_segments=112, size=GROUND_SIZE / 2) # size is the half-side
- for v in bm.verts:
- v.co.z = height_at(v.co.x, v.co.y)
- linked(ctx, "Ground", bm, ground_mat)
-
- haze = bpy.data.materials.new("Haze") # volume-only: the atmosphere the probe requires
- nodes = haze.node_tree.nodes
- nodes.remove(nodes["Principled BSDF"])
- vol = nodes.new("ShaderNodeVolumePrincipled")
- vol.inputs["Density"].default_value = 0.0025
- vol.inputs["Color"].default_value = (0.85, 0.78, 0.66, 1.0)
- haze.node_tree.links.new(vol.outputs["Volume"], nodes["Material Output"].inputs["Volume"])
- bm = bmesh.new()
- bmesh.ops.create_cube(bm, size=1.0)
- bmesh.ops.scale(bm, vec=(GROUND_SIZE, GROUND_SIZE, 24.0), verts=bm.verts)
- linked(ctx, "Atmosphere", bm, haze).location.z = 12.0
- return {"ground_material": ground_mat, "sun_direction": towards_sun, "water_level": WATER_LEVEL}
diff --git a/harness/codeverse3d/languages/scene_blender/starter/src/scene.py b/harness/codeverse3d/languages/scene_blender/starter/src/scene.py
deleted file mode 100644
index 11f5d551..00000000
--- a/harness/codeverse3d/languages/scene_blender/starter/src/scene.py
+++ /dev/null
@@ -1,25 +0,0 @@
-"""src/scene.py — ASSEMBLED BY THE HARNESS (codeverse3d assembler). Edit env / zones / assets
-instead; re-assembly overwrites this file.
-EXAMPLE: a lakeside hamlet at golden hour — the plan-less starter scene.
-
-The harness builds the scene in one Blender process: env.build_env(ctx); every hero GLB and asset
-module (build_<snake>(ctx)); then every zone's build(ctx) — each on its own (a zone that raises is
-dropped and reported with its file:line); then the CAMERAS below (Z up, -Y front, metres; fov is
-the VERTICAL field of view in degrees). The census is the t = 0 pose, frame 1.
-"""
-
-ZONES = {
- "hamlet": "Hamlet",
- "lakeside": "Lakeside",
- "orchard": "Orchard",
-}
-ASSETS = {
- "crate": "Crate",
- "lantern_post": "LanternPost",
-}
-HEROES = {}
-CAMERAS = [
- {"name": "village_street", "location": (1.0, -22.0, 1.8), "look_at": (3.0, 10.0, 1.6), "fov": 42},
- {"name": "lake_shore", "location": (-4.0, -24.0, 2.4), "look_at": (-24.0, 4.0, 0.2), "fov": 48},
- {"name": "orchard_walk", "location": (36.0, -30.0, 2.2), "look_at": (20.0, -10.0, 1.2), "fov": 45},
-]
diff --git a/harness/codeverse3d/languages/scene_blender/starter/src/zones/hamlet.py b/harness/codeverse3d/languages/scene_blender/starter/src/zones/hamlet.py
deleted file mode 100644
index c6c65413..00000000
--- a/harness/codeverse3d/languages/scene_blender/starter/src/zones/hamlet.py
+++ /dev/null
@@ -1,67 +0,0 @@
-"""src/zones/hamlet.py — zone "Hamlet": two gabled houses around a yard, lantern posts, a signpost
-and a few crates.
-
-CONTRACT: build(ctx) -> bpy.types.Collection — ctx.collection is this zone's; every PLACED thing
-is ONE root object in it (a mesh, a collection-instance Empty), named <Name>_<i>, seated on
-ctx.height_at. Assets are collection instances of ctx.assets['<snake>'].
-"""
-import bmesh
-import bpy
-from env import linked, material, seat
-
-SEED = 11
-HOUSES = ((-2.0, 14.0, 7.0, 5.5, 2), (9.5, 15.0, 6.0, 5.0, 1)) # x, y, width, depth, floors
-
-
-def _house(ctx, name, x, y, w, d, floors, wall, tile):
- """A box of `floors` storeys under a gabled roof: one mesh, two material slots, base on local z = 0."""
- h = 2.8 * floors
- bm = bmesh.new()
- body = bmesh.ops.create_cube(bm, size=1.0)["verts"]
- bmesh.ops.scale(bm, vec=(w, d, h), verts=body)
- bmesh.ops.translate(bm, vec=(0.0, 0.0, h / 2), verts=body)
- rise, eave = 0.45 * w, 0.35
- v = [bm.verts.new(p) for p in ((-w / 2 - eave, -d / 2 - eave, h), (w / 2 + eave, -d / 2 - eave, h), (w / 2 + eave, d / 2 + eave, h),
- (-w / 2 - eave, d / 2 + eave, h), (0.0, -d / 2 - eave, h + rise), (0.0, d / 2 + eave, h + rise))]
- roof = [bm.faces.new(f) for f in ((v[0], v[1], v[4]), (v[2], v[3], v[5]), (v[1], v[2], v[5], v[4]), (v[3], v[0], v[4], v[5]))]
- for f in roof:
- f.material_index = 1
- ob = linked(ctx, name, bm, wall, tile)
- ob.location = (x, y, 0.0)
- return seat(ob, ctx.height_at)
-
-
-def build(ctx):
- rng = ctx.rng(SEED)
- wall = material("HamletWall", (0.78, 0.72, 0.60), roughness=0.9, noise_scale=2.0, darker=0.8)
- tile = material("HamletTile", (0.42, 0.25, 0.20), roughness=0.85, noise_scale=4.0)
- timber = material("HamletTimber", (0.26, 0.18, 0.11), roughness=0.75, noise_scale=6.0)
- for i, (x, y, w, d, floors) in enumerate(HOUSES):
- _house(ctx, f"House_{i}", x, y, w, d, floors, wall, tile)
-
- bm = bmesh.new() # the signpost: a post and its board, one mesh
- post = bmesh.ops.create_cone(bm, segments=8, radius1=0.06, radius2=0.06, depth=2.3)["verts"]
- bmesh.ops.translate(bm, vec=(0.0, 0.0, 1.15), verts=post)
- board = bmesh.ops.create_cube(bm, size=1.0)["verts"]
- bmesh.ops.scale(bm, vec=(1.6, 0.06, 0.45), verts=board)
- bmesh.ops.translate(bm, vec=(0.0, 0.0, 2.0), verts=board)
- sign = linked(ctx, "Signpost_0", bm, timber)
- sign.location = (10.0, 6.0, 0.0)
- seat(sign, ctx.height_at)
-
- def instance(source, name, x, y, yaw): # a collection-instance Empty = ONE placement row
- ob = bpy.data.objects.new(name, None)
- ob.instance_type, ob.instance_collection = "COLLECTION", source
- ob.location, ob.rotation_euler = (x, y, ctx.height_at(x, y)), (0.0, 0.0, yaw)
- ctx.collection.objects.link(ob)
- return ob
-
- lantern = ctx.assets.get("lantern_post")
- if lantern is not None:
- for i, (x, y) in enumerate(((-1.0, 4.5), (9.0, 3.5), (12.5, 10.5))):
- instance(lantern, f"LanternPost_{i}", x, y, 0.0)
- crate = ctx.assets.get("crate")
- if crate is not None:
- for i, (x, y) in enumerate(((3.4, 14.3), (5.2, 15.8), (13.4, 13.5))):
- instance(crate, f"Crate_{i}", x, y, rng.uniform(0.0, 1.5))
- return ctx.collection
diff --git a/harness/codeverse3d/languages/scene_blender/starter/src/zones/lakeside.py b/harness/codeverse3d/languages/scene_blender/starter/src/zones/lakeside.py
deleted file mode 100644
index 5e07b373..00000000
--- a/harness/codeverse3d/languages/scene_blender/starter/src/zones/lakeside.py
+++ /dev/null
@@ -1,48 +0,0 @@
-"""src/zones/lakeside.py — zone "Lakeside": the lake in the env's basin, drifting slowly, and shore rocks.
-
-CONTRACT: build(ctx) -> bpy.types.Collection — every placed thing is ONE root object seated on
-ctx.height_at; the water is a water-named surface (the census files it as a backdrop and a foot
-in it as on water).
-"""
-import bmesh
-import bpy
-from env import linked, material
-
-SEED = 21
-LAKE = (-24.0, 2.0) # == env.BASIN's centre
-
-
-def build(ctx):
- rng = ctx.rng(SEED)
- level = float(ctx.env.get("water_level", -0.3))
-
- water = bpy.data.materials.new("LakeWaterMat") # a dielectric: transmission, not metal
- bsdf = water.node_tree.nodes["Principled BSDF"]
- bsdf.inputs["Base Color"].default_value = (0.10, 0.25, 0.29, 1.0)
- bsdf.inputs["Roughness"].default_value = 0.05
- bsdf.inputs["Transmission Weight"].default_value = 1.0
- bm = bmesh.new()
- bmesh.ops.create_grid(bm, x_segments=16, y_segments=16, size=17.0)
- lake = linked(ctx, "LakeWater", bm, water)
- lake.location = (LAKE[0], LAKE[1], level)
- lake.keyframe_insert("location", frame=ctx.frame(0.0)) # the surface drifts 0.3 m between the judged frames
- lake.location.x += 0.3
- lake.keyframe_insert("location", frame=ctx.frame(1.5))
- action = lake.animation_data.action
- for fc in action.layers[0].strips[0].channelbag(action.slots[0]).fcurves:
- for k in fc.keyframe_points:
- k.interpolation = "LINEAR"
-
- rock = material("ShoreRock", (0.44, 0.42, 0.38), roughness=0.95, noise_scale=8.0)
- for i in range(10): # irregular masses along the east bank, part sunk (a rock may)
- r = rng.uniform(0.4, 1.0)
- bm = bmesh.new()
- bmesh.ops.create_icosphere(bm, subdivisions=2, radius=r)
- bmesh.ops.scale(bm, vec=(rng.uniform(0.8, 1.5), rng.uniform(0.7, 1.3), rng.uniform(0.5, 0.8)), verts=bm.verts)
- for v in bm.verts:
- v.co *= 1.0 + 0.12 * (rng.random() - 0.5)
- bmesh.ops.translate(bm, vec=(0.0, 0.0, -min(v.co.z for v in bm.verts)), verts=bm.verts) # base on local z = 0
- ob = linked(ctx, f"Rock_{i}", bm, rock)
- x, y = LAKE[0] + 13.0 + (1.8 if i % 2 else -1.8) + rng.uniform(-0.3, 0.3), LAKE[1] - 9.0 + 2.2 * i # spaced: no two share a box
- ob.location = (x, y, ctx.height_at(x, y) - 0.08 * r) # its lowest vertex is under its centre: a little in, as a rock may
- return ctx.collection
diff --git a/harness/codeverse3d/languages/scene_blender/starter/src/zones/orchard.py b/harness/codeverse3d/languages/scene_blender/starter/src/zones/orchard.py
deleted file mode 100644
index 73817ff4..00000000
--- a/harness/codeverse3d/languages/scene_blender/starter/src/zones/orchard.py
+++ /dev/null
@@ -1,51 +0,0 @@
-"""src/zones/orchard.py — zone "Orchard": a stand of apple trees and harvest crates (instances of
-the crate asset).
-
-CONTRACT: build(ctx) -> bpy.types.Collection — every placed thing is ONE root object seated on
-ctx.height_at.
-"""
-import bmesh
-import bpy
-from env import linked, material, seat
-
-SEED = 31
-CENTER = (20.0, -12.0)
-
-
-def _tree(ctx, name, x, y, height, bark, leaves, rng):
- """A trunk under two overlapping crown lobes: one mesh, two material slots, base on local z = 0."""
- bm = bmesh.new()
- trunk = bmesh.ops.create_cone(bm, segments=8, radius1=0.16, radius2=0.10, depth=height * 0.5)["verts"]
- bmesh.ops.translate(bm, vec=(0.0, 0.0, height * 0.25), verts=trunk)
- for dx, dy, dz, r in ((0.0, 0.0, height * 0.68, height * 0.32), (rng.uniform(-0.6, 0.6), rng.uniform(-0.6, 0.6), height * 0.8, height * 0.24)):
- crown = bmesh.ops.create_icosphere(bm, subdivisions=2, radius=r)["verts"]
- bmesh.ops.scale(bm, vec=(1.15, 1.0, 0.85), verts=crown)
- bmesh.ops.translate(bm, vec=(dx, dy, dz), verts=crown)
- for f in {f for v in crown for f in v.link_faces}:
- f.material_index = 1
- ob = linked(ctx, name, bm, bark, leaves)
- ob.location = (x, y, 0.0)
- ob.rotation_euler.z = rng.uniform(0.0, 6.28)
- return seat(ob, ctx.height_at)
-
-
-def build(ctx):
- rng = ctx.rng(SEED)
- bark = material("OrchardBark", (0.29, 0.21, 0.14), roughness=0.9, noise_scale=6.0)
- leaves = material("OrchardLeaf", (0.31, 0.48, 0.18), roughness=0.7, noise_scale=10.0, darker=0.5)
- i = 0
- for row in range(3): # the planted grid, jittered a little
- for col in range(4):
- x = CENTER[0] - 6.75 + 4.5 * col + rng.uniform(-0.3, 0.3)
- y = CENTER[1] - 4.5 + 4.5 * row + rng.uniform(-0.3, 0.3)
- _tree(ctx, f"AppleTree_{i}", x, y, rng.uniform(3.8, 5.0), bark, leaves, rng)
- i += 1
-
- crate = ctx.assets.get("crate")
- if crate is not None:
- for i, (x, y) in enumerate(((25.0, -21.0), (27.2, -19.4), (29.0, -21.6))):
- ob = bpy.data.objects.new(f"HarvestCrate_{i}", None) # a collection-instance Empty = ONE placement row
- ob.instance_type, ob.instance_collection = "COLLECTION", crate
- ob.location, ob.rotation_euler = (x, y, ctx.height_at(x, y)), (0.0, 0.0, rng.uniform(0.0, 1.5))
- ctx.collection.objects.link(ob)
- return ctx.collection
diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.md
index b80cd99d..757d3469 100644
--- a/harness/docs/ARCHITECTURE.md
+++ b/harness/docs/ARCHITECTURE.md
@@ -102,13 +102,11 @@ codeverse3d/
languages/ LanguageRuntime + RuntimeLayout (base.py: every runtime states its file layout —
expected_files / files_for — and the tracks ask it); one module per language:
blender/ cadquery/ threejs/ urdf/ scene_threejs/ scene_blender/ glsl_shader/ opengl_python/
- are each a single __init__.py (lint → skeleton → runtime) beside their data (starter/,
+ are each a single __init__.py (lint → skeleton → runtime) beside their data (starter/ for scene_threejs,
opengl_python/wrappers/run_gl.py; the contract text is prompts/<lang>/contract.md); wrappers/
holds the python build wrappers (run_bpy, run_bpy_links, run_cq, run_bpy_scene), the
scene_blender render driver (render_bpy_scene) and what they share (_wrapper_common,
_census, _census_glb, _finite — the NaN / inf check on everything a Blender wrapper writes).
- scene_blender/starter/src/ is its example scene (scene.py, env.py, zones/{hamlet, lakeside,
- orchard}.py, assets/{crate, lantern_post}.py)
spatial/ node.py, render.py, observe.py, tool_common.py (shared tool plumbing),
render_scene.py (judge view subset, content-fitted orbit), render_blender.py (scene_blender:
Blender pixels under a GPU slot + CPU fallback, the same metrics.json),
@@ -317,7 +315,7 @@ paste):
```stage-graph
static_object plan → skeleton → materialize* → round 0
articulated_object plan → skeleton → materialize* → round 0
-scene plan → skeleton → materialize* → (assets ∥ env ∥ layouts?) → asset_api* → zones → clock* → assemble → round 0
+scene plan → skeleton → materialize* → (assets ∥ env ∥ layouts?) → clock* → asset_api* → zones → clock* → assemble → round 0
graphics plan → skeleton → materialize* → round 0
```
diff --git a/harness/tests/scene_blender/fixtures.py b/harness/tests/scene_blender/fixtures.py
index e11a07bc..f698e1ea 100644
--- a/harness/tests/scene_blender/fixtures.py
+++ b/harness/tests/scene_blender/fixtures.py
@@ -31,6 +31,17 @@ def build_env(ctx):
bm.free()
ctx.collection.objects.link(bpy.data.objects.new("Ground", me))
ctx.collection.objects.link(bpy.data.objects.new("Sun", bpy.data.lights.new("Sun", "SUN")))
+ haze = bpy.data.materials.new("Haze") # volume-only: the atmosphere (the census files it as a VolumeBox fog)
+ nodes = haze.node_tree.nodes
+ nodes.remove(nodes["Principled BSDF"])
+ vol = nodes.new("ShaderNodeVolumePrincipled")
+ haze.node_tree.links.new(vol.outputs["Volume"], nodes["Material Output"].inputs["Volume"])
+ bm = bmesh.new()
+ bmesh.ops.create_cube(bm, size=40.0)
+ bm.to_mesh(me := bpy.data.meshes.new("AtmosphereBody"))
+ bm.free()
+ me.materials.append(haze)
+ ctx.collection.objects.link(bpy.data.objects.new("Atmosphere", me))
return {}
'''
@@ -75,6 +86,9 @@ def build(ctx):
wheel.name = "CartWheel_0"
wheel.parent = cart
wheel.matrix_parent_inverse = cart.matrix_world.inverted()
+ cart.keyframe_insert("location", frame=ctx.frame(0.0)) # the Blender 5.2 slotted-action path
+ cart.location.x += 0.3
+ cart.keyframe_insert("location", frame=ctx.frame(1.5))
return ctx.collection
'''
diff --git a/harness/tests/scene_blender/test_build.py b/harness/tests/scene_blender/test_build.py
index fea7806b..661fcf48 100644
--- a/harness/tests/scene_blender/test_build.py
+++ b/harness/tests/scene_blender/test_build.py
@@ -73,6 +73,8 @@ def test_placement_rows_for_sunk_floating_and_free(built) -> None:
assert rows["Crate_3"]["exempt"] == "free" # obj["placement"] = "free" → glTF extras → userData
assert rows["Cart_0"]["zone"] == "Yard" # a parent mesh + child: ONE row
assert "CartWheel_0" not in rows
+ assert res.census["fog"]["type"] == "VolumeBox" # a volume-only cube is the fog
+ assert res.census["bpy"]["drivers_invalid"] == [] and res.census["bpy"]["handlers"] == []
assert [r["name"] for r in rows.values() if r["name"].startswith("GrassPatch")] == ["GrassPatch"]
@@ -84,7 +86,7 @@ def _only_unlit(res) -> None:
def test_the_skeleton_builds_and_passes(tmp_ws) -> None:
- """plan → skeleton → assemble → build: the starter scene fails ONE gate — the placeholder env lights
+ """plan → skeleton → assemble → build: the skeleton fails ONE gate — the placeholder env lights
nothing (`unlit`, an ERROR since D112, so round 0's repair is handed the env) — and passes the rest;
the plan's cameras reach the host."""
plan = ScenePlan.model_validate(plan_example(Track.SCENE))
@@ -142,27 +144,3 @@ def test_a_hero_glb_is_imported_into_ctx_assets(tmp_ws) -> None:
assert res.ok, res.stdout_tail
row = _rows(res)["Windmill_0"]
assert row["zone"] == "Yard" and row["supported"] # a 4 m box centred on z = 2 stands on the ground
-
-
-
-def test_the_example_scene_builds_and_seats_every_root(tmp_ws) -> None:
- """The plan-less starter scene (``write_example``: env, two assets, three zones in plain bpy) lints
- clean, builds through the wrapper, seats every placed root (no floating, no burial past the 10 cm
- WARN, nothing interpenetrating), keeps every driver simple and leaves the render settings alone."""
- from codeverse3d.languages.scene_blender import write_example
-
- rt = _rt()
- write_example(tmp_ws)
- assert rt.lint(tmp_ws).passed, [(f.target, f.message) for f in rt.lint(tmp_ws).findings]
- res = rt.build(tmp_ws)
- assert res.ok, res.stdout_tail
- report = json.loads((tmp_ws.artifacts / "bpy_build.json").read_text())
- assert report["errors"] == [] and sorted(report["zones_ok"]) == ["hamlet", "lakeside", "orchard"], report
- assert res.census["bpy"]["drivers_invalid"] == [] and res.census["bpy"]["handlers"] == []
- rows = _rows(res)
- assert {"House_0", "Signpost_0", "LanternPost_2", "Crate_2", "Rock_9", "AppleTree_11", "HarvestCrate_2"} <= set(rows), sorted(rows)
- for r in rows.values():
- if not r["exempt"]:
- assert r["supported"] and not r["floating"] and r["sunk_m"] <= 0.10, r
- assert res.census["placement"]["interpenetrations"] == []
- assert res.census["fog"] is not None and res.census["light_types"]