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
| name | type | optional | description |
|---|---|---|---|
| manager | Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager | No | The manager that owns this RenderNode. |
| config | Phaser.Types.Renderer.WebGL.RenderNodes.SubmitterQuadConfig | Yes | The configuration object for this RenderNode. |
Scope: static
Extends
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:
| name | type | optional | description |
|---|---|---|---|
| a | number | No | The index of the first vertex of the quad. This is the corner unique to the first triangle. |
| b | number | No | The index of the second vertex of the quad. This is shared between triangles. |
| c | number | No | The index of the third vertex of the quad. This is shared between triangles. |
| d | number | No | The index of the fourth vertex of the quad. This is the corner unique to the second triangle. |
| texturePage | number | No | The index of the texture source to use for the quad. |
| drawingContext | Phaser.Renderer.WebGL.DrawingContext | No | The current drawing context. |
| gameObject | Phaser.GameObjects.GameObject | No | The GameObject being rendered. |
| parentMatrix | Phaser.GameObjects.Components.TransformMatrix | No | The parent matrix of the GameObject, if it is a nested game object. |
| transformerNode | Phaser.Renderer.WebGL.RenderNodes.TransformerVertex | No | The transformer node used to transform the GameObject. |
| normalMap | Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | Yes | The 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. |
| normalMapRotation | number | Yes | The 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:
| name | type | optional | description |
|---|---|---|---|
| drawingContext | Phaser.Renderer.WebGL.DrawingContext | No | The current drawing context. |
| gameObject | Phaser.GameObjects.GameObject | No | The GameObject being rendered. |
| parentMatrix | Phaser.GameObjects.Components.TransformMatrix | No | The parent matrix of the GameObject, if it is a nested game object. |
| transformerNode | Phaser.Renderer.WebGL.RenderNodes.TransformerVertex | No | The transformer node used to transform the GameObject. |
| normalMap | Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | Yes | The 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. |
| normalMapRotation | number | Yes | The 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