Options
All
  • Public
  • Public/Protected
  • All
Menu

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

param object

The light-emitting object that generates this light source

Hierarchy

Index

Constructors

Properties

The object type for a Light Source. This is a Scene in the case of a global light source This is an AmbientLight placeable object when the source is provided by an AmbientLightDocument This is a Token placeable object when the source is provided by a TokenDocument

background: any

The light or darkness container for this source

illumination: any

The light or darkness container for this source

coloration: any

This visible color container for this source

The computed polygon which expresses the area of effect of this light source

data: any = {}

The object of data which configures how the source is rendered

isDarkness: boolean = false

Internal flag for whether this is a darkness source

preview: boolean = false

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

ratio: number

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

animation: any

The animation configuration applied to this source

colorRGB: any
radius: number

The maximum radius of emission for this source

_noise: SmoothNoise
active: boolean = false

A flag for whether this source is currently rendered or not.

losMask: any = ...

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

_flags: Object = {}

Additional information which controls whether certain behaviors of the source must be enforced

_meshesInit: boolean = false

To track meshes initialization

_resetUniforms: { background: boolean; illumination: boolean; coloration: boolean } = ...

Track which uniforms need to be reset

Type declaration

  • background: boolean
  • illumination: boolean
  • coloration: boolean
_shutdown: { illumination: boolean } = ...

To track if a source is temporarily shutdown to avoid glitches

Type declaration

  • illumination: boolean
#visibility: { background: boolean; illumination: boolean; coloration: boolean; any: boolean } = ...

Record the current visibility state of this LightSource and its respective channels.

Type declaration

  • background: boolean
  • illumination: boolean
  • coloration: boolean
  • any: boolean
sourceType: string = "light"

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

EDGE_OFFSET: number = -8

The offset in pixels applied to create soft edges.

_appearanceKeys: string[] = ...

Keys in the LightSourceData structure which, when modified, change the appearance of the light

Accessors

  • get disabled(): boolean
  • To know if a light source is completely disabled.

    Returns boolean

  • get isAnimated(): boolean
  • override

    Returns boolean

  • get x(): number
  • The x-coordinate of the point source origin.

    Returns number

  • get y(): number
  • The y-coordinate of the point source origin.

    Returns number

  • get sourceType(): string
  • The type of source represented by this data structure.

    Returns string

  • get elevation(): number
  • The elevation of the object bound to this base source, if any. Returns the canvas primary background elevation otherwise.

    Returns number

