Skip to content

Commit c6d25c9

Browse files
committed
Added z parameter
1 parent 8ff78ef commit c6d25c9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/geom/mesh/Face.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,19 @@ var Face = new Class({
312312
* @method Phaser.Geom.Mesh.Face#isCounterClockwise
313313
* @since 3.50.0
314314
*
315+
* @param {number} z - The z-axis value to test against. Typically the `MeshCamera.position.z`.
316+
*
315317
* @return {boolean} `true` if the vertices in this Face run counter-clockwise, otherwise `false`.
316318
*/
317-
isCounterClockwise: function ()
319+
isCounterClockwise: function (z)
318320
{
319321
var v1 = this.vertex1;
320322
var v2 = this.vertex2;
321323
var v3 = this.vertex3;
322324

323-
return (v2.vx - v1.vx) * (v3.vy - v1.vy) - (v2.vy - v1.vy) * (v3.vx - v1.vx) >= 0;
325+
var d = (v2.vx - v1.vx) * (v3.vy - v1.vy) - (v2.vy - v1.vy) * (v3.vx - v1.vx);
326+
327+
return (z <= 0) ? d >= 0 : d < 0;
324328
},
325329

326330
/**

0 commit comments

Comments
 (0)