PIXI.Mesh
class Mesh extends PIXI.Container
Base mesh class.
This class empowers you to have maximum flexibility to render any kind of WebGL visuals you can think of. This class assumes a certain level of WebGL knowledge. If you know a bit this should abstract enough away to make your life easier!
Pretty much ALL WebGL can be broken down into the following:
- Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc..
- Shader - This is the shader that PixiJS will render the geometry with (attributes in the shader must match the geometry)
- State - This is the state of WebGL required to render the mesh.
Through a combination of the above elements you can render anything you want, 2D or 3D!
Constructor
new PIXI.Mesh(geometry: PIXI.Geometry, shader: PIXI.MeshMaterial, state: PIXI.State, drawMode: PIXI.DRAW_MODES) → {}
Name | Type | Attributes | Description |
---|---|---|---|
geometry | PIXI.Geometry |
The geometry the mesh will use. |
|
shader | PIXI.MeshMaterial |
The shader the mesh will use. |
|
state | PIXI.State |
<optional> |
The state that the WebGL context is required to be in to render the mesh if no state is provided, uses PIXI.State.for2d to create a 2D state for PixiJS. |
drawMode | PIXI.DRAW_MODES |
The drawMode, can be any of the PIXI.DRAW_MODES constants. |
Summary
Properties from Mesh
number |
The maximum number of vertices to consider batchable. Generally, the complexity of the geometry. |
PIXI.BLEND_MODES |
|
PIXI.DRAW_MODES |
The way the Mesh should be drawn, can be any of the PIXI.DRAW_MODES constants. |
PIXI.Geometry |
|
T |
Alias for PIXI.Mesh#shader. |
boolean |
|
PIXI.Shader | PIXI.MeshMaterial |
|
number |
|
number |
|
PIXI.State |
|
PIXI.Texture |
The texture that the Mesh uses. Null for non-MeshMaterial shaders |
number |
|
PIXI.Buffer |
|
PIXI.Buffer |
|
PIXI.Texture |
|
number |
|
HTMLCanvasElement |
|
Methods from Mesh
void |
Updates uv field based on from geometry uv's or batchUvs. |
void |
Updates vertexData field based on transform and vertices. |
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Properties inherited from Container
T[] |
|
number |
The height of the Container, setting this will actually modify the scale to achieve the value set. |
boolean |
|
boolean |
|
boolean |
Should children be sorted by zIndex at the next updateTransform call. |
number |
The width of the Container, setting this will actually modify the scale to achieve the value set. |
Properties inherited from DisplayObject
Methods inherited from Container
Methods inherited from DisplayObject
Inherited Events from Container
Inherited Events from DisplayObject
|
|
|
|
|
|
Capture phase equivalent of |
|
|
|
|
|
Capture phase equivalent of |
|
Fired when the mouse pointer is moved over a DisplayObject and its descendant's hit testing boundaries. |
|
Capture phase equivalent of |
|
Fired when the mouse pointer exits a DisplayObject and its descendants. |
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
Fired when the pointer is moved over a DisplayObject and its descendant's hit testing boundaries. |
|
Capture phase equivalent of |
|
Fired when the pointer leaves the hit testing boundaries of a DisplayObject and its descendants. |
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
|
|
Capture phase equivalent of |
|
PIXI.FederatedWheelEvent |
Fired when a the user scrolls with the mouse cursor over a DisplayObject. |
PIXI.FederatedWheelEvent |
Capture phase equivalent of |
Public Properties
static BATCHABLE_SIZE: number = 100
The maximum number of vertices to consider batchable. Generally, the complexity of the geometry.
blendMode: PIXI.BLEND_MODES = PIXI.BLEND_MODES.NORMAL;
The blend mode to be applied to the Mesh. Apply a value of
PIXI.BLEND_MODES.NORMAL
to reset the blend mode.
drawMode: PIXI.DRAW_MODES
The way the Mesh should be drawn, can be any of the PIXI.DRAW_MODES constants.
geometry: PIXI.Geometry
Includes vertex positions, face indices, normals, colors, UVs, and custom attributes within buffers, reducing the cost of passing all this data to the GPU. Can be shared between multiple Mesh objects.
roundPixels: boolean = false
If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation. Advantages can include sharper image quality (like text) and faster rendering on canvas. The main disadvantage is movement of objects may appear less smooth. To set the global default, change PIXI.settings.ROUND_PIXELS
shader: PIXI.Shader | PIXI.MeshMaterial
Represents the vertex and fragment shaders that processes the geometry and runs on the GPU. Can be shared between multiple Mesh objects.
state: PIXI.State
Represents the WebGL state the Mesh required to render, excludes shader and geometry. E.g., blend mode, culling, depth testing, direction of rendering triangles, backface, etc.
texture: PIXI.Texture
The texture that the Mesh uses. Null for non-MeshMaterial shaders
tint: number = 0xFFFFFF
The multiply tint applied to the Mesh. This is a hex value. A value of
0xFFFFFF
will remove any tint effect.
Null for non-MeshMaterial shaders
uvBuffer: PIXI.Buffer
To change mesh uv's, change its uvBuffer data and increment its _updateID.
verticesBuffer: PIXI.Buffer
To change mesh vertices, change its uvBuffer data and increment its _updateID. Incrementing _updateID is optional because most of Mesh objects do it anyway.
Protected Properties
protected _cachedTexture: PIXI.Texture = undefined
The cache texture is used to generate _tintedCanvas
.
protected _cachedTint: number = 16777215
Cached tint value so we can tell when the tint is changed.
protected _tintedCanvas: HTMLCanvasElement = undefined
Cached tinted texture.
Public Methods
calculateUvs() → {void}
Updates uv field based on from geometry uv's or batchUvs.
Type | Description |
---|---|
void |
calculateVertices() → {void}
Updates vertexData field based on transform and vertices.
Type | Description |
---|---|
void |
containsPoint(point: IPointData) → {boolean}
Tests if a point is inside this mesh. Works only for PIXI.DRAW_MODES.TRIANGLES.
Name | Type | Description |
---|---|---|
point | IPointData |
The point to test. |
Type | Description |
---|---|
boolean |
|
renderCanvas(renderer: PIXI.CanvasRenderer) → {void}
Renders the object using the Canvas renderer
Name | Type | Description |
---|---|---|
renderer | PIXI.CanvasRenderer |
The renderer |
Type | Description |
---|---|
void |
Protected Methods
protected _calculateBounds() → {void}
Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly.
Type | Description |
---|---|
void |
protected _render(renderer: PIXI.Renderer) → {void}
Standard renderer draw.
Name | Type | Description |
---|---|---|
renderer | PIXI.Renderer |
Instance to renderer. |
Type | Description |
---|---|
void |
protected _renderCanvas(renderer: PIXI.CanvasRenderer) → {void}
Renders the object using the Canvas renderer
Name | Type | Description |
---|---|---|
renderer | PIXI.CanvasRenderer |
The canvas renderer. |
Type | Description |
---|---|
void |
protected _renderDefault(renderer: PIXI.Renderer) → {void}
Standard non-batching way of rendering.
Name | Type | Description |
---|---|---|
renderer | PIXI.Renderer |
Instance to renderer. |
Type | Description |
---|---|
void |
protected _renderToBatch(renderer: PIXI.Renderer) → {void}
Rendering by using the Batch system.
Name | Type | Description |
---|---|---|
renderer | PIXI.Renderer |
Instance to renderer. |
Type | Description |
---|---|
void |