Skip to content

useGLTF typescript access geometry in typesafe way #1337

Answered by myznikovgleb
Dave-Patsy asked this question in Q&A
Discussion options

You must be logged in to vote

@Dave-Patsy

I guess you just miss the point of usage gtlfjsx or its web version to work with GLTF-models. This command-line tool also support type safe user experience

I also try to explain what happens in this code snippet

const { nodes,  materials }= useGLTF("/models/shoe-draco.glb")

useGLTF return value with GLTF type imported from three-stdlib. You can see that GLTF type does not contain nodes or materials fields. Why? I guess that it is simply imposable for third-party library (as three-stdlib) to predict what types of nodes (i.e. meshes) and materials will be stored at your brand new model

And here you have to options. The first one is to manually describe content of your model wit…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Dave-Patsy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants