threejs-errors-rendering

Diagnose and fix Three.js rendering errors including black screens, invisible objects, and z-fighting.

1|Updated Aug 20, 2023
One-click install
npx skills add https://github.com/imanlangaran/mini-projects --skill threejs-errors-rendering-imanlangaran
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: threejs-errors-rendering
Source: https://github.com/imanlangaran/mini-projects/tree/main/react/three-gsap/.claude/skills/threejs-errors-rendering
Command: npx skills add https://github.com/imanlangaran/mini-projects --skill threejs-errors-rendering-imanlangaran

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Three.js scenes often fail silently: black screens, invisible meshes, washed-out colors, flickering surfaces, or broken shadows. This Skill provides a systematic diagnostic workflow that maps each visual symptom to its root causes and verified fix patterns, preventing common mistakes like wrong color space settings, missing updateProjectionMatrix calls, or forgotten needsUpdate flags. ## Core Features & Use Cases - Symptom-Based Diagnosis: Covers nine symptom categories including black screens, invisible objects, wrong colors, z-fighting, shadow artifacts, WebGL context loss, stale buffers, projection matrix errors, and transparency sorting issues. - Fix Patterns with Code: Each cause includes concrete JavaScript fixes, such as setting SRGBColorSpace on color textures, using polygonOffset for z-fighting, and alphaTest instead of transparent for hard-edge alpha. - Anti-Pattern Reference: Documents nine common mistakes like setting near to 0, applying SRGBColorSpace to normal maps, or calling material.needsUpdate every frame. - Use Case: Your Three.js model loads but the screen stays black. Follow the debugging checklist to verify renderer size, camera position, lighting, and the render loop, then apply the matching fix. ## Quick Start Ask the assistant to diagnose why your Three.js scene shows a black screen or why a loaded model is not appearing.

Frequently Asked Questions about threejs-errors-rendering

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

FAQPage Schema
Why is my Three.js scene showing a black screen?

A black screen in Three.js usually means the renderer has zero size, the camera is inside the object or facing away, no light exists for lit materials, or renderer.render() is never called. Check the browser console, verify canvas dimensions, and confirm the animation loop is started.

How do I fix invisible objects in Three.js?

Invisible objects in Three.js are commonly caused by back-face culling, opacity set without transparent: true, layer mismatches between camera and object, or a hidden parent. Set material.side to THREE.DoubleSide for thin geometry and check the full parent chain for visible = false.

Why are my Three.js texture colors washed out or over-saturated?

Washed-out or over-saturated colors indicate a color space mismatch. Set texture.colorSpace to THREE.SRGBColorSpace for color and diffuse textures, but leave normal, roughness, and metalness maps in linear space. Also configure renderer tone mapping such as ACESFilmicToneMapping.

How do I fix z-fighting flickering surfaces in Three.js?

Z-fighting is fixed by enabling polygonOffset on one material, adding a small position offset between overlapping surfaces, or reducing the camera near/far ratio. Keep the near plane as large as possible and call camera.updateProjectionMatrix() after changes.

Does Three.js recover from WebGL context loss automatically?

No, Three.js does not recover from WebGL context loss automatically. You must add a webglcontextlost listener that calls event.preventDefault() and a webglcontextrestored listener that re-initializes materials, textures, and the render loop.

When should I use alphaTest instead of transparent in Three.js?

Use alphaTest instead of transparent: true for hard-edge alpha textures like foliage and fences. Alpha blending requires back-to-front sorting that fails with many overlapping planes, while alphaTest discards fragments below a threshold without sorting.