Code2Worlds: Empowering Coding LLMs for 4D World Generation
Abstract
Achieving spatial intelligence requires moving beyond visual plausibility to build world simulators grounded in physical laws. While coding LLMs have advanced static 3D scene generation, extending this paradigm to 4D dynamics remains a critical frontier. This task presents two fundamental challenges: multi-scale context entanglement, where monolithic generation fails to balance local object structures with global environmental layouts; and a semantic-physical execution gap, where open-loop code generation leads to physical hallucinations lacking dynamic fidelity. We introduce Code2Worlds, a framework that formulates 4D generation as language-to-simulation code generation. First, we propose a dual-stream architecture that disentangles retrieval-augmented object generation from hierarchical environmental orchestration. Second, to ensure dynamic fidelity, we establish a physics-aware closed-loop mechanism in which a PostProcess Agent scripts dynamics, coupled with a VLM-Motion Critic that performs self-reflection to iteratively refine simulation code. Evaluations on the Code4D benchmark show Code2Worlds outperforms baselines with a 41% SGS gain and 49% higher Richness, while uniquely generating physics-aware dynamics absent in prior static methods.
Lay Summary
Code2Worlds is a system that turns text descriptions into controllable 4D worlds that can change over time. Instead of only generating images or videos, it generates computer programs to build and animate scenes, making the results easier to edit and reuse. The system creates detailed objects, arranges them into realistic environments, and checks whether their motion is physically reasonable. This helps produce richer and more reliable virtual worlds for simulation, robotics, games, and creative design.