Skip to main content

SphericalHarmonics3

Represents a third-order spherical harmonics (SH). Light probes use this class to encode lighting information.

Constructor

SphericalHarmonics3

function SphericalHarmonics3( ): void;  

Creates a new instance of SphericalHarmonics3.

Properties

coefficients

coefficients: Array;  

An array holding the (9) SH coefficients. A single coefficient is represented as an instance of Vector3.

isSphericalHarmonics3

isSphericalHarmonics3: Boolean;  

Read-only flag to check if a given object is of type SphericalHarmonics3.

Methods

add

function add( sh: SphericalHarmonics3 ): this;  

sh - The SH to add.

Adds the given SH to this instance.

addScaledSH

function addScaledSH( sh: SphericalHarmonics3, scale: Number ): this;  

sh - The SH to add.
scale - The scale factor.

A convenience method for performing .add() and .scale() at once.

clone

function clone( ): SphericalHarmonics3;  

Returns a new instance of SphericalHarmonics3 with equal coefficients.

copy

function copy( sh: SphericalHarmonics3 ): this;  

sh - The SH to copy.

Copies the given SH to this instance.

equals

function equals( sh: SphericalHarmonics3 ): Boolean;  

sh - The SH to compare with.

Returns true if the given SH and this instance have equal coefficients.

fromArray

function fromArray( array: Array, offset: Number ): this;  

array - The array holding the numbers of the SH coefficients.
offset - (optional) The array offset.

Sets the coefficients of this instance from the given array.

getAt

function getAt( normal: Vector3, target: Vector3 ): Vector3;  

normal - The normal vector (assumed to be unit length).
target - The result vector.

Returns the radiance in the direction of the given normal.

getIrradianceAt

function getIrradianceAt( normal: Vector3, target: Vector3 ): Vector3;  

normal - The normal vector (assumed to be unit length).
target - The result vector.

Returns the irradiance (radiance convolved with cosine lobe) in the direction of the given normal.

lerp

function lerp( sh: SphericalHarmonics3, alpha: Number ): this;  

sh - The SH to interpolate with.
alpha - The alpha factor.

Linear interpolates between the given SH and this instance by the given alpha factor.

scale

function scale( scale: Number ): this;  

scale - The scale factor.

Scales this SH by the given scale factor.

set

function set( coefficients: Array ): this;  

coefficients - An array of SH coefficients.

Sets the given SH coefficients to this instance.

toArray

function toArray( array: Array, offset: Number ): Array;  

array - (optional) The target array.
offset - (optional) The array offset.

Returns an array with the coefficients, or copies them into the provided array. The coefficients are represented as numbers.

zero

function zero( ): this;  

Sets all SH coefficients to 0.

Static Methods

getBasisAt

function getBasisAt( normal: Vector3, shBasis: Array ): undefined;  

normal - The normal vector (assumed to be unit length).
shBasis - The resulting SH basis.

Computes the SH basis for the given normal vector.

Source

src/math/SphericalHarmonics3.js