Building a Rainy-Night Town with Three.js and an LLM: From Idea to Working Scene
This article walks through building a rainy-night convenience store scene in Three.js with an LLM. It covers how to move from a one-sentence prompt to iterative refinement, the key techniques for fog, lighting, rain particles, and wet ground, and the common problems that come up when iterating on AI-generated code.
1. Why a Rainy-Night Town as a Practice Project
In Web 3D development, a “rainy-night convenience store” is a representative beginner project. It covers nearly every core topic in 3D development:
- Scene atmosphere: A rainy night requires handling lighting, fog, and reflections, which makes it a good test of how well you understand the rendering pipeline.
- Models and scale: Streets, shops, street lamps, and pedestrians need sensible spatial proportions.
- Particle systems: Simulating raindrops is one of the most classic particle use cases.
- Animation and interaction: Flickering neon signs, a free-roaming camera, and rain sound synced with the visuals.
More importantly, this kind of project gives instant feedback. As soon as the code runs, you can see whether the result looks right. That makes it well suited for testing the real efficiency of an AI-assisted coding workflow.
2. A Complete LLM-Assisted 3D Workflow
2.1 From One Sentence to a Task Breakdown
In a traditional process, you write a technical plan first and then implement it step by step. With an LLM, the workflow becomes: describe the vision → break down tasks → generate code → run and verify → iterate and fix.
For this project, the initial prompt does not need to be complicated. One sentence is enough to start:
Use Three.js to build a rainy-night convenience store on a street corner. Requirements: neon signs, a rain effect, wet ground with reflections, and mouse-drag camera navigation.
An LLM typically breaks this request into technical components: scene setup, camera and controls, lighting (ambient light plus point lights to simulate neon), a particle system for rain, ground material (a highly reflective PBR material), and an animation loop.
2.2 Prompting Strategy: Coarse First, Then Fine-Tune
A key lesson from practice is that you should not expect a perfect result in one go. A better approach is two rounds of conversation:
Round 1: build the skeleton. Ask the model for a complete, runnable base version. Focus on getting it to run first. Proportions and details can wait.
Round 2: refine the details. Based on the running result, give specific corrections, for example:
Rain is too sparse. Increase the density by 3x and add a slight tilt to simulate wind-driven rain.Slow the breathing effect of the store sign to one cycle every 2 seconds.Ground reflections are too strong. Reduce the contrast of the roughnessMap.
This “overall first, then local” rhythm works better than issuing dozens of requirements at once. When context is limited, models respond much better to a small number of clear, verifiable changes.
3. Key Technical Implementation Points
3.1 Atmosphere: Combining Fog and Lighting
The core of a rainy-night mood comes from three elements layered together: low light, wet reflections, and fog.
scene.fog = new THREE.FogExp2(0x0a0a12, 0.015);scene.add(new THREE.AmbientLight(0x1a1a2e, 0.6));const neonLight = new THREE.PointLight(0xff2d75, 2, 20);neonLight.position.set(5, 4, 0);
Exponential fog (FogExp2) suits a city at night better than linear fog, because it makes distant lights appear to glow softly. For neon signs, a point light paired with a self-illuminated material lights up the surroundings while keeping the sign itself bright.
3.2 Raindrop Particles: Balancing Performance and Visual Quality
For rain, use BufferGeometry + Points instead of creating a separate Mesh for each drop:
const count = 8000;const positions = new Float32Array(count * 3);for (let i = 0; i < count; i++) {positions[i * 3] = (Math.random() - 0.5) * 60;positions[i * 3 + 1] = Math.random() * 30;positions[i * 3 + 2] = (Math.random() - 0.5) * 60;}
In each frame of the render loop, update the Y coordinate and reset the drop when it reaches the ground. Combined with a stretched texture, this simulates falling rain streaks. Keep the particle count between a few thousand and about ten thousand. On mobile devices, reduce the count dynamically based on device performance.
3.3 Wet Ground: A Low-Cost Reflection Approach
True mirror reflections are expensive. A practical alternative is a standard material with high metalness and low roughness, combined with an environment map. This produces the look of asphalt soaked by rain, with negligible performance cost.
4. Common Problems and Fixes During Iteration
In practice, AI-generated code usually runs into three types of problems:
- Wrong proportions: The store is too large or too small relative to the street. Fix this by setting a unified scale reference (for example, 1 unit = 1 meter) and stating it explicitly in the prompt.
- Performance bottlenecks: Oversized shadow maps and too many particles cause frame drops. Fix these by limiting shadow resolution, merging static geometry, and enabling antialiasing only when needed.
- Missing detail: The model generates the objects, but the scene lacks life. Fix this by adding descriptive details, such as dripping eaves, outdoor AC units, or shelf silhouettes behind the glass, and letting the model add them step by step.
These issues show that LLM coding assistance is not a one-click solution. It works more like a responsive pair programmer that needs clear instructions. Human judgment on aesthetics, acceptance criteria, and the direction of iteration remains essential.
5. Reflections on the Workflow
The biggest takeaway from this project is not the single scene itself but the validation of a new development approach:
- The cycle from idea to prototype is much shorter. A demo scene that once took days to build can now reach a runnable version in tens of minutes.
- Communication cost shifts from writing code to writing clear requirements. Describing requirements well becomes a core skill.
- Iterative dialogue beats one large request. Small steps, with verification at each round, are the most effective rhythm for working with a model.
The limits are also clear. Models still struggle with complex physics simulation and with managing detailed art assets. Production projects still need engineers for architecture and performance work. For creative validation, prototypes, and teaching examples, however, this natural-language-driven 3D workflow already offers practical value.
Although the rainy-night town is small, it offers a glimpse of how development may evolve. When an idea can be translated directly into a working, interactive piece through language, the barrier to creation starts to change.
