Multimodal Code Generation in Practice: A Hands-On Test of Spatial Modeling
This article reports a hands-on test of multimodal code generation for spatial modeling. Starting from the shift from text-to-code tasks to expressing 3D space, it uses a representative challenge—building a fully navigable commercial space from a roughly 450-square-meter bare shell and switching the same camera between bare and decorated states—to show how four hard constraints (immutable structure, multi-zone layout, state consistency, and detail credibility) expose where spatial code generation typically fails. It then breaks down a practical method: setting a unified coordinate system and scale baseline, splitting the scene into structure, decor, and prop layers, and closing a visual self-check loop so the model can inspect rendered screenshots and fix its own output. The article also provides a checklist-style acceptance list, common failure modes with workarounds, and suggestions for turning the approach into a repeatable pipeline, helping readers get usable results from spatial generation tasks.
1. Background: From Writing Pages to Expressing Space
Over the past two years, most code generation work has focused on tasks that can be verified as plain text: building web pages, refactoring APIs, and writing scripts. These tasks share a common trait—the input is natural language, the output is code, and correctness can be judged quickly through compilation, unit tests, or rendered page results. But once the task moves into 3D scenes, interaction rules, and physical constraints, the traditional “text-to-code” pipeline shows clear weaknesses. The model cannot see what the space it generates actually looks like and has to rely on coordinate math; even a small deviation leads to intersecting components, blocked circulation, or distorted proportions.
Newer models summarize this expanded capability boundary as “general-purpose programming”: every frame of a video, the geometry and materials of a 3D scene, and interaction and physics rules can all be expressed as code. The engineering implication is that code no longer only describes data and logic—it also carries the responsibility of expressing spatial structure and visual results. Combined with visual understanding, the model can extend from “writing code” to “building space and interactive creation,” forming a closed loop from requirements to a runnable artifact.
It is worth stressing that this capability is not an exclusive feature of any single vendor, but a general technology trend that emerges when multimodal models are combined with rendering toolchains. What really matters for engineering is the set of constraints and acceptance criteria built around this pipeline.
2. Task Setup: Why “Bare Shell to Finished Space”
To test spatial expression, a typical and difficult task is this: given a bare space of roughly 450 square meters, use a 3D rendering library to build from scratch a fully functional commercial space that can be freely explored, and support switching the same camera position between “bare” and “decorated” states.
This task is representative because it locks in several kinds of constraints at once:
- Immutable structure constraints: load-bearing columns, door and window openings, and main aisle width are hard constraints that cannot move or deform in any state.
- Multi-zone functional layout: the storefront, lobby, private rooms, and dining area must satisfy both functional zoning and visual order.
- State consistency constraints: when switching between the two states from the same camera position, camera parameters and spatial scale must be exactly identical; otherwise the switch immediately reveals flaws.
- Detail credibility constraints: close-up details such as tableware, partitions, and soup surfaces determine whether it “looks like a real space.”
Stacking these four constraint types covers exactly where spatial code generation most easily fails: coordinates and proportions, occlusion relationships, materials and details, and state synchronization.
3. Method Breakdown: Translating Spatial Requirements into Executable Code
3.1 Set the Coordinate System and Scale Baseline First
The first principle of a spatial task is to establish a unified unit and coordinate baseline. Use meters as the unit, define the origin position, orientation, and floor height, then define the camera’s eye height (commonly around 1.6 meters). Express every component’s position as “baseline point + offset” to avoid scattered magic numbers.
// Example: unified scale and baselineconst UNIT = 1; // 1 unit = 1 meterconst EYE_HEIGHT = 1.6; // eye heightconst AXIS_WIDTH = 2.6; // central main aisle width (hard constraint)function place(obj, x, y, z) {obj.position.set(x * UNIT, y * UNIT, z * UNIT);return obj;}
3.2 Modular Breakdown: Structure Layer, Decor Layer, Prop Layer
Splitting the scene into three layers can significantly reduce coupling and rework costs:
- Structure layer: floor, walls, columns, door and window openings, and aisles—the immutable parts;
- Decor layer: grilles, ceilings, light strips, and signage, which can change with state;
- Prop layer: tables, chairs, booth seating, cookware, and glassware, responsible for close-up credibility.
When switching states, only replace the visibility of the decor and prop layers while the structure layer stays resident, which fundamentally guarantees camera consistency between “before” and “after.”
// Example: state switching only changes visibility, not structurefunction setState(state) {decorGroup.visible = state === 'decorated';propsGroup.visible = state === 'decorated';// structureGroup is always visible}
3.3 Visual Self-Check Loop: Let the Model “See” Its Own Result
Pure code reasoning struggles to catch occlusion and misalignment. A more reliable engineering approach is to connect the generation process to preview and screenshot capabilities, so the model gets visual feedback after each step and corrects accordingly. A typical loop looks like this:
- Generate or modify a piece of spatial code;
- Trigger a preview render and capture a frame from a fixed camera position;
- Compare the frame against the constraint list to locate clipping, occlusion, and proportion deviations;
- Go back to the code and fix it, repeating until it passes.
// Example: self-check loop (pseudocode)for (let i = 0; i < MAX_ITER; i++) {render(scene);const shot = capture(fixedCamera);const issues = inspect(shot, constraintList);if (issues.length === 0) break;patch(scene, issues);}
The value of this loop is that it turns “guessing the effect from code” into “changing code based on the frame.” It can catch problems that are visible to the eye but hard to detect in code, such as a wooden grille blocking a doorway or a partition misaligned with the soup surface.
4. Acceptance Checklist: When Does a Spatial Generation Task Pass?
It is best to use a checkable acceptance approach to avoid subjective judgment:
- The structure layer has exactly identical coordinates in both states, with no displacement of columns, openings, or aisles;
- The clear width of the main aisle meets the specified value, and furniture on both sides does not cross the boundary;
- Private-room door openings, grilles, and circulation are aligned, and the entrance offers a direct view of the dining table inside;
- Close-up details hold up: the media on both sides of the partition are distinct, and glassware has wall thickness;
- Interaction works: it supports multiple camera positions and free drag-to-look controls;
- Performance is acceptable: the frame rate is stable on the target device with no obvious stutter.
5. Common Failure Modes and How to Avoid Them
- Proportion drift: errors accumulate step by step in multi-zone layouts. The workaround is to lock the main aisle and column grid first, then expand to both sides.
- State desynchronization: rebuilding the entire scene on switch causes camera and scale changes. The workaround is to keep the structure resident and only switch visibility.
- Occlusion blind spots: decorative components block functional openings. The workaround is to capture fixed-camera screenshots and check them item by item.
- Missing details: close-ups show “paper-thin cups” or “zero-thickness walls.” The workaround is to model close-up props separately and give materials thickness.
- Missing interaction: you can only look, not move. The workaround is to define camera control and view-switching acceptance items before delivery.
6. Engineering Implementation Suggestions
In real projects, the above method can be solidified into a pipeline: the requirements side outputs a constraint list and a camera-position table; the generation side uses layered modeling and a unified coordinate system; the validation side connects preview screenshots and automated comparison; and the delivery side includes interaction notes and acceptance records. For team collaboration, you can use a container platform to unify the rendering environment, use object storage to keep versioned artifacts, and use logging and monitoring with alerts to track the failure rate of generation and rendering—turning a one-off “it runs” into a sustainable “maintainable.”
7. Conclusion
The significance of multimodal code generation is not to replace developers in writing pages, but to bring space, visuals, and rules into code expression, making “building a walkable space from zero” an engineerable task. Mastering these four things—coordinate baselines, layered modeling, visual self-checking, and checklist acceptance—lets you reliably get usable results in most spatial generation tasks.
