mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 12:43:26 +00:00
Added Mesh.hasFaceAt
This commit is contained in:
parent
60d6119b1b
commit
49ad4348d9
1 changed files with 36 additions and 0 deletions
|
@ -796,6 +796,42 @@ var Mesh = new Class({
|
|||
return this.faces[index];
|
||||
},
|
||||
|
||||
/**
|
||||
* Tests to see if _any_ face in this Mesh intersects with the given coordinates.
|
||||
*
|
||||
* The given position is translated through the matrix of this Mesh and the given Camera,
|
||||
* before being compared against the vertices.
|
||||
*
|
||||
* @method Phaser.GameObjects.Mesh#hasFaceAt
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {number} x - The x position to check against.
|
||||
* @param {number} y - The y position to check against.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} [camera] - The camera to pass the coordinates through. If not give, the default Scene Camera is used.
|
||||
*
|
||||
* @return {boolean} Returns `true` if _any_ face of this Mesh intersects with the given coordinate, otherwise `false`.
|
||||
*/
|
||||
hasFaceAt: function (x, y, camera)
|
||||
{
|
||||
if (camera === undefined) { camera = this.scene.sys.cameras.main; }
|
||||
|
||||
var calcMatrix = GetCalcMatrix(this, camera).calc;
|
||||
|
||||
var faces = this.faces;
|
||||
|
||||
for (var i = 0; i < faces.length; i++)
|
||||
{
|
||||
var face = faces[i];
|
||||
|
||||
if (face.contains(x, y, calcMatrix))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return an array of Face objects from this Mesh that intersect with the given coordinates.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue