threejs-webgl

Provides performance optimization rules and best practices for Three.js WebGL and WebGPU applications.

Updated Aug 26, 2026
One-click install
npx skills add https://github.com/aungpwint/presentation --skill threejs-webgl-aungpwint
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: threejs-webgl
Source: https://github.com/aungpwint/presentation/tree/main/.agents/skills/threejs-webgl
Command: npx skills add https://github.com/aungpwint/presentation --skill threejs-webgl-aungpwint

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Three.js applications frequently suffer from memory leaks, excessive draw calls, and poor frame rates because developers miss critical optimization steps like geometry disposal, instancing, and texture compression. This Skill provides a prioritized rule set of 120+ guidelines so AI-assisted coding produces performant, leak-free 3D scenes. ## Core Features & Use Cases - Prioritized Optimization Rules: 120+ rules across 18 categories ranked by impact, covering memory disposal, render loops, draw calls, geometry, materials, lighting, and mobile optimization. - Modern Rendering Coverage: Guidance for WebGPURenderer, TSL (Three.js Shading Language), compute shaders, and GLSL shader best practices. - Production Readiness: Rules for asset compression (Draco, KTX2, Meshopt), Core Web Vitals, WebGL context loss recovery, debugging tools, and version migration checklists. - Use Case: When reviewing a React Three Fiber scene that leaks GPU memory on unmount, apply the memory-dispose rules to add recursive geometry, material, and texture disposal in cleanup functions. ## Quick Start Review my Three.js scene code and apply the critical memory management and draw call optimization rules to fix performance issues.

Frequently Asked Questions about threejs-webgl

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

FAQPage Schema
How do I optimize Three.js performance and reduce draw calls?▼

Target under 100 draw calls per frame by using InstancedMesh for identical objects, BatchedMesh for varied geometries sharing a material, and BufferGeometryUtils to merge static geometry. Monitor progress with renderer.info.render.calls.

How do I fix Three.js memory leaks when removing objects?▼

Three.js does not garbage collect GPU resources, so you must call dispose() on geometries, materials, and textures when removing objects. Use recursive disposal for hierarchies and dispose in React cleanup functions on unmount.

Should I use WebGLRenderer or WebGPURenderer in Three.js?▼

WebGLRenderer is the default with broad browser support, while WebGPURenderer enables TSL node materials and compute shaders for GPU-driven workloads. Import WebGPU features from three/webgpu and three/tsl in r170+.

What texture compression format works best for Three.js?▼

KTX2 with Basis transcoding keeps textures compressed in GPU memory, reducing VRAM usage dramatically compared to PNG. Use UASTC mode for quality-critical textures like normal maps and ETC1S for backgrounds.

Why does my Three.js app lose WebGL context and how do I recover?▼

Context loss typically comes from memory leaks, GPU overload, or mobile tab switching. Listen for webglcontextlost and webglcontextrestored events, prevent default on loss, then recreate resources and restart the render loop.

How do I optimize Three.js for mobile devices?▼

Limit pixel ratio to 1.5, cap textures at 1024px, disable antialiasing, prefer MeshBasicMaterial or MeshLambertMaterial over PBR materials, and avoid or bake shadows. Keep draw calls under 100 and use LOD for complex models.