Skip to main content
Version: Phaser v4.2.1

SubmitterMeshToQuad

The SubmitterMeshToQuad RenderNode submits data for rendering a Mesh GameObject. It uses a BatchHandler to render the mesh as part of a batch. It is designed to maximize batch compatibility with regular quads, by combining adjacent triangles into quads where possible.

Performance-wise, this depends on the sequence of triangles in the mesh. Two sequential triangles sharing an edge will be combined into a quad, which renders as just 4 vertices instead of 6. But a triangle that can't combine will be rendered as a quad too, taking 4 vertices instead of 3. Try to arrange triangles so they can combine.

This node receives the drawing context, game object, and parent matrix. It also receives the transformer node from the node that invoked it. This allows the behavior to be configured by setting the appropriate nodes on the GameObject for individual tweaks, or on the invoking Renderer node for global changes.

Constructor

new SubmitterMeshToQuad(manager, [config])

Parameters

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

Scope: static

Extends

Phaser.Renderer.WebGL.RenderNodes.SubmitterQuad

Source: src/renderer/webgl/renderNodes/submitter/SubmitterMeshToQuad.js#L15
Since: 4.2.0

Inherited Members​

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:

From Phaser.Renderer.WebGL.RenderNodes.SubmitterQuad:


Public Members​

defaultConfig​

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

Description:

The default configuration for this RenderNode.

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

Source: src/renderer/webgl/renderNodes/submitter/SubmitterMeshToQuad.js#L63


Inherited Methods​

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:

From Phaser.Renderer.WebGL.RenderNodes.SubmitterQuad:


Public Methods​

_submitQuad​

<instance> _submitQuad(a, b, c, d, texturePage, drawingContext, gameObject, parentMatrix, transformerNode, [normalMap], [normalMapRotation])​

Description:

Submits a quad to the batch handler for rendering. This is used internally by the run method to submit a quad that is a combination of two triangles, or a single triangle using a degenerate triangle to pad quad alignment.

Parameters:

nametypeoptionaldescription
anumberNoThe index of the first vertex of the quad. This is the corner unique to the first triangle.
bnumberNoThe index of the second vertex of the quad. This is shared between triangles.
cnumberNoThe index of the third vertex of the quad. This is shared between triangles.
dnumberNoThe index of the fourth vertex of the quad. This is the corner unique to the second triangle.
texturePagenumberNoThe index of the texture source to use for the quad.
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.
gameObjectPhaser.GameObjects.GameObjectNoThe GameObject being rendered.
parentMatrixPhaser.GameObjects.Components.TransformMatrixNoThe parent matrix of the GameObject, if it is a nested game object.
transformerNodePhaser.Renderer.WebGL.RenderNodes.TransformerVertexNoThe transformer node used to transform the GameObject.
normalMapPhaser.Renderer.WebGL.Wrappers.WebGLTextureWrapperYesThe normal map texture to use for lighting. If omitted, the normal map texture of the GameObject will be used, or the default normal map texture of the renderer.
normalMapRotationnumberYesThe rotation of the normal map texture. If omitted, the rotation of the GameObject will be used.

Source: src/renderer/webgl/renderNodes/submitter/SubmitterMeshToQuad.js#L159
Since: 4.2.0


run​

<instance> run(drawingContext, gameObject, parentMatrix, transformerNode, [normalMap], [normalMapRotation])​

Description:

Processes the given GameObject and submits mesh vertex data to the appropriate batch handler for rendering.

If the mesh has a prebuilt ordered index list (Mesh2D#useOrderedIndices is true), it is used directly.

Otherwise, the method submits each triangle as a quad, synthesizing a degenerate triangle for the other half of the quad. This is inefficient and should be avoided, either by using the ordered index list, or by using the BatchHandlerTri render node.

The method also sets the render options for the GameObject, including the normal map texture and rotation.

Parameters:

nametypeoptionaldescription
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.
gameObjectPhaser.GameObjects.GameObjectNoThe GameObject being rendered.
parentMatrixPhaser.GameObjects.Components.TransformMatrixNoThe parent matrix of the GameObject, if it is a nested game object.
transformerNodePhaser.Renderer.WebGL.RenderNodes.TransformerVertexNoThe transformer node used to transform the GameObject.
normalMapPhaser.Renderer.WebGL.Wrappers.WebGLTextureWrapperYesThe normal map texture to use for lighting. If omitted, the normal map texture of the GameObject will be used, or the default normal map texture of the renderer.
normalMapRotationnumberYesThe rotation of the normal map texture. If omitted, the rotation of the GameObject will be used.

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

Source: src/renderer/webgl/renderNodes/submitter/SubmitterMeshToQuad.js#L75
Since: 4.2.0