Skip to main content

Class: Clouds

A class that generates and manages clouds. Clouds are essentially a 2D grid of cells that contain further sub-grids of cloud blocks. This 2D grid move altogether in the +x direction, and is generated at the start asynchronously using web workers using simplex noise.

When using Clouds.update, new clouds will be generated if the center of the grid does not match the passed in position.

Clouds

Hierarchy

  • Group

    Clouds

Constructors

constructor

new Clouds(options?): Clouds

Create a new Clouds instance, initializing it asynchronously automatically.

Parameters

NameTypeDescription
optionsPartial<CloudsOptions>Parameters used to create a new Clouds instance.

Returns

Clouds

Overrides

Group.constructor

Properties

baseColorHSL

baseColorHSL: Object

The authored cloud colour, kept because the day/night cycle overwrites the live uniform every frame and would otherwise have nothing to scale from.

Type declaration

NameType
hnumber
lnumber
snumber

isInitialized

isInitialized: boolean = false

Whether or not are the clouds done generating.


locatedCell

locatedCell: Coords2

The cell that this cloud is currently centered around.


material

material: ShaderMaterial

The shard shader material used to render the clouds.


meshes

meshes: Mesh<BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>, Material | Material[], Object3DEventMap>[][] = []

A 2D array of cloud meshes. The first dimension is the x-axis, and the second dimension is the z-axis.


options

options: CloudsOptions

Parameters used to create a new Clouds instance.


xOffset

xOffset: number = 0

The x-offset of the clouds since initialization. This is determined by diffing the locatedCell and the position passed into Clouds.update.


zOffset

zOffset: number = 0

The z-offset of the clouds since initialization. This is determined by diffing the locatedCell and the position passed into Clouds.update.

Methods

dispose

dispose(): void

Returns

void


reset

reset(): Promise<void>

Reset the clouds to their initial state.

Returns

Promise<void>


update

update(position): void

Move the clouds to centering around the passed in position. If there aren't enough cloud cells at any side, new clouds are generated.

Parameters

NameTypeDescription
positionVector3The new position that this cloud should be centered around.

Returns

void