SphericalHarmonics3

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

  • Primary reference: https://graphics.stanford.edu/papers/envmap/envmap.pdf

  • Secondary reference: https://www.ppsloan.org/publications/StupidSH36.pdf

Instances are mutable and not thread-safe; confine an instance to a single thread, exactly as in three.js.

The isSphericalHarmonics3 duck-typing flag is intentionally dropped. Use is SphericalHarmonics3 instead.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

An array holding the (9) SH coefficients.

Functions

Link copied to clipboard

Adds the given SH to this instance.

Link copied to clipboard

A convenience method for performing add and scale at once.

Link copied to clipboard

Returns a new spherical harmonics with copied values from this instance.

Link copied to clipboard

Copies the values of the given spherical harmonics to this instance.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Structural equality: true when other is a SphericalHarmonics3 whose nine coefficients are all equal (via Vector3.equals, so NaN != NaN).

Link copied to clipboard
fun fromArray(array: DoubleArray, offset: Int = 0): SphericalHarmonics3

Sets the SH coefficients of this instance from the given array.

Link copied to clipboard
fun getAt(normal: Vector3, target: Vector3): Vector3

Returns the radiance in the direction of the given normal.

Link copied to clipboard
fun getIrradianceAt(normal: Vector3, target: Vector3): Vector3

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

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

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

Link copied to clipboard

Scales this SH by the given scale factor.

Link copied to clipboard
fun set(coefficients: Array<Vector3>): SphericalHarmonics3

Sets the given SH coefficients to this instance by copying the values.

Link copied to clipboard
fun toArray(array: MutableList<Double> = mutableListOf(), offset: Int = 0): MutableList<Double>

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

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

Sets all SH coefficients to 0.