fec-canvas-threejs
Installation
SKILL.md
Canvas and Three.js
Purpose
Enable high-performance 2D/3D graphics rendering in the browser.
Procedure
- First select the rendering layer: DOM for standard UI; Canvas 2D for simple 2D graphics/signatures/particles; Three.js/WebGL for 3D models, spatial interactions and complex particles; React Three Fiber for declarative 3D in React projects.
- Define stable size, DPI adaptation, and resize behavior for the render container; Canvas does not automatically scale cleanly with CSS.
- The animation loop uses
requestAnimationFrame, which is paused when it is invisible or has no changes, and canceled when it is uninstalled. - Three.js must release geometry/material/texture/renderer and remove event listeners and observers.
- Shader/WebGL tasks first identify whether it is an SDF, ray marching, noise, particle, post-processing, multipass or debugging issue, and then decide whether native WebGL2, Three.js ShaderMaterial or R3F is required.
- Check the GLSL version, entry function, varying/in-out, texture API, uniform usage and function declaration order when adapting to WebGL2 to avoid white screen leaving only console errors.
- Provide
aria-label, alternative text or DOM summary for inaccessible graphic content; interactive graphics must have keyboard support.