Multimodal Code Generation for Interactive 3D Space Design

    Using a 450-square-meter restaurant space as a case study, this article explains how multimodal code generation can turn spatial requirements and visual references into an interactive browser-based 3D scene. It covers coordinate systems, layered modeling, reusable furniture components, unfinished and finished states, visual validation, camera controls, and performance optimization.

    Code generation models are moving beyond conventional software development into a broader range of tasks that can be expressed programmatically. These tasks extend beyond generating web pages or API code to describing video scenes, three-dimensional spaces, material properties, interaction logic, and even some physical rules.

    The challenge is not simply to understand a written request. A model must also interpret spatial relationships in images or screenshots and translate them into executable project code. Success therefore depends on more than whether the code runs: the scene must make spatial sense, maintain appropriate proportions, support natural interaction, and remain consistent across viewpoints.

    This article uses an unfinished, 450-square-meter restaurant space to explain how multimodal code generation can support a browser-accessible 3D visualization with preset viewpoints and free mouse or touch navigation.

    1. Why 3D Space Modeling Is More Complex Than Web Page Generation

    A static web page typically involves text, images, buttons, and layout. A 3D space requires geometry, coordinates, materials, lighting, cameras, and interaction to work together.

    The first challenge is spatial constraints. Real sites are rarely blank canvases. Structural columns, doors, windows, stairs, fire escape routes, and equipment areas may all be fixed. An incorrect dimension can affect furniture placement, circulation routes, and camera views throughout the project.

    The second challenge is relationships between objects. A private dining room is more than four walls: it needs correctly positioned door openings, adequate spacing between tables and chairs, sufficient passage widths, and appropriate wall thickness. A dining table must also sit at reasonable distances from chairs, tableware, lighting, and walking routes.

    The third challenge is consistency across viewpoints. Users may inspect the space from the entrance, service counter, main dining area, private rooms, or individual tables. Optimizing only for one screenshot can produce a scene that looks correct from the front but reveals intersecting geometry from another angle.

    A reliable 3D scene needs a unified world coordinate system, rather than separate arrangements assembled for individual views.

    2. Case Study Goals: From an Unfinished Floor Plan to an Interactive Space

    The project has five goals:

    1. Reconstruct the building footprint of approximately 450 square meters.
    2. Preserve fixed structures, including structural columns, doors, windows, and main circulation routes.
    3. Define the entrance frontage, main dining area, private dining rooms, kitchen, and dining zones.
    4. Support immediate switching between unfinished and finished states.
    5. Provide preset camera views alongside free mouse and touch navigation.

    To keep modeling manageable, build the scene progressively rather than generating every detail at once:

    • Structural layer: floors, walls, columns, doors, windows, and upper boundaries.
    • Functional layer: tables, chairs, service counters, and partitions.
    • Decorative layer: lighting fixtures, signage, materials, colors, and furnishings.
    • Interaction layer: camera controls, state switching, and object display.

    This separation reduces the cost of revisions. If the main dining area needs resizing, the structural and functional layers can be adjusted without rewriting all the lighting and decoration code.

    3. Establish a Shared Coordinate and Dimension System

    A common source of errors is allowing different modules to use different scales or positioning conventions. Define the basic rules before generating the scene.

    For example:

    • Use the X-axis for horizontal length.
    • Use the Z-axis for horizontal depth.
    • Use the Y-axis for vertical height.
    • Map one rendering unit to one real-world length unit.
    • Use a consistent object-positioning reference, such as the geometric center or a defined lower-left corner.
    • Read wall thickness, door opening height, and furniture dimensions from shared configuration data.

    An illustrative configuration might look like this:

    1. const spaceConfig = {
    2. width: 30,
    3. depth: 15,
    4. wallHeight: 3.2,
    5. wallThickness: 0.24,
    6. columns: [
    7. { x: 6, z: 4, width: 0.5, depth: 0.5 },
    8. { x: 18, z: 10, width: 0.5, depth: 0.5 }
    9. ],
    10. rooms: [
    11. { name: "Main dining area", x: 2, z: 2, width: 16, depth: 8 },
    12. { name: "Private dining area", x: 20, z: 2, width: 8, depth: 10 }
    13. ]
    14. };

    The key benefit is the separation of spatial data from rendering logic. When the site dimensions change, the configuration can be updated instead of manually editing geometry throughout the codebase.

    4. Build the Unfinished Structural Scene First

    The unfinished state should prioritize structural accuracy, not materials and decoration. A practical sequence is as follows.

    Create the Floor and Building Boundaries

    The floor establishes the height reference for every object. Create the complete floor first, then generate exterior walls from the building footprint.

    Walls should have thickness rather than being represented only by visually thin planes. Otherwise, oblique views may reveal missing back faces, lighting artifacts, or apparent penetration through surfaces.

    Add Structural Columns and Fixed Facilities

    Lock column positions early because they constrain passage widths and furniture layouts.

    Other fixed facilities may include stairs, elevators, service shafts, and equipment rooms. Mark these objects as non-movable so that later automated layout operations cannot override them.

    Define Doors, Windows, and Main Circulation Routes

    Doors and windows shape both the building’s appearance and the first view users see when entering.

    Main routes must remain continuous and unobstructed by furniture, partitions, or decoration. In a restaurant layout, customer, service, and back-of-house circulation should also be distinguished where possible.

    Separate Functional Areas

    Use walls, half-height partitions, or material differences to distinguish the main dining area, private rooms, checkout area, and kitchen.

    Do not rely on color alone. Color differences may be difficult to read from a distance, so reinforce zoning through changes in height, transparency, and structure.

    5. Generate Furniture and Decoration as Reusable Modules

    Once the base structure is stable, add furniture. Rather than writing large numbers of unrelated objects directly into the page, package them as reusable components.

    A dining table component might include:

    • A tabletop.
    • Table legs.
    • Cookware or plates.
    • Chairs.
    • Local lighting.
    • Optional labels and interaction events.

    Component-based generation makes dimensions and style easier to update consistently. Changing round tables to rectangular ones, or adjusting every chair’s height, can be handled in a shared generation function.

    Objects can also carry semantic properties:

    1. {
    2. type: "table",
    3. zone: "dining",
    4. capacity: 6,
    5. position: { x: 8, y: 0, z: 5 },
    6. rotation: 0
    7. }

    These properties help with debugging and can support click selection, zone-level statistics, object hiding, and state switching.

    6. Switch Between Unfinished and Finished States

    The unfinished and finished versions should not be treated as entirely separate scenes. Maintaining two independent models can cause walls, columns, doors, and windows to drift out of alignment.

    A more reliable approach is to share structural objects and switch materials, decoration, and visibility.

    Organize objects into three categories:

    • Fixed structure: floors, walls, columns, doors, and windows.
    • Interior finishes: ceilings, lighting fixtures, signage, and wall decoration.
    • Operational furnishings: tables, chairs, tableware, plants, and display signs.

    When switching states, retain the same structural geometry and change the visibility or materials of the other categories. The following illustrates the intended state-switching logic:

    1. function switchScene(mode) {
    2. const isFinished = mode === "finished";
    3. decorationGroup.visible = isFinished;
    4. furnitureGroup.visible = isFinished;
    5. rawWallMaterial.opacity = isFinished ? 0.2 : 1;
    6. finishedWallMaterial.visible = isFinished;
    7. }

    The exact visibility and material behavior must match the rendering implementation. Transparent walls also require attention to rendering order, since transparency can introduce depth-sorting artifacts.

    For larger scenes, replacing materials may be preferable to repeatedly destroying and rebuilding geometry.

    7. Use Visual Validation to Improve Scene Quality

    Code checks alone cannot identify every spatial problem. Many mistakes do not trigger runtime errors but still degrade the result:

    • A partition blocks a private dining room entrance.
    • A door’s swing conflicts with a circulation route.
    • Tables and chairs leave insufficient walking clearance.
    • A lighting fixture hangs too low.
    • Cookware is misaligned with the tabletop.
    • A wall obscures an important display area.
    • Objects intersect when viewed from a particular camera position.

    Use an iterative generate–capture–analyze–correct loop.

    In the first pass, build a low-detail scene to verify overall dimensions and zone relationships. In the second, add furniture and inspect passageways and object collisions. In the third, introduce materials and lighting and assess visual hierarchy. Finally, capture screenshots from every preset viewpoint to confirm that important areas are visible and coherent.

    If image understanding is available, screenshots can be fed back to the model for checks such as:

    1. Are there obvious geometry intersections?
    2. Are any objects floating or embedded in the floor?
    3. Are doors or windows obstructed?
    4. Is the main circulation route continuous?
    5. Do the unfinished and finished states preserve the same spatial structure?
    6. Are any objects visibly out of proportion?

    This feedback does not replace human review, but it can reduce straightforward visual errors.

    8. Design Cameras and Interaction Alongside the Scene

    Even an accurate model can be difficult to understand if its camera views are poorly designed. Provide at least three types of view:

    • Exterior entrance view: shows the frontage, entrance, and depth of the interior.
    • Eye-level view: approximates the experience of a customer entering the space.
    • Overhead overview: reveals the overall layout and relationships between zones.

    Free navigation should constrain minimum camera height, maximum distance, and pitch angle to reduce the risk of users moving below the floor or into unintended positions. Wall penetration also needs to be considered when designing camera behavior.

    On mobile devices, support touch dragging and pinch-to-zoom.

    Preset views can be managed through a shared configuration:

    1. const cameraViews = {
    2. entrance: { position: [2, 2, 12], target: [10, 1.5, 6] },
    3. hall: { position: [12, 1.7, 7], target: [18, 1.4, 7] },
    4. room: { position: [24, 1.7, 6], target: [24, 1.4, 9] }
    5. };

    Keep camera configuration separate from scene data so that viewpoints can be recalibrated quickly when the space changes.

    9. Address Performance Before Deployment

    As object counts grow, a browser-based 3D scene can become increasingly expensive to render. Common optimizations include:

    1. Reusing geometry and materials for identical furniture.
    2. Merging static objects to reduce draw calls.
    3. Using lower-detail models for distant objects.
    4. Limiting the coverage and resolution of real-time shadows.
    5. Culling regions that are not visible.
    6. Replacing complex decoration with textures or simplified geometry.
    7. Reducing rendering resolution on mobile devices.

    The page should also provide loading states and useful error messages. If a model, texture, or configuration file fails to load, users should see an explanation and an option to retry rather than a blank canvas.

    10. A Reusable Workflow for Multimodal 3D Generation

    The value of this case study lies not only in producing a navigable restaurant scene, but also in establishing a workflow that can be reused:

    1. Break natural-language requirements into structural constraints, object inventories, visual goals, and interaction goals.
    2. Establish shared coordinates and configuration data so the model does not guess dimensions while generating code.
    3. Generate geometry and functional zones through reusable modules.
    4. Create a visual feedback loop using screenshots and multiple viewpoints.
    5. Refine materials, lighting, and performance after the core functionality is correct.

    Multimodal code generation does not eliminate the need for design and engineering judgment. It automates repetitive scene-building work, while high-quality results still depend on explicit constraints, well-organized data, stable rendering logic, and ongoing visual review.

    The same approach can extend to exhibition planning, retail store design, home interior previews, industrial equipment layouts, and interactive teaching. As models become capable of interpreting text, images, space, and code together, software development can increasingly encompass not just writing programs, but constructing interactive representations of the physical world.