new Vertex(x, y, z, u, v [, color] [, alpha] [, nx] [, ny] [, nz])
Parameters:
Name | Type | Argument | 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. |
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 11)
Extends
Members
-
alpha :number
-
The alpha value of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 133)
-
color :number
-
The color value of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 124)
-
nx :number
-
The projected x coordinate of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 79)
-
ny :number
-
The projected y coordinate of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 88)
-
nz :number
-
The projected z coordinate of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 97)
-
ta :number
-
The translated alpha value of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 160)
-
tx :number
-
The translated x coordinate of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 142)
-
ty :number
-
The translated y coordinate of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 151)
-
u :number
-
UV u coordinate of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 106)
-
v :number
-
UV v coordinate of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 115)
-
vx :number
-
The projected x coordinate of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 52)
-
vy :number
-
The projected y coordinate of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 61)
-
vz :number
-
The projected z coordinate of this vertex.
Type:
- number
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 70)
-
x :number
-
The x component of this Vector.
Type:
- number
- Since: 3.0.0
- Inherited From:
- Default Value:
-
- 0
- Source: src/math/Vector3.js (Line 33)
-
y :number
-
The y component of this Vector.
Type:
- number
- Since: 3.0.0
- Inherited From:
- Default Value:
-
- 0
- Source: src/math/Vector3.js (Line 43)
-
z :number
-
The z component of this Vector.
Type:
- number
- Since: 3.0.0
- Inherited From:
- Default Value:
-
- 0
- Source: src/math/Vector3.js (Line 53)
Methods
-
add(v)
-
Add a given Vector to this Vector. Addition is component-wise.
Parameters:
Name Type Description v
Phaser.Math.Vector2 | Phaser.Math.Vector3 The Vector to add to this Vector.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 317)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
addScalar(s)
-
Add the given value to each component of this Vector.
Parameters:
Name Type Description s
number The amount to add to this Vector.
- Since: 3.50.0
- Inherited From:
- Source: src/math/Vector3.js (Line 336)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
addScale(v, scale)
-
Add and scale a given Vector to this Vector. Addition is component-wise.
Parameters:
Name Type Description v
Phaser.Math.Vector2 | Phaser.Math.Vector3 The Vector to add to this Vector.
scale
number The amount to scale
v
by.- Since: 3.50.0
- Inherited From:
- Source: src/math/Vector3.js (Line 355)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
addVectors(a, b)
-
Adds the two given Vector3s and sets the results into this Vector3.
Parameters:
Name Type Description a
Phaser.Math.Vector3 The first Vector to add.
b
Phaser.Math.Vector3 The second Vector to add.
- Since: 3.50.0
- Inherited From:
- Source: src/math/Vector3.js (Line 147)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
applyMatrix3(mat3)
-
Takes a Matrix3 and applies it to this Vector3.
Parameters:
Name Type Description mat3
Phaser.Math.Matrix3 The Matrix3 to apply to this Vector3.
- Since: 3.50.0
- Inherited From:
- Source: src/math/Vector3.js (Line 651)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
applyMatrix4(mat4)
-
Takes a Matrix4 and applies it to this Vector3.
Parameters:
Name Type Description mat4
Phaser.Math.Matrix4 The Matrix4 to apply to this Vector3.
- Since: 3.50.0
- Inherited From:
- Source: src/math/Vector3.js (Line 675)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
clone()
-
Make a clone of this Vector3.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 134)
Returns:
A new Vector3 object containing this Vectors values.
- Type
- Phaser.Math.Vector3
-
copy(src)
-
Copy the components of a given Vector into this Vector.
Parameters:
Name Type Description src
Phaser.Math.Vector2 | Phaser.Math.Vector3 The Vector to copy the components from.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 211)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
cross(v)
-
Calculate the cross (vector) product of this Vector (which will be modified) and the given Vector.
Parameters:
Name Type Description v
Phaser.Math.Vector3 The Vector to cross product with.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 597)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
crossVectors(a, b)
-
Calculate the cross (vector) product of two given Vectors.
Parameters:
Name Type Description a
Phaser.Math.Vector3 The first Vector to multiply.
b
Phaser.Math.Vector3 The second Vector to multiply.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 167)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
distance(v)
-
Calculate the distance between this Vector and the given Vector.
Parameters:
Name Type Description v
Phaser.Math.Vector2 | Phaser.Math.Vector3 The Vector to calculate the distance to.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 481)
Returns:
The distance from this Vector to the given Vector.
- Type
- number
-
distanceSq(v)
-
Calculate the distance between this Vector and the given Vector, squared.
Parameters:
Name Type Description v
Phaser.Math.Vector2 | Phaser.Math.Vector3 The Vector to calculate the distance to.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 500)
Returns:
The distance from this Vector to the given Vector, squared.
- Type
- number
-
divide(v)
-
Perform a component-wise division between this Vector and the given Vector.
Divides this Vector by the given Vector.
Parameters:
Name Type Description v
Phaser.Math.Vector2 | Phaser.Math.Vector3 The Vector to divide this Vector by.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 443)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
dot(v)
-
Calculate the dot product of this Vector and the given Vector.
Parameters:
Name Type Description v
Phaser.Math.Vector3 The Vector3 to dot product with this Vector3.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 582)
Returns:
The dot product of this Vector and
v
.- Type
- number
-
equals(v)
-
Check whether this Vector is equal to a given Vector.
Performs a strict equality check against each Vector's components.
Parameters:
Name Type Description v
Phaser.Math.Vector3 The Vector3 to compare against.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 194)
Returns:
True if the two vectors strictly match, otherwise false.
- Type
- boolean
-
fromArray(array [, offset])
-
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]
Parameters:
Name Type Argument Default Description array
Array.<number> The array of values to get this Vector from.
offset
number <optional>
0 The offset index into the array.
- Since: 3.50.0
- Inherited From:
- Source: src/math/Vector3.js (Line 291)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
length()
-
Calculate the length (or magnitude) of this Vector.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 519)
Returns:
The length of this Vector.
- Type
- number
-
lengthSq()
-
Calculate the length of this Vector squared.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 536)
Returns:
The length of this Vector, squared.
- Type
- number
-
lerp(v [, t])
-
Linearly interpolate between this Vector and the given Vector.
Interpolates this Vector towards the given Vector.
Parameters:
Name Type Argument Default Description v
Phaser.Math.Vector3 The Vector3 to interpolate towards.
t
number <optional>
0 The interpolation percentage, between 0 and 1.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 623)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
load(F32, U32, offset, textureUnit)
-
Loads the data from this Vertex into the given Typed Arrays.
Parameters:
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.
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 261)
Returns:
The new array offset.
- Type
- number
-
max(v)
-
Sets the components of this Vector to be the
Math.max
result from the given vector.Parameters:
Name Type Description v
Phaser.Math.Vector3 The Vector3 to check the maximum values against.
- Since: 3.50.0
- Inherited From:
- Source: src/math/Vector3.js (Line 115)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
min(v)
-
Sets the components of this Vector to be the
Math.min
result from the given vector.Parameters:
Name Type Description v
Phaser.Math.Vector3 The Vector3 to check the minimum values against.
- Since: 3.50.0
- Inherited From:
- Source: src/math/Vector3.js (Line 96)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
multiply(v)
-
Perform a component-wise multiplication between this Vector and the given Vector.
Multiplies this Vector by the given Vector.
Parameters:
Name Type Description v
Phaser.Math.Vector2 | Phaser.Math.Vector3 The Vector to multiply this Vector by.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 394)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
negate()
-
Negate the
x
,y
andz
components of this Vector.- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 464)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
normalize()
-
Normalize this Vector.
Makes the vector a unit length vector (magnitude of 1) in the same direction.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 553)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
project(mat)
-
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.
Parameters:
Name Type Description mat
Phaser.Math.Matrix4 The Matrix4 to multiply this Vector3 with.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 813)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
projectViewMatrix(viewMatrix, projectionMatrix)
-
Multiplies this Vector3 by the given view and projection matrices.
Parameters:
Name Type Description viewMatrix
Phaser.Math.Matrix4 A View Matrix.
projectionMatrix
Phaser.Math.Matrix4 A Projection Matrix.
- Since: 3.50.0
- Inherited From:
- Source: src/math/Vector3.js (Line 857)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
reset()
-
Make this Vector the zero vector (0, 0, 0).
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 925)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
scale(scale)
-
Scale this Vector by the given value.
Parameters:
Name Type Description scale
number The value to scale this Vector by.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 415)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
set(x [, y] [, z])
-
Set the
x
,y
, andz
components of this Vector to the givenx
,y
, andz
values.Parameters:
Name Type Argument 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.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 230)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
setFromMatrixColumn(mat4, index)
-
Sets the components of this Vector3 from the Matrix4 column specified.
Parameters:
Name Type Description mat4
Phaser.Math.Matrix4 The Matrix4 to get the column from.
index
number The column index.
- Since: 3.50.0
- Inherited From:
- Source: src/math/Vector3.js (Line 275)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
setFromMatrixPosition(mat4)
-
Sets the components of this Vector3 from the position of the given Matrix4.
Parameters:
Name Type Description mat4
Phaser.Math.Matrix4 The Matrix4 to get the position from.
- Since: 3.50.0
- Inherited From:
- Source: src/math/Vector3.js (Line 260)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
setUVs(u, v)
-
Sets the U and V properties.
Parameters:
Name Type Description u
number The UV u coordinate of the vertex.
v
number The UV v coordinate of the vertex.
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 170)
Returns:
This Vertex.
-
subtract(v)
-
Subtract the given Vector from this Vector. Subtraction is component-wise.
Parameters:
Name Type Description v
Phaser.Math.Vector2 | Phaser.Math.Vector3 The Vector to subtract from this Vector.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 375)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
transformCoordinates(mat)
-
Transforms the coordinates of this Vector3 with the given Matrix4.
Parameters:
Name Type Description mat
Phaser.Math.Matrix4 The Matrix4 to transform this Vector3 with.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 749)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
transformCoordinatesLocal(transformMatrix, width, height, cameraZ)
-
Transforms this vertex by the given matrix, storing the results in
vx
,vy
andvz
.Parameters:
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.
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 189)
-
transformMat3(mat)
-
Transform this Vector with the given Matrix.
Parameters:
Name Type Description mat
Phaser.Math.Matrix3 The Matrix3 to transform this Vector3 with.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 701)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
transformMat4(mat)
-
Transform this Vector with the given Matrix4.
Parameters:
Name Type Description mat
Phaser.Math.Matrix4 The Matrix4 to transform this Vector3 with.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 725)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
transformQuat(q)
-
Transform this Vector with the given Quaternion.
Parameters:
Name Type Description q
Phaser.Math.Quaternion The Quaternion to transform this Vector with.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 778)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
unproject(viewport, invProjectionView)
-
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.
Parameters:
Name Type Description viewport
Phaser.Math.Vector4 Screen x, y, width and height in pixels.
invProjectionView
Phaser.Math.Matrix4 Combined projection and view matrix.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 889)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
unprojectViewMatrix(projectionMatrix, worldMatrix)
-
Multiplies this Vector3 by the given inversed projection matrix and world matrix.
Parameters:
Name Type Description projectionMatrix
Phaser.Math.Matrix4 An inversed Projection Matrix.
worldMatrix
Phaser.Math.Matrix4 A World View Matrix.
- Since: 3.50.0
- Inherited From:
- Source: src/math/Vector3.js (Line 873)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
up()
-
Set this Vector to point up.
Sets the y component of the vector to 1, and the others to 0.
- Since: 3.0.0
- Inherited From:
- Source: src/math/Vector3.js (Line 77)
Returns:
This Vector3.
- Type
- Phaser.Math.Vector3
-
update(a, b, c, d, e, f, roundPixels, alpha)
-
Updates this Vertex based on the given transform.
Parameters:
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.
- Since: 3.50.0
- Source: src/geom/mesh/Vertex.js (Line 226)
Returns:
This Vertex.