Skip to main content
Version: Phaser v4.2.0

TransformerVertex

A RenderNode that computes and stores the screen-space position of a single vertex each time it is run.

During its run call, this node applies the camera view matrix (adjusted for the game object's scroll factors), any parent container matrix, and the game object's own position, rotation, and scale into a single final transform matrix. It then projects the vertex position through that matrix and writes the result back to the vertex position, ready for consumption by the subsequent submitter node.

Constructor

new TransformerVertex(manager, [config])

Parameters

nametypeoptionaldescription
managerPhaser.Renderer.WebGL.RenderNodes.RenderNodeManagerNoThe manager that owns this RenderNode.
configobjectYesThe configuration object for this RenderNode.

Scope: static

Extends

Phaser.Renderer.WebGL.RenderNodes.RenderNode

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

Inherited Members​

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:


Inherited Methods​

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:


Public Methods​

run​

<instance> run(drawingContext, gameObject, parentMatrix, vertex)​

Description:

Computes the final screen-space position of the given vertex for the given GameObject and stores it in the vertex.

The method builds the complete transform by combining the camera view matrix (modified by the game object's scroll factors), an optional parent container matrix, and the game object's own position, rotation, and scale. If vertex rounding is required, the resulting values are snapped to the nearest integer.

Parameters:

nametypeoptionaldescription
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.
gameObjectPhaser.GameObjects.GameObjectNoThe GameObject being rendered.
parentMatrixPhaser.GameObjects.Components.TransformMatrixNoThis transform matrix is defined if the game object is nested.
vertexPhaser.Math.Vector2NoThe vertex to transform.

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

Source: src/renderer/webgl/renderNodes/transformer/TransformerVertex.js#L79
Since: 4.0.0


setupMatrix​

<instance> setupMatrix(drawingContext, gameObject, [parentMatrix])​

Description:

Builds the final transform matrix for the given GameObject and caches it, along with whether transformed vertices should be rounded. This combines the camera view matrix (modified by the game object's scroll factors), an optional parent container matrix, and the game object's own position, rotation, and scale.

Call this once before transforming a batch of vertices with transformVertex, since the matrix is constant for all vertices of a single GameObject. This avoids rebuilding the matrix for every vertex.

Parameters:

nametypeoptionaldescription
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.
gameObjectPhaser.GameObjects.GameObjectNoThe GameObject being rendered.
parentMatrixPhaser.GameObjects.Components.TransformMatrixYesThis transform matrix is defined if the game object is nested.

Returns: Phaser.GameObjects.Components.TransformMatrix - The cached transform matrix.

Source: src/renderer/webgl/renderNodes/transformer/TransformerVertex.js#L105
Since: 4.2.0


transformVertex​

<instance> transformVertex(vertex)​

Description:

Projects a single vertex through the matrix built by the most recent setupMatrix call, writing the result back to the vertex. If vertex rounding is required, the values are snapped to the nearest integer.

Parameters:

nametypeoptionaldescription
vertexPhaser.Math.Vector2NoThe vertex to transform.

Returns: Phaser.Math.Vector2 - The transformed vertex.

Source: src/renderer/webgl/renderNodes/transformer/TransformerVertex.js#L158
Since: 4.2.0