Skip to content

Commit 51ab685

Browse files
committed
Matrix4.getMaxScaleOnAxis is a new method that will return the maximum axis scale from the Matrix4.
1 parent 7896bb4 commit 51ab685

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/math/Matrix4.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,25 @@ var Matrix4 = new Class({
15931593
}
15941594

15951595
return this;
1596+
},
1597+
1598+
/**
1599+
* Returns the maximum axis scale from this Matrix4.
1600+
*
1601+
* @method Phaser.Math.Matrix4#getMaxScaleOnAxis
1602+
* @since 3.50.0
1603+
*
1604+
* @return {number} The maximum axis scale.
1605+
*/
1606+
getMaxScaleOnAxis: function ()
1607+
{
1608+
var m = this.val;
1609+
1610+
var scaleXSq = m[0] * m[0] + m[1] * m[1] + m[2] * m[2];
1611+
var scaleYSq = m[4] * m[4] + m[5] * m[5] + m[6] * m[6];
1612+
var scaleZSq = m[8] * m[8] + m[9] * m[9] + m[10] * m[10];
1613+
1614+
return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
15961615
}
15971616

15981617
});

0 commit comments

Comments
 (0)