Skip to main content
Version: Phaser v4.0.0

Camera

A RenderNode responsible for executing the full rendering pipeline for a single Phaser Camera. It orchestrates every stage of camera output: filling the background color, rendering the list of visible children via the ListCompositor, applying post-render effects (flash and fade), and then compositing the result into the parent drawing context.

When the camera requires isolation — because it has a non-opaque alpha, active internal or external filter chains, or forceComposite is set — the node allocates a temporary framebuffer from the drawing context pool and renders into that instead of directly into the parent context. Internal filters are applied to the camera contents before compositing, while external filters expand the coverage area and are applied after the camera output has been placed into the scene coordinate space. The final composited image is then batched back to the parent context using the BatchHandlerQuadSingle node, with the camera's alpha and pixel-rounding settings respected.

Constructor

new Camera(manager)

Parameters

nametypeoptionaldescription
managerPhaser.Renderer.WebGL.RenderNodes.RenderNodeManagerNoThe manager that owns this RenderNode.

Scope: static

Extends

Phaser.Renderer.WebGL.RenderNodes.RenderNode

Source: src/renderer/webgl/renderNodes/Camera.js#L21
Since: 4.0.0

Inherited Members

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:


Public Members

batchHandlerQuadSingleNode

batchHandlerQuadSingleNode: Phaser.Renderer.WebGL.RenderNodes.BatchHandlerQuad

Description:

The RenderNode that handles batching quads. This is used when a camera is rendering to a framebuffer, and the framebuffer needs to be drawn to the parent context.

Source: src/renderer/webgl/renderNodes/Camera.js#L54
Since: 4.0.0


fillCameraNode

fillCameraNode: Phaser.Renderer.WebGL.RenderNodes.FillCamera

Description:

The RenderNode that handles filling the camera with a flat color. This is used to render the camera background, flash effects, and fade effects.

Source: src/renderer/webgl/renderNodes/Camera.js#L65
Since: 4.0.0


listCompositorNode

listCompositorNode: Phaser.Renderer.WebGL.RenderNodes.ListCompositor

Description:

The RenderNode that handles rendering lists of children.

Source: src/renderer/webgl/renderNodes/Camera.js#L76
Since: 4.0.0


Inherited Methods

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:


Public Methods

run

<instance> run(drawingContext, children, camera, [parentTransformMatrix], [forceFramebuffer], [renderStep])

Description:

Executes the full rendering pipeline for the given camera. This includes drawing the camera background color, rendering all child Game Objects via the ListCompositor, applying any post-render flash and fade effects, and then compositing the result into the parent drawing context.

If the camera requires a framebuffer (due to active filters, a non-opaque alpha, or forceComposite being set), a temporary context is allocated from the drawing context pool. Internal filters are applied to the camera contents within that framebuffer, and external filters are applied after the output has been transformed into scene space. The final image is batched back to the parent context, with camera alpha and pixel-rounding applied as appropriate.

Parameters:

nametypeoptionaldefaultdescription
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe context currently in use.
childrenArray.<Phaser.GameObjects.GameObject>NoThe list of children to render.
cameraPhaser.Cameras.Scene2D.CameraNoCurrent Camera.
parentTransformMatrixPhaser.GameObjects.Components.TransformMatrixYesThis transform matrix is defined if the camera is focused on a filtered object.
forceFramebufferbooleanYesfalseShould the camera always draw to a new framebuffer? This will also be activated if the camera has filters enabled.
renderStepnumberYes0Which step of the rendering process is this? This is the index of the currently running function in a list of functions.

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

Source: src/renderer/webgl/renderNodes/Camera.js#L97
Since: 4.0.0