From Idea to Running Demo: Building a Rainy Night 3D Town with an AI Coding Assistant

    Turning a "convenience store on a rainy night in a small town" into a runnable, interactive 3D scene in the browser takes more than asking an AI coding assistant to generate all the code at once. This article walks through a complete workflow: modeling requirements into a verifiable spec, building a minimal skeleton first, implementing rain and lighting effects, setting a performance budget with adaptive quality tiers, and validating through small, iterative steps.

    From Idea to Running Demo: Building a Rainy Night 3D Town with an AI Coding Assistant

    Turning a “convenience store on a rainy night in a small town” from a mental image into a runnable, interactive 3D piece in the browser doesn’t hinge on getting an AI coding assistant to spit out all the code in one shot. The key is to break a vague visual concept into verifiable technical specifications, then approach the target through small, iterative steps. An AI coding assistant is well suited for skeleton generation, interface completion, parameter explanation, debugging suggestions, and documentation—but proportions, lighting, performance, and details still require developers to judge and communicate based on actual run results. Using the “rainy night 3D town” as an example, this article outlines a fairly complete, general-purpose workflow.

    1. Model the Requirements First, Don’t Jump Straight into Code

    A “rainy night town” is a compound scene. Describing it simply as “build a rainy-night convenience store” leads to runaway scope. A more sensible approach is to separate visual elements, functional elements, and engineering constraints.

    Visual elements include: a low-light night environment, contrast between the store’s interior and exterior lighting, wet ground reflections, rain streaks and rain mist, street scale, neon or sign glow, and silhouettes of distant buildings. Functional elements include: camera movement, rain toggle, light toggle, simple collision or boundary limits, performance monitoring, and quality switching. Engineering constraints include: target browsers, mobile compatibility, first-screen load time, asset size, frame rate budget, accessibility, and error fallbacks.

    You can organize these into a scene specification:

    1. {
    2. "scene": "rainy night town convenience store",
    3. "camera": { "mode": "first-person or orbit camera", "height": "set to street scale" },
    4. "weather": { "rain": true, "fog": true, "wetGround": true },
    5. "lighting": { "exterior": "low ambient light", "interior": "cool white key light", "accent": "warm light from signs and street lamps" },
    6. "interaction": ["movement", "rain toggle", "light toggle", "quality toggle"],
    7. "quality": ["high", "medium", "low"],
    8. "acceptance": ["runs correctly", "degrades on mobile", "no visible clipping", "stable frame rate"]
    9. }

    The value of this spec is twofold: it gives the AI coding assistant a clear input, and it gives the developer acceptance criteria. Prompts should include the role, technical constraints, acceptance standards, and step-by-step requirements—not just “build me a rainy-night convenience store.”

    2. Build the Skeleton First, Then Add Details

    Real-time 3D in the browser can typically be split into four layers: scene, rendering, interaction, and engineering. The scene layer handles node organization, camera, lights, and assets; the rendering layer handles the render loop, materials, post-processing, and resolution control; the interaction layer handles input events, state switching, and UI; the engineering layer handles asset loading, error handling, performance monitoring, and build delivery.

    Start with a minimal runnable skeleton: a ground plane, a box-shaped convenience store, a camera, a directional or ambient light, and a render loop. Once the skeleton runs, gradually add rain particles, wet materials, glowing signs, fog, and post-processing. The reason is that 3D scene problems tend to be coupled: bad lighting may come from material parameters, wrong proportions from camera FOV, and stuttering from pixel ratio or particle counts. Get the smallest closed loop working first so you can localize issues.

    At this stage, the AI coding assistant can generate module breakdowns and pseudocode, but the developer should set explicit constraints such as “no complex dependencies yet,” “all parameters centralized in config,” and “each module independently toggleable.” For example, the render loop can stay simple:

    1. let last = performance.now();
    2. function frame(now) {
    3. const dt = Math.min((now - last) / 1000, 0.05);
    4. last = now;
    5. updateCamera(dt);
    6. updateRain(dt);
    7. updateLights(dt);
    8. renderer.render(scene, camera);
    9. requestAnimationFrame(frame);
    10. }
    11. requestAnimationFrame(frame);

    This code isn’t complicated, but it establishes an upper bound on the time step, preventing particles from teleporting after the tab regains focus. Details like this should be written into the collaboration constraints explicitly rather than left to generated output.

    3. Key Techniques for the Rainy Night Atmosphere

    Whether a rainy night scene “looks right” usually comes down to four things: rain layering, wet ground feel, lighting contrast, and fog with depth.

    Rain streaks shouldn’t be a uniform grid of dots. A more natural approach is screen-space stretching or instanced particles, with raindrops offset by wind direction and given a lifecycle. Pseudocode:

    1. vec2 p = position.xy;
    2. p.x += wind.x * time;
    3. p.y -= fallSpeed * time;
    4. p = mod(p, bounds.xy);
    5. float alpha = smoothstep(0.0, 1.0, life);

    In the actual implementation, control particle count, size, and opacity to avoid overly dense rain that makes the image look gray and washed out. Wet ground can be approximated by increasing specular highlights, lowering roughness, and layering environment reflections; if performance is limited, use a simplified screen-space reflection or a pre-generated environment map. The store’s interior lighting should create a clear warm-cool contrast: a cool white key light inside to highlight products and glass, warm accents from street lamps and signs outside, with fog pulling apart the near and far layers.

    The AI coding assistant can help generate shader skeletons, explain parameters, and propose fallback options—but the final parameters must be tested on target devices. Rain particle count, fog density, and post-processing intensity should all be tuned against the actual image and frame rate, not copied from fixed values.

    4. Performance Budget and Adaptive Degradation

    Performance problems in 3D scenes usually come from pixel fill rate, particle counts, shadows, post-processing, and draw calls. In practice, set a budget first: target devices, acceptable frame rate, first-screen asset size, and maximum draw calls. Then define high, medium, and low quality tiers.

    1. const qualityLevels = [
    2. { name: "high", rainCount: 12000, pixelRatio: 2.0, shadows: true, post: true },
    3. { name: "medium", rainCount: 6000, pixelRatio: 1.5, shadows: false, post: true },
    4. { name: "low", rainCount: 2500, pixelRatio: 1.0, shadows: false, post: false }
    5. ];

    The numbers above are illustrative only and must be tuned with real device testing. Degradation strategies include: capping device pixel ratio, reducing rain particles, disabling shadows or lowering shadow resolution, disabling expensive post-processing, and reducing distant building detail. You can also add simple frame rate monitoring that automatically drops a quality tier when the frame rate stays below a threshold for a period—rather than making users hunt for settings manually.

    5. Interaction, Acceptance, and Engineering

    Playability doesn’t need to be complex, but it needs clear feedback. Camera movement, rain toggle, light toggle, and quality switching are all low-cost, high-impact interactions. During acceptance, check: whether the first screen runs, whether mobile can degrade gracefully, whether state switching is stable, whether window resizing behaves correctly, whether asset load failures have fallbacks, and whether the console stays free of persistent errors.

    On the engineering side, centralize scene parameters in configuration, separate asset loading from scene initialization, and treat error logs and performance metrics as observable items. If your team needs to host static assets and collect runtime metrics, general cloud capabilities such as object storage, logging services, and monitoring alerts can support the workflow—but the core remains the correct implementation of the local rendering pipeline, interaction logic, and performance strategy.

    Overall, an AI coding assistant is excellent for quickly turning an idea into a runnable prototype and for speeding up debugging and documentation—but it is not a “one-click finished product” replacement. Developers still need to provide clear specifications, step-by-step verification, real run feedback, and aesthetic judgment. Breaking the “rainy night town” into small, verifiable modules and refining proportions, performance, and details over multiple rounds of communication is the reliable path from idea to playable work.