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:
Name | Type | Description |
---|---|---|
sh | t3d. | The SH to add. |
Returns:
- Type:
- t3d.
SphericalHarmonics3
addScaledSH(sh, s) → {t3d.SphericalHarmonics3}
A convenience method for performing .add() and .scale() at once.
Parameters:
Name | Type | Description |
---|---|---|
sh | t3d. | The SH to add. |
s | t3d. | The scale factor. |
Returns:
- Type:
- t3d.
SphericalHarmonics3
clone() → {t3d.SphericalHarmonics3}
Returns a new instance of SphericalHarmonics3 with equal coefficients.
Returns:
- Type:
- t3d.
SphericalHarmonics3
copy(sh) → {t3d.SphericalHarmonics3}
Copies the given SH to this instance.
Parameters:
Name | Type | Description |
---|---|---|
sh | t3d. | The SH to compare with. |
Returns:
- Type:
- t3d.
SphericalHarmonics3
equals(sh) → {Boolean}
Returns true if the given SH and this instance have equal coefficients.
Parameters:
Name | Type | Description |
---|---|---|
sh | t3d. | The SH to compare with. |
Returns:
- Type:
- Boolean
fromArray(array, offsetopt) → {t3d.SphericalHarmonics3}
Sets the coefficients of this instance from the given array.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array | Array.<Number> | The array holding the numbers of the SH coefficients. | ||
offset | Number | <optional> | 0 | The array offset. |
Returns:
- Type:
- t3d.
SphericalHarmonics3
getAt(normal, target) → {t3d.Vector3}
Returns the radiance in the direction of the given normal.
Parameters:
Name | Type | Description |
---|---|---|
normal | t3d. | The normal vector (assumed to be unit length). |
target | t3d. | The 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:
Name | Type | Description |
---|---|---|
normal | t3d. | The normal vector (assumed to be unit length). |
target | t3d. | The 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:
Name | Type | Description |
---|---|---|
sh | t3d. | The SH to interpolate with. |
alpha | Number | The alpha factor. |
Returns:
- Type:
- t3d.
SphericalHarmonics3
scale(s) → {t3d.SphericalHarmonics3}
Multiply the s to this SphericalHarmonics3.
Parameters:
Name | Type | Description |
---|---|---|
s | Number | The scale factor. |
Returns:
- Type:
- t3d.
SphericalHarmonics3
set(coefficients) → {t3d.SphericalHarmonics3}
Set this sphericalHarmonics3 value.
Parameters:
Name | Type | Description |
---|---|---|
coefficients | Array.<t3d.Vector3> | An array of SH coefficients. |
Returns:
- Type:
- t3d.
SphericalHarmonics3
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:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array | Array.<Number> | <optional> | The target array. | |
offset | Number | <optional> | 0 | The array offset. |
Returns:
- Type:
- Array.<Number>
zero() → {t3d.SphericalHarmonics3}
Sets all SH coefficients to 0.
Returns:
- Type:
- t3d.
SphericalHarmonics3
(static) getBasisAt(normal, array)
Computes the SH basis for the given normal vector.
Parameters:
Name | Type | Description |
---|---|---|
normal | t3d. | The normal vector (assumed to be unit length). |
array | Array.<Number> | The resulting SH basis. |