Skip to main content
skill CX Codex

threejs · oakoss — Claude Code skill: what it does, how to install

This skill guides agents through Three.js scenes, WebGPU rendering, TSL shaders, and React Three Fiber. Use it when building 3D features for React or Next.js.

MIT 167 installs ★ 29 updated 2026-08-17

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add oakoss/agent-skills --skill threejs -a claude-code
Open on GitHub

What threejs does

The skill covers scene structure, WebGPU setup, TSL shader work, and React Three Fiber patterns. It also addresses React 19 and Next.js integration, GLTF model loading, lighting, shadows, and animation.

For WebGPU, initialize the renderer with await renderer.init() before the first render; skipping that step can cause a race. The guidance also covers asset compression, level of detail, and reducing draw calls. In React projects, use R3F’s useFrame for frame updates rather than a manually managed requestAnimationFrame.

What it helps with

  • build a 3D scene with Three.js
  • configure a WebGPU renderer
  • write a shader with TSL
  • load and optimize a GLTF model
  • integrate Three.js with React Three Fiber and Next.js

Example prompts for the agent

  • Build a Three.js scene with lighting and shadows.
  • Set up WebGPU rendering and initialize the renderer before the first frame.
  • Load a GLTF model with GLTFLoader and add animation using AnimationMixer.

How to install threejs

1Skills CLI (Vercel)

npx skills add oakoss/agent-skills --skill threejs -a claude-code

2Manually: put the files in place

~/.claude/skills/threejs/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/threejs/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about threejs

How do I install threejs in Claude Code?

Run npx skills add oakoss/agent-skills --skill threejs -a claude-code. The skill file is at ~/.claude/skills/threejs/SKILL.md.

What does the threejs skill do?

It guides an agent in creating Three.js scenes and working with WebGPU, TSL, and React Three Fiber. Its guidance also covers model loading, animation, and asset optimization.

What should I do before rendering with WebGPU?

Wait for await renderer.init() to finish before the first render. Skipping initialization can cause a race.

Source text

SKILL.md · MIT
---
name: threejs
description: 'Builds 3D web experiences with Three.js, WebGPU rendering, TSL shaders, and React Three Fiber. Covers scene setup, asset optimization, performance tuning, and React 19 integration. Use when creating 3D scenes, setting up WebGPU rendering, writing TSL shaders, optimizing draw calls, or integrating Three.js with React and Next.js.'
license: MIT
metadata:
  author: oakoss
  version: '1.1'
  source: 'https://threejs.org/docs'
user-invocable: false
---

# Three.js

## Overview

Guides building high-performance 3D web experiences with Three.js, WebGPU-first rendering, TSL (Three Shader Language), and React Three Fiber. Covers scene architecture, asset compression, draw call budgets, and React 19 / Next.js integration patterns.

**When to use:** Creating 3D scenes, WebGPU rendering setup, TSL shader authoring, asset optimization (Draco/KTX2), React Three Fiber composition, Next.js streaming for 3D content, loading GLTF models, setting up lighting and shadows, animation playback and blending.

**When NOT to use:** 2D canvas animations (use Canvas API), simple SVG graphics, server-side rendering without client hydration, projects targeting pre-2022 hardware exclusively.

## Quick Reference

| Pattern           | API / Approach                                     | Key Points                                             |
| ----------------- | -------------------------------------------------- | ------------------------------------------------------ |
| WebGPU renderer   | `import * as THREE from 'three/webgpu'`            | Must `await renderer.init()` before first render       |
| R3F canvas        | `<Canvas gl={...}>` with Suspense                  | Wrap in `<Suspense>` for streaming support             |
| Frame updates     | `useFrame((state, delta) => ...)`                  | Mutate refs directly; never use `setState`             |
| TSL shaders       | `import { ... } from 'three/tsl'`                  | Node-based; compiles to WGSL or GLSL                   |
| Instancing        | `<instancedMesh>` with matrix updates              | Single draw call for repeated geometry                 |
| Batched mesh      | `BatchedMesh` (r156+)                              | Different geometries sharing one material              |
| Draco compression | `gltf-pipeline -i in.gltf -o out.glb -d`           | Up to 90% geometry size reduction                      |
| KTX2 textures     | Basis Universal via `toktx`                        | Stays compressed in VRAM                               |
| LOD               | `THREE.LOD` with distance thresholds               | Swap detail levels by camera distance                  |
| On-demand render  | `<Canvas frameloop="demand">`                      | Only render when scene state changes                   |
| Cleanup           | `.dispose()` on unmount                            | Geometries, materials, and textures                    |
| Compute shaders   | `Fn(() => {...})().compute(count)`                 | GPU-side physics, particles, flocking                  |
| Lighting          | `DirectionalLight`, `SpotLight`, `HemisphereLight` | Enable `shadowMap` on renderer + `castShadow` on light |
| GLTF loading      | `GLTFLoader` + `DRACOLoader`                       | Draco for geometry compression; traverse for shadows   |
| Animation         | `AnimationMixer` + `clipAction()`                  | Update with `clock.getDelta()` every frame             |
| Crossfade         | `action.fadeOut()` / `action.fadeIn()`             | Weight-based blending between walk/run/idle            |
| Environment maps  | `RGBELoader` + `PMREMGenerator`                    | Set `scene.environment` for PBR reflections            |
| Raycasting        | `Raycaster.setFromCamera(pointer, cam)`            | Mouse/touch picking; use `recursive: true` for GLTF    |
| Morph targets     | `mesh.morphTargetInfluences[index]`                | Facial animation, blend shapes from GLTF               |

