useLoader
Generic resource loader that wraps any Three.js Loader and returns reactive loading state.
Usage
ts
import { useLoader } from '@threeuse/core'
import { GLTFLoader } from 'three/addons'
const { result, isLoading, error, load } = useLoader(GLTFLoader)
await load('/models/character.glb')
// result.value -> loaded GLTFParameters
| Param | Type | Description |
|---|---|---|
LoaderClass | new () => Loader<T> | Three.js Loader class (not instance) |
Return Value
| Property | Type | Description |
|---|---|---|
result | Ref<T | null> | Load result |
isLoading | Ref<boolean> | Loading state |
error | Ref<Error | null> | Error information |
load | (url: string) => Promise<T> | Trigger loading |