Large Language Models for Frontend and 3D Development: Capability Boundaries and Acceptance Testing

    Large language models can now generate runnable frontend components and 3D rendering code, but output quality depends on version constraints, validation workflows, and human review. This article explains which tasks are suitable for model-generated code, how to validate frontend and shader output, and why developers must personally review and test security-sensitive logic and rendering performance.

    Large language models can generate runnable frontend components and 3D rendering code. However, the quality of the output depends heavily on version constraints, validation procedures, and human review. The practical conclusion is straightforward: component scaffolding, boilerplate code, and initial shader drafts are suitable tasks for a model. Decisions involving authorization, payments, form validation, and rendering performance must be reviewed and tested by developers.

    1. Fix the Environment Before Writing the Prompt

    When versions are not specified, a model may mix legacy lifecycle patterns with Hooks in the same code sample, resulting in compilation errors or runtime warnings. Prompts should therefore state the framework version, build tool, and styling solution at the beginning. For example: React 18, TypeScript 5, Vite 5, and Tailwind CSS 3.

    A useful prompt should include four parts:

    • Page objective
    • Component list
    • Data interfaces
    • Interaction rules

    For example:

    Build a product card list with React 18 and TypeScript. Split the UI into three components: ProductCard, ProductGrid, and PriceTag. Define the data with a Product interface containing id, title, price, and imageUrl fields. Clicking a card should trigger an onSelect callback. When the viewport is narrower than 768px, switch the layout to a single column.

    Spacing, typography, and colors from a design should be provided as design tokens. If the model receives only a screenshot, it cannot reliably reproduce the design at pixel level. Spacing and color deviations are especially common.

    Acceptance Checklist for Generated Output

    • Type checking passes, with no uncontrolled spread of any types in business code.
    • Each component has a focused responsibility. When a component has more than six props, consider splitting it or using an object parameter. This threshold is a team guideline, not a strict rule.
    • List rendering uses stable keys rather than array indexes.
    • Event listeners and timers are cleaned up when components are unmounted. Browser developer tools and memory snapshots can help verify this.
    • Compare screenshots at 375px, 768px, and 1280px viewport widths. Fix the baseline images, browser version, and pixel-difference threshold. For example, a team might set the maximum acceptable difference ratio to 0.5%; anything above that requires manual inspection.

    When there are too many props, related fields can be grouped into an object:

    1. interface ProductCardProps {
    2. product: Product;
    3. onSelect: (id: string) => void;
    4. options?: { showBadge?: boolean; compact?: boolean };
    5. }

    Boundary Conditions

    Authorization, payment, and form-validation logic must be reviewed line by line by a developer. These areas should never rely solely on generated output. Errors can lead to financial or data loss, while the cost of reviewing the code is usually far lower than the cost of an incident.

    2. 3D Rendering: Shader Versions, Debugging, and Performance Measurement

    1. Versions and Shader Types

    The examples in this article target Three.js r160 or later and WebGL 2. Three.js provides three commonly used shader material configurations, and each handles version declarations differently:

    • ShaderMaterial: Three.js automatically adds a prefix to the shader, including a version declaration, precision declarations, and macro definitions that map GLSL ES 1.00 syntax to newer syntax. When writing GLSL ES 1.00-style code, no changes are usually required.
    • ShaderMaterial with glslVersion set to THREE.GLSL3: The shader must use GLSL ES 3.00 syntax. Three.js no longer adds the legacy macros, so syntax such as varying and gl_FragColor will not work.
    • RawShaderMaterial: Three.js adds no prefix. The developer must provide #version 300 es and precision declarations manually.

    The exact injected content can vary with the Three.js version and configuration. Before deployment, inspect the final shader source generated by Three.js. Prompts must explicitly specify both the graphics library version and the GLSL version; otherwise, the model may mix GLSL ES 1.00 and 3.00 syntax.

    2. Example: A Water-Ripple Fragment Shader

    The following fragment shader uses GLSL ES 1.00 syntax and is intended for use with ShaderMaterial. The vertex shader must output vUv.

    1. precision mediump float;
    2. uniform float uTime;
    3. uniform vec3 uColor;
    4. varying vec2 vUv;
    5. void main() {
    6. float wave = sin((vUv.x + vUv.y) * 24.0 - uTime * 2.0) * 0.5 + 0.5;
    7. vec3 color = mix(uColor * 0.6, uColor, wave);
    8. gl_FragColor = vec4(color, 1.0);
    9. }

    In GLSL ES fragment shaders, float has no default precision. If RawShaderMaterial is used without a precision declaration, compilation fails directly rather than merely producing a black screen. With ShaderMaterial, Three.js already declares precision in the injected prefix, so the declaration shown above overrides the default.

    On mobile devices, explicitly setting mediump can reduce performance overhead. The resulting color behavior should still be verified on actual hardware.

    3. Debugging Checklist

    • Capture a frame with Spector.js or a browser WebGL debugging tool and check whether the number of draw calls is unexpectedly high.
    • When shader compilation fails, read the line number in the log first, then inspect the surrounding context. Three.js reports line numbers based on the complete concatenated shader source, not the original source file. Compare the error with the shader source printed in the log.
    • In WebGL 1, textures with mipmaps must use power-of-two dimensions. WebGL 2 relaxes this restriction, but texture formats must still be compatible with the target device.
    • Normal maps use two common Y-axis conventions. OpenGL uses an upward Y direction, while DirectX uses a downward direction. Three.js interprets normal maps according to the OpenGL convention by default. If lighting appears inverted, first check the source convention of the normal map, or set normalScale.y to -1 for comparison. For verification, use a plane with a single, clearly oriented slope and check whether the highlight appears in the expected position relative to the light source.

    4. Performance Measurement

    Performance data is only useful when the measurement methodology is clearly defined. Otherwise, results from different tests cannot be compared.

    • Frame time and frame rate: Record the time difference between consecutive frames inside the requestAnimationFrame callback and collect data for 60 seconds. Report both the median frame time and the 99th-percentile frame time. Derive the frame rate from the 99th-percentile frame time using 1000 / milliseconds. Looking only at average frame rate can hide occasional stutters.
    • Draw calls and triangle count: Read renderer.info.render.calls and renderer.info.render.triangles. By default, renderer.info resets its counters after each render, so read the values after the render call, or set autoReset to false and reset the counters manually.
    • GPU memory: Three.js does not provide an interface that reports GPU memory usage in bytes. You can use renderer.info.memory.geometries and renderer.info.memory.textures to count objects and then estimate usage. For textures, use width × height × bytes per pixel; when mipmaps are enabled, multiply the result by approximately 4/3. For geometry, sum the array.byteLength values of all BufferAttribute objects. These estimates indicate only the approximate scale of usage. Drivers, framebuffers, and compressed formats affect actual consumption, which is usually higher. The GPU memory column in a browser task manager can provide an additional reference, although it is not visible on every platform. On mobile devices, verify available GPU memory on physical hardware rather than relying only on estimates.

    3. Model Selection and Cost Control

    1. Choose a Model by Task Difficulty

    Task difficulty determines the model tier that can be used and the level of validation required. The following table is a starting point for team planning. Specific model names and tiers should be selected according to current pricing and capability tests.

    Difficulty Typical tasks Model tier Validation Human review
    L1 Minor style adjustments, variable renaming, single-function completion Small or low-cost model Type checking and unit tests Spot checks
    L2 A single component with state and API calls, form layout Mid-range model Type checking, screenshot comparison, and interaction testing Review business logic