Methods

  • Initialize the source with provided object data.

    Parameters

    • data: any = {}

      Initial data provided to the point source.

    Returns LightSource

    A reference to the initialized source.

  • _getPolygonConfiguration(): { type: string; angle: any; density: number; radius: number; rotation: any; source: LightSource }
  • _createMeshes(): void
  • destroy(): void
  • Steps that must be performed when the base source is destroyed.

    Returns void

  • refreshSource(): void
  • updateVisibility(): boolean
  • Update the visible state of the component channels of this LightSource.

    Returns boolean

    Is any channel of this light source active?

  • drawMeshes(): { background: Mesh; light: Mesh; color: Mesh }
  • Render the containers used to represent this light source within the LightingLayer

    Returns { background: Mesh; light: Mesh; color: Mesh }

    • background: Mesh
    • light: Mesh
    • color: Mesh
  • drawBackground(): any
  • Create a Mesh for the background component of this source which will be added to CanvasBackgroundEffects.

    Returns any

    The background mesh for this LightSource, or null

  • drawLight(): any
  • Create a Mesh for the illumination component of this source which will be added to CanvasIlluminationEffects.

    Returns any

    The illumination mesh for this LightSource, or null

  • drawColor(): any
  • Create a Mesh for the coloration component of this source which will be added to CanvasColorationEffects.

    Returns any

    The coloration mesh for this LightSource, or null

  • animateTorch(dt: number, [options={}]?: { speed: number; intensity: number; reverse: boolean }): void
  • An animation with flickering ratio and light intensity

    Parameters

    • dt: number

      Delta time

    • [options={}]: { speed: number; intensity: number; reverse: boolean } = {}

      Additional options which modify the flame animation

      • speed: number
      • intensity: number
      • reverse: boolean

    Returns void

  • animateFlickering(dt: number, [options={}]?: { speed: number; intensity: number; amplification: number; reverse: boolean }): void
  • An animation with flickering ratio and light intensity

    Parameters

    • dt: number

      Delta time

    • [options={}]: { speed: number; intensity: number; amplification: number; reverse: boolean } = {}

      Additional options which modify the flame animation

      • speed: number
      • intensity: number
      • amplification: number
      • reverse: boolean

    Returns void

  • animatePulse(dt: number, [options={}]?: { speed: number; intensity: number; reverse: boolean }): void
  • A basic "pulse" animation which expands and contracts.

    Parameters

    • dt: number

      Delta time

    • [options={}]: { speed: number; intensity: number; reverse: boolean } = {}

      Additional options which modify the pulse animation

      • speed: number
      • intensity: number
      • reverse: boolean

    Returns void

  • animateTime(dt: number, [options={}]?: { speed: number; intensity: number; reverse: boolean }): void
  • Emanate waves of light from the source origin point

    Parameters

    • dt: number

      Delta time

    • [options={}]: { speed: number; intensity: number; reverse: boolean } = {}

      Additional options which modify the animation

      • speed: number
      • intensity: number
      • reverse: boolean

    Returns void

  • Test whether this LightSource provides visibility to see a certain target object.

    Parameters

    Returns boolean

    Is the target object visible to this source?

  • Can this LightSource theoretically detect a certain object based on its properties? This check should not consider the relative positions of either object, only their state.

    Parameters

    Returns boolean

    Can the target object theoretically be detected by this vision source?

  • containsPoint(point: Point): boolean
  • A point is contained with the area of the source if it is within both the FOV circle and the LOS polygon.

    Parameters

    • point: Point

      The point to test

    Returns boolean

    Is the point contained

  • animate(dt: number): any
  • Animate the BaseSource, if an animation is enabled and if it currently has rendered containers.

    Parameters

    • dt: number

      Delta time.

    Returns any

  • _initializeData(data: any): any
  • Initialize the PointSource with new input data

    Parameters

    • data: any

      Initial data provided to the light source

    Returns any

    The changes compared to the prior data

  • _initializeFlags(): void
  • Record internal status flags which modify how the light source is rendered

    Returns void

  • _updateUniforms(): void
  • Update all layer uniforms.

    Returns void

  • _updateLosGeometry(polygon: Polygon): void
  • Create or update the source geometry with a polygon shape Triangulate the form and create buffers

    Parameters

    Returns void

  • _initializeMeshes(polygon: Polygon): void
  • _createMesh(shaderCls: Function): Mesh
  • Create a new Mesh for this source using a provided shader class

    Parameters

    • shaderCls: Function

      The subclass of AdaptiveLightingShader being used for this Mesh

    Returns Mesh

    The created Mesh

  • _updateMesh(mesh: Mesh): Mesh
  • Update the position and size of the mesh each time it is drawn.

    Parameters

    • mesh: Mesh

      The Mesh being updated

    Returns Mesh

    The updated Mesh

  • _initializeShaders(): void
  • Initialize the shaders used for this source, swapping to a different shader if the animation has changed.

    Returns void

  • _initializeBlending(): void
  • Initialize the blend mode and vertical sorting of this source relative to others in the container.

    Returns void

  • _isSuppressed(): boolean
  • Test whether this light source is currently suppressed?

    Returns boolean

  • _updateColorationUniforms(): void
  • Update shader uniforms by providing data from this PointSource

    Returns void

  • _updateIlluminationUniforms(): void
  • Update shader uniforms by providing data from this PointSource

    Returns void

  • _updateBackgroundUniforms(): void
  • Update shader uniforms by providing data from this PointSource

    Returns void

  • Update shader uniforms shared by all shader types

    Parameters

    Returns void

  • _mapLuminosity(lum: number): number
  • Map luminosity value to exposure value luminosity[-1 , 0 [ => Darkness => map to exposure ] 0, 1] luminosity[ 0 , 0.5[ => Light => map to exposure [-0.5, 0[ luminosity[ 0.5, 1 ] => Light => map to exposure [ 0, 1]

    Parameters

    • lum: number

      The luminosity value

    Returns number

    The exposure value