Text-to-3D Scene Reconstruction: Technical Practice and Evaluation

    This article examines how to turn a reference image into a runnable, interactive 3D scene using code only, with no external models, textures, or inline images. It covers prompt design as an acceptance contract, structured scene parsing, parametric geometry and camera control, material and lighting choices, code-drawn text and UI, interaction and performance, a four-dimension evaluation checklist, and common failure modes with practical workarounds.

    1. The Problem: From “Describe the Image” to “A Runnable Scene”

    As visual generation capabilities advance quickly, a representative technical task has come into focus: given a reference image, the model must procedurally rebuild the scene in a browser using code only, without referencing any external model files, textures, or inline images. The result must support mouse-drag rotation, scroll-wheel zoom, run on a double-click, and produce no console errors. The value of this task is that it pushes generation from a static display toward a deliverable, verifiable engineering artifact.

    Compared with generating a descriptive paragraph, this task demands an order of magnitude more from the model. It must understand composition, perspective, and lighting in the image, map that understanding into geometry, material parameters, light sources, and renderer configuration, and also handle text, UI elements, and interaction logic. If any one of these is missing, the output “looks right but does not work.”

    2. Prompt Design: Put Acceptance Criteria Up Front

    A practice that works well is to let the prompt itself act as an acceptance contract. A reusable structure looks like this:

    1. I will give you a reference image.
    2. Constraints: all geometry, materials, and lighting must be generated procedurally in code;
    3. referencing external models, textures, or base64 inline images is prohibited.
    4. Interaction: support mouse-drag rotation and scroll-wheel zoom.
    5. Delivery: runs in the browser on a double-click, with no console errors.
    6. Fidelity requirements:
    7. (1) overall composition matches the reference image (subject position, perspective);
    8. (2) lighting direction matches the reference image;
    9. (3) reproduce at least two material characteristics (e.g., metallic reflection, wet surfaces, fabric texture);
    10. (4) text or UI elements in the image are drawn in code, not as textures.
    11. Output order: first summarize the scene and key visual elements in one sentence, then provide the complete code.

    Three points make this design effective. First, the prohibitions draw a clear boundary and stop the model from taking shortcuts. Second, the numbered clauses break subjective impressions into items that can be judged. Third, the required output order enforces understanding before implementation, which reduces semantic drift in one-shot generation.

    3. Scene Parsing: Build a Structured Understanding First

    The “one-sentence understanding” before generation is not a formality; it is the skeleton for the code that follows. Take a night landmark scene as an example. The structured understanding typically includes the subject composition (base, gear assembly, clock face, truss, celestial decorations), light direction (warm ground light from below, cool blue as fill), background layers (buildings with lit windows), foreground elements (light strips, neon text, railings), and a text inventory (Roman numerals, year, place name, inscription).

    When translating natural-language understanding into a scene graph, it helps to define three layers: subject, environment, and decoration. The subject layer determines composition and proportion; the environment layer determines ground reflection and background depth; the decoration layer carries text and fine details. The benefit of layering is that later debugging can target a specific layer instead of rebuilding everything from scratch.

    4. Geometry and Composition: Control Perspective with Parameters

    The core of procedural modeling is expressing intent through parameters. A low-angle upward shot can be achieved by combining camera position and field of view; a subject placed to the right, with celestial elements centered or slightly left, is controlled through alignment anchors and offsets. Example code:

    1. camera.position.set(0, 1.6, 9);
    2. camera.fov = 45; // field of view affects perspective strength
    3. const root = new THREE.Group();
    4. root.position.x = 1.2; // subject shifted to the right
    5. scene.add(root);

    For repeated structures such as gears, railing posts, and truss diagonals, use loops and instancing rather than hand-writing each coordinate. This shortens the code and makes spacing and orientation easy to adjust consistently.

    5. Materials and Lighting: Two Characteristics Are the Passing Line

    The worst outcome in material reproduction is a uniform, high-brightness plastic look. It is better to prioritize two easily judged characteristics: metallic reflection and wet pavement. Metal needs low roughness, relatively high metalness, and relies on environment lighting to form highlights; wet pavement needs low roughness combined with reflection so that light strips and neon are mirrored on it. For lighting, separate the key light from the fill: a warm key light emphasizes volume, a cool fill darkens the shadow areas, and the overall image avoids looking washed out and gray.

    1. const gold = new THREE.MeshStandardMaterial({
    2. color: 0xffcc66, metalness: 0.9, roughness: 0.25
    3. });
    4. const wet = new THREE.MeshStandardMaterial({
    5. color: 0x111318, metalness: 0.1, roughness: 0.15
    6. });

    Procedural generation does not mean giving up realism; it means trading physical parameters for control and reproducibility.

    6. Text and UI: Always Draw in Code

    If text in the reference image is implemented as a texture, it immediately violates the constraints and is hard to scale. The common approach is to generate a texture on a canvas and map it onto a plane, or to assemble strokes from geometry. The key is to expose text content, font proportions, and glow intensity as parameters so they can be aligned with the reference image.

    1. function makeTextTexture(text, color = '#fff') {
    2. const c = document.createElement('canvas');
    3. c.width = 512; c.height = 128;
    4. const g = c.getContext('2d');
    5. g.fillStyle = color; g.font = 'bold 64px sans-serif';
    6. g.textAlign = 'center'; g.textBaseline = 'middle';
    7. g.fillText(text, 256, 64);
    8. return new THREE.CanvasTexture(c);
    9. }

    7. Interaction, Runtime, and Performance

    For interaction, bind pointer events and scroll-wheel zoom, and clamp the polar angle to keep the camera from going below the ground. For performance, the usual measures are controlling draw calls, merging static geometry, and capping the pixel ratio to keep things smooth. Before delivery, make sure the file runs on a double-click locally with no build step, the console is error-free, and first-screen load time is acceptable.

    8. Evaluation Method: Turn Subjective Impressions into a Checklist

    A four-dimension evaluation is recommended: composition consistency, lighting match, number of material characteristics, and completeness of text and interaction. Score each item against criteria that can be judged, and keep one “blind review without the reference image” as a control to rule out preconceptions. If conditions allow, have a reviewer describe the image without seeing the reference, then compare it with the reference; this reflects fidelity more objectively.

    9. Common Failure Modes and How to Avoid Them

    The first is the “texture shortcut,” passing off inline images as modeling. The second is “plastic materials,” with no distinction in metalness and roughness. The third is “missing text,” either omitted or replaced with textures. The fourth is “broken interaction,” with laggy dragging or zoom that goes out of bounds. The fifth is “console errors,” mostly caused by resource paths or version differences. All of these point to the same principle: write the constraints into the prompt, and write the acceptance criteria into a checklist.

    10. Conclusion

    Generating an interactive 3D scene from an image is an effective yardstick for the combined capability of multimodal understanding and code generation. What really decides success is not the impressiveness of the demo moment, but constraint compliance, structural completeness, and reproducibility. Putting acceptance criteria up front, layering the scene, and parameterizing materials and text is what moves a generated result from “looks like it” to “usable.”