Skip to content

Commit

Permalink
fix(useGLTF): mirror inferred ObjectMap types (#1734)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored Dec 3, 2023
1 parent e4ceaf0 commit 481b327
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/core/useGLTF.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Loader } from 'three'
// @ts-ignore
import { GLTFLoader, DRACOLoader, MeshoptDecoder } from 'three-stdlib'
import { useLoader } from '@react-three/fiber'
import { type Loader } from 'three'
import { type GLTF, GLTFLoader, DRACOLoader, MeshoptDecoder } from 'three-stdlib'
import { type ObjectMap, useLoader } from '@react-three/fiber'

let dracoLoader: DRACOLoader | null = null

Expand Down Expand Up @@ -32,9 +31,8 @@ export function useGLTF<T extends string | string[]>(
useDraco: boolean | string = true,
useMeshOpt: boolean = true,
extendLoader?: (loader: GLTFLoader) => void
) {
const gltf = useLoader(GLTFLoader, path, extensions(useDraco, useMeshOpt, extendLoader))
return gltf
): T extends any[] ? (GLTF & ObjectMap)[] : GLTF & ObjectMap {
return useLoader(GLTFLoader, path, extensions(useDraco, useMeshOpt, extendLoader))
}

useGLTF.preload = (
Expand Down

1 comment on commit 481b327

@vercel
Copy link

@vercel vercel bot commented on 481b327 Dec 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.