Skip to content

Official Codebase of 3DCodeVerse

Python

roomShell: a glazed pane and its frame are thin along the wall's own axis, not the panel's smallest size

gaoypengc406718b1d77
diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/environment.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/environment.js
index 79a4fe4f..c59d0a1e 100644
--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/environment.js
+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/environment.js
@@ -85,9 +85,10 @@ export function roomShell(opts = {}) {
const bars = []; // [cx, cy, cz, sx, sy, sz] per bar
// The frame of one glazed panel: bars on a WORLD lattice (so the grid runs on across
// adjacent panels and around an opening) plus a bar on every panel edge.
- const frame = (sx, sy, sz, x, y, z) => {
+ // `thin` is the slab's thickness axis (0 x, 1 y, 2 z), known from the face — never the smallest
+ // size: a sill or a strip between openings can be narrower than the wall is thick.
+ const frame = (sx, sy, sz, x, y, z, thin) => {
const dims = [sx, sy, sz], c = [x, y, z];
- const thin = dims.indexOf(Math.min(...dims));
const [i, j] = [0, 1, 2].filter((k) => k !== thin);
const step = (k) => (k === 1 ? bayU : bayA);
const lines = (k) => {
@@ -104,15 +105,15 @@ export function roomShell(opts = {}) {
}
}
};
- const slab = (name, sx, sy, sz, x, y, z, mat) => {
+ const slab = (name, sx, sy, sz, x, y, z, mat, thin) => {
if (glazed) {
// one sheet of glass in the slab's mid-plane (a 0.3 m glass BOX is four faces of glass)
const sheet = [sx, sy, sz];
- sheet[sheet.indexOf(Math.min(...sheet))] = 0.02;
+ sheet[thin] = 0.02;
const m = new THREE.Mesh(new THREE.BoxGeometry(...sheet), glassMat);
m.name = name === 'Ceiling' ? 'Roof' : name; m.position.set(x, y, z);
group.add(m);
- frame(sx, sy, sz, x, y, z);
+ frame(sx, sy, sz, x, y, z, thin);
return m;
}
const m = new THREE.Mesh(new THREE.BoxGeometry(sx, sy, sz), mat);
@@ -136,7 +137,7 @@ export function roomShell(opts = {}) {
if (a1 - a0 < 0.01 || b1 - b0 < 0.01) return;
const [x, z] = along(origin + (a0 + a1) / 2);
const sx = f.axis === 'x' ? t : a1 - a0, sz = f.axis === 'x' ? a1 - a0 : t;
- slab(name, sx, b1 - b0, sz, x, y0 + (b0 + b1) / 2, z, wallMat);
+ slab(name, sx, b1 - b0, sz, x, y0 + (b0 + b1) / 2, z, wallMat, f.axis === 'x' ? 0 : 2);
};
if (!holes.length) { place(`Wall_${face}`, 0, f.len, 0, h); continue; }
const clipped = holes.map((o) => ({
@@ -162,7 +163,7 @@ export function roomShell(opts = {}) {
place(`Wall_${face}_${n++}`, a0, a1, bottom, h);
}
}
- if (opts.ceiling !== false) slab('Ceiling', w + 2 * t, t, d + 2 * t, cx, y0 + h + t / 2, cz, ceilMat);
+ if (opts.ceiling !== false) slab('Ceiling', w + 2 * t, t, d + 2 * t, cx, y0 + h + t / 2, cz, ceilMat, 1);
if (bars.length) {
const inst = new THREE.InstancedMesh(new THREE.BoxGeometry(1, 1, 1), frameMat, bars.length);
const m4 = new THREE.Matrix4(), q = new THREE.Quaternion();
diff --git a/harness/tests/scene_runtime/lib/test_room_shell.py b/harness/tests/scene_runtime/lib/test_room_shell.py
index 4ee63d34..e3f46600 100644
--- a/harness/tests/scene_runtime/lib/test_room_shell.py
+++ b/harness/tests/scene_runtime/lib/test_room_shell.py
@@ -93,3 +93,25 @@ def test_a_glazed_shell_is_glass_on_a_frame_grid_that_lets_the_sun_in():
assert got["bars"] > 40 and got["frameShadow"], got
# between the bars the sun reaches the floor; the opaque shell shades all of it
assert got["opaque"] == 1.0 and got["shaded"] < 0.3, got
+
+
+_THIN_PANELS = """
+import * as THREE from 'three';
+import { roomShell } from './lib/environment.js';
+// two south windows 0.1 m apart with 0.2 m sills: a strip and sills narrower than the 0.3 m wall
+const g = roomShell({ center: [0, 5, 0], extents: [20, 10, 16], glazed: true, thickness: 0.3,
+ openings: [{ face: 'south', center: [5, 2.0], size: [2, 3.6] },
+ { face: 'south', center: [7.1, 2.0], size: [2, 3.6] }] });
+const south = g.children.filter((m) => m.name.startsWith('Wall_south')).map((m) => {
+ const s = new THREE.Vector3(); new THREE.Box3().setFromObject(m).getSize(s); return s.toArray(); });
+console.log(JSON.stringify({ south }));
+"""
+
+
+def test_glazed_panes_are_thin_along_the_wall_even_when_narrower_than_it():
+ """/code-review 2026-09-24: the glass (and its frame) took the SMALLEST size as the thickness axis,
+ so a 0.2 m sill became a horizontal plate and a 0.1 m strip a fin through the wall."""
+ got = measure(_THIN_PANELS, ("environment.js", "sky.js"))
+ assert len(got["south"]) >= 5, got
+ assert all(abs(size[2] - 0.02) < 1e-6 for size in got["south"]), got # z is the south wall's thickness
+ assert any(size[0] < 0.3 for size in got["south"]) and any(size[1] < 0.3 for size in got["south"]), got