useGLTF typescript access geometry in typesafe way #1337
-
I am looking at the Shoe configurator example and trying to refactor it to typescript This is the code in the example. However, Property 'nodes' and 'materials ' does not exist on type 'GLTF'
these are the variables of useGLTF
this will give me the geometries for all the meshes, but it is not typesafe.
I am trying to loop through the model to create multiple meshes for example.
I tried
But then, the geometries became undefined. Is there a typesafe way to access the geometries and materials of an Object3D? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
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
And here you have to options. The first one is to manually describe content of your model with corresponding types and names. But I do not recommend to do that. The last one is to use convenient solution provided by developers of this library that I've mentioned above |
Beta Was this translation helpful? Give feedback.
@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
useGLTF
return value withGLTF
type imported from three-stdlib. You can see thatGLTF
type does not containnodes
ormaterials
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 modelAnd here you have to options. The first one is to manually describe content of your model wit…