Skip to content

How to Load gltf file for GLTF Extension with GPU instancing? #2741

Answered by drcmda
Suprhimp asked this question in Q&A
Discussion options

You must be logged in to vote

first of all you can use that loader as you always would, in a useEffect. although we do have hooks that integrate loaders into react suspense, so that loading and fallbacks are easier to handle, and these have a callback to allow you configure:

useLoader(GLTFLoader, url, loader => {
  loader.register(...)

same for useGLTF

export function useGLTF<T extends string | string[]>(
  path: T,
  useDraco: boolean | string = true,
  useMeshOpt: boolean = true,
  extendLoader?: (loader: GLTFLoader) => void
) {

also check out https://github.com/pmndrs/gltfjsx it can instance automatically, even models that were not instanced in blender, simply by detecting similar, re-occuring geometry+material pairs.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Suprhimp
Comment options

Answer selected by Suprhimp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants