AI-Assisted Programming: Engineering a 3D Rainy Night Cityscape
Turning a "rainy night city" concept into a runnable, interactive 3D scene in the browser challenges developers to balance scale, performance, detail, and collaboration workflows. While AI-assisted programming can significantly reduce prototyping time, it is not a "generate once and deliver" magic. This article explores an engineering approach to building a 3D rainy night city scene using large language models (LLMs), offering a reusable framework for requirement breakdown, implementation paths, and optimization strategies.
From Concept to Runnable Work: Engineering a 3D Rainy Night Cityscape
Transforming a “rainy night city” idea into a runnable, interactive 3D scene in the browser usually presents challenges not in a single visual effect, but in balancing scale, performance, detail, and collaboration workflows. AI-assisted programming can significantly shorten the time from idea to prototype, but it is not a “generate once and deliver” magic. A more reliable approach is to break the creative vision into verifiable specifications, then gradually converge through multi-round communication, manual corrections, and performance profiling.
This article uses a “rainy night convenience store city” as a general case study to discuss how to build a browser-side 3D scene using AI-assisted programming capabilities. It provides a reusable framework for requirement breakdown, implementation paths, and optimization methods.
1. Define Acceptance Criteria Before Writing Code
Many 3D scene projects require rework because the initial description only specified “it should look good,” “it should rain,” or “it needs a convenience store,” without defining what “done” means. Before generating code, it is recommended to establish four categories of acceptance criteria:
- Scale Standards: Building heights, road widths, character or vehicle dimensions, and camera height should share a unified unit. For example, using “meters” as the scene unit, a convenience store door is about 2.2 meters high, a streetlight is about 5 meters high, and a road is 6 meters wide. If the scale is inconsistent, even the best materials and lighting will look distorted.
- Visual Standards: The rainy night atmosphere is formed by fog, wet ground reflections, local warm light, cool ambient light, rain particles, and glowing signs. It is necessary to clarify which are the main light sources and which are decorative, avoiding an overly bright scene or excessive reflections.
- Performance Standards: The desktop version aims for a stable frame rate, while the mobile version sets a baseline frame rate and downgrade strategy; simultaneously limit draw calls, particle counts, shadow resolution, and texture VRAM budget. The sample budget below is not a fixed value, but a quantifiable template for team communication:
Scene Specifications = {Viewport Ratio: "16:9 and mobile portrait adaptive",Frame Rate Target: "Desktop fluidity priority, mobile interactive baseline",Draw Call Limit: 120,Rain Particle Budget: 8000,Total Texture VRAM Budget: 128MB,Shadows: "Main light only, can be disabled on mobile"}
- Interaction Standards: Determine if it supports camera roaming, perspective switching, rain volume adjustment, day/night toggling, or a performance panel. Do not overcomplicate interactions; the first version should prioritize smooth movement and scene observability.
Writing these standards into the requirement specification before handing them to an LLM for code generation significantly reduces the problem of “it looks usable but cannot be accepted.”
2. Scene Layering: Breaking Down Complex Visuals into Manageable Modules
A rainy night city can be divided into five layers: Base Scene Layer, Building and Road Layer, Convenience Store Detail Layer, Rainy Night Atmosphere Layer, and Interaction and Debugging Layer. The benefit of layering is that each layer can be generated, replaced, and verified independently.
- Base Scene Layer: Camera, renderer, scene root node, time step, and window adaptation. Focus on checking camera near/far clipping planes, color space, and pixel ratio settings.
- Building and Road Layer: First use low-poly modules to determine street layout and building massing, then gradually replace them with detailed models. The first version should not pursue high precision; instead, confirm scale and visual guidance.
- Convenience Store Detail Layer: Includes the storefront, shelves, freezers, checkout counter, glowing signs, and indoor warm light. Details should serve the visual focus, avoiding stacking polygon counts in invisible areas.
- Rainy Night Atmosphere Layer: Rain particles, wet ground reflections, fog effects, streetlight volumetrics, and distant building silhouettes. The atmosphere layer easily consumes performance, so prioritize low-cost approximations.
- Interaction and Debugging Layer: Camera controls, parameter panels, frame rate observation, and downgrade switches. The earlier debugging capabilities are added, the easier subsequent optimizations will be.
The scene assembly process can be described with pseudocode:
function buildRainyNightCity(specs):scene = createScene()city = createStreetBlocks(specs.layout)store = createStoreDetails(specs.shop)atmosphere = createRainNightEffects(specs.atmosphere)scene.load(city, store, atmosphere)return scene
This pseudocode emphasizes the “assemble first, then refine” workflow. LLMs can quickly provide the skeleton, but scale, materials, and lighting still require manual adjustments based on preview results.
3. The Right Way to Collaborate with AI-Assisted Programming
AI-assisted programming is suitable for three things: generating project skeletons, explaining errors, and providing multi-solution comparisons. However, it requires clear constraints. It is recommended to use a “Goal—Constraint—Acceptance—Output Format” prompt structure:
- Goal: Build a browser-side runnable rainy night city scene, including a convenience store, streets, raindrops, fog, and basic camera roaming.
- Constraint: Use standard browser-side 3D rendering APIs; avoid unnecessary dependencies; centralize all parameters in configuration; allow mobile degradation.
- Acceptance: Interactive first screen; no camera clipping; raindrops do not block UI; automatic downgrade when frame rate falls below the baseline.
- Output Format: Provide directory structure, key module descriptions, runnable code, and items pending manual confirmation.
When iterating, do not just say “performance is bad.” Provide observable information, such as “current particle count is too high causing mobile lag, please change raindrops to a layered particle system and provide a downgrade switch that halves the quantity.” LLMs are better at producing mergeable code snippets under explicit constraints rather than making final aesthetic and performance decisions for the developer.
4. Key Implementations for Scale, Atmosphere, and Detail
Scale and Camera: Fix the scene unit and camera height first. A camera too low will magnify ground texture issues, while too high will weaken the street immersion. It is recommended to use a fixed roaming path or limited free perspective for the first version to easily check building scales and occlusion relationships.
Rainy Night Atmosphere: Raindrops can be simulated with multi-layer particles—near layers large and sparse, far layers small and dense; ground reflections use low-cost approximations instead of real reflections; fog is used to hide distant boundaries and enhance depth perception. Lighting should follow a “cool ambient light + local warm light” contrast, with the convenience store storefront and streetlights acting as visual anchors.
Convenience Store Details: Storefront glow, glass transparency, shelf outlines, and indoor warm tones are key. Glass materials should not be overly transparent, otherwise exposing inadequate interior models; wet ground reflection intensity must be controlled to avoid acting like a mirror and stealing focus from the main subject.
Interaction: The first version can provide perspective switching, rain volume adjustment, and a performance mode switch. Interaction states should be centrally managed to avoid being scattered across modules, which makes maintenance difficult.
5. Prioritizing Performance Optimization
Performance optimization should start with “observability.” First record frame rate, draw calls, particle count, and texture memory usage, then handle issues by priority:
- Reduce Draw Calls: Merge static buildings, reuse materials, and use instancing for repeated objects.
- Control Particle Costs: Use layering and distance culling for raindrops—retain detail up close and reduce density in the distance.
- Use Level of Detail (LOD): Use low-poly models for distant buildings and load details for closer ones.
- Compress Textures and Models: Control texture sizes and avoid multiple high-resolution maps residing in memory simultaneously.
- Establish Downgrade Strategies: When the frame rate falls below the baseline, automatically reduce particles, disable secondary reflections, and lower shadow resolution.
Sample downgrade logic is as follows:
function adaptiveDowngrade(currentFPS, budget):if currentFPS < budget.baselineFPS:reduceParticleCount(rain, 0.5)disableSecondaryReflections()reduceShadowResolution()if currentFPS > budget.targetFPS + 10:graduallyRestoreDetails()
Downgrade strategies should be added early in development, not as an afterthought when mobile lag occurs.
6. Engineering and Cloud Collaboration
When a scene transitions from a single-page prototype to a shareable work, it needs static resource hosting, error logging, and performance observability. You can place models, textures, and configuration files into object storage and use Content Delivery Networks (CDNs) to improve loading speed. Frontend errors and key performance metrics can be integrated into logging services and monitoring alerts to help pinpoint lag and resource loading failures on low-end devices. In a cloud environment like Baidu AI Cloud, you can leverage general cloud capabilities such as object storage, logging services, and monitoring alerts to manage resource hosting and build observability, though the specific selection should still be based on project budget, traffic scale, and team operations habits.
7. Conclusion
Using AI-assisted programming to build a rainy night city provides true value not through “one-sentence generation of a complete scene,” but by connecting requirement breakdown, code generation, preview correction, and performance optimization into an efficient closed loop. Scale determines realism, performance determines playability, details determine atmosphere, and clear acceptance criteria determine whether a project can be delivered stably. The key to turning creativity into a runnable work always lies in engineering methodologies and continuous iteration.
