Building a Web 3D Rainy Night Scene with an AI Coding Assistant

    This guide walks through building an interactive 3D rainy night scene for the web, a small city with a convenience store, through multi-round conversations with an AI coding assistant. It covers scene planning, prompt design, iterative fixes for proportions, lighting, and performance, and deployment, and it ends with a reusable workflow.

    Building a Web 3D Rainy Night Scene with an AI Coding Assistant

    Turning a scene from your imagination into a working web piece that people can explore used to mean a long learning curve. You had to understand the rendering pipeline, the material system, and the animation loop, and then deal with compatibility issues across browsers and devices. Today, AI coding tools let you build an atmospheric 3D scene step by step through multi-round conversations, even if you are not a graphics specialist. This article uses a classic mood piece, “a rainy night town with a convenience store,” as an example. It reviews the process from zero to a working prototype and summarizes the methods you can reuse.

    1. From Scene Description to Technical Choices

    A rainy night scene works well as a practice project because it touches on several core elements of real-time rendering:

    • Light sources: the warm light of the convenience store, street lamps, and neon signs in the distance create multiple light sources;
    • Materials: the mirror-like reflections on a wet road, the transparency of shop windows, and the self-illuminated surfaces of signs;
    • Particle systems: falling raindrops, splashes, and ripples on puddles;
    • Atmosphere: fog, tone mapping, and post-processing that give the scene a cinematic feel.

    On the technical side, developers commonly build this kind of scene with a mature WebGL-based 3D rendering library. The library wraps concepts such as the scene graph, camera, lighting, and materials, so you can organize a 3D world declaratively. With a modern front-end toolchain, a single web page can carry the full experience. Users open a link and can interact with the scene right away, without installing anything.

    Before writing any code, write a “scene script” that defines the time (late at night), the weather (moderate rain), the main subject (a convenience store on a street corner), the camera (it can start outside the store and slowly move closer), and the interactions (drag the mouse to rotate the view, scroll to zoom). This script becomes the first requirements document for your conversations with the AI coding tool.

    2. Generating the First Prototype with a Structured Prompt

    The key to working with an AI coding tool is turning vague aesthetic goals into concrete technical instructions. A first prompt can be organized like this:

    Generate a single-file web page that uses a mainstream WebGL 3D rendering library. The scene should include a convenience store building with warm lighting, a rainy night street, wet ground with reflections, continuously falling raindrop particles, and environmental fog. The camera should support orbit controls. The overall color tone should be cool, and the interior of the store should be warm.

    The first version usually runs, but it often looks right only at a glance. The proportions are off, the lighting is flat, and the rain streaks look like straight lines. This is normal. The value of conversational development is not getting everything right in one step. It is getting a baseline you can iterate on quickly.

    The core skeleton of a typical first version looks roughly like this (illustrative code):

    1. // Scene and renderer
    2. const scene = new THREE.Scene();
    3. scene.fog = new THREE.FogExp2(0x0a0f1a, 0.035);
    4. const renderer = new THREE.WebGLRenderer({ antialias: true });
    5. renderer.toneMapping = THREE.ACESFilmicToneMapping;
    6. // Raindrops: Points with a custom falling animation
    7. const dropCount = 3000;
    8. const positions = new Float32Array(dropCount * 3);
    9. // ...initialize a random distribution, update the y coordinate every frame in animate()
    10. // Wet ground: low roughness + environment reflection
    11. const groundMat = new THREE.MeshStandardMaterial({
    12. color: 0x111418, roughness: 0.15, metalness: 0.6
    13. });

    3. Iteration One: Fixing Proportions and Spatial Relationships

    The most common problem in a first version is proportion. A door may be twice the height of a person, shelves may float in the air, or raindrop streaks may be the wrong length. The fix is to give the AI coding assistant a clear frame of reference instead of abstract adjectives. For example:

    Use an adult height of 1.7 meters as the baseline. The store door should be 2.2 meters tall, the storefront 6 meters wide, and the street 8 meters wide. Raindrops should fall at about 9 meters per second, and their visual length should not exceed 0.05 meters.

    When you convert aesthetic problems into numeric constraints, the model’s output becomes noticeably more consistent. You can also add a temporary 1.7-meter reference cube to the scene so you can check proportions by eye. Remove the cube once the proportions look right.

    4. Iteration Two: Tuning Lighting and Atmosphere

    Most of the atmosphere in a rainy night scene comes from lighting. Based on practical experience:

    1. Interior key light: use two or three point lights to simulate fluorescent tubes, with a warm color temperature (around 3000K), and enable shadows so the shelves cast soft layers of shadow on the floor;
    2. Street lamps: use spotlights that cast cone-shaped light downward, and add volumetric “fake light shafts” (semi-transparent cone meshes) to strengthen the rainy night mood;
    3. Neon accents: set an emissive value on the sign materials, and place point lights of a matching color on the ground below them, so the glow appears to spread across the wet pavement;
    4. Global settings: lower the ambient light intensity, use a cinematic tone mapping curve, and reduce exposure slightly so the dark areas sink.

    For each round of adjustment, give the AI coding assistant feedback in three parts: what is wrong, the expected result, and the direction of the suggested parameters. For example: “The store lighting is too flat. I want the shelves to have a clear boundary between light and dark. Enable shadows on the key light and increase the contrast.”

    5. Iteration Three: Performance Optimization

    Once particles, shadows, and reflections are combined, a drop in frame rate is likely. Common optimizations include:

    • Raindrop recycling: when a drop reaches the ground, reset it to the top and reuse it. This avoids repeatedly creating and destroying objects;
    • Limiting the shadow area: enable shadows only for the main light sources, and tighten the shadow camera frustum;
    • Simplified reflections: real-time reflection probes are expensive. A pre-baked environment map combined with a low-roughness material can approximate the wet ground look;
    • Pixel ratio limit: renderer.setPixelRatio(Math.min(devicePixelRatio, 2)) avoids over-rendering on high-density screens;
    • Batching and instancing: use instanced meshes (InstancedMesh) for repeated elements such as signs and shelf items to reduce draw calls.

    After optimization, measure the frame rate on your target devices. Use a stable 60 FPS as the baseline. If the scene falls short, reduce the number of particles or lights until it reaches the target.

    6. Iteration Four: Details and Interaction

    The last 20% of detail determines how compelling the piece feels:

    • When a raindrop lands, create a small expanding ring ripple (a ring mesh that grows and fades out);
    • Add a slowly rotating fan and a flickering light box inside the shop window to make the scene feel alive;
    • Add a slight camera sway to simulate a handheld camera;
    • Optionally add an ambient audio track. A white-noise rain sound greatly increases immersion. Provide a mute toggle.

    7. Publishing and Sharing

    The biggest advantage of a single-file page is that deployment is simple. Host it on any static file service, and you get a shareable link. For projects that need stable access and team collaboration, you can also place the static files in general-purpose object storage with static website hosting enabled, or deploy them to a container platform to manage versions and rollbacks. Combined with logging and monitoring alerts, you can track traffic and page performance, which closes the loop from creation to release to observation.

    8. Summary of the Method

    Looking back at the whole process, these principles are worth keeping:

    1. Write the scene script before the prompt: translate aesthetic goals into numbers and structure;
    2. Expect multiple iterations: conversational development is not a wish-granting machine. It works more like pair programming, and specific feedback speeds up convergence;
    3. Proportions, lighting, and performance are the three main hurdles: check every version against these three items;
    4. Keep the code readable: ask the assistant to organize code into modules (scene, lighting, particles, and interaction in separate files or functions). Otherwise, fine-tuning later becomes difficult.

    The distance from a one-sentence idea to a rainy night town where you can walk around under an umbrella in the browser keeps getting shorter. By learning how to work well with AI coding tools, anyone can turn an idea into a working, interactive piece.