Code as an Asset: A Technical Breakdown of a 1.36MB Procedural 3D Demo
This article breaks down how an AI agent generated a browser-based, realistic-style shooter demo in a single 1.36MB local page, with no binary models or bitmap textures. It covers the size budget by module, the runtime generation pipeline, deterministic procedural techniques for meshes, materials, animation, and audio, a realistic view of the approach's strengths and limits, and a full cost analysis beyond token spend. It also offers engineering practices for adopting code-driven 3D assets.
1. The Signal: Output from a Long-Running Agent Task
A recent public experiment drew attention: a developer gave a single-sentence requirement—a realistic, high-visual-quality single-player shooter demo—and then stepped away. The agent ran for about 8 hours, consumed roughly $550 in token budget, and delivered a local page that opens directly in a browser, about 1.36MB in size.
What matters here is not the visuals but the delivery format: no binary model files like FBX or GLB, no bitmap texture folders, and no asset download step. Every asset is computed on the fly at runtime. This marks a paradigm shift in 3D content production—code as the asset, bypassing binary model files.
2. What the Size Budget Reveals
Breaking the 1.36MB down by responsibility makes the cost distribution clear (ratios are approximate):
| Module | Size Share | Responsibility |
|---|---|---|
| Rendering core and math library | ~50% | WebGL2 abstraction layer, matrix/quaternion operations |
| Scene layout manifest | ~10% | Level layout, giant cranes, waves, and wet ground |
| Parametric prop library | ~8% | Molds for containers, forklifts, generators, etc. |
| HUD and main loop | ~6.5% | Crosshair, collision boxes, state machine |
| Materials and industrial decals | ~5% | Canvas-printed nameplates at runtime, noise-driven rust |
| Weapons and hand motion | ~4% | Part assembly, spring feel, reload and inspect |
| Lighting and post-processing | ~4% | Baked sky, soft shadows, reflections, color grading |
| Mechanical enemies and skeletons | ~4% | Quadruped/flying unit assembly and stepping |
| Audio synthesis | ~4% | Math-based sound waves for gunfire, sea wind, and music |
| Particles and destruction | ~4% | Muzzle flash, shell ejection, black smoke, bullet holes, debris |
Two conclusions follow. First, the general-purpose rendering core takes up half the budget and is a fixed cost. Second, the actual “content” is compressed into a few hundred KB of parameters and algorithms. In traditional pipelines, assets that run to tens of megabytes are essentially runtime computation results frozen ahead of time and shipped across a network, whereas the procedural route chooses to compute everything on the spot each time.
3. The Runtime Generation Pipeline
Requirement description→ Asset manifest (semantic)→ Parametric molds (mesh = f(seed, params))→ Texture synthesis (Canvas/noise → runtime textures)→ Skeletons and animation (procedural gait, spring damping)→ Audio synthesis (waveform layering + envelopes)→ Frame loop (physics, collision, post-processing)
The key is determinism: the same seed must reproduce the same world, otherwise debugging and save games are impossible. So random number sources, noise, and time sources all need to be controllable.
// Deterministic PRNG: the same seed reproduces the same propfunction mulberry32(seed) {return function () {seed |= 0; seed = (seed + 0x6D2B79F5) | 0;let t = Math.imul(seed ^ (seed >>> 15), 1 | seed);t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;return ((t ^ (t >>> 14)) >>> 0) / 4294967296;};}const rnd = mulberry32(20261111);const rust = 0.15 + rnd() * 0.35; // rust intensity
4. Why “Pure Code Can’t Produce Fine Detail” Is an Outdated Claim
- Detail comes from functions, not pixels: wear, rust, and nameplates are printed on the fly by noise and a 2D canvas, so resolution costs no size.
- Repetition buys realism: containers, cargo crates, and props are mass-generated from a few molds plus parameter perturbation; industrial scenes naturally tolerate repetition.
- Motion relies on physics, not keyframes: reloads, recoil, and quadruped stepping use damped springs and inverse-kinematics approximations, eliminating animation assets.
- Sound is math: gunfire and sea wind are synthesized from waveform layering and envelopes, with zero sample memory.
- The weak spots are real: high-fidelity facial micro-expressions, complex cloth, and film-grade fluids remain weak; the procedural route excels at hard-surface, industrial, and mechanical subjects.
5. Cost-Effectiveness: Doing the Token Math
$550 over 8 hours is only the visible cost. A full accounting should include four items:
- Inference cost: strongly tied to context length and number of tool-call rounds; long-running tasks grow non-linearly.
- Rework cost: the success rate without human intervention is not 100%, and failed reruns must be counted.
- Runtime cost: procedural output has zero asset downloads, so edge and mobile traffic costs are extremely low—an underappreciated benefit.
- Maintenance cost: code as an asset can be diffed, reviewed, and regression-tested; binary assets are hard to version.
Conclusion: one-time generation is expensive, but distribution and iteration are cheap. If a product needs massive numbers of levels or frequent revisions, the procedural route has a lower total cost of ownership.
6. Engineering Recommendations
- Build the budget table before generating: give the agent explicit size and module quotas to avoid core bloat.
- Constrain determinism: fix the seed and random source so output is reproducible and therefore testable.
- Layer quality by tier: enable soft shadows and reflections on high-end machines, disable post-processing on low-end ones to hold frame rate.
- Keep assets semantic: describe the world with a “manifest + parameters” rather than handing over meshes directly.
- Cloud-side support: use object storage to host artifacts and versions, container platforms to run builds and stress tests, and logging plus monitoring/alerting services to track frame rate and error rate. On Baidu AI Cloud, a combination of general-purpose cloud products can close the loop without proprietary interfaces.
7. Closing Thoughts
The real lesson from this experiment is rewriting 3D assets from “files” into “functions.” When a generative agent can reliably produce reproducible, versionable, testable code assets, the bottleneck in content production shifts from art capacity to budget design and verification systems. For developers, the worthwhile move now is not to wait for a stronger model, but to shore up three things first: determinism, size budgets, and automated evaluation.
