Building 3D Web Pages with LLMs: A Practical Guide to Parametric and Generative Workflows
Large language models are reshaping how 3D web content gets built, compressing a workflow that once required modeling artists, rendering specialists, and frontend engineers into "describe in natural language, generate code, preview in the browser." This guide explains how to choose between parametric and generative modeling, how to select between code-generation and 3D-generation models, provides a reusable prompt template and review checklist, and walks through lighting, camera work, performance optimization, and deployment practices for shipping interactive 3D scenes built with Three.js.
Why 3D Content Generation Is Worth Rebuilding with AI
The main barrier to 3D content is the long production pipeline. Modeling software has a steep learning curve, material and lighting tuning depends on experience, and engine-side scripting and interaction require programming skills. A complete 3D showcase page often needs collaboration among a modeler, a rendering artist, and a frontend engineer.
Large language models compress this pipeline into “natural language description, code generation, real-time browser preview.” The underlying essence of most 3D web pages is a programmatic scene description: declaring geometry, materials, lights, cameras, and animations in code. LLMs are good at generating this kind of structured code, shifting the developer’s job from “building from scratch” to “reviewing and fine-tuning.” This shift can compress days of work into hours—but only if the developer knows how to inspect the generated results.
Parametric vs. Generative: Choosing a Route
The two approaches suit different objects. When choosing, first check whether the object has clear geometric rules.
| Dimension | Parametric Modeling | Generative Modeling |
|---|---|---|
| Best for | Gears, housings, assemblies, standard parts | Terrain, organic surfaces, character props |
| Controllability | Dimensions, symmetry, and hierarchy fully explicit and controllable | Depends on prompts and random seeds; details hard to specify precisely |
| Editability | Change one parameter to regenerate | Usually requires regeneration or manual mesh editing |
| Output format | Code and geometric descriptions | Height maps, voxel fields, or mesh assets |
| Main risk | Heavy modeling effort when rules are unclear | Messy topology, unstable units and scale |
The two routes are usually combined: write parameters for the rule-based parts, use generation for the irregular parts, then unify the coordinate system and scale in the scene.
Parametric Modeling: Precise Control
Parametric modeling describes geometry through code. Well-suited objects include:
- Gears and toothed parts: extrude a tooth-profile sketch along the thickness direction, exposing tooth count, module, and pressure angle as parameters;
- Tires, knobs, cups, and other solids of revolution: generate by revolving a cross-section profile—ideal for shapes symmetric around one axis;
- Assemblies: model buttons and connectors piece by piece, then place them by coordinate system; the clear part hierarchy makes later animation easier to drive.
Screws need special handling. A simple revolved profile only yields a smooth shaft; threads require a helical sweep.
Here is illustrative gear code using Three.js ES module syntax. The tooth profile is simplified, using only four key points per tooth. Real production work requires completing the profile according to standard tooth curves and verifying it against the Three.js version you use.
import * as THREE from 'three';function polar(r, angle) {return new THREE.Vector2(Math.cos(angle) * r, Math.sin(angle) * r);}function createGear({ teeth = 16, module = 1, thickness = 2 } = {}) {const pitchR = (teeth * module) / 2;const tipR = pitchR + module;const rootR = pitchR - 1.25 * module;const step = (Math.PI * 2) / teeth;const shape = new THREE.Shape();for (let i = 0; i < teeth; i++) {const a = i * step;const p0 = polar(rootR, a);const p1 = polar(tipR, a + step * 0.2);const p2 = polar(tipR, a + step * 0.4);const p3 = polar(rootR, a + step * 0.6);if (i === 0) shape.moveTo(p0.x, p0.y);else shape.lineTo(p0.x, p0.y);shape.lineTo(p1.x, p1.y);shape.lineTo(p2.x, p2.y);shape.lineTo(p3.x, p3.y);}shape.closePath();const geo = new THREE.ExtrudeGeometry(shape, { depth: thickness, bevelEnabled: false });geo.center();const material = new THREE.MeshStandardMaterial({ metalness: 0.8, roughness: 0.3 });return new THREE.Mesh(geo, material);}// Example: 16 teeth, module 1, thickness 2const gear = createGear({ teeth: 16, module: 1, thickness: 2 });scene.add(gear);
Once the code is generated, the parameters become an editable interface. Changing to 20 teeth means changing a single number. ExtrudeGeometry extrudes along the Z axis, so the gear lies in the XY plane and faces the camera by default.
Generative Modeling: Handling Irregular Shapes
The typical generative workflow looks like this:
- Generate a height map (terrain) or mesh assets (props) from text descriptions;
- Check units and scale—some 3D generation models output dimensions not in meters, so a unified scaling step is needed;
- Decimate and clean up topology, export as GLB, and compress with Draco or Meshopt;
- Load in Three.js with GLTFLoader, set position and orientation, and add to the scene.
Note that some tools export models in a Z-up coordinate system, while Three.js defaults to Y-up. You need to rotate and correct after import, or the model will lie flat in the scene.
Terrain content can be produced with noise functions plus displacement maps—cheap and reproducible. Details such as rocks and vegetation can be simulated with procedural materials.
Model Selection: Code-Generation LLMs vs. 3D-Generation Models
The two model types differ in output. Code-generation LLMs output Three.js or Babylon.js source code, suited to regular shapes and scene assembly. 3D-generation models output mesh or point cloud assets directly, suited to organic shapes.
| Comparison | Code-Generation LLM | 3D-Generation Model |
|---|---|---|
| Input | Natural language requirements and code context | Text or reference images |
| Output | Readable, editable source code | Mesh or point cloud assets |
| Precision | Dimensions can be specified exactly | Dimensions and scale often need manual correction |
| Iteration cost | Low cost per call, fast to modify | Generation and cleanup take longer |
| Licensing review | Check the usage terms for code output | Check the model service terms and asset licenses |
For mechanical assemblies and architectural scenes, prefer code-generation models. For character props and natural objects, try 3D-generation models, followed by manual topology cleanup.
Prompt Templates and Output Review
A usable prompt should include a role, a goal, technical constraints, negative constraints, and output format. Here is a template:
You are a frontend engineer familiar with Three.js; the project uses the team's specified Three.js version.Goal: Generate a mechanical assembly showcase page containing three parts: a gear, a housing, and a button.Technical constraints:1. Use only `import * as THREE from 'three'` and OrbitControls;2. Dimensions in millimeters, centralized in a config object;3. Use MeshStandardMaterial, tuning look via metalness and roughness;4. Each module in its own function; output skeleton code first—do not produce the full page in one shot.Negative constraints:- Do not use deprecated APIs;- Do not invent loaders or parameter names that do not exist;- Do not replace critical code with "omitted for brevity."Output format: List the file structure first, then give code file by file, and finally list the assumptions requiring human confirmation.
When reviewing generated output, focus on four things: whether the coordinate system is consistent, whether units are consistent, whether API names and parameters actually exist in the version you use, and whether rendering performance exceeds budget. Generated code must be run locally and visually verified in the target browsers.
Scene Building: Lighting, Materials, and Camera Work
Lighting and Materials
Lighting strongly affects visual quality. Three-point lighting is a common starting point: the key light determines direction and shadows, the fill light softens shadow contrast, and the rim light separates the subject from the background. Key light intensity is typically two to three times the fill light; the exact values require repeated adjustment per scene.
Prefer physically based rendering (PBR) for materials. Metalness and roughness are the two core parameters. Metal parts usually have metalness near 1, plastic parts near 0. Writing specific material terms in the prompt—for example, “matte black ABS plastic”—yields more stable results than just “black housing.”
Shadow map resolution should also be set per platform. Desktop can use 1024–2048; on mobile, drop to 512 or disable shadows entirely.
Camera Movement
Orbit shots, dolly moves, and path interpolation are common techniques. The following function implements a slow orbiting camera:
function orbitCamera(t, radius, target) {const angle = t * 0.5;camera.position.set(target.x + radius * Math.sin(angle),target.y + Math.sin(t * 0.3) * 2 + 3,target.z + radius * Math.cos(angle));camera.lookAt(target);}const clock = new THREE.Clock();const target = new THREE.Vector3(0, 0, 0);function animate() {requestAnimationFrame(animate);orbitCamera(clock.getElapsedTime(), 8, target);renderer.render(scene, camera);}animate();
This code assumes camera, renderer, and scene are created elsewhere. When switching shots, smooth the interpolation progress—for example, with the smoothstep easing s * s * (3 - 2 * s)—to make transitions start and end more gently.
Interaction and Performance
Picking is done via Raycaster; drag-based camera control can use OrbitControls directly; a lightweight GUI library lets you tweak geometry properties in real time.
Common performance practices:
- Merge static meshes with
BufferGeometryUtils.mergeGeometriesto reduce draw calls; - Load large assets on demand rather than downloading everything upfront;
- Cap the pixel ratio, e.g.,
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)), to avoid high-DPI screens consuming too much GPU memory; - On mobile, limit shadow resolution and reduce the number of dynamic lights.
Workflow: From Requirements to Production
- Break down requirements: Split “build a mechanical assembly showcase page” into five subtasks—scene, objects, lighting, camera, interaction—and write acceptance criteria for each;
- Generate step by step: Ask for skeleton code first, then iterate module by module, avoiding compounding errors from one-shot generation;
- Externalize parameters: Centralize key dimensions and colors in a config object for easy manual tuning;
- Review and validate: Check coordinate systems, units, API versions, and performance; actually run it in target browsers;
- Deploy: Host static assets in object storage and serve via CDN, paying attention to:
- CORS: When GLB files and textures load from another domain, the object storage must have CORS configured, or WebGL loading will fail;
- Caching: Hashed filenames can use long-term caching; the entry HTML should use shorter cache times;
- Compression: Enable Brotli or gzip, and use Draco compression for GLB assets;
- Compatibility: Detect WebGL2 support and show a fallback message when unavailable;
- Monitoring: Log frame rate, load time, JavaScript errors, and resource load failure rates, and set alert thresholds.
Copyright and Risk Checklist
- Copyright of generated assets: Confirm whether the model service terms allow commercial use; keep records of generation dates and prompts for traceability;
- Third-party assets: HDRI environment maps, fonts, and textures all need license verification;
- Performance budget: Set limits per page—total asset size, draw call count, and memory usage—and optimize when exceeded;
- Fact-checking: Verify APIs and parameters against the official documentation; models may produce parameter names that do not exist;
- Data privacy: Avoid including unreleased product dimensions or internal drawings in prompts.
Conclusion
LLMs turn 3D domain expertise into executable code, but judgment around modeling, lighting, and performance still belongs to the developer. Regular shapes suit parametric approaches; irregular shapes suit generative ones—and model selection should match the characteristics of the object. With a workflow of step-by-step generation, externalized parameters, and pre-launch checks, developers can build interactive 3D work with browser technologies while keeping copyright and performance risks under control.
