Code as an Asset: A 1.36MB AI Native Approach to Compiling a Real-Time World
This article explores a different path for AI-driven 3D content production: moving assets from binary model files to code that compiles the world at runtime. It examines why binary assets bottleneck AI content pipelines, breaks down the size budget of a roughly 1.36MB playable first-person shooter page with no external asset packs, and explains the techniques behind runtime compilation, including parametric geometry, canvas-generated materials, spring-based animation, synthesized audio, and baked lighting. It also covers lifecycle cost, clear boundaries of the approach, and practical engineering recommendations.
If you are using AI to build a 3D game, your first instinct is usually one of two paths: have a generative tool output mesh models directly, or have an agent drive traditional modeling software to build assets automatically. After all that effort, what you often end up with is still a binary model file tens of megabytes in size, plus a few texture maps—and then you are back to wrestling with rigging, animation tuning, and asset management. This article discusses another approach: shifting the nature of assets from binary files to code, and compiling the entire world on the fly at runtime.
The Overlooked Problem: Binary Assets Are the Bottleneck in AI Content Production
The core asset in a traditional 3D pipeline is the binary model file. These files pack geometry, topology, and material references together. Their strength is broad compatibility with mainstream engines and modeling tools; their weaknesses are low information density, poor editability, and version diffs that are practically unreadable. For an AI generation workflow, the problems are even sharper:
- Generated results are hard to validate programmatically. Topology errors, flipped normals, and stretched UVs often require manual rework.
- Asset size scales with art fidelity, so bloat directly raises load times and peak memory usage.
- Assets are finished products rather than recipes, so a model cannot adjust its level of detail at runtime based on device capability.
This has led to a rethinking in the industry: a truly AI Native asset standard is not about having AI operate modeling software on behalf of humans. It is about bypassing the binary model file altogether—treating code as the asset and compiling the world at runtime.
Lessons from an Extreme Case
A recent and widely discussed experiment took a single natural-language requirement and had an AI coding tool run for hours with zero human intervention, producing a playable first-person shooter page with a realistic art style. The surprise was not the visuals but the size: the entire playable experience fits within roughly 1.36MB. It is a purely local web page with no external asset packs, no prebuilt models, and no texture files. All geometry, materials, and sound effects are computed in real time from code.
Abstracting its size structure yields a useful reference “budget table” (values are illustrative orders of magnitude):
| Module | Share of Size | Actual Responsibility |
|---|---|---|
| Rendering foundation and math library | ~50% | WebGL2 rendering wrapper, vector and matrix operations |
| Scene placement manifest | ~10% | Level layout, large machinery, water and ground puddles |
| Parametric prop library | ~8% | Reusable molds for containers, forklifts, generators, etc. |
| HUD, physics, and main flow | ~6.5% | Crosshair UI, collision boxes, state machine |
| Materials and industrial decals | ~5.3% | Canvas-printed nameplates, noise-generated rust |
| Weapons and motion | ~4.1% | Part assembly, recoil spring feel, reload inspection |
| Lighting and post-processing | ~3.9% | Baked sky, soft shadows, specular reflections, color grading |
| Mechanical enemies and skeletons | ~3.9% | Quadruped and flying unit assembly, walking animation |
| Sound and music | ~3.9% | Mathematical waveform synthesis for gunshots, sea wind, and score |
| Particles and destruction effects | ~3.8% | Muzzle flash, shell ejection, black smoke, bullet holes, debris |
The most important takeaway from this table: the rendering foundation is nearly half the total, while all “art assets” combined are under 40%—and all of them are code.
Technical Breakdown: Compiling the World at Runtime
1. Geometry: Parametric Molds Plus a Scene Manifest
Props are not modeled; they are generated from recipes. A container can be expressed as three sets of parameters: dimensions, edge bevels, and corrugation density. The scene file degrades into a placement manifest that records each instance’s position, rotation, scale, and mold reference. Illustrative code:
const container = buildContainer({ w: 2.4, h: 2.6, d: 6.0, ribStep: 0.28 });scene.add(instance(container, { pos: [12, 0, -30], rotY: 0.3 }));
The benefit is native support for instancing and level of detail: distant instances can keep only a bounding silhouette, while nearby ones expand corrugation and bevels.
2. Materials: Printed on a Canvas On the Fly
Textures do not come from files; they come from an offscreen canvas. First, a noise function generates base noise; then stripes, text, and wear masks are layered on top; finally the result is uploaded as a texture. Industrial decals such as nameplates, serial numbers, and warning stripes are especially suited to this method, because they are essentially typography plus noise rather than hand painting.
3. Animation and Feel: Springs and State Machines
Feel elements like weapon recoil and reload inspection use a damped spring model, which is both smaller in size and more natural than keyframes:
// Second-order damped spring: x is displacement, v is velocityv += (-k * x - c * v) * dt;x += v * dt;
A quadruped enemy’s gait is driven by phase-offset sine waves acting on its joints, with simple IK correction to plant the feet.
4. Audio: Mathematical Waveform Synthesis
A gunshot is a short noise envelope layered with a low-frequency impact; sea wind is filtered long noise; the score is oscillators plus envelopes. Everything is determined by sample rate and waveform parameters, with zero audio files.
5. Lighting: Baked into Code
Sky and distant lighting can be computed offline and written into code as lookup tables. At runtime, only soft shadows, specular reflections, and color grading are applied, avoiding the cost of real-time global illumination.
How to Evaluate Cost-Effectiveness: Break Cost into Four Items
Judging whether this kind of approach is worthwhile should not focus only on generation-stage consumption; it should consider the full lifecycle:
- Generation cost: one-time and reproducible, with marginal cost amortized across reuses.
- Distribution cost: package size drops from tens of megabytes to the megabyte range, significantly reducing first-load time and bandwidth overhead.
- Runtime cost: geometry and textures are parameter-driven and can be dynamically downgraded by device tier.
- Maintenance cost: assets are code, so they are diffable, testable, and regression-friendly, but they require engineering discipline.
The boundaries are equally clear: this paradigm excels at hard-surface, industrial-style, and procedurally repetitive structures. It is not advantageous for high-fidelity human faces, complex cloth, or scan-level realistic materials, so a hybrid pipeline remains the pragmatic choice.
Practical Engineering Recommendations
- Establish an asset budget table with a size cap for each module, and treat “megabytes” as a first-class metric in reviews.
- Use fixed random seeds to guarantee reproducibility, and bring the generation process into continuous integration for size and frame-rate regression.
- Version parametric molds, and have the scene manifest reference specific versions to avoid runtime drift.
- On the generation side, use a container platform for task isolation and elastic scheduling, send artifacts and logs to object storage and a logging service respectively, and track failure rates and durations with monitoring and alerts.
- If multi-agent collaborative generation is needed, decouple stages with a message queue to avoid long tasks blocking one another.
Conclusion
The value of this case is not any specific number but its proof that asset form can migrate: from binary finished products to executable recipes. When assets become code, AI output becomes readable, testable, and rollback-able for the first time, and size and quality are no longer in a simple linear relationship. For teams preparing to bring AI into a 3D content production line, what deserves priority validation is not a stronger generation model but a clearer asset standard.
