agentleFS
grounded-playgrounded-play/hunker-bunker/.agents/skills/threejs-builder/SKILL.md

threejs-builder

Skill2 starsChanged 51 days agoMITView on GitHub

Comprehensive guide and production patterns for Three.js and WebGL 3D development. Use this skill whenever building, modifying, debugging, or optimizing Three.js scenes, render pipelines, shaders, PBR materials, lighting & shadow maps, cameras, GLTF/GLB loaders, instanced rendering, memory leak prevention, and WebGL performance.

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every unique mesh, material, or non-instanced object incurs CPU-to-GPU overhead (a draw call).

    line 23
  2. Very specific:

    Use InstancedMesh for repeated objects (bullets, foliage, enemies, props).

    line 24
  3. Very specific:

    Use BatchedMesh (Three.js r159+) or BufferGeometryUtils.mergeGeometries for static scenery.

    line 25
  4. Very specific:

    Never pass raw window.devicePixelRatio without clamping!

    line 29
  5. Distinctive:

    Read the following specialized references when working on specific subsystems:

    line 52

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Three.js Builder & 3D WebGL Mastery

This skill provides production-grade architectural patterns, memory management runbooks, and performance optimizations for Three.js and WebGL applications.


The Golden Commandments of Three.js

  1. VRAM Is Not Garbage-Collected Automatically: JavaScript garbage collection only frees CPU references. GPU resources (Geometry, Material, Texture, RenderTarget) remain leaked in WebGL VRAM unless explicitly freed via .dispose(). Always implement explicit teardown lifecycles. 👉 See references/memory-and-disposal.md for recursive disposal patterns.
  2. Respect the Draw Call Budget: Every unique mesh, material, or non-instanced object incurs CPU-to-GPU overhead (a draw call). Target < 50-100 draw calls for smooth 60-120 FPS.
    • Use InstancedMesh for repeated objects (bullets, foliage, enemies, props).
    • Use BatchedMesh (Three.js r159+) or BufferGeometryUtils.mergeGeometries for static scenery. 👉 See references/performance-and-instancing.md.
  3. Clamp Device Pixel Ratio: Never pass raw window.devicePixelRatio without clamping! 3x or 4x Retina screens will cause severe fill-rate bottlenecks.
    renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
  4. Clamp Animation Delta Time: Tab switching or lag spikes produce huge delta values that can catapult physics objects or break animations. Always clamp:
    const dt = Math.min(clock.getDelta(), 0.1); // clamp to max 100ms
  5. Linear Workflow & Color Management: Configure modern color spaces and tone mapping immediately during initialization:
    renderer.outputColorSpace = THREE.SRGBColorSpace;
    renderer.toneMapping = THREE.ACESFilmicToneMapping;
    renderer.toneMappingExposure = 1.0;

Architectural Breakdown & Subdocs

Read the following specialized references when working on specific subsystems:

  • Memory Management & Disposal: references/memory-and-disposal.md
    • Recursive scene disposal, texture de-allocation, WebGL context loss prevention.
  • Performance, Instancing & Batching: references/performance-and-instancing.md
    • InstancedMesh, BatchedMesh, frustum culling, LOD, draw call debugging.
  • Lighting & Soft Shadows: references/lighting-and-shadows.md
    • Directional light shadow camera frustum sizing, shadow bias & normalBias, PCFSoftShadowMap, HDR environment maps.
  • Materials & Custom Shaders: references/materials-and-shaders.md
    • MeshStandardMaterial vs MeshPhysicalMaterial, onBeforeCompile chunk injection, custom GLSL ShaderMaterial, shader warmup.
  • Asset Loading & GLTF Pipelines: references/asset-loading-and-draco.md
    • GLTFLoader, DRACOLoader, KTX2Loader, model bounding box normalization, animation mixers.
  • Cameras & Controls: references/cameras-and-controls.md
    • Smooth follow third-person camera (damped lerp/slerp), camera occlusion raycasting, resize handling.

Standard Boilerplate Template

For a clean, battle-tested setup with responsive resizing, tone mapping, and teardown support, refer to: 👉 examples/boilerplate-scene.js

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.