-
Hi, I used vanila js before, and I met wonderful tool r3f recently. Anyway I think i can't find the example of gltf extension with instancing. Since GpuInstancingExtension goes built-in plug in, I think this plug in has to be adjust with r3f.. Is there any plan to add this plug in to r3f? Or if not, Is there any way to add the custom plugin with gltf loader like I used in vanila?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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. see this tweet: https://twitter.com/0xca0a/status/1552372534397501446 this has overhead (three needs to call updateMatrix and updateWorldMatrix on each instance to figure out the positions), but it can give you an easy way out for models you would otherwise not be able to instance (easily). |
Beta Was this translation helpful? Give feedback.
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:
same for useGLTF
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.