pmndrs / gltfjsx

🎮 Turns GLTFs into JSX components
https://gltf.pmnd.rs
MIT License
4.42k stars 290 forks source link

Error with types in useGLTF hook #167

Closed iskhakgoodmans closed 6 months ago

iskhakgoodmans commented 1 year ago

Problem description:

After creating the tsx file from glb file using gltfjsx tool, there was an error with types in useGTLF hook.

Снимок экрана 2022-11-24 в 15 06 56

Relevant code:

Here is an example of code in codesandbox (sandbox based on this).

drcmda commented 1 year ago

everything typescript i would need your help, im not good enough to get types right myself.

mihirgupta0900 commented 1 year ago

@drcmda I looked into the types for fiber and drei, and we might need to add more generic types. Will take out some time and try to raise a PR.

But for the time being, a patch could be using as unkown type coercion. Not ideal, but atleast types won't be broken when generating the file.

const { nodes, materials, animations } = useGLTF("/path") as unknown as GLTFResult

Edit: Also raised a quick PR to patch this: https://github.com/pmndrs/gltfjsx/pull/173

rafelis1997 commented 1 year ago

Actually I think this solution is better for this https://github.com/pmndrs/gltfjsx/issues/101#issuecomment-1363432531 does it solve your problem?

CodyJasonBennett commented 6 months ago

This is fixed in Drei since https://github.com/pmndrs/drei/releases/tag/v9.89.1.