SphericalHarmonics3

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

Constructor

SphericalHarmonics3()

Creates a new instance of SphericalHarmonics3.

Properties

.coefficients : Array

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

.isSphericalHarmonics3 : Boolean

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

Methods

.add(sh : SphericalHarmonics3) → this

sh — the SH to add.

Adds the given SH to this instance.

.addScaledSH(sh : SphericalHarmonics3, scale : Float) → this

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

.clone() → SphericalHarmonics3

Returns a new instance of SphericalHarmonics3 with equal coefficients.

.copy(sh : SphericalHarmonics3) → this

sh — the SH to copy.

Copies the given SH to this instance.

.equals(sh : SphericalHarmonics3) → Boolean

sh — the SH to compare with.

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

.fromArray(array : Array, offset : Float) → this

Sets the coefficients of this instance from the given array.

.getAt(normal : Vector3, target : Vector3) → Vector3

Returns the radiance in the direction of the given normal.

.getIrradianceAt(normal : Vector3, target : Vector3) → Vector3

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

.lerp(sh : SphericalHarmonics3, alpha : Float) → this

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

.scale(scale : Float) → this

scale — the scale factor.

Scales this SH by the given scale factor.

.set(coefficients : Array) → this

coefficients — an array of SH coefficients.

Sets the given SH coefficients to this instance.

.toArray(array : Array, offset : Float) → Array

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

.zero() → this

Sets all SH coefficients to 0.

Static Methods

.getBasisAt(normal : Vector3, shBasis : Array)

Computes the SH basis for the given normal vector.

Source

For more info on how to obtain the source code of this module see this page.