Skip to content

Commit

Permalink
fix: gltf types
Browse files Browse the repository at this point in the history
  • Loading branch information
drcmda committed Dec 22, 2022
1 parent b67bcd6 commit cbf8c1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 1 addition & 5 deletions README.md
Expand Up @@ -1298,11 +1298,7 @@ Accepts an SVG url or svg raw data.

#### Gltf

<p>
<a href="https://codesandbox.io/s/if9crg"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/if9crg/screenshot.png" alt="Demo"/></a>
</p>

This is a convenience component that will load a gltf file and clone the scene using drei/Clone. That means you can re-use and mount the same gltf file multiple times. It accepts all props that Clone does.
This is a convenience component that will load a gltf file and clone the scene using [drei/Clone](#clone). That means you can re-use and mount the same gltf file multiple times. It accepts all props that Clone does, including shortcuts (castShadow, receiveShadow) and material overrides.

```js
<Gltf src="/model.glb" receiveShadow castShadow />
Expand Down
9 changes: 5 additions & 4 deletions src/core/Gltf.tsx
@@ -1,13 +1,14 @@
import * as React from 'react'
import * as THREE from 'three'
import { useGLTF } from './useGLTF'
import { Clone, CloneProps } from './Clone'

type GltfProps = JSX.IntrinsicElements['primitive'] &
CloneProps & {
type GltfProps = Omit<JSX.IntrinsicElements['group'], 'children'> &
Omit<CloneProps, 'object'> & {
src: string
}

export const Gltf = React.forwardRef<THREE.Group, GltfProps>(({ src, ...props }, ref) => {
export const Gltf = React.forwardRef(({ src, ...props }: GltfProps, ref: React.Ref<THREE.Object3D>) => {
const { scene } = useGLTF(src)
return <Clone ref={ref} {...props} object={scene} />
return <Clone ref={ref as any} {...props} object={scene} />
})

1 comment on commit cbf8c1e

@vercel
Copy link

@vercel vercel bot commented on cbf8c1e Dec 22, 2022

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.