Generating Interactive 3D Work with Large Language Models: A Complete Workflow from Specifications to Acceptance Testing

    Large language models can now generate 3D scene code, parametric model scripts, and interaction logic from natural language. Yet first-run results often look rough and behave inconsistently. This article presents a five-step workflow for producing four types of 3D work—interactive web 3D viewers, mechanical parts, architectural scenes, and small game prototypes or camera trailers: writing specifications, implementing code, handling interaction and performance, controlling camera timing, and running quality acceptance. It includes ready-to-use specification templates, JavaScript and Python code examples, performance measurement methods, and a full acceptance checklist.

    1. Why First-Run Results Fall Short

    Large language models can already write 3D scene code, parametric model scripts, and interaction logic from a natural language description. When you run the generated program for the first time, it usually works—but the visuals are crude, the interactions feel stiff, and the camera jitters. Most of these problems trace back to one root cause: the requirements were never written as verifiable conditions, so the model had to guess dimensions, units, and timing on its own.

    This article covers four types of work: interactive 3D web pages, mechanical parts, architectural scenes, and small game prototypes and camera trailers. The workflow has five steps: specification, code implementation, interaction and performance, camera timing, and quality acceptance.

    2. Write the Specification First, Then Let the Model Write Code

    The specification is the starting point of the entire workflow. It should include at least: units, coordinate system, geometry source, materials, interaction behavior, camera parameters, performance budget, and acceptance criteria. Below is an illustrative template with a format defined by this article to explain the idea—it is not a standard format of any tool.

    1. {
    2. "work_type": "web_3d_viewer",
    3. "units": "mm",
    4. "coordinate_system": "y_up",
    5. "geometry": {
    6. "source": "parametric",
    7. "params": { "outer_d": 120, "inner_d": 40, "thickness": 12 }
    8. },
    9. "material": { "base_color": "#8a9199", "metalness": 0.9, "roughness": 0.35 },
    10. "interaction": ["hover_highlight", "click_show_label", "drag_rotate"],
    11. "camera": { "fov": 50, "pitch_limit_deg": [-80, 80] },
    12. "performance_budget": { "max_triangles": 200000, "max_texture_px": 2048 },
    13. "acceptance": ["no_runtime_errors", "dimensions_match_params", "fps_p95_within_target"]
    14. }

    Follow three rules when writing the specification:

    • Attach units to every dimension and keep them consistent globally. The units field prevents mixing millimeters with meters—one of the most common beginner mistakes.
    • Write interaction behavior as “trigger condition plus response result,” for example, “clicking a part shows its label.”
    • Set the performance budget before work begins, not as a fix after completion.

    Here is a comparison:

    Vague prompt: “Make a cool flange that looks nice and can rotate.”

    Structured description: “Generate a flange in millimeters: outer diameter 120, center hole diameter 40, thickness 12, 6 bolt holes on a bolt circle diameter of 90, bolt hole diameter 10. The web page supports drag rotation with unlimited horizontal range and pitch limited to -80 to 80 degrees. Acceptance: no console errors, dimensions match the parameters.”

    The second approach puts the model and the reviewer on the same standard.

    3. Web 3D: Rendering, Interaction, and Performance

    3.1 Runtime Environment

    The code targets current stable versions of Chrome, Edge, Firefox, and Safari. Pages use ES modules (<script type="module">) and requestAnimationFrame. If you open the HTML file directly by double-clicking, the browser will refuse to run it due to module loading restrictions; you need to serve it through a local server—for example, run python -m http.server 8000 in the project directory and visit http://localhost:8000. If you use build tools like Vite or Webpack, Node.js 18 or later is recommended.

    3.2 Resource Layering and On-Demand Loading

    Load models, textures, and audio separately. Only load resources required for the current view on first screen; request the rest when the user interacts or scrolls to the relevant section. Static assets can be stored in object storage and distributed through a content delivery network (CDN) to reduce latency for users in different regions. Which provider to choose depends on your team’s existing cloud environment, costs, and compliance requirements.

    3.3 Fixed-Timestep Rendering Loop

    Browser frame intervals are not fixed. If physics and animations depend directly on frame intervals, behavior will differ between high-refresh-rate devices and low-performance devices. A common solution is a fixed logic timestep with interpolation by the remaining fraction at render time. update and render are implemented by your business code.

    1. const STEP = 1 / 60;
    2. let accumulator = 0;
    3. let last = performance.now();
    4. function frame(now) {
    5. // Cap accumulated time per frame at 0.25s to prevent catching up too many steps after tab switch
    6. accumulator += Math.min((now - last) / 1000, 0.25);
    7. last = now;
    8. while (accumulator >= STEP) {
    9. update(STEP);
    10. accumulator -= STEP;
    11. }
    12. render(accumulator / STEP);
    13. requestAnimationFrame(frame);
    14. }
    15. requestAnimationFrame(frame);

    3.4 Separating Drag from Click

    Drags and clicks often overlap. Treat pointer movement beyond 5 pixels as a drag; otherwise treat it as a click. Reset state on pointer cancellation too, or the next click will be misjudged.

    1. const DRAG_THRESHOLD_PX = 5;
    2. function attachPointer(el, { onClick, onDragStart, onDragMove, onDragEnd }) {
    3. let start = null;
    4. let dragging = false;
    5. el.addEventListener("pointerdown", (e) => {
    6. start = { x: e.clientX, y: e.clientY, id: e.pointerId };
    7. dragging = false;
    8. el.setPointerCapture(e.pointerId);
    9. });
    10. el.addEventListener("pointermove", (e) => {
    11. if (!start || e.pointerId !== start.id) return;
    12. const dx = e.clientX - start.x;
    13. const dy = e.clientY - start.y;
    14. if (!dragging && Math.hypot(dx, dy) > DRAG_THRESHOLD_PX) {
    15. dragging = true;
    16. onDragStart?.(e);
    17. }
    18. if (dragging) onDragMove?.(e);
    19. });
    20. el.addEventListener("pointerup", (e) => {
    21. if (!start || e.pointerId !== start.id) return;
    22. if (dragging) onDragEnd?.(e);
    23. else onClick?.(e);
    24. start = null;
    25. dragging = false;
    26. });
    27. el.addEventListener("pointercancel", () => {
    28. if (dragging) onDragEnd?.(null);
    29. start = null;
    30. dragging = false;
    31. });
    32. }

    Lingering hover highlights usually come from unhandled leave events. Clear hover state in both pointerleave and pointercancel, and keep only one currently hovered object.

    3.5 Performance Budgets and Measurement Methods

    A performance budget must specify how it is measured, otherwise the numbers cannot be compared.

    Metric Measurement Method Notes
    First-screen load time Listen for largest-contentful-paint via PerformanceObserver Time from navigation start to main content appearing
    Frame rate stability Record frame intervals in the loop; take P95 frame time over a 5-second window Average FPS masks stutters; look at P95 instead
    Draw calls Read renderer.info.render.calls in Three.js Merging meshes with the same material reduces this value
    Texture size Read pixel dimensions of textures Compare against max_texture_px in the specification

    Measurement results must state the conditions: target device (e.g., a specific mid-range phone or laptop model), network conditions (e.g., bandwidth and latency), browser version, and the number of runs per measurement. Run each measurement at least 3 times and take the median. The metrics above are engineering checkpoints, not performance promises of any platform; specific target values must be defined by the project itself.

    4. Mechanical Parts and Architecture: Parametric Modeling

    For mechanical parts and architecture, the core requirement is dimensional reliability. The approach: express the shape as a parameterized class, validate parameters before generation, verify the results with independent calculations, and finally output a report. A flange is used as the example below.

    The runtime environment is Python 3.9 or later, using only the standard library—no additional installation required.

    1. import json
    2. import math
    3. from dataclasses import dataclass, asdict
    4. @dataclass
    5. class Flange:
    6. outer_d: float # Outer diameter in mm
    7. inner_d: float # Center hole diameter in mm
    8. thickness: float # Thickness in mm
    9. bolt_count: int # Number of bolt holes
    10. bolt_pitch_d: float # Bolt circle diameter in mm
    11. bolt_d: float # Bolt hole diameter in mm
    12. def validate(self) -> None:
    13. if min(self.outer_d, self.inner_d, self.thickness,
    14. self.bolt_d, self.bolt_pitch_d) <= 0:
    15. raise ValueError("All dimensions must be positive")
    16. if self.bolt_count < 3:
    17. raise ValueError("At least 3 bolt holes required")
    18. if self.inner_d >= self.outer_d:
    19. raise ValueError("Inner diameter must be smaller than outer diameter")
    20. if self.bolt_pitch_d - self.bolt_d <= self.inner_d:
    21. raise ValueError("Bolt holes overlap the center hole")
    22. if self.bolt_pitch_d + self.bolt_d >= self.outer_d:
    23. raise ValueError("Bolt holes exceed the flange outer edge")
    24. # Chord distance between adjacent hole centers is pitch * sin(pi / n); must exceed hole diameter
    25. chord = self.bolt_pitch_d * math.sin(math.pi / self.bolt_count)
    26. if chord <= self.bolt_d:
    27. raise ValueError("Adjacent bolt holes intersect")
    28. def bolt_centers(self) -> list[tuple[float, float]]:
    29. r = self.bolt_pitch_d / 2
    30. return [
    31. (round(r * math.cos(2 * math.pi * i / self.bolt_count), 4),
    32. round(r * math.sin(2 * math.pi * i / self.bolt_count), 4))
    33. for i in range(self.bolt_count)
    34. ]
    35. def build_report(flange: Flange) -> dict:
    36. flange.validate()
    37. centers = flange.bolt_centers()
    38. radius = flange.bolt_pitch_d / 2
    39. radius_error = max(abs(math.hypot(x, y) - radius) for x, y in centers)
    40. checks = {
    41. "bolt_count_matches": len(centers) == flange.bolt_count,
    42. "bolt_radius_error_mm": round(radius_error, 6),
    43. "radius_error_within_tolerance": radius_error <= 1e-3,
    44. }
    45. if not (checks["bolt_count_matches"] and checks["radius_error_within_tolerance"]):
    46. raise RuntimeError(f"Acceptance failed: {checks}")
    47. return {
    48. "units": "mm",
    49. "params": asdict(flange),
    50. "bolt_centers": centers,
    51. "checks": checks,
    52. }
    53. if __name__ == "__main__":
    54. part = Flange(outer_d=120, inner_d=40, thickness=12,
    55. bolt_count=6, bolt_pitch_d=90, bolt_d=10)
    56. report = build_report(part)
    57. with open("flange_report.json", "w", encoding="utf-8") as f:
    58. json.dump(report, f, ensure_ascii=False, indent=2)
    59. print("Validation passed; report written to flange_report.json")

    When run, the terminal prints “Validation passed; report written to flange_report.json,” and a JSON file containing the parameters, bolt hole coordinates, and validation results is generated in the same directory. If you change the bolt hole diameter to 50, validate throws an exception because adjacent holes intersect—exactly what the validation is for.

    Exporting to STEP or STL requires a CAD kernel library such as CadQuery, which is out of scope for this example. Before exporting, check three things: whether the units are mm; whether STL normals point outward—reversed normals break rendering and Boolean operations; and whether assembly constraints, such as the fit clearance between bolts and holes, are documented in the specification.

    Architectural scenes follow the same approach. Express rooms, door openings, and corridors as parameter objects, and validate that door opening widths are no smaller than the clearance width stated in the specification. Specific values must be confirmed against local building codes.

    5. Camera Keyframes and Trailer Timing Control

    5.1 Camera Keyframes

    Describe the camera with keyframes. Each keyframe contains a time, a camera position, and a look-at target, with interpolation between two keyframes. Keyframe times must be strictly increasing—validate this on load.

    1. function smoothstep(t) {
    2. return t * t * (3 - 2 * t);
    3. }
    4. // keys is an array sorted by ascending time; each item looks like { t, pos: [x, y, z], target: [x, y, z] }
    5. function sampleCamera(keys, time) {
    6. if (time <= keys[0].t) return keys[0];
    7. for (let i = 0; i < keys.length - 1; i++) {
    8. const a = keys[i];
    9. const b = keys[i + 1];
    10. if (time <= b.t) {
    11. const u = smoothstep((time - a.t) / (b.t - a.t));
    12. return {
    13. pos: a.pos.map((v, k) => v + (b.pos[k] - v) * u),
    14. target: a.target.map((v, k) => v + (b.target[k] - v) * u),
    15. };
    16. }
    17. }
    18. return keys[keys.length - 1];
    19. }

    smoothstep has zero velocity at each keyframe, so the camera pauses at keyframes—suitable for storyboard-style transitions. For continuous camera motion, use a Catmull-Rom spline instead. This curve requires an extra check to confirm the camera path does not pass through buildings or mechanical models.

    5.2 Timing Driven by the Logic Clock

    Events in trailers and small games—such as entrances, transitions, and sound effects—should be attached to the logic timeline, advanced by the fixed-timestep loop from Section 3, rather than reading frame time directly. This way, events fire at exactly the same times and in the same order on both 60 Hz and 144 Hz screens.

    5.3 State Reset in Small Games

    A common mistake in small game prototypes is state leaking across restarts—scores, enemy positions, or input buffers not cleared. The fix: keep all mutable state in a single object, and on restart replace it entirely with the initial state instead of clearing variables one by one. Inputs should also be consumed uniformly within each logic step to prevent the same keypress from being processed multiple times.

    6. Quality Verification and Acceptance Checklist

    Complete acceptance item by item before delivery. Pass criteria for each item are defined by the project; the table below gives the checking method.

    Category Check Item Method Pass Criteria
    Geometry Dimensions match parameters Run build_report and compare checks All checks are true
    Geometry Units consistent Check units in the spec against code constants All mm or all m
    Material Not a plain white model Manual comparison against reference images Visible differences in metalness, roughness, and lighting
    Interaction No duplicate triggers Click rapidly 20 times in a row Each click triggers exactly one response
    Interaction No hover residue Move off a part and observe the highlight Highlight disappears immediately on leave
    Performance First-screen load time Measured per Section 3.5 Below the target in the specification
    Performance Frame rate stability Record P95 frame time over 5 seconds Below the target in the specification
    Camera Smooth motion Compute camera velocity change frame by frame Velocity change between adjacent frames within project threshold
    Timing Consistent across refresh rates Record event times at 60 Hz and 120 Hz Identical event times and order
    Runtime No runtime errors Check console error count Count is 0

    7. Common Mistakes

    • Mixing units, e.g., parameters written in mm but interpreted as m on export.
    • Binding physics or animations directly to frame intervals, causing inconsistent behavior across devices.
    • Hover, drag, or small game states not reset on restart or cancellation.
    • Camera interpolated only between keyframes without checking for velocity discontinuities.
    • Reporting only average frame rate, which masks periodic stutters.
    • Copying example code as-is without adding validation, so out-of-range parameters fail silently.