Parameterized Acceptance Testing for Code-Generated 3D Scenes

    Judging a code-generated 3D scene by a single render is not enough. This article explains how to treat natural-language scene requests as parameterized specifications: expose design quantities as named constants, derive frames, drivetrains, and character contacts from those constants, and re-check clearance, contact, and phase after changing only the numbers.

    Handing a natural-language description to a code-generation model and asking it to emit a batch-runnable 3D scene script looks, on the surface, like “writing code.” The hard part is spatial reasoning: part scale, contact, motion phase, and occlusion must all hold at once, and they must still hold after parameters change. If the script is full of magic numbers detached from the design intent, changing wingspan, tooth count, or crank angle often produces immediate interpenetration, floating parts, or a broken pose. Evaluating this capability should not stop at how a screenshot looks. It needs an acceptance method in which geometry is derived from parameters and every constant change is a regression.

    Why visual review is not enough

    A 3D result can look complete very easily. A correct silhouette, a plausible palette, and a full set of story elements do not mean the spatial relationships are checkable. Common failures include a grip that misses the usable region of the handle; a foot that only appears near a pedal while the normal and contact face do not match; a chain length hard-coded for an old tooth count so that a larger chainring sends the path through the hub or leaves it hanging in the air; and a crank phase that changes while the pedaling side stays at the old angle.

    Some of these errors are hidden under the default parameters. Others appear only after the camera rotates. A single render cannot distinguish a shape assembled by coincidence from a shape solved from constraints, and it cannot tell whether the script still works after the numbers change. For a development team, a sample that cannot be regressed cannot enter continuous evaluation, and it cannot guide prompt or post-processing changes.

    A more reliable approach is to require a complete script that runs in headless batch mode; put the key design quantities at the top of the script as global constants; compute every mesh, curve, joint, and placement from those constants; and, at acceptance time, change only the numbers, not the functions, then automatically or semi-automatically check that the spatial predicates are still true.

    Turn the narrative into a computable spec with global constants

    The scene may be artistic, but the spatial relationships must be parameterized. Take a description such as “on a seaside path, body leaning forward, both wings on the grips, one foot planted on a pedal, the other foot low on the return stroke, a diamond frame, and the drivetrain driving the rear wheel.” At least three classes of constants should be extracted.

    Scale constants set the envelope and spacing. Wingspan, for example, sets handlebar width and grip spacing; wheelbase sets the distance between wheel centers and the proportions of the frame tubes. After a scale constant changes, the grips should still cover the usable region near the wing tips. The bars must not simply grow wider while the wings stay floating at the old coordinates.

    Drivetrain constants set circumference and path. Chainring teeth and cog teeth set pitch radii and gear ratio, and therefore cumulative chain length and the tangent points of the slack and taut runs. When the tooth count increases, the chain must recompute wrap angle and tangents. It must not reuse the old polyline.

    Phase constants keep pose consistent. Crank angle sets the positions of both pedals: one in contact with a sole, the other near the low point of the return stroke with a reasonable gap. After the phase moves into another quadrant, both the contact side and the airborne side must be solved again. Rotating only the crank while leaving the character mesh in place is not enough.

    Constants should be centralized, clearly named, and given units. Inside functions, do not introduce magic numbers that are unrelated to these quantities yet control the same geometric feature. Local chamfers, subdivision levels, and other purely visual parameters may exist, but they must not secretly decide contact, wheelbase, or chain length.

    Derivation order from constants to geometry

    A sound generation order is usually top-down, not “place static parts and then make them look aligned.”

    First, build the frame skeleton. Wheelbase, wheel diameter, and head-tube angle yield the front and rear wheel centers, the bottom-bracket center, and the stem position. The top tube, down tube, seat tube, and rear triangle of a diamond frame should share those joints instead of each tube carrying its own coordinate set.

    Second, solve the drivetrain. Tooth counts yield pitch circles. Crank phase yields crank and pedal coordinates. Common tangents of the front and rear pitch circles yield the chain polyline or curve. Under a tensioned-chain meaning, the chain must stay on a feasible path: it must not penetrate the collision volumes of the chainring, cog, frame, or spokes.

    Third, solve the rider. Wingspan yields shoulder width, wing length, and grip targets. Handlebar width is used to recover the grasp interval of the hands, or of the wing tips. Pedal pose is used to recover ankle and metatarsal contact on the planted foot; the other foot is constrained to the target height and fore-aft position of the low return stroke. Forward lean should satisfy both grip height and bottom-bracket height, rather than a fixed Euler angle unrelated to the frame.

    Fourth, place narrative attachments. If a tool bag hangs on the down tube, the mount point should follow the tube’s direction and length. A rolled item on the rack should follow the rear-rack plane and must not pass into the rear wheel after the wheelbase changes.

    The sketch below is only a constraint-style skeleton. The numbers illustrate data flow; they are not a fixed API for any one implementation:

    1. # Illustrates derivation only. Mesh APIs depend on the 3D environment in use.
    2. WINGSPAN = 1.15
    3. WHEELBASE = 1.02
    4. CHAINRING_TEETH = 44
    5. COG_TEETH = 16
    6. CRANK_PHASE_DEG = 35.0
    7. def build():
    8. frame = frame_from_wheelbase(WHEELBASE)
    9. drive = drive_from_teeth(CHAINRING_TEETH, COG_TEETH, CRANK_PHASE_DEG, frame.bb)
    10. bars = handlebar_from_span(WINGSPAN, frame.head)
    11. rider = rider_from_contacts(WINGSPAN, bars.grips, drive.pedals, drive.phase)
    12. assert_clearance(drive.chain, [frame, drive.wheels])
    13. assert_contact(rider.planted_foot, drive.pedals.down)
    14. return frame, drive, rider

    What matters is not the syntax. It is the assertions and the data flow: inputs to the geometry functions can be traced to the top-level constants, and the assertions still run after those constants change.

    At acceptance time, change only the numbers

    Design the regression as a minimal perturbation. For example, change wingspan, chainring teeth, and crank phase together or separately, rerun the script, and check three kinds of invariants.

    Scale propagation: after the bars widen, grip spacing matches the wing-tip bounding region. If overall rider scale is driven by wingspan, torso and wing-bone proportions should scale together, or follow a piecewise function documented in the spec. Do not only stretch the wings.

    Path recomputation: after the chainring grows, total chain length, tangent points, and the slack and taut runs update. Minimum distance to the wheels and frame stays above a set threshold. Scaling the whole chain mesh to “make up” the length is not allowed.

    Phase consistency: after the crank moves to a new angle, the distance from sampled sole points on the contact foot to the pedal plane, and the angle between normals, stay within tolerance. The airborne foot stays near the low point of the return stroke and does not intersect the pedal or crank. Forward lean and the wing grips must not leave the bars just because the phase changed.

    Also check repeatability: two runs with the same constants produce key-point coordinates within numerical tolerance. On failure, print which assertion failed instead of silently emitting a wrong mesh. Rendering is only an aid. The decision is based on measurements.

    Common failure modes and how to revise the prompt

    Models often treat the task as “generate some shape code that runs.” Four failure types are typical.

    The first is default values buried inside functions. The top-level constants change, but the interior still uses the old half-width of the bars or the old chain segment count. Changing a number at acceptance time exposes this immediately.

    The second is visual alignment instead of a constraint. A translation moves the foot “near the pedal,” but the pedal transform is not the parent or the target. As soon as the phase changes, the foot separates.

    The third is ignoring negative space. The chain, a rolled net, or a wing membrane is checked only at its own vertices, not for intersection with other parts. Use simplified collision volumes for distance or Boolean tests, not a wireframe-only look.

    The fourth is vague phase semantics. “One foot at the lowest point,” without saying whether that means crank angle or world-space height, can pull both pedals to the wrong place. The prompt should state which side is in contact, the contact tolerance, and the angular offset of the other side relative to the crank—typically about half a turn.

    When revising the prompt, separate narrative from specification. The narrative describes style and objects. The specification lists constant names, units, derivation relationships, and prohibitions such as no magic numbers and no edits that touch only one part. Require the script to print key measurements at the end: wheelbase, grip distance, pitch radii, foot-to-pedal distance, and minimum chain clearance. An evaluation script that gates on those measurements is more stable than a person looking at an image.

    How to put this into an engineering workflow

    This kind of case fits a specialized check of code-generation quality. It does not replace a general programming benchmark. A layered setup works well:

    • Unit level: given the constants, assert that key-point formulas (pitch circle, pedal coordinates) stay within tolerance.
    • Scene level: the full script runs without a UI and exports measurements plus an optional preview.
    • Perturbation level: sample within a reasonable range of the constants and report the assertion pass rate. Pass rate says more about stable spatial reasoning than one striking screenshot.

    Samples should cover boundaries: a very short wheelbase, a large tooth-count difference, phase near vertical or horizontal, and a wingspan clearly larger or smaller than the default bar width. Classify failures so a single score does not hide a model that only handles the default pose.

    Results and scripts should be traceable. Scripts, constant-change records, measurement logs, and previews can live in object storage. A container platform can run the cases in batch, and logs plus monitoring can cluster failures. If a team uses general compute and storage on Baidu AI Cloud for this regression, treat it as batch jobs and artifact archival. Do not bind the evaluation conclusion to any closed interface or unpublished metric.

    Conclusion

    Spatial reasoning is not proven by polished copy. It is proven when geometry is derived from a small set of explainable constants and, after those constants are replaced, contact, clearance, and phase still agree. Writing the scene as an executable, measurable, perturbable script turns model output from a demo into a comparable engineering capability, and it guides prompt design, failure analysis, and later regression. Artistic style can stay. Parameters and their linkages are what separate “assembling a picture” from “building a model.”