Open doebi opened 2 years ago
update: did exactly the same in a non-typescript project and it works just fine.
This probably is not the ideal solution, but I did this as a work-around:
export default function Model({ ...props }: JSX.IntrinsicElements['group']) {
// Without `as` the type is:
// (alias) useRef<THREE.Group>(): React.MutableRefObject<THREE.Group | undefined> (+2 overloads)
const group = useRef<THREE.Group>() as React.MutableRefObject<THREE.Group>
const { nodes, materials } = useGLTF('/r-place.glb') as GLTFResult
return (
<group ref={group} {...props} dispose={null}>
<mesh
geometry={nodes.rPlaceGrid.geometry}
material={materials.ColorMap}
scale={10}
/>
</group>
)
}
const group = useRef
import { Group } from 'three';
const group = useRef<Group>(null!);
Same with the Mesh:
import { Mesh } from 'three';
const ref = useRef<Mesh>(null!);
GLTFResult
Where GLTFResult come from
Hi. While setting this up and testing it on a fresh react typescript project I ran into this issue.
Looks like some type definition problem. Am I missing something or are there breaking changes in one of the dependecy libraries?
Thanks.