## Common Mistakes

| Mistake                                                                   | Correct Pattern                                                                 |
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| Allocating `new THREE.Vector3()` or `new THREE.Color()` inside `useFrame` | Pre-allocate outside the loop to avoid GC pressure every frame                  |
| Using `requestAnimationFrame` manually in React projects                  | Use R3F's `useFrame` hook for frame-by-frame updates                            |
| Not awaiting `renderer.init()` for WebGPU                                 | Always `await renderer.init()` before the first render to avoid race conditions |
| Loading assets without `<Suspense>` boundaries                            | Wrap `<Canvas>` in `<Suspense>` to prevent main thread blocking                 |
| Using high-poly models for background or distant elements                 | Use LOD (Level of Detail) or Impostors to reduce draw calls                     |
| Using `setState` inside render loop for animations                        | Mutate refs directly via `useFrame` for frame-by-frame updates                  |
| Speed tied to frame rate (`rotation += 0.01`)                             | Multiply by `delta` for frame-rate-independent motion                           |
| Not using `clock.getDelta()` for `mixer.update()`                         | Always pass delta time to `mixer.update(delta)` for correct animation speed     |
| Forgetting to dispose loaded GLTF models                                  | Traverse and dispose geometries, materials, and textures on removal             |
| Shadow map enabled on renderer but not on the light                       | Set both `renderer.shadowMap.enabled` and `light.castShadow = true`             |
| Large `far/near` ratio on camera                                          | Keep ratio small to avoid z-fighting; set `near` as large as possible           |

## Delegation

- **Asset and scene graph exploration**: Use `Explore` agent
- **Multi-file scene refactoring and optimization passes**: Use `Task` agent
- **3D architecture and rendering pipeline planning**: Use `Plan` agent

## References

- [Scene, lighting, and model loading](references/scene-and-lighting.md)
- [Animation system and blending](references/animation.md)
- [Performance and asset optimization](references/performance.md)
- [WebGPU and TSL shader patterns](references/webgpu-tsl.md)
- [React Three Fiber patterns and Next.js integration](references/r3f-patterns.md)

© oakoss · MIT · oakoss/agent-skills

Similar skills

All skills for Game dev and 3D: Unity, Unreal, Godot, Blender →

threejs by other authors comes first.

threejs nexu-io Guides the agent in building browser 3D scenes, materials, interactive controls, and post-processing with Three.js. CX Codex +1 3,600installs threejs MengTo Guides your agent through building and debugging interactive Three.js scenes: scene, camera, lights, glTF loading, controls and performance. CX Codex +1 2,500installs threejs mrgoonie A coding-agent skill that walks you through Three.js scenes, shaders and VR work. Useful when a project needs WebGL or WebGPU and you want the agent to know the API. CX Codex +1 1,300installs threejs secondsky A skill with reference files and working examples for Three.js: scenes, materials, lighting, shaders, GLTF loading. Useful when you build 3D in the browser. CX Codex +1 501installs threejs benchflow-ai This skill maps Three.js scene groups to parts, then prepares per-part OBJ files or URDF links. Use it when a scene needs structured geometry export. CX Codex +1 8installs threejs-animation CloudAI-X threejs-animation — a skill for keyframe, skeletal and morph-target animation in Three.js. Play glTF animations, control bones, blend and crossfade clips on WebGL and WebGPU. CX Codex +1 27,200installs threejs-fundamentals CloudAI-X threejs-fundamentals sets up Three.js r186 scenes, cameras, renderers, and animation loops for WebGL or WebGPU with TSL. CX Codex +1 24,100installs threejs-gltf-loading gamedev-skills threejs-gltf-loading — a Claude Code skill for loading glTF and GLB 3D models into three.js r187 and playing animations. The agent uses this skill when importing assets or fixing invisible meshes. CX Codex +1 11,200installs threejs-webgl freshtechbro threejs-webgl configures coding agents to build Three.js scenes, set up WebGL or WebGPU renderers, adjust lighting, and load glTF models for web 3D apps. CX Codex +1 5,300installs threejs-game-ui-designer majidmanzarpour threejs-game-ui-designer — a skill for designing game UIs in Three.js: HUDs, menus, pause and win screens, responsive layout for mobile and desktop. Prevents overlaps, ensures readability, and keeps UI cohesive with game style. CX Codex +1 4,400installs threejs-gameplay-systems majidmanzarpour threejs-gameplay-systems is a Claude Code skill that scaffolds Three.js browser games with Vite and TypeScript. It handles core loops, input, camera motion, and Rapier physics. CX Codex +1 4,400installs

From the same set106

The whole set →

Project sponsors

Companies that keep this analytics open