Rapidly Build an Interactive Rainy Night Town Scene with AI Coding

    This article explores how to use AI coding tools to transform the creative concept of a "rainy night town" into an interactive 3D scene. It details a structured development workflow, covering scene decomposition, procedural rain generation, wet ground reflections, camera interaction design, effective prompt engineering for AI models, and performance optimization strategies for web deployment.

    I. From Creative Description to Runnable Prototype

    A “rainy night town” may seem like a simple visual theme, but actual implementation involves numerous technical details that must be clarified: how wide the streets should be, how buildings are distributed, how raindrops move, how lights map onto wet surfaces, whether users can move the camera, and whether the scene runs smoothly on standard devices.

    When starting from scratch, developers typically need to handle scene organization, geometry creation, material setup, lighting calculations, animation loops, camera control, and resource management simultaneously. The value of AI coding tools is not simply to replace developers in writing code, but to help them quickly establish the first runnable version, gradually transforming vague visual ideas into concrete technical solutions through continuous communication and localized modifications.

    An effective development workflow can be divided into four stages:

    1. Define the scene goals and visual focus.
    2. Build a minimal runnable 3D scene.
    3. Add rainy night atmosphere and interactive effects.
    4. Optimize proportions, performance, and details based on actual runtime conditions.

    This phased approach is more reliable than requesting a complete work all at once and makes it easier to pinpoint issues.

    II. Decompose the Scene Before Implementation

    Before writing code, the scene should be broken down into several independent modules.

    1. Environment Module

    The environment module includes the sky, ground, streets, buildings, streetlights, and distant silhouettes. To quickly verify the overall effect, there is no need to create complex models early on; basic geometries like cubes, planes, and cylinders can form the buildings and streets.

    For example:

    • Use a large plane for the ground;
    • Use dark cuboids or planes for streets;
    • Use cubes of varying heights and widths for buildings;
    • Use simple thin structures for roofs, awnings, and signposts;
    • Keep only silhouettes and color blocks for distant buildings.

    The benefit of this approach is clear structure, low computational cost, and easy subsequent proportion adjustments. Many scenes “don’t look like a town” not because they lack detail, but because the relationship between road width, building height, and camera angle is poorly calibrated.

    2. Convenience Store Module

    The convenience store is the visual center of the scene, so its silhouette and lighting recognizability should be prioritized. It can be decomposed into:

    • Main walls;
    • Transparent or semi-transparent windows;
    • Door frame and entrance;
    • Glowing signboard;
    • Front awning;
    • Indoor shelves and light strips;
    • Outdoor puddle area.

    The store doesn’t need a large number of products initially. A bright indoor color temperature, regularly arranged shelves, and a prominent signboard are enough for users to quickly recognize the scene’s theme.

    3. Atmosphere Module

    The realism of a rainy night comes primarily from the layering of multiple subtle effects, rather than a single complex visual effect. Common components include:

    • Continuous falling raindrops;
    • Ground reflections;
    • Air fog;
    • Local lighting;
    • Water streaks on glass;
    • Low-contrast silhouettes of distant buildings;
    • Occasionally changing lights or vehicle brightness.

    During implementation, ensure the overall tone and spatial layers first, then gradually add details. Otherwise, it is easy to end up with many elements but no clear visual focus.

    III. Procedural Rain Generation

    Raindrops usually do not need to be created as individual independent objects. A more efficient approach is to pre-generate a set of vertices, render them as a point or line collection, and update their positions in the animation loop.

    Each raindrop can contain at least the following attributes:

    1. x: horizontal position
    2. y: vertical position
    3. z: depth position
    4. speed: fall speed
    5. length: raindrop length
    6. opacity: transparency

    In each frame, update the vertical coordinate based on speed:

    1. y = y - speed * deltaTime

    When a raindrop falls below the ground, recycle it to the top:

    1. if y < groundHeight:
    2. y = cloudHeight

    This recycling method avoids continuous object creation and destruction, reducing stuttering caused by memory allocation and garbage collection.

    To prevent the rain curtain from looking mechanical, set slight variations in speed and length for different raindrops, and add limited horizontal offsets. Note that more raindrops are not always better. Excessive raindrops will obscure the main buildings and increase rendering pressure. A more reasonable strategy is to use different densities for the foreground, midground, and background to create depth.

    IV. Wet Ground and Light Reflections

    The key to a rainy night scene is not just “having rain,” but making the audience feel that the rain has altered the environmental materials.

    1. Ground Materials

    Wet ground can use a darker base color while lowering the roughness and appropriately increasing the reflection intensity. Using a completely mirror-like material will make the image unrealistic; if the ground is too rough, lights cannot form clear reflections.

    The ground can be divided into multiple zones:

    • Main road area;
    • Sidewalk area;
    • Puddle area in front of the store;
    • Building shadow area.

    Using slightly different colors and reflection levels for different zones enhances spatial layering.

    2. Pseudo-Reflection Approach

    If device performance is limited, you don’t need to use costly real-time reflections from the start. You can simulate light reflections using semi-transparent stretched planes, blurred color blocks, or gradient textures.

    For example, a narrow, semi-transparent plane can be placed below a storefront light, with its color transitioning from bright to dark. Combined with the ground’s low roughness, this creates a visual hint of a reflection.

    3. Lighting Layers

    It is recommended to divide lights into three categories:

    • Ambient light: responsible for overall environmental brightness;
    • Local lights: from signboards, entrances, and indoors;
    • Decorative lights: for streetlights, windows, and distant buildings.

    The ambient light should not be too bright, or the rainy night atmosphere will disappear. The interior of the convenience store can use a warm light color to contrast with the colder outdoor environment. This warm-cold contrast naturally guides users’ attention to the store entrance.

    V. Camera and Interaction Design

    A playable scene should not just display visuals, but also allow basic user exploration. For a small rainy night block, a low camera height is recommended to bring the perspective close to pedestrian eye level.

    Interactions can start with the following features:

    • Mouse drag to rotate the view;
    • Keyboard to control forward, backward, left, and right movement;
    • Scroll wheel to adjust viewing distance;
    • Click the store entrance to trigger a prompt;
    • Click the signboard to toggle the light state;
    • Display environmental descriptions when entering designated areas.

    Movement logic needs boundary limits to prevent users from walking through buildings or leaving the scene. Simple bounding boxes can solve most problems. If there are multiple obstacles in the scene, the walkable area can be abstracted into a 2D grid for collision detection before moving.

    Interaction feedback is also crucial. For example, as the user approaches the convenience store, the indoor light brightness can gradually increase, or an “Enter Indoors” prompt can appear. Such details don’t require complex algorithms but significantly enhance immersion.

    VI. How to Communicate Effectively with AI Coding Tools

    High-quality results usually stem from high-quality descriptions. Instead of asking “help me make a beautiful rainy night city,” it is better to break the requirements into verifiable tasks.

    A good description should include:

    1. Runtime environment: browser-side, single-page, or multi-file structure;
    2. Visual goals: cold-toned rainy night, warm-toned interior, wet ground;
    3. Scene composition: roads, buildings, convenience store, streetlights, rain curtain;
    4. Interaction requirements: view rotation, character movement, area triggers;
    5. Technical constraints: prefer basic geometries, avoid high-complexity assets;
    6. Output requirements: provide full code, run instructions, and modification points.

    After the first generation, it is not advisable to immediately request a large number of new features. A more effective iteration order is:

    • First, confirm the page can run;
    • Then adjust building and road proportions;
    • Next, handle camera and movement logic;
    • Then add raindrops and lighting;
    • Finally, supplement materials, sound, and decorative details.

    If issues arise, provide observable phenomena, such as “raindrops don’t loop,” “movement clips through walls,” or “the scene stutters noticeably on low-end devices,” rather than vaguely saying “the effect is wrong.” The more specific the problem description, the easier it is to converge on a solution during subsequent modifications.

    VII. Performance Optimization Focus

    Even a small-scale 3D scene can suffer performance drops due to object counts, transparency effects, and real-time lighting.

    1. Reduce Object Count

    A large number of independent meshes increases update and draw overhead. Repeated buildings, windows, and raindrops should utilize batch generation or shared geometry data.

    2. Control Transparent Materials

    Raindrops, fog, glass, and reflections typically require transparency. Too many transparent objects increase sorting and blending costs. Therefore, limit the number of transparent layers and avoid large overlapping fully transparent planes.

    3. Lower Distant Details

    Distant buildings only need to retain their silhouettes and do not need the same level of detail as nearby models. You can switch object complexity based on distance, or simply use color blocks and simple planes.

    4. Limit Real-time Lights

    The number of real-time lights should be kept within a reasonable range. Most streetlights can use preset colors and simple glowing materials, without requiring every single light to produce high-cost shadows.

    5. Provide Degradation Strategies

    You can set low, medium, and high effect tiers:

    • Low quality: reduce raindrop count, disable dynamic shadows;
    • Medium quality: retain main lights and limited reflections;
    • High quality: add fog, reflections, and local dynamic effects.

    This allows the work to cover more devices, rather than only running smoothly on the developer’s own computer.

    VIII. From Prototype to Complete Work

    Once the basic scene is stable, you can continue to add more narrative content, such as:

    • Awning at the convenience store entrance;
    • Parked vehicles by the road;
    • Slowly moving lights in the distance;
    • Silhouettes of merchandise in the window;
    • Local reflections in ground puddles;
    • Ambient audio and rain sounds;
    • Lighting changes in different areas;
    • Short exploration tasks.

    However, when expanding features, you should still follow the principle of “core experience first, decorative effects second.” The core experience of a rainy night town is spatial atmosphere, visual focus, and explorability, not the sheer number of models.

    Conclusion

    Transforming an idea about a rainy night town into a 3D scene that runs and interacts in a browser relies less on generating all the code at once, and more on establishing a clear workflow of decomposition, validation, and iteration.

    AI coding tools can significantly lower the barrier to prototyping, allowing developers to see results faster. However, whether the proportions are reasonable, the performance is stable, and the interactions are natural still needs to be judged through actual runtime and continuous adjustment. By breaking down the creative idea into modules, building the skeleton with basic technology, and then gradually refining it with rain curtains, lighting, materials, and sound, an abstract concept can truly be transformed into an immersive and playable digital scene.