Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Generate physically grounded 4D scenes from natural language through dual-stream architecture separating object detail from scene orchestration. VLM-Motion Critic validates physics parameters iteratively, bridging semantic-physical execution gap.
Code2Worlds: 4D World Generation from Code
Problem Context
Generating realistic 3D environments with physics requires balancing two competing demands: high-fidelity individual objects and coherent global layouts. Open-loop code generation often produces "physical hallucinations" where visual structures don't align with physics. A single monolithic generator struggles with multi-scale context management. Existing methods sacrifice local detail for global structure or vice versa.
Core Concept
Code2Worlds uses a dual-stream architecture to decouple concerns in 4D world generation:
Object Stream: Generates high-fidelity individual objects through retrieval-augmented parameter generation
Scene Stream: Orchestrates global environment with hierarchical planning
Rather than open-loop generation, a VLM-Motion Critic validates rendered simulations and iteratively refines physics parameters, bridging the semantic-physical execution gap. The system generates executable procedural code that creates both geometry and physics-driven animations.
Architecture Overview
Dual-Stream Generation: Object and scene streams with separate concerns
Retrieval-Augmented Parameters: Library-based parameter selection for object fidelity
Hierarchical Scene Planning: Multi-scale layout reasoning
Closed-Loop Refinement: VLM-Motion Critic validates and refines
Physics Parameter Inference: Automatic tuning of simulation parameters
Temporal Coherence: Ensures physics-consistent evolution over time
Executable Procedural Code: Generates Blender Python scripts or similar
# Retrieval-augmented generation: find similar objects
self
5
# Generate parameters building on retrieved examples
self
None
# Create object with generated parameters
'type'
'type'
'params'
'shape'
'material'
return
def
generate_scene_hierarchy
self, semantic_description,
objects, num_levels=3
"""
Stream 2: Orchestrate global environment hierarchically.
Plans placement and relationships at multiple scales.
"""
'objects'
'hierarchy_levels'
for
in
range
# High-level: spatial relationships (room layout)
# Mid-level: object groupings and constraints
# Low-level: fine position adjustments
if
0
# Room/environment scale
self
elif
1
# Object grouping scale
self
else
# Fine positioning scale
self
'hierarchy_levels'
'level'
'reasoning'
None
# For interpretability
'constraints'
None
return
def
infer_physics_parameters
self, scene
"""
Infer mass, friction, elasticity, etc. for realistic physics.
Uses object properties and scene context.
"""
for
in
'objects'
# Infer mass from size and material
'params'
'size'
'params'
'material'
# Infer friction from material
# Infer elasticity from interaction context
'id'
'mass'
'friction'
'elasticity'
'gravity'
9.8
return
def
generate_code
self, scene, physics_params
"""
Generate executable Blender Python script creating 4D scene.
Includes geometry, material, physics, and animation.
"""
"""
import bpy
import numpy as np
from blender_physics import RigidBody, PhysicsSimulation
# Clear scene
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
# Create objects from scene specification
"""
Executable code quality enabling direct simulation
Implementation checklist:
Build/integrate object parameter library
Implement dual-stream generators
Connect to physics simulator (Blender, Isaac Sim, etc.)
Integrate VLM for evaluation (GPT-4V or similar)
Test refinement loop convergence
Generate Blender/engine-specific code templates
Reference
Dual-stream architecture with closed-loop refinement enables generation of complex 4D scenes that balance semantic fidelity with physical plausibility. VLM-Motion Critic bridges the semantic-physical execution gap through iterative parameter refinement.