Skip to main content

Sky consists of both a large dodecahedron used to render the 3-leveled sky gradient and a CanvasBox that renders custom sky textures ( for a sky box) within the dodecahedron sky.

Example

// Create the sky texture.
const sky = new VOXELIZE.Sky();

// Load a texture and paint it to the top of the sky.
world.loader.addTexture(ExampleImage, (texture) => {
sky.paint("top", texture);
})

// Add the sky to the scene.
world.add(sky);

// Update the sky per frame.
sky.update(camera.position);

Sky

Hierarchy​

Constructors​

constructor​

• new Sky(options?, glow?): Sky

Create a new sky instance.

Parameters​

NameTypeDescription
optionsPartial<SkyOptions>-
glowSkyGlowUniformsThe glow's uniform objects, to share them with the fog.

Returns​

Sky

Overrides​

CanvasBox.constructor

Properties​

boxLayers​

• boxLayers: BoxLayer[] = []

The inner layers of the canvas box.

Inherited from​

CanvasBox.boxLayers


depth​

• depth: number

The depth of the canvas box.

Inherited from​

CanvasBox.depth


glow​

• Readonly glow: SkyGlowUniforms

The sky's own light (see SkyGlowUniforms). The world shares these objects with the fog of every surface it draws.


height​

• height: number

The height of the canvas box.

Inherited from​

CanvasBox.height


options​

• options: CanvasBoxOptions & SkyOptions

Parameters for creating a canvas box.

Overrides​

CanvasBox.options


shadingData​

• shadingData: SkyShadingCycleData[] = []


uBottomColor​

• uBottomColor: ValueUniform<Color>

The bottom color of the sky gradient. Change this by calling Sky.setBottomColor.


uCelestialDirection​

• uCelestialDirection: ValueUniform<Vector3>

The celestial disc's direction, colour and light, for the refracted disc the dome draws inside the Snell window.


uDirectSunlight​

• uDirectSunlight: ValueUniform<1>

The share of the disc's light that reaches the world as a beam (the chunk renderer's directSunlight): a veiled disc is not drawn.


uMiddleColor​

• uMiddleColor: ValueUniform<Color>

The middle color of the sky gradient. Change this by calling Sky.setMiddleColor.


uSkyOffset​

• uSkyOffset: ValueUniform<0>


uSunColor​

• uSunColor: ValueUniform<Color>


uSunlightIntensity​

• uSunlightIntensity: ValueUniform<1>


uTextureBloomIntensity​

• uTextureBloomIntensity: ValueUniform<number>


uTextureBloomThreshold​

• uTextureBloomThreshold: ValueUniform<number>


uTopColor​

• uTopColor: ValueUniform<Color>

The top color of the sky gradient. Change this by calling Sky.setTopColor.


uUnderwaterAmbient​

• uUnderwaterAmbient: ValueUniform<Color>

The ambient water color the sky gradient fades toward while the camera is submerged.


uUnderwaterFade​

• uUnderwaterFade: ValueUniform<0>

How much of the sky gradient is replaced by the underwater ambient, driven by camera depth.


uUnderwaterSubmerged​

• uUnderwaterSubmerged: ValueUniform<0>

1 while the camera is under water: the dome then shows the sky only through the Snell window, refracted, and the water's in-scatter everywhere else.


uVoidOffset​

• uVoidOffset: ValueUniform<1200>


width​

• width: number

The width of the canvas box.

Inherited from​

CanvasBox.width

Accessors​

boxMaterials​

• get boxMaterials(): Map<string, MeshBasicNodeMaterial>

The first layer of the canvas box.

Returns​

Map<string, MeshBasicNodeMaterial>

Inherited from​

CanvasBox.boxMaterials


shadowBody​

• get shadowBody(): EntityShadowBody

The body this canvas box is shaded as part of (its first layer's). Null if receiveShadows is false.

Returns​

EntityShadowBody

Inherited from​

CanvasBox.shadowBody

Methods​

dispose​

▸ dispose(): void

Frees the box's layers (geometry, face canvases and materials, atlas) and the gradient dome's geometry and shader. Call once the sky has left the scene for good.

Returns​

void

Overrides​

CanvasBox.dispose


getBottomColor​

▸ getBottomColor(): Color

Get the current bottom color of the sky gradient. This can be used as shader uniforms's value.

Returns​

Color

The current bottom color of the sky gradient.


getMiddleColor​

▸ getMiddleColor(): Color

Get the current middle color of the sky gradient. This can be used as shader uniforms's value. For instance, this can be used to set the color of the fog in the world.

Returns​

Color

The current middle color of the sky gradient.


getTopColor​

▸ getTopColor(): Color

Get the current top color of the sky gradient. This can be used as shader uniforms's value.

Returns​

Color

The current top color of the sky gradient.


paint​

▸ paint(side, art, layer?): void

Add art to the canvas(s) of this box layer.

Parameters​

NameTypeDefault valueDescription
sideBoxSides | BoxSides[]undefinedThe side(s) of the box layer to draw on.
artColor | Texture<unknown, TextureEventMap> | ArtFunctionundefinedThe art or art function to draw on the box layer's side.
layernumber0The layer to draw on.

Returns​

void

Inherited from​

CanvasBox.paint


setShadingPhases​

▸ setShadingPhases(data): void

Parameters​

NameType
dataSkyShadingCycleData[]

Returns​

void


setShadowBody​

▸ setShadowBody(body): void

Shades every layer as part of body (a character's).

Parameters​

NameType
bodyEntityShadowBody

Returns​

void

Inherited from​

CanvasBox.setShadowBody


update​

▸ update(position, time, timePerDay): void

Update the position of the sky box to the camera's x/z position, and lerp the sky gradient colors.

Parameters​

NameTypeDescription
positionVector3The new position to center the sky at.
timenumber-
timePerDaynumber-

Returns​

void