A Vertex Geometry Object.
This class consists of all the information required for a single vertex within a Face Geometry Object.
Faces, and thus Vertex objects, are used by the Mesh Game Object in order to render objects in WebGL.
new Vertex(x, y, z, u, v, [color], [alpha], [nx], [ny], [nz])
name | type | arguments | Default | description |
---|---|---|---|---|
x | number |
The x position of the vertex. |
||
y | number |
The y position of the vertex. |
||
z | number |
The z position of the vertex. |
||
u | number |
The UV u coordinate of the vertex. |
||
v | number |
The UV v coordinate of the vertex. |
||
color | number | <optional> | 0xffffff |
The color value of the vertex. |
alpha | number | <optional> | 1 |
The alpha value of the vertex. |
nx | number | <optional> | 0 |
The x normal value of the vertex. |
ny | number | <optional> | 0 |
The y normal value of the vertex. |
nz | number | <optional> | 0 |
The z normal value of the vertex. |
The alpha value of this vertex.
The color value of this vertex.
The normalized projected x coordinate of this vertex.
The normalized projected y coordinate of this vertex.
The normalized projected z coordinate of this vertex.
The translated alpha value of this vertex.
The translated uv u coordinate of this vertex.
The translated uv v coordinate of this vertex.
The translated x coordinate of this vertex.
The translated y coordinate of this vertex.
UV u coordinate of this vertex.
UV v coordinate of this vertex.
The projected x coordinate of this vertex.
The projected y coordinate of this vertex.
The projected z coordinate of this vertex.
The x component of this Vector.
The y component of this Vector.
The z component of this Vector.
Add a given Vector to this Vector. Addition is component-wise.
name | type | description |
---|---|---|
v | Phaser.Math.Vector2 | Phaser.Math.Vector3 |
The Vector to add to this Vector. |
This Vector3.
Add the given value to each component of this Vector.
name | type | description |
---|---|---|
s | number |
The amount to add to this Vector. |
This Vector3.
Add and scale a given Vector to this Vector. Addition is component-wise.
name | type | description |
---|---|---|
v | Phaser.Math.Vector2 | Phaser.Math.Vector3 |
The Vector to add to this Vector. |
scale | number |
The amount to scale |
This Vector3.
Adds the two given Vector3s and sets the results into this Vector3.
name | type | description |
---|---|---|
a | Phaser.Math.Vector3 |
The first Vector to add. |
b | Phaser.Math.Vector3 |
The second Vector to add. |
This Vector3.
Takes a Matrix3 and applies it to this Vector3.
name | type | description |
---|---|---|
mat3 | Phaser.Math.Matrix3 |
The Matrix3 to apply to this Vector3. |
This Vector3.
Takes a Matrix4 and applies it to this Vector3.
name | type | description |
---|---|---|
mat4 | Phaser.Math.Matrix4 |
The Matrix4 to apply to this Vector3. |
This Vector3.
Make a clone of this Vector3.
A new Vector3 object containing this Vectors values.
Copy the components of a given Vector into this Vector.
name | type | description |
---|---|---|
src | Phaser.Math.Vector2 | Phaser.Math.Vector3 |
The Vector to copy the components from. |
This Vector3.
Calculate the cross (vector) product of this Vector (which will be modified) and the given Vector.
name | type | description |
---|---|---|
v | Phaser.Math.Vector3 |
The Vector to cross product with. |
This Vector3.
Calculate the cross (vector) product of two given Vectors.
name | type | description |
---|---|---|
a | Phaser.Math.Vector3 |
The first Vector to multiply. |
b | Phaser.Math.Vector3 |
The second Vector to multiply. |
This Vector3.
Calculate the distance between this Vector and the given Vector.
name | type | description |
---|---|---|
v | Phaser.Math.Vector2 | Phaser.Math.Vector3 |
The Vector to calculate the distance to. |
The distance from this Vector to the given Vector.
Calculate the distance between this Vector and the given Vector, squared.
name | type | description |
---|---|---|
v | Phaser.Math.Vector2 | Phaser.Math.Vector3 |
The Vector to calculate the distance to. |
The distance from this Vector to the given Vector, squared.
Perform a component-wise division between this Vector and the given Vector.
Divides this Vector by the given Vector.
name | type | description |
---|---|---|
v | Phaser.Math.Vector2 | Phaser.Math.Vector3 |
The Vector to divide this Vector by. |
This Vector3.
Calculate the dot product of this Vector and the given Vector.
name | type | description |
---|---|---|
v | Phaser.Math.Vector3 |
The Vector3 to dot product with this Vector3. |
The dot product of this Vector and v
.
Check whether this Vector is equal to a given Vector.
Performs a strict equality check against each Vector's components.
name | type | description |
---|---|---|
v | Phaser.Math.Vector3 |
The Vector3 to compare against. |
True if the two vectors strictly match, otherwise false.
Sets the components of this Vector3 from the given array, based on the offset.
Vector3.x = array[offset] Vector3.y = array[offset + 1] Vector3.z = array[offset + 2]
name | type | arguments | description |
---|---|---|---|
array | Array.<number> |
The array of values to get this Vector from. |
|
offset | number | <optional> |
The offset index into the array. |
This Vector3.
Calculate the length (or magnitude) of this Vector.
The length of this Vector.
Calculate the length of this Vector squared.
The length of this Vector, squared.
Linearly interpolate between this Vector and the given Vector.
Interpolates this Vector towards the given Vector.
name | type | arguments | description |
---|---|---|---|
v | Phaser.Math.Vector3 |
The Vector3 to interpolate towards. |
|
t | number | <optional> |
The interpolation percentage, between 0 and 1. |
This Vector3.
Loads the data from this Vertex into the given Typed Arrays.
name | type | description |
---|---|---|
F32 | Float32Array |
A Float32 Array to insert the position, UV and unit data in to. |
U32 | Uint32Array |
A Uint32 Array to insert the color and alpha data in to. |
offset | number |
The index of the array to insert this Vertex to. |
textureUnit | number |
The texture unit currently in use. |
tintEffect | number |
The tint effect to use. |
The new array offset.
Sets the components of this Vector to be the Math.max
result from the given vector.
name | type | description |
---|---|---|
v | Phaser.Math.Vector3 |
The Vector3 to check the maximum values against. |
This Vector3.
Sets the components of this Vector to be the Math.min
result from the given vector.
name | type | description |
---|---|---|
v | Phaser.Math.Vector3 |
The Vector3 to check the minimum values against. |
This Vector3.
Perform a component-wise multiplication between this Vector and the given Vector.
Multiplies this Vector by the given Vector.
name | type | description |
---|---|---|
v | Phaser.Math.Vector2 | Phaser.Math.Vector3 |
The Vector to multiply this Vector by. |
This Vector3.
Negate the x
, y
and z
components of this Vector.
This Vector3.
Normalize this Vector.
Makes the vector a unit length vector (magnitude of 1) in the same direction.
This Vector3.
Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, e.g. unprojecting a 2D point into 3D space.
name | type | description |
---|---|---|
mat | Phaser.Math.Matrix4 |
The Matrix4 to multiply this Vector3 with. |
This Vector3.
Multiplies this Vector3 by the given view and projection matrices.
name | type | description |
---|---|---|
viewMatrix | Phaser.Math.Matrix4 |
A View Matrix. |
projectionMatrix | Phaser.Math.Matrix4 |
A Projection Matrix. |
This Vector3.
Make this Vector the zero vector (0, 0, 0).
This Vector3.
Resizes this Vertex by setting the x and y coordinates, then transforms this vertex
by an identity matrix and dimensions, storing the results in vx
, vy
and vz
.
name | type | description |
---|---|---|
x | number |
The x position of the vertex. |
y | number |
The y position of the vertex. |
width | number |
The width of the parent Mesh. |
height | number |
The height of the parent Mesh. |
originX | number |
The originX of the parent Mesh. |
originY | number |
The originY of the parent Mesh. |
This Vertex.
Scale this Vector by the given value.
name | type | description |
---|---|---|
scale | number |
The value to scale this Vector by. |
This Vector3.
Scales the original UV values by the given amounts.
The original properties Vertex.u
and Vertex.v
remain unchanged, only the translated properties
Vertex.tu
and Vertex.tv
, as used in rendering,
are updated.
name | type | description |
---|---|---|
x | number |
The amount to scale the UV u coordinate by. |
y | number |
The amount to scale the UV v coordinate by. |
This Vertex.
Translates the original UV positions by the given amounts.
The original properties Vertex.u
and Vertex.v
remain unchanged, only the translated properties
Vertex.tu
and Vertex.tv
, as used in rendering,
are updated.
name | type | description |
---|---|---|
x | number |
The amount to scroll the UV u coordinate by. |
y | number |
The amount to scroll the UV v coordinate by. |
This Vertex.
Set the x
, y
, and z
components of this Vector to the given x
, y
, and z
values.
name | type | arguments | description |
---|---|---|---|
x | number | object |
The x value to set for this Vector, or an object containing x, y and z components. |
|
y | number | <optional> |
The y value to set for this Vector. |
z | number | <optional> |
The z value to set for this Vector. |
This Vector3.
Sets the components of this Vector3 from the Matrix4 column specified.
name | type | description |
---|---|---|
mat4 | Phaser.Math.Matrix4 |
The Matrix4 to get the column from. |
index | number |
The column index. |
This Vector3.
Sets the components of this Vector3 from the position of the given Matrix4.
name | type | description |
---|---|---|
mat4 | Phaser.Math.Matrix4 |
The Matrix4 to get the position from. |
This Vector3.
Sets the U and V properties.
Also resets the translated uv properties, undoing any scale or shift they may have had.
name | type | description |
---|---|---|
u | number |
The UV u coordinate of the vertex. |
v | number |
The UV v coordinate of the vertex. |
This Vertex.
Subtracts the two given Vector3s and sets the results into this Vector3.
name | type | description |
---|---|---|
a | Phaser.Math.Vector3 |
The first Vector to sub. |
b | Phaser.Math.Vector3 |
The second Vector to sub. |
This Vector3.
Subtract the given Vector from this Vector. Subtraction is component-wise.
name | type | description |
---|---|---|
v | Phaser.Math.Vector2 | Phaser.Math.Vector3 |
The Vector to subtract from this Vector. |
This Vector3.
Transforms the coordinates of this Vector3 with the given Matrix4.
name | type | description |
---|---|---|
mat | Phaser.Math.Matrix4 |
The Matrix4 to transform this Vector3 with. |
This Vector3.
Transforms this vertex by the given matrix, storing the results in vx
, vy
and vz
.
name | type | description |
---|---|---|
transformMatrix | Phaser.Math.Matrix4 |
The transform matrix to apply to this vertex. |
width | number |
The width of the parent Mesh. |
height | number |
The height of the parent Mesh. |
cameraZ | number |
The z position of the MeshCamera. |
Transform this Vector with the given Matrix.
name | type | description |
---|---|---|
mat | Phaser.Math.Matrix3 |
The Matrix3 to transform this Vector3 with. |
This Vector3.
Transform this Vector with the given Matrix4.
name | type | description |
---|---|---|
mat | Phaser.Math.Matrix4 |
The Matrix4 to transform this Vector3 with. |
This Vector3.
Transform this Vector with the given Quaternion.
name | type | description |
---|---|---|
q | Phaser.Math.Quaternion |
The Quaternion to transform this Vector with. |
This Vector3.
Unproject this point from 2D space to 3D space. The point should have its x and y properties set to 2D screen space, and the z either at 0 (near plane) or 1 (far plane). The provided matrix is assumed to already be combined, i.e. projection * view * model.
After this operation, this vector's (x, y, z) components will represent the unprojected 3D coordinate.
name | type | description |
---|---|---|
viewport | Phaser.Math.Vector4 |
Screen x, y, width and height in pixels. |
invProjectionView | Phaser.Math.Matrix4 |
Combined projection and view matrix. |
This Vector3.
Multiplies this Vector3 by the given inversed projection matrix and world matrix.
name | type | description |
---|---|---|
projectionMatrix | Phaser.Math.Matrix4 |
An inversed Projection Matrix. |
worldMatrix | Phaser.Math.Matrix4 |
A World View Matrix. |
This Vector3.
Set this Vector to point up.
Sets the y component of the vector to 1, and the others to 0.
This Vector3.
Updates this Vertex based on the given transform.
name | type | description |
---|---|---|
a | number |
The parent transform matrix data a component. |
b | number |
The parent transform matrix data b component. |
c | number |
The parent transform matrix data c component. |
d | number |
The parent transform matrix data d component. |
e | number |
The parent transform matrix data e component. |
f | number |
The parent transform matrix data f component. |
roundPixels | boolean |
Round the vertex position or not? |
alpha | number |
The alpha of the parent object. |
This Vertex.