Building a 3D Rainy Night Convenience Store with AI Coding Assistants: A Practical Guide

    Discover how to leverage AI coding assistants to bridge the gap between creative ideas and frontend implementation. This article details the complete process of building an interactive WebGL "rainy night convenience store" scene, covering requirement translation, Three.js scene setup, particle systems for rain, lighting, fog effects, performance optimization, and effective AI collaboration strategies.

    In creative development, a gap often exists between an idea and its frontend implementation. Traditionally, building a 3D scene with a realistic rainy night atmosphere requires significant time spent on graphics fundamentals, shader writing, and performance tuning. However, as AI coding assistants evolve, developers can now translate blurry “rainy night” concepts into runnable, interactive WebGL applications through natural language dialogue. This article uses the construction of a “rainy night convenience store” 3D scene to review the complete closed-loop process: from requirement description and code generation to detail polishing and final launch.

    I. From Concept to Requirements: Translating “Mental Images” into “Technical Language”

    The starting point of any AI-assisted development project is a clear, structured requirement description. For a highly atmospheric “rainy night convenience store,” the first step is not to simply ask the AI to “write a Three.js page,” but to decompose it into sub-problems with explicit technical constraints:

    • Scene Composition: The main convenience store building, surrounding streets, streetlights, raindrop particle systems, and ground reflection effects.
    • Environmental Atmosphere: A dark blue night tone, warm yellow convenience store lighting, and wet road texture after rain.
    • Interactive Experience: Users can rotate the perspective by dragging the mouse, scroll to zoom, and observe the dynamic effects of raindrops falling on different materials.

    When feeding these elements to an AI coding assistant, avoid vague instructions. Instead, use a format of “structured feature description + explicit tech stack constraints.” For example: “Use Three.js to create a low-poly style convenience store 3D scene, including water puddle reflection effects on the road, implement raindrops using a particle system, and add environmental fog to enhance depth.” This description allows the AI to accurately understand the goal and output a more targeted initial code framework.

    II. Scene Setup and Key Technical Selection

    After obtaining the AI-generated initial code, the primary task is to understand its structure and evaluate whether the technical choices are reasonable. A typical code skeleton for a rainy night scene should include the following modules:

    1. Scene and Renderer: Use WebGLRenderer and enable ShadowMap to enhance the three-dimensionality of objects under lighting.
    2. Camera: It is recommended to use PerspectiveCamera, set at a suitable overlooking angle to observe the main building.
    3. Geometry: The main convenience store building can be assembled using basic geometries like BoxGeometry and CylinderGeometry. The signboard can use PlaneGeometry and load text textures generated via Canvas.
    4. Material: Combine MeshStandardMaterial (for building walls) with MeshPhysicalMaterial (for glass windows). The latter better simulates transparency and refraction effects. For wet road surfaces, simulate puddle reflections by adjusting the roughness value and using an Environment Map.

    In these steps, the AI coding assistant significantly reduces the time spent writing boilerplate code. Developers only need to verify whether the generated code logic is correct and parameters are reasonable, rather than typing every line from scratch.

    III. The Core of a Rainy Night Atmosphere: Particle Systems, Lighting, and Fog

    A compelling “rainy night” scene relies more on atmosphere than model complexity. AI-generated base scenes often achieve a superficial resemblance, but true realism requires deep tuning around the following three techniques:

    1. Particle System for Raindrops
    Implementing raindrops shouldn’t just be straight falling lines; it should simulate the tilt caused by wind. In Three.js, you can implement large batches of raindrops using Points and PointsMaterial. A more advanced approach is to introduce BufferGeometry to dynamically update each particle’s position: each raindrop has an independent 3D coordinate, falling speed, and acceleration. Building on the AI’s code, add a vector overlay logic consistent with the wind direction, making the rain curtain present an overall tilted dynamic vision, enhancing realism. Additionally, the particle material can be set to semi-transparent with a slight blue tint influenced by the surrounding scene’s color.

    2. Multi-light Layout and Volumetric Light Attempts
    The light layout in a night scene directly determines the emotional tone of the image. A typical configuration includes: a warm yellow SpotLight as the main light for the convenience store entrance, supplemented by a white PointLight simulating interior light. Streetlights on both sides of the road use cool-toned DirectionalLight or PointLight to create a warm-cool contrast. Furthermore, you can try using SpotLightHelper with a spotlight in the fog to debug the light cone range, or implement a simple volumetric light effect via a custom Shader, creating a hazy light pillar when light pierces through the rain curtain.

    3. Fog Effects and Background Environment
    (THREE.Fog) Fog is a powerful tool for enhancing depth perception. In a rainy night scene, setting Fog (linear fog) or FogExp2 (exponential fog) allows distant building outlines to gradually disappear into the rain curtain, enhancing the deep atmosphere of a small city. Meanwhile, set the background color to a deep blue close to late night (e.g., 0x0a0a2a) and use the Renderer’s setClearColor to maintain a unified overall scene tone.

    IV. Detail Polishing: From “Runnable” to “Playable”

    A successful AI-assisted development process doesn’t stop at code generation. Based on the AI’s initial output, developers need multiple rounds of a “review-feedback-modify” iteration loop. In this practice, three main issues were resolved through conversational feedback:

    Issue 1: Convenience Store Proportion Imbalance. The initial entrance width was too large, making the building look like a flat box. Solution: Provide clear numerical targets in the feedback: “Maintain the building’s aspect ratio close to the golden ratio, with the entrance width taking up 40% of the building facade.” The AI then adjusted the size parameters of the Geometry accordingly.

    Issue 2: Performance Drop Due to Excessive Rain. When the particle count reached 20,000, the frame rate dropped noticeably. Solution: Introduce performance monitoring tools to analyze the issue. Through the online preview, the bottleneck was identified in the per-frame property updates of the particle system. Ultimately, reducing the particle count to 8,000 and optimizing the gravity acceleration and wind speed constants significantly improved smoothness. During this process, the AI coding assistant provided multiple optimization solutions, requiring the developer to have basic performance analysis skills to select the optimal one.

    Issue 3: Lack of a “Convenience Store” Visual Identity. A building outline alone cannot convey the concept of a “convenience store.” The developer had the AI generate Canvas texture code to dynamically draw the text “Convenience Store” and applied it to the signboard created by PlaneGeometry. A neon tube halo effect was also added (implemented using emissive materials or Sprites).

    V. Managing the Big Picture: Roles and Communication Strategies

    The collaboration model between the developer and the AI coding assistant throughout the creation process is worth summarizing. The AI is not an omniscient replacement, but a fast-reacting junior partner. The developer’s core responsibilities include:

    • Architecture Decisions: Determining which tech stack to use (e.g., native WebGL vs. Three.js) and how to organize the overall scene structure.
    • Aesthetic Gatekeeping: Evaluating whether the generated colors, lighting, and materials meet visual expectations, and providing specific modification suggestions like “change the raindrop color to a semi-transparent cool gray.”
    • Performance Review: Analyzing the time complexity of AI-generated code to identify potential main thread blocking operations.

    An effective communication strategy lies in “granularity control.” For big-picture issues, use general language to describe them; for detail modifications, provide quantified metrics as much as possible. For example, “increase the raindrop falling speed to 2 units per second” is an effective instruction, whereas “make the rain heavier” makes it difficult for the AI to grasp the scale.

    VI. Experience Summary and Insights

    The process of building a rainy night convenience store using an AI coding assistant fully demonstrates the massive potential of generative AI in the rapid prototyping of creative ideas. It significantly lowers the technical barrier to building 3D scenes, allowing developers to focus more on artistic expression and creative validation. Although multiple iterations and performance tuning are still required, the efficiency improvement is remarkable compared to the traditional method of writing underlying code from scratch.

    For developers, mastering the ability to collaborate efficiently with AI has become an important new literacy in digital creation. This requires developers not only to have solid programming fundamentals to review and modify AI code, but also clear aesthetic logic and scene construction thinking. When technical implementation is no longer the bottleneck, what determines the ceiling of a work is the creator’s own imagination, systems thinking, and aesthetic vision. The next time a blurry image pops into your head, try opening an AI coding assistant and describing it clearly—you might soon get a surprising, interactive 3D world.