mirror of
https://github.com/photonstorm/phaser
synced 2024-11-25 06:00:41 +00:00
Removed all of the mvp functions as they're no longer needed
This commit is contained in:
parent
0b3011add3
commit
8c85887479
20 changed files with 0 additions and 777 deletions
|
@ -12,7 +12,6 @@ module.exports = {
|
||||||
|
|
||||||
PipelineManager: require('./PipelineManager'),
|
PipelineManager: require('./PipelineManager'),
|
||||||
Pipelines: require('./pipelines'),
|
Pipelines: require('./pipelines'),
|
||||||
MVP: require('./mvp'),
|
|
||||||
Utils: require('./Utils'),
|
Utils: require('./Utils'),
|
||||||
WebGLPipeline: require('./WebGLPipeline'),
|
WebGLPipeline: require('./WebGLPipeline'),
|
||||||
WebGLRenderer: require('./WebGLRenderer')
|
WebGLRenderer: require('./WebGLRenderer')
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
var SetIdentity = require('./SetIdentity');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads an identity matrix into the model matrix.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.Identity
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var Identity = function (model)
|
|
||||||
{
|
|
||||||
SetIdentity(model.modelMatrix);
|
|
||||||
|
|
||||||
model.modelMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = Identity;
|
|
|
@ -1,28 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
var SetIdentity = require('./SetIdentity');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads an identity matrix into the projection matrix.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.ProjectIdentity
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var ProjectIdentity = function (model)
|
|
||||||
{
|
|
||||||
SetIdentity(model.projectionMatrix);
|
|
||||||
|
|
||||||
model.projectionMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = ProjectIdentity;
|
|
|
@ -1,52 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Translates the model matrix by the given values.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.ProjectOrtho
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {number} left - The left value.
|
|
||||||
* @param {number} right - The right value.
|
|
||||||
* @param {number} bottom - The bottom value.
|
|
||||||
* @param {number} top - The top value.
|
|
||||||
* @param {number} near - The near value.
|
|
||||||
* @param {number} far - The far value.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var ProjectOrtho = function (model, left, right, bottom, top, near, far)
|
|
||||||
{
|
|
||||||
var projectionMatrix = model.projectionMatrix;
|
|
||||||
var leftRight = 1 / (left - right);
|
|
||||||
var bottomTop = 1 / (bottom - top);
|
|
||||||
var nearFar = 1 / (near - far);
|
|
||||||
|
|
||||||
projectionMatrix[0] = -2 * leftRight;
|
|
||||||
projectionMatrix[1] = 0;
|
|
||||||
projectionMatrix[2] = 0;
|
|
||||||
projectionMatrix[3] = 0;
|
|
||||||
projectionMatrix[4] = 0;
|
|
||||||
projectionMatrix[5] = -2 * bottomTop;
|
|
||||||
projectionMatrix[6] = 0;
|
|
||||||
projectionMatrix[7] = 0;
|
|
||||||
projectionMatrix[8] = 0;
|
|
||||||
projectionMatrix[9] = 0;
|
|
||||||
projectionMatrix[10] = 2 * nearFar;
|
|
||||||
projectionMatrix[11] = 0;
|
|
||||||
projectionMatrix[12] = (left + right) * leftRight;
|
|
||||||
projectionMatrix[13] = (top + bottom) * bottomTop;
|
|
||||||
projectionMatrix[14] = (far + near) * nearFar;
|
|
||||||
projectionMatrix[15] = 1;
|
|
||||||
|
|
||||||
model.projectionMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = ProjectOrtho;
|
|
|
@ -1,49 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up a perspective projection matrix into the projection matrix.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.ProjectPerspective
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {number} fovY - The fov value.
|
|
||||||
* @param {number} aspectRatio - The aspectRatio value.
|
|
||||||
* @param {number} near - The near value.
|
|
||||||
* @param {number} far - The far value.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var ProjectPerspective = function (model, fovY, aspectRatio, near, far)
|
|
||||||
{
|
|
||||||
var projectionMatrix = model.projectionMatrix;
|
|
||||||
var fov = 1 / Math.tan(fovY / 2);
|
|
||||||
var nearFar = 1 / (near - far);
|
|
||||||
|
|
||||||
projectionMatrix[0] = fov / aspectRatio;
|
|
||||||
projectionMatrix[1] = 0;
|
|
||||||
projectionMatrix[2] = 0;
|
|
||||||
projectionMatrix[3] = 0;
|
|
||||||
projectionMatrix[4] = 0;
|
|
||||||
projectionMatrix[5] = fov;
|
|
||||||
projectionMatrix[6] = 0;
|
|
||||||
projectionMatrix[7] = 0;
|
|
||||||
projectionMatrix[8] = 0;
|
|
||||||
projectionMatrix[9] = 0;
|
|
||||||
projectionMatrix[10] = (far + near) * nearFar;
|
|
||||||
projectionMatrix[11] = -1;
|
|
||||||
projectionMatrix[12] = 0;
|
|
||||||
projectionMatrix[13] = 0;
|
|
||||||
projectionMatrix[14] = (2 * far * near) * nearFar;
|
|
||||||
projectionMatrix[15] = 0;
|
|
||||||
|
|
||||||
model.projectionMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = ProjectPerspective;
|
|
|
@ -1,48 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rotates the model matrix around the X axis.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.RotateX
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {number} radians - The amount to rotate by.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var RotateX = function (model, radians)
|
|
||||||
{
|
|
||||||
var modelMatrix = model.modelMatrix;
|
|
||||||
|
|
||||||
var s = Math.sin(radians);
|
|
||||||
var c = Math.cos(radians);
|
|
||||||
|
|
||||||
var a10 = modelMatrix[4];
|
|
||||||
var a11 = modelMatrix[5];
|
|
||||||
var a12 = modelMatrix[6];
|
|
||||||
var a13 = modelMatrix[7];
|
|
||||||
var a20 = modelMatrix[8];
|
|
||||||
var a21 = modelMatrix[9];
|
|
||||||
var a22 = modelMatrix[10];
|
|
||||||
var a23 = modelMatrix[11];
|
|
||||||
|
|
||||||
modelMatrix[4] = a10 * c + a20 * s;
|
|
||||||
modelMatrix[5] = a11 * c + a21 * s;
|
|
||||||
modelMatrix[6] = a12 * c + a22 * s;
|
|
||||||
modelMatrix[7] = a13 * c + a23 * s;
|
|
||||||
modelMatrix[8] = a20 * c - a10 * s;
|
|
||||||
modelMatrix[9] = a21 * c - a11 * s;
|
|
||||||
modelMatrix[10] = a22 * c - a12 * s;
|
|
||||||
modelMatrix[11] = a23 * c - a13 * s;
|
|
||||||
|
|
||||||
model.modelMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = RotateX;
|
|
|
@ -1,48 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rotates the model matrix around the Y axis.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.RotateY
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {number} radians - The amount to rotate by.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var RotateY = function (model, radians)
|
|
||||||
{
|
|
||||||
var modelMatrix = model.modelMatrix;
|
|
||||||
|
|
||||||
var s = Math.sin(radians);
|
|
||||||
var c = Math.cos(radians);
|
|
||||||
|
|
||||||
var a00 = modelMatrix[0];
|
|
||||||
var a01 = modelMatrix[1];
|
|
||||||
var a02 = modelMatrix[2];
|
|
||||||
var a03 = modelMatrix[3];
|
|
||||||
var a20 = modelMatrix[8];
|
|
||||||
var a21 = modelMatrix[9];
|
|
||||||
var a22 = modelMatrix[10];
|
|
||||||
var a23 = modelMatrix[11];
|
|
||||||
|
|
||||||
modelMatrix[0] = a00 * c - a20 * s;
|
|
||||||
modelMatrix[1] = a01 * c - a21 * s;
|
|
||||||
modelMatrix[2] = a02 * c - a22 * s;
|
|
||||||
modelMatrix[3] = a03 * c - a23 * s;
|
|
||||||
modelMatrix[8] = a00 * s + a20 * c;
|
|
||||||
modelMatrix[9] = a01 * s + a21 * c;
|
|
||||||
modelMatrix[10] = a02 * s + a22 * c;
|
|
||||||
modelMatrix[11] = a03 * s + a23 * c;
|
|
||||||
|
|
||||||
model.modelMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = RotateY;
|
|
|
@ -1,48 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rotates the model matrix around the Z axis.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.RotateZ
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {number} radians - The amount to rotate by.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var RotateZ = function (model, radians)
|
|
||||||
{
|
|
||||||
var modelMatrix = model.modelMatrix;
|
|
||||||
|
|
||||||
var s = Math.sin(radians);
|
|
||||||
var c = Math.cos(radians);
|
|
||||||
|
|
||||||
var a00 = modelMatrix[0];
|
|
||||||
var a01 = modelMatrix[1];
|
|
||||||
var a02 = modelMatrix[2];
|
|
||||||
var a03 = modelMatrix[3];
|
|
||||||
var a10 = modelMatrix[4];
|
|
||||||
var a11 = modelMatrix[5];
|
|
||||||
var a12 = modelMatrix[6];
|
|
||||||
var a13 = modelMatrix[7];
|
|
||||||
|
|
||||||
modelMatrix[0] = a00 * c + a10 * s;
|
|
||||||
modelMatrix[1] = a01 * c + a11 * s;
|
|
||||||
modelMatrix[2] = a02 * c + a12 * s;
|
|
||||||
modelMatrix[3] = a03 * c + a13 * s;
|
|
||||||
modelMatrix[4] = a10 * c - a00 * s;
|
|
||||||
modelMatrix[5] = a11 * c - a01 * s;
|
|
||||||
modelMatrix[6] = a12 * c - a02 * s;
|
|
||||||
modelMatrix[7] = a13 * c - a03 * s;
|
|
||||||
|
|
||||||
model.modelMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = RotateZ;
|
|
|
@ -1,42 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scales the model matrix by the given values.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.Scale
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {number} x - The x component.
|
|
||||||
* @param {number} y - The y component.
|
|
||||||
* @param {number} z - The z component.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var Scale = function (model, x, y, z)
|
|
||||||
{
|
|
||||||
var modelMatrix = model.modelMatrix;
|
|
||||||
|
|
||||||
modelMatrix[0] = modelMatrix[0] * x;
|
|
||||||
modelMatrix[1] = modelMatrix[1] * x;
|
|
||||||
modelMatrix[2] = modelMatrix[2] * x;
|
|
||||||
modelMatrix[3] = modelMatrix[3] * x;
|
|
||||||
modelMatrix[4] = modelMatrix[4] * y;
|
|
||||||
modelMatrix[5] = modelMatrix[5] * y;
|
|
||||||
modelMatrix[6] = modelMatrix[6] * y;
|
|
||||||
modelMatrix[7] = modelMatrix[7] * y;
|
|
||||||
modelMatrix[8] = modelMatrix[8] * z;
|
|
||||||
modelMatrix[9] = modelMatrix[9] * z;
|
|
||||||
modelMatrix[10] = modelMatrix[10] * z;
|
|
||||||
modelMatrix[11] = modelMatrix[11] * z;
|
|
||||||
|
|
||||||
model.modelMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = Scale;
|
|
|
@ -1,35 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads an identity matrix into the model matrix.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.SetIdentity
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Float32Array} array - The array to set to be an identity matrix.
|
|
||||||
*/
|
|
||||||
var SetIdentity = function (array)
|
|
||||||
{
|
|
||||||
array[0] = 1;
|
|
||||||
array[1] = 0;
|
|
||||||
array[2] = 0;
|
|
||||||
array[3] = 0;
|
|
||||||
array[4] = 0;
|
|
||||||
array[5] = 1;
|
|
||||||
array[6] = 0;
|
|
||||||
array[7] = 0;
|
|
||||||
array[8] = 0;
|
|
||||||
array[9] = 0;
|
|
||||||
array[10] = 1;
|
|
||||||
array[11] = 0;
|
|
||||||
array[12] = 0;
|
|
||||||
array[13] = 0;
|
|
||||||
array[14] = 0;
|
|
||||||
array[15] = 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = SetIdentity;
|
|
|
@ -1,34 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Translates the model matrix by the given values.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.Translate
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {number} x - The x component.
|
|
||||||
* @param {number} y - The y component.
|
|
||||||
* @param {number} z - The z component.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var Translate = function (model, x, y, z)
|
|
||||||
{
|
|
||||||
var modelMatrix = model.modelMatrix;
|
|
||||||
|
|
||||||
modelMatrix[12] = modelMatrix[0] * x + modelMatrix[4] * y + modelMatrix[8] * z + modelMatrix[12];
|
|
||||||
modelMatrix[13] = modelMatrix[1] * x + modelMatrix[5] * y + modelMatrix[9] * z + modelMatrix[13];
|
|
||||||
modelMatrix[14] = modelMatrix[2] * x + modelMatrix[6] * y + modelMatrix[10] * z + modelMatrix[14];
|
|
||||||
modelMatrix[15] = modelMatrix[3] * x + modelMatrix[7] * y + modelMatrix[11] * z + modelMatrix[15];
|
|
||||||
|
|
||||||
model.modelMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = Translate;
|
|
|
@ -1,24 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
var SetIdentity = require('./SetIdentity');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads an identity matrix into the view matrix.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.ViewIdentity
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var ViewIdentity = function (model)
|
|
||||||
{
|
|
||||||
SetIdentity(model.viewMatrix);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = ViewIdentity;
|
|
|
@ -1,44 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copies a 4x4 matrix into the view matrix
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.ViewLoad
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {Float32Array} matrix - A Float32Array containing the Matrix2d to copy into the MVP view matrix.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var ViewLoad = function (model, matrix)
|
|
||||||
{
|
|
||||||
var vm = model.viewMatrix;
|
|
||||||
|
|
||||||
vm[0] = matrix[0];
|
|
||||||
vm[1] = matrix[1];
|
|
||||||
vm[2] = matrix[2];
|
|
||||||
vm[3] = matrix[3];
|
|
||||||
vm[4] = matrix[4];
|
|
||||||
vm[5] = matrix[5];
|
|
||||||
vm[6] = matrix[6];
|
|
||||||
vm[7] = matrix[7];
|
|
||||||
vm[8] = matrix[8];
|
|
||||||
vm[9] = matrix[9];
|
|
||||||
vm[10] = matrix[10];
|
|
||||||
vm[11] = matrix[11];
|
|
||||||
vm[12] = matrix[12];
|
|
||||||
vm[13] = matrix[13];
|
|
||||||
vm[14] = matrix[14];
|
|
||||||
vm[15] = matrix[15];
|
|
||||||
|
|
||||||
model.viewMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = ViewLoad;
|
|
|
@ -1,44 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads a 2D view matrix (3x2 matrix) into a 4x4 view matrix.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.ViewLoad2D
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {Float32Array} matrix2D - The Matrix2D.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var ViewLoad2D = function (model, matrix2D)
|
|
||||||
{
|
|
||||||
var vm = model.viewMatrix;
|
|
||||||
|
|
||||||
vm[0] = matrix2D[0];
|
|
||||||
vm[1] = matrix2D[1];
|
|
||||||
vm[2] = 0;
|
|
||||||
vm[3] = 0;
|
|
||||||
vm[4] = matrix2D[2];
|
|
||||||
vm[5] = matrix2D[3];
|
|
||||||
vm[6] = 0;
|
|
||||||
vm[7] = 0;
|
|
||||||
vm[8] = matrix2D[4];
|
|
||||||
vm[9] = matrix2D[5];
|
|
||||||
vm[10] = 1;
|
|
||||||
vm[11] = 0;
|
|
||||||
vm[12] = 0;
|
|
||||||
vm[13] = 0;
|
|
||||||
vm[14] = 0;
|
|
||||||
vm[15] = 1;
|
|
||||||
|
|
||||||
model.viewMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = ViewLoad2D;
|
|
|
@ -1,48 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rotates the view matrix around the X axis.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.ViewRotateX
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {number} radians - The amnount to rotate by.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var ViewRotateX = function (model, radians)
|
|
||||||
{
|
|
||||||
var viewMatrix = model.viewMatrix;
|
|
||||||
|
|
||||||
var s = Math.sin(radians);
|
|
||||||
var c = Math.cos(radians);
|
|
||||||
|
|
||||||
var a10 = viewMatrix[4];
|
|
||||||
var a11 = viewMatrix[5];
|
|
||||||
var a12 = viewMatrix[6];
|
|
||||||
var a13 = viewMatrix[7];
|
|
||||||
var a20 = viewMatrix[8];
|
|
||||||
var a21 = viewMatrix[9];
|
|
||||||
var a22 = viewMatrix[10];
|
|
||||||
var a23 = viewMatrix[11];
|
|
||||||
|
|
||||||
viewMatrix[4] = a10 * c + a20 * s;
|
|
||||||
viewMatrix[5] = a11 * c + a21 * s;
|
|
||||||
viewMatrix[6] = a12 * c + a22 * s;
|
|
||||||
viewMatrix[7] = a13 * c + a23 * s;
|
|
||||||
viewMatrix[8] = a20 * c - a10 * s;
|
|
||||||
viewMatrix[9] = a21 * c - a11 * s;
|
|
||||||
viewMatrix[10] = a22 * c - a12 * s;
|
|
||||||
viewMatrix[11] = a23 * c - a13 * s;
|
|
||||||
|
|
||||||
model.viewMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = ViewRotateX;
|
|
|
@ -1,48 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rotates the view matrix around the Y axis.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.ViewRotateY
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {number} radians - The amnount to rotate by.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var ViewRotateY = function (model, radians)
|
|
||||||
{
|
|
||||||
var viewMatrix = model.viewMatrix;
|
|
||||||
|
|
||||||
var s = Math.sin(radians);
|
|
||||||
var c = Math.cos(radians);
|
|
||||||
|
|
||||||
var a00 = viewMatrix[0];
|
|
||||||
var a01 = viewMatrix[1];
|
|
||||||
var a02 = viewMatrix[2];
|
|
||||||
var a03 = viewMatrix[3];
|
|
||||||
var a20 = viewMatrix[8];
|
|
||||||
var a21 = viewMatrix[9];
|
|
||||||
var a22 = viewMatrix[10];
|
|
||||||
var a23 = viewMatrix[11];
|
|
||||||
|
|
||||||
viewMatrix[0] = a00 * c - a20 * s;
|
|
||||||
viewMatrix[1] = a01 * c - a21 * s;
|
|
||||||
viewMatrix[2] = a02 * c - a22 * s;
|
|
||||||
viewMatrix[3] = a03 * c - a23 * s;
|
|
||||||
viewMatrix[8] = a00 * s + a20 * c;
|
|
||||||
viewMatrix[9] = a01 * s + a21 * c;
|
|
||||||
viewMatrix[10] = a02 * s + a22 * c;
|
|
||||||
viewMatrix[11] = a03 * s + a23 * c;
|
|
||||||
|
|
||||||
model.viewMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = ViewRotateY;
|
|
|
@ -1,48 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rotates the view matrix around the Z axis.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.ViewRotateZ
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {number} radians - The amnount to rotate by.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var ViewRotateZ = function (model, radians)
|
|
||||||
{
|
|
||||||
var viewMatrix = model.viewMatrix;
|
|
||||||
|
|
||||||
var s = Math.sin(radians);
|
|
||||||
var c = Math.cos(radians);
|
|
||||||
|
|
||||||
var a00 = viewMatrix[0];
|
|
||||||
var a01 = viewMatrix[1];
|
|
||||||
var a02 = viewMatrix[2];
|
|
||||||
var a03 = viewMatrix[3];
|
|
||||||
var a10 = viewMatrix[4];
|
|
||||||
var a11 = viewMatrix[5];
|
|
||||||
var a12 = viewMatrix[6];
|
|
||||||
var a13 = viewMatrix[7];
|
|
||||||
|
|
||||||
viewMatrix[0] = a00 * c + a10 * s;
|
|
||||||
viewMatrix[1] = a01 * c + a11 * s;
|
|
||||||
viewMatrix[2] = a02 * c + a12 * s;
|
|
||||||
viewMatrix[3] = a03 * c + a13 * s;
|
|
||||||
viewMatrix[4] = a10 * c - a00 * s;
|
|
||||||
viewMatrix[5] = a11 * c - a01 * s;
|
|
||||||
viewMatrix[6] = a12 * c - a02 * s;
|
|
||||||
viewMatrix[7] = a13 * c - a03 * s;
|
|
||||||
|
|
||||||
model.viewMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = ViewRotateZ;
|
|
|
@ -1,42 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scales the view matrix.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.ViewScale
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {number} x - The x component.
|
|
||||||
* @param {number} y - The y component.
|
|
||||||
* @param {number} z - The z component.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var ViewScale = function (model, x, y, z)
|
|
||||||
{
|
|
||||||
var viewMatrix = model.viewMatrix;
|
|
||||||
|
|
||||||
viewMatrix[0] = viewMatrix[0] * x;
|
|
||||||
viewMatrix[1] = viewMatrix[1] * x;
|
|
||||||
viewMatrix[2] = viewMatrix[2] * x;
|
|
||||||
viewMatrix[3] = viewMatrix[3] * x;
|
|
||||||
viewMatrix[4] = viewMatrix[4] * y;
|
|
||||||
viewMatrix[5] = viewMatrix[5] * y;
|
|
||||||
viewMatrix[6] = viewMatrix[6] * y;
|
|
||||||
viewMatrix[7] = viewMatrix[7] * y;
|
|
||||||
viewMatrix[8] = viewMatrix[8] * z;
|
|
||||||
viewMatrix[9] = viewMatrix[9] * z;
|
|
||||||
viewMatrix[10] = viewMatrix[10] * z;
|
|
||||||
viewMatrix[11] = viewMatrix[11] * z;
|
|
||||||
|
|
||||||
model.viewMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = ViewScale;
|
|
|
@ -1,34 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Translates the view matrix.
|
|
||||||
*
|
|
||||||
* @method Phaser.Renderer.WebGL.MVP.ViewTranslate
|
|
||||||
* @since 3.50.0
|
|
||||||
*
|
|
||||||
* @param {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} model - The Model View Projection object.
|
|
||||||
* @param {number} x - The x component.
|
|
||||||
* @param {number} y - The y component.
|
|
||||||
* @param {number} z - The z component.
|
|
||||||
*
|
|
||||||
* @return {Phaser.Renderer.WebGL.Pipelines.ModelViewProjection} The Model View Projection object.
|
|
||||||
*/
|
|
||||||
var ViewTranslate = function (model, x, y, z)
|
|
||||||
{
|
|
||||||
var viewMatrix = model.viewMatrix;
|
|
||||||
|
|
||||||
viewMatrix[12] = viewMatrix[0] * x + viewMatrix[4] * y + viewMatrix[8] * z + viewMatrix[12];
|
|
||||||
viewMatrix[13] = viewMatrix[1] * x + viewMatrix[5] * y + viewMatrix[9] * z + viewMatrix[13];
|
|
||||||
viewMatrix[14] = viewMatrix[2] * x + viewMatrix[6] * y + viewMatrix[10] * z + viewMatrix[14];
|
|
||||||
viewMatrix[15] = viewMatrix[3] * x + viewMatrix[7] * y + viewMatrix[11] * z + viewMatrix[15];
|
|
||||||
|
|
||||||
model.viewMatrixDirty = true;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = ViewTranslate;
|
|
|
@ -1,32 +0,0 @@
|
||||||
/**
|
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
|
||||||
* @copyright 2020 Photon Storm Ltd.
|
|
||||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @namespace Phaser.Renderer.WebGL.MVP
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
|
|
||||||
Identity: require('./Identity'),
|
|
||||||
ProjectIdentity: require('./ProjectIdentity'),
|
|
||||||
ProjectOrtho: require('./ProjectOrtho'),
|
|
||||||
ProjectPerspective: require('./ProjectPerspective'),
|
|
||||||
RotateX: require('./RotateX'),
|
|
||||||
RotateY: require('./RotateY'),
|
|
||||||
RotateZ: require('./RotateZ'),
|
|
||||||
Scale: require('./Scale'),
|
|
||||||
SetIdentity: require('./SetIdentity'),
|
|
||||||
Translate: require('./Translate'),
|
|
||||||
ViewIdentity: require('./ViewIdentity'),
|
|
||||||
ViewLoad: require('./ViewLoad'),
|
|
||||||
ViewLoad2D: require('./ViewLoad2D'),
|
|
||||||
ViewRotateX: require('./ViewRotateX'),
|
|
||||||
ViewRotateY: require('./ViewRotateY'),
|
|
||||||
ViewRotateZ: require('./ViewRotateZ'),
|
|
||||||
ViewScale: require('./ViewScale'),
|
|
||||||
ViewTranslate: require('./ViewTranslate')
|
|
||||||
|
|
||||||
};
|
|
Loading…
Reference in a new issue