From c6d25c9559c2c10be829ad33d95964d14c7853d5 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 7 Oct 2020 13:15:44 +0100 Subject: [PATCH] Added z parameter --- src/geom/mesh/Face.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/geom/mesh/Face.js b/src/geom/mesh/Face.js index a6a61ee90..5d17b8674 100644 --- a/src/geom/mesh/Face.js +++ b/src/geom/mesh/Face.js @@ -312,15 +312,19 @@ var Face = new Class({ * @method Phaser.Geom.Mesh.Face#isCounterClockwise * @since 3.50.0 * + * @param {number} z - The z-axis value to test against. Typically the `MeshCamera.position.z`. + * * @return {boolean} `true` if the vertices in this Face run counter-clockwise, otherwise `false`. */ - isCounterClockwise: function () + isCounterClockwise: function (z) { var v1 = this.vertex1; var v2 = this.vertex2; var v3 = this.vertex3; - return (v2.vx - v1.vx) * (v3.vy - v1.vy) - (v2.vy - v1.vy) * (v3.vx - v1.vx) >= 0; + var d = (v2.vx - v1.vx) * (v3.vy - v1.vy) - (v2.vy - v1.vy) * (v3.vx - v1.vx); + + return (z <= 0) ? d >= 0 : d < 0; }, /**