ankyr-threejs

Enforces React Three Fiber render-loop performance, typed materials, and GPU resource disposal rules.

1|Updated May 21, 2026
One-click install
npx skills add https://github.com/GuyErreich/AI_Agents --skill ankyr-threejs-guyerreich
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ankyr-threejs
Source: https://github.com/GuyErreich/AI_Agents/tree/main/plugins/ankyr-web/skills/ankyr-threejs
Command: npx skills add https://github.com/GuyErreich/AI_Agents --skill ankyr-threejs-guyerreich

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @react-three/fiber, @react-three/drei, three, and includes references (resource) and assets (resource) components.

What problem does it solve? React Three Fiber and Three.js components commonly suffer from GC stutter caused by per-frame allocations, unnecessary React re-renders inside animation loops, untyped material access, and GPU memory leaks from undisposed geometries, materials, and textures. ## Core Features & Use Cases - Render-loop performance rules: Prohibits object allocation inside useFrame, mandates mutation of uniforms and refs instead of per-frame setState, and recommends InstancedMesh for many identical geometries. - Typed materials and shader uniforms: Enforces narrowing mesh.material to concrete classes like THREE.ShaderMaterial before uniform access, and stable uniform objects defined via useMemo. - Resource disposal and scaffolding: Provides disposal checklists for geometries, materials, and textures, plus a TypeScript R3F component template in assets/. - Use Case: When writing or reviewing a WebGL scene component, load the matching reference (lifecycle, disposal, or shaders) to verify the component avoids per-frame allocation and disposes all GPU resources on unmount. ## Quick Start Ask the AI to review your React Three Fiber component for render-loop allocations, material typing, and missing disposal cleanup.

Frequently Asked Questions about ankyr-threejs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid performance issues in React Three Fiber useFrame loops?▼

Never allocate objects like Vector3, Color, or geometries inside useFrame; allocate once via useMemo or useRef and reuse them. Mutate material uniforms and ref values directly instead of calling setState, which re-renders every frame.

How to type shader material uniforms in TypeScript with R3F?▼

Narrow mesh.material to the concrete class, for example `meshRef.current.material as THREE.ShaderMaterial`, before accessing uniforms. Define the uniforms object once with useMemo so its reference stays stable, then mutate `.value` inside the loop.

Does Three.js require manual disposal of geometries and materials?▼

Yes, geometries, materials, and textures hold GPU memory and must be disposed in the component's cleanup function. Meshes should also be removed from their parent on unmount to avoid leaks.

When should I use InstancedMesh in Three.js scenes?▼

Use THREE.InstancedMesh when rendering many identical geometries such as stars, dust, or particles. Update per-instance transforms with a reusable dummy object and setMatrixAt, then set instanceMatrix.needsUpdate to true.

Why does my R3F animation stutter after a few seconds?▼

Stutter usually comes from allocating new objects every frame inside useFrame, which triggers frequent garbage collection. Move allocations outside the loop with useMemo and reuse the same instances across frames.