Renderer · class
LightField
Explained in Hello world.
class LightField implements DriftLightVolumesimport { LightField } from '@driftengine/core';Constructor
new
constructor(lights: readonly LightFieldSource[], options: LightFieldOptions)| Parameter | Type | Description |
|---|---|---|
lights | readonly LightFieldSource[] | |
options | LightFieldOptions |
Properties
| Name | Type | Description |
|---|---|---|
layoutreadonly | LightFieldLayout | |
atlasSizereadonly | readonly [number, number, number] | Texels on each axis of the atlas. |
atlasBricksreadonly | readonly [number, number, number] | Bricks on each axis of the atlas, which the shader needs to find a brick's corner. |
atlasreadonly | Uint16Array | The atlas as half floats, four channels a texel, x fastest. |
bandreadonly | number | Metres over which exact and summed light crossfade. |
occludedreadonly | boolean | Whether a distance field occludes this field's light. |
fadeSecreadonly | number | Seconds the summed light fades in over once whole; zero is at once. |
scale | number | The summed light's brightness, for a scene that dims all its lamps at once: dawn, a switch. |
Accessors
| Name | Type | Description |
|---|---|---|
readyget | boolean | Whether every brick has been baked. |
progressget | number | How much of the bake is done, 0 to 1, for a loading screen. |
radiusget | number | The radius, in metres from centre, inside which lights are shaded exactly. |
presenceget | number | How much of the summed light is in the frame, 0 until the field is whole, then up to 1. |
centreget | Float32Array | Where the frame's choice was centred, which the shader measures the radius from. |
emptyget | boolean | |
indexDimsget | readonly [number, number, number] | |
indexget | Uint32Array | |
sampleOriginget | readonly [number, number, number] | |
signedSpacingget | number |
Methods
atlasCorner
atlasCorner(brick: number): [number, number, number]The texel at which brick brick's light block starts; its direction block is 4 along x.
| Parameter | Type | Description |
|---|---|---|
brick | number |
bake
bake(bricks: number): numberBake up to bricks more bricks into the atlas, and answer how many were baked.
| Parameter | Type | Description |
|---|---|---|
bricks | number |
takeBaked
takeBaked(): { from: number; to: number; }The bricks baked since the last call, for a backend to upload.
follow
follow(complete: number, x: number, y: number, z: number, dtSec: number): voidFollow the frame's choice: complete from the selection, centred at (x, y, z). The radius
shrinks at once, because a pixel inside it that a left-out light reaches would be shaded
short, and grows back slowly, because a pixel it has not reached yet takes the summed light,
which is only less exact. While nothing is summed the radius simply follows.
| Parameter | Type | Description |
|---|---|---|
complete | number | |
x | number | |
y | number | |
z | number | |
dtSec | number |