Building a Rainy Night 3D Town with an AI Coding Assistant: A Practical Guide
This article walks through building a browser-based rainy night 3D town with the help of an AI coding assistant. It covers defining experience goals, establishing believable proportions, layering the scene into manageable parts, using warm-and-cool lighting contrast and wet surface textures, designing a scalable rain particle system, breaking large tasks into small steps, optimizing performance within a fixed budget, polishing details, and testing across desktop and mobile environments. Instead of tying the process to any single product, it presents a general, transferable workflow that helps developers turn a vague idea into a runnable, interactive, and continuously iterable 3D experience.
As browser-based 3D content becomes more common, many developers want to turn “the image in their head” into a work that can run, be interacted with, and be shared. A rainy night town is an excellent theme for this kind of project: it has clear visual focal points such as a convenience store, streets, lights, rain, and wet ground, while also offering plenty of technical room to explore—scene organization, camera movement, particle systems, material rendering, performance budgets, and multi-device adaptation. An AI coding assistant can reduce the cost of building a foundation from scratch, letting developers spend more energy on creative definition, aesthetic judgment, and performance tuning.
At the same time, an AI coding assistant does not automatically replace engineering judgment. It is good at generating code structures from clear instructions, filling in implementation details, suggesting parameter adjustments, and helping locate problems during development. But whether the final work looks good, runs smoothly, and stays stable still depends on the developer’s understanding of scene proportions, visual hierarchy, interaction logic, and performance boundaries. For that reason, this article is not centered on any specific product. It approaches the topic as a general technical practice and discusses how to use an AI coding assistant to build, tune, and deliver a rainy night 3D town.
1. Define the Goal First: From “A Scene” to “An Experienceable Work”
Before writing any code, avoid a common mistake: treating “make a small town” as a vague goal. A truly deliverable 3D work should be broken down into clear experience goals. For example:
- When users open the page, they can quickly see a small scene with a rainy night atmosphere;
- The scene has a clear visual center, such as a convenience store glowing with warm light;
- Users can observe the scene through rotation, zooming, or an automatic camera tour;
- Elements such as rain, lights, fog, and wet ground reflections together build the atmosphere;
- The scene stays reasonably smooth on both ordinary desktop and mobile devices;
- Resource size stays manageable and loading completes progressively.
From these goals, you can further split the task into four layers:
- Visual goal: Does the scene look like a rainy night town? Is the convenience store the visual center? Is the rain obvious enough without blocking the view?
- Interaction goal: Can users smoothly rotate, zoom, and move the viewpoint? Are there problems with going out of bounds or clipping through buildings?
- Performance goal: Is the frame rate stable on the target device? Are the raindrop count, shadow range, and transparent materials under control?
- Engineering goal: Is the code structure clear? Are resources easy to replace? Can new elements be added quickly later?
Once the goals are broken down, communication with the AI coding assistant also becomes more efficient. Instead of just saying “make a rainy night convenience store,” give structured constraints such as:
Please generate a browser-based 3D rainy night scene. The main subject is a small convenience store surrounded by streets, street lights, and light fog. Requirements: build the structure from simple geometric shapes and avoid overly complex textures; render rain using batched particles or instancing; the store interior has warm lighting while the exterior is cool-toned; the initial camera looks slightly downward to highlight the sign and the wet ground; support user rotation and zoom; on mobile, reduce the raindrop count and render resolution.
This way of describing the task turns creativity into executable requirements, so the code the assistant produces is closer to a runnable prototype rather than only a reference snippet.
2. Start with Proportion: The First Principle Is Believability
A rainy night town emphasizes atmosphere, but proportion is still the foundation. Many 3D scenes look atmospheric at first glance yet feel “fake” up close, and the reason is often not that the models are insufficiently detailed but that proportions and scale are distorted. For example, if the convenience store is too tall or too short, if the street is too wide or too narrow, or if the raindrops are too large or too small, the overall believability breaks down.
A simplified rainy night convenience store scene can follow these scale guidelines:
- Keep the convenience store height between roughly three and four meters, matching a typical small commercial space;
- Organize details such as the sign, glass doors and windows, steps, and canopy around human scale;
- The street width should not be too narrow, or camera movement will feel cramped; nor too wide, or the store will lose its role as the visual center;
- The rain should cover the main visible area but does not need to extend infinitely;
- The camera height can be set near a pedestrian’s viewpoint or slightly elevated, so the sign, the falling rain, and the ground reflections can be seen at the same time.
Once proportions are set, camera composition has a foundation to build on. Rainy scenes are especially suited to low-angle shots, because a low angle makes the rain streaks more visible, brings out the ground reflections, and lets distant lights form layers. But if the camera is too low, users will easily see the edges of the scene and reveal its limits; if it is too high, the immersion of a rainy street weakens. So the initial camera position usually needs repeated adjustment—it should deliver atmosphere while leaving room for exploration.
3. Layer the Scene: Break the Town into a Manageable Structure
A complex 3D scene should not be treated as a single object. A more reasonable approach is to split it into multiple layers, each responsible for a different job. Common layers include:
- Environment layer: Handles the sky, background color, fog, and distant silhouettes to establish the overall tone.
- Building layer: The main structures such as the convenience store, surrounding buildings, walls, and canopies.
- Street layer: Roads, sidewalks, curbs, steps, manhole covers, and puddle areas.
- Lighting layer: The store interior light, sign light, street lights, and ambient fill light.
- Weather layer: Raindrops, rain mist, ground puddles, and a sense of particles in the air.
- Interaction layer: Camera controls, automatic tours, click feedback, and mobile touch support.
This layering helps both code organization and later optimization. For example, when mobile frame rates fall short, you can first judge whether the problem comes from the building models, the raindrop count, or the lighting and shadow calculations. When you need to adjust the mood, you can modify only the weather or lighting layer without touching the main building structure.
At the code level, a simple initialization pseudocode can help clarify the overall structure:
createScene();createEnvironment();createBuildings();createStreet();createLights();createRainSystem();setupCameraControls();startRenderLoop();
The function names here are illustrative; when actually implemented, they should be split into modules according to the specific approach. The AI coding assistant can play a big role at this stage: it can quickly generate a base skeleton, complete the initialization flow, and split certain modules into separate configurations as requested. For example, you can ask the assistant to generate a configuration object with parameters such as “raindrop count, fall speed, wind offset, and fog density” for easier tuning later.
4. The Key to Atmosphere: Warm-Cool Contrast and Wet Texture
The element that most often makes a rainy night scene stand out is the contrast between warm and cool light. You can typically use cool colors as the environmental base—deep blue, gray-cyan, dark purple—and warm colors as the visual focus, such as the orange-yellow light inside the convenience store, the warm white glow of the sign, and the soft light under the eaves. This contrast naturally guides the eye, helping users quickly identify the subject in a complex scene.
There are three areas to work on:
1. The Convenience Store Warm Light Is the Visual Center
The convenience store is the emotional core of the whole scene. It stands for warmth, safety, and everyday life. You can let the interior light pass through the glass windows to form soft light pools and light up a certain area of the ground. To avoid the cost of real reflection calculations, you can also use glossy materials, gradient textures, or semi-transparent light spots to simulate reflections on the wet ground.
2. External Street Lights Provide Cool-Toned Layers
Not every street light needs to carry a main lighting role. You can make one or two of them serve as cool-toned key lights, with the rest acting as distant accents. This opens up spatial layers while avoiding the performance drop that comes from too many dynamic light sources. For a rainy night scene, a few high-contrast light sources are often more atmospheric than a large amount of even lighting.
3. Fog and Air Enhance Depth
Fog lets distant buildings, lights, and rain streaks gradually fade into the background, strengthening the sense of depth in the image. The fog density should not be too high, or it will hide the subject; nor too low, or the rainy night feeling weakens. You can make the fog color cool and grayish, contrasting with the warm light of the convenience store. This gives the image both spatial depth and emotional warmth.
5. The Rain System: Not More Is Better, but Layered
Raindrops are the element that best represents the rainy night theme, but they are also the most likely to cause performance problems. If every raindrop is handled as an independent object, the scene will easily become choppy. A more reasonable approach is to treat rain as an integrated system rather than a large number of discrete objects.
A workable rain system usually includes these parameters:
- Raindrop count: slightly higher on desktop, reduced on mobile;
- Fall speed: too fast looks like a rendering error of straight lines, too slow looks like floating particles;
- Wind offset: a slight tilt increases realism, but the angle should not be too large;
- Rain curtain range: either following the camera or arranged around the main scene;
- Near and far layers: raindrops in the foreground are more visible, those in the distance are fainter;
- Ground feedback: raindrops hitting the ground shown through ripples, water glints, or brief highlights.
In terms of implementation, you can apply general optimization ideas such as batch updates, instancing, or shared objects. In other words, do not give every raindrop a complete, independent lifecycle; instead, let the rain system manage the position, speed, and recycling of a large number of particles in a unified structure. Once a raindrop falls below the ground level, it can be reset to the upper area to form a loop.
This can be abstracted as the following pseudocode:
function updateRain(time) {for each rainDrop in rainSystem {rainDrop.position.y -= rainDrop.speed * deltaTime;rainDrop.position.x += rainDrop.wind * deltaTime;if (rainDrop.position.y < groundLevel) {resetRainDrop(rainDrop);spawnSmallRipple(rainDrop.position);}}}function animate(time) {updateRain(time);renderScene();scheduleNextFrame(animate);}
The key to this approach is that rain is not built by piling up quantity but by the overall rhythm, consistent direction, and how well it works with the environment. Too many raindrops make the image muddy; too few fail to build atmosphere. Usually you need to set several tiers—low, medium, and high—according to target device performance, each corresponding to different devices or performance modes.
6. Using the AI Coding Assistant Efficiently: Break Big Tasks into Small Steps
In practice, an AI coding assistant is not simply “generate a complete work from one sentence.” It works better as a collaborative role throughout development. To get more reliable output, break the task into several small steps.
For example:
Step one: Generate the base scene skeleton.
Have the assistant first generate an empty scene, camera, lights, and a simple ground. Do not chase complex details from the start.Step two: Add the main building.
Build the convenience store outline with basic geometric shapes, including the body, sign, glass, canopy, and steps.Step three: Add atmosphere elements.
Add rain, fog, ground reflections, street lights, and the sign light one by one.Step four: Add interaction.
Implement rotation, zoom, and an automatic camera tour, and add mobile adaptation.Step five: Tune performance.
Based on runtime behavior, reduce raindrops, disable unnecessary shadows, and lower material complexity.Step six: Correct details.
Adjust the camera, proportions, brightness, rain speed, color contrast, and boundary limits.
This decomposition significantly reduces how unpredictable the generated code is. Developers can also verify each step before moving on, rather than discovering a proportion error or a performance collapse only at the end.
When communicating with the assistant, it helps to use constraining descriptions, for example:
- “Do not generate complex textures; use solid colors or simple gradient materials.”
- “The raindrop count needs to be configurable and support automatic downgrade on mobile.”
- “Camera rotation needs angle limits to avoid revealing the back of the scene.”
- “The convenience store lighting should stand out, but not be overexposed.”
- “Please split the scene code into three parts: initialization, update, and rendering.”
These instructions help the assistant generate code closer to real engineering practice rather than only a demo snippet.
7. Performance Optimization: A Rainy Scene Needs a Budget from the Start
A 3D work easily keeps piling on visual detail until performance drops. For a scene like a rainy night town, which includes many transparent, glowing, and particle elements, performance optimization must begin at the design stage rather than being patched after the page starts stuttering.
1. Control the Number of Transparent Materials
Rain, fog, glass, water glints, and glows all commonly involve transparency. Transparent materials often cost more resources than opaque ones during rendering, especially when large areas of transparency stack up. You can control the cost by reducing transparent area, lowering the number of transparency layers, or using simplified light spots.
2. Use Dynamic Lights Reasonably
A rainy night scene needs light, but not every light source needs real shadow calculations. Let a small number of key light sources handle the main lighting, and represent the rest with self-illumination, simulated glow, or static textures. This preserves the atmosphere while lowering rendering cost.
3. Batch-Manage Repeated Objects
Elements such as raindrops, street lights, leaves, bricks, and rain ripples are often repetitive. Creating and updating each object individually causes high overhead. You can use instancing or batch processing so the system updates a large number of objects within a unified structure.
4. Limit the Rendering Resolution
On mobile devices, an overly high rendering resolution adds a significant burden. You can cap the device pixel ratio or lower the render resolution in a low-performance mode. This is especially effective for rainy scenes, since raindrops and fog depend relatively little on absolute clarity.
5. Adopt Progressive Loading
If the scene has many resources, load the basic geometry and key atmosphere elements first, then load finer details step by step. For example, show the convenience store outline and the rain curtain first, then add sign details, ground textures, and distant buildings. This lets users reach an interactive state faster.
6. Build an Awareness of Performance Monitoring
During development, keep an eye on a few general metrics: the number of scene objects, the raindrop count, the number of dynamic lights, the number of transparent materials, the per-frame update frequency, and the resource size. Although implementations differ, these indicators help developers judge performance risk.
8. Detail Polishing: From “It Runs” to “It’s Worth Watching”
Whether a 3D work draws people in often depends on whether the details serve the atmosphere. For a rainy night town, the details do not need to be numerous, but they should be chosen deliberately.
You can polish the following areas:
- Sign readability: The store name or sign does not need to be complex, but it should be clearly legible in the dark environment, ideally with a modest glow.
- Rain direction consistency: All raindrops should share a similar direction and speed, avoiding a look of random floating particles.
- Wet ground feel: Do not simply brighten the ground; show wetness through local highlights, light and dark variation, and patches of reflection.
- Camera boundaries: When users rotate or zoom, they should not see empty space beyond the scene or exposed structure.
- Mobile touch experience: Rotation and zoom should feel smooth, avoiding accidental touches that suddenly shift the viewpoint.
- Automatic tour rhythm: If you provide an auto-display mode, the camera movement should be slow and steady, not switching focus frequently.
- Single visual focus: The scene can be rich in elements, but users should never be unsure where to look. A rainy night town in particular should keep the convenience store as a clear center.
Detail polishing is usually not completed in one pass but through continuous “small adjustments.” For example, first make the rain look like rain, then let the rain relate to the lighting, then make sure the ground reflections do not overpower the scene, and finally tune the camera rhythm. This process also works well with an AI coding assistant: the developer describes a specific symptom, the assistant offers modification suggestions or code snippets, and the developer verifies the effect.
9. Testing and Delivery: Making the Work Run Stably Across Environments
When the scene is initially complete, you cannot check it only in the development environment; you also need multi-environment validation. At a minimum, focus on these areas:
- Desktop performance: Check whether the initial camera, rotation and zoom, raindrop density, and lighting contrast feel natural.
- Mobile performance: Check whether touch is smooth and whether raindrops and fog cause noticeable lag.
- Low-performance device performance: On lower-spec devices, try disabling shadows, reducing raindrop count, or switching to a low-quality mode.
- Loading behavior: Check whether there is clear feedback while resources load and whether long blank periods appear.
- Interaction boundaries: Check whether users can rotate to abnormal angles or zoom in to a clipping position.
- Visual stability: Check whether raindrops suddenly appear or disappear, whether lights flicker, and whether transparent areas show obvious sorting problems.
For delivery, if this is a web work, it can be published as a static page. In enterprise-level practice, you can combine general cloud capabilities for deployment and reliability: host static resources in a general storage service, use a content delivery network (CDN) to improve access speed, and combine log services and monitoring alerts to observe how the work runs. For projects that need continuous iteration, you can also use a container platform for versioned releases, log services to record anomalies, and monitoring alerts to track resource loading and access quality.
10. Summary: Bringing Creativity to Life Relies on Structured Decomposition, Not Single-Point Generation
Building a rainy night 3D town with an AI coding assistant is essentially a transformation “from creativity to engineering.” It tests not only the ability to generate code but also how developers turn a vague imagination into executable goals, how they control proportions and the camera, how they organize scene layers, how they express atmosphere within a limited performance budget, and how they polish a work into a deliverable state through multiple rounds of testing.
For developers, three core lessons are worth keeping in mind:
- State the goal clearly before letting the assistant generate. Defining the visual center, interaction, performance boundaries, and output structure is far more effective than a simple “just make it for me.”
- Get a base structure running first, then add detail step by step. Avoid piling on too many effects at the start, which leads to out-of-control performance and maintenance costs.
- Treat atmosphere as systems engineering. Rain, light, fog, reflections, and the camera do not exist in isolation; they build the immersion of a rainy night town together through a unified rhythm.
Once creativity is broken down, the scene is layered, performance is constrained, and details are verified, a rainy night town is no longer just an image in your mind—it becomes a real 3D work that can run, be interacted with, and be continuously iterated.
