Spatial AI Coding in Practice: How Multimodal LLMs Generate Interactive 3D Scenes

    This article examines spatial AI coding through a reproducible test: whether a multimodal LLM can deliver, in one pass, a freely navigable web-based 3D scene with switchable states and no visible clipping. It breaks down why rigid, coupled constraints make the task hard, then lays out a reusable implementation path built on a unified coordinate system, modular scene layers, and visibility-based state switching. It also covers the render-screenshot-compare-fix loop that drives visual self-correction, a practical acceptance checklist, and performance and maintainability practices for spatial scenes.

    1. From Writing Pages to Building Spaces: The Expanding Boundary of General-Purpose Coding

    Over the past two years, competition in code generation has centered on a single dimension: given a requirement description, can a model output code that runs and stays maintainable? Once multimodal capabilities entered the picture, both the input and output boundaries of coding were pushed outward. On the input side, a model can now take in screenshots, drawings, video frames, and the geometry and material information of a 3D scene. On the output side, results are no longer limited to forms and APIs; they can also be code expressions of spatial layouts, interaction logic, and physical rules. The industry often calls this kind of capability “general-purpose coding”: anything whose structure and rules can be formally described can be attempted through code generation.

    This article does not evaluate any specific product. Instead, it abstracts a representative technical question: given a 3D scene requirement with strong spatial constraints, can a model deliver in a single pass an interactive web page that supports free roaming, state switching, and has no obvious clipping? This question simultaneously tests code organization, spatial geometry understanding, the use of visual feedback, and self-correction. It is an effective angle for observing the real capability level of multimodal coding models.

    2. Task Setup: Why “Renovating a Bare Shell into a Complete Space” Is a Hard Problem

    To keep the discussion reproducible, we frame the task as follows: the input is a description of an empty bare-shell space of roughly 450 square meters, including immovable load-bearing columns, existing door and window openings, and a main aisle. Using a general-purpose 3D rendering approach, the model must build a fully functional, walkable, and interactive space from scratch, and support instant switching between a “bare-shell state” and a “fully renovated state” from the same camera position.

    The difficulty lies in constraints that are rigid and coupled:

    • Immutable constraints: Load-bearing structures, opening positions, and aisle widths are hard boundaries; any offset breaks the spatial logic.
    • Multi-zone coordination: The entrance, main hall, private rooms, and back-kitchen circulation must simultaneously satisfy area ratios and passage relationships. A local optimum is not a global optimum.
    • Dual-state consistency: The bare-shell and finished states share the same coordinate system, and the two states must align strictly within it; otherwise, misalignment shows up the moment you switch.
    • Visual verifiability: Problems such as clipping, occlusion, and distorted proportions often “look correct” at the code level and only become visible after rendering.

    Combined, these four factors elevate the task from “writing code that runs” to “building a self-consistent spatial model.”

    3. A Reusable Implementation Path: Modularity, Unified Coordinates, Layered States

    1. Fix the Coordinate System and Units Before Writing Any Geometry

    Most rework in spatial tasks stems from inconsistent coordinate systems. The recommended first step is to fix the unit (for example, 1 unit = 1 meter), the origin position, and the orientation convention, then abstract load-bearing columns, openings, and aisles into immutable configuration:

    1. // Spatial baseline config: all geometry references this config to avoid hard-coded coordinates
    2. const SPACE = {
    3. unit: 'meter',
    4. size: { width: 15, depth: 30, height: 3.2 },
    5. fixed: {
    6. columns: [{ x: 4.5, z: 8, r: 0.35 }, { x: 10.5, z: 22, r: 0.35 }],
    7. openings: [{ wall: 'south', center: 0, width: 2.4 }],
    8. mainAisle: { width: 1.8 }
    9. }
    10. };

    Turning the “immovable” parts into data is the prerequisite for all later layout calculations, and it makes it easier for the model to stay consistent during generation.

    2. Split the Scene by Functional Module, Not by Piling Up Lines of Code

    It is best to split the scene into modules that can be built and validated independently: a structure layer (floor, walls, columns), an envelope layer (doors, windows, partitions), a furniture layer (tables, chairs, bar counter), a decor layer (grilles, lighting, soft furnishings), and an interaction layer (camera positions, toggle switches). The benefit of modularity is not just readability; more importantly, it enables targeted rework: when the render looks wrong, you can quickly tell which layer the problem is in.

    1. const layers = ['structure', 'envelope', 'furniture', 'decor', 'interaction'];
    2. function buildScene(root, layerName, factory) {
    3. const group = new THREE.Group();
    4. group.name = layerName;
    5. factory(group);
    6. root.add(group);
    7. return group;
    8. }

    3. Implement Dual States with “Same Coordinates + Visibility Switching”

    The bare-shell and finished states should not maintain two separate coordinate sets. Instead, overlay different layers on the same spatial baseline and switch via visibility and material replacement. This makes switching nearly free and prevents the two models from drifting apart:

    1. function setState(state) {
    2. decorGroup.visible = state === 'finished';
    3. envelopeGroup.visible = true; // Envelope structure is shared by both states
    4. furnitureGroup.visible = state === 'finished';
    5. // Materials can be swapped in the finished state while geometry is reused
    6. }

    4. The Key Challenge: A Visual Self-Check Loop Is the Source of Stability

    Pure text reasoning struggles to catch problems like “a grille blocks a private-room doorway” or “a partition is misaligned with the direction of a soup pot,” because these are not syntax errors but spatial-relationship errors that appear only after rendering. The reliable approach is to turn “render, screenshot, compare, fix” into a closed loop:

    1. After generating or modifying code, automatically trigger a preview render.
    2. Take screenshots from several fixed camera positions covering key views such as the entrance, main aisle, private rooms, and back kitchen.
    3. Compare the screenshots against the requirement constraints item by item (whether openings are blocked, whether the aisle is unobstructed, whether proportions are reasonable).
    4. Based on the differences, locate the specific layer and entity, make a minimal change, and re-render.

    The engineering implication of this loop is that the model needs a combined ability to “read images, locate issues, and modify code,” while the user needs to provide a stable, reproducible preview and screenshot environment. Missing either side causes delivery quality to fluctuate significantly.

    5. Evaluation Checklist: How to Judge Whether a Spatial Generation Passes

    It is best to accept work through a checkable list rather than overall impression:

    • Hard constraints: zero offset in the position and size of load-bearing columns, openings, and the main aisle.
    • Global layout: reasonable area ratios across zones, with no deadlocks in circulation.
    • State switching: no jumps, misalignment, or flicker when switching from the same camera position.
    • Visual details: no clipping, no blocked doorways, no floating furniture.
    • Interaction completeness: camera switching, free dragging, and view reset all work.
    • Performance: acceptable frame rate on the target device, with reusable and releasable resources.

    6. Performance and Maintainability: Don’t Wait Until Acceptance to Think About It

    Spatial scenes are prone to being “runnable but laggy.” Common general-purpose optimizations include reusing geometry and materials, using instanced rendering for repeated components (such as tables, chairs, and grilles), applying visibility culling by area, tiering texture sizes, and adapting render resolution. For maintainability, keep layout parameters, material parameters, and interaction logic separated into configuration and modules so coordinates are not scattered everywhere; also keep a “constraints list” as the basis for regression testing, and re-check against it after every change.

    7. Conclusion: The Competitiveness of General-Purpose Coding Lies in the Loop, Not a Single Point

    The value of a multimodal coding model lies not in whether it can write longer code, but in whether it can chain “understand constraints, generate structure, observe results, and correct deviations” into a stable loop. For developers, rather than chasing how impressive a single generation looks, it is better to turn task constraints into data, modularize the scene, turn acceptance into a checklist, and set up a reproducible preview and screenshot environment. Once this engineering method is in place, improvements in model capability can be reliably converted into deliverable results. If you need to host preview artifacts, screenshots, and logs, you can use general-purpose cloud capabilities such as object storage, container platforms, and log monitoring to handle archiving and observability, making every generation traceable and reproducible.