I need to position three models, each of which are rotated differently. I envisaged that I would create three functions to import and animate each of the three models and then export three canvases sized appropriately.
But this is not working for me. In the current test I have two canvases and models. I do get the two canvases but the second canvas has no model.
This is the code for the second model:
function Number4() {
console.log(“Function Number4 running”);
const group2 = useRef();
const { scene2 } = useLoader(GLTFLoader, “/models/BigW_only_mesh13July_centredScale2.glb”);
const { nodes2 } = useLoader(GLTFLoader, “/models/BigW_only_mesh13July_centredScale2.glb”);
const { model2} = “/Models/models/BigW_only_mesh13July_centredScale2.glb”;
useFrame(() => {
group2.current.rotation.y += 0.016; // axis & speed
});
return (
);
}
This is the export code:
<div id="divCanvas2">
<Canvas id = "canvas2" className = "canvas2" style={{ background: "darkgreen"}} orthographic camera={{ zoom: 50, position: [0, 0, 100] }} >
<ambientLight />
<pointLight position={[10, 10, 10]} />
<directionalLight intensity={4.16} />
<Suspense fallback={<Loading />}>
<Number4 />
</Suspense>
</Canvas>
</div>
I am using the same model for testing.
I get this error in Chrome Dev Tools:
index.js:1 The above error occurred in the component:
in primitive (at Logo.js:58)
in group2 (at Logo.js:57)
in Number4 (at Logo.js:84)
in Suspense (at Logo.js:83)
in Canvas
Any suggestion welcomed