-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
types.ts
40 lines (33 loc) 路 1.57 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import * as THREE from 'three'
import { FC } from 'react'
import { OmitByValue } from 'utility-types'
import { ReactThreeFiber } from '../three-types'
type Three = typeof import('three')
/** Classes exported `three/src/Three.d.ts` but not from `three/src/Three.js` */
type MissingInThreeRuntimeExports =
| THREE.AnimationAction
| THREE.DirectGeometry
| THREE.WebGLClipping
| THREE.WebGLInfo
| THREE.WebGLProperties
| THREE.WebGLRenderList
| THREE.WebGLRenderLists
| THREE.WebGLColorBuffer
| THREE.WebGLDepthBuffer
| THREE.WebGLStencilBuffer
type InterestingThreeExports = OmitByValue<Three, MissingInThreeRuntimeExports | THREE.BufferAttribute>
type __ThreeFiberComponents = {
[P in keyof InterestingThreeExports]: Three[P] extends new (...args: any) => any
? InstanceType<Three[P]> extends InstanceType<Three['Object3D']>
? FC<ReactThreeFiber.Object3DNode<InstanceType<Three[P]>, Three[P]>>
: InstanceType<Three[P]> extends InstanceType<Three['Geometry']>
? FC<ReactThreeFiber.GeometryNode<InstanceType<Three[P]>, Three[P]>>
: InstanceType<Three[P]> extends InstanceType<Three['BufferGeometry']>
? FC<ReactThreeFiber.BufferGeometryNode<InstanceType<Three[P]>, Three[P]>>
: InstanceType<Three[P]> extends InstanceType<Three['Material']>
? FC<ReactThreeFiber.MaterialNode<InstanceType<Three[P]>, Required<ConstructorParameters<Three[P]>>>>
: FC<ReactThreeFiber.Node<InstanceType<Three[P]>, Three[P]>>
: never
}
export { OmitByValue }
export interface ThreeFiberComponents extends OmitByValue<__ThreeFiberComponents, never> {}