-
I have a very simple mesh that I am trying to load as an instancedMesh: https://codesandbox.io/s/laughing-gates-26zwd?file=/src/App.jsx:473-1613 The file loads, and when I log "nodes.TableMed.geometry" it prints a BufferGeometry {uuid: "2803D99A-12B5-4FCC-ABD4-B6233A0F3272", name: "", type: "BufferGeometry", index: BufferAttribute, attributes: Object…} I try and use that as the geometry argument in the instancedMesh:
If I uncomment the <boxGeometry args={[0.8, 0.8, 0.8]}> - then it uses the box successfully, but I haven't been able to make it use the mesh from the .glb file. Hopefully, it is something obvious! Thanks, Josh -- Now also trying with Suzanne: https://codesandbox.io/s/charming-monad-1iobm?file=/src/App.jsx |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Looking around I can't find any working examples of using gLTF with R3F instancedMesh. There are some compelling similar examples: This loads a glb file and uses its contents as an instancedMesh in Three.js: This use's drei's and to bring in the shoe model: This is an example of Suzanne being successfully used in an R3F instancedMesh - but using a blob file rather than a gltf. I am hoping this is just a syntax error. I have also been trying adjusting the transforms with set Matrix, and copying the geometry, based on some other Three.js instancedMesh threads. Banging my head on this wall :( |
Beta Was this translation helpful? Give feedback.
-
Success! This one successfully imports Suzanne! Perhaps the key lines were:
Or maybe because I switched the material. (It was see below) I am very happy. sorry for the spam - I just had to share! |
Beta Was this translation helpful? Give feedback.
-
You can also use Drei's instancing to manage this for you: |
Beta Was this translation helpful? Give feedback.
-
gltfjsx does this automatically now https://twitter.com/0xca0a/status/1439953570439303171 all you need is the -i flag and it will create instances from shared geometry. you also don't need to do any crazy blender stuff, if two meshes share the same geo that's already enough. |
Beta Was this translation helpful? Give feedback.
Success!
This one successfully imports Suzanne!
https://codesandbox.io/s/elated-lumiere-exsvq?file=/src/App.jsx:799-856
Perhaps the key lines were:
Or maybe because I switched the material. (It was see below)
I am very happy. sorry for the spam - I just had to share!