Best practices for adding a lot of dynamic objects from gltfjsx to the Physics world #91
-
Say if I just imported a scene via gltfjsx and wanted to iterate through objects in that scene and just add them as simple collideable objects in the world. Right now given that However, I was just wondering if there was a more efficient way to do so, especially if I have lots of objects in the scene and if most of these objects don't need to be moved manually via the api. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Are these objects similar enough in size and shape to be used as instanced geometry as in the cube demo? That would be the most efficient. Else, I've done this, which isn't great by any means, but ran alright. There might be a yet-more-efficient way of doing things. function Model (props) {
const gltf = useLoader(GLTFLoader, props.url)
const [ref, api] = use<shape>(() => ({...}))
return (<mesh .../>)
}
// and a setup that populates a physics world
const objects = [] // a list of urls, objects from a scene, what have you
<Physics>
{objects.map((object) => (
<Model {...object} />
))}
</Physics> |
Beta Was this translation helpful? Give feedback.
Are these objects similar enough in size and shape to be used as instanced geometry as in the cube demo? That would be the most efficient.
Else, I've done this, which isn't great by any means, but ran alright. There might be a yet-more-efficient way of doing things.