threejs-3d
/threejs-3d
Build and optimize browser 3D scenes with Three.js, React Three Fiber, WebGPU or WebGL, TSL and glTF assets. Use when implementing cameras, materials, 3D interaction, model loading or renderer performance; preserve renderer compatibility and resource ownership.
- Author
- wrongstack ↗
- Repository
- wrongstack ↗
- Licence
- MIT
- Last repository change
- 27.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 2
No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Build and optimize browser 3D scenes with Three.js, React Three Fiber, WebGPU or WebGL, TSL and glTF assets. Use when implementing cameras, materials, 3D interaction, model loading or renderer performance; preserve renderer compatibility and resource ownership.
Original author description
Build and optimize browser 3D scenes with Three.js, React Three Fiber, WebGPU or WebGL, TSL and glTF assets. Use when implementing cameras, materials, 3D interaction, model loading or renderer performance; preserve renderer compatibility and resource ownership.
How it works
- Selection card
- Overview
- Rules
- Workflow
- Core Patterns & Pitfalls
- Sources
- Acceptance checks
- Skills in scope
SKILL.md preview
---
name: threejs-3d
description: "Build and optimize browser 3D scenes with Three.js, React Three Fiber, WebGPU or WebGL, TSL and glTF assets. Use when implementing cameras, materials, 3D interaction, model loading or renderer performance; preserve renderer compatibility and resource ownership."
version: 1.2.2
required-capabilities: [filesystem.read, filesystem.write]
required-tools: []
optional-capabilities: [verification.run, web.research]
trigger: "implementing cameras, materials, 3D interaction, model loading or renderer performance; preserve renderer compatibility and resource ownership."
metadata:
routing-group: media
paths: ["*.{glsl,wgsl,vert,frag}"]
---
# Three.js and Browser 3D
## Selection card
- Task: Build interactive Three.js 3D rendering and shaders.
- Start: Identify the existing engine, scene, timeline and delivery format.
- Finish: apply the acceptance checks below; report observed results and unresolved constraints.
## Overview
Latest stable targets checked 2026-10-23: Three.js 0.186.1 (r186),
@types/three 0.186.0, React Three Fiber 9.8.2 and Drei 10.7.9 with React 19.3.1.
Refresh these together before installation and check peer ranges.
## Rules
1. Choose the renderer from deployment requirements, materials and postprocessing.
WebGPURenderer is a modern option with WebGL2 fallback; backend fallback does
not guarantee every shader, compute feature or plugin behaves identically.
2. For WebGPU use the matching three/webgpu and three/tsl APIs. Initialize the
renderer before rendering; keep supported WebGL paths when integration needs them.
3. Bound pixel ratio, shadow cost, render targets, texture sizes and geometry.
Use frame/draw-call measurements, not a universal mesh-count threshold.
4. Keep allocations and React setState out of per-frame hot loops. Mutate owned
scene refs for frame updates and use delta for frame-rate independent movement.
5. Dispose only resources the component owns. Cached glTF textures/materials may
be shared across mounts; blindly disposing them breaks the remaining users.
6. Provide loading/error states and a useful non-canvas fallback. Preserve keyboard
and pointer alternatives where the scene implements a user task.
## Workflow
1. Inspect browser targets, renderer and asset pipeline. Start with a simple lit
scene and camera controls; validate the actual target browser before complex shaders.
2. Load assets with bounded error handling. In R3F, use Suspense around loading
boundaries and inspect cache/disposal ownership.
3. Profile instancing, merging, compressed textures and geometry codecs against
visual quality and download/decoder cost. Compress only where it helps.
4. Test resize, DPR changes, background tabs, repeated mounts, loading failure and
context/device loss where supported.
5. Record cold-load size/time, frame performance and resource counts after repeated
mount/unmount. Distinguish source correctness from rendered verification.
## Core Patterns & Pitfalls
- **Zero-Allocation Render Loop (`useFrame` / `requestAnimationFrame`)**: Pre-allocate scratch math objects (`const _vec3 = new THREE.Vector3()`, `Matrix4`, `Quaternion`) outside the frame loop and mutate refs directly (`meshRef.current.rotation.y += delta`); never call React `setState` or `new THREE.Vector3()` every frame.
- **Draw-Call & GPU Memory Budgeting**: Cap canvas DPR (`dpr={[1, 2]}`), prefer `THREE.InstancedMesh` or `<Instances>` for repeated geometry, match color spaces (`SRGBColorSpace` for color textures, `NoColorSpace` for normal/roughness/metalness maps), and verify `renderer.info.memory` (`geometries`, `textures`) returns to baseline after unmount.
- **Anti-pattern — Disposing Shared `useGLTF` Assets**: Calling `.dispose()` on geometries or materials returned directly from a shared `useGLTF` cache breaks every other mounted or future instance of that model unless the resource was explicitly cloned for local ownership.
## Sources
[WebGPURenderer](https://threejs.org/docs/pages/WebGPURenderer.html),
[R3F performance pitfalls](https://r3f.docs.pmnd.rs/advanced/pitfalls).
## Acceptance checks
- [ ] Three.js, `@types/three`, `@react-three/fiber`, and `@react-three/drei` peer versions aligned
- [ ] Per-frame loops (`useFrame`) free of React state updates and heap object allocations
- [ ] Owned geometries, materials, render targets, and event listeners disposed cleanly across mount/unmount cycles
- [ ] DPR bounded (`[1, 2]`), Suspense/error fallbacks provided, and keyboard/reduced-motion alternatives preserved
## Skills in scope
- react-modern — React 19 Suspense boundaries, ref lifecycle cleanup, and state coordination outside the canvas.
- motion-design — coordinating DOM overlay transitions and scroll progress with 3D camera/scene states.
- web-performance — glTF/KTX2 asset payload sizing, main-thread shader compile stalls, and frame pacing.
- accessibility — `prefers-reduced-motion` camera stabilization and keyboard/DOM equivalents for 3D interactions.
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · wrongstack/wrongstack | 90 | MIT |
| krishna-modi12/frontend-design-pro | 100 | MIT |
Database snapshot: 13.11.2026 · package version 802f597c6209 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 2 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100threejs
Three.js is a JavaScript library for building interactive 3D graphics in the browser with WebGL and WebGPU. Use it for 3D product configurators, data visualizations, games and creative sites: scenes, cameras, lighting, glTF model loading, performance tuning, and React Three… - 100threejs-react-three-fiber
Building three.js scenes from React with React Three Fiber and drei: renderer setup, the scene graph as JSX, frame-loop, state and loading hooks, pointer events, and adaptive performance, on WebGL or with WebGPU and TSL. Use when writing React components that render three.js. - 95web3d-webgl
Use this skill when the user says 'Three.js', 'React Three Fiber', 'R3F', 'drei', '3D in the browser', 'GLTF model loading', 'product configurator 3D', 'WebGL scene performance', 'three.js memory leak'. It builds and optimises Three.js / React Three Fiber scenes: renderer setup,… - 95threejs-performance
Three.js 性能优化指南。当 Three.js/React Three Fiber 项目出现掉帧、内存增长、加载缓慢、绘制调用过多,或需要迁移 WebGPU、实现大规模粒子/实例化渲染、配置资源压缩管线时使用。触发关键词:"Three.js 优化"、"WebGPU"、"draw calls"、"内存泄漏"、"TSL"、"InstancedMesh"、"R3F 优化"等。不用于:通用 React 性能问题(用 vercel-react-best-practices)、WebGL/Three.js 入门教学、3D 美术资产的制作本身。 - 90threejs-guide
Use when building or editing 3D scenes in vanilla Three.js for WebGL/WebGPU. Triggers on `.js`/`.ts` files with `three` or `three/*` imports, and on prompts about Scene, Renderer, Mesh, BufferGeometry, materials, lighting, GLTF loaders, raycasting, shaders, post-processing,… - 100game-threejs-specialist
Builds 3D browser games with Three.js or React Three Fiber on WebGL 2 and WebGPU: stack choice (vanilla, R3F, Babylon.js, PlayCanvas), Rapier physics, glTF/KTX2 pipelines, mobile budgets, Playwright checks, and fixes for outdated agent-written Three.js. Use for "three.js",…