r3f-loaders
enzed/r3f-skills
Load and reuse 3D assets in React Three Fiber with caching, cloning, and error handling.
What is r3f-loaders?
Provides patterns for loading glTF/GLB models and other 3D formats into React Three Fiber using useGLTF, useLoader, and Suspense. Use this skill when you need to load, cache, clone, or manage the lifecycle of 3D assets in a Fiber scene.
- Load glTF/GLB models and other 3D formats with useGLTF and useLoader hooks
- Clone and reuse cached 3D assets with separate transforms but shared geometry/materials
- Set up Suspense boundaries for coordinated or independent asset loading
- Configure decoders (Draco, Meshopt, KTX2) and handle decoder/loader lifecycle
- Implement error boundaries and retry strategies for failed asset loads
- Preload assets ahead of interaction without blocking initial render
How to install r3f-loaders
npx skills add https://github.com/enzed/r3f-skills --skill r3f-loaders- React Three Fiber 9+ and React 19+ (or verify your installed versions)
- Three.js and @react-three/drei installed
- 3D asset files (glTF/GLB or other formats) served from your application
How to use r3f-loaders
- 1.Verify your installed versions of Fiber, Drei, Three.js, and React
- 2.Use useGLTF for glTF/GLB assets or useLoader with the appropriate Three.js loader for other formats
- 3.Wrap asset-loading components in Suspense boundaries; use separate boundaries for independent loading
- 4.Clone cached assets using Drei Clone or SkeletonUtils.clone for repeated placement with separate transforms
- 5.Configure decoders (Draco, Meshopt, KTX2) before requests start, matching your asset compression and hosting policy
- 6.Implement error boundaries with explicit retry/remount strategies; avoid clearing caches during render
- 7.Test with actual compressed assets, network errors, and CORS to validate decoder and loader paths
Use cases
- Loading a robot model and rendering multiple clones with different positions in a scene
- Setting up Draco-compressed glTF assets with proper decoder configuration and caching
- Displaying loading UI with Suspense while assets decode and compile shaders
- Cloning a rigged character model with independent animation mixers using SkeletonUtils
- Handling network errors and CORS issues with explicit error boundaries and recovery
- React Three Fiber developers building 3D web applications
- Game and interactive experience developers using Fiber for asset-heavy scenes
- Developers managing memory and GPU resources in multi-asset scenes
r3f-loaders FAQ
Prefer useGLTF for glTF/GLB files. Use useLoader with the matching Three.js loader for other formats. Both hooks suspend, so wrap them in Suspense boundaries.
Use Drei Clone to duplicate the scene graph while sharing cached geometry, textures, and materials. For rigged models with independent animation, use SkeletonUtils.clone for explicit ownership.
Preloading starts a request early but does not guarantee instant display or shader compilation. Conditional loading mounts the component only when needed; do not call hooks conditionally or pass null as a URL.
Configure decoders (Draco, Meshopt, KTX2) before requests start, using the same settings for both preload and actual load. Avoid creating new decoder pools in every render or callback.
Use an error boundary with explicit retry/remount strategy. Suspense handles pending work, not errors. Test with actual network errors and CORS to validate decoder hosting and loader paths.
Full instructions (SKILL.md)
Source of truth, from enzed/r3f-skills.
name: r3f-loaders description: Load and reuse 3D assets in React Three Fiber with useGLTF, useLoader, Suspense, and preloading. Use for model loading, decoder setup, caching, cloning, or loading/error UI.
React Three Fiber loaders
Inspect installed Fiber, Drei, Three.js, and React versions first. Examples use Fiber 9 / React 19. Verify actual asset paths, node names, formats, and compression; do not invent a model's structure.
Load and reuse a model
Mount below Canvas. Supply /models/robot.glb in the application. These clones have separate object transforms but intentionally share cached geometry/materials.
import { Suspense } from 'react'
import { Clone, useGLTF } from '@react-three/drei'
function Models() {
const { scene } = useGLTF('/models/robot.glb')
return (
<group dispose={null}>
<Clone object={scene} position={[-1.2, 0, 0]} />
<Clone object={scene} position={[1.2, 0, 0]} />
</group>
)
}
export default function Example() {
return (
<Suspense fallback={null}>
<Models />
</Suspense>
)
}
Loading decisions
- Prefer
useGLTFfor glTF/GLB; useuseLoaderwith the matching Three.js loader for other formats. Fiber 9 also accepts an externally owned loader instance when configuration isolation is needed. - Loader hooks suspend. Put boundaries around assets that should reveal together; separate boundaries for independent loading. Preload likely-needed assets ahead of interaction, not the entire catalog.
- Preloading starts a request; it does not guarantee instantaneous display or GPU shader compilation. Asset decoding and first rendering can still cost time.
- Conditional loading means conditionally mounting a child component that calls the hook. Do not pass
nullas a pretend URL or call a hook conditionally. - Three.js addons use paths such as
three/addons/loaders/GLTFLoader.js. Check installed exports for renamed loaders; modern Three.js usesHDRLoaderwhere older examples usedRGBELoader. - Use gltfjsx with types when exposing named nodes/materials is useful, and inspect the generated result. For wrappers, use
ThreeElements['group'], not the removed global JSX type namespace.
Cache, clones, and lifetime
- Treat cached loader results as shared. Mounting one Object3D under two parents moves it between them; clone the graph for repeated placement.
- Drei Clone supports ordinary graph duplication and skeleton-aware cloning. For independent animation mixers, a stable
SkeletonUtils.cloneroot makes ownership explicit. - A graph clone normally shares geometry, textures, and materials. Clone the specific material/texture before per-instance edits; deep-cloning everything wastes memory.
- Prevent an individual consumer from disposing shared cached resources (
dispose={null}on the shared subtree). An application cache owner may release them only after all consumers are gone. - Primitives are not automatically disposed by R3F. Neither
useGLTF.clear(url)noruseLoader.clear(...)is a complete GPU cleanup operation. - Do not clear caches during render, and do not mutate a cached scene's transforms/materials as a local setup shortcut.
Decoders and failure paths
useGLTFintegrates Draco/Meshopt support, but decoder URLs and loader configuration must match the asset and hosting policy. For KTX2 textures, configure a KTX2Loader with renderer capability detection before loading.- Use the same loader/decoder settings for preload and actual load. Configure before requests start; later changes do not retroactively reparse an already cached result.
- Avoid creating a new decoder worker pool in every render or load callback. Give custom loader/decoder instances a deliberate owner and cleanup.
- Suspense handles pending work, not rejected requests. Use an error boundary with an explicit retry/remount strategy; cache eviction for retry belongs in a user action or controlled recovery path.
- Inside Canvas, use a Three.js fallback or Drei Html. Drei Loader is a DOM overlay and belongs outside Canvas.
useProgressreflects the loading manager's activity, not necessarily one asset's byte-accurate completion. Avoid treating an unavailable Content-Length as a trustworthy denominator.- Test network errors, CORS, decoder/transcoder hosting, and actual compressed assets. An uncompressed GLB smoke test does not validate every decoder path.
Sources
Related skills
More from enzed/r3f-skills and the wider catalog.

r3f-materials
Choose and configure React Three Fiber surface materials, PBR, transparency, and transmission.

r3f-physics
Add Rapier physics simulation to React Three Fiber with rigid bodies, colliders, forces, and joints.

r3f-postprocessing
Configure React Three Fiber postprocessing: bloom, selection effects, ambient occlusion, and depth of field.

r3f-shaders
Implement custom GLSL or TSL materials in React Three Fiber with uniforms and vertex deformation.

r3f-textures
Configure textures in React Three Fiber: color spaces, UV channels, sampling, video, and render targets.

bb-browser
Browser automation with login state for accessing public and private information across 36+ platforms.