Code as Assets: A Technical Practice for AI-Generated 3D Games

    Binary mesh files produced by generative 3D pipelines discard structure and push integration work back onto people. This article explains an alternative—defining assets as parameters and algorithms that compile a world at runtime—using a 1.36MB single-file browser shooter, six implementation techniques, rollout guidance, and clear limits.

    1. Structural Bottlenecks in the Old Pipeline

    Two paths dominate generative 3D content today. One calls a mesh-generation service and receives a model directly. The other lets an agent drive modeling software. Both end in the same place: a binary mesh of tens of megabytes, plus a handful of textures.

    The problem is not generation quality. It is the form of the deliverable. A binary mesh is a snapshot of the result. It throws away the structure created along the way: how parts assemble, how materials are distributed, and how joints are bound. Everything after that falls back to manual work—rigging, animation, collision splitting, texture compression, and draw-call reduction. Time saved in generation is spent again during integration.

    Maintainability is worse. A 50MB model file cannot be reviewed as code, diffed, rebuilt at the needed level of detail, or trimmed at runtime for device capability. It is a black box.

    2. Invert the Idea: The Asset Is the Code That Generates It

    A route worth evaluating seriously is to skip the binary model file and define the asset as parameters and algorithms that compile the world on the spot at runtime.

    That route has three direct benefits:

    • Volume collapses. Geometry comes from parametric molds, instancing, and noise. Textures are drawn on a canvas or in a shader. Audio is synthesized from mathematical waveforms. What is stored is the recipe, not the finished product.
    • It can be reviewed, tested, and rebuilt. Once an asset is code, version control, unit tests, and on-demand recomputation come back.
    • Level of detail fits naturally. Runtime code can choose subdivision from distance and device performance instead of baking a fixed LOD chain in advance.

    The cost is equally clear. Runtime CPU and GPU budget is consumed, and realism is capped by what procedural methods can express. This is not a free lunch. It is a budget transfer: disk and bandwidth are traded for compute and engineering complexity.

    3. Case Breakdown: A 1.36MB Single-File Shooter

    In a published experiment, an engineer supplied one sentence—a realistic, AAA-looking single-player shooter—and did not intervene. The model ran continuously for about eight hours and produced a single-file page that opens directly in a browser. The file is about 1.36MB and has no external asset pack. Module sizes break down roughly as follows:

    Module Share of size What it actually does
    Rendering base and math library ~50% Browser graphics API wrappers, matrix and vector math
    Scene and placement list ~9.7% Level layout, large mechanical structures, waves and wet ground
    Parametric prop library ~8.1% Industrial molds such as containers, forklifts, and generators
    HUD, physics, and main loop ~6.5% Interface style, crosshair, collision boxes, game loop
    Materials and industrial decals ~5.3% On-the-spot nameplates, noise-based rust and grit
    Weapons, hands, and motion ~4.1% Part assembly, spring feel, reload and inspect motions
    Lighting and post-processing ~3.9% Dawn sky bake, soft shadows, specular reflection, color grading
    Mechanical enemies and skeletons ~3.9% Flying and quadruped assembly, gait driving
    Sound and score ~3.9% Math-wave gunshots, ambient wind, combat music
    Particles and destruction ~3.8% Muzzle flash, ejected shells, black smoke, bullet decals, debris

    Half the size sits in the rendering base. That matches engineering intuition: the base is a fixed cost and does not grow linearly with content. What matters is how far the content itself was compressed. Scene, props, materials, motion, audio, and effects together stay under 800KB and still support a playable level.

    4. Six Key Technical Points

    1. Parametric geometry and mold reuse

    Props are not modeled. They are assembled. A container is a box, an array of ribs, and corner castings. A forklift is a frame, hydraulic rods, and forks. The core is a parametric mold plus instancing plus noise: change a few parameters on the same mold to get a variant, instead of storing a mesh per object.

    1. mold(parameters):
    2. box(size, bevel)
    3. array(ribs, spacing, count)
    4. corner_castings(four_corners, size)
    5. material_slots(rust_strength, decal_id)
    6. instantiate(mold, transform_matrix, parameter_noise_seed)

    2. Procedural materials and decals

    Textures are not loaded. They are drawn in place: an offscreen canvas produces nameplate text and numbers, layered noise builds rust, grit, and water stains, and the result is uploaded as a texture. The gains are zero download, effectively unlimited resolution, and mipmaps generated on demand. The loss is hand-painted detail. The look stays consistent, but it lacks a handmade feel.

    3. Procedural skeleton and motion assembly

    A quadruped gait does not need an animation file. Phase-offset sine waves can drive the joints. Weapon feel comes from a spring-damper model rather than keyframes. Motion is naturally parametric—speed, weight, and recoil are variables—but expression is limited by the algorithm itself.

    4. Audio synthesis

    Gunshots, sea wind, and music are all synthesized from mathematical waveforms: noise envelopes, filters, and a short reverb. There are no audio files. The tradeoff is limited timbral realism, and synthesis cost rises with the number of concurrent sources.

    5. Lighting and post-processing

    The sky is baked from an analytic model into a texture. Shadows use a soft-shadow approach. Water uses a screen-space reflection approximation. A final grade unifies the image. Realism comes mainly from correct lighting and color, not from mesh precision. That is why a procedural route can approach a AAA look.

    6. Simplified collision and physics

    The render mesh and the collider are separate. Collision uses primitives such as boxes and capsules. That is required for performance, and it is a natural fit: colliders are already generated in code, so they do not need a separate production pass.

    5. Engineering Rollout

    If a real project adopts this route, move in this order:

    1. Start with a budget. Decide the runtime generation time the first screen can accept—hundreds of milliseconds is a reasonable target—and treat it as a hard CI constraint.
    2. Gate both size and performance. Fail the pipeline when artifact size, draw calls, or generation time cross their thresholds.
    3. Put generators under version control and tests. Write parameter-boundary tests for every mold so out-of-range values cannot produce degenerate geometry.
    4. Give the cloud only the work it should own. Distribute build artifacts from object storage behind a CDN. Run build jobs on a container platform so dependencies stay isolated. Send generation and runtime logs to a logging service. Feed size, duration, and error rate into monitoring and alerts. General Baidu AI Cloud capabilities such as object storage, a container platform, logging, and monitoring can cover this chain. Follow the official documentation for the actual integration.
    5. Keep a hybrid exit. For the few hero assets that truly need high fidelity, allow an external asset, but hide it behind a unified loading layer so the architecture is not locked in.

    6. Capability Limits and Risks

    Three limits should be stated plainly:

    • Realism has a ceiling. Procedural materials struggle to reproduce hand-painted detail and scanned textures. Faces and cloth are especially hard.
    • Maintainability cuts both ways. Code assets can be diffed, but the generator becomes a new center of complexity. When parameters couple badly, debugging can cost more than editing a model file.
    • Cost does not disappear. About $550 in token spend and eight hours of generation in this case show that cost moved to the model side. Input and output still have to be recalculated for the project’s scale.

    7. Conclusion

    “Code as the asset, compile the world at runtime” is not a replacement for a traditional art pipeline. It is a new path for fast prototypes, playable demos, procedural open worlds, and cases that need a very small package. The test is simple. If the bottleneck is asset size, iteration speed, or maintainability, the route is worth the investment. If the bottleneck is realism and art direction, it cannot carry that load yet.