mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 14:38:30 +00:00
Added Mat4.makeRotationAxis.
This commit is contained in:
parent
c48501b4ec
commit
6aae306aa0
1 changed files with 24 additions and 0 deletions
|
@ -400,6 +400,30 @@ var Matrix4 = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
// Axis = vec3, angle = radians
|
||||
makeRotationAxis: function (axis, angle)
|
||||
{
|
||||
// Based on http://www.gamedev.net/reference/articles/article1199.asp
|
||||
|
||||
var c = Math.cos(angle);
|
||||
var s = Math.sin(angle);
|
||||
var t = 1 - c;
|
||||
var x = axis.x;
|
||||
var y = axis.y;
|
||||
var z = axis.z;
|
||||
var tx = t * x;
|
||||
var ty = t * y;
|
||||
|
||||
this.set(
|
||||
tx * x + c, tx * y - s * z, tx * z + s * y, 0,
|
||||
tx * y + s * z, ty * y + c, ty * z - s * x, 0,
|
||||
tx * z - s * y, ty * z + s * x, t * z * z + c, 0,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
rotate: function (rad, axis)
|
||||
{
|
||||
var a = this.val;
|
||||
|
|
Loading…
Add table
Reference in a new issue