Code-as-Room: Generating 3D Rooms from Top-Down View Images via Agentic Code Synthesis

Yixuan Yang, Zhen Luo, Wanshui Gan, Jinkun Hao, Junru Lu, Jinghao Yan, Zhaoyang Lyu, Xudong XuarXiv 2026

TL;DR

Code-as-Room (CaR) is a novel agentic framework that transforms a single top-down image into a fully functional, editable 3D Blender scene by synthesizing executable code. By employing a structured multi-stage pipeline and a cross-stage memory module, it overcomes the stability and "context forgetting" issues that typically plague Multimodal Large Language Model (MLLM) agents in complex 3D generation tasks.

What Problem Does This Paper Address?

Generating realistic 3D indoor environments is a cornerstone of VR, gaming, and embodied AI. While MLLMs have shown promise in 3D synthesis, they face two major hurdles:

  1. Spatial Imprecision: Text-to-3D methods often fail to capture the exact layout and relationships between objects.
  2. Agent Instability: Existing image-conditioned agents often fall into infinite loops or suffer from "context forgetting," where the model loses track of earlier scene elements during a long generation process. This leads to incomplete rooms, overlapping furniture, or code that simply won't run.

CaR addresses these by treating the 3D scene not as a static mesh, but as a structured program, using a top-down view as a global spatial prior.

Methods

The core of Code-as-Room is a structured execution harness that orchestrates an MLLM agent through a principled, five-phase pipeline:

  1. Image-based Scene Structuring: The agent parses the input image to identify functional zones, furniture hierarchies, and architectural elements (walls, doors), creating a holistic scene graph.
  2. Layout Code Generation: It generates initial Blender code for bounding-box proxies. Crucially, this stage includes a vision-feedback loop where the agent renders the current layout, critiques it against the original image, and revises the code to fix overlaps or missing items.
  3. Layout-Grounded Object Profiling: With the layout fixed, the agent infers detailed properties for each object, such as material, style, and functional attributes.
  4. Object-level Code Generation: The agent replaces simple boxes with detailed procedural geometry code or retrieves high-fidelity assets from a library for complex items.
  5. Interior Decoration: The final stage synthesizes code for PBR materials, AI-generated textures (for rugs or paintings), and realistic lighting.

A cross-stage memory module acts as a persistent state, ensuring that decisions made during scene structuring are preserved and accessible during the final decoration phase, preventing the "forgetting" typical of long-context agentic workflows.

Figure 2: Overview of the Code-as-Room pipeline. A single top-down view image is progressively transformed into a fully renderable 3D scene through a sequence of specialized MLLM agent stages, organized into five phases: image-based scene structuring, layout code generation, layout-grounded object profiling, object-level code generation, and interior decoration code generation. Arrows de- note data flow through the cross-stage memory system, wherein each stage reads upstream outputs and writes its own results as typed memory entries.

Datasets

The authors introduced a dedicated Image-to-3D Room synthesis benchmark consisting of 41 diverse scenes.

  • Diversity: Includes residential spaces (bedrooms, kitchens) and specialized environments (laboratories, cafes).
  • Complexity: Scenes are categorized into Simple, Middle, and Hard levels based on object density.
  • Input Variety: The benchmark tests robustness across photorealistic photos, synthetic renders, and abstract line drawings.
  • Evaluation: Metrics cover visual understanding (object recall), spatial reasoning (Layout IoU, rotation accuracy), code execution rates, and holistic scene quality.

Key Insights and Ideas

  • Code as Representation: Representing 3D scenes as Blender code makes the output inherently editable, interpretable, and compact compared to neural representations.
  • Visual Feedback is the "Critic": The "render-critique-revise" loop is essential. The paper finds that 5 iterations of feedback provide the best balance between quality and computational cost.
  • Memory as Glue: The cross-stage memory module is the primary defense against hallucination. Without it, later stages of the pipeline often fail to maintain consistency with the initial layout.
  • Staged Decomposition: By separating "where things are" (layout) from "what things look like" (geometry/material), the framework makes a massive reasoning task manageable for current MLLMs.

Key Results

The framework was tested using leading backbones like Gemini 3.1 Pro and GPT-5.5. The results demonstrate that CaR significantly elevates the capabilities of these models:

  • Stability: Gemini 3.1 Pro w/ CaR achieved a 95.5% Blender execution rate, compared to just 57.8% for direct generation.
  • Spatial Accuracy: Layout IoU jumped from ~17% (direct generation) to over 73% when using the CaR harness.
  • Human Preference: In human evaluations, CaR variants consistently scored higher in similarity, usability, and aesthetic quality compared to direct generation and previous state-of-the-art agents like VIGA.
Qualitative comparisons showing CaR's ability to generate stable, well-aligned 3D scenes compared to other methods.

Limitations and Future Work

  • Viewpoint Constraints: The system is currently optimized for top-down views. Adapting it for arbitrary perspective images remains a challenge.
  • Procedural Limits: While procedural code is great for layout, very complex organic shapes still require retrieval-based methods for high fidelity.
  • Temporal Consistency: While the 3D scenes are consistent, using them for high-quality video re-rendering (walkthroughs) still faces hurdles in temporal stability for long trajectories.

The authors suggest that future work will explore using video generation models as "neural renderers" to produce even more realistic and coherent visualizations of the generated 3D code.

Summary updated

BibTeX
@misc{yang2026code,
  author = {Yixuan Yang and Zhen Luo and Wanshui Gan and Jinkun Hao and Junru Lu and Jinghao Yan and Zhaoyang Lyu and Xudong Xu},
  title = {{Code-as-Room: Generating 3D Rooms from Top-Down View Images via Agentic Code Synthesis}},
  year = {2026},
  eprint = {2605.18451},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.18451},
}
Figure