Evaluating LLM Spatial Reasoning with Parametric 3D Code
Evaluating LLM-generated 3D scenes requires more than checking whether the result looks convincing. This article explains how to design reproducible, text-only modeling tasks, define global parameters and derived geometry, and test spatial and mechanical consistency after parameter changes. It also outlines a fair comparison process and practical steps for building an internal benchmark.
Large language models are increasingly asked to generate runnable 3D scene scripts from text descriptions alone. Although this may look like creative coding, it is fundamentally a test of spatial reasoning: Are components positioned correctly relative to one another? Are motion phases synchronized? Does the geometry remain consistent when key dimensions change?
An evaluation based only on visual resemblance can mistake stylized rendering for modeling competence. A more reliable approach is to frame the task as an engineering problem that is parametric, reproducible, and objectively verifiable.
1. Why Spatial Reasoning Requires Parametric Checks
Unlike ordinary application code, a 3D scene script can contain substantial errors without raising an exception. A crooked bicycle frame, a slack chain, or a foot misaligned with a pedal may not prevent the script from completing.
Evaluation should therefore distinguish between writing code and constructing a model. Code quality concerns syntax, modularity, and executability. Modeling quality concerns whether spatial relationships derive from explicit constants rather than magic numbers scattered throughout functions.
An effective task combines narrative constraints with numerical constraints. Narrative constraints establish understandable relationships: a riding pose on a path at dusk, the shape of a bicycle frame, or the placement of a tool bag relative to a cargo rack. Numerical constraints make those relationships testable:
- Changes in wingspan should drive handlebar grip spacing.
- Changes in wheelbase should drive frame geometry.
- Changes in sprocket tooth counts and their ratio should affect the required chain length.
- Changes in crank phase should update both pedal positions and foot contact points.
If these relationships remain valid after changing only the constants and rerunning the script, the model has demonstrated an understanding of spatial relationships and drivetrain motion—not merely reproduced a fixed set of coordinates.
2. Task Design: From Text to a Reproducible Script
Define the deliverable as a complete script that runs in headless batch mode, rather than an interactive project file. This has three advantages:
- It removes irreproducible manual operations.
- It requires all geometry to be generated through code.
- It supports regression testing in continuous integration.
The prompt should explicitly prohibit reference images and require modeling from text alone. This helps prevent image imitation from being presented as spatial reasoning.
Scene descriptions should specify the motion phase. For example, a winged character might lean forward with both wings extended to grip the handlebars, one foot on a pedal, and the other suspended at the lowest point of its return stroke. The crank is driving the rear wheel, the chain is taut, and the riding pose must match the current drivetrain phase.
These details are not decorative prose. They close off the shortcut of assembling static props. A model that creates a stationary bicycle and simply attaches a character to it should fail the phase-consistency checks.
Artistic styling is acceptable, but spatial relationships between components must remain verifiable through parameter changes. Evaluators should state in advance which constants will change, the approximate scale of those changes, and the invariants they will inspect. For example:
- Increasing wingspan must not cause intersections at the grips.
- Increasing tooth counts must not produce a self-intersecting or visibly slack chain.
- Moving the crank phase into another quadrant must rotate the relevant contact points rather than leave them at their original coordinates.
3. Global Constants and Derived Relationships: The Core Evaluation Contract
Placing key parameters at the top of the script as global constants establishes a clear distinction between hard-coded shapes and maintainable modeling. At minimum, the parameters should cover four categories:
- Character dimensions: Wingspan, for example, controls lateral reach and grip spacing.
- Vehicle dimensions: Wheelbase drives axle positions and frame triangles.
- Discrete drivetrain parameters: Chainring and rear sprocket tooth counts determine chain-link count and drive ratio.
- Motion phase: Crank angle determines pedal positions and foot poses.
All geometry must derive from these constants. An implementation can first generate frame landmarks from the wheelbase and proportional relationships for the head tube and seat tube. It can then derive handlebar width from wingspan so that grip points remain within a reasonable reach envelope.
For the drivetrain, tooth counts can be used to estimate the chain’s discrete length and construct its path along tangent segments between the front and rear sprocket circles. The sprocket geometry should reflect the specified tooth counts and ratio. Rotation matrices can map crank phase to left and right pedal coordinates, after which the feet are constrained to the pedal contact surfaces.
Absolute dimensions inside functions that are disconnected from the declared constants should be treated as a failure of the parametric requirement.
Acceptance testing should be simple and repeatable: change numbers only, leave the code untouched, and rerun the script. Include at least one stress-test parameter set, such as a substantial wingspan increase, a substantial tooth-count increase, and a crank-phase shift of roughly 90 degrees or more.
Checks can include:
- Whether distances between key points remain within tolerance.
- Whether a chain-tension proxy, such as the relationship between sprocket center distance and chain length, remains reasonable.
- Whether the distance between a foot and its pedal stays below the contact threshold.
- Whether the script completes successfully in headless mode without interaction.
4. Avoiding “Looks Good, Therefore Correct” in Model Comparisons
When comparing multiple models on the same task, keep the prompt, runtime environment, and parameter-change matrix fixed.
Success should not be defined merely by whether the model produces a file. Instead, check whether:
- The script runs successfully in batch mode on the first attempt.
- It still runs after the prescribed parameter changes.
- It passes the spatial relationship checks.
Common failure modes include:
- Assembling fixed meshes that resemble a bicycle while the wheelbase constant has no effect.
- Hard-coding character and handlebar positions, causing limb intersections when wingspan changes.
- Using a decorative chain curve unrelated to sprocket tooth counts.
- Rotating only the crank’s visual representation while leaving pedals and feet unsynchronized.
Code-generated video or animation can be an additional scoring criterion, but only after spatial validation. Correct kinematics should come before interpolation, camera work, and lighting. Otherwise, smooth animation can create a misleading advantage despite incorrect geometry.
5. Practical Implementation
Teams can turn this evaluation contract into an internal benchmark with four components: a standard prompt template, a parameter list, a headless execution wrapper, and a library of geometric assertions.
Assertions should use relative error rather than absolute pixel measurements. Logs should report derived intermediate values, including actual wheelbase, grip spacing, chain length, and pedal coordinates. These values help distinguish reasoning failures from numerical implementation errors.
For cloud-based batch execution, object storage can preserve scripts and generated outputs, a container platform can keep the runtime consistent, and logging and monitoring services can track pass rates and trigger alerts. These are general infrastructure capabilities and do not require vendor-specific interfaces.
6. Conclusion
The meaningful test of a code model’s spatial reasoning is not a broad claim of parity with another capability. It is whether a set of global constants can drive the complete geometry and drivetrain while preserving spatial consistency when only numerical values change.
Connecting narrative requirements, parameterization, and headless reproducibility within a single acceptance workflow turns creative coding into an engineering capability that can be measured. Developers can use this approach both to compare intelligent coding tools and to improve the constraint design of their own 3D generation pipelines.
