> & O
+type Mutable = { [K in keyof P]: P[K] | Readonly
}
+type NonFunctionKeys
= { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
+type Overwrite
= Omit
> & O
-/**
- * If **T** contains a constructor, @see ConstructorParameters must be used, otherwise **T**.
- */
-type Args = T extends new (...args: any) => any ? ConstructorParameters : T
-
-export type Euler = THREE.Euler | Parameters
-export type Matrix4 = THREE.Matrix4 | Parameters | Readonly
-
-/**
- * Turn an implementation of THREE.Vector in to the type that an r3f component would accept as a prop.
- */
-type VectorLike =
- | VectorClass
- | Parameters
- | Readonly>
- | Parameters[0]
-
-export type Vector2 = VectorLike
-export type Vector3 = VectorLike
-export type Vector4 = VectorLike
-export type Color = ConstructorParameters | THREE.Color | number | string // Parameters will not work here because of multiple function signatures in three.js types
-export type ColorArray = typeof THREE.Color | Parameters
-export type Layers = THREE.Layers | Parameters[0]
-export type Quaternion = THREE.Quaternion | Parameters
+interface MathRepresentation {
+ set(...args: any[]): any
+}
+interface VectorRepresentation extends MathRepresentation {
+ setScalar(s: number): any
+}
+type MathProps = {
+ [K in keyof P]: P[K] extends infer M
+ ? M extends THREE.Color
+ ? ConstructorParameters | THREE.ColorRepresentation
+ : M extends MathRepresentation
+ ? M extends VectorRepresentation
+ ? M | Parameters | Parameters[0]
+ : M | Parameters
+ : {}
+ : {}
+}
-export type AttachCallback = string | ((child: any, parentInstance: any) => void)
+interface RaycastableRepresentation {
+ raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void
+}
+type EventProps = P extends RaycastableRepresentation ? Partial : {}
-export interface NodeProps {
- attach?: AttachType
- /** Constructor arguments */
- args?: Args
+interface ReactProps
{
children?: React.ReactNode
- ref?: React.Ref
+ ref?: React.Ref
key?: React.Key
}
-export type ExtendedColors = { [K in keyof T]: T[K] extends THREE.Color | undefined ? Color : T[K] }
-export type Node = ExtendedColors, NodeProps>>
-
-export type Object3DNode = Overwrite<
- Node,
- {
- position?: Vector3
- up?: Vector3
- scale?: Vector3
- rotation?: Euler
- matrix?: Matrix4
- quaternion?: Quaternion
- layers?: Layers
- dispose?: (() => void) | null
- }
-> &
- EventHandlers
-
-export type BufferGeometryNode = Node
-export type MaterialNode = Node
-export type LightNode = Object3DNode
-
-export type Object3DProps = Object3DNode
-// export type AudioProps = Object3DNode
-export type AudioListenerProps = Object3DNode
-export type PositionalAudioProps = Object3DNode
-
-export type MeshProps = Object3DNode
-export type InstancedMeshProps = Object3DNode
-export type SceneProps = Object3DNode
-export type SpriteProps = Object3DNode
-export type LODProps = Object3DNode
-export type SkinnedMeshProps = Object3DNode
-
-export type SkeletonProps = Object3DNode
-export type BoneProps = Object3DNode
-export type LineSegmentsProps = Object3DNode
-export type LineLoopProps = Object3DNode
-// export type LineProps = Object3DNode
-export type PointsProps = Object3DNode
-export type GroupProps = Object3DNode
-
-export type CameraProps = Object3DNode
-export type PerspectiveCameraProps = Object3DNode
-export type OrthographicCameraProps = Object3DNode
-export type CubeCameraProps = Object3DNode
-export type ArrayCameraProps = Object3DNode
-
-export type InstancedBufferGeometryProps = BufferGeometryNode<
- THREE.InstancedBufferGeometry,
- typeof THREE.InstancedBufferGeometry
->
-export type BufferGeometryProps = BufferGeometryNode
-export type BoxBufferGeometryProps = BufferGeometryNode
-export type CircleBufferGeometryProps = BufferGeometryNode<
- THREE.CircleBufferGeometry,
- typeof THREE.CircleBufferGeometry
->
-export type ConeBufferGeometryProps = BufferGeometryNode
-export type CylinderBufferGeometryProps = BufferGeometryNode<
- THREE.CylinderBufferGeometry,
- typeof THREE.CylinderBufferGeometry
->
-export type DodecahedronBufferGeometryProps = BufferGeometryNode<
- THREE.DodecahedronBufferGeometry,
- typeof THREE.DodecahedronBufferGeometry
->
-export type ExtrudeBufferGeometryProps = BufferGeometryNode<
- THREE.ExtrudeBufferGeometry,
- typeof THREE.ExtrudeBufferGeometry
->
-export type IcosahedronBufferGeometryProps = BufferGeometryNode<
- THREE.IcosahedronBufferGeometry,
- typeof THREE.IcosahedronBufferGeometry
->
-export type LatheBufferGeometryProps = BufferGeometryNode
-export type OctahedronBufferGeometryProps = BufferGeometryNode<
- THREE.OctahedronBufferGeometry,
- typeof THREE.OctahedronBufferGeometry
+type ElementProps> = Partial<
+ Overwrite & MathProps
& EventProps
>
>
-export type PlaneBufferGeometryProps = BufferGeometryNode
-export type PolyhedronBufferGeometryProps = BufferGeometryNode<
- THREE.PolyhedronBufferGeometry,
- typeof THREE.PolyhedronBufferGeometry
->
-export type RingBufferGeometryProps = BufferGeometryNode
-export type ShapeBufferGeometryProps = BufferGeometryNode
-export type SphereBufferGeometryProps = BufferGeometryNode<
- THREE.SphereBufferGeometry,
- typeof THREE.SphereBufferGeometry
->
-export type TetrahedronBufferGeometryProps = BufferGeometryNode<
- THREE.TetrahedronBufferGeometry,
- typeof THREE.TetrahedronBufferGeometry
->
-export type TorusBufferGeometryProps = BufferGeometryNode
-export type TorusKnotBufferGeometryProps = BufferGeometryNode<
- THREE.TorusKnotBufferGeometry,
- typeof THREE.TorusKnotBufferGeometry
->
-export type TubeBufferGeometryProps = BufferGeometryNode
-export type WireframeGeometryProps = BufferGeometryNode
-export type TetrahedronGeometryProps = BufferGeometryNode
-export type OctahedronGeometryProps = BufferGeometryNode
-export type IcosahedronGeometryProps = BufferGeometryNode
-export type DodecahedronGeometryProps = BufferGeometryNode<
- THREE.DodecahedronGeometry,
- typeof THREE.DodecahedronGeometry
->
-export type PolyhedronGeometryProps = BufferGeometryNode
-export type TubeGeometryProps = BufferGeometryNode
-export type TorusKnotGeometryProps = BufferGeometryNode
-export type TorusGeometryProps = BufferGeometryNode
-export type SphereGeometryProps = BufferGeometryNode
-export type RingGeometryProps = BufferGeometryNode
-export type PlaneGeometryProps = BufferGeometryNode
-export type LatheGeometryProps = BufferGeometryNode
-export type ShapeGeometryProps = BufferGeometryNode
-export type ExtrudeGeometryProps = BufferGeometryNode
-export type EdgesGeometryProps = BufferGeometryNode
-export type ConeGeometryProps = BufferGeometryNode
-export type CylinderGeometryProps = BufferGeometryNode
-export type CircleGeometryProps = BufferGeometryNode
-export type BoxGeometryProps = BufferGeometryNode
-export type CapsuleGeometryProps = BufferGeometryNode
-export type MaterialProps = MaterialNode
-export type ShadowMaterialProps = MaterialNode
-export type SpriteMaterialProps = MaterialNode
-export type RawShaderMaterialProps = MaterialNode
-export type ShaderMaterialProps = MaterialNode
-export type PointsMaterialProps = MaterialNode
-export type MeshPhysicalMaterialProps = MaterialNode
-export type MeshStandardMaterialProps = MaterialNode
-export type MeshPhongMaterialProps = MaterialNode
-export type MeshToonMaterialProps = MaterialNode
-export type MeshNormalMaterialProps = MaterialNode
-export type MeshLambertMaterialProps = MaterialNode
-export type MeshDepthMaterialProps = MaterialNode
-export type MeshDistanceMaterialProps = MaterialNode
-export type MeshBasicMaterialProps = MaterialNode
-export type MeshMatcapMaterialProps = MaterialNode
-export type LineDashedMaterialProps = MaterialNode
-export type LineBasicMaterialProps = MaterialNode
-
-export type PrimitiveProps = { object: any } & { [properties: string]: any }
-
-export type LightProps = LightNode
-export type SpotLightShadowProps = Node
-export type SpotLightProps = LightNode
-export type PointLightProps = LightNode
-export type RectAreaLightProps = LightNode
-export type HemisphereLightProps = LightNode
-export type DirectionalLightShadowProps = Node
-export type DirectionalLightProps = LightNode
-export type AmbientLightProps = LightNode
-export type LightShadowProps = Node
-export type AmbientLightProbeProps = LightNode
-export type HemisphereLightProbeProps = LightNode
-export type LightProbeProps = LightNode
-
-export type SpotLightHelperProps = Object3DNode
-export type SkeletonHelperProps = Object3DNode
-export type PointLightHelperProps = Object3DNode
-export type HemisphereLightHelperProps = Object3DNode
-export type GridHelperProps = Object3DNode
-export type PolarGridHelperProps = Object3DNode
-export type DirectionalLightHelperProps = Object3DNode<
- THREE.DirectionalLightHelper,
- typeof THREE.DirectionalLightHelper
+export type ThreeElement = Mutable<
+ Overwrite