Skip to content

Commit

Permalink
fix: add correct suzanne types in useGLTF story
Browse files Browse the repository at this point in the history
  • Loading branch information
ffdead committed Nov 4, 2021
1 parent 29432dd commit 03aa8ae
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .storybook/stories/useGLTF.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react'
import { Mesh, Vector3 } from 'three'
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader'

import { Setup } from '../Setup'

Expand All @@ -11,8 +12,17 @@ export default {
decorators: [(storyFn) => <Setup cameraPosition={new Vector3(0, 0, 5)}>{storyFn()}</Setup>],
}

type GLTFResult = GLTF & {
nodes: {
Suzanne: THREE.Mesh
}
materials: {
['Material.001']: THREE.MeshStandardMaterial
}
}

function Suzanne() {
const { nodes, materials } = useGLTF('suzanne.glb', true)
const { nodes, materials } = useGLTF('suzanne.glb', true) as GLTFResult

return <mesh material={materials['Material.001']} geometry={(nodes.Suzanne as Mesh).geometry} />
}
Expand All @@ -31,7 +41,7 @@ UseGLTFSceneSt.story = {
}

function SuzanneWithLocal() {
const { nodes, materials } = useGLTF('suzanne.glb', '/draco-gltf/')
const { nodes, materials } = useGLTF('suzanne.glb', '/draco-gltf/') as GLTFResult

return (
<group dispose={null}>
Expand Down

0 comments on commit 03aa8ae

Please sign in to comment.