How can I spawn new Models into my scene using react three fiber?
App = ()=>{
return(
{[...Array(5)].map((_, index) => (
<Model key={index} />
))}
)
}
what I tried is to have the array as a state variable using useState(); and increase it’s length if additional model is needed… but the new Model is not randered into the scene.
Model itself is something like this:
Model = ()=>{
const ref = useRef();
const {scene} = useGLTF("model.glb");
useFrame(()=>{ ref.current.position.z +=0.1;})
return <Clone object={scene} ref={ref} />
}