Building a Three.js Rainy Night Convenience Store Scene with an AI Coding Assistant
This article explores the practical workflow of using an AI coding assistant to build a Three.js rainy night convenience store scene. It breaks down the technical implementation of the scene, shares best practices for collaborating with AI on WebGL projects, and details the iteration process from a basic prototype to a polished, performant final product. It serves as a methodology guide for developers looking to rapidly turn creative ideas into runnable web experiences.
I. It Starts With a Creative Idea
Late night, rain, neon lights, and a warmly lit convenience store—this is a scene many developers have in mind when they think, “I want to build this.” Implementing a 3D rainy night convenience store scene that runs in a browser using the WebGL tech stack used to require developers to be highly proficient in 3D rendering, shaders, and animation systems, often taking days to build from scratch. Today, with the help of an AI coding assistant, this cycle can be compressed into a few hours, or even a single conversation to get a basically runnable version.
This article does not focus on a specific product but uses this practice as a sample to summarize a general methodology on “how to collaborate efficiently with an AI coding assistant to quickly turn ideas in your head into runnable, interactive works.”
II. Technical Breakdown of the Scene
Before getting started, it is necessary to break down the vague concept of a “rainy night convenience store” into implementable technical elements:
1. Scene Modeling
The convenience store itself can be built from geometric combinations: a rectangular box for the main building structure, planes for the storefront glass, and low-poly shelves and counters for the interior. AI assistants are good at generating this kind of basic modeling code based on text descriptions, such as using BoxGeometry and PlaneGeometry to quickly piece together the structure.
2. The Core of the Rainy Atmosphere: Particle Rain
The most intuitive implementation of rain is a particle system. A common approach is to use BufferGeometry + Points:
const rainCount = 8000;const positions = new Float32Array(rainCount * 3);for (let i = 0; i < rainCount; i++) {positions[i * 3] = Math.random() * 60 - 30;positions[i * 3 + 1] = Math.random() * 30;positions[i * 3 + 2] = Math.random() * 60 - 30;}
Combined with a custom shader or simple per-frame displacement, the falling effect can be simulated. Material transparency and stretching effects can then be used to enhance the texture of the rain streaks.
3. Lighting and Neon
The atmosphere of a rainy night relies heavily on lighting: warm-toned point lights simulate the interior store lights, cold-toned ambient light darkens the overall image, and the neon signboard on the storefront can use an emissive material combined with Bloom post-processing to produce a halo effect.
4. Ground Reflection
A wet road surface is the soul of a rainy night scene. A common practice is to approximate the reflection effect using a ground material with high metalness and low roughness, or use a reflection plane for a more realistic mirror effect.
5. Interaction and Camera
Adding mouse-controlled perspectives and slow camera panning allows the work to transition from a “static image” to an “interactive space.”
III. The Right Posture for Collaborating with an AI Assistant
An important conclusion drawn from this practice is: It is rarely perfect in one shot. The initial code generated by the AI assistant often suffers from proportion distortions, performance issues, or missing details, requiring multiple rounds of communication and iteration. Here are a few practical tips:
1. Break Big Requirements into Small Steps
Do not expect a perfect result from a single prompt like “give me a rainy night convenience store.” A better approach is to ask in stages: first build the scene structure, then add the rain effect, then adjust the lighting, and finally do the post-processing. Each step has clear acceptance criteria, making it easier to pinpoint errors when they occur.
2. Use Specific Feedback Instead of Vague Evaluations
“Looks bad” provides almost no guidance to the AI; whereas “The raindrops are too sparse, double the quantity, and slow down the falling speed by 20%” can directly drive effective modifications. Providing error messages, screenshot descriptions, and parameter expectations is key to high-quality collaboration.
3. Proactively Manage Performance
AI-generated code often ignores performance issues. Typical optimizations in practice include:
- Rendering raindrops as a single geometry to avoid tens of thousands of Meshes;
- Downgrading or disabling post-processing (Bloom, anti-aliasing) based on device capabilities;
- Limiting the upper limit of the pixel ratio, for example,
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)); - Using throttled handling for window events to avoid frequent reflows.
4. Repeatedly Check Proportions
Common flaws in the initial version of a scene include doors that are too high, shelves that are too small, and incorrect camera positions. In these cases, describing relative relationships is more effective than describing values. Relative descriptions like “The door height is about one-third of the building height, and the shelves should be close to the ceiling” are easier for the AI to understand and execute.
IV. Record of the Iteration and Tuning Process
Taking this practice as an example, the overall iteration path was roughly as follows:
- Round 1: Generated the basic scene. It ran, but the visuals were plain. The rain effect looked like “snow,” and the ground had no reflection.
- Round 2: Corrected the particle movement logic (added falling acceleration and ground reset), adjusted the color temperature contrast of the lights, and added a ground reflection material.
- Round 3: Added a neon signboard flicker animation, glass light transmission effects, and Bloom post-processing to give the lights a halo.
- Round 4: Performance stress testing and downgrade strategy—automatically reducing the number of raindrops and disabling high-overhead post-processing on low-end devices.
After four rounds, the work evolved from a “technical demo” to a “complete work with atmosphere.” The AI handled a large amount of boilerplate code writing and parameter trial-and-error, while the developer focused on aesthetic judgment and experience polishing.
V. Methodology Summary
Looking back at the entire process, a few general collaboration insights can be extracted:
- AI excels at “0 to 0.6”: The leap from an idea to a runnable prototype has become faster than ever.
- Humans are responsible for “0.6 to 1”: Proportions, atmosphere, performance, and details—judgments that rely on aesthetics and experience—remain where human value lies.
- Descriptive ability equals productivity: The ability to translate vague feelings into precise technical language determines iteration efficiency.
- Performance awareness cannot be outsourced: The AI will not proactively optimize for your target devices; the performance budget must be maintained by the developer.
For developers looking to try this, it is recommended to start with a small but complete scene and treat every conversation with the AI as a combination of a requirement review and a code review. When “building a small rainy night city” goes from a multi-day task to an evening’s enjoyment, the barrier to technical creation is genuinely lowering—and this is the greatest significance of AI-assisted programming.
