threejs-performance
Agent skill fromCloudAI-X/threejs-skills
Measuring and optimizing three.js speed: render statistics, memory counters, fewer draw calls via merging, instancing, batching and LOD, fill rate, shadows, CPU work per frame, shader stalls and GPU compute for particles, WebGL or WebGPU with TSL. Use when a scene is slow, janks or exceeds memory.
How to install threejs-performance
install threejs-performance
# install the threejs-skills pack with the skills CLI
npx skills add CloudAI-X/threejs-skills# or add only this skill to Claude Code: copy the folder
skills/threejs-performance/
# into
~/.claude/skills/threejs-performance/ (all projects)
.claude/skills/threejs-performance/ (one project)
1# Three.js Performance23Targets three.js r186. Examples use WebGLRenderer; the WebGPU and TSL section uses WebGPURenderer.45## Quick Start67```javascript8import * as THREE from "three";910const renderer = new THREE.WebGLRenderer({ antialias: true });11renderer.setPixelRatio(window.devicePixelRatio);12renderer.setSize(window.innerWidth, window.innerHeight);13document.body.appendChild(renderer.domElement);1415const scene = new THREE.Scene();16scene.add(new THREE.HemisphereLight(0xffffff, 0x445566, 1));17const sun = new THREE.DirectionalLight(0xffffff, 2);18sun.position.set(3, 6, 4);19scene.add(sun);2021const camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 100);22camera.position.set(0, 2, 8);2324const mesh = new THREE.Mesh(new THREE.SphereGeometry(1, 32, 16), new THREE.MeshStandardMaterial({ color: 0x4488ff }));25scene.add(mesh);2627function animate() {28 mesh.rotation.y += 0.01;29 renderer.render(scene, camera);30 // the counters reset at the start of every render() call, so these cover the frame just drawn31 console.log(`${renderer.info.render.calls} calls, ${renderer.info.render.triangles} triangles, ${renderer.info.memory.textures} textures`);32}3334renderer.setAnimationLoop(animate);35```3637## Measure First3839Optimize what the numbers name, not what a hunch suspects. WebGLRenderer's `renderer.info` object is read after `render()`:4041```javascript42function animate() {43 renderer.render(scene, camera);44 console.table({45…
Excerpt shown under the repository's MIT license.
