sdfsdfs
This commit is contained in:
199
node_modules/pixi.js/lib/maths/matrix/Matrix.d.ts
generated
vendored
Normal file
199
node_modules/pixi.js/lib/maths/matrix/Matrix.d.ts
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
import { Point } from '../point/Point';
|
||||
import type { PointData } from '../point/PointData';
|
||||
interface TransformableObject {
|
||||
position: PointData;
|
||||
scale: PointData;
|
||||
pivot: PointData;
|
||||
skew: PointData;
|
||||
rotation: number;
|
||||
}
|
||||
/**
|
||||
* A fast matrix for 2D transformations.
|
||||
* ```js
|
||||
* | a | c | tx|
|
||||
* | b | d | ty|
|
||||
* | 0 | 0 | 1 |
|
||||
* ```
|
||||
* @memberof maths
|
||||
*/
|
||||
export declare class Matrix {
|
||||
/** @default 1 */
|
||||
a: number;
|
||||
/** @default 0 */
|
||||
b: number;
|
||||
/** @default 0 */
|
||||
c: number;
|
||||
/** @default 1 */
|
||||
d: number;
|
||||
/** @default 0 */
|
||||
tx: number;
|
||||
/** @default 0 */
|
||||
ty: number;
|
||||
/** An array of the current matrix. Only populated when `toArray` is called */
|
||||
array: Float32Array | null;
|
||||
/**
|
||||
* @param a - x scale
|
||||
* @param b - y skew
|
||||
* @param c - x skew
|
||||
* @param d - y scale
|
||||
* @param tx - x translation
|
||||
* @param ty - y translation
|
||||
*/
|
||||
constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number);
|
||||
/**
|
||||
* Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:
|
||||
*
|
||||
* a = array[0]
|
||||
* b = array[1]
|
||||
* c = array[3]
|
||||
* d = array[4]
|
||||
* tx = array[2]
|
||||
* ty = array[5]
|
||||
* @param array - The array that the matrix will be populated from.
|
||||
*/
|
||||
fromArray(array: number[]): void;
|
||||
/**
|
||||
* Sets the matrix properties.
|
||||
* @param a - Matrix component
|
||||
* @param b - Matrix component
|
||||
* @param c - Matrix component
|
||||
* @param d - Matrix component
|
||||
* @param tx - Matrix component
|
||||
* @param ty - Matrix component
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
set(a: number, b: number, c: number, d: number, tx: number, ty: number): this;
|
||||
/**
|
||||
* Creates an array from the current Matrix object.
|
||||
* @param transpose - Whether we need to transpose the matrix or not
|
||||
* @param [out=new Float32Array(9)] - If provided the array will be assigned to out
|
||||
* @returns The newly created array which contains the matrix
|
||||
*/
|
||||
toArray(transpose?: boolean, out?: Float32Array): Float32Array;
|
||||
/**
|
||||
* Get a new position with the current transformation applied.
|
||||
* Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)
|
||||
* @param pos - The origin
|
||||
* @param {Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)
|
||||
* @returns {Point} The new point, transformed through this matrix
|
||||
*/
|
||||
apply<P extends PointData = Point>(pos: PointData, newPos?: P): P;
|
||||
/**
|
||||
* Get a new position with the inverse of the current transformation applied.
|
||||
* Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)
|
||||
* @param pos - The origin
|
||||
* @param {Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)
|
||||
* @returns {Point} The new point, inverse-transformed through this matrix
|
||||
*/
|
||||
applyInverse<P extends PointData = Point>(pos: PointData, newPos?: P): P;
|
||||
/**
|
||||
* Translates the matrix on the x and y.
|
||||
* @param x - How much to translate x by
|
||||
* @param y - How much to translate y by
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
translate(x: number, y: number): this;
|
||||
/**
|
||||
* Applies a scale transformation to the matrix.
|
||||
* @param x - The amount to scale horizontally
|
||||
* @param y - The amount to scale vertically
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
scale(x: number, y: number): this;
|
||||
/**
|
||||
* Applies a rotation transformation to the matrix.
|
||||
* @param angle - The angle in radians.
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
rotate(angle: number): this;
|
||||
/**
|
||||
* Appends the given Matrix to this Matrix.
|
||||
* @param matrix - The matrix to append.
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
append(matrix: Matrix): this;
|
||||
/**
|
||||
* Appends two matrix's and sets the result to this matrix. AB = A * B
|
||||
* @param a - The matrix to append.
|
||||
* @param b - The matrix to append.
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
appendFrom(a: Matrix, b: Matrix): this;
|
||||
/**
|
||||
* Sets the matrix based on all the available properties
|
||||
* @param x - Position on the x axis
|
||||
* @param y - Position on the y axis
|
||||
* @param pivotX - Pivot on the x axis
|
||||
* @param pivotY - Pivot on the y axis
|
||||
* @param scaleX - Scale on the x axis
|
||||
* @param scaleY - Scale on the y axis
|
||||
* @param rotation - Rotation in radians
|
||||
* @param skewX - Skew on the x axis
|
||||
* @param skewY - Skew on the y axis
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
setTransform(x: number, y: number, pivotX: number, pivotY: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number): this;
|
||||
/**
|
||||
* Prepends the given Matrix to this Matrix.
|
||||
* @param matrix - The matrix to prepend
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
prepend(matrix: Matrix): this;
|
||||
/**
|
||||
* Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.
|
||||
* @param transform - The transform to apply the properties to.
|
||||
* @returns The transform with the newly applied properties
|
||||
*/
|
||||
decompose(transform: TransformableObject): TransformableObject;
|
||||
/**
|
||||
* Inverts this matrix
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
invert(): this;
|
||||
/** Checks if this matrix is an identity matrix */
|
||||
isIdentity(): boolean;
|
||||
/**
|
||||
* Resets this Matrix to an identity (default) matrix.
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
identity(): this;
|
||||
/**
|
||||
* Creates a new Matrix object with the same values as this one.
|
||||
* @returns A copy of this matrix. Good for chaining method calls.
|
||||
*/
|
||||
clone(): Matrix;
|
||||
/**
|
||||
* Changes the values of the given matrix to be the same as the ones in this matrix
|
||||
* @param matrix - The matrix to copy to.
|
||||
* @returns The matrix given in parameter with its values updated.
|
||||
*/
|
||||
copyTo(matrix: Matrix): Matrix;
|
||||
/**
|
||||
* Changes the values of the matrix to be the same as the ones in given matrix
|
||||
* @param matrix - The matrix to copy from.
|
||||
* @returns this
|
||||
*/
|
||||
copyFrom(matrix: Matrix): this;
|
||||
/**
|
||||
* check to see if two matrices are the same
|
||||
* @param matrix - The matrix to compare to.
|
||||
*/
|
||||
equals(matrix: Matrix): boolean;
|
||||
toString(): string;
|
||||
/**
|
||||
* A default (identity) matrix.
|
||||
*
|
||||
* This is a shared object, if you want to modify it consider creating a new `Matrix`
|
||||
* @readonly
|
||||
*/
|
||||
static get IDENTITY(): Readonly<Matrix>;
|
||||
/**
|
||||
* A static Matrix that can be used to avoid creating new objects.
|
||||
* Will always ensure the matrix is reset to identity when requested.
|
||||
* Use this object for fast but temporary calculations, as it may be mutated later on.
|
||||
* This is a different object to the `IDENTITY` object and so can be modified without changing `IDENTITY`.
|
||||
* @readonly
|
||||
*/
|
||||
static get shared(): Matrix;
|
||||
}
|
||||
export {};
|
||||
404
node_modules/pixi.js/lib/maths/matrix/Matrix.js
generated
vendored
Normal file
404
node_modules/pixi.js/lib/maths/matrix/Matrix.js
generated
vendored
Normal file
@@ -0,0 +1,404 @@
|
||||
'use strict';
|
||||
|
||||
var _const = require('../misc/const.js');
|
||||
var Point = require('../point/Point.js');
|
||||
|
||||
"use strict";
|
||||
class Matrix {
|
||||
/**
|
||||
* @param a - x scale
|
||||
* @param b - y skew
|
||||
* @param c - x skew
|
||||
* @param d - y scale
|
||||
* @param tx - x translation
|
||||
* @param ty - y translation
|
||||
*/
|
||||
constructor(a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0) {
|
||||
/** An array of the current matrix. Only populated when `toArray` is called */
|
||||
this.array = null;
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
this.tx = tx;
|
||||
this.ty = ty;
|
||||
}
|
||||
/**
|
||||
* Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:
|
||||
*
|
||||
* a = array[0]
|
||||
* b = array[1]
|
||||
* c = array[3]
|
||||
* d = array[4]
|
||||
* tx = array[2]
|
||||
* ty = array[5]
|
||||
* @param array - The array that the matrix will be populated from.
|
||||
*/
|
||||
fromArray(array) {
|
||||
this.a = array[0];
|
||||
this.b = array[1];
|
||||
this.c = array[3];
|
||||
this.d = array[4];
|
||||
this.tx = array[2];
|
||||
this.ty = array[5];
|
||||
}
|
||||
/**
|
||||
* Sets the matrix properties.
|
||||
* @param a - Matrix component
|
||||
* @param b - Matrix component
|
||||
* @param c - Matrix component
|
||||
* @param d - Matrix component
|
||||
* @param tx - Matrix component
|
||||
* @param ty - Matrix component
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
set(a, b, c, d, tx, ty) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
this.tx = tx;
|
||||
this.ty = ty;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Creates an array from the current Matrix object.
|
||||
* @param transpose - Whether we need to transpose the matrix or not
|
||||
* @param [out=new Float32Array(9)] - If provided the array will be assigned to out
|
||||
* @returns The newly created array which contains the matrix
|
||||
*/
|
||||
toArray(transpose, out) {
|
||||
if (!this.array) {
|
||||
this.array = new Float32Array(9);
|
||||
}
|
||||
const array = out || this.array;
|
||||
if (transpose) {
|
||||
array[0] = this.a;
|
||||
array[1] = this.b;
|
||||
array[2] = 0;
|
||||
array[3] = this.c;
|
||||
array[4] = this.d;
|
||||
array[5] = 0;
|
||||
array[6] = this.tx;
|
||||
array[7] = this.ty;
|
||||
array[8] = 1;
|
||||
} else {
|
||||
array[0] = this.a;
|
||||
array[1] = this.c;
|
||||
array[2] = this.tx;
|
||||
array[3] = this.b;
|
||||
array[4] = this.d;
|
||||
array[5] = this.ty;
|
||||
array[6] = 0;
|
||||
array[7] = 0;
|
||||
array[8] = 1;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
/**
|
||||
* Get a new position with the current transformation applied.
|
||||
* Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)
|
||||
* @param pos - The origin
|
||||
* @param {Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)
|
||||
* @returns {Point} The new point, transformed through this matrix
|
||||
*/
|
||||
apply(pos, newPos) {
|
||||
newPos = newPos || new Point.Point();
|
||||
const x = pos.x;
|
||||
const y = pos.y;
|
||||
newPos.x = this.a * x + this.c * y + this.tx;
|
||||
newPos.y = this.b * x + this.d * y + this.ty;
|
||||
return newPos;
|
||||
}
|
||||
/**
|
||||
* Get a new position with the inverse of the current transformation applied.
|
||||
* Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)
|
||||
* @param pos - The origin
|
||||
* @param {Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)
|
||||
* @returns {Point} The new point, inverse-transformed through this matrix
|
||||
*/
|
||||
applyInverse(pos, newPos) {
|
||||
newPos = newPos || new Point.Point();
|
||||
const a = this.a;
|
||||
const b = this.b;
|
||||
const c = this.c;
|
||||
const d = this.d;
|
||||
const tx = this.tx;
|
||||
const ty = this.ty;
|
||||
const id = 1 / (a * d + c * -b);
|
||||
const x = pos.x;
|
||||
const y = pos.y;
|
||||
newPos.x = d * id * x + -c * id * y + (ty * c - tx * d) * id;
|
||||
newPos.y = a * id * y + -b * id * x + (-ty * a + tx * b) * id;
|
||||
return newPos;
|
||||
}
|
||||
/**
|
||||
* Translates the matrix on the x and y.
|
||||
* @param x - How much to translate x by
|
||||
* @param y - How much to translate y by
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
translate(x, y) {
|
||||
this.tx += x;
|
||||
this.ty += y;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Applies a scale transformation to the matrix.
|
||||
* @param x - The amount to scale horizontally
|
||||
* @param y - The amount to scale vertically
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
scale(x, y) {
|
||||
this.a *= x;
|
||||
this.d *= y;
|
||||
this.c *= x;
|
||||
this.b *= y;
|
||||
this.tx *= x;
|
||||
this.ty *= y;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Applies a rotation transformation to the matrix.
|
||||
* @param angle - The angle in radians.
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
rotate(angle) {
|
||||
const cos = Math.cos(angle);
|
||||
const sin = Math.sin(angle);
|
||||
const a1 = this.a;
|
||||
const c1 = this.c;
|
||||
const tx1 = this.tx;
|
||||
this.a = a1 * cos - this.b * sin;
|
||||
this.b = a1 * sin + this.b * cos;
|
||||
this.c = c1 * cos - this.d * sin;
|
||||
this.d = c1 * sin + this.d * cos;
|
||||
this.tx = tx1 * cos - this.ty * sin;
|
||||
this.ty = tx1 * sin + this.ty * cos;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Appends the given Matrix to this Matrix.
|
||||
* @param matrix - The matrix to append.
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
append(matrix) {
|
||||
const a1 = this.a;
|
||||
const b1 = this.b;
|
||||
const c1 = this.c;
|
||||
const d1 = this.d;
|
||||
this.a = matrix.a * a1 + matrix.b * c1;
|
||||
this.b = matrix.a * b1 + matrix.b * d1;
|
||||
this.c = matrix.c * a1 + matrix.d * c1;
|
||||
this.d = matrix.c * b1 + matrix.d * d1;
|
||||
this.tx = matrix.tx * a1 + matrix.ty * c1 + this.tx;
|
||||
this.ty = matrix.tx * b1 + matrix.ty * d1 + this.ty;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Appends two matrix's and sets the result to this matrix. AB = A * B
|
||||
* @param a - The matrix to append.
|
||||
* @param b - The matrix to append.
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
appendFrom(a, b) {
|
||||
const a1 = a.a;
|
||||
const b1 = a.b;
|
||||
const c1 = a.c;
|
||||
const d1 = a.d;
|
||||
const tx = a.tx;
|
||||
const ty = a.ty;
|
||||
const a2 = b.a;
|
||||
const b2 = b.b;
|
||||
const c2 = b.c;
|
||||
const d2 = b.d;
|
||||
this.a = a1 * a2 + b1 * c2;
|
||||
this.b = a1 * b2 + b1 * d2;
|
||||
this.c = c1 * a2 + d1 * c2;
|
||||
this.d = c1 * b2 + d1 * d2;
|
||||
this.tx = tx * a2 + ty * c2 + b.tx;
|
||||
this.ty = tx * b2 + ty * d2 + b.ty;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets the matrix based on all the available properties
|
||||
* @param x - Position on the x axis
|
||||
* @param y - Position on the y axis
|
||||
* @param pivotX - Pivot on the x axis
|
||||
* @param pivotY - Pivot on the y axis
|
||||
* @param scaleX - Scale on the x axis
|
||||
* @param scaleY - Scale on the y axis
|
||||
* @param rotation - Rotation in radians
|
||||
* @param skewX - Skew on the x axis
|
||||
* @param skewY - Skew on the y axis
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
setTransform(x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) {
|
||||
this.a = Math.cos(rotation + skewY) * scaleX;
|
||||
this.b = Math.sin(rotation + skewY) * scaleX;
|
||||
this.c = -Math.sin(rotation - skewX) * scaleY;
|
||||
this.d = Math.cos(rotation - skewX) * scaleY;
|
||||
this.tx = x - (pivotX * this.a + pivotY * this.c);
|
||||
this.ty = y - (pivotX * this.b + pivotY * this.d);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Prepends the given Matrix to this Matrix.
|
||||
* @param matrix - The matrix to prepend
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
prepend(matrix) {
|
||||
const tx1 = this.tx;
|
||||
if (matrix.a !== 1 || matrix.b !== 0 || matrix.c !== 0 || matrix.d !== 1) {
|
||||
const a1 = this.a;
|
||||
const c1 = this.c;
|
||||
this.a = a1 * matrix.a + this.b * matrix.c;
|
||||
this.b = a1 * matrix.b + this.b * matrix.d;
|
||||
this.c = c1 * matrix.a + this.d * matrix.c;
|
||||
this.d = c1 * matrix.b + this.d * matrix.d;
|
||||
}
|
||||
this.tx = tx1 * matrix.a + this.ty * matrix.c + matrix.tx;
|
||||
this.ty = tx1 * matrix.b + this.ty * matrix.d + matrix.ty;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.
|
||||
* @param transform - The transform to apply the properties to.
|
||||
* @returns The transform with the newly applied properties
|
||||
*/
|
||||
decompose(transform) {
|
||||
const a = this.a;
|
||||
const b = this.b;
|
||||
const c = this.c;
|
||||
const d = this.d;
|
||||
const pivot = transform.pivot;
|
||||
const skewX = -Math.atan2(-c, d);
|
||||
const skewY = Math.atan2(b, a);
|
||||
const delta = Math.abs(skewX + skewY);
|
||||
if (delta < 1e-5 || Math.abs(_const.PI_2 - delta) < 1e-5) {
|
||||
transform.rotation = skewY;
|
||||
transform.skew.x = transform.skew.y = 0;
|
||||
} else {
|
||||
transform.rotation = 0;
|
||||
transform.skew.x = skewX;
|
||||
transform.skew.y = skewY;
|
||||
}
|
||||
transform.scale.x = Math.sqrt(a * a + b * b);
|
||||
transform.scale.y = Math.sqrt(c * c + d * d);
|
||||
transform.position.x = this.tx + (pivot.x * a + pivot.y * c);
|
||||
transform.position.y = this.ty + (pivot.x * b + pivot.y * d);
|
||||
return transform;
|
||||
}
|
||||
/**
|
||||
* Inverts this matrix
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
invert() {
|
||||
const a1 = this.a;
|
||||
const b1 = this.b;
|
||||
const c1 = this.c;
|
||||
const d1 = this.d;
|
||||
const tx1 = this.tx;
|
||||
const n = a1 * d1 - b1 * c1;
|
||||
this.a = d1 / n;
|
||||
this.b = -b1 / n;
|
||||
this.c = -c1 / n;
|
||||
this.d = a1 / n;
|
||||
this.tx = (c1 * this.ty - d1 * tx1) / n;
|
||||
this.ty = -(a1 * this.ty - b1 * tx1) / n;
|
||||
return this;
|
||||
}
|
||||
/** Checks if this matrix is an identity matrix */
|
||||
isIdentity() {
|
||||
return this.a === 1 && this.b === 0 && this.c === 0 && this.d === 1 && this.tx === 0 && this.ty === 0;
|
||||
}
|
||||
/**
|
||||
* Resets this Matrix to an identity (default) matrix.
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
identity() {
|
||||
this.a = 1;
|
||||
this.b = 0;
|
||||
this.c = 0;
|
||||
this.d = 1;
|
||||
this.tx = 0;
|
||||
this.ty = 0;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Creates a new Matrix object with the same values as this one.
|
||||
* @returns A copy of this matrix. Good for chaining method calls.
|
||||
*/
|
||||
clone() {
|
||||
const matrix = new Matrix();
|
||||
matrix.a = this.a;
|
||||
matrix.b = this.b;
|
||||
matrix.c = this.c;
|
||||
matrix.d = this.d;
|
||||
matrix.tx = this.tx;
|
||||
matrix.ty = this.ty;
|
||||
return matrix;
|
||||
}
|
||||
/**
|
||||
* Changes the values of the given matrix to be the same as the ones in this matrix
|
||||
* @param matrix - The matrix to copy to.
|
||||
* @returns The matrix given in parameter with its values updated.
|
||||
*/
|
||||
copyTo(matrix) {
|
||||
matrix.a = this.a;
|
||||
matrix.b = this.b;
|
||||
matrix.c = this.c;
|
||||
matrix.d = this.d;
|
||||
matrix.tx = this.tx;
|
||||
matrix.ty = this.ty;
|
||||
return matrix;
|
||||
}
|
||||
/**
|
||||
* Changes the values of the matrix to be the same as the ones in given matrix
|
||||
* @param matrix - The matrix to copy from.
|
||||
* @returns this
|
||||
*/
|
||||
copyFrom(matrix) {
|
||||
this.a = matrix.a;
|
||||
this.b = matrix.b;
|
||||
this.c = matrix.c;
|
||||
this.d = matrix.d;
|
||||
this.tx = matrix.tx;
|
||||
this.ty = matrix.ty;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* check to see if two matrices are the same
|
||||
* @param matrix - The matrix to compare to.
|
||||
*/
|
||||
equals(matrix) {
|
||||
return matrix.a === this.a && matrix.b === this.b && matrix.c === this.c && matrix.d === this.d && matrix.tx === this.tx && matrix.ty === this.ty;
|
||||
}
|
||||
toString() {
|
||||
return `[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`;
|
||||
}
|
||||
/**
|
||||
* A default (identity) matrix.
|
||||
*
|
||||
* This is a shared object, if you want to modify it consider creating a new `Matrix`
|
||||
* @readonly
|
||||
*/
|
||||
static get IDENTITY() {
|
||||
return identityMatrix.identity();
|
||||
}
|
||||
/**
|
||||
* A static Matrix that can be used to avoid creating new objects.
|
||||
* Will always ensure the matrix is reset to identity when requested.
|
||||
* Use this object for fast but temporary calculations, as it may be mutated later on.
|
||||
* This is a different object to the `IDENTITY` object and so can be modified without changing `IDENTITY`.
|
||||
* @readonly
|
||||
*/
|
||||
static get shared() {
|
||||
return tempMatrix.identity();
|
||||
}
|
||||
}
|
||||
const tempMatrix = new Matrix();
|
||||
const identityMatrix = new Matrix();
|
||||
|
||||
exports.Matrix = Matrix;
|
||||
//# sourceMappingURL=Matrix.js.map
|
||||
1
node_modules/pixi.js/lib/maths/matrix/Matrix.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/maths/matrix/Matrix.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
402
node_modules/pixi.js/lib/maths/matrix/Matrix.mjs
generated
vendored
Normal file
402
node_modules/pixi.js/lib/maths/matrix/Matrix.mjs
generated
vendored
Normal file
@@ -0,0 +1,402 @@
|
||||
import { PI_2 } from '../misc/const.mjs';
|
||||
import { Point } from '../point/Point.mjs';
|
||||
|
||||
"use strict";
|
||||
class Matrix {
|
||||
/**
|
||||
* @param a - x scale
|
||||
* @param b - y skew
|
||||
* @param c - x skew
|
||||
* @param d - y scale
|
||||
* @param tx - x translation
|
||||
* @param ty - y translation
|
||||
*/
|
||||
constructor(a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0) {
|
||||
/** An array of the current matrix. Only populated when `toArray` is called */
|
||||
this.array = null;
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
this.tx = tx;
|
||||
this.ty = ty;
|
||||
}
|
||||
/**
|
||||
* Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:
|
||||
*
|
||||
* a = array[0]
|
||||
* b = array[1]
|
||||
* c = array[3]
|
||||
* d = array[4]
|
||||
* tx = array[2]
|
||||
* ty = array[5]
|
||||
* @param array - The array that the matrix will be populated from.
|
||||
*/
|
||||
fromArray(array) {
|
||||
this.a = array[0];
|
||||
this.b = array[1];
|
||||
this.c = array[3];
|
||||
this.d = array[4];
|
||||
this.tx = array[2];
|
||||
this.ty = array[5];
|
||||
}
|
||||
/**
|
||||
* Sets the matrix properties.
|
||||
* @param a - Matrix component
|
||||
* @param b - Matrix component
|
||||
* @param c - Matrix component
|
||||
* @param d - Matrix component
|
||||
* @param tx - Matrix component
|
||||
* @param ty - Matrix component
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
set(a, b, c, d, tx, ty) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
this.tx = tx;
|
||||
this.ty = ty;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Creates an array from the current Matrix object.
|
||||
* @param transpose - Whether we need to transpose the matrix or not
|
||||
* @param [out=new Float32Array(9)] - If provided the array will be assigned to out
|
||||
* @returns The newly created array which contains the matrix
|
||||
*/
|
||||
toArray(transpose, out) {
|
||||
if (!this.array) {
|
||||
this.array = new Float32Array(9);
|
||||
}
|
||||
const array = out || this.array;
|
||||
if (transpose) {
|
||||
array[0] = this.a;
|
||||
array[1] = this.b;
|
||||
array[2] = 0;
|
||||
array[3] = this.c;
|
||||
array[4] = this.d;
|
||||
array[5] = 0;
|
||||
array[6] = this.tx;
|
||||
array[7] = this.ty;
|
||||
array[8] = 1;
|
||||
} else {
|
||||
array[0] = this.a;
|
||||
array[1] = this.c;
|
||||
array[2] = this.tx;
|
||||
array[3] = this.b;
|
||||
array[4] = this.d;
|
||||
array[5] = this.ty;
|
||||
array[6] = 0;
|
||||
array[7] = 0;
|
||||
array[8] = 1;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
/**
|
||||
* Get a new position with the current transformation applied.
|
||||
* Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)
|
||||
* @param pos - The origin
|
||||
* @param {Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)
|
||||
* @returns {Point} The new point, transformed through this matrix
|
||||
*/
|
||||
apply(pos, newPos) {
|
||||
newPos = newPos || new Point();
|
||||
const x = pos.x;
|
||||
const y = pos.y;
|
||||
newPos.x = this.a * x + this.c * y + this.tx;
|
||||
newPos.y = this.b * x + this.d * y + this.ty;
|
||||
return newPos;
|
||||
}
|
||||
/**
|
||||
* Get a new position with the inverse of the current transformation applied.
|
||||
* Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)
|
||||
* @param pos - The origin
|
||||
* @param {Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)
|
||||
* @returns {Point} The new point, inverse-transformed through this matrix
|
||||
*/
|
||||
applyInverse(pos, newPos) {
|
||||
newPos = newPos || new Point();
|
||||
const a = this.a;
|
||||
const b = this.b;
|
||||
const c = this.c;
|
||||
const d = this.d;
|
||||
const tx = this.tx;
|
||||
const ty = this.ty;
|
||||
const id = 1 / (a * d + c * -b);
|
||||
const x = pos.x;
|
||||
const y = pos.y;
|
||||
newPos.x = d * id * x + -c * id * y + (ty * c - tx * d) * id;
|
||||
newPos.y = a * id * y + -b * id * x + (-ty * a + tx * b) * id;
|
||||
return newPos;
|
||||
}
|
||||
/**
|
||||
* Translates the matrix on the x and y.
|
||||
* @param x - How much to translate x by
|
||||
* @param y - How much to translate y by
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
translate(x, y) {
|
||||
this.tx += x;
|
||||
this.ty += y;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Applies a scale transformation to the matrix.
|
||||
* @param x - The amount to scale horizontally
|
||||
* @param y - The amount to scale vertically
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
scale(x, y) {
|
||||
this.a *= x;
|
||||
this.d *= y;
|
||||
this.c *= x;
|
||||
this.b *= y;
|
||||
this.tx *= x;
|
||||
this.ty *= y;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Applies a rotation transformation to the matrix.
|
||||
* @param angle - The angle in radians.
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
rotate(angle) {
|
||||
const cos = Math.cos(angle);
|
||||
const sin = Math.sin(angle);
|
||||
const a1 = this.a;
|
||||
const c1 = this.c;
|
||||
const tx1 = this.tx;
|
||||
this.a = a1 * cos - this.b * sin;
|
||||
this.b = a1 * sin + this.b * cos;
|
||||
this.c = c1 * cos - this.d * sin;
|
||||
this.d = c1 * sin + this.d * cos;
|
||||
this.tx = tx1 * cos - this.ty * sin;
|
||||
this.ty = tx1 * sin + this.ty * cos;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Appends the given Matrix to this Matrix.
|
||||
* @param matrix - The matrix to append.
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
append(matrix) {
|
||||
const a1 = this.a;
|
||||
const b1 = this.b;
|
||||
const c1 = this.c;
|
||||
const d1 = this.d;
|
||||
this.a = matrix.a * a1 + matrix.b * c1;
|
||||
this.b = matrix.a * b1 + matrix.b * d1;
|
||||
this.c = matrix.c * a1 + matrix.d * c1;
|
||||
this.d = matrix.c * b1 + matrix.d * d1;
|
||||
this.tx = matrix.tx * a1 + matrix.ty * c1 + this.tx;
|
||||
this.ty = matrix.tx * b1 + matrix.ty * d1 + this.ty;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Appends two matrix's and sets the result to this matrix. AB = A * B
|
||||
* @param a - The matrix to append.
|
||||
* @param b - The matrix to append.
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
appendFrom(a, b) {
|
||||
const a1 = a.a;
|
||||
const b1 = a.b;
|
||||
const c1 = a.c;
|
||||
const d1 = a.d;
|
||||
const tx = a.tx;
|
||||
const ty = a.ty;
|
||||
const a2 = b.a;
|
||||
const b2 = b.b;
|
||||
const c2 = b.c;
|
||||
const d2 = b.d;
|
||||
this.a = a1 * a2 + b1 * c2;
|
||||
this.b = a1 * b2 + b1 * d2;
|
||||
this.c = c1 * a2 + d1 * c2;
|
||||
this.d = c1 * b2 + d1 * d2;
|
||||
this.tx = tx * a2 + ty * c2 + b.tx;
|
||||
this.ty = tx * b2 + ty * d2 + b.ty;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets the matrix based on all the available properties
|
||||
* @param x - Position on the x axis
|
||||
* @param y - Position on the y axis
|
||||
* @param pivotX - Pivot on the x axis
|
||||
* @param pivotY - Pivot on the y axis
|
||||
* @param scaleX - Scale on the x axis
|
||||
* @param scaleY - Scale on the y axis
|
||||
* @param rotation - Rotation in radians
|
||||
* @param skewX - Skew on the x axis
|
||||
* @param skewY - Skew on the y axis
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
setTransform(x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) {
|
||||
this.a = Math.cos(rotation + skewY) * scaleX;
|
||||
this.b = Math.sin(rotation + skewY) * scaleX;
|
||||
this.c = -Math.sin(rotation - skewX) * scaleY;
|
||||
this.d = Math.cos(rotation - skewX) * scaleY;
|
||||
this.tx = x - (pivotX * this.a + pivotY * this.c);
|
||||
this.ty = y - (pivotX * this.b + pivotY * this.d);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Prepends the given Matrix to this Matrix.
|
||||
* @param matrix - The matrix to prepend
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
prepend(matrix) {
|
||||
const tx1 = this.tx;
|
||||
if (matrix.a !== 1 || matrix.b !== 0 || matrix.c !== 0 || matrix.d !== 1) {
|
||||
const a1 = this.a;
|
||||
const c1 = this.c;
|
||||
this.a = a1 * matrix.a + this.b * matrix.c;
|
||||
this.b = a1 * matrix.b + this.b * matrix.d;
|
||||
this.c = c1 * matrix.a + this.d * matrix.c;
|
||||
this.d = c1 * matrix.b + this.d * matrix.d;
|
||||
}
|
||||
this.tx = tx1 * matrix.a + this.ty * matrix.c + matrix.tx;
|
||||
this.ty = tx1 * matrix.b + this.ty * matrix.d + matrix.ty;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.
|
||||
* @param transform - The transform to apply the properties to.
|
||||
* @returns The transform with the newly applied properties
|
||||
*/
|
||||
decompose(transform) {
|
||||
const a = this.a;
|
||||
const b = this.b;
|
||||
const c = this.c;
|
||||
const d = this.d;
|
||||
const pivot = transform.pivot;
|
||||
const skewX = -Math.atan2(-c, d);
|
||||
const skewY = Math.atan2(b, a);
|
||||
const delta = Math.abs(skewX + skewY);
|
||||
if (delta < 1e-5 || Math.abs(PI_2 - delta) < 1e-5) {
|
||||
transform.rotation = skewY;
|
||||
transform.skew.x = transform.skew.y = 0;
|
||||
} else {
|
||||
transform.rotation = 0;
|
||||
transform.skew.x = skewX;
|
||||
transform.skew.y = skewY;
|
||||
}
|
||||
transform.scale.x = Math.sqrt(a * a + b * b);
|
||||
transform.scale.y = Math.sqrt(c * c + d * d);
|
||||
transform.position.x = this.tx + (pivot.x * a + pivot.y * c);
|
||||
transform.position.y = this.ty + (pivot.x * b + pivot.y * d);
|
||||
return transform;
|
||||
}
|
||||
/**
|
||||
* Inverts this matrix
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
invert() {
|
||||
const a1 = this.a;
|
||||
const b1 = this.b;
|
||||
const c1 = this.c;
|
||||
const d1 = this.d;
|
||||
const tx1 = this.tx;
|
||||
const n = a1 * d1 - b1 * c1;
|
||||
this.a = d1 / n;
|
||||
this.b = -b1 / n;
|
||||
this.c = -c1 / n;
|
||||
this.d = a1 / n;
|
||||
this.tx = (c1 * this.ty - d1 * tx1) / n;
|
||||
this.ty = -(a1 * this.ty - b1 * tx1) / n;
|
||||
return this;
|
||||
}
|
||||
/** Checks if this matrix is an identity matrix */
|
||||
isIdentity() {
|
||||
return this.a === 1 && this.b === 0 && this.c === 0 && this.d === 1 && this.tx === 0 && this.ty === 0;
|
||||
}
|
||||
/**
|
||||
* Resets this Matrix to an identity (default) matrix.
|
||||
* @returns This matrix. Good for chaining method calls.
|
||||
*/
|
||||
identity() {
|
||||
this.a = 1;
|
||||
this.b = 0;
|
||||
this.c = 0;
|
||||
this.d = 1;
|
||||
this.tx = 0;
|
||||
this.ty = 0;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Creates a new Matrix object with the same values as this one.
|
||||
* @returns A copy of this matrix. Good for chaining method calls.
|
||||
*/
|
||||
clone() {
|
||||
const matrix = new Matrix();
|
||||
matrix.a = this.a;
|
||||
matrix.b = this.b;
|
||||
matrix.c = this.c;
|
||||
matrix.d = this.d;
|
||||
matrix.tx = this.tx;
|
||||
matrix.ty = this.ty;
|
||||
return matrix;
|
||||
}
|
||||
/**
|
||||
* Changes the values of the given matrix to be the same as the ones in this matrix
|
||||
* @param matrix - The matrix to copy to.
|
||||
* @returns The matrix given in parameter with its values updated.
|
||||
*/
|
||||
copyTo(matrix) {
|
||||
matrix.a = this.a;
|
||||
matrix.b = this.b;
|
||||
matrix.c = this.c;
|
||||
matrix.d = this.d;
|
||||
matrix.tx = this.tx;
|
||||
matrix.ty = this.ty;
|
||||
return matrix;
|
||||
}
|
||||
/**
|
||||
* Changes the values of the matrix to be the same as the ones in given matrix
|
||||
* @param matrix - The matrix to copy from.
|
||||
* @returns this
|
||||
*/
|
||||
copyFrom(matrix) {
|
||||
this.a = matrix.a;
|
||||
this.b = matrix.b;
|
||||
this.c = matrix.c;
|
||||
this.d = matrix.d;
|
||||
this.tx = matrix.tx;
|
||||
this.ty = matrix.ty;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* check to see if two matrices are the same
|
||||
* @param matrix - The matrix to compare to.
|
||||
*/
|
||||
equals(matrix) {
|
||||
return matrix.a === this.a && matrix.b === this.b && matrix.c === this.c && matrix.d === this.d && matrix.tx === this.tx && matrix.ty === this.ty;
|
||||
}
|
||||
toString() {
|
||||
return `[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`;
|
||||
}
|
||||
/**
|
||||
* A default (identity) matrix.
|
||||
*
|
||||
* This is a shared object, if you want to modify it consider creating a new `Matrix`
|
||||
* @readonly
|
||||
*/
|
||||
static get IDENTITY() {
|
||||
return identityMatrix.identity();
|
||||
}
|
||||
/**
|
||||
* A static Matrix that can be used to avoid creating new objects.
|
||||
* Will always ensure the matrix is reset to identity when requested.
|
||||
* Use this object for fast but temporary calculations, as it may be mutated later on.
|
||||
* This is a different object to the `IDENTITY` object and so can be modified without changing `IDENTITY`.
|
||||
* @readonly
|
||||
*/
|
||||
static get shared() {
|
||||
return tempMatrix.identity();
|
||||
}
|
||||
}
|
||||
const tempMatrix = new Matrix();
|
||||
const identityMatrix = new Matrix();
|
||||
|
||||
export { Matrix };
|
||||
//# sourceMappingURL=Matrix.mjs.map
|
||||
1
node_modules/pixi.js/lib/maths/matrix/Matrix.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/maths/matrix/Matrix.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
224
node_modules/pixi.js/lib/maths/matrix/groupD8.d.ts
generated
vendored
Normal file
224
node_modules/pixi.js/lib/maths/matrix/groupD8.d.ts
generated
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
import { Matrix } from './Matrix';
|
||||
type GD8Symmetry = number;
|
||||
/**
|
||||
* @typedef {number} GD8Symmetry
|
||||
* @see groupD8
|
||||
*/
|
||||
/**
|
||||
* Implements the dihedral group D8, which is similar to
|
||||
* [group D4]{@link http://mathworld.wolfram.com/DihedralGroupD4.html};
|
||||
* D8 is the same but with diagonals, and it is used for texture
|
||||
* rotations.
|
||||
*
|
||||
* The directions the U- and V- axes after rotation
|
||||
* of an angle of `a: GD8Constant` are the vectors `(uX(a), uY(a))`
|
||||
* and `(vX(a), vY(a))`. These aren't necessarily unit vectors.
|
||||
*
|
||||
* **Origin:**<br>
|
||||
* This is the small part of gameofbombs.com portal system. It works.
|
||||
* @see maths.groupD8.E
|
||||
* @see maths.groupD8.SE
|
||||
* @see maths.groupD8.S
|
||||
* @see maths.groupD8.SW
|
||||
* @see maths.groupD8.W
|
||||
* @see maths.groupD8.NW
|
||||
* @see maths.groupD8.N
|
||||
* @see maths.groupD8.NE
|
||||
* @author Ivan @ivanpopelyshev
|
||||
* @namespace maths.groupD8
|
||||
*/
|
||||
export declare const groupD8: {
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 0° | East |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
E: number;
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 45°↻ | Southeast |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
SE: number;
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 90°↻ | South |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
S: number;
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 135°↻ | Southwest |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
SW: number;
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 180° | West |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
W: number;
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |-------------|--------------|
|
||||
* | -135°/225°↻ | Northwest |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
NW: number;
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |-------------|--------------|
|
||||
* | -90°/270°↻ | North |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
N: number;
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |-------------|--------------|
|
||||
* | -45°/315°↻ | Northeast |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
NE: number;
|
||||
/**
|
||||
* Reflection about Y-axis.
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
MIRROR_VERTICAL: number;
|
||||
/**
|
||||
* Reflection about the main diagonal.
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
MAIN_DIAGONAL: number;
|
||||
/**
|
||||
* Reflection about X-axis.
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
MIRROR_HORIZONTAL: number;
|
||||
/**
|
||||
* Reflection about reverse diagonal.
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
REVERSE_DIAGONAL: number;
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} ind - sprite rotation angle.
|
||||
* @returns {GD8Symmetry} The X-component of the U-axis
|
||||
* after rotating the axes.
|
||||
*/
|
||||
uX: (ind: GD8Symmetry) => GD8Symmetry;
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} ind - sprite rotation angle.
|
||||
* @returns {GD8Symmetry} The Y-component of the U-axis
|
||||
* after rotating the axes.
|
||||
*/
|
||||
uY: (ind: GD8Symmetry) => GD8Symmetry;
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} ind - sprite rotation angle.
|
||||
* @returns {GD8Symmetry} The X-component of the V-axis
|
||||
* after rotating the axes.
|
||||
*/
|
||||
vX: (ind: GD8Symmetry) => GD8Symmetry;
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} ind - sprite rotation angle.
|
||||
* @returns {GD8Symmetry} The Y-component of the V-axis
|
||||
* after rotating the axes.
|
||||
*/
|
||||
vY: (ind: GD8Symmetry) => GD8Symmetry;
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} rotation - symmetry whose opposite
|
||||
* is needed. Only rotations have opposite symmetries while
|
||||
* reflections don't.
|
||||
* @returns {GD8Symmetry} The opposite symmetry of `rotation`
|
||||
*/
|
||||
inv: (rotation: GD8Symmetry) => GD8Symmetry;
|
||||
/**
|
||||
* Composes the two D8 operations.
|
||||
*
|
||||
* Taking `^` as reflection:
|
||||
*
|
||||
* | | E=0 | S=2 | W=4 | N=6 | E^=8 | S^=10 | W^=12 | N^=14 |
|
||||
* |-------|-----|-----|-----|-----|------|-------|-------|-------|
|
||||
* | E=0 | E | S | W | N | E^ | S^ | W^ | N^ |
|
||||
* | S=2 | S | W | N | E | S^ | W^ | N^ | E^ |
|
||||
* | W=4 | W | N | E | S | W^ | N^ | E^ | S^ |
|
||||
* | N=6 | N | E | S | W | N^ | E^ | S^ | W^ |
|
||||
* | E^=8 | E^ | N^ | W^ | S^ | E | N | W | S |
|
||||
* | S^=10 | S^ | E^ | N^ | W^ | S | E | N | W |
|
||||
* | W^=12 | W^ | S^ | E^ | N^ | W | S | E | N |
|
||||
* | N^=14 | N^ | W^ | S^ | E^ | N | W | S | E |
|
||||
*
|
||||
* [This is a Cayley table]{@link https://en.wikipedia.org/wiki/Cayley_table}
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} rotationSecond - Second operation, which
|
||||
* is the row in the above cayley table.
|
||||
* @param {GD8Symmetry} rotationFirst - First operation, which
|
||||
* is the column in the above cayley table.
|
||||
* @returns {GD8Symmetry} Composed operation
|
||||
*/
|
||||
add: (rotationSecond: GD8Symmetry, rotationFirst: GD8Symmetry) => GD8Symmetry;
|
||||
/**
|
||||
* Reverse of `add`.
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} rotationSecond - Second operation
|
||||
* @param {GD8Symmetry} rotationFirst - First operation
|
||||
* @returns {GD8Symmetry} Result
|
||||
*/
|
||||
sub: (rotationSecond: GD8Symmetry, rotationFirst: GD8Symmetry) => GD8Symmetry;
|
||||
/**
|
||||
* Adds 180 degrees to rotation, which is a commutative
|
||||
* operation.
|
||||
* @memberof maths.groupD8
|
||||
* @param {number} rotation - The number to rotate.
|
||||
* @returns {number} Rotated number
|
||||
*/
|
||||
rotate180: (rotation: number) => number;
|
||||
/**
|
||||
* Checks if the rotation angle is vertical, i.e. south
|
||||
* or north. It doesn't work for reflections.
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} rotation - The number to check.
|
||||
* @returns {boolean} Whether or not the direction is vertical
|
||||
*/
|
||||
isVertical: (rotation: GD8Symmetry) => boolean;
|
||||
/**
|
||||
* Approximates the vector `V(dx,dy)` into one of the
|
||||
* eight directions provided by `groupD8`.
|
||||
* @memberof maths.groupD8
|
||||
* @param {number} dx - X-component of the vector
|
||||
* @param {number} dy - Y-component of the vector
|
||||
* @returns {GD8Symmetry} Approximation of the vector into
|
||||
* one of the eight symmetries.
|
||||
*/
|
||||
byDirection: (dx: number, dy: number) => GD8Symmetry;
|
||||
/**
|
||||
* Helps sprite to compensate texture packer rotation.
|
||||
* @memberof maths.groupD8
|
||||
* @param {Matrix} matrix - sprite world matrix
|
||||
* @param {GD8Symmetry} rotation - The rotation factor to use.
|
||||
* @param {number} tx - sprite anchoring
|
||||
* @param {number} ty - sprite anchoring
|
||||
*/
|
||||
matrixAppendRotationInv: (matrix: Matrix, rotation: GD8Symmetry, tx?: number, ty?: number) => void;
|
||||
};
|
||||
export {};
|
||||
264
node_modules/pixi.js/lib/maths/matrix/groupD8.js
generated
vendored
Normal file
264
node_modules/pixi.js/lib/maths/matrix/groupD8.js
generated
vendored
Normal file
@@ -0,0 +1,264 @@
|
||||
'use strict';
|
||||
|
||||
var Matrix = require('./Matrix.js');
|
||||
|
||||
"use strict";
|
||||
const ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1];
|
||||
const uy = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1];
|
||||
const vx = [0, -1, -1, -1, 0, 1, 1, 1, 0, 1, 1, 1, 0, -1, -1, -1];
|
||||
const vy = [1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, 1, 1, 1, 0, -1];
|
||||
const rotationCayley = [];
|
||||
const rotationMatrices = [];
|
||||
const signum = Math.sign;
|
||||
function init() {
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const row = [];
|
||||
rotationCayley.push(row);
|
||||
for (let j = 0; j < 16; j++) {
|
||||
const _ux = signum(ux[i] * ux[j] + vx[i] * uy[j]);
|
||||
const _uy = signum(uy[i] * ux[j] + vy[i] * uy[j]);
|
||||
const _vx = signum(ux[i] * vx[j] + vx[i] * vy[j]);
|
||||
const _vy = signum(uy[i] * vx[j] + vy[i] * vy[j]);
|
||||
for (let k = 0; k < 16; k++) {
|
||||
if (ux[k] === _ux && uy[k] === _uy && vx[k] === _vx && vy[k] === _vy) {
|
||||
row.push(k);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const mat = new Matrix.Matrix();
|
||||
mat.set(ux[i], uy[i], vx[i], vy[i], 0, 0);
|
||||
rotationMatrices.push(mat);
|
||||
}
|
||||
}
|
||||
init();
|
||||
const groupD8 = {
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 0° | East |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
E: 0,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 45°↻ | Southeast |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
SE: 1,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 90°↻ | South |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
S: 2,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 135°↻ | Southwest |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
SW: 3,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 180° | West |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
W: 4,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |-------------|--------------|
|
||||
* | -135°/225°↻ | Northwest |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
NW: 5,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |-------------|--------------|
|
||||
* | -90°/270°↻ | North |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
N: 6,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |-------------|--------------|
|
||||
* | -45°/315°↻ | Northeast |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
NE: 7,
|
||||
/**
|
||||
* Reflection about Y-axis.
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
MIRROR_VERTICAL: 8,
|
||||
/**
|
||||
* Reflection about the main diagonal.
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
MAIN_DIAGONAL: 10,
|
||||
/**
|
||||
* Reflection about X-axis.
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
MIRROR_HORIZONTAL: 12,
|
||||
/**
|
||||
* Reflection about reverse diagonal.
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
REVERSE_DIAGONAL: 14,
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} ind - sprite rotation angle.
|
||||
* @returns {GD8Symmetry} The X-component of the U-axis
|
||||
* after rotating the axes.
|
||||
*/
|
||||
uX: (ind) => ux[ind],
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} ind - sprite rotation angle.
|
||||
* @returns {GD8Symmetry} The Y-component of the U-axis
|
||||
* after rotating the axes.
|
||||
*/
|
||||
uY: (ind) => uy[ind],
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} ind - sprite rotation angle.
|
||||
* @returns {GD8Symmetry} The X-component of the V-axis
|
||||
* after rotating the axes.
|
||||
*/
|
||||
vX: (ind) => vx[ind],
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} ind - sprite rotation angle.
|
||||
* @returns {GD8Symmetry} The Y-component of the V-axis
|
||||
* after rotating the axes.
|
||||
*/
|
||||
vY: (ind) => vy[ind],
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} rotation - symmetry whose opposite
|
||||
* is needed. Only rotations have opposite symmetries while
|
||||
* reflections don't.
|
||||
* @returns {GD8Symmetry} The opposite symmetry of `rotation`
|
||||
*/
|
||||
inv: (rotation) => {
|
||||
if (rotation & 8) {
|
||||
return rotation & 15;
|
||||
}
|
||||
return -rotation & 7;
|
||||
},
|
||||
/**
|
||||
* Composes the two D8 operations.
|
||||
*
|
||||
* Taking `^` as reflection:
|
||||
*
|
||||
* | | E=0 | S=2 | W=4 | N=6 | E^=8 | S^=10 | W^=12 | N^=14 |
|
||||
* |-------|-----|-----|-----|-----|------|-------|-------|-------|
|
||||
* | E=0 | E | S | W | N | E^ | S^ | W^ | N^ |
|
||||
* | S=2 | S | W | N | E | S^ | W^ | N^ | E^ |
|
||||
* | W=4 | W | N | E | S | W^ | N^ | E^ | S^ |
|
||||
* | N=6 | N | E | S | W | N^ | E^ | S^ | W^ |
|
||||
* | E^=8 | E^ | N^ | W^ | S^ | E | N | W | S |
|
||||
* | S^=10 | S^ | E^ | N^ | W^ | S | E | N | W |
|
||||
* | W^=12 | W^ | S^ | E^ | N^ | W | S | E | N |
|
||||
* | N^=14 | N^ | W^ | S^ | E^ | N | W | S | E |
|
||||
*
|
||||
* [This is a Cayley table]{@link https://en.wikipedia.org/wiki/Cayley_table}
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} rotationSecond - Second operation, which
|
||||
* is the row in the above cayley table.
|
||||
* @param {GD8Symmetry} rotationFirst - First operation, which
|
||||
* is the column in the above cayley table.
|
||||
* @returns {GD8Symmetry} Composed operation
|
||||
*/
|
||||
add: (rotationSecond, rotationFirst) => rotationCayley[rotationSecond][rotationFirst],
|
||||
/**
|
||||
* Reverse of `add`.
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} rotationSecond - Second operation
|
||||
* @param {GD8Symmetry} rotationFirst - First operation
|
||||
* @returns {GD8Symmetry} Result
|
||||
*/
|
||||
sub: (rotationSecond, rotationFirst) => rotationCayley[rotationSecond][groupD8.inv(rotationFirst)],
|
||||
/**
|
||||
* Adds 180 degrees to rotation, which is a commutative
|
||||
* operation.
|
||||
* @memberof maths.groupD8
|
||||
* @param {number} rotation - The number to rotate.
|
||||
* @returns {number} Rotated number
|
||||
*/
|
||||
rotate180: (rotation) => rotation ^ 4,
|
||||
/**
|
||||
* Checks if the rotation angle is vertical, i.e. south
|
||||
* or north. It doesn't work for reflections.
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} rotation - The number to check.
|
||||
* @returns {boolean} Whether or not the direction is vertical
|
||||
*/
|
||||
isVertical: (rotation) => (rotation & 3) === 2,
|
||||
// rotation % 4 === 2
|
||||
/**
|
||||
* Approximates the vector `V(dx,dy)` into one of the
|
||||
* eight directions provided by `groupD8`.
|
||||
* @memberof maths.groupD8
|
||||
* @param {number} dx - X-component of the vector
|
||||
* @param {number} dy - Y-component of the vector
|
||||
* @returns {GD8Symmetry} Approximation of the vector into
|
||||
* one of the eight symmetries.
|
||||
*/
|
||||
byDirection: (dx, dy) => {
|
||||
if (Math.abs(dx) * 2 <= Math.abs(dy)) {
|
||||
if (dy >= 0) {
|
||||
return groupD8.S;
|
||||
}
|
||||
return groupD8.N;
|
||||
} else if (Math.abs(dy) * 2 <= Math.abs(dx)) {
|
||||
if (dx > 0) {
|
||||
return groupD8.E;
|
||||
}
|
||||
return groupD8.W;
|
||||
} else if (dy > 0) {
|
||||
if (dx > 0) {
|
||||
return groupD8.SE;
|
||||
}
|
||||
return groupD8.SW;
|
||||
} else if (dx > 0) {
|
||||
return groupD8.NE;
|
||||
}
|
||||
return groupD8.NW;
|
||||
},
|
||||
/**
|
||||
* Helps sprite to compensate texture packer rotation.
|
||||
* @memberof maths.groupD8
|
||||
* @param {Matrix} matrix - sprite world matrix
|
||||
* @param {GD8Symmetry} rotation - The rotation factor to use.
|
||||
* @param {number} tx - sprite anchoring
|
||||
* @param {number} ty - sprite anchoring
|
||||
*/
|
||||
matrixAppendRotationInv: (matrix, rotation, tx = 0, ty = 0) => {
|
||||
const mat = rotationMatrices[groupD8.inv(rotation)];
|
||||
mat.tx = tx;
|
||||
mat.ty = ty;
|
||||
matrix.append(mat);
|
||||
}
|
||||
};
|
||||
|
||||
exports.groupD8 = groupD8;
|
||||
//# sourceMappingURL=groupD8.js.map
|
||||
1
node_modules/pixi.js/lib/maths/matrix/groupD8.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/maths/matrix/groupD8.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
262
node_modules/pixi.js/lib/maths/matrix/groupD8.mjs
generated
vendored
Normal file
262
node_modules/pixi.js/lib/maths/matrix/groupD8.mjs
generated
vendored
Normal file
@@ -0,0 +1,262 @@
|
||||
import { Matrix } from './Matrix.mjs';
|
||||
|
||||
"use strict";
|
||||
const ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1];
|
||||
const uy = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1];
|
||||
const vx = [0, -1, -1, -1, 0, 1, 1, 1, 0, 1, 1, 1, 0, -1, -1, -1];
|
||||
const vy = [1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, 1, 1, 1, 0, -1];
|
||||
const rotationCayley = [];
|
||||
const rotationMatrices = [];
|
||||
const signum = Math.sign;
|
||||
function init() {
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const row = [];
|
||||
rotationCayley.push(row);
|
||||
for (let j = 0; j < 16; j++) {
|
||||
const _ux = signum(ux[i] * ux[j] + vx[i] * uy[j]);
|
||||
const _uy = signum(uy[i] * ux[j] + vy[i] * uy[j]);
|
||||
const _vx = signum(ux[i] * vx[j] + vx[i] * vy[j]);
|
||||
const _vy = signum(uy[i] * vx[j] + vy[i] * vy[j]);
|
||||
for (let k = 0; k < 16; k++) {
|
||||
if (ux[k] === _ux && uy[k] === _uy && vx[k] === _vx && vy[k] === _vy) {
|
||||
row.push(k);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const mat = new Matrix();
|
||||
mat.set(ux[i], uy[i], vx[i], vy[i], 0, 0);
|
||||
rotationMatrices.push(mat);
|
||||
}
|
||||
}
|
||||
init();
|
||||
const groupD8 = {
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 0° | East |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
E: 0,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 45°↻ | Southeast |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
SE: 1,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 90°↻ | South |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
S: 2,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 135°↻ | Southwest |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
SW: 3,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |----------|-----------|
|
||||
* | 180° | West |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
W: 4,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |-------------|--------------|
|
||||
* | -135°/225°↻ | Northwest |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
NW: 5,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |-------------|--------------|
|
||||
* | -90°/270°↻ | North |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
N: 6,
|
||||
/**
|
||||
* | Rotation | Direction |
|
||||
* |-------------|--------------|
|
||||
* | -45°/315°↻ | Northeast |
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
NE: 7,
|
||||
/**
|
||||
* Reflection about Y-axis.
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
MIRROR_VERTICAL: 8,
|
||||
/**
|
||||
* Reflection about the main diagonal.
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
MAIN_DIAGONAL: 10,
|
||||
/**
|
||||
* Reflection about X-axis.
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
MIRROR_HORIZONTAL: 12,
|
||||
/**
|
||||
* Reflection about reverse diagonal.
|
||||
* @memberof maths.groupD8
|
||||
* @constant {GD8Symmetry}
|
||||
*/
|
||||
REVERSE_DIAGONAL: 14,
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} ind - sprite rotation angle.
|
||||
* @returns {GD8Symmetry} The X-component of the U-axis
|
||||
* after rotating the axes.
|
||||
*/
|
||||
uX: (ind) => ux[ind],
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} ind - sprite rotation angle.
|
||||
* @returns {GD8Symmetry} The Y-component of the U-axis
|
||||
* after rotating the axes.
|
||||
*/
|
||||
uY: (ind) => uy[ind],
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} ind - sprite rotation angle.
|
||||
* @returns {GD8Symmetry} The X-component of the V-axis
|
||||
* after rotating the axes.
|
||||
*/
|
||||
vX: (ind) => vx[ind],
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} ind - sprite rotation angle.
|
||||
* @returns {GD8Symmetry} The Y-component of the V-axis
|
||||
* after rotating the axes.
|
||||
*/
|
||||
vY: (ind) => vy[ind],
|
||||
/**
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} rotation - symmetry whose opposite
|
||||
* is needed. Only rotations have opposite symmetries while
|
||||
* reflections don't.
|
||||
* @returns {GD8Symmetry} The opposite symmetry of `rotation`
|
||||
*/
|
||||
inv: (rotation) => {
|
||||
if (rotation & 8) {
|
||||
return rotation & 15;
|
||||
}
|
||||
return -rotation & 7;
|
||||
},
|
||||
/**
|
||||
* Composes the two D8 operations.
|
||||
*
|
||||
* Taking `^` as reflection:
|
||||
*
|
||||
* | | E=0 | S=2 | W=4 | N=6 | E^=8 | S^=10 | W^=12 | N^=14 |
|
||||
* |-------|-----|-----|-----|-----|------|-------|-------|-------|
|
||||
* | E=0 | E | S | W | N | E^ | S^ | W^ | N^ |
|
||||
* | S=2 | S | W | N | E | S^ | W^ | N^ | E^ |
|
||||
* | W=4 | W | N | E | S | W^ | N^ | E^ | S^ |
|
||||
* | N=6 | N | E | S | W | N^ | E^ | S^ | W^ |
|
||||
* | E^=8 | E^ | N^ | W^ | S^ | E | N | W | S |
|
||||
* | S^=10 | S^ | E^ | N^ | W^ | S | E | N | W |
|
||||
* | W^=12 | W^ | S^ | E^ | N^ | W | S | E | N |
|
||||
* | N^=14 | N^ | W^ | S^ | E^ | N | W | S | E |
|
||||
*
|
||||
* [This is a Cayley table]{@link https://en.wikipedia.org/wiki/Cayley_table}
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} rotationSecond - Second operation, which
|
||||
* is the row in the above cayley table.
|
||||
* @param {GD8Symmetry} rotationFirst - First operation, which
|
||||
* is the column in the above cayley table.
|
||||
* @returns {GD8Symmetry} Composed operation
|
||||
*/
|
||||
add: (rotationSecond, rotationFirst) => rotationCayley[rotationSecond][rotationFirst],
|
||||
/**
|
||||
* Reverse of `add`.
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} rotationSecond - Second operation
|
||||
* @param {GD8Symmetry} rotationFirst - First operation
|
||||
* @returns {GD8Symmetry} Result
|
||||
*/
|
||||
sub: (rotationSecond, rotationFirst) => rotationCayley[rotationSecond][groupD8.inv(rotationFirst)],
|
||||
/**
|
||||
* Adds 180 degrees to rotation, which is a commutative
|
||||
* operation.
|
||||
* @memberof maths.groupD8
|
||||
* @param {number} rotation - The number to rotate.
|
||||
* @returns {number} Rotated number
|
||||
*/
|
||||
rotate180: (rotation) => rotation ^ 4,
|
||||
/**
|
||||
* Checks if the rotation angle is vertical, i.e. south
|
||||
* or north. It doesn't work for reflections.
|
||||
* @memberof maths.groupD8
|
||||
* @param {GD8Symmetry} rotation - The number to check.
|
||||
* @returns {boolean} Whether or not the direction is vertical
|
||||
*/
|
||||
isVertical: (rotation) => (rotation & 3) === 2,
|
||||
// rotation % 4 === 2
|
||||
/**
|
||||
* Approximates the vector `V(dx,dy)` into one of the
|
||||
* eight directions provided by `groupD8`.
|
||||
* @memberof maths.groupD8
|
||||
* @param {number} dx - X-component of the vector
|
||||
* @param {number} dy - Y-component of the vector
|
||||
* @returns {GD8Symmetry} Approximation of the vector into
|
||||
* one of the eight symmetries.
|
||||
*/
|
||||
byDirection: (dx, dy) => {
|
||||
if (Math.abs(dx) * 2 <= Math.abs(dy)) {
|
||||
if (dy >= 0) {
|
||||
return groupD8.S;
|
||||
}
|
||||
return groupD8.N;
|
||||
} else if (Math.abs(dy) * 2 <= Math.abs(dx)) {
|
||||
if (dx > 0) {
|
||||
return groupD8.E;
|
||||
}
|
||||
return groupD8.W;
|
||||
} else if (dy > 0) {
|
||||
if (dx > 0) {
|
||||
return groupD8.SE;
|
||||
}
|
||||
return groupD8.SW;
|
||||
} else if (dx > 0) {
|
||||
return groupD8.NE;
|
||||
}
|
||||
return groupD8.NW;
|
||||
},
|
||||
/**
|
||||
* Helps sprite to compensate texture packer rotation.
|
||||
* @memberof maths.groupD8
|
||||
* @param {Matrix} matrix - sprite world matrix
|
||||
* @param {GD8Symmetry} rotation - The rotation factor to use.
|
||||
* @param {number} tx - sprite anchoring
|
||||
* @param {number} ty - sprite anchoring
|
||||
*/
|
||||
matrixAppendRotationInv: (matrix, rotation, tx = 0, ty = 0) => {
|
||||
const mat = rotationMatrices[groupD8.inv(rotation)];
|
||||
mat.tx = tx;
|
||||
mat.ty = ty;
|
||||
matrix.append(mat);
|
||||
}
|
||||
};
|
||||
|
||||
export { groupD8 };
|
||||
//# sourceMappingURL=groupD8.mjs.map
|
||||
1
node_modules/pixi.js/lib/maths/matrix/groupD8.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/maths/matrix/groupD8.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user