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>

Regrow the deck around the current cell, after any grid work already in flight has finished.

Returns​

Promise<void>


setSeed​

▸ setSeed(seed): Promise<void>

Regrow the deck from a new seed. A World calls this with the server's world seed once INIT delivers it, so all of its clients see one deck.

Parameters​

NameType
seednumber

Returns​

Promise<void>


update​

▸ update(position, driftClock?): 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.
driftClock?numberSeconds on a clock every viewer of this deck shares (World.sharedClock). Given, the deck's drift is a pure function of it, so two clients looking up see the same cloud in the same place; without it the deck drifts by this instance's own frame time.

Returns​

void