Skip to main content
Version: Phaser v4.0.0

BatchHandlerPointLight

A batch handler RenderNode that renders PointLight Game Objects using WebGL.

Each PointLight is submitted as a textured quad (4 vertices, 6 indices) into a shared vertex buffer. The dedicated point-light shader computes the radial light falloff per fragment, using the light's world position, radius, attenuation factor, colour, and intensity. Multiple lights are batched together and flushed in a single draw call when the batch is full or when the renderer needs to switch context.

This handler uses no textures; it passes an empty texture array to the draw call because the lighting is calculated entirely in the fragment shader.

Constructor

new BatchHandlerPointLight(manager, [config])

Parameters

nametypeoptionaldescription
managerPhaser.Renderer.WebGL.RenderNodes.RenderNodeManagerNoThe manager that owns this RenderNode.
configPhaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfigYesThe configuration object for this handler.

Scope: static

Extends

Phaser.Renderer.WebGL.RenderNodes.BatchHandler

Source: src/renderer/webgl/renderNodes/BatchHandlerPointLight.js#L12
Since: 4.0.0

Inherited Members

From Phaser.Renderer.WebGL.RenderNodes.BatchHandler:

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:


Public Members

defaultConfig

defaultConfig: Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfig

Description:

The default configuration for this handler.

Source: src/renderer/webgl/renderNodes/BatchHandlerPointLight.js#L55
Since: 4.0.0


Inherited Methods

From Phaser.Renderer.WebGL.RenderNodes.BatchHandler:

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:


Public Methods

batch

<instance> batch(drawingContext, light, xTL, yTL, xBL, yBL, xTR, yTR, xBR, yBR, lightX, lightY)

Description:

Add a light to the batch.

Parameters:

nametypeoptionaldescription
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.
lightPhaser.GameObjects.PointLightNoThe light to add to the batch.
xTLnumberNoThe top-left x-coordinate of the light.
yTLnumberNoThe top-left y-coordinate of the light.
xBLnumberNoThe bottom-left x-coordinate of the light.
yBLnumberNoThe bottom-left y-coordinate of the light.
xTRnumberNoThe top-right x-coordinate of the light.
yTRnumberNoThe top-right y-coordinate of the light.
xBRnumberNoThe bottom-right x-coordinate of the light.
yBRnumberNoThe bottom-right y-coordinate of the light.
lightXnumberNoThe world x-coordinate of the light's centre, used by the shader to calculate radial falloff.
lightYnumberNoThe world y-coordinate of the light's centre, used by the shader to calculate radial falloff.

Overrides: Phaser.Renderer.WebGL.RenderNodes.BatchHandler#batch

Source: src/renderer/webgl/renderNodes/BatchHandlerPointLight.js#L213
Since: 4.0.0


run

<instance> run(drawingContext)

Description:

Draw then empty the current batch.

This method is called automatically, by either this node or the manager, when the batch is full, or when something else needs to be rendered.

Parameters:

nametypeoptionaldescription
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.

Overrides: Phaser.Renderer.WebGL.RenderNodes.BatchHandler#run

Source: src/renderer/webgl/renderNodes/BatchHandlerPointLight.js#L163
Since: 4.0.0


setupUniforms

<instance> setupUniforms(drawingContext)

Description:

Update the uniforms for the current shader program.

This method is called automatically when the batch is run.

Parameters:

nametypeoptionaldescription
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.

Source: src/renderer/webgl/renderNodes/BatchHandlerPointLight.js#L131
Since: 4.0.0