Desk Lamp

showcase/desk-lamp/

A procedural balanced-arm desk lamp — stepped cast base, swivel turret, two parallelogram arm sections pinned through knuckle bosses with knurled tension knobs, three extension springs hung on cross bars, a domed enamel shade with a rolled rim, reflector and glowing lamp, a draped flex and a cable to a plug — through UVs, bake, LOD, collider, and Unity glTF, asserting recomputed budgets rather than an API contract.

Rendered headless by the showcase piece itself. Select it to enlarge.

witnesses Recomputed: 30110 tris, six materials with 3972 enamel, 9210 steel, 348 bulb, 1508 rubber, 622 reflector and 384 bakelite faces, UVs in 0..1 with zero AABB overlap, outer AABB 0.725×0.361×0.442 m, zmin 0, hygiene 0 including zero coplanar cross-shell pairs, all 7 joint pins coaxial with the 23 eyes and bosses they pass through (offset 0.000 mm, band 0.3 mm), all 6 spring loops centred on their bars' axes (band 0.6 mm), mass centre 39.6 mm inside the base footprint (floor 25 mm), base 0.180 m square, arm sections 0.320 and 0.360 m pin to pin, one connected assembly of 78 shells, LOD ratios in band, collider 472 tris, non-empty glTF. --skip-decimate exits 9; --stray-vert 15; --lift-z 16; --offset-pin 17; --unhook-spring 18; --hollow-base 19; --unscrew-bulb 20.

category Household

tags mesh export showcase

blender --background --python showcase/desk-lamp/desk_lamp.py --

A showcase piece, not an example, and the first in the household category. It builds a procedural balanced-arm architect's lamp in the classic Anglepoise pattern:

The linkage is solved from named stations (arm_stations()): the lower and upper rods run at 72° and −10°, each section's second rod is offset by the same 30 mm link vector, and the shade hangs on its own pin at 50° below horizontal. Every pin, eye, bar and spring is placed from those stations, so moving one angle moves the whole arm consistently.

Two things the coplanar budget forced:

The cable is a Catmull-Rom spline through floor points. Between points the spline dipped 0.3 mm through the desk and grounded the whole piece on the cable, so the base stood 0.3 mm in the air. The cable is now clamped to rest on the desk, and the base and plug are what reach Z = 0.

Shading follows what each part is. Round stock (rods, springs, flex, shade, lamp) is smooth-shaded. Treads, chamfers and knurls stay crisp through sharp edges above 35° and at every material boundary. The enamel is a deep glossy red with a clear coat. The springs, pins and knobs are plated steel, rough enough to catch the key rather than mirror a black stage.

It asserts budget conformance of the generated result. It does not witness an API contract. "It rendered without error" is not a check.

Composes skills mesh-editing-and-bmesh, bake-high-to-low, depsgraph-and-evaluated-data, engine-export-presets, and snippets bake_normal_high_to_low.py, setup_bake_target_image.py, lod_chain.py / decimate_to_budget.py, convex_hull_collider.py, export_preset_unity.py (helpers copied inline, not imported).

Intended size: a 0.18 m square base, 0.32 m and 0.36 m arm sections, and a shade 0.17 m across the rim. The outer AABB is 0.725 × 0.361 × 0.442 m. The shade rim sets +X, the plug sets −X and −Y, and the elbow knuckle sets the top. The origin is under the base centre, so the lamp drops onto a desk by its base.

Budgets#

Every budget is declared as a named constant. Every gate recomputes its value from the mesh, materials, UVs, evaluated LOD, collider, or export file.

AxisDeclaredMeasured (5.2.1)
Base triangles29000–3150030110
LOD1 ratio0.32–0.62 of base0.5000
LOD2 ratio0.10–0.35 of base0.2200
Materialsexactly 6 distinct; ≥3600 enamel, ≥8300 steel, ≥310 bulb, ≥1350 rubber, ≥560 reflector, ≥340 bakelite faces6 slots; 3972 / 9210 / 348 / 1508 / 622 / 384
UVsin 0..1, AABB overlap ≤ 1e-5in range, overlap 0
Outer AABB(0.725, 0.361, 0.442) m ± 0.01(0.7252, 0.3606, 0.4421), zmin 0
Collider tris≤ 760472
Exportwritten, size > 0, removed after measuring2217452 / 2217452 / 2217444 bytes (4.5.11 / 5.1.2 / 5.2.1)

The triangle band is wide enough to hold --hollow-base (30974) and --unhook-spring (29790), so those falsifiers exit on their own budgets rather than on the triangle count.

DECIMATE COLLAPSE triangle counts are not identical across Blender series, so the LOD gate is a ratio band, not an exact count. Bake pixels are stochastic, so the bake gate is has_data plus operator FINISHED, not byte-identity. Construction uses no RNG; two default runs print identical measurements.

Hygiene#

Recomputed from the generated mesh, not asserted about the script.

AxisDeclaredMeasured
Non-manifold edges00
Loose verts / edges0 / 00 / 0
Doubles merged at 1e-500
Zero-area faces00
N-gons00
Coplanar cross-shell face pairs (KD range 0.05 m, plane ε 1e-4)00
Grounded: zminwithin 1e-4 of 00.0000

Joint pins, springs, stance and assembly#

