Building a Rainy Night Convenience Store Scene in Three.js with an AI Coding Assistant

    This article walks through using an LLM-powered AI coding assistant to build a rainy-night convenience store scene in Three.js. It covers how to split the scene into technical modules, control proportions, design the lighting, add rain and wet ground reflections, prompt the assistant effectively, and tune performance.

    1. From Idea to Working Demo: A New Pattern for AI-Assisted Coding

    In the past, turning a vivid idea, such as “a convenience store glowing with warm light on a rainy night,” into a 3D piece that runs in a browser required a long technical setup. Developers had to build the rendering environment, write shaders, tune lighting, and handle materials. Now, LLM-powered AI coding assistants shorten this cycle considerably. Developers describe their intent in natural language, the assistant generates an initial code framework, and several rounds of conversation bring the result closer to the target effect.

    This is not a one-prompt, finished-product process, however. In practice, the first output rarely gets everything right. Proportions, performance, and details still need repeated discussion and adjustment. Understanding this is a prerequisite for using AI coding tools well.

    2. Breaking Down the Scene: Technical Elements of a Rainy Night Convenience Store

    Before writing any code, break the “small-town convenience store on a rainy night” into technical modules that can be built:

    1. Base scene and camera: Use Three.js to create the scene, a perspective camera, and a renderer, and set the viewport aspect ratio and background color. For a rainy night mood, use a dark blue, near-black background. This leaves room for contrast in the lighting later.
    1. const scene = new THREE.Scene();
    2. scene.background = new THREE.Color(0x0a0e1a);
    3. scene.fog = new THREE.FogExp2(0x0a0e1a, 0.035);

    Fog is an effective way to create depth on a rainy night. Exponential fog gradually blends distant buildings into the darkness.

    1. Proportion control for buildings and streets: The store, signs, shelves, road, and street lamps must all follow a consistent scale. Proportion is the most common source of problems. AI-generated starting code often makes doors several times taller than a person or leaves signs floating above the facade. These errors need explicit numerical constraints, for example: “The store is 6 meters wide and 3.5 meters high, and the door is 2.2 meters high.”

    2. Lighting system: The layers of light largely determine whether a rainy night scene works:

      • Keep the ambient light at very low intensity to set a cool color tone;
      • Place warm point lights inside the store so their glow spills out through the glass door;
      • Give the signs emissive materials to create a neon look;
      • Use cone-shaped lights for the street lamps to simulate light shafts, combined with fog to produce the Tyndall effect.
    3. Raindrops and ground reflections: A particle system can render the rain. A few thousand short falling line segments with transparent material give a convincing result. For the ground, combine a high-roughness texture with an environment map reflection to simulate a wet road with puddles.

    3. Working Effectively with the AI Assistant

    To get generated code close to the intended result quickly, turn vague aesthetic descriptions into precise technical instructions. These practices have proven effective:

    1. Generate one module at a time instead of describing the whole scene at once. The first conversation should only ask for the scene skeleton. After confirming that it runs, add the raindrops, lighting, and sign animations one at a time. Each change then has a limited scope, and errors are easier to trace.

    2. Use quantified language instead of adjectives. A request like “make the rain heavier” is vague. A better request is: “Increase the particle count from 3000 to 8000, raise the falling speed from 0.2 to 0.5, and move each particle along the y-axis every frame.” AI assistants interpret executable parameters far more accurately than descriptive language.

    3. Report performance problems early. If the frame rate drops, state the device and the scene where it happens, and ask the assistant for a fallback plan. Options include reducing the particle count, merging geometries, or lowering the shadow map resolution:

    1. renderer.shadowMap.type = THREE.PCFSoftShadowMap;
    2. // On mobile, disable shadows and use baked lighting instead

    4. Keep the key decisions from the conversation. Once a proportion or parameter is settled, include it in later prompts. This keeps the assistant from losing earlier decisions over many rounds of iteration.

    4. Refining Performance and Detail

    A visually satisfying scene usually takes several rounds of fine-tuning, sometimes more than a dozen. Common refinement points include:

    • Material tuning: The glass door of the store uses a light-transmitting material with an appropriate transmission value, so the warm interior light seeps out softly. This largely determines the atmosphere of the scene.
    • Animation timing: Raindrop speed and the neon flicker rate need to work together. A sign that flickers too fast looks cheap, so use random intervals combined with easing functions.
    • Draw call control: Merge large numbers of repeated objects, such as raindrops and bricks, with instanced rendering. This significantly reduces drawing overhead.
    • Mobile adaptation: Adjust the render resolution dynamically based on the device pixel ratio, trading off sharpness against smoothness.

    At this stage, the AI assistant handles most of the boilerplate code and parameter trial and error. The developer focuses on aesthetic judgment and feedback on the experience. The division of labor is clear.

    5. Summary and Reflections

    Building a 3D scene with an AI coding assistant shows that current AI programming tools can turn an idea into a working, interactive piece quickly. Their strengths are generating structured code, suggesting technical options, and handling repetitive parameter tuning. Creative direction, aesthetic standards, and performance trade-offs still require the developer to stay involved, acting as a product manager and tester.

    For developers, a useful mental model is to treat the AI as a collaborator that responds very quickly and has broad knowledge but needs clear instructions. The more precise the description and the more specific the feedback, the better the output. Once this way of working becomes familiar, the time from idea to demo can drop from several days to a few hours. That gives more ideas a chance to be tested and shared, which is where these tools add the most value to individual creativity.