SphericalHarmonics3

优质
小牛编辑
133浏览
2023-12-01

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.

Methods

.add ( sh : SphericalHarmonics3 ) : SphericalHarmonics3

sh - The SH to add.

Adds the given SH to this instance.

.addScaledSH ( sh : SphericalHarmonics3, scale : Number ) : SphericalHarmonics3

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

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

.clone () : SphericalHarmonics3

Returns a new instance of SphericalHarmonics3 with equal coefficients.

.copy ( sh : SphericalHarmonics3 ) : SphericalHarmonics3

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 : Number ) : SphericalHarmonics3

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 ( 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 ( 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 ( sh : SphericalHarmonics3, alpha : Number ) : SphericalHarmonics3

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 ( scale : Number ) : SphericalHarmonics3

sh - The scale factor.

Scales this SH by the given scale factor.

.set ( coefficients : Array ) : SphericalHarmonics3

coefficients - An array of SH coefficients.

Sets the given SH coefficients to this instance.

.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 () : SphericalHarmonics3

Sets all SH coefficients to 0.

Static Methods

.getBasisAt ( normal : Vector3, shBasis : Array ) : void

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