Skip to content

SkyProvider ​

Connects SkySystem to Three.js Water Pro, providing reflections, fog color, and sun lighting.

Construction ​

typescript
// Cloud-free sky, including celestial discs and configured stars.
water.setSky(sky.createSkyProvider());

// Cloud reflections via an automatically-managed baked equirect env map.
water.setSky(sky.createSkyProvider({ envMap: true }));

Create a provider with sky.createSkyProvider().

Options ​

envMap ​

Type: boolean | SkyEnvironmentOptions
Default: false
Units: -

Creates a SkyEnvironment for cloud reflections. When false, reflections still include the atmosphere, sun and moon discs, and any configured star panorama, but omit all cloud layers.

Pass a SkyEnvironmentOptions object instead of true to forward width, cloudMarchSteps, and the rest to the bake.

When enabled, createSkyProvider() performs an initial bake before returning. Creating another cloud-enabled provider disposes the previous system-owned environment map.

Methods ​

Water Pro calls these methods automatically.

createFogSampler() ​

Creates a linear HDR sky sampler for distant fog. The result does not include the sun disc.

Takes no parameters.

Returns: TSL Fn([dir]) => vec3 — dir is a Node<vec3> world direction, normalized internally.


createReflectionSampler() ​

Creates a prefiltered linear HDR reflection sampler. The baked sun disc is filtered with the rest of the environment.

Takes no parameters.

Returns: TSL Fn([dir]) => vec3 — dir is a Node<vec3> reflection direction, normalized internally.


dispose() ​

Releases a provider-owned cloud-free bake. A cloud-enabled environment map created by SkySystem is released by sky.dispose() or by the next cloud-enabled createSkyProvider() call.

Takes no parameters.

Returns: void


followCamera(camera) ​

Moves the environment-map capture point to the camera's X and Z while preserving Y. For a provider created without envMap, this method also updates the bake. Otherwise, sky.update() updates it.

ParamTypeRequiredDescription
cameraTHREE.CamerarequiredThe camera to track.

Returns: void


getEnvironmentTexture() ​

Returns the environment texture. Assign it to scene.environment or sample it through TSL's pmremTexture().

Takes no parameters.

Returns: THREE.Texture — the equirect bake. Replaced when the bake's resolution changes; compare by reference and rebind on change.


getMeshes() ​

Returns the sky's backdrop meshes, cloud layer included, so Water Pro can exclude them from refraction sampling. They are already in your scene — SkySystem.create added them.

Takes no parameters.

Returns: THREE.Object3D[]


getSun() ​

Returns the live sun uniforms, so Water Pro's lighting tracks an animated sun.

Takes no parameters.

Returns: { color, direction, intensity } — uniform nodes off sky.sun. Writes through .value reach both the water and the sky.


setActive(visible) ​

Enables or suspends sky updates for underwater rendering.

ParamTypeRequiredDescription
visiblebooleanrequiredfalse freezes the env map and switches the cloud layer off while the camera is underwater; true resumes both.

Returns: void

Example ​

typescript
const sky = await SkySystem.create({ renderer, camera, scene });
const water = await WaterSystem.create(renderer, scene, camera, "medium");

const provider = sky.createSkyProvider({ envMap: true });
water.setSky(provider);

Create the provider once and reuse it. Creating another cloud-enabled provider disposes the previous system-owned environment map.

See Also ​

Commercial License - All Rights Reserved.