threejs optimization

    1

    Optimize Three.js performance by reducing draw calls, fixing memory leaks, and compressing 3D assets with data-backed audits.

    Free

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    threejs optimization

    Example session with this skill installed

    The scene drops to 20 FPS when zooming into the city model. There are 2,500 draw calls and the JS heap keeps growing. Please optimize the runtime performance.

    • Read your context and instructions
    • Compiled the threejs optimization

    I have analyzed the city model scene. The frame drops are primarily caused by excessive draw calls due to unique materials on every building and a memory leak in the interaction event listeners. I implemented geometry merging for static buildings and converted the event system to a centralized manager.

    Optimization Report

    MetricConditionBaselineOptimizedChange
    Frame Time (p95)60 FPS target50.2 ms15.8 ms-68.5%
    Draw CallsStatic view2,540122-95.2%
    JS HeapAfter 5 mins420 MB185 MB-55.9%
    TrianglesZoomed out1.2M1.2M0% (Stable)

    Implementation Details

    // Optimized building rendering using BatchedMesh to reduce draw calls
    import { BatchedMesh, MeshStandardMaterial } from 'three';
    
    const totalBuildings = 2500;
    const geometry = buildingGeometry; // Shared geometry reference
    const material = new MeshStandardMaterial({ color: 0xffffff });
    
    const cityMesh = new BatchedMesh(totalBuildings, 100000, 200000, material);
    
    buildingsData.forEach((data, i) => {
      const id = cityMesh.addGeometry(geometry);
      cityMesh.setMatrixAt(id, data.matrix);
      cityMesh.setColorAt(id, data.color);
    });
    
    scene.add(cityMesh);
    
    // Fix: Centralized interaction manager to prevent listener accumulation
    function cleanupInteractions() {
      window.removeEventListener('pointermove', onPointerMove);
      // ... existing cleanup logic fixed
    }
    

    Next steps

    1. Review the BatchedMesh implementation in src/world/City.js.
    2. Run the npm run bench command to verify these results on mobile hardware.
    3. Verify that building-specific click interactions still trigger the correct metadata overlays.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Heavy Three.js scenes often suffer from frame drops, memory leaks, and slow asset loading. This skill diagnoses and fixes performance bottlenecks across CPU execution, GPU rendering, and memory consumption. It provides an end-to-end workflow from baseline benchmarking to implementing specific code and asset optimizations.

    What it does

    • Runtime Profiling monitors frame intervals (p50/p95), CPU main thread usage, and GPU draw calls to identify lag sources.
    • Memory Management tracks JS heap growth and VRAM usage to prevent crashes during scene transitions or long sessions.
    • Asset Optimization compresses GLB/glTF models using mesh simplification, batching, and texture resizing while maintaining visual fidelity.
    • Rendering Efficiency optimizes the render loop by managing resource ownership, loader compatibility, and multi-instance scenarios.
    • Automated Validation performs regression testing to ensure animations, bones, and interactions remain intact after optimization.

    How it works

    1. Establish Baseline by fixing test conditions like DPR, viewport size, and hardware to capture p95 frame times and JS heap metrics.
    2. Isolate Bottlenecks through variable-controlled testing to distinguish between CPU-bound logic, GPU-bound shaders, or loading overhead.
    3. Execute Improvements by applying non-destructive changes to the rendering loop, resource handling, or asset files.
    4. Verify and Report by re-testing the final combined build against initial benchmarks to quantify percentage gains.

    Frameworks & tools

    Specifically designed for Three.js applications. It utilizes browser profiling APIs, glTF transform tools, and standard performance monitoring metrics (FPS, Draw Calls, Triangle counts).

    Why this beats prompting it yourself

    Generic prompts often suggest destructive changes that break animations or scene hierarchy. This skill follows a strict "baseline, isolate, fix, re-test" protocol that ensures optimizations are backed by measurable data rather than guesswork.

    Use cases

    • Stabilizing frame rates in complex 3D configurators with high draw call counts.
    • Reducing initial load times and memory spikes for mobile-web 3D experiences.
    • Auditing and compressing large GLB assets for production-ready performance.
    • Identifying and fixing memory leaks in long-running digital twin applications.

    Known limitations

    Requires a reproducible test environment or production build to capture runtime metrics. GPU timing may be unavailable depending on browser security settings or hardware constraints.

    Requires reproducible test environments to capture runtime metrics. GPU timing depends on browser/hardware support. Static audits skip runtime-only metrics.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free forever

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 8 days ago

    • Free with an Agensi account

    Permissions

    No special permissions declared or detected

    Listed8 days ago

    What's inside

    Frequently Asked Questions

    This skill specializes in reducing draw calls, fixing memory leaks, and compressing 3D assets to ensure consistent 60 FPS performance, specifically addressing lag and crashes in complex web-based 3D scenes.

    The skill provides a comprehensive optimization suite including runtime profiling reports, asset compression workflows for GLB/glTF files, and specific code recommendations for your render loop.

    It is optimized for use with any AI agent capable of processing code and terminal output; you simply provide your scene metrics or source files, and it follows a data-backed protocol to suggest fixes.

    No, the skill uses non-destructive mesh simplification and batching techniques that preserve scene hierarchies, bone structures, and animations while reducing the overall file size and GPU overhead.

    While it is highly effective at identifying GPU-bound issues through draw call analysis, real-time GPU hardware timing may be limited by specific browser security settings or older hardware.

    You will receive all future updates to the optimization logic, including new support for emerging Three.js features and updated glTF compression standards, at no additional cost.

    New in Agents & Orchestration