new Face(vertex1, vertex2, vertex3)
Parameters:
| Name | Type | Description |
|---|---|---|
vertex1 |
Phaser.Geom.Mesh.Vertex | The first vertex of the Face. |
vertex2 |
Phaser.Geom.Mesh.Vertex | The second vertex of the Face. |
vertex3 |
Phaser.Geom.Mesh.Vertex | The third vertex of the Face. |
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 34)
Members
-
alpha :number
-
Set the alpha value of this Face.
Each vertex is given the same value. If you need to adjust the alpha on a per-vertex basis then use the
Vertex.alphaproperty instead.When getting the alpha of this Face, it will return an average of the alpha component of all three vertices.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 487)
-
bounds :Phaser.Geom.Rectangle
-
The bounds of this Face.
Be sure to call the
Face.updateBoundsmethod before using this property.Type:
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 86)
-
<readonly> depth :number
-
The depth of this Face, which is an average of the z component of all three vertices.
The depth is calculated based on the transformed z value, not the local one.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 520)
-
vertex1 :Phaser.Geom.Mesh.Vertex
-
The first vertex in this Face.
Type:
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 59)
-
vertex2 :Phaser.Geom.Mesh.Vertex
-
The second vertex in this Face.
Type:
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 68)
-
vertex3 :Phaser.Geom.Mesh.Vertex
-
The third vertex in this Face.
Type:
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 77)
-
x :number
-
The x coordinate of this Face, based on the in center position of the Face.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 441)
-
y :number
-
The y coordinate of this Face, based on the in center position of the Face.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 464)
Methods
-
contains(x, y [, calcMatrix])
-
Checks if the given coordinates are within this Face.
You can optionally provide a transform matrix. If given, the Face vertices will be transformed first, before being checked against the coordinates.
Parameters:
Name Type Argument Description xnumber The horizontal position to check.
ynumber The vertical position to check.
calcMatrixPhaser.GameObjects.Components.TransformMatrix <optional>
Optional transform matrix to apply to the vertices before comparison.
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 170)
Returns:
trueif the coordinates lay within this Face, otherwisefalse.- Type
- boolean
-
destroy()
-
Destroys this Face and nulls the references to the vertices.
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 543)
-
getInCenter( [local])
-
Calculates and returns the in-center position of this Face.
Parameters:
Name Type Argument Default Description localboolean <optional>
true Return the in center from the un-transformed vertex positions (
true), or transformed? (false)- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 108)
Returns:
A Vector2 containing the in center position of this Face.
- Type
- Phaser.Math.Vector2
-
isCounterClockwise(z)
-
Checks if the vertices in this Face are orientated counter-clockwise, or not.
It checks the transformed position of the vertices, not the local one.
Parameters:
Name Type Description znumber The z-axis value to test against. Typically the
Mesh.modelPosition.z.- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 243)
Returns:
trueif the vertices in this Face run counter-clockwise, otherwisefalse.- Type
- boolean
-
isInView(camera, hideCCW, z, alpha, a, b, c, d, e, f, roundPixels)
-
Checks if this Face is within the view of the given Camera.
This method is called in the
MeshWebGLRendererfunction. It performs the following tasks:First, the
Vertex.updatemethod is called on each of the vertices. This populates them with the new translated values, updating theirtx,tyandtaproperties.Then it tests to see if this face is visible due to the alpha values, if not, it returns.
After this, if
hideCCWis set, it callsisCounterClockwiseand returns if not.Finally, it will update the
Face.boundsbased on the newly translated vertex values and return the results of an intersection test between the bounds and the camera world view rectangle.Parameters:
Name Type Description cameraPhaser.Cameras.Scene2D.Camera The Camera to check against.
hideCCWboolean Test the counter-clockwise orientation of the verts?
znumber The Cameras z position, used in the CCW test.
alphanumber The alpha of the parent object.
anumber The parent transform matrix data a component.
bnumber The parent transform matrix data b component.
cnumber The parent transform matrix data c component.
dnumber The parent transform matrix data d component.
enumber The parent transform matrix data e component.
fnumber The parent transform matrix data f component.
roundPixelsboolean Round the vertex position or not?
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 344)
Returns:
trueif this Face can be seen by the Camera.- Type
- boolean
-
load(F32, U32, offset, textureUnit, alpha, a, b, c, d, e, f, roundPixels)
-
Loads the data from this Vertex into the given Typed Arrays.
Parameters:
Name Type Description F32Float32Array A Float32 Array to insert the position, UV and unit data in to.
U32Uint32Array A Uint32 Array to insert the color and alpha data in to.
offsetnumber The index of the array to insert this Vertex to.
textureUnitnumber The texture unit currently in use.
alphanumber The alpha of the parent object.
anumber The parent transform matrix data a component.
bnumber The parent transform matrix data b component.
cnumber The parent transform matrix data c component.
dnumber The parent transform matrix data d component.
enumber The parent transform matrix data e component.
fnumber The parent transform matrix data f component.
roundPixelsboolean Round the vertex position or not?
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 266)
Returns:
The new vertex index array offset.
- Type
- number
-
transformCoordinatesLocal(transformMatrix, width, height, cameraZ)
-
Transforms all Face vertices by the given matrix, storing the results in their
vx,vyandvzproperties.Parameters:
Name Type Description transformMatrixPhaser.Math.Matrix4 The transform matrix to apply to this vertex.
widthnumber The width of the parent Mesh.
heightnumber The height of the parent Mesh.
cameraZnumber The z position of the MeshCamera.
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 296)
Returns:
This Face instance.
-
translate(x [, y])
-
Translates the vertices of this Face by the given amounts.
The actual vertex positions are adjusted, not their transformed position.
Therefore, this updates the vertex data directly.
Parameters:
Name Type Argument Default Description xnumber The amount to horizontally translate by.
ynumber <optional>
0 The amount to vertically translate by.
- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 406)
Returns:
This Face instance.
-
updateBounds()
-
Updates the bounds of this Face, based on the translated values of the vertices.
Call this method prior to accessing the
Face.boundsproperty.- Since: 3.50.0
- Source: src/geom/mesh/Face.js (Line 318)
Returns:
This Face instance.
