Skip to main content

Resource is the component form of useLoader — it loads a resource and drops it straight into the scene graph, or hands it to a render function.

Props

PropTypeDescription
loaderConstructor<Loader>The three.js loader class — TextureLoader, GLTFLoader, …
urlstring | string[] | Record<string, string>What to load, matching what the loader expects.
children(resource) => JSX.ElementOptional render function, receiving the loaded resource.
basestringBase URL for resolving relative paths (forwarded to useLoader).
cacheboolean | LoaderRegistrytrue (default global cache), false (disable), or a custom registry. See Caching.
onBeforeLoad(loader) => voidRuns with the loader before loading — e.g. to configure decoders.
onLoad(resource) => voidRuns with the resolved resource after loading.
other propsForwarded to the loaded resource — including attach.

Examples

// CubeTextureLoader expects an array of strings
<Resource
loader={CubeTextureLoader}
url={["px.png", "nx.png", "py.png", "ny.png", "pz.png", "nz.png"]}
/>
// Attach loaded textures into a material's slots
<T.MeshStandardMaterial>
<Resource loader={TextureLoader} url="diffuse.jpg" attach="map" />
<Resource loader={TextureLoader} url="normal.jpg" attach="normalMap" />
</T.MeshStandardMaterial>
// A render function for full control over the result
<Resource loader={GLTFLoader} url="model.gltf">
{gltf => <Entity from={gltf.scene} scale={2} />}
</Resource>
// Disable caching for a specific resource
<Resource loader={TextureLoader} url="/dynamic-texture.png" cache={false} />

See also

Last updated: 6/8/26, 11:20 AM

solid threeA SolidJS renderer for three.js — learn by reading.
Community
github