Building a Rainy Night Convenience Store Scene in Three.js with LLMs: A Hands-On Guide

    This article is a hands-on guide to using large language models (LLMs) to build a rainy-night convenience store scene in Three.js from scratch. It explains why Web 3D is a strong testbed for AI coding assistants, how to turn a vague idea into structured technical requirements, how to implement the scene skeleton, warm/cool lighting, fog, and rain particles, how to iterate with specific feedback when the result is not right, and what performance optimizations matter for browser delivery.

    Why Use a Web 3D Scene as a Testbed

    A 3D scene is one of the most demanding paths from an idea to a finished artifact. Unlike ordinary page development, it does not rely on a large set of mature templates. It combines geometry modeling, material systems, lighting calculations, particle systems, camera controls, and many other technical dimensions. A “rainy-night convenience store” seems simple, but it requires handling several things at once:

    • Atmosphere: raindrops, wet-ground reflections, and neon glow create the emotional tone.
    • Technical depth: meshes, PBR materials, point lights, fog effects, and shaders.
    • Performance constraints: in the browser, frame rate and image quality must be balanced, so detail cannot be added without limit.

    This makes such a scene a good benchmark for LLM-powered coding assistants. The model has to write code, but it also has to understand visual design and engineering tradeoffs.

    From Inspiration to Requirements: Break It Down First

    If you ask a model directly to “make a rainy-night convenience store,” the result is often a scene that barely runs with rough details. A better method is to perform a round of requirement decomposition first and turn vague creativity into structured technical descriptions:

    1. Scene composition: street ground, convenience store building, glass windows, illuminated sign boxes, streetlights, and a few props such as trash cans, barriers, and utility poles.
    2. Weather system: continuously falling rain particles, puddle reflections, and localized fog.
    3. Dynamic elements: breathing sign flicker, warm light from the windows, and raindrop splash animation.
    4. Interaction and camera: orbit-style camera control that lets users drag to rotate and zoom.
    5. Performance target: a stable 60 fps on desktop and an upper limit on particle counts and geometry face counts.

    Handing this checklist to a coding assistant can significantly improve the output. The underlying idea is that humans are responsible for creative direction and tradeoffs, while the model is responsible for implementation and detail.

    Core Implementation

    Scene Skeleton

    Using a mainstream browser-side 3D rendering library such as Three.js, the base scene structure can be created like this:

    1. const scene = new THREE.Scene();
    2. scene.fog = new THREE.FogExp2(0x0a0a12, 0.035); // Night fog adds depth
    3. const camera = new THREE.PerspectiveCamera(55, innerWidth/innerHeight, 0.1, 100);
    4. camera.position.set(6, 3, 8);
    5. const renderer = new THREE.WebGLRenderer({ antialias: true });
    6. renderer.toneMapping = THREE.ACESFilmicToneMapping;
    7. renderer.toneMappingExposure = 1.2;

    Exponential fog is especially important in this rainy-night setting. It lets distant objects disappear naturally into the darkness and gives the scene a cinematic feel right away.

    Lighting Design: Warm and Cool Contrast

    The mood of a rainy night depends mostly on contrast between warm and cool light. The convenience store windows and signs can use warm colors around 0xffaa55, while the environment and moonlight can use cool colors around 0x334466. The wet ground can simulate reflections by combining meshStandardMaterial with an environment map and tuned metalness and roughness values.

    1. const windowLight = new THREE.PointLight(0xffb347, 8, 12, 2);
    2. windowLight.position.set(-2, 2.2, 3.2);
    3. const ambient = new THREE.HemisphereLight(0x223344, 0x080808, 0.6);

    For the store sign, a simple sine wave plus some noise can modulate emissive intensity and create a breathing flicker effect.

    Rain Particle System

    There are several ways to implement rain. Rendering tens of thousands of small particles with Points gives the best performance, but individual points lack a trailing-streak feel. Using elongated lines or custom shaders can show the speed of rain, at the cost of higher geometry overhead. A balanced approach is to store particle positions in a BufferGeometry and update them each frame:

    1. const rainCount = 8000;
    2. const positions = new Float32Array(rainCount * 3);
    3. const velocities = new Float32Array(rainCount);
    4. // Per frame: y -= velocity; if y < 0, reset to the top of the camera view

    With a few semi-transparent reflective planes on the ground, using a low-roughness material and a slight normal perturbation, the rain can feel as though it is actually landing.

    What Iteration Is Really Like

    A project like this rarely comes out perfect in one pass. Some common issues and practical responses include:

    • Proportion problems: the first version may have a door that is too small or windows with odd proportions. Instead of saying “it looks bad,” give concrete quantified feedback, such as “the door height should be about one third of the total building height, and the window width should cover about 60% of the front facade.”
    • Performance bottlenecks: too many particles or a high shadow map resolution can cause dropped frames. Ask the model to lower the shadow map to 1024, make the particle count a parameter, and merge static geometry to reduce draw calls.
    • Missing details: raindrops may not splash and puddles may not appear. List these issues one by one and ask the model to add them in separate rounds, verifying each round.

    In practice, this is high-frequency conversational development: propose a change, run a preview, compare against expectations, and give specific feedback. The model’s value is that it lowers the implementation cost of every iteration, leaving the human free to focus on the final look.

    Performance Optimization Checklist

    For delivering a 3D scene in the browser, these optimizations are almost always useful:

    1. Geometry merging: merge small static props such as stones and fences into one Mesh to reduce draw calls.
    2. Texture reuse and compression: share material instances and avoid loading the same texture repeatedly.
    3. Particle budget: dynamically adjust the rain count by device capability, and halve it on mobile.
    4. Render on demand: when there is no interaction or animation, reduce the frame rate or pause the render loop.
    5. Lazy loading and async construction: initialize the scene across multiple frames to avoid a long white screen on first load.

    Summary and Takeaways

    The practical result is that today’s LLM-powered coding assistants are capable enough to turn an idea into a runnable, explorable scene quickly. However, the process is not fully automatic. Creative direction, aesthetic judgment, and performance tradeoffs still need to be led by a human. The model’s role is to reduce the friction of implementation details.

    For developers who want to try a similar workflow, it is better to start with a small scene with a clear atmosphere goal and practice a loop of requirement decomposition, iterative rounds, and quantified feedback. This is closer to real collaborative development than trying to get everything right in one shot. As multimodal and code-generation capabilities continue to improve, this kind of human-machine co-creation may become a standard working model for independent developers and small teams.