Building a Rainy Night 3D Town with an AI Coding Assistant: A Practical Workflow
This article presents a structured workflow for turning a natural-language concept of a rainy night town into a runnable browser-based 3D prototype with an AI coding assistant. It covers requirement breakdown, acceptance criteria, layered architecture, rainy-night lighting and material techniques, scale and composition, performance budgets, a minimal runnable loop, iterative communication with screenshots and metrics, and final acceptance and risk control. Readers can use the workflow to move from an ambiguous idea to a testable, playable, and degradable 3D scene through small, verifiable iterations.
Building a Rainy Night 3D Town with an AI Coding Assistant: A Practical Workflow
From an Idea in Mind to a Runnable Prototype
Describing a rainy night town in natural language sounds like a simple creative instruction. In practice, it involves scene modeling, lighting design, material representation, particle systems, camera movement, performance optimization, interaction, and acceptance testing. The value of an AI coding assistant is not one-shot generation of perfect code. Its value is in quickly turning a vague idea into a runnable prototype, then converging on scale, performance, and detail through multiple rounds of communication.
A more reasonable workflow is therefore to define a minimum runnable scene first, establish quantitative acceptance criteria, and then iterate around visual goals and performance budgets. This approach preserves the efficiency of natural-language-driven code generation while avoiding a common problem: the result looks plausible but does not actually run.
Requirements Breakdown: Define Scene Boundaries and Acceptance Criteria
Before asking an AI coding assistant to generate code, break “rainy night town” into executable requirements. At minimum, clarify the following dimensions:
- Scene scope: Is it a single street, the area in front of a convenience store, or a small block that can be observed from around? The larger the scope, the harder it is to control geometry, textures, light sources, and draw calls.
- Visual anchor: A rainy-night convenience store is usually the visual center. Clarify its position, glowing sign, glass reflections, and the contrast between warm indoor light and cold outdoor rain.
- Camera behavior: Fixed camera, orbit control, first-person walkthrough, or automatic camera movement have different interaction complexity and performance requirements.
- Atmosphere elements: Rain streaks, wet ground, puddles, fog, neon reflections, streetlight halos, and distant building silhouettes should be classified as “must have” or “degradable.”
- Acceptance metrics: Time to first interactive frame, target frame rate, interaction latency, mobile fallback strategy, and whether pause and reset are supported.
The more specific these requirements are, the closer the generated code will be to a runnable prototype. Otherwise, “rainy night,” “town,” and “convenience store” may be interpreted differently by the model, causing repeated rework in scale, lighting, and performance.
Technical Architecture: Separate Rendering, Scene, Interaction, and Performance Layers
It is useful to split the scene into four layers so that each layer can be generated, debugged, and replaced independently:
- Rendering layer: Canvas size, pixel ratio, camera, render loop, post-processing toggles, and quality tiers.
- Scene layer: Organization of the ground, buildings, convenience store, streetlights, rain particles, fog, and other objects.
- Interaction layer: Mouse drag, wheel zoom, touch gestures, pause/resume, and quality switching.
- Performance layer: Object merging, instancing, visibility culling, texture sizes, shadows, and post-processing budgets.
With this separation, the AI coding assistant only needs to focus on one module at a time, reducing the unpredictability of generating an entire town in one pass. For example, first generate a runnable camera and ground, confirm the coordinate scale, then add the convenience store, and finally add rain particles and post-processing. Each round produces a verifiable artifact.
Key Implementation of the Rainy Night Atmosphere
The visual quality of a rainy night town comes mainly from the combination of lighting and materials, not from simply piling up models. Focus on the following:
- Warm-cool contrast: Warm interior light from the convenience store contrasts with cool outdoor ambient light to create a visual focus. Streetlights should use low-intensity, wide-area local light to avoid overexposing the whole scene.
- Wet ground reflection: The ground material needs strong roughness variation and a reflective feel. Environment reflections, local highlights, and deepened shadows can simulate puddles.
- Rain streaks and fog: Rain particles should be limited to an area near the camera and reused in a loop. Fog hides distant boundaries and enhances spatial depth.
- Signs and bloom: Emissive signs can use mild bloom post-processing, but bloom intensity must be restrained; otherwise it can wash out text and details.
- Tone mapping: A rainy night scene has a large dynamic range. Exposure and tone mapping need reasonable settings to avoid clipped highlights and muddy shadows.
These effects are not better simply because they are heavier. Every additional post-processing effect or light source should be evaluated for its impact on frame rate and mobile devices.
Scale and Composition: The Convenience Store as Visual Anchor
Scale issues are often more subtle than code issues. A common problem is that the convenience store is too large, which distorts the street, or the camera field of view is too wide, which weakens the visual center. Establish a basic scale first—for example, use a door height of about 2.4 meters as a reference—and then derive the relative sizes of the sign, streetlights, vehicles, and rain particles. For the camera, validate composition with a fixed view first, then enable orbit controls.
During composition, place the convenience store near the visual center, use street perspective lines to guide the eye, and use rain streaks and fog to provide foreground and background depth. If the scene needs to be interactive, limit camera pitch and movement range to avoid clipping or revealing unfinished boundaries.
Performance Optimization: Set Budgets Before Adding Effects
Performance optimization for browser-based 3D scenes should be planned upfront. Establish the following budgets:
- Draw calls: Reduce repeated small objects, merge static geometry, and use instancing for repeated elements.
- Textures and VRAM: Control texture sizes, load on demand, and use lower-resolution textures for distant objects.
- Shadows and post-processing: Shadow maps and post-processing are often expensive. Provide toggles and quality tiers.
- Particle count: Use local looping and a particle cap for rain, avoiding uniform full-scene distribution that wastes resources.
- Visibility culling: Use level of detail or direct silhouettes for distant buildings and details.
Do not wait until the scene stutters before optimizing. Define the target frame rate and degradation strategy during the prototype stage. For example, low quality can disable bloom and shadows, keeping only basic lighting and rain particles.
Illustrative Code: Minimum Runnable Loop
The following pseudo-code focuses on structure rather than specific APIs:
// Pseudo-code: minimum rainy night scene loopconst scene = createScene();const camera = createPerspectiveCamera({ fov: 55, near: 0.1, far: 400 });const renderer = createRenderer({ antialias: true, powerPreference: "high-performance" });const ground = createPlane({ size: [120, 120], material: "wet-asphalt" });scene.add(ground);const store = createStorefront({position: [0, 0, -12],emissive: true,signColor: "warm"});scene.add(store);const rain = createParticleSystem({count: 8000,bounds: [80, 40, 80],speed: 18,loopAroundCamera: true});scene.add(rain);function tick(dt) {updateRain(rain, dt);updateCamera(camera, dt);renderer.render(scene, camera);requestAnimationFrame(tick);}
The purpose of this structure is to have a runnable loop first, then gradually replace materials, add light sources, adjust the camera, and add interaction. The AI coding assistant can generate different modules around this skeleton, but every change should return to a runnable state.
Iterative Communication: Close the Loop with Screenshots, Metrics, and Parameters
Natural-language code generation is uncertain, so the communication method matters. In each iteration, provide three types of information:
- Visual feedback: Screenshots or screen recordings that point out specific issues such as “the sign is too bright,” “the ground is too dry,” or “the rain streaks are too dense.”
- Quantitative metrics: Target frame rate, current stutter locations, mobile performance, and time to first screen.
- Parameter constraints: Camera field of view, scene size, rain particle cap, post-processing toggles, and similar constraints.
Replace vague requests such as “make it more realistic” with executable instructions such as “reduce bloom intensity, increase ground roughness, and reduce the number of distant light sources.” Small iterative steps are more stable than rewriting the entire town at once.
Acceptance and Risk Control
Final acceptance should cover whether the scene runs, whether interaction can recover, whether quality can be degraded, whether mobile devices can access it, and whether exceptions can be located. In particular, avoid over-reliance on a single high-performance device. Provide strategies for low-performance devices, such as disabling post-processing, reducing particle count, and simplifying shadows. Only when both “looks good” and “runs well” are included in acceptance does the rainy night town truly move from an idea to a playable work.
