Skip to content

Commit

Permalink
fix: Euler types and ReactProps
Browse files Browse the repository at this point in the history
  • Loading branch information
krispya committed Jan 13, 2023
1 parent dd1ffe8 commit 56a11a9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/fiber/src/three-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ interface VectorRepresentation extends MathRepresentation {
setScalar(s: number): any
}

export type MathType<T extends MathRepresentation> = T extends THREE.Color
export type MathType<T extends MathRepresentation | THREE.Euler> = T extends THREE.Color
? ConstructorParameters<typeof THREE.Color> | THREE.ColorRepresentation
: T extends VectorRepresentation | THREE.Layers
: T extends VectorRepresentation | THREE.Layers | THREE.Euler
? T | Parameters<T['set']> | number
: T | Parameters<T['set']>

Expand All @@ -21,15 +21,16 @@ export type Vector4 = MathType<THREE.Vector4>
export type Color = MathType<THREE.Color>
export type Layers = MathType<THREE.Layers>
export type Quaternion = MathType<THREE.Quaternion>
export type Euler = MathType<THREE.Euler>

type WithMathProps<P> = { [K in keyof P]: P[K] extends MathRepresentation ? MathType<P[K]> : P[K] }
type WithMathProps<P> = { [K in keyof P]: P[K] extends MathRepresentation | THREE.Euler ? MathType<P[K]> : P[K] }

interface RaycastableRepresentation {
raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void
}
type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}

interface ReactProps<P> {
export interface ReactProps<P> {
children?: React.ReactNode
ref?: React.Ref<P>
key?: React.Key
Expand Down

0 comments on commit 56a11a9

Please sign in to comment.