LightSource

LightSource

A specialized subclass of the PointSource abstraction which is used to control the rendering of light sources.

Constructor

new LightSource(object)

Parameters:
Name Type Description
object AmbientLight | Token

The light-emitting object that generates this light source

Extends

Members

(protected) _flags :Object.<string, boolean>

Overrides:

Boolean flags which control whether certain behaviors of the source must be enforced

Type:
  • Object.<string, boolean>

active :boolean

Overrides:

A flag for whether this source is currently active (rendered) or not

Type:
  • boolean

animation :LightAnimationConfiguration

The animation configuration applied to this source

Type:

background :PIXI.Container

The light or darkness container for this source

Type:
  • PIXI.Container

BLUR_STRENGTH :number

Strength of the blur for light source edges

Type:
  • number

coloration :PIXI.Container

This visible color container for this source

Type:
  • PIXI.Container

data :LightSourceData

Overrides:

The object of data which configures how the source is rendered

Type:

fovTexture :PIXI.RenderTexture

The rendered field-of-vision texture for the source for use within shaders.

Type:
  • PIXI.RenderTexture

GEOMETRY :PIXI.Geometry

Overrides:

The default Geometry stored in the GPU for all Point Source meshes.

Type:
  • PIXI.Geometry

illumination :PIXI.Container

The light or darkness container for this source

Type:
  • PIXI.Container

isDarkness :boolean

Internal flag for whether this is a darkness source

Type:
  • boolean

limited :boolean

Overrides:

Is the angle of emission for this source limited?

Type:
  • boolean

los :PointSourcePolygon

Overrides:

The restricted line-of-sight polygon that is generated by the origin and radius of this source.

Type:

losMask :PIXI.Graphics

Overrides:

A Graphics object with pre-computed geometry used for masking based on line-of-sight.

Type:
  • PIXI.Graphics

object :PlaceableObject

Overrides:

The object responsible for this source.

Type:

preview :boolean

To know if a light source is a preview or not. False by default.

Type:
  • boolean

radius :number

Overrides:

The maximum radius of emission for this source

Type:
  • number

ratio :number

The ratio of dim:bright as part of the source radius

Type:
  • number

sourceType :string

Overrides:

The type of source represented by this data structure. Each subclass must implement this attribute.

Type:
  • string

x :number

Overrides:

The x-coordinate of the point source origin.

Type:
  • number

y :number

Overrides:

The y-coordinate of the point source origin.

Type:
  • number

Methods

(protected) _createMesh(shaderCls) → {PIXI.Mesh}

Overrides:

Create a new Mesh for this source using a provided shader class

Parameters:
Name Type Description
shaderCls function

The subclass of AdaptiveLightingShader being used for this Mesh

Returns:

The created Mesh

Type
PIXI.Mesh

(protected) _drawRenderTextureContainer() → {PIXI.Container}

Overrides:

Create a container that should be rendered to the fov texture for this source

Returns:

The drawn container for the render texture

Type
PIXI.Container

(protected) _renderTexture() → {PIXI.RenderTexture}

Overrides:

Render this source to a texture which can be used for masking and blurring.

Returns:
Type
PIXI.RenderTexture

(protected) _updateMesh(mesh) → {PIXI.Mesh}

Overrides:

Update the position and size of the mesh each time it is drawn.

Parameters:
Name Type Description
mesh PIXI.Mesh

The Mesh being updated

Returns:

The updated Mesh

Type
PIXI.Mesh

animate(dt)

Animate the PointSource, if an animation is enabled and if it currently has rendered containers.

Parameters:
Name Type Description
dt number

Delta time

animatePulse(dt, speed, intensity, reverse)

A basic "pulse" animation which expands and contracts.

Parameters:
Name Type Description
dt number

Delta time

speed number

The animation speed, from 1 to 10

intensity number

The animation intensity, from 1 to 10

reverse boolean

Is the animation reversed?

animateTime(dt, speed, intensity, reverse)

Emanate waves of light from the source origin point

Parameters:
Name Type Description
dt number

Delta time

speed number

The animation speed, from 1 to 10

intensity number

The animation intensity, from 1 to 10

reverse boolean

Is the animation reversed?

animateTorch(dt, speed, intensity)

A torch animation where the luminosity and coloration decays each frame and is revitalized by flashes

Parameters:
Name Type Description
dt number

Delta time

speed number

The animation speed, from 1 to 10

intensity number

The animation intensity, from 1 to 10

containsPoint(point) → {boolean}

Overrides:

A point is contained with the area of the source if it is within both the FOV circle as well as the LOS polygon.

Parameters:
Name Type Description
point Point

The point to test

Returns:

Is the point contained

Type
boolean

destroy()

Overrides:

Steps that must be performed when the base source is destroyed.

drawBackground() → {PIXI.Container}

Draw the display of this source for background container.

Returns:

The rendered light container

Type
PIXI.Container

drawColor() → {PIXI.Container}

Draw and return a container used to depict the visible color tint of the light source on the LightingLayer

Returns:

An updated color container for the source

Type
PIXI.Container

drawLight() → {PIXI.Container}

Draw the display of this source for the darkness/light container of the SightLayer.

Returns:

The rendered light container

Type
PIXI.Container

drawMeshes() → {Object.<string, PIXI.Mesh>}

Render the containers used to represent this light source within the LightingLayer

Returns:
Type
Object.<string, PIXI.Mesh>

getPowerOf2Size() → {number}

Overrides:

Get power of 2 size pertaining to base-source radius and performance modes

Returns:

The computed power of 2 size

Type
number

initialize(data) → {LightSource}

Overrides:
  • PointSource#initialize

Initialize the source with provided object data.

Parameters:
Name Type Description
data object

Initial data provided to the point source

Returns:

A reference to the initialized source

Type
LightSource