Evaluating Spatial Reasoning in LLMs with Parameterized 3D Generation
This article presents a practical framework for evaluating the spatial reasoning capabilities of large language models through parameterized 3D scene generation. Instead of relying on rendering scripts that are hard to verify, it uses headless modeling scripts and cross-model comparison under identical prompts. The framework defines three evaluation layers—syntax correctness, structural validity, and parameter linkage—and explains how to design verifiable scenes, write prompts that declare the runtime environment and deliverables, and use global constants to build parameter dependency graphs. It also covers four observation dimensions, execution methods for headless comparison, common failure patterns, and actionable recommendations for building a repeatable evaluation pipeline within a team.
1. Background: Why Generating Code Is Not the Same as Spatial Reasoning
In AI coding tools and LLM capability evaluation, generating 3D scenes from pure code has become an important way to test spatial reasoning. However, many evaluations stop at whether the script runs or whether the output looks right, overlooking the real difficulty: whether spatial relationships between parts hold, whether motion states are self-consistent, and whether the model preserves structural consistency after parameters change.
The core idea of the original practice is worth abstracting: abandon rendering scripts that are hard to verify parametrically, switch to modeling scripts that can run in headless mode, and introduce horizontal comparison across multiple models under the same prompt. The point is not to compare a few specific products, but to build a general evaluation framework that determines whether a model truly “understands” 3D space and mechanical transmission relationships.
1.1 Three Layers of Evaluation Goals
- Layer 1: Syntax correctness. The script runs in the target environment without errors.
- Layer 2: Structural validity. No intersections, floating parts, or misalignment between geometries.
- Layer 3: Parameter linkage. After modifying global constants, all derived geometry updates synchronously.
Most evaluations only cover Layer 1, while Layers 2 and 3 are what actually differentiate capability.
2. Evaluation Design: From Prompt to Acceptance Criteria
2.1 Choose Scenes That Are Verifiable
The original case chose the scene of “a pelican riding a bicycle,” which is clever: it contains organic form (the pelican), mechanical structure (diamond frame, chain drive), pose constraints (forward lean, gripping the handlebar, foot contact with pedals), and a narrative environment (a coastal boardwalk at dusk). The advantage of such a scene is that any spatial relationship error can be clearly identified.
Three principles for designing evaluation scenes:
- Include at least one closed-loop transmission or kinematic constraint;
- Include at least one contact relationship between an organic body and a mechanical body;
- Include parameterizable dimension constants whose changes trigger cascading geometric adjustments.
2.2 The Prompt Must Explicitly Declare the Runtime Environment and Deliverables
The original prompt explicitly required a modeling script file that runs in headless mode, and specified the file naming and execution method. This is critical: it rules out the possibility of “relying on interactive interface debugging” and forces the model to output complete, self-consistent engineering code in one pass.
A general prompt skeleton:
Design a 3D scene based only on the text below. No reference images are provided.Deliver a modeling script that runs in headless mode.1. Scene and narrative: ...2. Global parameters: all geometry must be derived from top-level constants; magic numbers inside functions are prohibited.3. Acceptance: modify the specified constants and rerun, then check the linkage results.
2.3 Parameterization Is the Dividing Line Between “Writing Code” and “Building a Model”
The original case defined global constants such as wingspan, wheelbase, chainring teeth, sprocket teeth, and crank phase angle. The essence is a parameter dependency graph:
wingspan -> handlebar width, grip spacing, wing posturewheelbase -> frame node coordinates, front and rear wheel positionschainring/sprocket -> gear ratio, chain length, rear wheel drive phasecrank phase -> pedal coordinates, foot contact points, leg posture
The acceptance side only changes numbers without touching the code, then observes whether the geometry updates synchronously. This method efficiently identifies “pseudo-parameterization,” where the model merely puts numbers at the top while the actual geometry is still determined by hardcoded coordinates.
3. Four Observation Dimensions of Spatial Reasoning
3.1 Rigid Bodies and Contact Relationships
The pelican’s wings must rest on the handlebar grips, and the webbed feet must stay in contact with the pedals or be lifted according to phase. During evaluation, check whether contact points are recomputed as parameters change, rather than fixed coordinates.
3.2 Transmission Chain Closure
The chain must connect the chainring and the sprocket, with its length determined by the tooth counts and center distance, and it must be under tension. If the model only draws a closed curve without considering the gear ratio, that is visual approximation rather than spatial reasoning.
3.3 Phase Consistency
The crank phase angle determines the pedal position, which in turn determines foot position and leg posture. If the pelican’s pose does not change after modifying the phase, the model has not established kinematic linkage.
3.4 Balancing Stylization and Verifiability
Artistic style is allowed, but the spatial relationships between parts must be verifiable through parameterization. This requires the model to make engineering trade-offs between “looking good” and “being correct.”
4. Running the Horizontal Comparison
Run the output scripts of multiple models in parallel in a headless environment, and record three types of metrics:
- Execution success rate: whether errors occur and whether missing resources are required;
- Parameter sensitivity: whether the geometry bounding box and key node coordinates change after modifying constants;
- Structural error list: specific locations of intersections, floating parts, proportion issues, and transmission breaks.
It is recommended to organize the results into a table and label each error as belonging to the syntax layer, the structure layer, or the linkage layer. This avoids vague conclusions such as “it feels good overall.”
5. Common Failure Patterns and Improvement Suggestions
- Residual magic numbers: fixed coordinates inside functions that are disconnected from global constants.
- Frozen pose: the organic body’s pose does not update after parameter changes.
- Decorative transmission: chains and gears have appearance only, with no geometric constraints.
- Environment dependency: the script depends on an interactive interface or external resources and cannot run in batch.
- Missing self-checks: no assertions inside the script for bounding boxes, contact distances, and similar checks.
The improvement direction is to require the model to build in self-check logic in the prompt, for example outputting the world coordinates of key nodes, computing contact point distances, and printing parameter activation logs.
6. Practical Recommendations for Developers
To build a similar evaluation system within an enterprise or team, the following process can be referenced:
- Define a scene template library covering three types of difficulties: mechanical transmission, organic form, and composite contact;
- Unify the runtime environment, use a container platform to ensure consistent dependencies, and use a logging service to collect execution output;
- Script parameter modification and assertion checks to form a repeatable acceptance pipeline;
- Use monitoring and alerting to track the success rate of evaluation tasks and the distribution of failure types;
- Turn evaluation results into a basis for prompt optimization and model selection.
7. Conclusion
The value of parameterized 3D scene generation evaluation lies in turning “spatial reasoning” from a subjective impression into quantifiable, reproducible engineering metrics. Through global-constant-driven parameterization, kinematic phase linkage, headless batch execution, and layered error attribution, developers can more accurately determine the real capability boundaries of AI coding tools and optimize prompt design and engineering practices accordingly.
