3D Scene Code Generation: Evaluating LLM Spatial Reasoning with Parametric Acceptance Tests
Parametric 3D scene generation offers a practical way to evaluate whether large language models can satisfy spatial constraints rather than merely produce plausible-looking geometry. This article outlines a text-only evaluation task, parameter-driven modeling requirements, numerical perturbation tests, scoring criteria, and a headless execution pipeline for repeatable assessment.
1. Why Spatial Reasoning Is Becoming a Key Differentiator
As text generation and code completion tasks approach saturation, evaluation is shifting from whether a model can produce an output to whether that output is internally consistent in physical space.
Here, spatial reasoning means constructing the correct relative positions, orientations, and motion-phase relationships between parts from natural-language instructions alone, without reference images or interactive feedback. It tests three capabilities:
- Understanding 3D coordinate systems and rigid-body transformations.
- Modeling dependencies between parameters.
- Verifying that the resulting geometry actually satisfies its constraints.
Traditional 3D generation evaluations often use browser-based rendering libraries to build small scenes, then rely on screenshots for manual comparison. This approach has limitations: scene updates can be asynchronous, parent–child relationships can introduce implicit transformations, and a model can assemble visually similar parts without satisfying the underlying spatial constraints.
A stricter approach uses general-purpose 3D authoring software in headless batch mode. A script handles modeling, materials, and rendering without GUI intervention, allowing spatial errors to surface during execution or in the rendered output.
2. Designing the Task: Narrative Constraints Instead of Reference Images
The evaluation prompt should be a text-only delivery specification. It should explicitly exclude reference images and require a complete script that runs directly in headless batch mode.
A useful scene includes a clearly defined moving subject, a mechanical assembly with a drivetrain, several flexible attachments, and a motion phase that must remain internally consistent.
An example prompt excerpt:
On a coastal promenade at dusk, a pelican is riding a dark-green, steel-frame bicycle. Its body leans forward, and both wings extend to hold the handlebars. One webbed foot rests on a pedal; the other is suspended near the lowest point of the pedal’s return stroke. The bicycle has a classic diamond frame, a canvas tool bag attached to the down tube, and a rolled fishing net secured to the rear rack. The crank drives the rear wheel, and the chain is taut. The riding pose must match the drivetrain’s current phase. Stylization is allowed, but spatial relationships between parts must support parametric verification.
The goal is to separate visual quality from structural correctness. Stylization gives the model creative freedom; parametric checks prevent that freedom from becoming an excuse for incorrect assembly.
3. Parameters and Dependencies: Writing Code Versus Building a Model
The evaluation depends on whether the script is genuinely parametric. All adjustable dimensions should appear as global constants at the top of the script, and all geometry should derive from those constants. Modeling functions must not contain disconnected, hard-coded values.
# ---- Global parameters: the single source of truth ----PELICAN_WINGSPAN = 1.15 # Wingspan in meters; controls handlebar width and grip spacingBICYCLE_WHEELBASE = 1.02 # Wheelbase in meters; drives all frame nodesBICYCLE_CHAINRING_TEETH = 44 # Chainring tooth count; controls chain length and gear ratioBICYCLE_COG_TEETH = 16 # Rear sprocket tooth countBICYCLE_CRANK_PHASE = 35.0 # Crank phase in degrees; controls pedal and foot contact# ---- Compute derived values centrally, not inside modeling functions ----def derive(p):d = {}d["handlebar_width"] = p.wingspan * 0.92 # Grips must accommodate the wing tipsd["grip_offset"] = p.wingspan * 0.5 - 0.03d["ratio"] = p.ring_teeth / p.cog_teethd["pitch"] = 0.0127 # Chain pitch: a material constantd["r_ring"] = d["pitch"] * p.ring_teeth / (2 * math.pi)d["r_cog"] = d["pitch"] * p.cog_teeth / (2 * math.pi)return d
Chain length should not be chosen by eye. It should be calculated from the two sprocket radii and their center distance. An approximate length for a taut chain is:
def chain_length(center_dist, r1, r2):return (2 * center_dist+ math.pi * (r1 + r2)+ (r1 - r2) ** 2 / center_dist)
The crank phase determines the pedal’s spatial position, which in turn determines the foot-contact point:
def pedal_center(bottom_bracket, crank_len, phase_deg):t = math.radians(phase_deg)return (bottom_bracket[0] + crank_len * math.cos(t),bottom_bracket[1] + crank_len * math.sin(t),bottom_bracket[2])
The supporting foot uses phase, while the opposite pedal uses phase + 180. This phase relationship must be explicit in the code rather than achieved through a coincidentally plausible pose. The suspended foot’s return-stroke pose must remain consistent with the current pedal positions.
4. Acceptance Testing: Change Numbers, Not Code
Parameter perturbation is the most valuable part of this evaluation. The evaluator changes only constant values, leaves function bodies untouched, reruns the script, and checks the resulting assembly.
| Perturbation | Parameter change | Acceptance check |
|---|---|---|
| Increase wingspan | 1.15 → 1.35 | Do the handlebars widen accordingly, and do the grips still accommodate both wing tips? |
| Increase chainring size | 44 → 52 | Is the chain path recalculated without intersecting geometry or floating away from the sprockets? |
| Rotate the crank phase | 35 → 140 | Does the supporting foot remain in contact with the pedal surface, and does the suspended foot remain consistent with the return-stroke pose? |
A script that passes these tests demonstrates parameter-driven assembly relationships. A script that fails has likely produced a static arrangement that merely looks plausible.
This distinction is the central basis for evaluating the model’s spatial reasoning.
5. Common Failure Modes and Scoring Criteria
Frequent failures include:
- Copying global constant values into functions, creating hidden hard-coded dependencies.
- Stretching a fixed-length chain, producing an incorrect tension state.
- Calculating foot and pedal positions independently, so contact breaks when the phase changes.
- Defining frame nodes with fixed absolute coordinates, causing the fork and rear triangle to become misaligned when the wheelbase changes.
- Leaving attachments, such as the tool bag or fishing net, floating or intersecting the frame.
A five-dimensional scoring framework can cover:
- Parameter coupling: Whether dependent geometry updates correctly when an input changes.
- Constraint satisfaction: Whether required contacts, alignments, and phase relationships hold.
- Geometric self-intersection rate: How often unintended intersections occur.
- Script executability: Whether the script runs successfully in the required environment.
- Visual and stylistic completeness: How fully the scene realizes the requested appearance.
Parameter coupling and constraint satisfaction should receive the highest weights and must be assessed through automated script checks rather than visual inspection alone. Visual and stylistic completeness should receive the lowest weight, preventing attractive rendering from masking structural errors.
6. Engineering the Evaluation Pipeline
To scale this approach, package it as an automated pipeline:
- Store task prompts and parameter sets in object storage.
- Launch a headless batch environment on a container platform for each evaluation.
- Collect standard output and rendering logs in a centralized logging service.
- Track failure rates and the average number of passed evaluation dimensions through monitoring and alerts.
- Run multiple parameter perturbations in parallel.
Parallel testing can shorten evaluation cycles and make regression comparisons between model versions easier.
7. Conclusion
Spatial reasoning evaluation should go beyond whether a generated scene looks convincing.
Parametric 3D scenes, global constants as the single source of truth, and acceptance tests that change only numerical inputs turn a subjective judgment into repeatable, automatable engineering measurements.
The same approach applies to mechanical assemblies, architectural components, and robot workspaces—generation tasks in which strict spatial constraints matter. It provides a practical basis for assessing whether a generative model can maintain coherent spatial relationships rather than simply reproduce their appearance.
