AI-Assisted 3D Rainy Night Scene Development: From Concept to a Runnable WebGL Project
This article presents a practical workflow for using AI coding assistants to build a 3D rainy-night convenience-store scene with WebGL. It covers scene modularization, materials and lighting, rain and splash effects, user interaction, performance tuning, multi-turn prompting, and the capability boundaries of AI-assisted development.
In traditional front-end development, turning a visual idea into a runnable 3D scene often involves a long chain of tasks: environment setup, model design, material tuning, animation implementation, and performance optimization. As intelligent coding tools mature, developers are gaining a new “conversational construction” workflow. They can describe requirements in natural language, and the assistant can generate runnable base code—making it possible to move from “I can imagine it” to “I can build it.”
1. From Idea to Engineering: What AI-Assisted Programming Changes
In the past, implementing a WebGL-based 3D scene required developers to complete several steps: choose a rendering library, set up the basic scene structure, create geometry and materials, add a lighting system, design interaction logic, and repeatedly adjust camera parameters and animation timing. For less experienced developers, simply understanding the relationships among the Scene Graph, the Render Loop, and the camera projection matrix could take considerable time.
With an intelligent coding assistant, this process is greatly compressed. A developer only needs to describe “I want to build a rainy-night convenience-store scene,” and the tool can generate starting code that includes scene initialization, renderer configuration, and basic geometry generation. This capability comes from large language models’ deep understanding of large amounts of open-source code and 3D graphics knowledge. The model is familiar with common rendering-library APIs, understands the basic principles of lighting models, and knows how to organize the code structure of a front-end 3D project.
It is important to be clear, however, that AI-assisted programming is not an “instant” magic solution. In practice, developers still need sufficient foundational knowledge and debugging ability. The model generates the “skeleton,” while the “flesh” of the scene must be filled in through multiple rounds of dialogue between the developer and the AI.
2. Scene Construction: Using Functional Modules as Dialogue Units
In practice, an efficient dialogue strategy is to break a complex scene into multiple functional modules and discuss implementation approaches with the AI one by one. Building a rainy-night convenience-store scene can be roughly divided into the following subtasks: street and building layout, convenience-store interior and exterior structure, lighting system (including streetlights, storefront neon signs, and indoor lighting), weather system (raindrops, splashes, and fog), and interaction logic (such as rotating the view and clicking to switch viewpoints).
2.1 Base Scene and Background
The first step is to create a 3D space with a ground plane and set appropriate fog to simulate the hazy feel of a rainy night. In dialogue with the AI, the developer can describe it like this: “Create a basic 3D scene with a wide ground plane, a dark sky background, and a layer of light fog to simulate the air texture of a rainy day.” The intelligent tool will generate the corresponding initialization code, usually including the scene object, perspective camera, WebGL renderer, and fog parameter settings.
2.2 Buildings and Geometry Construction
The main structure of the convenience store can be built by combining boxes: the main store body, the store sign, the glass window, and the entrance steps. With AI tools, developers can quickly complete the building outline using combinations of simple geometry. In contrast, the past required writing large numbers of vertex coordinates and face indices by hand. Now, developers only need to describe “create a small convenience-store building about 3 meters high, with window and door openings reserved on the facade,” and the code can be generated as needed.
2.3 Materials and Visual Style
The soul of a rainy-night scene lies in how materials respond to light. Glass materials need a certain degree of transparency and reflection; wet street surfaces should reflect the warm yellow halos of streetlights; and metal door handles on the store entrance should produce highlights. These details can be explicitly stated to the AI in dialogue, for example: “Add a semi-transparent reflective material to the glass in the scene, with reduced reflection intensity to suit nighttime ambient light.”
3. Dynamic Effects and Interaction: From Static to Experiential
After the base scene is built, the most important step is adding dynamic elements and interaction controls. This is also often the stage with the heaviest debugging workload.
3.1 Two-Layer Rain Implementation
Rain is central to creating a rainy-night atmosphere. In practice, raindrops are usually divided into two layers: large near-field raindrops and fine far-field rain streaks. The near-field part can be implemented with a particle system (Points), updating particle positions every frame and moving them downward. The far-field part can use multiple semi-transparent planes with noise texture maps. Because the number of particles is large, performance optimization requires special attention at this stage—for example, using cached arrays to manage particle lifecycles or reducing draw calls through texture merging.
3.2 Splash Effects and Ground Reflection
The splashes created when raindrops hit the ground are subtle but can greatly enhance the realism of the scene. Collision detection can be set up in the particle system: when a raindrop particle reaches ground height, it triggers a simple ring-shaped ripple animation. For ground reflection, a real-time reflection plane can be used, or a cheaper and more efficient approach can be introduced—pre-making a blurred reflection texture and combining it with dynamic UV offset to simulate the flow of light and shadow on a wet road.
3.3 User Interaction View
To enhance the “playable” experience, the scene should support basic mouse interaction: drag to rotate the view, scroll to zoom, and click specific objects to trigger dynamic responses. For example, when the user clicks the convenience-store door, a door-pushing animation can play and the indoor light can flicker. This type of interaction logic can use Raycasting to temporarily store the handle of the clicked object and then call the corresponding animation controller.
4. Performance Bottlenecks and Tuning Strategies
Performance optimization for 3D scenes is unavoidable. The main bottlenecks encountered in this practice and their corresponding solutions are as follows:
- Too many draw calls: In the early version, a single object was split into multiple meshes, resulting in too many render batches. Merging static geometry and grouping objects with shared materials into the same draw call can effectively reduce CPU overhead.
- High particle-system computation: Tens of thousands of raindrop particles update their positions every frame, putting significant pressure on the CPU. The optimization approach is to move particle position update logic into the vertex shader and use the GPU’s parallel computing capability, reducing CPU usage by an order of magnitude.
- Texture and VRAM usage: High-resolution textures cause noticeable stuttering on mobile devices. It is recommended to use compressed formats for all textures or appropriately reduce resolution, while enabling mipmap generation.
AI-assisted tools offer a unique advantage at this stage: developers can describe performance metrics to the AI (for example, “the current frame rate is low and may be related to an excessively high shadow map resolution”), and the tool will use the code context to provide targeted optimization suggestions, or even directly generate improved code sections.
5. Multi-Turn Dialogue Is Key to Completing the Product
It is important not to overlook that the first generated version often struggles to reach the desired state directly. In the transformation from “idea” to “finished product,” scale perception, physical plausibility, and performance all require repeated adjustment.
A common problem is inconsistent scale in AI-generated 3D scenes. For example, buildings may be as tall as skyscrapers while characters are only ant-sized. In this case, the developer needs to clearly describe size references to the AI: “Keep the building height in the scene at around 3 meters, and make the entrance about 0.9 meters wide.” The AI will then recalculate the parameters of the corresponding geometry based on the proportional relationships.
Another common scenario is unrealistic lighting. Rainy-night light should have high environmental contrast—areas lit by point lights are clearly visible, shadows are deep, and road reflections have blurred halos. The first generated lighting may be too bright and uniform, losing the nighttime atmosphere. Through multiple rounds of feedback such as “reduce overall brightness by another 30%, add a flickering effect to the streetlights, and add an emissive material to the storefront neon sign,” the final effect will gradually approach the expectation.
In addition, different AI tools have different context memory lengths. In longer conversations, parameters set earlier may be forgotten. An effective strategy in practice is to briefly summarize the current scene state at the end of each dialogue turn (for example, “The current scene contains one convenience-store building, uses RGB three-color dynamic neon lights, has 8,000 raindrops, and uses a BMP format reflection texture for the road”) to help the AI maintain a grasp of the overall situation.
6. Capability Boundaries and Future Outlook
Through this “rainy-night convenience store” project practice, it is clear that the main advantages of intelligent coding tools for 3D scene development are greatly reducing setup time, lowering the entry barrier, and providing creative inspiration. At the same time, however, their capability boundaries are also clear: they have limited ability to organize extremely complex scenes, lack true physical intuition, and cannot replace developers’ judgment on motion aesthetics and performance trade-offs.
Therefore, it is advisable to treat AI assistance as a “super partner” rather than a “fully automatic engine.” Developers are responsible for creative direction, logical architecture, and aesthetic control, while AI is responsible for rapid implementation, code optimization, and best-practice reminders. This human-AI collaboration model is redefining productivity in front-end development, especially in 3D visualization.
In the future, as AI tools deepen their understanding of 3D graphics and as dialogue context windows continue to expand, we can expect to see more complex 3D works that “ordinary people can also complete.” For now, the most important thing is still to be willing to try—take a clear scene concept, hand the “rainy night in your mind” to the AI to present, and then enjoy the creative process through adjustment and refinement.
