Skip to content

Commit

Permalink
types-extra Introduce MeshMaterialWithColor and `MeshMaterialWith…
Browse files Browse the repository at this point in the history
…EnvMap` (#200)

This way the type of Material can be further narrowed for common use cases:
-  `MeshMaterialWithColor`:  can be used with functions which assign / alter Material's color
-  `MeshMaterialWithEnvMap`:  can be used with functions which assign / alter Material's environment map, e.g. the `CubeCamera` component.
  • Loading branch information
Vatroslav Vrbanic committed Dec 18, 2022
1 parent f5dce29 commit bd41d70
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/lib/types/types-extra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,36 @@ export type get_props<T> = OnlyWritableNonFunctionProps<T>
export type RemoveFirst<T extends unknown[]> = T extends [unknown, ...infer R] ? R : T
export type RemoveLast<T extends unknown[]> = T extends [...infer H, unknown] ? H : T

export type MeshMaterialWithColor =
| THREE.MeshBasicMaterial
//| THREE.MeshDepthMaterial
//| THREE.MeshDistanceMaterial
| THREE.MeshLambertMaterial
| THREE.MeshMatcapMaterial
//| THREE.MeshNormalMaterial
| THREE.MeshPhongMaterial
| THREE.MeshPhysicalMaterial
| THREE.MeshStandardMaterial
| THREE.MeshToonMaterial
//| THREE.RawShaderMaterial
//| THREE.ShaderMaterial
| THREE.ShadowMaterial

export type MeshMaterialWithEnvMap =
| THREE.MeshBasicMaterial
//| THREE.MeshDepthMaterial
//| THREE.MeshDistanceMaterial
| THREE.MeshLambertMaterial
//| THREE.MeshMatcapMaterial
//| THREE.MeshNormalMaterial
| THREE.MeshPhongMaterial
| THREE.MeshPhysicalMaterial
| THREE.MeshStandardMaterial
//| THREE.MeshToonMaterial
//| THREE.RawShaderMaterial
//| THREE.ShaderMaterial
//| THREE.ShadowMaterial

export type MeshAssignableMaterial =
| THREE.MeshBasicMaterial
| THREE.MeshDepthMaterial
Expand Down

0 comments on commit bd41d70

Please sign in to comment.