AxisDeclaredMeasured
Joint pins: for each of the 7 pins (axis by PCA), the XZ offset from its axis to the axis of every eye and boss within 12 mm, taken at that eye's own station≤ 0.0003 m; 7 pins, 23 eyes and bosses, ≥ 3 per pin; each pin spans every one of them in Y; pin tilt ≤ 0.5°0.000000; 7 pins, 23 (3, 3, 4, 4, 3, 3, 3); 0 not through; 0.000°
Spring seat: for each of the 6 looped ends, distance from its centre to the axis of the nearest bar, within that bar's length; each coil's wire runs into exactly 2 loops≤ 0.0006 m; 3 coils, 6 loops, 4 bars0.000000; ends [2, 2, 2]
Stance: mass centre (shell volumes × density per material) inside the base footprint read off the mesh≥ 0.025 m inside every edge0.0396 (11.76 kg, centre at x 0.0504)
Base width0.180 m ± 0.003 each way0.1800 × 0.1800
Arm sections, pin to pin (both rods of each)0.320 / 0.360 m ± 0.0030.3200, 0.3200 / 0.3600, 0.3600
One connected assembly (union of shells whose BVH trees overlap)1 component1 (78 shells)

A balanced-arm lamp whose shade rim reaches nearly 0.6 m past its pivot stands only because its base is heavy. The stance budget tests exactly that: the densities are named constants (steel and cast iron 7850, bakelite 1400, rubber 1200, and 300 for the lamp, whose glass is modelled solid but is a hollow envelope), and the volumes come from the mesh.

Falsifiers#

Each falsifier violates one named budget. Every one was run on 5.2.1 and exited its declared code. None moves the envelope: every run measured the same outer AABB as the default.

FlagBudget violatedExit
--skip-decimateLOD1 ratio band (measured 1.0000)9
--stray-vertloose vertex count is 0 (measured 1, placed inside the envelope)15
--lift-zbounding box zmin is 0 (measured 0.05000)16
--offset-pinjoint pins coaxial (elbow pin moved 2.5 mm off its eyes: offset 0.00250 m)17
--unhook-springspring seat (one loop 10 mm short of its bar: 0.01000 m)18
--hollow-basestance (base pressed from 1.5 mm steel: 3.22 kg, centre at x 0.184, margin −0.094 m)19
--unscrew-bulbone connected assembly (lamp backed 5 mm out of its socket: 2 components)20

--offset-pin still leaves the pin inside every eye it passes through, and the arm lengths it moves (0.3208, 0.3575 m) stay inside their tolerance, so only the coaxial budget sees it. --unhook-spring leaves the spring hanging from its lower bar, so the assembly stays connected. --hollow-base keeps the outer loft, so the envelope and footprint are unchanged and only the mass moves.

Run#

blender --background --python desk_lamp.py --
blender --background --python desk_lamp.py -- --skip-decimate
blender --background --python desk_lamp.py -- --stray-vert
blender --background --python desk_lamp.py -- --lift-z
blender --background --python desk_lamp.py -- --offset-pin
blender --background --python desk_lamp.py -- --unhook-spring
blender --background --python desk_lamp.py -- --hollow-base
blender --background --python desk_lamp.py -- --unscrew-bulb
blender --background --python desk_lamp.py -- --output lamp.png

Smoke passes no flags.

The hero turns the piece HERO_YAW_DEG (−95°). The reach then points to the camera's right and toward it, so the parallelogram reads in depth and the shade's mouth shows the lit lamp. A small point light just inside the mouth stands in for the lamp's light and lights the reflector. It is render-only, like the stage. The wall stands 2.6 m behind the lamp, and the warm wedge pools on it behind the shade.

Exit codes#

File-local. 9 is a valid check code. 10 is reserved for gallery_framing.check_framing on the --output path. 15–19 are the hygiene and joint-fit family. 20 is file-local. 21 is the asset-quality floor on the render path: check_asset_quality returns 11, which this piece already spends on the collider ceiling, so the call site remaps it.

CodeMeaning
0Success
1Uncaught exception (FATAL wrapper)
2argparse / usage
3Mesh did not build / no UV layer
4Base triangle count outside range
5Material count ≠ 6 distinct slots, or a face-count floor missed
6UVs outside 0..1
7UV AABB overlap above tolerance
8World AABB off declared outer size
9LOD ratio band (--skip-decimate lands here)
10Framing gate (render path only)
11Collider triangle count above ceiling
12Bake did not finish or image has no data
13Export file missing or empty
14--output produced no file
15Mesh hygiene: loose, non-manifold, zero-area, doubles, n-gons, coplanar cross-shell pairs
16Not grounded: bounding box zmin off 0
17Joint pins: a pin off the axis of an eye or boss it joins, not spanning one, tilted, or not 7 pins and 23 eyes (--offset-pin)
18Spring seat: a looped end off its bar's axis or length, or a coil not running into two loops, or not 3 coils, 6 loops and 4 bars (--unhook-spring)
19Stance and size: mass centre within 25 mm of the base's edge, base width, or an arm section's length (--hollow-base)
20Assembly splits into more than one connected component (--unscrew-bulb)
21Asset-quality floor (render path only; remapped from 11)

Source

showcase/desk-lamp/desk_lamp.py View the script on GitHub →
A red balanced-arm desk lamp on a dark studio floor: stepped base, parallel-rod arms with chrome springs and knobs, and a domed shade whose white reflector frames a glowing bulb.