Skip to content

Commit

Permalink
MeshPhysicalMaterial: Add dispersion. (#896)
Browse files Browse the repository at this point in the history
* Add MeshPhysicalMaterial.dispersion

* Update MeshPhysicalNodeMaterial

* Update three.js

* Add examples

* Update changes.patch

* Delete examples
  • Loading branch information
Methuselah96 authored Apr 21, 2024
1 parent f5ba0e2 commit 94aded5
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 65 deletions.
13 changes: 13 additions & 0 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7103,6 +7103,19 @@ index 8202430..0926a59 100644

init();
render();
diff --git a/examples-testing/examples/webgl_loader_gltf_dispersion.ts b/examples-testing/examples/webgl_loader_gltf_dispersion.ts
index d17e066..496142d 100644
--- a/examples-testing/examples/webgl_loader_gltf_dispersion.ts
+++ b/examples-testing/examples/webgl_loader_gltf_dispersion.ts
@@ -4,7 +4,7 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';

-let camera, scene, renderer;
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGLRenderer;

init().then(render);

diff --git a/examples-testing/examples/webgl_loader_gltf_instancing.ts b/examples-testing/examples/webgl_loader_gltf_instancing.ts
index 5d23e77..b8a6814 100644
--- a/examples-testing/examples/webgl_loader_gltf_instancing.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,45 @@ export default class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {

// Properties from MeshPhysicalMaterial
readonly isMeshPhysicalMaterial: true;
clearcoat: number;
anisotropyRotation: number;
anisotropyMap: Texture | null;
clearcoatMap: Texture | null;
clearcoatRoughness: number;
clearcoatRoughnessMap: Texture | null;
clearcoatNormalScale: Vector2;
clearcoatNormalMap: Texture | null;
reflectivity: number;
ior: number;
sheen: number;
get reflectivity(): number;
set reflectivity(reflectivity: number);
iridescenceMap: Texture | null;
iridescenceIOR: number;
iridescenceThicknessRange: [number, number];
iridescenceThicknessMap: Texture | null;
sheenColor: Color;
sheenColorMap: Texture | null;
sheenRoughness: number;
sheenRoughnessMap: Texture | null;
transmission: number;
transmissionMap: Texture | null;
thickness: number;
thicknessMap: Texture | null;
attenuationDistance: number;
attenuationColor: Color;
specularIntensity: number;
specularColor: Color;
specularIntensityMap: Texture | null;
specularColor: Color;
specularColorMap: Texture | null;
iridescenceMap: Texture | null;
iridescenceIOR: number;
iridescence: number;
iridescenceThicknessRange: [number, number];
iridescenceThicknessMap: Texture | null;
anisotropy?: number;
anisotropyRotation?: number;
anisotropyMap?: Texture | null;
get anisotropy(): number;
set anisotropy(value: number);
get clearcoat(): number;
set clearcoat(value: number);
get iridescence(): number;
set iridescence(value: number);
get dispersion(): number;
set dispersion(value: number);
get sheen(): number;
set sheen(value: number);
get transmission(): number;
set transmission(value: number);

constructor(parameters?: MeshPhysicalNodeMaterialParameters);
}
116 changes: 65 additions & 51 deletions types/three/src/materials/MeshPhysicalMaterial.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,47 @@ import { Texture } from "../textures/Texture.js";
import { MeshStandardMaterial, MeshStandardMaterialParameters } from "./MeshStandardMaterial.js";

export interface MeshPhysicalMaterialParameters extends MeshStandardMaterialParameters {
clearcoat?: number | undefined;
anisotropyRotation?: number | undefined;
anisotropyMap?: Texture | null | undefined;

clearcoatMap?: Texture | null | undefined;
clearcoatRoughness?: number | undefined;
clearcoatRoughnessMap?: Texture | null | undefined;
clearcoatNormalScale?: Vector2 | undefined;
clearcoatNormalMap?: Texture | null | undefined;

reflectivity?: number | undefined;
ior?: number | undefined;

sheen?: number | undefined;
reflectivity?: number | undefined;

iridescenceMap?: Texture | null | undefined;
iridescenceIOR?: number | undefined;
iridescenceThicknessRange?: [number, number] | undefined;
iridescenceThicknessMap?: Texture | null | undefined;

sheenColor?: ColorRepresentation | undefined;
sheenColorMap?: Texture | null | undefined;
sheenRoughness?: number | undefined;
sheenRoughnessMap?: Texture | null | undefined;

transmission?: number | undefined;
transmissionMap?: Texture | null | undefined;

thickness?: number | undefined;
thicknessMap?: Texture | null | undefined;

attenuationDistance?: number | undefined;
attenuationColor?: ColorRepresentation | undefined;

specularIntensity?: number | undefined;
specularColor?: ColorRepresentation | undefined;
specularIntensityMap?: Texture | null | undefined;
specularColor?: ColorRepresentation | undefined;
specularColorMap?: Texture | null | undefined;

iridescenceMap?: Texture | null | undefined;
iridescenceIOR?: number | undefined;
iridescence?: number | undefined;
iridescenceThicknessRange?: [number, number] | undefined;
iridescenceThicknessMap?: Texture | null | undefined;

anisotropy?: number | undefined;
anisotropyRotation?: number | undefined;
anisotropyMap?: Texture | null | undefined;
clearcoat?: number | undefined;
iridescence?: number | undefined;
dispersion?: number | undefined;
sheen?: number | undefined;
transmission?: number | undefined;
}

export class MeshPhysicalMaterial extends MeshStandardMaterial {
Expand All @@ -55,20 +57,25 @@ export class MeshPhysicalMaterial extends MeshStandardMaterial {
*/
readonly isMeshPhysicalMaterial: true;

/**
* @default { 'STANDARD': '', 'PHYSICAL': '' }
*/
defines: { [key: string]: any };

/**
* @default 'MeshPhysicalMaterial'
*/
type: string;

/**
* @default { 'STANDARD': '', 'PHYSICAL': '' }
* @default 0
*/
defines: { [key: string]: any };
anisotropyRotation?: number;

/**
* @default 0
* @default null
*/
clearcoat: number;
anisotropyMap?: Texture | null;

/**
* @default null
Expand All @@ -95,20 +102,36 @@ export class MeshPhysicalMaterial extends MeshStandardMaterial {
*/
clearcoatNormalMap: Texture | null;

/**
* @default 1.5
*/
ior: number;

/**
* @default 0.5
*/
reflectivity: number;
get reflectivity(): number;
set reflectivity(reflectivity: number);

/**
* @default 1.5
* @default null
*/
ior: number;
iridescenceMap: Texture | null;

/**
* @default 0.0
* @default 1.3
*/
iridescenceIOR: number;

/**
* @default [100, 400]
*/
iridescenceThicknessRange: [number, number];

/**
* @default null
*/
sheen: number;
iridescenceThicknessMap: Texture | null;

/**
* @default Color( 0x000000 )
Expand All @@ -130,11 +153,6 @@ export class MeshPhysicalMaterial extends MeshStandardMaterial {
*/
sheenRoughnessMap: Texture | null;

/**
* @default 0
*/
transmission: number;

/**
* @default null
*/
Expand Down Expand Up @@ -165,58 +183,54 @@ export class MeshPhysicalMaterial extends MeshStandardMaterial {
*/
specularIntensity: number;

/**
* @default Color(1, 1, 1)
*/
specularColor: Color;

/**
* @default null
*/
specularIntensityMap: Texture | null;

/**
* @default null
* @default Color(1, 1, 1)
*/
specularColorMap: Texture | null;
specularColor: Color;

/**
* @default null
*/
iridescenceMap: Texture | null;

/**
* @default 1.3
*/
iridescenceIOR: number;
specularColorMap: Texture | null;

/**
* @default 0
*/
iridescence: number;
get anisotropy(): number;
set anisotropy(value: number);

/**
* @default [100, 400]
* @default 0
*/
iridescenceThicknessRange: [number, number];
get clearcoat(): number;
set clearcoat(value: number);

/**
* @default null
* @default 0
*/
iridescenceThicknessMap: Texture | null;
get iridescence(): number;
set iridescence(value: number);

/**
* @default 0
*/
anisotropy?: number;
get dispersion(): number;
set dispersion(value: number);

/**
* @default 0
* @default 0.0
*/
anisotropyRotation?: number;
get sheen(): number;
set sheen(value: number);

/**
* @default null
* @default 0
*/
anisotropyMap?: Texture | null;
get transmission(): number;
set transmission(value: number);
}
2 changes: 2 additions & 0 deletions types/three/src/renderers/webgl/WebGLPrograms.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export interface WebGLProgramParameters {
clearcoatNormalMap: boolean;
clearcoatRoughnessMap: boolean;

dispersion: boolean;

iridescence: boolean;
iridescenceMap: boolean;
iridescenceThicknessMap: boolean;
Expand Down

0 comments on commit 94aded5

Please sign in to comment.