Building a Rainy Night Scene with LLM-Driven Three.js: From Prompt to Reality
As Large Language Model (LLM) code generation capabilities advance, turning natural language descriptions into runnable 3D scenes is becoming a reality. Using a representative case study—an LLM-generated Three.js rainy night convenience store—this article outlines the complete workflow from requirement breakdown and multi-round iteration to performance optimization. It also summarizes the methodology and engineering essentials of this new development paradigm, helping developers quickly transform ideas into playable, runnable projects.
1. Why “Rainy Night” is an Excellent Technical Exercise
Among the many topics in 3D graphics development, the rainy night scene is an outstanding comprehensive practice project. It covers almost all major technical points of real-time rendering:
- Lighting System: Night scenes rely heavily on artificial light sources. Neon signs, streetlights, and window illumination require a combination of point lights, spotlights, and emissive materials.
- Atmosphere Rendering: Rain particles, wet ground reflections, and fog effects collectively create the “rainy night feel,” involving particle systems, environmental reflections, and post-processing.
- Performance Pressure: The number of particles, reflection calculations, and shadow maps significantly consume rendering resources. Maintaining a smooth frame rate on ordinary devices is a real challenge.
- Narrative Detail: A convenience store still lit late at night naturally carries emotional expression, testing the model’s ability to understand and transform vague requirements like “atmosphere.”
Therefore, this type of project is well-suited for evaluating the true level of LLM-assisted development. It is not just about generating runnable code, but repeatedly weighing trade-offs between visuals, performance, and details.
2. Overall Development Workflow: From Prompt to Runnable Work
The entire process can be summarized into four stages, forming a clear iterative loop.
2.1 Requirement Breakdown: Translating a Prompt into Engineering Language
The initial requirement is often just a visual description, such as “make a convenience store on a rainy night.” Feeding this directly to the model usually results in a mediocre box with a few lights. A more effective approach is to break down the requirement dimensions first:
- Scene Subjects: Convenience store building (walls, facade, signboard, windows)- Environmental Elements: Streets, streetlights, utility poles, AC units- Weather System: Rain particles, ground puddles, distant fog- Lighting Scheme: Signboard neon lights, warm window lighting, contrast with cool ambient light- Interaction Design: Camera roaming, click to flash signboard, open/close doors
This decomposed list can directly serve as the prompt skeleton, allowing the model to understand the project boundaries at once.
2.2 First-Round Generation: Accept “Runnable but Imperfect”
The first round of generation should prioritize two things: runnable code and complete scene structure. At this stage, do not demand high visual quality. A common issue in practice is proportion distortion, such as the store door being too wide, the signboard too large, or character models being out of scale with the building. This is normal; the LLM’s grasp of 3D spatial proportions needs to be calibrated gradually through feedback.
It is recommended to specify technical constraints clearly in the initial prompt:
Please build the scene using Three.js (imported via ES Module):- Single HTML file, directly openable in a browser- Use InstancedMesh for raindrops, max 5000 particles- Provide OrbitControls interaction- Add comments to key code blocks
Specifying constraints like “single file, no build process” prevents the model from introducing complex engineering scaffolding, reducing trial-and-error costs.
2.3 Multi-Round Communication: Iterating on Proportion, Performance, and Detail
Real AI-assisted development rarely gets it right in one step. It requires repeated communication across three lines:
Proportion Calibration. Use specific numbers instead of vague descriptions. Instead of saying “make the signboard bigger,” say “the signboard width is about 60% of the building’s frontage width, 1.5 meters high, and suspended 3.5 meters off the ground.” The model executes quantitative instructions far better than adjectives.
Performance Tuning. Rain particles are a typical performance hotspot. Optimize using the following strategy:
// Reuse the same geometry with InstancedMesh, avoiding thousands of Meshesconst rainGeo = new THREE.CylinderGeometry(0.005, 0.005, 0.3, 4);const rainMat = new THREE.MeshBasicMaterial({ color: 0x88aacc, transparent: true, opacity: 0.6 });const rain = new THREE.InstancedMesh(rainGeo, rainMat, 4000);// Only update the matrix per frame, instead of rebuilding the geometryfor (let i = 0; i < 4000; i++) {dummy.position.y -= speeds[i];if (dummy.position.y < 0) dummy.position.y = 20;dummy.updateMatrix();rain.setMatrixAt(i, dummy.matrix);}rain.instanceMatrix.needsUpdate = true;
Additionally, for wet ground reflection, do not use real-time reflection (Reflector) as the overhead is too high. Instead, use a standard material with high metalness and low roughness combined with an environment map to achieve a “near wet ground” visual effect at almost zero cost.
Detail Polishing. The flickering of neon signs, the arrangement of shelves inside the window, and the ripples of raindrops hitting the ground—these details determine the “completeness” of the final product. This stage is suitable for communication via screenshot feedback: point out specific issues on the screen and let the model modify local code accordingly, rather than rewriting the entire page.
2.4 Verification and Delivery
The final work should meet the following criteria: open and run directly in mainstream browsers, stable frame rate (recommended target 60fps), and no blocking interaction errors. Deployment can be accomplished using cloud static hosting capabilities (such as object storage combined with static website hosting) to obtain a shareable online preview link.
3. Methodology: Three Principles for AI-Assisted 3D Development
First, Quantification over Adjectives. LLMs have limited execution capability for words like “atmospheric” or “high-end,” but execute instructions like “raindrop falling speed 12 m/s, 4000 particles, fog density 0.03” very precisely. The core value of developers lies in translating perceptual requirements into quantitative parameters.
Second, Local Iteration over Global Rewrite. Each round of communication should target only one problem and define the scope of changes clearly. Rewriting the entire page easily introduces regression issues and loses details that have already been fine-tuned.
Third, Front-loading Performance Constraints. Specify constraints such as particle limits, whether to use real-time shadows, and target frame rates in the initial prompt. Performance issues addressed after the fact often require restructuring the scene to resolve.
4. Conclusion and Outlook
From this practice, it is clear that current LLMs are well-suited for quickly turning ideas in your head into runnable, playable works. However, it is not a “one-click magic” solution: proportions require manual verification, performance requires engineering fallbacks, and details require multi-round polishing. A more accurate positioning is that LLMs handle 80% of the repetitive coding work, while developers focus on aesthetic judgment, parameter calibration, and architectural decisions.
As models deepen their understanding of graphics knowledge and integrate with real-time preview and visual debugging tools, the iteration efficiency of this “conversational 3D development” still has much room for improvement. For developers looking to get started with Three.js, beginning with a rainy night city is undoubtedly a path that balances fun and technical depth.
