Skip to content

Commit 1b96976

Browse files
authored
fix: Add MeshProps to <Text3D />
1 parent 7a334a3 commit 1b96976

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/core/Text3D.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react'
22
import * as THREE from 'three'
3-
import { extend, Node } from '@react-three/fiber'
3+
import { extend, MeshProps, Node } from '@react-three/fiber'
44
import { useMemo } from 'react'
55
import { useEffect } from 'react'
66
import { suspend } from 'suspend-react'
@@ -35,7 +35,8 @@ declare type FontData = {
3535

3636
type Text3DProps = {
3737
font: FontData | string
38-
} & Omit<TextGeometryParameters, 'font'>
38+
} & Omit<TextGeometryParameters, 'font'> &
39+
MeshProps
3940

4041
const types = ['string', 'number']
4142
const getTextFromChildren = (children) => {
@@ -63,6 +64,7 @@ const Text3DBase = React.forwardRef<THREE.Mesh, React.PropsWithChildren<Text3DPr
6364
bevelOffset = 0,
6465
curveSegments = 8,
6566
children,
67+
...props
6668
},
6769
ref
6870
) => {
@@ -92,7 +94,7 @@ const Text3DBase = React.forwardRef<THREE.Mesh, React.PropsWithChildren<Text3DPr
9294
const args = React.useMemo(() => [txt, opts], [txt, opts])
9395

9496
return (
95-
<mesh ref={ref}>
97+
<mesh {...props} ref={ref}>
9698
<renamedTextGeometry args={args} />
9799
{children}
98100
</mesh>
@@ -107,16 +109,16 @@ const Text3DSuspend = React.forwardRef<THREE.Mesh, React.PropsWithChildren<Text3
107109
return json
108110
}, [font])
109111

110-
return <Text3DBase ref={ref} {...props} font={_font as FontData} loader={loader} />
112+
return <Text3DBase {...props} ref={ref} font={_font as FontData} loader={loader} />
111113
}
112114
)
113115

114116
export const Text3D = React.forwardRef<THREE.Mesh, React.PropsWithChildren<Text3DProps>>((props, ref) => {
115117
const loader = React.useMemo(() => new FontLoader(), [])
116118

117119
if (typeof props.font === 'string') {
118-
return <Text3DSuspend ref={ref} {...props} loader={loader} />
120+
return <Text3DSuspend {...props} ref={ref} loader={loader} />
119121
} else {
120-
return <Text3DBase ref={ref} {...props} loader={loader} />
122+
return <Text3DBase {...props} ref={ref} loader={loader} />
121123
}
122124
})

0 commit comments

Comments
 (0)