Low-Cost 3D Web Page Generation with LLMs: A Practical Guide to MoE Models

    Learn how mixture-of-experts language models can help generate interactive 3D web pages at low inference cost. This guide covers the core components of a 3D page, a four-step workflow using structured prompts and targeted revisions, token-cost considerations, and the limits of AI-generated prototypes.

    1. Why Low-Cost 3D Web Page Generation Is Becoming Practical

    Generating a web page from scratch with a 3D scene, drag-to-rotate controls, and clickable objects has traditionally required a substantial token budget. Two characteristics make these tasks expensive:

    1. Long context and output: A complete 3D page includes scene initialization, geometry, materials, lighting, camera controls, and event handlers. The resulting code can easily span hundreds of lines.
    2. Repeated revisions: The first version is rarely perfect. Multiple rounds of changes can increase token consumption because subsequent requests often include previous conversation history.

    Mixture-of-experts (MoE) language models offer a way to reduce inference costs through sparse activation. A model may have hundreds of billions of total parameters while activating only a small subset for each token—for example, roughly 200 billion total parameters with around 10 billion active parameters.

    This design offers several potential advantages:

    • Broad knowledge capacity: A large total parameter count provides capacity for knowledge of frontend technologies such as WebGL, Three.js, and CSS3D.
    • Lower inference compute: Activating only a subset of parameters reduces per-token computation compared with a dense model of similar total size, which can support lower API pricing.
    • Long-context and multimodal options: Some models in this category support multimodal input and context windows of up to one million tokens, allowing developers to supply design screenshots alongside existing project code.

    These capabilities depend on the specific model; MoE architecture alone does not guarantee multimodal support, a particular context length, or a particular API price. Nevertheless, sparse activation can make generating a complete interactive 3D prototype inexpensive—potentially on the order of a few tenths of a Chinese yuan in inference charges.

    2. What an Interactive 3D Web Page Contains

    Before prompting a model, break the page into its technical layers. This makes the requirements clearer and helps the model produce a coherent implementation.

    1. Rendering layer: A WebGL-based library such as Three.js initializes the scene, camera, and renderer.
    2. Content layer: Geometry, materials, lights, and textures define the objects and their appearance.
    3. Interaction layer: Dragging rotates the view, scrolling adjusts zoom, raycasting identifies clicked objects, and animations handle transitions.
    4. UI layer: HTML and CSS overlays display information panels and controls.

    The following minimal skeleton illustrates scene setup, geometry, lighting, click detection, and an animation loop:

    1. <script type="module">
    2. import * as THREE from 'three';
    3. // 1. Initialize the scene, camera, and renderer
    4. const scene = new THREE.Scene();
    5. const camera = new THREE.PerspectiveCamera(45, innerWidth / innerHeight, 0.1, 1000);
    6. camera.position.set(0, 2, 6);
    7. const renderer = new THREE.WebGLRenderer({ antialias: true });
    8. renderer.setSize(innerWidth, innerHeight);
    9. document.body.appendChild(renderer.domElement);
    10. // 2. Add geometry and lighting
    11. const cube = new THREE.Mesh(
    12. new THREE.BoxGeometry(1.5, 1.5, 1.5),
    13. new THREE.MeshStandardMaterial({ color: 0x4a90e2 })
    14. );
    15. scene.add(cube, new THREE.AmbientLight(0xffffff, 0.6));
    16. const dir = new THREE.DirectionalLight(0xffffff, 1);
    17. dir.position.set(3, 5, 4);
    18. scene.add(dir);
    19. // 3. Use raycasting to change the object's color on click
    20. const raycaster = new THREE.Raycaster();
    21. addEventListener('click', (e) => {
    22. const p = new THREE.Vector2(e.clientX / innerWidth * 2 - 1, -(e.clientY / innerHeight) * 2 + 1);
    23. raycaster.setFromCamera(p, camera);
    24. if (raycaster.intersectObject(cube).length) {
    25. cube.material.color.set(Math.random() * 0xffffff);
    26. }
    27. });
    28. // 4. Run the animation loop
    29. renderer.setAnimationLoop(() => {
    30. cube.rotation.y += 0.01;
    31. renderer.render(scene, camera);
    32. });
    33. </script>

    This is a code skeleton rather than a complete standalone HTML file: the surrounding project must resolve the three module import.

    Giving the model this modular structure is more useful than a vague request such as “build me a 3D web page.”

    3. A Four-Step Workflow for Low-Cost Generation

    Step 1: Use Structured Prompts to Reduce Wasted Tokens

    Even with a capable model, clear requirements help prevent unnecessary revisions. Specify:

    • The technology stack: The rendering library, whether to use ES modules, and the target browsers.
    • The interactions: Drag-to-rotate, scroll-to-zoom, click selection, or an automatic camera tour.
    • The output format: A single HTML file, explanatory comments, and a runnable result.

    For example:

    1. Generate a single-file HTML page using Three.js:
    2. 1. Include three geometric objects in different colors and soft ambient lighting.
    3. 2. Support dragging to rotate the camera view and scrolling to zoom.
    4. 3. Display an information panel when a geometric object is clicked.
    5. 4. Include English code comments and make the page runnable in a browser.

    The goal is to define the expected result upfront, rather than spending multiple requests clarifying basic behavior.

    Step 2: Generate the Complete Skeleton in One Request

    Long-context support is useful when the task includes a detailed requirements document or an existing codebase. If the model supports image input, reference screenshots can also be included.

    Providing the relevant context together can reduce back-and-forth and help the model generate a consistent project skeleton. Repeated small requests often resend earlier messages, increasing input-token usage.

    The important distinction is relevant context, not simply the largest possible prompt. A well-scoped initial request can be more economical than many rounds of incremental clarification.

    Step 3: Validate Locally and Request Targeted Changes

    Test the generated page in a local browser before deployment. Common problems include:

    • A blank or black screen: Check the camera position and rendering dimensions. If the browser reports an error, send the exact message back to the model.
    • Unresponsive interactions: Check whether event listeners are attached to the intended DOM element.
    • Expensive revisions: Request only the functions or code sections that need to change instead of asking the model to regenerate the entire page.

    Targeted edits reduce output tokens and make the changes easier to review.

    Step 4: Deploy the Page

    A static single-file page can be hosted in object storage with static website hosting enabled. It can also be deployed through a container platform if that fits the existing release workflow.

    If the page loads large 3D models or other assets, store those resources in object storage and deliver them through a CDN to reduce their impact on initial rendering.

    4. Understanding the Cost

    A rough token budget for a moderately complex interactive 3D page might look like this:

    • Initial output: Around 300–500 lines of code, or approximately 4,000–8,000 output tokens.
    • Follow-up work: Two or three targeted repair rounds may keep total usage below roughly 20,000 tokens.
    • Sparse activation: In the illustrative 200-billion-total, 10-billion-active configuration, only about 5% of parameters are active for each token, reducing compute relative to a dense model with the same total parameter count.

    These factors help explain how a working prototype can be generated for a few tenths of a Chinese yuan under sufficiently low API pricing.

    However, the active-parameter percentage is not an API billing multiplier. Actual charges depend on the model’s input and output token rates, the amount of conversation history included, and the number of revisions. The token ranges above are estimates, not a guaranteed budget for every page.

    The practical cost-saving strategy is to combine an economical model with a clear initial specification and small, focused follow-up requests.

    5. Suitable Use Cases and Limitations

    Low inference cost does not mean generated code is ready for every production workload. This approach is particularly useful for:

    • Rapid prototypes: Initial versions of product demos, campaign pages, and data visualizations.
    • Learning: Reading modular generated code to understand the 3D rendering pipeline.
    • Scaffolding: Creating a foundation that developers can refine and maintain.

    Performance-sensitive scenes—such as large particle systems or complex physics simulations—still benefit from experienced developers reviewing and optimizing the implementation. Projects that require precise artistic control also need more hands-on refinement.

    Relevant optimization techniques include rendering batches, level of detail (LOD), and asset compression. Generating a working scene is a starting point, not a substitute for performance testing or visual polish.

    Conclusion

    MoE models can lower the inference cost of generating interactive 3D web pages by combining substantial model capacity with sparse parameter activation. The resulting economics make them useful for prototypes, learning, and development scaffolding.

    Three habits have the greatest practical value: write structured prompts, provide the relevant context upfront, and request targeted changes rather than full rewrites. Together, they can shorten the path from an idea to a runnable prototype while leaving more time for the design and engineering work that requires human judgment.