How to Reliably Evaluate LLM-Generated Frontend and 3D Code
This guide is for frontend and 3D engineering teams and evaluation leads who want to distinguish "the model can write code" from "the code can enter a real development workflow." It first fixes the evaluation methodology, then walks through acceptance criteria for frontend and 3D tasks, and finally explains how to decide caching and model routing strategies based on measured data rather than assumptions.
How to Reliably Evaluate LLM-Generated Frontend and 3D Code
This article is written for frontend and 3D engineering teams and evaluation leads. The goal is to separate “the model can write it” from “it can enter the development workflow.” We first fix the evaluation methodology, then give acceptance criteria by category, and finally explain how cost strategy should be driven by measured data.
1. Fix the Evaluation Baseline First
Results must be compared under the same standard, so every test run must fix three things: test cases, scoring rules, and the runtime environment.
Test cases come in three tiers. The basic tier covers a single component or a single scene, such as a centered button or a cube. The intermediate tier covers multi-section page layouts, or scenes with lights and materials. The complex tier covers interactive components with state management, or complete scenes with dragging and collision. Each tier should have at least 20 cases. Frontend and 3D tasks are scored separately, so good results in one category cannot hide problems in the other.
Scoring uses a 100-point scale with four dimensions:
| Dimension | Max Score | How It Is Determined |
|---|---|---|
| Syntax correctness | 20 | Checked with a fixed-version ESLint or TypeScript compiler, plus the browser console. Deduct 5 points per error, down to zero. |
| Logical completeness | 30 | Break the natural-language requirement into requirement points; score proportionally to coverage. Two reviewers verify independently. |
| Visual fidelity | 25 | Frontend: check breakpoints, spacing, and alignment against a checklist, scored proportionally. 3D: two reviewers each rate “proportion” and “lighting” from 1 to 5 (formula below). |
| Code maintainability | 25 | Check module decomposition, function length (recommended: no more than 50 lines per function), global variables, and resource cleanup, scored proportionally to checklist items passed. |
Anchors for 3D visual scoring: 1 means clearly distorted or missing; 2 means multiple errors; 3 means overall consistent with visible deviations; 4 means only minor detail deviations; 5 means essentially identical to the design.
If the two reviewers’ scores differ by no more than 1 point, take the average. If the difference exceeds 1 point, a third reviewer adjudicates. If disagreement remains, record both scores and mark the case as pending re-review—do not average them directly.
The 3D visual score is computed as: (average of the proportion and lighting scores) ÷ 5 × 25.
The pass criteria are: overall score of at least 80, syntax correctness of at least 16, and logical completeness of at least 24.
2. Record the Runtime Environment and Repetitions
Every run must save the following information. Results missing any item are excluded from the formal evaluation.
| Item | What to Record |
|---|---|
| Model name and version | Full name as returned by the API or shown on the platform |
| Temperature | The actual value, never “default” |
| Prompt text | Saved in full, unedited |
| Test date | Year-month-day |
| Browser and version | Type and major version number |
| Node.js version | Pinned minor version |
| Three.js version | Same as the sample or the version actually used |
| ESLint and TypeScript versions | Pinned minor versions |
| Viewport width | 375px, 768px, 1280px; height recorded uniformly |
| Device pixel ratio | Recorded separately for 1 and 2 |
| Screenshot tool and version | For example, Playwright, with its version |
Each case runs at least 3 times, and each run’s pass/fail result is recorded. A team may adopt the rule that “passing at least 2 of 3 runs” counts as a pass for that case.
| Case ID | Tier | Run 1 | Run 2 | Run 3 | Passes | Notes |
|---|---|---|---|---|---|---|
| FE-001 | Basic | TBD | TBD | TBD | TBD | TBD |
| 3D-001 | Basic | TBD | TBD | TBD | TBD | TBD |
3. Frontend: Responsive Card Grid
Test prompt: “Create a responsive card grid with a single column on mobile, two columns on tablets, four columns on desktop, and a hover zoom effect.”
Check three things during acceptance. First, the column count is controlled by media queries, with no hard-coded widths. Second, breakpoints follow a mobile-first organization. The sample here uses min-width. If the team has standardized on max-width, every breakpoint range must be verified individually to ensure they do not overlap. Third, the hover effect uses transform together with a transition; otherwise the zoom will look abrupt.
The following file can be saved as an .html file and opened directly in a browser.
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Card Grid</title><style>.page { padding: 24px; }.card-grid {display: grid;grid-template-columns: 1fr;gap: 16px;}@media (min-width: 768px) {.card-grid { grid-template-columns: repeat(2, 1fr); }}@media (min-width: 1024px) {.card-grid { grid-template-columns: repeat(4, 1fr); }}.card {background: #fff;border-radius: 8px;padding: 16px;box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);transition: transform 0.2s ease;}.card:hover { transform: scale(1.05); }</style></head><body><main class="page"><div class="card-grid"><article class="card">Card 1</article><article class="card">Card 2</article><article class="card">Card 3</article><article class="card">Card 4</article></div></main></body></html>
In the sample, .page provides 24px of padding so enlarged cards do not touch the edges. If a parent container sets overflow: hidden, the edges of a zoomed card will be clipped—this must be checked during acceptance.
Common problems in model output:
| Common Issue | Symptom | Fix |
|---|---|---|
| Overlapping breakpoints | Mixing min-width and max-width, so two rules apply at the same width |
Standardize on mobile-first min-width; if using max-width, verify each range individually |
| Hover overflow | Enlarged cards exceed the container and cover adjacent content | Add padding to the parent container and check for overflow: hidden |
| Using JS instead of CSS hover | Modifying styles with mouseenter, making the code longer and harder to maintain |
Use :hover with transform; reserve JS for logic CSS cannot express |
For visual review, set the viewport to 375px, 768px, and 1280px respectively, take one screenshot at each width, and compare against the design. Screenshot filenames should include the model name, case ID, and viewport width, and be stored with the evaluation record.
4. 3D: Drag-to-Rotate and Scroll-to-Zoom
Production projects should prefer the library’s built-in orbit controls. Three.js’s OrbitControls already handles damping, distance bounds, wheel, and touch events. Implement your own controls only when the library cannot meet the requirement.
When implementing controls yourself, first agree on a coordinate system. Here we use Y-up, with the camera moving on a sphere around the target. Spherical coordinates are defined by radius r, polar angle φ (angle from the +Y axis), and azimuthal angle θ (rotation around the Y axis):
- x = r · sin φ · sin θ
- y = r · cos φ
- z = r · sin φ · cos θ
The polar angle φ must be clamped to [ε, π − ε]. When φ crosses 0 or π, the azimuth flips abruptly and the view flips with it. This is the cause of the view-flipping problem mentioned earlier when the pitch angle crosses a pole.
The sample below is a reference implementation using Three.js r160.0. Before the formal evaluation, run it in the recorded environment and write the actual version into the environment checklist.
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><style>html, body { margin: 0; height: 100%; overflow: hidden; }</style><script type="importmap">{"imports": {"three": "https://unpkg.com/three@0.160.0/build/three.module.js","three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"}}</script></head><body><script type="module">import * as THREE from 'three';import { OrbitControls } from 'three/addons/controls/OrbitControls.js';const scene = new THREE.Scene();scene.background = new THREE.Color(0x222222);const camera = new THREE.PerspectiveCamera(60, innerWidth / innerHeight, 0.1, 100);camera.position.set(3, 2, 5);const renderer = new THREE.WebGLRenderer({ antialias: true });renderer.setSize(innerWidth, innerHeight);renderer.setPixelRatio(Math.min(devicePixelRatio, 2));document.body.appendChild(renderer.domElement);const controls = new OrbitControls(camera, renderer.domElement);controls.enableDamping = true;controls.dampingFactor = 0.05;controls.enableZoom = true;controls.minDistance = 2;controls.maxDistance = 20;controls.minPolarAngle = 0.01;controls.maxPolarAngle = Math.PI - 0.01;controls.target.set(0, 0, 0);scene.add(new THREE.AmbientLight(0xffffff, 0.4));const light = new THREE.DirectionalLight(0xffffff, 1);light.position.set(5, 10, 7);scene.add(light);const geometry = new THREE.BoxGeometry(1, 1, 1);const material = new THREE.MeshStandardMaterial({ color: 0x4fa3ff });scene.add(new THREE.Mesh(geometry, material));let rafId;function animate() {rafId = requestAnimationFrame(animate);controls.update();renderer.render(scene, camera);}animate();function onResize() {camera.aspect = innerWidth / innerHeight;camera.updateProjectionMatrix();renderer.setSize(innerWidth, innerHeight);}window.addEventListener('resize', onResize);function dispose() {cancelAnimationFrame(rafId);window.removeEventListener('resize', onResize);controls.dispose();geometry.dispose();material.dispose();renderer.dispose();}window.addEventListener('pagehide', dispose);</script></body></html>
Damping depends on calling controls.update() in the animation loop; omit that line and damping silently stops working. On page unload, you must cancel the animation frame, remove listeners, and dispose of the controls, geometry, material, and renderer. Without cleanup, GPU memory keeps growing as the page is opened and closed repeatedly.
3D acceptance checklist:
- After dragging, the view does not flip, and the pitch angle stays within bounds.
- Scroll zoom stops at the minimum and maximum distances, and the camera never passes through the target.
- On touch devices, one-finger rotation and two-finger zoom work correctly.
- After page unload, no geometry or material remains; re-entering the page repeatedly does not cause resource counts to grow continuously.
- Frame-rate fluctuation on mid-range devices is acceptable. On mobile, you can lower the pixel ratio, disable shadows, and reduce the number of lights.
5. Use Measured Data to Decide Caching and Model Routing
This article provides no performance or cost figures. The metrics below must be measured by each team on their own cases and models.
| Metric | Calculation | Value (TBD) |
|---|---|---|
| Case pass rate | Passed cases ÷ total cases | TBD |
| Mean overall score | Average of overall scores across cases | TBD |
| Cost per request | (input tokens × input price + output tokens × output price) | TBD |
| Cost per passed case | Total cost ÷ passed cases | TBD |
| Latency P50 and P95 | Median and 95th percentile of request durations | TBD |
| Cache hit rate | Cache hits ÷ total requests | TBD |
The cache key should include the model name and version, temperature, and a hash of the prompt. Only fully identical inputs can hit the cache. When temperature is greater than 0, a cached result is just one sample, and this must be noted in the report.
Routing rules can be designed by tier. Basic-tier cases go to a lower-cost model. Complex-tier cases go directly to a more capable model. When the low-cost model fails, escalate to the more capable model for a retry, and record the number of escalations. Escalations count toward the cost per passed case.
Routing thresholds are set by the team itself. For example, if a tier’s pass rate on the low-cost model meets the team’s agreed standard, pin that tier to that model; otherwise route directly to the more capable model. Thresholds should be written into the evaluation record and revisited with each evaluation round.
6. Conclusion and Risks
Generated frontend or 3D code can enter the development workflow only when all of the following hold:
- Overall score of at least 80, syntax correctness of at least 16, and logical completeness of at least 24.
- Each case passes under the team’s agreed repetition rule.
- Differences between visual screenshots and the design have been confirmed by reviewers.
- The code passes human review, dependency versions are pinned, and there are no hard-coded secrets or internal addresses.
A first-round validation can follow these steps:
- Select 5 cases each from frontend and 3D tasks, covering the basic, intermediate, and complex tiers.
- Fix the model, temperature, prompts, and runtime environment, and record them.
- Run each case 3 times and record the results.
- Score with the scoring table; 3D visual fidelity is rated independently by two reviewers.
- Capture screenshots at the three viewports and compare against the design.
- Based on whether the conditions above are met, decide to adopt, rework, or defer.
First-round results only reflect how this batch of cases performs in the current environment. A formal evaluation still requires at least 20 cases per tier.
Key risks: First, passing the evaluation does not mean the code can ship directly—security review, performance testing, and production monitoring are still required. Second, 3D scenes may behave very differently across GPUs and browsers, so conclusions must note the test hardware. Third, test screenshots and logs must not contain real user data or internal credentials. Fourth, after a model version upgrade, historical results may no longer be valid and the baseline must be re-run.
