I'm building a nextjs
app with 3D animations using @react-three/drei
.
I have a gltf
file in the public
folder, under the desktop_pc
folder called scene. gltf
.
The path from the project root is: /public/desktop_pc/scene.gltf
.
When importing the gltf
file into the useGLTF
hook, I'm getting the error:
TypeError: Failed to parse URL from /desktop_pc/scene.gltf
Github Repository - nextjs & @react-three/drei - TypeError: Failed to parse URL
This is the component code:
import { useGLTF } from "@react-three/drei";
import React from "react";
const Computers = () => {
const computer = useGLTF("/desktop_pc/scene.gltf");
return <div>Computers</div>;
};
export default Computers;
These are my attempts so far (The links leads to the GitHub solution of them):
- Dynamic import - https://github.com/ItayTur/Portfolio/tree/invalid-url-error-dynamic-solution
- Lazy import - https://github.com/ItayTur/Portfolio/tree/invalid-url-error-lazy-solution
- Installing the
Three
&three-stdlib
npm packages. - Specify the exact path from the component to the file location.
- Adding a dot at the start of the path string.