Evaluating Code Generation and Spatial Reasoning with Parametric 3D Scenes

    Parametric 3D scenes provide a practical way to evaluate code generation beyond execution speed and visual quality. Using a pelican riding a bicycle as a test case, this article explains how parameter dependencies, coordinate systems, chain geometry, contact constraints, and motion relationships reveal spatial reasoning capabilities. It also outlines validation methods based on parameter perturbations and numerical checks, with clear distinctions between visual approximations and mechanical modeling.

    1. Code Generation Evaluation Must Go Beyond Speed and Appearance

    For complex 3D scene generation, the most visible measures are how quickly code is produced, whether the script runs, and whether the result looks convincing. These measures are useful, but they do not establish that a system can reason about spatial relationships.

    A script may execute successfully and produce a recognizable scene while treating the bicycle frame, chain, pedals, and character limbs as independently positioned decorations. Changing a single key parameter can expose problems hidden by the original camera angle: wings lose contact with the handlebars, the chain intersects the chainring, webbed feet remain at outdated positions, or the frame visibly crosses the wheels.

    Evaluation should therefore shift from producing a static result to building a system that preserves constraints as parameters change.

    This capability can be assessed at four levels:

    1. Execution correctness: The code builds the scene without manual intervention and produces the required outputs.
    2. Geometric correctness: Object dimensions, positions, and orientations satisfy basic spatial relationships.
    3. Parametric consistency: Changes to input parameters propagate through dependencies and update related objects.
    4. Motion consistency: Moving components obey shared mechanical constraints rather than playing unrelated animations.

    These levels are progressive. Successful execution is only the starting point; the more meaningful evidence comes from verifying the other three.

    2. Use One Scene to Test Multiple Spatial Reasoning Problems

    Consider the following test scene: at dusk on a seaside promenade, a pelican rides a dark green bicycle. Its body leans forward, and both wings reach toward the handlebars. The bicycle has a classic diamond frame, a tool bag mounted on the down tube, and a rolled fishing net secured to the rear rack.

    The challenge is not simply the number of objects. It is the density of their relationships:

    • Wingspan affects wingtip positions and the spacing between handlebar contact points.
    • Wheelbase determines front and rear wheel positions, which in turn influence frame geometry.
    • Chainring and rear sprocket tooth counts affect pitch-circle dimensions, the chain path, and the transmission ratio.
    • Crank phase determines both pedal positions and constrains foot contact.
    • The tool bag and fishing net must follow their mounting components rather than rely on isolated world coordinates.

    The artistic style can vary, but stylization must not conceal constraint errors. Wheels may be exaggerated and feathers simplified, while drivetrain relationships and contact points should remain explicit.

    This task is useful for evaluating general-purpose code generation and spatial reasoning because it requires language understanding, program organization, geometric construction, and cross-object dependency management.

    3. Clarify Constraints Before Treating Ambiguity as an Error

    Before generating code, check whether the task specification is internally consistent.

    For example, “one foot rests on a pedal while the other always remains at the lowest point of the return stroke” does not directly describe standard two-foot bicycle pedaling. Conventional left and right cranks are half a revolution apart, and both pedal positions depend on the same crank phase. As that phase changes, the opposite pedal cannot remain at its lowest point.

    If one foot must remain suspended, the specification needs to clarify:

    • Does the suspended foot follow the opposite pedal?
    • Does “low on the return path” mean near the lower portion of the pedal trajectory, or always at its absolute lowest point?
    • Is the requirement for a single pose or a continuous riding animation?

    A reasonable static acceptance criterion is that one foot remains in contact with the designated pedal, while the other stays near the opposite pedal’s trajectory with a measurable separation from its surface. If the second foot must remain low, that should be defined as an artistic pose constraint, not a standard mechanical pedaling constraint.

    This distinction matters. When the test specification contains conflicting requirements, a reasonable implementation choice may be incorrectly judged as a failure. A sound evaluation separates requirement ambiguity from implementation errors.

    4. Parametric Modeling Depends on a Dependency Graph, Not a List of Constants

    Placing parameters at the top of a script does not, by itself, make the model parametric. Geometry must be derived through an explicit dependency graph.

    Inputs can be organized into three groups.

    Primary Control Parameters

    These include wingspan, wheelbase, front and rear tooth counts, and crank phase. They directly control the properties varied during testing.

    Mechanical Dimensions

    These include wheel radius, crank length, chain pitch, handlebar height, frame tube diameter, and foot sole thickness. Define them centrally, with units and reasonable ranges.

    Shape Ratios and Tolerances

    These include body size relative to wingspan, grip offsets relative to the handlebar center, acceptable chain-to-sprocket clearance, and distance thresholds for contact checks.

    Avoid interpreting every numerical constant as a “magic number.” Values such as one-half or π in mathematical formulas do not need to be eliminated. The problematic values are unexplained dimensions and offsets that have no clear meaning or connection to the parameter system.

    For example, do not assign fixed lateral coordinates to the grips while positioning the wings with a separate, unrelated coordinate scheme. A more reliable dependency structure is:

    Wingspan → grip spacing → left and right grip points → wingtip targets → wing pose

    Similarly, wheelbase should determine wheel axle centers, which then help define the frame through its control points. The tool bag should be positioned relative to the down tube, and the fishing net relative to the rear rack.

    This structure reduces the maintenance burden of changing one parameter and then manually correcting numerous coordinates.

    5. Use a Consistent Coordinate System

    Adopt a consistent right-handed coordinate system, with defined axes for:

    • Longitudinal movement, or forward travel
    • Lateral position, or left and right
    • Vertical position, or height

    Define wheel axle centers, the crank center, the handlebar center, and the character’s body reference point using the same convention. Each component can then have its own local coordinate system.

    Local coordinates do more than simplify repositioning. They also make contact checks easier. To determine whether a foot rests on a pedal, transform samples from the sole into the pedal’s local coordinate system and check:

    1. Whether the normal distance to the pedal’s upper surface is sufficiently small
    2. Whether the projected points lie within the pedal’s supporting area
    3. Whether the sole orientation is compatible with the pedal surface

    Comparing only the distance between the foot center and pedal center is insufficient. Their centers may be close even when the sole penetrates the pedal or extends beyond its supporting area.

    6. Derive the Chain Path from Sprocket Geometry

    The chain is one of the easiest parts of this scene to make visually plausible but mathematically incorrect.

    When the chainring tooth count changes, its dimensions should change accordingly. For an ideal regular sprocket with chain pitch (p) and tooth count (N), the pitch-circle radius is:

    [
    r = \frac{p}{2\sin(\pi/N)}
    ]

    This formula describes the pitch circle, not the outer tooth profile. When generating visible teeth, distinguish the pitch circle, tooth-tip region, and chain-link connection positions rather than treating them as interchangeable.

    In a simplified coplanar drivetrain model, the chain centerline can consist of four sections:

    • A wrap arc around the front chainring
    • A wrap arc around the rear sprocket
    • An upper common tangent segment
    • A lower common tangent segment

    Recalculate tangent directions and contact points from the two pitch-circle radii and their center distance. Updating only the chainring mesh while retaining the old chain path is not sufficient.

    An arc-and-tangent path is useful for procedural visualization and basic geometric validation, but it remains an approximation. A real chain consists of discrete links and introduces additional considerations, including integer link counts, tensioning, tooth engagement, and polygonal effects.

    The evaluation report should therefore identify the modeling level used:

    • A visual centerline approximation
    • Links arranged at a fixed pitch
    • Mechanical-level modeling with discrete links and tooth engagement

    The absence of obvious chain intersections does not establish that the scene implements a realistic mechanical simulation.

    7. Crank Phase Must Drive Pedals, Feet, and Transmission Relationships

    Let the crank center be (C), crank length be (L), and phase angle be (\theta). Using longitudinal, lateral, and vertical components in that order, one pedal spindle position is:

    [
    P_1 = C + (L\cos\theta,\ 0,\ L\sin\theta)
    ]

    The opposite pedal spindle uses phase (\theta+\pi). Define the zero-angle direction in advance; otherwise, the same phase value can produce different poses.

    Once a pedal spindle is positioned, the foot center should not simply be placed at that point. The sole contact target must account for the pedal surface height, sole thickness, and local offset within the foot.

    The character pose can be solved using segmented limb constraints or inverse kinematics so that the foot follows its target. Even with a highly stylized character, the solution should avoid obvious limb stretching or joints bending backward.

    For the drivetrain, assuming ideal no-slip transmission with the drive engaged:

    [
    \omega{\text{rear sprocket}}
    =
    \omega
    {\text{crank}}
    \times
    \frac{N{\text{front}}}{N{\text{rear}}}
    ]

    If the rear sprocket is actively driving the rear wheel, wheel rotation can be updated from this relationship. If the bicycle also moves forward, the model must additionally enforce rolling without slipping between the tire and the ground.

    A single frame verifies pose consistency only at one phase. It does not demonstrate motion. To evaluate whether the crank drives the rear wheel, inspect multiple time samples and verify the relationship between their angular changes.

    8. Validate with Parameter Perturbations and Numerical Checks

    A final render alone is unlikely to reveal every problem. Divide validation into three groups.

    Basic Execution Checks

    Run the script in a headless environment. Confirm that it requires no manual operations, reads no undeclared external resources, and produces both the scene output and a validation report.

    Also inspect object naming, unit conventions, and error messages. Failures should distinguish unsatisfied geometric constraints, missing resources, and execution exceptions rather than produce a single ambiguous failure status.

    Parameter Perturbation Checks

    Example test changes include:

    • Increasing wingspan from 1.15 m to 1.35 m
    • Increasing front chainring tooth count from 44 to 52
    • Changing crank phase from 35° to 140°

    These values are test inputs, not performance findings or industry standards.

    After each change, verify that grip spacing updates, the chain path is recalculated, and foot contact targets move appropriately. Test each parameter independently before changing several together, rather than validating only one combination.

    Numerical Constraint Checks

    Useful measurements include:

    • Distance between wing endpoints and grip regions
    • Distance from the sole to the pedal surface
    • Whether the sole projection lies within the supporting area
    • Agreement between the chain path and pitch-circle tangent points
    • Chain-link spacing deviation
    • Whether transmission angle changes match the tooth-count ratio
    • Minimum clearances between critical components

    Define all tolerances before inspecting results, and explain their basis relative to scene scale. Do not relax thresholds after seeing an unsatisfactory output.

    9. Report a Capability Profile, Not a Single Ranking

    A comprehensive evaluation should not reduce different capabilities to “the system that finishes first is better.”

    Execution time measures generation and runtime efficiency. Geometric constraints measure spatial understanding. Parameter perturbations reveal program structure. Multi-frame checks test motion consistency. Visual quality reflects modeling and presentation. These dimensions are related, but they are not equivalent.

    A more informative report should state:

    • Which requirements passed automated checks
    • Which were confirmed only through manual visual inspection
    • Which use approximate modeling
    • Which cannot be judged directly because the requirements are ambiguous
    • Which remain at risk of failure when parameters change

    For developers and enterprise users, this is more useful than a broad claim that a system is highly capable. It helps determine whether the system is suitable for automated asset generation, parametric design, or procedural content production.

    10. Conclusion: Spatial Reasoning Should Produce Maintainable Constraint Systems

    The real achievement in complex scene generation is not assembling many objects once. It is translating textual requirements into relationships that can be computed, checked, and preserved as parameters change.

    A bicycle-riding scene should prioritize coordinate conventions, parameter dependencies, chain paths, foot contact, and motion phase. Rendering quality should remain a separate evaluation dimension. Clarify ambiguous requirements before validation, and explicitly document mechanical approximations rather than treating appearance as technical proof.

    The capabilities that matter are whether the code forms a clear dependency graph, whether the geometry withstands perturbation, whether motion obeys shared constraints, and whether failures can be located accurately. Meeting these requirements is what allows procedural 3D generation to progress from a demonstration to reliable engineering practice.