Building 3D Spaces with Large Language Models: A Practical Generative Coding Evaluation

    This article evaluates how large language models can generate executable, interactive 3D environments from structured spatial requirements. It covers parameterized scene design, constraint-based layout generation, synchronized raw and finished states, visual feedback loops, reproducible evaluation, and engineering practices for performance and deployment.

    1. Why Generative Coding Matters: Code as a Cross-Modal Representation

    Over the past two years, the coding capabilities of large language models have mainly been evaluated in two-dimensional text-based scenarios, such as building web pages, modifying APIs, and generating unit tests. However, code is not limited to interfaces. A video can be represented as a time series of frames, while a 3D scene can be described through geometry, materials, lighting, and camera parameters. Interaction and physical behavior can likewise be expressed through state machines and constraint solvers.

    Mapping these objects into executable code is the idea behind generative coding: the model does not merely output isolated snippets, but produces an executable, debuggable, and evolvable engineering artifact.

    The immediate benefit is that generated results can move from “looking right” to “running correctly.” Executability enables verification, and verification creates an iterative development loop instead of a one-shot generation process.

    2. Evaluation Scenario: An Interactive 3D Reconstruction of a 450-Square-Meter Shell Space

    To evaluate this capability, I designed a highly constrained task. Given a description of an approximately 450-square-meter unfinished space, the model had to generate a complete 3D environment that supported free navigation, camera switching, and drag-based view control. From the same camera position, users also needed to switch between an unfinished state and a decorated state with a single action.

    This scenario was selected because it exposes several important challenges:

    • Immutable structural constraints: Load-bearing columns, door and window openings, and the clear width of primary paths are rigid requirements. Any displacement can break the spatial logic.
    • Coordination across functional areas: The entrance, open seating area, private rooms, and back-of-house circulation must satisfy area allocations while avoiding conflicting traffic flows.
    • Consistency across two states: The unfinished and decorated geometries must share the same coordinate system and scale reference. Otherwise, switching between them immediately reveals misalignment.
    • Visual intersection and occlusion issues: Problems such as a wooden grille blocking a doorway or a partition facing the wrong direction are difficult to detect by inspecting code alone. They require visual feedback.

    3. Core Technical Challenges and Solutions

    3.1 Establish a Single Source of Truth for Scale and Coordinates

    The floor plan should be represented as a parameterized configuration. All geometry should be derived from this shared configuration instead of relying on hard-coded coordinates in multiple places.

    1. {
    2. "unit": "meter",
    3. "bounds": {"width": 18, "depth": 25, "height": 3.6},
    4. "fixed": [{"type": "column", "at": [6, 12], "size": [0.6, 0.6]}],
    5. "zones": [
    6. {"id": "lobby", "rect": [0, 0, 18, 10], "capacity": 24},
    7. {"id": "hall", "rect": [0, 10, 12, 15], "capacity": 40},
    8. {"id": "booth", "rect": [12, 10, 6, 15], "capacity": 16}
    9. ]
    10. }

    This approach ensures that the scene can be regenerated or modified without introducing inconsistent dimensions across different components.

    3.2 Use Constraint Solving Instead of Unrestricted Placement

    The system should first generate a layout skeleton, then validate it using rules such as minimum clear width, circulation connectivity, and collision detection. Invalid results should be rejected and regenerated or rearranged.

    1. def build_scene(cfg):
    2. scene = SceneGraph()
    3. for col in cfg.fixed:
    4. scene.add(collider(col)) # Reserve rigid structures first
    5. for zone in cfg.zones:
    6. cells = pack(zone, module=1.2) # Arrange elements using modular spacing
    7. assert clearance(cells, cfg.fixed) >= 1.2
    8. scene.add(group(zone.id, cells))
    9. return scene

    Rigid structural elements should be placed first, followed by modular elements within each functional zone. This makes it easier to preserve required clearances and prevent collisions with fixed objects.

    3.3 Share a Common Reference Between Two Scene States

    The unfinished and decorated states should use the same root transform. The decorative layer can be mounted as a switchable child node. Switching states should only change visibility and materials, not the underlying geometric reference.

    This ensures that both states remain spatially aligned and that the camera position remains valid after the transition.

    4. Visual Self-Inspection: Enabling the Model to Evaluate Its Own Output

    Text-only reasoning cannot reliably detect occlusion, intersections, or visual misalignment. The rendered output should therefore be fed back to the model to create a loop of generation, rendering, comparison, and correction.

    1. loop:
    2. code = model.generate(plan, feedback)
    3. image = render(code, camera=preset)
    4. report = compare(image, spec) # Occlusion/intersection/proportion/composition
    5. if report.passed: break
    6. feedback = report

    In production, it is useful to define a fixed set of camera presets, such as:

    • The entrance
    • The center of the main hall
    • The entrance to a private room
    • A top-down view

    Fixed viewpoints make the output from each iteration comparable. A maximum iteration count should also be established, especially when two consecutive iterations show no improvement. This prevents the system from consuming resources in an ineffective loop.

    5. A Reproducible Evaluation Method

    A practical evaluation framework should include the following elements:

    • Separate scoring dimensions: Score constraint compliance, spatial rationality, visual quality, interaction usability, and performance budget independently instead of reducing everything to a single score.
    • Layered test cases: Use four levels of difficulty: a simple single-zone scene, a complex multi-zone scene, a scene containing rigid structural elements, and a scene supporting two-state switching.
    • Automated assertions: Prioritize measurable indicators such as collision rate, minimum corridor width, render frame rate, and initial-load asset size.
    • Trajectory logging: Save the generated code and screenshots from every iteration. This makes it possible to determine whether a failure came from misunderstanding the requirements or executing them incorrectly.

    6. Performance and Engineering Recommendations

    As scene complexity increases, the system should pay close attention to instanced rendering, level of detail, texture compression, and occlusion culling. On the interaction side, input throttling and graceful degradation are recommended. Lower-end devices can automatically reduce shadow quality and post-processing effects.

    Generated artifacts should be distributed through object storage for static resources. Container platforms can host the build and preview services, while logging and monitoring systems should be integrated to track key indicators such as rendering failure rate, iteration count, and asset size.

    7. Conclusion

    The value of generative coding is not simply that it can produce code that runs. Its greater significance lies in bringing 3D spaces, interaction rules, and visual feedback into one verifiable engineering loop.

    Constraint modeling, a single source of truth, visual self-inspection, and quantitative evaluation are the four key practices for moving this capability from demonstrations into production.

    As multimodal understanding and code generation continue to improve, the engineering barriers to spatial construction, interactive creation, and digital twins will decrease significantly. At the same time, developers will increasingly differentiate themselves through the quality of their constraint definitions and evaluation systems.