Neversight skills feed three best practices 1.0.2
Skill VRIL-LABS/skill-jam/skills/web-frontend/neversight-skills_feed-three-best-practices-1.0.2
Three.js performance optimization and best practices guidelines. Use when writing, reviewing, or optimizing Three.js code. Triggers on tasks involving 3D scenes, WebGL/WebGPU rendering, geometries, materials, textures, lighting, shaders, or TSL.From its SKILL.md
npx -y skills add VRIL-LABS/skill-jam --skill neversight-skills_feed-three-best-practices-1.0.2Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
9.5 KB, ~2.5k tokens by cl100k_base, as published. Nobody here has run it
Three.js Best Practices
Comprehensive performance optimization guide for Three.js applications. Contains 100+ rules across 17 categories, prioritized by impact.
Based on official guidelines from Three.js
llmsbranch maintained by mrdoob.
When to Apply
Reference these guidelines when:
- Setting up a new Three.js project
- Writing or reviewing Three.js code
- Optimizing performance or fixing memory leaks
- Working with custom shaders (GLSL or TSL)
- Implementing WebGPU features
- Building VR/AR experiences with WebXR
- Integrating physics engines
- Optimizing for mobile devices
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 0 | Modern Setup & Imports | FUNDAMENTAL | setup- |
| 1 | Memory Management & Dispose | CRITICAL | memory- |
| 2 | Render Loop Optimization | CRITICAL | render- |
| 3 | Geometry & Buffer Management | HIGH | geometry- |
| 4 | Material & Texture Optimization | HIGH | material- |
| 5 | Lighting & Shadows | MEDIUM-HIGH | lighting- |
| 6 | Scene Graph Organization | MEDIUM | scene- |
| 7 | Shader Best Practices (GLSL) | MEDIUM | shader- |
| 8 | TSL (Three.js Shading Language) | MEDIUM | tsl- |
| 9 | Loading & Assets | MEDIUM | loading- |
| 10 | Camera & Controls | LOW-MEDIUM | camera- |
| 11 | Animation System | MEDIUM | animation- |
| 12 | Physics Integration | MEDIUM | physics- |
| 13 | WebXR / VR / AR | MEDIUM | webxr- |
| 14 | Audio | LOW-MEDIUM | audio- |
| 15 | Mobile Optimization | HIGH | mobile- |
| 16 | Production | HIGH | error-, migration- |
| 17 | Debug & DevTools | LOW | debug- |
Quick Reference
0. Modern Setup (FUNDAMENTAL)
setup-use-import-maps- Use Import Maps, not old CDN scriptssetup-choose-renderer- WebGLRenderer (default) vs WebGPURenderer (TSL/compute)setup-animation-loop- Userenderer.setAnimationLoop()not manual RAFsetup-basic-scene-template- Complete modern scene template
1. Memory Management (CRITICAL)
memory-dispose-geometry- Always dispose geometriesmemory-dispose-material- Always dispose materials and texturesmemory-dispose-textures- Dispose dynamically created texturesmemory-dispose-render-targets- Always dispose WebGLRenderTargetmemory-dispose-recursive- Use recursive disposal for hierarchiesmemory-dispose-on-unmount- Dispose in React cleanup/unmountmemory-renderer-dispose- Dispose renderer when destroying viewmemory-reuse-objects- Reuse geometries and materials
2. Render Loop (CRITICAL)
render-single-raf- Single requestAnimationFrame looprender-conditional- Render on demand for static scenesrender-delta-time- Use delta time for animationsrender-avoid-allocations- Never allocate in render looprender-cache-computations- Cache expensive computationsrender-frustum-culling- Enable frustum cullingrender-update-matrix-manual- Disable auto matrix updates for static objectsrender-pixel-ratio- Limit pixel ratio to 2render-antialias-wisely- Use antialiasing judiciously
3. Geometry (HIGH)
geometry-buffer-geometry- Always use BufferGeometrygeometry-merge-static- Merge static geometriesgeometry-instanced-mesh- Use InstancedMesh for identical objectsgeometry-lod- Use Level of Detail for complex modelsgeometry-index-buffer- Use indexed geometrygeometry-vertex-count- Minimize vertex countgeometry-attributes-typed- Use appropriate typed arraysgeometry-interleaved- Consider interleaved buffers
4. Materials & Textures (HIGH)
material-reuse- Reuse materials across meshesmaterial-simplest-sufficient- Use simplest material that worksmaterial-texture-size-power-of-two- Power-of-two texture dimensionsmaterial-texture-compression- Use compressed textures (KTX2/Basis)material-texture-mipmaps- Enable mipmaps appropriatelymaterial-texture-anisotropy- Use anisotropic filtering for floorsmaterial-texture-atlas- Use texture atlasesmaterial-avoid-transparency- Minimize transparent materialsmaterial-onbeforecompile- Use onBeforeCompile for shader mods (or TSL)
5. Lighting & Shadows (MEDIUM-HIGH)
lighting-limit-lights- Minimize dynamic lightslighting-bake-static- Bake lighting for static sceneslighting-shadow-camera-tight- Fit shadow camera tightlylighting-shadow-map-size- Choose appropriate shadow resolutionlighting-shadow-selective- Enable shadows selectivelylighting-shadow-cascade- Use CSM for large sceneslighting-probe- Use Light Probes
6. Scene Graph (MEDIUM)
scene-group-objects- Use Groups for organizationscene-layers- Use Layers for selective renderingscene-visible-toggle- Use visible flag, not add/removescene-flatten-static- Flatten static hierarchiesscene-name-objects- Name objects for debuggingscene-object-pooling- Use object pooling
7. Shaders GLSL (MEDIUM)
shader-precision- Use appropriate precisionshader-avoid-branching- Minimize branchingshader-precompute-cpu- Precompute on CPUshader-avoid-discard- Avoid discard, use alphaTestshader-texture-lod- Use textureLod for known mip levelsshader-uniform-arrays- Prefer uniform arraysshader-varying-interpolation- Use flat when appropriateshader-chunk-injection- Use Three.js shader chunks
8. TSL - Three.js Shading Language (MEDIUM)
tsl-why-use- Use TSL instead of onBeforeCompiletsl-setup-webgpu- WebGPU setup for TSLtsl-complete-reference- Full TSL type system and functionstsl-material-slots- Material node properties referencetsl-node-materials- Use NodeMaterial classestsl-basic-operations- Types, operations, swizzlingtsl-functions- Creating TSL functions with Fn()tsl-conditionals- If, select, loops in TSLtsl-textures- Textures and triplanar mappingtsl-post-processing- bloom, blur, dof, aotsl-compute-shaders- GPGPU and compute operationstsl-glsl-to-tsl- GLSL to TSL translation
9. Loading & Assets (MEDIUM)
loading-draco-compression- Use Draco for large meshesloading-gltf-preferred- Use glTF formatgltf-loading-optimization- Full loader setup with DRACO/Meshopt/KTX2loading-progress-feedback- Show loading progressloading-async-await- Use async/await for loadingloading-lazy- Lazy load non-critical assetsloading-cache-assets- Enable cachingloading-dispose-unused- Unload unused assets
10. Camera & Controls (LOW-MEDIUM)
camera-near-far- Set tight near/far planescamera-fov- Choose appropriate FOVcamera-controls-damping- Use damping for smooth controlscamera-resize-handler- Handle resize properlycamera-orbit-limits- Set orbit control limits
11. Animation (MEDIUM)
animation-system- AnimationMixer, blending, morph targets, skeletal
12. Physics (MEDIUM)
physics-integration- Rapier, Cannon-es integration patterns
13. WebXR (MEDIUM)
webxr-setup- VR/AR buttons, controllers, hit testing
14. Audio (LOW-MEDIUM)
audio-spatial- PositionalAudio, HRTF, spatial sound
15. Optimization (HIGH)
mobile-optimization- Mobile-specific optimizations and checklistraycasting-optimization- BVH, layers, GPU picking
16. Production (HIGH)
error-handling-recovery- WebGL context loss and recoverymigration-checklist- Breaking changes by version
17. Debug (LOW)
debug-stats- Use Stats.jsdebug-helpers- Use built-in helpersdebug-gui- Use lil-gui for tweakingdebug-renderer-info- Check renderer.infodebug-conditional- Remove debug code in production
How to Use
Read individual rule files for detailed explanations and code examples:
rules/setup-use-import-maps.md
rules/memory-dispose-geometry.md
rules/tsl-complete-reference.md
rules/mobile-optimization.md
Each rule file contains:
- Brief explanation of why it matters
- BAD code example with explanation
- GOOD code example with explanation
- Additional context and references
Key Patterns
Modern Import Maps
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/",
"three/tsl": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.tsl.js"
}
}
</script>
Proper Disposal
function disposeObject(obj) {
if (obj.geometry) obj.geometry.dispose();
if (obj.material) {
if (Array.isArray(obj.material)) {
obj.material.forEach(m => m.dispose());
} else {
obj.material.dispose();
}
}
}
TSL Basic Usage
import { texture, uv, color, time, sin } from 'three/tsl';
const material = new THREE.MeshStandardNodeMaterial();
material.colorNode = texture(map).mul(color(0xff0000));
material.colorNode = color(0x00ff00).mul(sin(time).mul(0.5).add(0.5));
Mobile Detection
const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, isMobile ? 1.5 : 2));
What ships with it: 11 files
3.4 KB alongside SKILL.md
- description_ar.txt421 B
- description_cn.txt213 B
- description_de.txt291 B
- description_en.txt246 B
- description_es.txt271 B
- description_fr.txt351 B
- description_it.txt304 B
- description_ja.txt391 B
- description_ko.txt261 B
- description_ru.txt513 B
- description_tw.txt213 B