Building a Rainy-Night Convenience Store Scene in Three.js with an AI Coding Assistant
This practical guide explains how to use an AI coding assistant to create a rainy-night convenience store scene in Three.js. It covers scene planning, an iterative AI-assisted development workflow, atmospheric lighting, emissive materials, wet-ground reflections, rain particles, performance optimization, and the path from a single building to a procedural small-town street.од
1. Why Build a Rainy-Night Convenience Store?
After learning the basics of 3D visualization APIs, many beginners struggle to find a practical project to build. A rainy-night convenience store is an effective exercise because it naturally brings together several core real-time rendering concepts:
- Atmospheric lighting: Night scenes rely on artificial light sources. Neon signs, interior lighting, and streetlight glows provide useful practice in tuning lights and materials.
- Weather effects: Rain introduces more advanced techniques, including particle systems, ground reflections, and wet-surface materials.
- Familiar details: Signs, shelves, glass storefronts, and other everyday elements are easy to compare with real-world references, making it easier to judge whether the scene looks convincing.
- Manageable scope: A small-town street or a single building can feel complete without allowing the project to become unmanageable.
This type of project is also well suited to AI-assisted programming. The requirements can be described clearly in natural language, the results are easy to inspect visually, and the feedback loop is short.
2. A Practical Workflow with an AI Coding Assistant
When using an intelligent coding tool to build this kind of scene, the process usually follows a repeating cycle: describe, generate, inspect, and revise.
- Describe the requirements structurally. Instead of simply asking for “a rainy-night convenience store,” break the request into modules: the background color and fog, the building geometry, emissive sign materials, rain particles, and orbit camera controls. The more structured the description, the more usable the generated code is likely to be.
- Move quickly and validate one module at a time. Start with the smallest runnable version, such as a box-shaped building and one point light. Once the environment works, add modules incrementally. Asking for several hundred lines of complete code at once can make debugging more difficult.
- Keep the conversation context. Paste the current code back into the conversation as you continue iterating. This allows the assistant to make incremental changes based on the existing structure instead of rebuilding the project from scratch each time.
- Describe observable problems precisely. For example, “the raindrops do not disappear when they reach the ground and keep accumulating” is more useful than simply saying “the rain effect is broken.”
In practice, the result will not always work perfectly on the first attempt. Incorrect proportions, performance bottlenecks, and missing details are common and usually require several rounds of refinement. Even so, an AI coding assistant can significantly reduce the time required to turn an idea into a runnable, interactive prototype. That reduction in the validation cycle is one of the main benefits of AI-assisted programming.
3. Key Technical Considerations
3.1 Creating a Nighttime Atmosphere with Fog and Color
The essence of a rainy night is that it should be dark without becoming completely black. Scene fog, such as THREE.Fog or FogExp2, can gradually blend distant objects into the night. Use a consistent dark blue-gray tone for both the background and the fog:
scene.background = new THREE.Color(0x0a0e1a);scene.fog = new THREE.Fog(0x0a0e1a, 10, 60);
3.2 Emissive Materials and Bloom
The appearance of a neon sign comes from combining an emissive material with a bloom effect in post-processing. A common approach is to use a bloom pass that blurs bright areas and layers the result over the original image, creating a natural glow around the sign.
Be careful with the brightness threshold and exposure. If they are set too aggressively, the entire scene can become overexposed.
3.3 Wet Ground and Reflections
Reflections on wet pavement are one of the most important details in a rainy-night scene. A simple approach is to increase the ground material’s metalness and reduce its roughness to simulate wet asphalt.
For higher visual quality, planar reflection techniques can produce more realistic reflections and stretch the lights across the ground. However, they add rendering overhead, so the trade-off should be evaluated against the capabilities of the target device.
3.4 Building a Rain Particle System
A basic rain effect can be created from a particle collection containing thousands of short line segments. Update their positions every frame, and reset a raindrop to the top when it falls below the ground:
positions[i + 1] -= speed;if (positions[i + 1] < 0) positions[i + 1] = 20;
A vertex shader can stretch the particles to make the rain streaks feel faster and more directional. When drops reach the ground, animated ripples can be added to reinforce the sense of physical interaction.
4. Performance Optimization
A small-town scene may contain many objects. Performance issues mainly come from three areas:
- Too many geometries and draw calls: Repeated elements such as raindrops, streetlights, and windows should use instanced rendering. This can reduce thousands of draw calls to only a few.
- Too many light sources: Keep the number of real-time point lights to a small number. Other apparent lights can be approximated with emissive textures or baked lighting.
- Post-processing overhead: Bloom and reflection effects can be expensive on mobile devices. Provide quality settings or automatically reduce effect quality based on device capabilities.
5. From One Scene to a Small Town
Once the convenience store is working, the same modular approach can be used to expand the project into a larger neighborhood. Buildings can be abstracted into configurable generator functions, allowing you to create rows of structures with randomized heights, widths, and sign styles.
Procedural layouts can place streetlights, utility poles, and other props throughout the scene. An orbit camera or an automated tour view can then connect the different parts of the environment into a coherent presentation.
At that point, building a rainy-night town is no longer just an idea. It becomes a complete, demonstrable, and shareable project.
The broader lesson is clear: an AI coding assistant is not a replacement for architectural decisions made by the developer. Its greatest value is reducing repetitive implementation work and making creative experimentation significantly faster.
