1
1
import * as React from 'react'
2
2
import * as THREE from 'three'
3
- import { extend , Node } from '@react-three/fiber'
3
+ import { extend , MeshProps , Node } from '@react-three/fiber'
4
4
import { useMemo } from 'react'
5
5
import { useEffect } from 'react'
6
6
import { suspend } from 'suspend-react'
@@ -35,7 +35,8 @@ declare type FontData = {
35
35
36
36
type Text3DProps = {
37
37
font : FontData | string
38
- } & Omit < TextGeometryParameters , 'font' >
38
+ } & Omit < TextGeometryParameters , 'font' > &
39
+ MeshProps
39
40
40
41
const types = [ 'string' , 'number' ]
41
42
const getTextFromChildren = ( children ) => {
@@ -63,6 +64,7 @@ const Text3DBase = React.forwardRef<THREE.Mesh, React.PropsWithChildren<Text3DPr
63
64
bevelOffset = 0 ,
64
65
curveSegments = 8 ,
65
66
children,
67
+ ...props
66
68
} ,
67
69
ref
68
70
) => {
@@ -92,7 +94,7 @@ const Text3DBase = React.forwardRef<THREE.Mesh, React.PropsWithChildren<Text3DPr
92
94
const args = React . useMemo ( ( ) => [ txt , opts ] , [ txt , opts ] )
93
95
94
96
return (
95
- < mesh ref = { ref } >
97
+ < mesh { ... props } ref = { ref } >
96
98
< renamedTextGeometry args = { args } />
97
99
{ children }
98
100
</ mesh >
@@ -107,16 +109,16 @@ const Text3DSuspend = React.forwardRef<THREE.Mesh, React.PropsWithChildren<Text3
107
109
return json
108
110
} , [ font ] )
109
111
110
- return < Text3DBase ref = { ref } { ...props } font = { _font as FontData } loader = { loader } />
112
+ return < Text3DBase { ...props } ref = { ref } font = { _font as FontData } loader = { loader } />
111
113
}
112
114
)
113
115
114
116
export const Text3D = React . forwardRef < THREE . Mesh , React . PropsWithChildren < Text3DProps > > ( ( props , ref ) => {
115
117
const loader = React . useMemo ( ( ) => new FontLoader ( ) , [ ] )
116
118
117
119
if ( typeof props . font === 'string' ) {
118
- return < Text3DSuspend ref = { ref } { ...props } loader = { loader } />
120
+ return < Text3DSuspend { ...props } ref = { ref } loader = { loader } />
119
121
} else {
120
- return < Text3DBase ref = { ref } { ...props } loader = { loader } />
122
+ return < Text3DBase { ...props } ref = { ref } loader = { loader } />
121
123
}
122
124
} )
0 commit comments