Building a 3D Rainy Night City Scene with AI Coding Tools

    This article explores how to leverage AI coding tools to transform creative concepts into an interactive 3D rainy night city scene. It covers requirement decomposition, scene construction, lighting and atmosphere design, particle system implementation, human-machine collaboration strategies, and performance optimization practices. Readers will gain insights into effectively utilizing AI tools to accelerate 3D graphics development.

    Introduction: The Gap Between Creativity and Runnable Works is Shrinking

    Many developers have experienced that moment when a vivid image flashes in their mind—a rainy night, neon lights, and the warm glow of a convenience store spilling onto wet asphalt. However, bridging the gap between imagination and a runnable, interactive 3D scene in a browser often involves a steep learning curve and extensive debugging time. Traditionally, building a 3D scene with proper lighting, materials, particle systems, and post-processing effects requires solid knowledge of graphics concepts, rendering pipelines, and performance optimization, a process that could take weeks.

    As LLM-driven AI coding tools mature, this path is being significantly shortened. Using a “rainy night convenience store city” scene as an example, this article introduces how to use AI coding tools to complete the full practice from creative description to an interactive 3D work, and summarizes the methodology of human-machine collaboration. Note that this article does not bind to any specific product but discusses the general capability boundaries and best practices of this class of AI coding tools in creative development.

    1. Requirement Decomposition: Translating “Vibe” into a Technical Checklist

    The biggest challenge in creative projects is often not coding itself, but translating a vague “vibe” into executable technical requirements. Before starting with the rainy night convenience store scene, you should first decompose it as follows:

    1. Static Scene Layer: Main building of the convenience store (combination of geometries), door and window glass, illuminated signboards, surrounding streets, streetlights, and distant building silhouettes.
    2. Lighting Atmosphere Layer: Warm point lights inside the store, self-illuminating signboard materials, cool streetlights, ambient dim light, and ground reflections.
    3. Dynamic Effect Layer: Raindrop particle system, ground ripples, neon flickering, and slow camera movement or interactive roaming.
    4. Performance and Experience Layer: Stable frame rate, controllable asset size, and reasonable first-screen loading time.

    Using this checklist as the “initial requirements document” to communicate with AI coding tools is far more effective than a simple “help me build a rainy night city.” AI coding tools excel at handling structured, clearly bounded tasks; the more specific the requirement decomposition, the higher the usability of the first draft.

    2. Scene Construction: Geometry, Materials, and Hierarchy

    The foundation of a 3D scene is the combination of geometry and materials. For the main structure of a convenience store, you can use parameterized boxes and planes instead of importing complex external model files, which significantly reduces loading costs.

    1. // Example code: Convenience store main body and signboard
    2. const storeGeometry = new THREE.BoxGeometry(10, 5, 8);
    3. const storeMaterial = new THREE.MeshStandardMaterial({
    4. color: 0x2a2a35,
    5. roughness: 0.8,
    6. metalness: 0.2,
    7. });
    8. const store = new THREE.Mesh(storeGeometry, storeMaterial);
    9. // Self-illuminating signboard: a key element of the rainy night atmosphere
    10. const signMaterial = new THREE.MeshStandardMaterial({
    11. color: 0xffffff,
    12. emissive: 0xffe0a3,
    13. emissiveIntensity: 2.0,
    14. });

    For hierarchy organization, it is recommended to divide the scene into several logical groups: building group, lighting group, effects group, and decoration group. This structure makes it easier to adjust parameters of a specific layer later and allows the AI coding tool to modify only the designated module during iteration, reducing the risk of breaking the whole scene by changing one part.

    3. Lighting and Atmosphere: The Texture of a Rainy Night Comes from Light Contrast

    The soul of a rainy night scene lies in its lighting. Key takeaways include:

    • Cool and Warm Contrast: Use warm point lights inside the store (e.g., orange-yellow color temperature) and cool ambient light on the street. The contrast between the two is the core source of the “cozy rainy night” atmosphere.
    • Wet Ground: Increase the metalness and decrease the roughness of the ground material so it can reflect the signboard and streetlights, simulating the mirror effect of puddles after rain. Combined with post-processing effects like Screen Space Reflections (SSR), the texture will be further enhanced, though performance overhead should be noted.
    • Fog: Adding moderate atmospheric fog allows distant buildings to naturally fade out, creating a deep perspective of low visibility on a rainy night while cleverly hiding the lack of detail in low-poly backgrounds.

    When prompting the AI coding tool, you can directly describe these visual goals, such as “the ground needs to show wet, reflective effects after rain.” The tool can usually provide a reasonable implementation at the material parameter level, leaving the developer to fine-tune the values.

    4. Rain Effect Implementation: Particle Systems and Cost Control

    The classic approach for rain effects is a particle system: randomly distributing a large number of short line segments or point sprites in the space in front of the camera, moving them downward each frame, and resetting them to the top when they fall below ground level to form a looping rain curtain.

    1. // Example code: Core logic of the raindrop particle system
    2. const rainCount = 3000;
    3. const positions = new Float32Array(rainCount * 3);
    4. const velocities = new Float32Array(rainCount);
    5. function updateRain(delta) {
    6. for (let i = 0; i < rainCount; i++) {
    7. positions[i * 3 + 1] -= velocities[i] * delta;
    8. if (positions[i * 3 + 1] < 0) {
    9. positions[i * 3 + 1] = 30; // Reset to top for looping
    10. }
    11. }
    12. rainGeometry.attributes.position.needsUpdate = true;
    13. }

    Key performance considerations:

    1. Balance Between Particle Count and Visual Appeal: 3,000 to 8,000 particles are usually sufficient to cover a medium field of view. Blindly increasing the number provides limited improvement to the atmosphere but significantly drags down the frame rate.
    2. Single Draw Call: Merge all raindrops into one geometry and complete the rendering in a single draw call, avoiding an explosion of calls caused by creating an object for each raindrop.
    3. Frustum Culling: The rain area only needs to cover the visible range of the camera. When the camera moves, the rain area should follow rather than covering the entire scene.

    5. Iterative Collaboration: Strategies for Efficient Communication with AI Coding Tools

    The most realistic experience in practice is that the first draft is rarely perfect. Issues like disproportionate scaling, overexposed lighting, or low frame rates require multiple rounds of communication to fix. Here are proven collaboration tips:

    • Change One Thing at a Time: Breaking down “the signboard is too bright,” “the rain is too dense,” and “the camera clips through walls” into independent iteration requests is more effective than throwing out all problems at once.
    • Use Numeric Descriptions Instead of Adjectives: “Reduce the emissive intensity of the signboard to half of its current value” is more likely to get an accurate modification than “the signboard is too glaring.”
    • Require Explainability: Ask the tool to explain the principle behind each modification. This not only helps developers learn but also enables them to spot deviations in the implementation approach promptly.
    • Keep Version Snapshots: Save each usable version separately to avoid being unable to roll back if an iteration degrades the scene.

    The true value of these tools lies not in generating a perfect work in one shot, but in reducing the unit cost of trial and error to an absolute minimum. Adjustments that used to require half a day of documentation reading can now be done in a single conversation, allowing developers to focus their energy on aesthetic decisions and overall architecture.

    6. Performance Optimization and Pre-Release Checklist

    After completing the scene, it is recommended to check the following items before release:

    • Frame Rate: Maintain a stable 60fps (or at least 30fps) on mainstream mid-range devices. If necessary, reduce shadow resolution, post-processing sampling rate, or particle count.
    • Asset Size: Use texture compression, geometry reuse, and lazy loading to control the initial download size.
    • Compatibility: Verify rendering consistency across mainstream browsers and handle mobile touch interactions.
    • Memory Leaks: Ensure that animation loops and event listeners are correctly released when the page is destroyed.

    When sharing your work externally, you can leverage general static asset hosting or object storage cloud services for deployment, combined with content delivery networks (CDNs) for a stable access experience. The entire process requires no complex DevOps overhead.

    Conclusion

    Creative scenes like the rainy night convenience store are excellent samples for testing the capabilities of AI coding tools. They span multiple technical fields such as geometric modeling, lighting rendering, particle systems, and performance optimization, while carrying strong aesthetic subjectivity. Practice shows that current AI coding tools are well-suited for the role of “rapid prototyping + detail implementation,” quickly turning ideas in a developer’s mind into runnable, playable works. Meanwhile, proportion control, performance tuning, and final artistic decisions still rely on the developer’s experience and taste. Mastering clear requirement decomposition skills and efficient iterative communication methods is key to maximizing the value of these tools.