Unable render muliple <primitive/> in one page #1199
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Not sure how PCD works or is implemented, but a resource/object can only ever be mounted in one place at once. See here: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#putting-already-existing-objects-into-the-scene-graph export const useGltfScene = (model: string) => {
const gltf = useGLTF(`${process.env.PUBLIC_URL}/models/${model}`);
const scene = useMemo(() => gltf.scene.clone(), [gltf]); // Clone the scene to be able to use multiple instances.
return scene;
}; Maybe (hopefully) that will work for PCD as well. |
Beta Was this translation helpful? Give feedback.
-
@drcmda If I'm not mistaken, you have to process the file and create a Model (jsx/tsx) manually with gltfjsx? I dont think it covers the use case where users can upload models (vs already having the models and converted prior to deployment) |
Beta Was this translation helpful? Give feedback.
Not sure how PCD works or is implemented, but a resource/object can only ever be mounted in one place at once. See here: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#putting-already-existing-objects-into-the-scene-graph
To get around this, clone the loaded entity. For example, when loading GLTF scenes that I want to use multiple instances of, I do this:
Maybe (hopefully) that will work for PCD as well.