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(); }
}

Constructors
constructor
• new BlockOverlayEffect(world, camera): BlockOverlayEffect
Create a new block overlay effect.
Parameters
| Name | Type | Description |
|---|---|---|
world | World<any> | The world that the effect is in. |
camera | PerspectiveCamera | The camera that the effect is applied to. |
Returns
Properties
camera
• camera: PerspectiveCamera
The camera that the effect is applied to.
uniforms
• Readonly uniforms: Object
Type declaration
| Name | Type |
|---|---|
opacity | ValueUniform<0> |
overlay | ValueUniform<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
| Name | Type | Description |
|---|---|---|
idOrName | string | number | The block ID or name to add an overlay for. |
color | Color | The color of the overlay. |
opacity | number | The 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
| Name | Type |
|---|---|
color | Vec4Node |
Returns
update
▸ update(): void
Call once a frame: follows the block the camera is in.
Returns
void