Building a Rainy Night 3D Scene Prototype with AI Coding Assistants

    Learn how to use AI coding tools to build an interactive rainy night 3D scene prototype. This article covers requirements breakdown, scene scaffolding, layered prompting, code review, scale consistency, and performance budgeting for WebGL-style 3D prototyping.

    1. Problem Framing: The Role of AI Coding Tools in 3D Scene Prototypes

    The core of using an AI coding tool to build a rainy night scene is not “generating a finished piece from a single prompt.” Rather, it is about turning natural-language ideas into a runnable, inspectable, and iterable engineering prototype. A 3D scene involves cameras, lighting, materials, geometry, rain particles, ground reflection, interaction, and performance. A deviation in any of these areas affects the overall result. A more realistic division of labor is: the AI tool quickly produces the scene skeleton, sample code, and parameterized solutions, while the developer handles acceptance testing, parameter tuning, and engineering convergence.

    A key takeaway from hands-on practice: results rarely land perfectly on the first try—proportions, performance, and details still require repeated back-and-forth. But for prototyping purposes, these tools are already good enough to turn an idea in your head into something that actually runs and can be played with. This can be distilled into three engineering principles. First, get a minimal runnable scene working. Second, constrain proportions and performance with quantifiable metrics. Third, convert “communication” into structured prompts and code review checklists.

    2. Requirements Breakdown: From One Sentence to an Acceptance Checklist

    “A rainy night small town” is a vague description; handing it directly to a tool tends to produce randomly styled results. A more reliable approach is to break it down into an acceptance checklist first:

    1. Spatial scope: one street, one convenience store facade, and a handful of low-rise buildings, with scene boundaries kept at a scale that is explorable but not empty.
    2. Time and atmosphere: low nighttime illumination, cool ambient light, localized warm sign lighting, wet ground reflection, raindrops, and thin fog.
    3. Runnability: the page loads, the camera moves, the render loop is stable, and there are no console errors.
    4. Performance targets: maintain an interactive frame rate on ordinary office hardware, with particle counts, shadow resolution, and material complexity able to degrade gracefully.
    5. Level of detail: the nearby convenience store needs signage, an awning, and translucent glass; distant buildings can use low-poly models softened by fog.

    Writing these items into your prompt is far more effective than simply saying “build a rainy night town.” Prompts can be structured in three layers: a scene layer describing space and style, a technical layer describing render architecture and performance budget, and an acceptance layer describing required behaviors and degradation strategies. This way, the code an AI tool generates is closer to a reviewable engineering draft.

    3. Scene Skeleton: Camera, Lighting, Materials, and Rainy Night Atmosphere

    The first version of a 3D scene should prioritize the skeleton, not detail. The skeleton includes a perspective camera, basic ambient light, a key directional or local point light, a ground plane, city block volumes, a convenience store module, and the render loop. The rainy night atmosphere can be achieved through these general techniques:

    • Low ambient light combined with localized warm light to create a warm–cool contrast;
    • A ground material with a heightened sense of reflection, avoiding full mirror-like behavior that causes noise;
    • Raindrop particles cycling within a limited area, with particles near the camera slightly larger;
    • Fog to hide distant scene boundaries and reduce the pressure of long-range detail;
    • Emissive or semi-transparent materials for signs and glass, while keeping the number of transparent objects under control.

    Illustrative pseudocode follows. It expresses structure only and does not represent any specific engine API:

    1. // Illustrative pseudocode: decoupled from any specific rendering implementation
    2. function buildRainyTown(adapter) {
    3. const scene = adapter.createScene();
    4. const camera = adapter.createCamera({ fov: 55, near: 0.1, far: 300 });
    5. const lights = adapter.createLighting({ ambient: 0.25, key: 0.8 });
    6. const town = adapter.createGroup('town');
    7. const store = adapter.createStoreModule({
    8. width: 6,
    9. depth: 4,
    10. height: 3,
    11. warmLight: true
    12. });
    13. town.add(store);
    14. adapter.addRain(scene, { count: 1200, area: [40, 40], intensity: 0.6 });
    15. adapter.addGroundReflection(scene, { roughness: 0.2, opacity: 0.35 });
    16. adapter.addFog(scene, { near: 20, far: 120 });
    17. return { scene, camera, lights, town };
    18. }

    The value of this pseudocode lies in making module boundaries explicit: scene, camera, lighting, town group, rain, reflection, and fog can each be replaced and tuned independently. Developers can ask the AI tool to fill in each module one at a time, rather than generating one large, unmaintainable block of code.

    4. The Collaboration Workflow: Layered Prompting and Code Review

    When working with an AI coding tool, a “layered prompts + incremental acceptance” workflow is recommended:

    1. Round one: request only a minimal runnable scene—empty ground, camera, basic lighting, one convenience store volume, and the render loop.
    2. Round two: add the rainy night atmosphere—rain particles, fog, wet ground reflection, and warm–cool light contrast.
    3. Round three: add details—signage, awning, glass, roadside props, and low-poly distant buildings.
    4. Round four: optimize performance—cap particle counts, merge static geometry, reduce shadow overhead, and add degradation toggles.
    5. Each round should require change notes, a parameter table, and rollback points.

    Code review should focus on: unreleased rendering resources, object creation inside the render loop, excessive transparent materials, particle updates that allocate arrays every frame, an oversized camera far clipping plane, and light counts exceeding the budget. The AI tool can produce implementations quickly, but engineering constraints must be spelled out explicitly by the developer.

    5. Scale Consistency: Constraining Space with Reference Objects and Parameter Tables

    The most common problem in 3D scenes is scale distortion: doors too tall, streets too wide, raindrops too large, a convenience store that looks like a toy. The fix is not endless “eyeball adjustments” but establishing reference objects and a parameter table. For example, take an adult character of roughly 1.7 meters as the reference: a convenience store door about 2.1 meters tall, a sign’s bottom edge at about 2.5 meters, a street width of roughly 6 to 8 meters, and raindrop particle sizes kept within a centimeter-scale visual range. Writing these values into prompts and code constants gives later adjustments a concrete basis.

    At the same time, distinguish “real scale” from “camera scale.” For composition, the camera field of view, camera height, and street width can be moderately exaggerated, but reference relationships within the same scene must remain consistent. It’s advisable to define scale constants centrally in code, avoiding hard-coded values scattered across modules.

    6. Performance Budget and Degradation Strategies

    Performance pressure in a rainy night scene comes mainly from rain particles, transparent materials, reflection, shadows, and light count. Set a budget upfront: particle counts should be configurable, the number of transparent objects limited, shadows applied only to key near-field objects, and reflection implemented as a low-cost approximation rather than full-scene real-time reflection. More importantly, provide degradation strategies: on lower-end devices, reduce raindrop counts, disable some reflections, lower fog sampling, or reduce render resolution.

    Performance optimization should not break playability. Prioritize smooth camera movement and reliable scene loading before adding detail. For AI-generated code, check for common issues such as per-frame object allocation, frequent string concatenation, and unreused vectors. Only by writing the performance budget into the acceptance criteria can you avoid the “looks good but won’t run” outcome.

    7. Details and Playability: From Static Image to Interactive Prototype

    What separates a runnable piece from a static render is interaction and feedback. Low-cost interactions can be added, such as simple camera roaming, view switching, rain intensity adjustment, light toggles, and performance mode switching. On the detail side, translucent store glass, dripping awnings, ground puddles, sign glow, and distant building silhouettes all enhance the atmosphere—but the budget should follow a “high detail up close, medium detail mid-range, low detail in the distance” allocation.

    Final acceptance criteria can include: no page errors, working camera movement, a convincing rainy night atmosphere, no obvious scale distortion, interactivity on ordinary hardware, tunable parameters, and a code structure that remains maintainable. Through multiple iterations, the AI coding tool provides the speedup while the developer serves as the quality gate—only by combining the two can creative ideas be reliably turned into runnable 3D scene prototypes.