The tag <mesh> is not recognized in the browser. I am building a react and three.js project for which my 3D model is not loading. I tried many ways by seeing the documentation and other things but it was not working. This is my code.
import { Suspense, useEffect, useRef, useState } from 'react';
import { Canvas } from '@react-three/fiber';
import { OrbitControls, Preload, useGLTF } from '@react-three/drei';
import CanvasLoader from '../Loader';
const Computers = () => {
const computer = useGLTF('./desktop_pc/scene.gltf');
return (
<mesh>
<hemisphereLight intensity={0.15} groundColor="black" />
<pointLight intensity={1} />
<primitive object={computer.scene} />
</mesh>
);
};
const ComputerCanvas = () => {
return (
<Canvas
frameloop="demand"
shadows
camera={{ position: [20, 3, 5], fov: 25 }}
gl={{ preserveDrawingBuffer: true }}
>
<Suspense fallback={<CanvasLoader />}>
<OrbitControls
enableZoom={false}
maxPolarAngle={Math.PI / 2}
minPolarAngle={Math.PI / 2}
/>
<Computers />
</Suspense>
<Preload all />
</Canvas>
);
};
export default Computers;
I tried it seeing and implementing the official documentation but it didn’t work.
2
Answers
Instead of "export default Computers" type "export default ComputerCanvas"
JavaScript Mastery šš
I have the same case (eror): "Warning: is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements." etc.
This code is from YouTube: https ://youtu.be/0fYi8SGA20k
The error disappeared the next day.
Possibly due to the restart of VS Code, the Chrome browser.