It seems like this error has a multitude of issues that result in the same error message and it has been a very overwhelming experience to pin point the problem. I don’t know what to extend here, I can’t extend Canvas as it is?
import React, { useState, useEffect } from "react";
import { Canvas } from "react-three-fiber";
import * as THREE from "three";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
import vertexShader from "../shaders/vertexShader.glsl";
import fragmentShader from "../shaders/fragmentShader.glsl";
const Model = () => {
const [model, setModel] = useState<THREE.Object3D | null>(null);
// Load model
useEffect(() => {
const shaderMaterial = new THREE.ShaderMaterial({
vertexShader: vertexShader,
fragmentShader: fragmentShader,
});
const loader = new GLTFLoader();
loader.load(
"/scene.gltf",
(gltf) => {
const loadedModel = gltf.scene;
loadedModel.traverse((child) => {
if (child instanceof THREE.Mesh) {
child.material = shaderMaterial;
}
});
loadedModel.scale.set(75, 75, 75);
loadedModel.position.set(-75, -75, -75);
setModel(loadedModel);
},
undefined,
(error) => {
console.error("Error loading GLTF model:", error);
}
);
}, []);
return model ? <primitive object={model} /> : null;
};
const Scene = () => {
return (
<Canvas>
<Model />
</Canvas>
);
};
export default Scene;