Skip to main content

The block overlay effect is used to add a color blend whenever the camera is inside certain types of blocks.

A screen effect: apply takes the frame's colour node and returns it with the overlay mixed in; call update once a frame.

Example

const overlay = new VOXELIZE.BlockOverlayEffect(world, camera);
overlay.addOverlay("water", new THREE.Color("#5F9DF7"), 0.05);
// An effect of a `@voxelize/postprocessing` effect pass:
class Overlay extends Effect {
fragment({ color }) { return overlay.apply(color); }
update() { overlay.update(); }
}

Block overlay effect

Constructors​

constructor​

• new BlockOverlayEffect(world, camera): BlockOverlayEffect

Create a new block overlay effect.

Parameters​

NameTypeDescription
worldWorld<any>The world that the effect is in.
cameraPerspectiveCameraThe camera that the effect is applied to.

Returns​

BlockOverlayEffect

Properties​

camera​

• camera: PerspectiveCamera

The camera that the effect is applied to.


uniforms​

• Readonly uniforms: Object

Type declaration​

NameType
opacityValueUniform<0>
overlayValueUniform<Color>

world​

• world: World<any>

The world that the effect is in.

Methods​

addOverlay​

▸ addOverlay(idOrName, color, opacity): void

Add a new overlay to a certain voxel type.

Parameters​

NameTypeDescription
idOrNamestring | numberThe block ID or name to add an overlay for.
colorColorThe color of the overlay.
opacitynumberThe opacity of the overlay.

Returns​

void


apply​

▸ apply(color): Vec4Node

The frame's colour with the overlay of the block the camera is in.

Parameters​

NameType
colorVec4Node

Returns​

Vec4Node


update​

▸ update(): void

Call once a frame: follows the block the camera is in.

Returns​

void