Skip to content

Commit

Permalink
WebGLRenderer: Add support for rotating env maps. (#838)
Browse files Browse the repository at this point in the history
* WebGLRenderer: Add support for rotating env maps.

* Format
  • Loading branch information
Methuselah96 committed Feb 23, 2024
1 parent 0f3994c commit 1ca7ca3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions types/three/src/materials/MeshBasicMaterial.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Combine } from "../constants.js";
import { Color, ColorRepresentation } from "../math/Color.js";
import { Euler } from "../math/Euler.js";
import { Texture } from "../textures/Texture.js";
import { Material, MaterialParameters } from "./Material.js";

/**
* parameters is an object with one or more properties defining the material's appearance.
*/
Expand All @@ -17,6 +19,7 @@ export interface MeshBasicMaterialParameters extends MaterialParameters {
alphaMap?: Texture | null | undefined;
fog?: boolean | undefined;
envMap?: Texture | null | undefined;
envMapRotation?: Euler | undefined;
combine?: Combine | undefined;
reflectivity?: number | undefined;
refractionRatio?: number | undefined;
Expand Down Expand Up @@ -86,6 +89,11 @@ export class MeshBasicMaterial extends Material {
*/
envMap: Texture | null;

/**
* The rotation of the environment map in radians. Default is `(0,0,0)`.
*/
envMapRotation: Euler;

/**
* @default THREE.MultiplyOperation
*/
Expand Down
7 changes: 7 additions & 0 deletions types/three/src/materials/MeshLambertMaterial.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Combine, NormalMapTypes } from "../constants.js";
import { Color, ColorRepresentation } from "../math/Color.js";
import { Euler } from "../math/Euler.js";
import { Vector2 } from "../math/Vector2.js";
import { Texture } from "../textures/Texture.js";
import { Material, MaterialParameters } from "./Material.js";
Expand All @@ -25,6 +26,7 @@ export interface MeshLambertMaterialParameters extends MaterialParameters {
specularMap?: Texture | null | undefined;
alphaMap?: Texture | null | undefined;
envMap?: Texture | null | undefined;
envMapRotation?: Euler | undefined;
combine?: Combine | undefined;
reflectivity?: number | undefined;
refractionRatio?: number | undefined;
Expand Down Expand Up @@ -152,6 +154,11 @@ export class MeshLambertMaterial extends Material {
*/
envMap: Texture | null;

/**
* The rotation of the environment map in radians. Default is `(0,0,0)`.
*/
envMapRotation: Euler;

/**
* @default THREE.MultiplyOperation
*/
Expand Down
7 changes: 7 additions & 0 deletions types/three/src/materials/MeshPhongMaterial.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Combine, NormalMapTypes } from "../constants.js";
import { Color, ColorRepresentation } from "../math/Color.js";
import { Euler } from "../math/Euler.js";
import { Vector2 } from "../math/Vector2.js";
import { Texture } from "../textures/Texture.js";
import { Material, MaterialParameters } from "./Material.js";
Expand Down Expand Up @@ -29,6 +30,7 @@ export interface MeshPhongMaterialParameters extends MaterialParameters {
specularMap?: Texture | null | undefined;
alphaMap?: Texture | null | undefined;
envMap?: Texture | null | undefined;
envMapRotation?: Euler | undefined;
combine?: Combine | undefined;
reflectivity?: number | undefined;
refractionRatio?: number | undefined;
Expand Down Expand Up @@ -165,6 +167,11 @@ export class MeshPhongMaterial extends Material {
*/
envMap: Texture | null;

/**
* The rotation of the environment map in radians. Default is `(0,0,0)`.
*/
envMapRotation: Euler;

/**
* @default THREE.MultiplyOperation
*/
Expand Down
7 changes: 7 additions & 0 deletions types/three/src/materials/MeshStandardMaterial.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NormalMapTypes } from "../constants.js";
import { Color, ColorRepresentation } from "../math/Color.js";
import { Euler } from "../math/Euler.js";
import { Vector2 } from "../math/Vector2.js";
import { Texture } from "../textures/Texture.js";
import { Material, MaterialParameters } from "./Material.js";
Expand Down Expand Up @@ -28,6 +29,7 @@ export interface MeshStandardMaterialParameters extends MaterialParameters {
metalnessMap?: Texture | null | undefined;
alphaMap?: Texture | null | undefined;
envMap?: Texture | null | undefined;
envMapRotation?: Euler | undefined;
envMapIntensity?: number | undefined;
wireframe?: boolean | undefined;
wireframeLinewidth?: number | undefined;
Expand Down Expand Up @@ -170,6 +172,11 @@ export class MeshStandardMaterial extends Material {
*/
envMap: Texture | null;

/**
* The rotation of the environment map in radians. Default is `(0,0,0)`.
*/
envMapRotation: Euler;

/**
* @default 1
*/
Expand Down
1 change: 1 addition & 0 deletions types/three/src/renderers/shaders/UniformsLib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const UniformsLib: {
};
envmap: {
envMap: IUniform<unknown>;
envMapRotation: IUniform<Matrix3>;
flipEnvMap: IUniform<number>;
reflectivity: IUniform<number>;
ior: IUniform<number>;
Expand Down
13 changes: 13 additions & 0 deletions types/three/src/scenes/Scene.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Object3D } from "../core/Object3D.js";
import { Material } from "../materials/Material.js";
import { Color } from "../math/Color.js";
import { Euler } from "../math/Euler.js";
import { CubeTexture } from "../textures/CubeTexture.js";
import { Texture } from "../textures/Texture.js";
import { FogBase } from "./Fog.js";
Expand Down Expand Up @@ -68,13 +69,25 @@ export class Scene extends Object3D {
*/
background: Color | Texture | CubeTexture | null;

/**
* The rotation of the background in radians. Only influences environment maps assigned to {@link .background}.
* Default is `(0,0,0)`.
*/
backgroundRotation: Euler;

/**
* Sets the environment map for all physical materials in the scene.
* However, it's not possible to overwrite an existing texture assigned to {@link THREE.MeshStandardMaterial.envMap | MeshStandardMaterial.envMap}.
* @defaultValue `null`
*/
environment: Texture | null;

/**
* The rotation of the environment map in radians. Only influences physical materials in the scene when
* {@link .environment} is used. Default is `(0,0,0)`.
*/
environmentRotation: Euler;

/**
* Convert the {@link Scene} to three.js {@link https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 | JSON Object/Scene format}.
* @param meta Object containing metadata such as textures or images for the scene.
Expand Down

0 comments on commit 1ca7ca3

Please sign in to comment.