Skip to main content

A class that allows mesh to dynamically change brightness based on the voxel light level at their position.

By default, VOXELIZE.NameTag is ignored by this effect.

Example

// Create a light shined effect manager.
const lightShined = new VOXELIZE.LightShined();

// Add the effect to a mesh.
lightShined.add(character);

// In the render loop, update the effect.
lightShined.update();

Example

Constructors​

constructor​

• new LightShined(world, options?): LightShined

Construct a light shined effect manager.

Parameters​

NameTypeDescription
worldWorld<any>The world that the effect is applied to.
optionsPartial<LightShinedOptions>Parameters to customize the effect.

Returns​

LightShined

Properties​

ignored​

• ignored: Set<IgnoredType>

A list of types that are ignored by this effect.


list​

• list: Set<Object3D<Object3DEventMap>>

A list of meshes that are effected by this effect.


options​

• options: LightShinedOptions

Parameters to customize the effect.


world​

• world: World<any>

The world that the effect is applied to.

Methods​

add​

▸ add(obj): void

Add an object to be affected by this effect.

Parameters​

NameTypeDescription
objObject3D<Object3DEventMap>A THREE.JS object to be shined on.

Returns​

void


clearPositionOverride​

▸ clearPositionOverride(obj): void

Parameters​

NameType
objObject3D<Object3DEventMap>

Returns​

void


dispose​

▸ dispose(): void

Let go of every shined object: their subtree listeners, the light uniforms and the copies made for them. Materials it set up that outlive it keep a hook that holds nothing of the effect, and the next effect to meet them lights them again.

Returns​

void


ignore​

▸ ignore(...types): void

Parameters​

NameType
...typesIgnoredType[]

Returns​

void


lightAt​

▸ lightAt(position): Color

The light an object standing at position is shaded with, composed the way the chunk shader lights the block there (capped at maxBrightness). The returned colour is reused: copy it to keep it. Instanced entities light their instances from this.

Parameters​

NameType
positionVector3

Returns​

Color


remove​

▸ remove(obj): void

Remove an object from being affected by this effect

Parameters​

NameTypeDescription
objObject3D<Object3DEventMap>The object to be removed from the effect.

Returns​

void


setPositionOverride​

▸ setPositionOverride(obj, position): void

Parameters​

NameType
objObject3D<Object3DEventMap>
positionVector3

Returns​

void


update​

▸ update(): void

Update the light shined effect. This fetches the light level at the position of each object and recursively updates the brightness of the object.

This should be called in the render loop.

Returns​

void