t3d. SphericalHarmonics3

Primary reference: https://graphics.stanford.edu/papers/envmap/envmap.pdf Secondary reference: https://www.ppsloan.org/publications/StupidSH36.pdf 3-band SH defined by 9 coefficients.

Constructor

new SphericalHarmonics3()

Creates a new instance of SphericalHarmonics3.

Members

coefficients :Array

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

Methods

add(sh) → {t3d.SphericalHarmonics3}

Adds the given SH to this instance.
Parameters:
NameTypeDescription
sht3d.SphericalHarmonics3The SH to add.

addScaledSH(sh, s) → {t3d.SphericalHarmonics3}

A convenience method for performing .add() and .scale() at once.
Parameters:
NameTypeDescription
sht3d.SphericalHarmonics3The SH to add.
st3d.Vector3The scale factor.

clone() → {t3d.SphericalHarmonics3}

Returns a new instance of SphericalHarmonics3 with equal coefficients.

copy(sh) → {t3d.SphericalHarmonics3}

Copies the given SH to this instance.
Parameters:
NameTypeDescription
sht3d.SphericalHarmonics3The SH to compare with.

equals(sh) → {Boolean}

Returns true if the given SH and this instance have equal coefficients.
Parameters:
NameTypeDescription
sht3d.SphericalHarmonics3The SH to compare with.
Returns:
Type: 
Boolean

fromArray(array, offsetopt) → {t3d.SphericalHarmonics3}

Sets the coefficients of this instance from the given array.
Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<Number>The array holding the numbers of the SH coefficients.
offsetNumber<optional>
0The array offset.

getAt(normal, target) → {t3d.Vector3}

Returns the radiance in the direction of the given normal.
Parameters:
NameTypeDescription
normalt3d.Vector3The normal vector (assumed to be unit length).
targett3d.Vector3The result vector.
Returns:
Type: 
t3d.Vector3

getIrradianceAt(normal, target) → {t3d.Vector3}

Reference: https://graphics.stanford.edu/papers/envmap/envmap.pdf Returns the irradiance (radiance convolved with cosine lobe) in the direction of the given normal.
Parameters:
NameTypeDescription
normalt3d.Vector3The normal vector (assumed to be unit length).
targett3d.Vector3The result vector.
Returns:
Type: 
t3d.Vector3

lerp(sh, alpha) → {t3d.SphericalHarmonics3}

Linear interpolates between the given SH and this instance by the given alpha factor. Sets this coefficients vector to be the vector linearly interpolated between v1 and v2 where alpha is the percent distance along the line connecting the two vectors - alpha = 0 will be v1, and alpha = 1 will be v2.
Parameters:
NameTypeDescription
sht3d.SphericalHarmonics3The SH to interpolate with.
alphaNumberThe alpha factor.

scale(s) → {t3d.SphericalHarmonics3}

Multiply the s to this SphericalHarmonics3.
Parameters:
NameTypeDescription
sNumberThe scale factor.

set(coefficients) → {t3d.SphericalHarmonics3}

Set this sphericalHarmonics3 value.
Parameters:
NameTypeDescription
coefficientsArray.<t3d.Vector3>An array of SH coefficients.

toArray(arrayopt, offsetopt) → {Array.<Number>}

Returns an array with the coefficients, or copies them into the provided array. The coefficients are represented as numbers.
Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<Number><optional>
The target array.
offsetNumber<optional>
0The array offset.
Returns:
Type: 
Array.<Number>

zero() → {t3d.SphericalHarmonics3}

Sets all SH coefficients to 0.

(static) getBasisAt(normal, array)

Computes the SH basis for the given normal vector.
Parameters:
NameTypeDescription
normalt3d.Vector3The normal vector (assumed to be unit length).
arrayArray.<Number>The resulting SH basis.