Parametric 3D Generation in Practice: Evaluating Spatial Reasoning and Script Design
This article presents a practical methodology for evaluating spatial reasoning in code-generated 3D scenes. It explains why a script that runs is not necessarily usable, breaks spatial reasoning into four verifiable capabilities, and shows a constants-driven script skeleton with derived values. It covers analytical chain path calculation, crank-phase-driven pose and inverse kinematics, automated acceptance checks, common failure modes, and improvement suggestions. The approach turns subjective spatial reasoning into objective, reproducible engineering metrics.
1. Background: Why “It Generates” Does Not Mean “It Works”
In AI coding tools and large model evaluation, generating 3D content purely from code is becoming an important measure of spatial reasoning. Unlike generating an image, a 3D scene requires a model to maintain geometric topology, scale relationships, motion phase, and assembly constraints at the same time. A script that runs only proves the syntax is correct. Whether the spatial relationships between parts still hold after parameters change is the real dividing line for engineering usability.
The core idea of the original practice is representative: instead of chasing a rendered “looks right” result, use scripts that can run directly in headless background mode, and extract all key dimensions and phases as global constants at the top. The reviewer changes only the numbers, not the code, and observes whether the result remains self-consistent. This article abstracts that into a general methodology.
2. Evaluation Design: Breaking Spatial Reasoning into Verifiable Items
A vague sense of “spatial awareness” cannot be evaluated; it must be broken into quantifiable items. At least four capabilities should be covered:
- Scale derivation: whether one overall dimension (such as wingspan) correctly derives multiple related parts (handlebar width, grip spacing).
- Parameter coupling: after the gear ratio (chainring teeth, cog teeth) changes, whether the chain path is recalculated without clipping through geometry or floating in the air.
- Phase consistency: after the crank phase changes, whether the support foot still contacts the pedal surface and the lifted foot remains at a low position on the return stroke.
- No magic numbers: no hard-coded values disconnected from the global constants may appear inside function bodies.
Together these four capabilities form the minimum closed loop of “parametric spatial reasoning” and are the key to distinguishing a demo script from an engineering script.
3. Script Skeleton: Constants and Derived Relationships
The recommended script structure is as follows (illustrative):
# ===== Global constants: the single source of truth =====PELICAN_WINGSPAN = 1.15 # Wingspan; drives handlebar width and grip spacingBICYCLE_WHEELBASE = 1.02 # Wheelbase; drives frame geometryCHAINRING_TEETH = 44 # Chainring teethCOG_TEETH = 16 # Rear cog teethCRANK_PHASE = 35.0 # Crank phase angle (degrees)# ===== Derived values: all computed from constants, no magic numbers =====GEAR_RATIO = CHAINRING_TEETH / COG_TEETHHANDLEBAR_WIDTH = PELICAN_WINGSPAN * 0.92GRIP_OFFSET = PELICAN_WINGSPAN * 0.5CHAINRING_RADIUS = CHAINRING_TEETH * PITCH / (2 * PI)
The key principle is that derived values are defined in one place, computed once, and reused globally. Any geometry generation function receives only derived values as inputs and does not infer dimensions on its own. This keeps the impact of parameter changes controllable and predictable.
4. Drivetrain: Analytical Calculation of the Chain Path
The chain cannot be faked with two rings placed together. The engineering approach treats it as a closed envelope: two pitch circles (chainring and cog) plus upper and lower common tangent segments. The radii change with tooth count, and the tangent points move accordingly, so the solution must be analytical rather than fixed coordinates.
def chain_path(r1, r2, d):# r1: chainring pitch radius, r2: cog pitch radius, d: center distancealpha = asin((r1 - r2) / d)# Upper/lower tangent points and arc angles are derived from alphareturn build_closed_curve(r1, r2, d, alpha)
When the chainring tooth count changes from 44 to 52, the pitch radius increases, the envelope expands automatically, and the chain length and rear-wheel drive relationship update together, avoiding clipping and floating. This is a direct demonstration of parameter coupling.
5. Phase and Contact: Making Pose Follow the Drivetrain
The riding pose must be uniquely determined by the crank phase. With phase angle θ, the pedal position is:
pedal_pos = crank_center + crank_length * vector(cos(radians(CRANK_PHASE)),sin(radians(CRANK_PHASE)))
The ankle position of the support foot is solved back from the pedal position, and the leg uses a two-link inverse kinematics solve to keep the sole in contact with the pedal surface. The other foot is fixed at a low return position (a floating gap near phase plus 180 degrees). So when the phase changes from 35 to 140 degrees, the support foot still contacts the pedal and the lifted foot stays low, keeping the pose strictly consistent with the drivetrain phase.
6. Automated Acceptance: Passing Even When Only Numbers Change
Acceptance should be written as scripted checks rather than visual inspection:
- Enclosure check: whether the grip positions enclose both wing tips, passing within an error threshold.
- Chain continuity check: whether the envelope is closed, tangent to the pitch circles, and free of self-intersection.
- Contact check: whether the distance between the support foot sole and the pedal top is below the threshold.
- Phase check: whether the lifted foot is lower than the support foot and within the return interval.
- Magic number scan: statically scan function bodies and warn on any literal disconnected from the constants.
In cloud practice, such tasks are typically headless and batch-oriented. They can run on a container platform, store artifacts in object storage, and use logging and monitoring alerts to track failure causes, forming a repeatable evaluation pipeline.
7. Common Failure Modes and Improvement Suggestions
- Dimensions decoupled from pose: the handlebar widens but the grips do not follow, a typical missing derivation.
- Chain with fixed coordinates: any tooth count change causes clipping; switch to an analytical envelope.
- Hard-coded pose: the foot floats after the phase changes; switch to inverse kinematics.
- Missing thresholds: without tolerance design, floating-point error causes false judgments.
- Missing static checks: magic numbers scattered everywhere make behavior unpredictable after parameter changes.
8. Conclusion
The value of parametric 3D generation evaluation lies not in a flashy render but in whether the whole set of spatial relationships still holds when one number changes. Chaining constants, derivations, analytical geometry, inverse kinematics, and automated acceptance turns subjective spatial reasoning into objective, reproducible, regression-testable engineering metrics. The same method applies to mechanical assembly demos, architectural massing studies, and automated design validation.
