Evaluating LLM Programming Capabilities in Frontend and 3D Scenes

    This article provides a systematic framework for evaluating the ability of Large Language Models (LLMs) to generate frontend and 3D scene code. It outlines how to design a tiered task set, define multi-dimensional scoring criteria, execute specific checks for 3D environments, calculate the true cost per passing task, and maintain reproducible evaluation results. Following this framework helps engineering teams make data-driven model selection decisions.

    1. Why Demos Cannot Replace Systematic Evaluation

    Pages or 3D scenes generated by models often look impressive in a single demo: smooth animations, thoughtful color schemes, and seemingly complete interactions. However, demo samples are usually cherry-picked to showcase a successful run. The questions engineering teams truly need to answer are: when the same type of requirement is repeatedly submitted, can the model consistently deliver runnable code? Is the code maintainable after multiple rounds of modifications? Is the total cost within budget?

    To answer these questions, evaluation must shift from a “gut feeling” approach to a reproducible process. A complete workflow requires at least four elements: a task set, scoring dimensions, execution conditions, and a statistical method for results. Missing any of these can easily skew the comparison.

    2. Task Set Design: Tiered by Complexity

    The task set should cover real-world requirements ranging from simple to complex. It is recommended to divide them into four difficulty levels:

    Level Typical Tasks Key Evaluation Points
    L1 Static pages and responsive layouts Structural semantics, style adaptation
    L2 Interactive components like forms, lists, and filters State management, event handling
    L3 Data visualization and transition animations Data binding, rendering performance
    L4 Browser-side 3D scenes and complex interactions Coordinate system understanding, resource loading, frame rate control

    It is advisable to prepare 5 to 10 tasks for each level. Requirement descriptions should use neutral language, clearly define functional boundaries, and specify acceptance criteria to avoid vague expressions. For example, “make a beautiful product page” cannot be verified, whereas “implement a three-column responsive card layout that becomes single-column when the viewport width is below 768px, and displays a placeholder image if an image fails to load” can be checked item by item.

    Task definitions can be written in a structured format for batch execution and automated verification:

    1. task = {
    2. "id": "scene-3d-001",
    3. "level": "L4",
    4. "requirement": "Render a rotatable cube on the page that supports mouse drag rotation. The canvas should adapt when the window is resized.",
    5. "acceptance_criteria": [
    6. "No console errors after page load",
    7. "The cube rotates around the corresponding axis when dragged with the mouse",
    8. "The canvas width and height update synchronously when the window size changes",
    9. "No significant frame rate drop within one minute of continuous operation",
    10. ],
    11. }

    3. Scoring Dimensions and Weights

    A simple “pass or fail” does not reflect code quality. It is recommended to score across six dimensions using interpretable rules:

    1. Functional Correctness: Whether all acceptance criteria are met. Automated checks (e.g., element existence, event triggering) should be prioritized for script verification.
    2. Runtime Stability: Whether the page has uncaught exceptions, resource loading failures, or continuous memory growth. Stability issues often only surface after several minutes of operation, so longer runtime logs must be retained.
    3. Visual Fidelity: Compared against design drafts. Pixel-diff comparisons can be made via screenshots, followed by manual review. Manual scoring requires quantified standards, such as awarding full marks if the position deviation of key elements is within an agreed pixel range, and deducting points proportionately if exceeded.
    4. Code Quality: Whether the structure is clear, naming is consistent, duplicate logic is absent, and necessary comments exist for critical logic.
    5. Iteration Capability: Whether the model can modify only the relevant parts without breaking other functions when the user requests changes. This dimension best reflects the model’s value in actual development.
    6. Cost Efficiency: The number of input and output tokens consumed per task, and the number of interaction rounds required to complete it.

    The weight of each dimension should be determined by the team based on business scenarios. For instance, internal tool projects can increase the weight of functional correctness and iteration capability, while external marketing pages might warrant a higher weight for visual fidelity. The sample code for calculating the total score is as follows:

    1. def calculate_total_score(dim_scores: dict, weights: dict) -> float:
    2. """dim_scores range from 0 to 100. The sum of weights should be 1."""
    3. if abs(sum(weights.values()) - 1.0) > 1e-6:
    4. raise ValueError("The sum of weights must be 1")
    5. total_score = sum(dim_scores[k] * weights[k] for k in weights)
    6. return round(total_score, 2)
    7. weights = {
    8. "functional_correctness": 0.30,
    9. "runtime_stability": 0.15,
    10. "visual_fidelity": 0.15,
    11. "code_quality": 0.15,
    12. "iteration_capability": 0.15,
    13. "cost_efficiency": 0.10,
    14. }

    4. Specific Checks for 3D Scenes

    3D tasks fail differently from page tasks and require separate check items. Common checkpoints include:

    • Coordinate System Conventions: The requirements should explicitly state which coordinate system is used and how the positive directions are defined. Inconsistent coordinate systems cause incorrect rotation directions, which are easily overlooked visually.
    • Camera and Lighting: Whether the camera position is reasonable, whether objects are in the field of view, and whether light sources cause overexposure or complete darkness.
    • Resource Loading: Models or textures are loaded asynchronously. The code needs to handle three states: loading, loaded successfully, and failed to load.
    • Canvas Adaptation: When the window size changes, the rendering area and projection ratio must update synchronously.
    • Resource Release: When navigating away or unmounting a component, geometries, materials, and textures should be released; otherwise, long-term use will cause memory leaks.

    Resource release can be written as an automated check rule, such as counting the number of unreleased objects after the unmount process:

    1. def check_resource_release(scene_record: dict) -> bool:
    2. # scene_record is collected by the test script after unloading,
    3. # recording the creation and release counts of various resources
    4. for resource_type, stats in scene_record.items():
    5. if stats["created"] != stats["released"]:
    6. print(f"Unreleased {resource_type}: created {stats['created']}, released {stats['released']}")
    7. return False
    8. return True

    5. Cost Calculation: Measuring Cost Per Passing Task

    Comparing only the price per call can lead to wrong conclusions. A model with a low unit price but a low pass rate may require repeated retries, ultimately costing more. A more reasonable metric is the cost per passing task:

    Cost Per Passing Task = Total Cost ÷ Number of Passed Tasks

    Assume two models purely to illustrate the calculation: Model A has a base cost of 1 per task and a pass rate of 40%; Model B costs 1.5 per task and has a pass rate of 80%. Model A’s cost per passing task is 1 ÷ 0.4 = 2.5, while Model B’s is 1.5 ÷ 0.8 = 1.875. In this scenario, Model B has a lower cost per passing task.

    The calculation should include the costs of all retries and repair rounds; otherwise, the result will favor solutions that require extensive manual fixes not accounted for in the cost.

    6. Ensuring Evaluation Reproducibility

    Evaluation results are only valuable for comparison if they are reproducible. Adhere to the following guidelines:

    • Fix prompt templates and system instructions. Any modification must be recorded with a version number.
    • Record the model version, API call time, and values of all adjustable parameters.
    • Run each task multiple times and report the pass rate rather than a single result. For example, 7 out of 10 passes can be reported as 70%, noting that small sample sizes carry significant volatility.
    • Conduct blind evaluations where reviewers cannot see the model identifier, reducing bias from brand preference.
    • Save raw outputs, runtime logs, and screenshots for post-evaluation review and dispute resolution.

    7. Common Pitfalls in Interpreting Results

    The first pitfall is using the best single result to represent the model’s capability. The distribution of multiple runs is far more informative than the highest score.

    The second pitfall is focusing solely on visual effects. A beautiful page does not mean the interactions are correct, and an exquisite 3D scene does not guarantee proper resource management.

    The third pitfall is ignoring maintenance costs. If the code generated in one pass has a messy structure, every subsequent modification will cost extra time. This cost must be factored into the assessment.

    The fourth pitfall is extrapolating the results of a single task to all scenarios. Strong performance on L1 tasks does not mean the model is equally reliable on L4 tasks. Conclusions should be strictly limited to the tested task scope.

    8. Implementation Recommendations

    Teams can establish a long-term evaluation mechanism following these steps:

    1. Extract 20 to 50 tasks from a real requirements repository, covering all difficulty levels.
    2. Write automated acceptance scripts for each task. Automate checks wherever possible.
    3. After every model version update or prompt adjustment, run a regression on all tasks to observe changes in the pass rate.
    4. Compile the evaluation results into a selection document, recording test conditions, scoring rules, and statistical outcomes, making it easy for future team members to reuse and challenge.

    By following this methodology, teams can use a consistent benchmark to compare the performance of different models in frontend and 3D tasks, leading to more reliable judgments and well-founded selection decisions.