i have not use any div inside canvas and when i do extend({OrbitControls, Preload, useGLTF}) as the documention says then also error comes as extended is not defined . i am not able to solve the error as i am new to three.js
most likely it’s that. everything inside <Canvas> is three js, you can’t render a div in there. a <mesh> is just sugar for new THREE.Mesh(), if you put a <div> in it it would execute new THREE.Div() and there’s no such thing in the THREE namespace.
if you want to await threejs with a loading state just move the suspense block outside the canvas and et voila it will work. but inside canvas the fallback can only render threejs.
it’s the same, you render a div somewhere, find it, eliminate it. you either render it as a fallback or straight mounted into the canvas. everything within canvas is outside the dom, pure threejs, that includes fallbacks and error bounds.
If you try to add a standard HTML tag inside the React Three Fiber Canvas element, then you will get a similar error to,
Uncaught Error: R3F: Div is not part of the THREE namespace! Did you forget to extend?
The error happens because the React Three Fiber reconciler renders into a Three.js scene, and not the HTML document. So, a div, span, h1 or any other HTML tag will mean nothing to the Three.js renderer.
Instead, you need to render it to the HTML document, and for that you use the React-DOM reconciler.
Yes that is coming from canvas loader where at the time you are getting the error you are returning a div instead you have to return the Html tag there so proceed with the video of javascript mastery and it will be fine
Remove fallback from the suspense block because in the project we were using it without defining the canvas loader anywhere in the component. Thus it fails to load the canvas.
The issue is caused because of a <div> in the canvas from one of your components. just change it to <mesh> in that component, and your issue should get solved.
Hi, @Dhiraj_Gilda I’m also constructing a project using YouTube, and I’m having the same problem. @seanwasere suggested a good idea. You will see in the project we are passing