Building a Rainy Night Convenience Store in 3D: A Practical Guide to LLM Collaboration and Engineering

    This article walks through building a small rainy-night convenience store 3D scene in the browser as a hands-on exercise in collaborating with large language models. It covers how to scope requirements before prompting, how to structure prompts and iterate in rounds, how to calibrate proportions with a centralized config and validation checks, how to implement rain, puddles, neon, and fog effects, and how to set and enforce a performance budget—plus a checklist of common issues and debugging strategies.

    1. Why a Rainy Night Convenience Store Is a Good Practice Project

    A rainy-night convenience store is a compact 3D scene that’s well suited for practice. It combines architectural structure, interior furnishings, neon signage, reflective wet ground, rain animation, and nighttime lighting—covering typical challenges in spatial layout, materials, lighting, and performance control. Working on it lets you complete the full pipeline from concept to a running prototype within a small scope.

    An LLM can write most of the initial code. However, a first draft usually only guarantees “it runs”; proportions, frame rate, and details still require repeated correction by the developer. This article therefore focuses on how to organize collaboration with the model and which steps must be reviewed by a human.

    2. Define the Scope Before Letting the Model Write Code

    Asking directly for “a small rainy-night city” rarely produces usable results. When the scope is too large, the model delivers incomplete implementations across multiple directions at once. Before starting, write a short requirements note covering at least the following:

    • Scene boundary: a single store or an entire block; whether outdoor roads are needed.
    • Unit convention: unify units, e.g., 1 unit = 1 meter.
    • Visual style: color tone, light source types, rain intensity.
    • Interaction: whether the camera can move freely; whether click interactions are required.
    • Runtime targets: target devices, minimum frame rate, whether external assets are allowed.

    The more specific the requirements, the easier it is to locate and correct deviations in the output.

    3. Prompt Structure and Iterating in Rounds

    An effective prompt usually has four parts: role and goal, scene description, hard constraints, and output format. For example:

    Write a browser-based 3D scene in pure JavaScript. Unit is meters. The store interior is 8 wide, 12 deep, 3.2 high. It rains outside; the number of raindrops must not exceed 3000. Output a single-file page that runs directly, and list all tunable parameters at the top of the code.

    Iterating in rounds is more effective than demanding perfection in one shot. Change only one variable per round: confirm dimensions in round one, adjust lighting in round two, optimize the rain effect in round three. With a single variable, you can quickly identify which step introduced a problem.

    The following must be reviewed manually: whether dimensions match the spec, whether resources are released, whether temporary objects are created frequently inside loops, and whether external asset links are valid.

    4. Calibrating Proportions and Dimensions

    Proportion errors are the most common problem. Models tend to generate dimensions by intuition, resulting in shelves that are too short or doorways that are too narrow. The solution is to centralize all dimensions in a config object and verify each item after code generation:

    1. // Unified unit: 1 unit = 1 meter
    2. const STORE = {
    3. width: 8, // frontage width
    4. depth: 12, // depth
    5. height: 3.2, // ceiling height
    6. doorWidth: 1.2,
    7. doorHeight: 2.2,
    8. shelfHeight: 1.8,
    9. };
    10. function checkLayout(cfg) {
    11. if (cfg.doorWidth >= cfg.width) {
    12. throw new Error("Door width must not exceed frontage width");
    13. }
    14. if (cfg.doorHeight >= cfg.height) {
    15. throw new Error("Door height must not exceed ceiling height");
    16. }
    17. if (cfg.shelfHeight >= cfg.height) {
    18. throw new Error("Shelf height must not exceed ceiling height");
    19. }
    20. }
    21. checkLayout(STORE);

    The value of a validation function is that it turns “something looks off” into automatically checkable rules. In addition, compute the camera’s initial position from the store’s facade dimensions to ensure the full building exterior fits within the view.

    5. Implementing the Rainy Night Effects

    The rainy-night atmosphere comes from multiple elements working together; cranking up any single one usually doesn’t work well. A common implementation path:

    1. Raindrops: use a particle system where each particle stores position and fall speed, and is recycled to the top once it falls below the ground.
    2. Ground puddles: adjust the ground’s roughness, or use an environment-reflection approximation, so neon light reflects on the wet surface.
    3. Neon lights: use emissive materials with bloom post-processing. Keep light colors to two or three primary hues to avoid a cluttered image.
    4. Fog: moderate exponential fog blends the distant rain curtain into the background naturally and reduces the rendering burden of far-away scenery.

    The basic rain update logic:

    1. function createRain(count, area) {
    2. const positions = new Float32Array(count * 3);
    3. const speeds = new Float32Array(count);
    4. for (let i = 0; i < count; i++) {
    5. resetDrop(positions, speeds, i, area, true);
    6. }
    7. return { positions, speeds, area };
    8. }
    9. function resetDrop(positions, speeds, i, area, randomY) {
    10. positions[i * 3] = (Math.random() - 0.5) * area.x;
    11. positions[i * 3 + 1] = randomY ? Math.random() * area.y : area.y;
    12. positions[i * 3 + 2] = (Math.random() - 0.5) * area.z;
    13. speeds[i] = 6 + Math.random() * 4; // fall speed in meters per second
    14. }
    15. function updateRain(rain, dt) {
    16. const { positions, speeds, area } = rain;
    17. for (let i = 0; i < speeds.length; i++) {
    18. positions[i * 3 + 1] -= speeds[i] * dt;
    19. if (positions[i * 3 + 1] < 0) {
    20. resetDrop(positions, speeds, i, area, false);
    21. }
    22. }
    23. }

    This code keeps all particle data in contiguous arrays, avoiding per-frame object allocation and making it easy to submit the data to the render layer in one pass.

    6. Performance Budget

    Set a performance budget before writing code. Targeting a 60 Hz display, the per-frame budget is about 16.7 milliseconds. A reference allocation:

    Item Suggested Limit Notes
    Draw calls Keep within roughly 100 Merge static geometry; use instanced rendering for shelf products
    Dynamic lights 3 or fewer Most lighting can be replaced with baked or fake lights
    Raindrop count Adjust per device; start with a few thousand Doubling the count does not double the visual improvement
    Texture size Common textures no larger than 1024 px Neon textures can be slightly larger; keep the rest restrained

    Performance problems usually have multiple contributing factors, so measure before optimizing. The following code tracks the average frame time over a recent window:

    1. const samples = [];
    2. let last = performance.now();
    3. function recordFrame(now) {
    4. samples.push(now - last);
    5. last = now;
    6. if (samples.length > 120) samples.shift();
    7. }
    8. function averageFrameMs() {
    9. if (samples.length === 0) return 0;
    10. return samples.reduce((a, b) => a + b, 0) / samples.length;
    11. }

    If the average frame time stays above budget, troubleshoot in this order: first reduce draw calls, then lower the raindrop count, and finally shrink the post-processing render resolution.

    7. Common Issues and How to Diagnose Them

    • Distorted proportions: check that units are unified and that the camera’s field of view and distance match the store’s dimensions.
    • Noticeable frame drops: first check for object creation inside loops, then check for duplicate meshes that haven’t been merged.
    • Continuously growing memory: confirm old resources are released when replacing materials or textures.
    • Washed-out, grayish image: check the output color space settings.