Skip to main content
Version: Phaser v4.2.1

BatchHandlerTri

This RenderNode renders textured triangles individually, rather than combining them into quads. It is used by the Mesh2D Game Object when its renderAsTriangles property is enabled, which suits dynamic topology that cannot be optimized into quads ahead of time.

It extends BatchHandlerQuad and reuses its shader, vertex layout, texture handling, and draw logic. The only differences are its configuration (three vertices and indices per instance, drawn as gl.TRIANGLES) and the batchTriangles method, which accepts vertex and index arrays directly, much like BatchHandlerTriFlat, but writes each vertex in the layout used by BatchHandlerQuad.

Constructor

new BatchHandlerTri(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.BatchHandlerQuad

Source: src/renderer/webgl/renderNodes/BatchHandlerTri.js#L14
Since: 4.2.0

Inherited Members​

From Phaser.Renderer.WebGL.RenderNodes.BatchHandler:

From Phaser.Renderer.WebGL.RenderNodes.BatchHandlerQuad:

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:


Public Members​

defaultConfig​

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

Description:

The default configuration object for this handler. It is the BatchHandlerQuad configuration with the instance shape and topology changed to draw individual triangles.

Overrides: Phaser.Renderer.WebGL.RenderNodes.BatchHandlerQuad#defaultConfig

Source: src/renderer/webgl/renderNodes/BatchHandlerTri.js#L54
Since: 4.2.0


Inherited Methods​

From Phaser.Renderer.WebGL.RenderNodes.BatchHandler:

From Phaser.Renderer.WebGL.RenderNodes.BatchHandlerQuad:

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:


Public Methods​

batchTriangles​

<instance> batchTriangles(drawingContext, gameObject, parentMatrix, transformerNode, vertices, indices, renderOptions)​

Description:

Adds a set of textured triangles to the batch. Each triangle is defined by a stride-4 entry in indices (a, b, c, page), where a, b, c index into vertices and page selects the texture source. Each vertex is a stride-4 entry in vertices (x, y, u, v).

The vertex positions are transformed into screen space by the supplied transformer node, then written into the vertex buffer in the same layout used by BatchHandlerQuad. This handling mirrors BatchHandlerTriFlat, but produces fully textured and tinted vertices.

This method is named batchTriangles rather than batch because its call signature differs from the standard quad batch handlers.

Parameters:

nametypeoptionaldescription
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.
gameObjectPhaser.GameObjects.Mesh2DNoThe Mesh2D Game Object being rendered.
parentMatrixPhaser.GameObjects.Components.TransformMatrix | undefinedNoThe parent matrix of the Game Object, if it is nested.
transformerNodePhaser.Renderer.WebGL.RenderNodes.TransformerVertexNoThe transformer node used to transform each vertex into screen space.
verticesArray.<number>NoThe vertex data, as a sequence of x, y, u, v with a step of 4.
indicesArray.<number>NoThe index data, as a sequence of a, b, c, page with a step of 4.
renderOptionsPhaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerQuadRenderOptionsNoThe render options for the batch, as resolved by the submitter node.

Source: src/renderer/webgl/renderNodes/BatchHandlerTri.js#L96
Since: 4.2.0