From Code Generation to Spatial Reasoning: A Practical Approach to Evaluating 3D Scenes
Evaluating generative models on creative coding tasks requires more than checking whether code runs. Using a "pelican riding a bicycle" 3D scene as a running example, this article presents a framework for turning narrative descriptions into computable constraints, building explicit parameter dependency graphs, modeling drivetrain geometry and contact chains correctly, and validating results through parameter perturbation and independent geometric checks rather than single screenshots. It also outlines a delivery-oriented evaluation workflow and explains why constraint preservation under changing requirements is the capability that matters most.
1. Evaluating Generative Models: More Than “Does the Code Run?”
Generative models in creative coding are moving from drawing simple shapes to constructing complex 3D scenes. For developers, the real question is not whether a model can deliver code quickly, but whether it can translate spatial relationships, mechanical constraints, and narrative requirements from natural language into a consistent computational model.
For example, “a pelican riding a bicycle” looks like a purely visual task, but it actually involves multiple interrelated problems:
- The wheels, frame, chainring, and rear cog must maintain correct relative positions.
- The wing tips must align with the handlebar grip area.
- The webbed feet must follow the crank angle as it changes.
- The chain path must satisfy both geometric connection and drivetrain relationships.
- The whole scene must remain structurally coherent after parameter changes.
Successful code execution is only the minimum bar. A generation result with real engineering value should explain its structure, respond to parameter changes, and pass independent geometric checks.
This approach generalizes to procedural animation, industrial assembly illustrations, interactive educational scenes, and digital content production.
2. Decomposing a Narrative Description into Computable Constraints
1. Separate visual requirements from structural requirements
Elements like dusk lighting, a seaside promenade, a dark green frame, a canvas tool bag, and a fishing net primarily serve narrative and stylistic purposes. These can use simplified geometry or artistic representation, as long as they do not affect the main structure.
But descriptions such as “gripping the handlebars,” “standing on the pedals,” “a taut chain,” and “the crank driving the rear wheel” are structural requirements that must be enforced—they cannot be papered over with materials or camera angles.
A practical way is to split the requirements into four layers:
Geometry layer: defines object dimensions, shapes, and coordinates.
Topology layer: defines which parts connect, and where the connection points are.
Motion layer: defines the coupling between crank, pedals, chain, and wheels.
Presentation layer: defines materials, lighting, camera, and atmosphere.
Building in this order reduces cases of “a beautiful image with a mechanically wrong structure.”
2. Unify the coordinate system before generating objects
A computation-friendly convention:
- Forward direction as the horizontal axis.
- Axle direction as the lateral axis.
- Vertical direction as the height axis.
- Rear wheel center as the planar position reference.
- The horizontal distance between front and rear wheel centers determined by the wheelbase.
All frame nodes, drivetrain components, and character contact points should use this single convention. Local objects may keep their own coordinate frames, but the local-to-scene transform must be explicit.
If components are placed by eyeballing, the initial image may look correct, but changing the wheelbase or crank angle will quickly break the assembly.
3. Parametric Modeling Is About Dependency Relationships
1. Parameters are not decorative constants
A reasonable test scenario can start with the following inputs:
| Parameter | Example value | Primary impact |
|---|---|---|
| Wingspan | 1.15 m | Wing geometry, handlebar width, grip position |
| Wheelbase | 1.02 m | Wheel center distance, frame node layout |
| Front chainring teeth | 44 | Chainring pitch circle, chain envelope, gear ratio |
| Rear cog teeth | 16 | Cog pitch circle, gear ratio |
| Crank phase | 35° | Pedal position, foot contact, limb pose |
These are test inputs only, not general ergonomic or mechanical design standards.
During evaluation, check whether parameters actually flow into the geometry computation. For example, changing the wingspan should alter the grip points through an explicit proportion or pose rule—not just change a variable while the handlebar width stays fixed.
2. Build an explicit dependency graph
The dependencies can be organized as:
Wingspan → wing scale and pose targets → grip point spacing → handlebar end positions.
Wheelbase → front and rear wheel centers → frame nodes → saddle and handlebar mounts.
Tooth counts and chain pitch → sprocket pitch circles → chain tangent points and path → chain length check.
Crank phase → pedal position → foot contact target → leg pose.
This dependency graph is both an implementation guide and an acceptance checklist. Every input parameter should have a traceable downstream effect.
Also, avoid interpreting “all geometry derives from parameters” as “the entire script may only contain five numbers.” Wheel diameter, crank length, tube diameter, and joint range limits all need definitions too. A better practice is to centralize design dimensions, scale factors, and error thresholds in one configuration, rather than scattering unexplained constants inside functions.
4. The Drivetrain Is the Core Test of Spatial Consistency
1. Tooth count must be tied to chainring size
For an ideal chain drive with fixed link pitch, the sprocket pitch circle radius is:
r = p / [2 × sin(π / N)]
where p is the chain pitch and N is the number of teeth.
This formula describes the pitch circle traced by the chain pin centers, not the tooth tip outline. The chain path should reference the pitch circle; tooth appearance must be modeled separately.
Therefore, when the front chainring changes from 44 to 52 teeth, you cannot just add teeth while keeping the size fixed. The pitch circle must grow accordingly, and the chain tangent points with both sprockets must be recomputed.
2. The chain path cannot be a fixed oval
In a simplified coplanar two-sprocket model, the chain path consists of two external tangent segments and two arcs.
Let the two pitch circle radii be R and r, and the center distance be d. Computing the external tangents involves the ratio between the radius difference and the center distance. Before implementing, verify that the geometric conditions are valid—especially the relationship between center distance and radius difference.
This means the chain is not an arbitrary closed curve drawn around two circles. A sound process includes:
- Determine the two sprocket centers and pitch radii.
- Solve the external tangents and their tangent points.
- Select the corresponding envelope arcs.
- Assemble a continuous path.
- Check path direction, connection error, and local intersections.
If the generated result just reuses a fixed path computed for the initial parameters, changing the chainring size will easily produce a chain that cuts into a sprocket or detaches from the pitch circle.
3. A correct continuous path does not mean a real chain can be assembled
A continuous curve is suitable for checking spatial relationships, but a real chain consists of discrete links, and its length is constrained by pitch and assembly method.
With a fixed center distance, changing the chainring tooth count usually changes the required chain length. At that point, “use the same chain,” “keep a fixed center distance,” and “the chain is always taut” may not all hold simultaneously.
The test must state which assumption applies:
- Allow the chain to be regenerated from parameters, and check closure error of the discrete links.
- Allow adjusting the rear wheel position or adding a tensioner.
- Evaluate only the continuous chain envelope, without claiming a real mechanical assembly.
Making the simplification boundary explicit matters more than outputting a chain that merely looks correct.
5. Riding Pose Requires Contact Solving, Not Manual Placement
1. Compute pedal position from the crank phase
Let the crank center be C, crank length L, and phase angle θ. With the phase measured from the forward direction, the crank offset in the forward–height plane is:
Forward offset = L × cosθ
Height offset = L × sinθ
Left and right cranks are 180° apart, and each also needs a lateral offset. The pedal itself should usually stay approximately level—it should not simply inherit the crank’s full rotation.
The foot contact point should be derived from the pedal surface, not offset arbitrarily from the pedal center. This is how you distinguish “the foot is near the pedal” from “the foot is actually on the pedal.”
2. When the foot moves, the leg must be re-solved
The leg can be simplified as a joint chain of two rigid segments. Given the hip position and the foot target, first check whether the target is within reach, then solve for the intermediate joint position.
If the target is unreachable, report the constraint conflict explicitly, or adjust upstream parameters—body pose, saddle position—according to pre-approved strategies.
Never silently stretch the leg or fold a joint backward. Even if the contact point aligns, the model still lacks credible spatial consistency.
Wing grip on the handlebars needs the same treatment: grip target, wing length, and joint pose must be mutually consistent, rather than moving the grips or wing tips independently.
3. For ambiguous requirements, clarify before accepting
“The crank phase can vary arbitrarily, but the other foot always stays at the lowest point of the return stroke” contains a potential conflict.
In a fixed crank mechanism, the two pedals maintain a 180° phase difference. After the crank phase changes, the opposite pedal is not always at its lowest position. If the lifted foot is not on the pedal, it may take an independent artistic pose—but that no longer means it strictly follows the opposite pedal.
Two explicit options:
- Mechanical consistency first: the lifted foot follows the opposite pedal’s current motion envelope with a set clearance.
- Narrative pose first: the lifted foot stays low, but it is explicitly excluded from pedal-contact constraints.
Recognizing this contradiction is itself an important indicator of a model’s reasoning quality.
6. Parameter Perturbation Instead of Screenshot-Based Acceptance
1. Change parameters individually, then in combination
At minimum, run these tests:
Baseline test: use the initial parameters; check script execution, scene structure, and visible output.
Single-parameter perturbation: vary wingspan, tooth counts, wheelbase, and crank phase separately to verify the dependency chain is complete.
Combined perturbation: set wingspan to 1.35 m, front chainring to 52 teeth, and crank phase to 140° simultaneously, and check whether multiple changes can hold together.
Combined tests expose problems that single-variable tests miss—for example, after the handlebar widens, the wing may stretch but the body pose or joint reachability fails.
2. Turn visual judgment into numerical checks
Recommended outputs:
- Distance between wing tips and the grip region.
- Distance and penetration depth between the sole and the pedal surface.
- Deviation between actual wheel center distance and the target wheelbase.
- Position continuity at chain path joints.
- Minimum clearance between the chain and non-target parts.
- Whether joints exceed their configured ranges.
- Whether any objects were not recomputed after a parameter update.
Error thresholds should be set in advance based on model scale, geometric precision, and purpose—never relaxed after seeing results.
3. Static correctness is not motion correctness
A single-frame scene only proves the layout at one phase; it does not prove “the crank is driving the rear wheel.”
Under ideal, no-slip, engaged transmission, the ratio of rear cog angular velocity to crank angular velocity is determined by the front-to-rear tooth count ratio. But verifying motion requires sweeping multiple crank phases and checking:
- Whether the pedal trajectory is continuous.
- Whether the feet jump.
- Whether joints flip abruptly.
- Whether chain movement along the path is continuous.
- Whether rear wheel rotation matches the transmission relationship.
If video is generated, rendering stability, temporal sampling, and frame-to-frame consistency should also be part of acceptance—“a video file was produced” is not evidence that the motion is correct.
7. A Delivery-Oriented Evaluation Process
A full test can be organized as: requirements freeze → generate → execute → perturb → check → reproduce.
First, freeze the input description, parameter ranges, allowed simplifications, and output requirements. Then run the generated script in a headless environment, recording execution time, errors, warnings, and the list of artifacts.
Next, an independent checker reads the scene data and performs acceptance. Self-checks inside the generation script can be kept, but they should not be the only evidence—otherwise generation logic and checking logic may share the same flawed assumption.
Final deliverables should include at least:
- A reproducible scene generation script.
- Centrally managed parameter configuration.
- Baseline and perturbed scene outputs.
- Geometry and motion check reports.
- Known limitations and simplification assumptions.
- Failure cases with localization information.
Evaluation dimensions should be recorded separately. Execution success, structural correctness, parameter coupling, motion consistency, and visual quality are distinct capabilities. None can be replaced by a pretty screenshot, and no comprehensive conclusion should be drawn merely from which model finishes first.
8. Conclusion: What Matters Is Constraint Preservation
The technical value of a creative coding task lies not in how much code is generated in one shot, but in whether the result stays credible as requirements change.
Taking the 3D cycling scene as an example, the capabilities that genuinely matter are: converting text into structured constraints, establishing explicit parameter dependencies, handling drivetrain and contact relationships correctly, recognizing requirements that cannot be simultaneously satisfied, and providing reproducible verification evidence.
When evaluation shifts from “can it draw something” to “does it still hold after the parameters change,” developers can more accurately judge which engineering tasks generative models are fit to take on—and which stages still require manual modeling, independent checking, and professional review.
