Environment

1.2.3+

Environment lighting properties

.constructor(scene: Scene) ⇒ Environment 

Constructor

ParamTypeDescription
sceneScene

.coefficients: Float32Array 

Equivalent to getCoefficients.

Note: Prefer to use getCoefficients for performance.

.coefficients 

Equivalent to setCoefficients.

.intensity: number 

Get intensity of environment lighting.

Incoming environment lighting is multiplied by this factor.

.intensity 

Set intensity of environment lighting.

.tint: Float32Array 

Equivalent to getTint.

Note: Prefer to use getTint for performance.

.tint 

Equivalent to setTint.

.getCoefficients<T>(out: T) ⇒ T 

.getCoefficients() ⇒ Float32Array

Get spherical harmonics coefficients for indirect lighting.

These are 9 spherical harmonics coefficients for indirect diffuse lighting.

Returns: Spherical harmonics coefficients. Always 27 elements, every consecutive 3 values representing the red, green, blue components of a single coefficient. Unused/empty coefficients at the end can be 0.

ParamTypeDescription
outTPreallocated array to write into, to avoid garbage, otherwise will allocate a new Float32Array.
Template ParamType Definition
Textends NumberArray

.getTint<T>(out: T) ⇒ T 

.getTint() ⇒ Float32Array

Get tint for environment lighting.

Incoming environment lighting color channels are multiplied by these values.

Returns: Tint values - red, green, blue.

ParamTypeDescription
outTPreallocated array to write into, to avoid garbage, otherwise will allocate a new Float32Array.
Template ParamType Definition
Textends NumberArray

.setCoefficients(v: Readonly<NumberArray>) ⇒ void 

Set spherical harmonics coefficients for indirect lighting.

Note: The scene must have been packaged with environment lighting on for this to take effect.

Example: Coefficients from WebXR Lighting Estimation can be passed as follows:

1const probe = await engine.xr.session.requestLightProbe();
2const estimate = engine.xr.frame.getLightEstimate(probe);
3scene.environment.coefficients = estimate.sphericalHarmonicsCoefficients;
ParamTypeDescription
vReadonly<NumberArray>A set of spherical harmonics coefficients, every 3 elements constituting the red/green/blue components of a single coefficient. Should be 0, 3, 12 or 27 array elements. Passing an empty array disables indirect lighting.

.setTint(v: Readonly<NumberArray>) ⇒ void 

Set tint for environment lighting.

ParamTypeDescription
vReadonly<NumberArray>New tint value. Expects a 3 component array.