How can I use GLTFLoader?
See original GitHub issueHi, i’m trying to load a scene
function GLTFScene({ gltfUrl }) {
const object = useMemo(() => new GLTFLoader().load(gltfUrl), [gltfUrl])
return (
<>
{
object &&
<primitive object={object} position={[0,0,0]}/>
}
</>
)
}
and my jsx
<div className="main" style={{ color: '#172717' }}>
<Canvas style={{ background: '#A2CCB6', height: "100vh", width: "100hw" }} camera={{ position: [0, 0, 1000] }}>
<ambientLight intensity={0.5} />
<spotLight intensity={0.5} position={[300, 300, 4000]} />
<GLTFScene gltfUrl={url} />
</Canvas>
</div>
And i’m getting img path error, i’ve tried to import the same gltf file in threejs editor and works fine. Anyone who has done this before can helpme. Thanks in advance
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top Results From Across the Web
GLTFLoader – three.js docs
A loader for glTF 2.0 resources. glTF (GL Transmission Format) is an open format specification for efficient delivery and loading of 3D content....
Read more >GLTF Model Loader - Three.js Tutorials - sbcode.net
Description. A loader for loading glTF models into the Threejs scene. glTF is a specification for the efficient transmission and loading of 3D...
Read more >Load 3D Models in glTF Format - Discover three.js!
Once you have created a model in Blender, you can export your work using a 3D format such as glTF, then use the...
Read more >Three.js Loading a .GLTF File
The gLTF format is actually a format designed from the ground up for be used for displaying graphics. 3D formats can be divided...
Read more >three-gltf-loader examples - CodeSandbox
Learn how to use three-gltf-loader by viewing and forking three-gltf-loader example apps on CodeSandbox.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

it doesn’t work again right now, the codesandbox also shows nothing after i click.
I currently facing this problem, not sure why, im new to 3 and it doesn’t load anything, still blank with GLTFLoader
From how it looks to me you load something, but there’s no callback to give you the thing that you want to load, whenever its ready. But if the fetch request itself errors out, then your path is probably wrong, too.
here’s one example using svgloader: https://codesandbox.io/s/v8439q295l?from-embed
and the docs for gltf loader: https://threejs.org/docs/index.html#examples/loaders/GLTFLoader
it says loader.load(url, callback), so maybe something like this …
If i understand docs correctly, load will end up calling the “set” method with the gltf object as the first argument. And that re-renders the component.