-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useGLTF
dry-types
#2116
useGLTF
dry-types
#2116
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
type Path = string | string[] | ||
type UseDraco = boolean | string | ||
type UseMeshopt = boolean | ||
type ExtendLoader = (loader: GLTFLoader) => void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's all about reusing those 4 types
useDraco: boolean | string = true, | ||
useMeshOpt: boolean = true, | ||
extendLoader?: (loader: GLTFLoader) => void | ||
): T extends any[] ? (GLTF & ObjectMap)[] : GLTF & ObjectMap { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
: T extends any[] ? (GLTF & ObjectMap)[] : GLTF & ObjectMap
@CodyJasonBennett we should "normally" be able to remove this return type value, since it should be inferred by useLoader
but I have teste and & ObjectMap
is missing if we do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is still the case with latest R3F v8. R3F v9 should do this correctly, so we'll at least be able to remove this in the next major. Not eager to remove anything now with how volatile the types are when inferred.
type ExtendLoader = (loader: GLTFLoader) => void | ||
|
||
function extensions(useDraco: UseDraco = true, useMeshopt: UseMeshopt = true, extendLoader?: ExtendLoader) { | ||
return (loader: GLTFLoader) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
: GLTFLoader
type-assertion instead of : Loader
=> it avoids multiple as GLTFLoader
later in the function
85a7956
to
6ddbab0
Compare
6ddbab0
to
a7f43ea
Compare
Why
What
Checklist