AI-Assisted 3D Scene Building: Creating a Rainy Night Town for the Web

    This article presents a general workflow for using AI coding assistants to turn the mental image of "a convenience store on a rainy night" into a runnable, interactive, and iterable Web 3D prototype. It covers defining acceptance criteria before code generation, decomposing the scene into layered specifications, building the rendering pipeline for a rainy-night atmosphere, enforcing performance budgets and mobile adaptation, designing interactions, and adopting an iterative collaboration method with AI coding tools. The stack is based on open Web standards and does not bind to any specific rendering library or commercial product.

    AI-Assisted 3D Scene Building: Creating a Rainy Night Town for the Web

    This article describes a general practice: using an AI coding assistant to move “a convenience store in a small town on a rainy night” from a mental image to a runnable, interactive, and iterable Web 3D prototype. The technology stack is based primarily on open Web standards and is not tied to any specific rendering library or commercial product. It is important to emphasize that this kind of work is rarely done in a single generation pass. Proportions, performance, materials, and details still need to converge through specification descriptions, runtime feedback, and repeated localized rewrites.

    1. Define Acceptance Criteria Before Generating Code

    3D scene development easily falls into a loop of “write code first, then tweak the visuals.” A more reliable approach is to define acceptance criteria first: whether the scene runs stably in the browser; whether first-screen loading is acceptable; whether the camera angle conveys the rainy-night mood; whether the proportions of the convenience store, street, awning, and streetlights are consistent; whether mobile devices have a degradation strategy; and whether interactions are intuitive enough. AI coding assistants are well suited for architecture drafts, boilerplate code, debugging suggestions, and localized refactoring, but they cannot replace a developer’s judgment on visual goals and performance budgets.

    An actionable acceptance checklist includes: unified metric units; a fixed starting camera viewpoint; a target frame rate of at least 50 FPS on desktop and 30 FPS on mobile; no more than 2 real-time shadow-casting lights; on-demand loading of static assets; and toggleable rain intensity, lighting, and camera interactions. Writing these constraints into a specification before asking the tool to generate code produces far more maintainable results than simply saying “build a rainy-night convenience store.”

    2. Requirement Decomposition and Scene Modeling

    Scene elements should be organized in layers: ground and street, the convenience store body, awning and signage, shelves and interior furnishings, streetlights and wires, rain streaks and puddles, and distant building silhouettes. Each category should have explicit coordinates, dimensions, materials, and a performance tier. A data-driven approach is recommended—separating the “object manifest” from the “rendering logic”—so models can be swapped or proportions adjusted later.

    1. const sceneSpec = {
    2. unit: "meter",
    3. camera: { position: [8, 3, 12], target: [0, 1.5, 0], fov: 55 },
    4. budget: { drawCalls: 150, lights: 6, shadowLights: 2, maxTextureMB: 64 },
    5. objects: [
    6. { type: "box", name: "store", size: [6, 3, 4], position: [0, 1.5, 0] },
    7. { type: "plane", name: "wetGround", size: [40, 40], material: "wetAsphalt" },
    8. { type: "box", name: "sign", size: [5, 0.8, 0.2], position: [0, 3.2, 2.1] }
    9. ]
    10. };

    Proportion problems are often more subtle than code problems. Door height, awning height, streetlight spacing, and camera height need a unified reference. Developers can first build a gray-box model with plots, boxes, and simple materials, confirm the spatial relationships, and then replace them with detailed assets. An AI coding assistant can generate the gray-box code from the specification, but whether the proportions feel right still requires human observation and adjustment.

    3. Rendering Pipeline and the Rainy-Night Atmosphere

    The rainy-night atmosphere is built from lighting, materials, fog, and particles working together. The renderer should be configured with reasonable tone mapping and color space to avoid overexposed signage or crushed blacks. For lighting, a low-intensity ambient light can provide baseline visibility, point or spot lights from streetlights can shape pools of light on the ground, interior area lights can simulate cool-white fluorescent lighting, and self-illuminated signage can reinforce the visual focal point. Real-time shadows should be used sparingly—keep shadows only for key lights and use contact shadows or baked textures for the rest.

    Wet ground is the key to the atmosphere. You can simulate puddles by lowering roughness, layering normal perturbation, and controlling reflection intensity, using screen-space reflections or simplified planar reflections when necessary. Rain streaks can be implemented with instanced line segments or a particle system, combined with fog and slight camera shake to enhance the rainy feel. In code, raindrop updates should be constrained within a fixed budget:

    1. function updateRain(dt) {
    2. for (let i = 0; i < rain.count; i++) {
    3. rain.y[i] -= rain.speed[i] * dt;
    4. if (rain.y[i] < 0) rain.y[i] = rain.height;
    5. }
    6. }

    4. Performance Budget and Mobile Adaptation

    Performance bottlenecks in 3D scenes typically come from draw calls, shadowed lights, texture memory, and transparent particles. Establish a budget table: limit draw calls on desktop, and further reduce raindrop count, shadow resolution, and reflection quality on mobile; merge or instance static geometry where possible; use low-poly models or billboards for distant objects; load textures on demand and compress them; and pause updates for invisible regions. An AI coding assistant can help generate quality switches and degradation logic, but the budget values must be determined by the developer based on target devices.

    1. const quality = {
    2. desktop: { rainCount: 6000, shadowMap: 1024, reflections: true },
    3. mobile: { rainCount: 1800, shadowMap: 512, reflections: false }
    4. };

    5. Interaction Design and Playability

    Runnable does not mean playable. You can add interactions such as orbital camera controls, a rain-intensity slider, lighting toggles, clickable hotspots inside the convenience store, and day/night switching. Interaction events should be throttled, and state changes should be managed centrally to avoid expensive per-frame computations. AI coding assistants are good at generating event bindings, state management, and UI scaffolding, but interaction priorities and visual feedback still need human design.

    6. A Method for Collaborating with AI Coding Assistants

    An efficient collaboration workflow is: write the specification, generate the skeleton, run and observe, record issues, and rewrite locally. The specification should include technology stack constraints, coordinates and proportions, performance budgets, acceptance criteria, and interfaces that must not be modified. Generated code must be reviewed by a human for maintainability, security, and asset licensing. Do not expect a finished product from a single generation pass. Break the big goal into five iterations—gray-box model, lighting, rain effects, interaction, and optimization—and solve only one category of problems per round. That is how the project converges steadily.

    7. Engineering and Deployment

    On the engineering side, scene configuration, rendering modules, asset manifests, and interaction logic should be separated, with versioning and rollback capability preserved. For deployment, you can use general-purpose static asset hosting, object storage, container platforms, logging services, and monitoring/alerting; if you choose a cloud provider such as Baidu AI Cloud, plan resources, permissions, and observability metrics according to these general categories. The ultimate goal is not to show off, but to make the rainy-night town a 3D piece that loads, responds to interaction, and can be continuously optimized.