@vpmedia/phaser 1.68.0 → 1.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +6 -5
- package/src/phaser/core/animation_parser.js +4 -4
- package/src/phaser/core/const.js +13 -0
- package/src/phaser/core/device_util.js +18 -18
- package/src/phaser/core/frame_util.js +4 -4
- package/src/phaser/core/loader_parser.js +32 -32
- package/src/phaser/core/scale_manager.js +2 -2
- package/src/phaser/core/sound_manager.js +5 -1
- package/src/phaser/core/tween.js +4 -2
- package/src/phaser/core/tween_data.js +4 -4
- package/src/phaser/core/tween_easing.js +62 -62
- package/src/phaser/core/tween_manager.js +1 -1
- package/src/phaser/display/bitmap_text.js +2 -2
- package/src/phaser/display/canvas/graphics.js +7 -7
- package/src/phaser/display/canvas/masker.js +4 -4
- package/src/phaser/display/canvas/pool.js +14 -14
- package/src/phaser/display/canvas/tinter.js +14 -16
- package/src/phaser/display/canvas/util.js +18 -18
- package/src/phaser/display/graphics_data_util.js +2 -2
- package/src/phaser/display/sprite_util.js +10 -10
- package/src/phaser/display/text.js +2 -2
- package/src/phaser/display/webgl/graphics.js +24 -24
- package/src/phaser/display/webgl/mask_manager.js +4 -4
- package/src/phaser/display/webgl/shader/complex.js +2 -2
- package/src/phaser/display/webgl/shader/fast.js +2 -2
- package/src/phaser/display/webgl/shader/normal.js +2 -2
- package/src/phaser/display/webgl/shader/primitive.js +2 -2
- package/src/phaser/display/webgl/shader/strip.js +2 -2
- package/src/phaser/display/webgl/texture_util.js +4 -4
- package/src/phaser/display/webgl/util.js +13 -13
- package/src/phaser/geom/util/circle.js +15 -15
- package/src/phaser/geom/util/ellipse.js +2 -2
- package/src/phaser/geom/util/line.js +11 -11
- package/src/phaser/geom/util/matrix.js +6 -6
- package/src/phaser/geom/util/point.js +42 -42
- package/src/phaser/geom/util/polygon.js +2 -2
- package/src/phaser/geom/util/rectangle.js +33 -33
- package/src/phaser/geom/util/rounded_rectangle.js +2 -2
- package/src/phaser/util/math.js +47 -63
- package/types/phaser/core/animation_parser.d.ts +0 -17
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/const.d.ts +12 -0
- package/types/phaser/core/const.d.ts.map +1 -1
- package/types/phaser/core/device_util.d.ts +2 -43
- package/types/phaser/core/device_util.d.ts.map +1 -1
- package/types/phaser/core/frame_util.d.ts +0 -12
- package/types/phaser/core/frame_util.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts +0 -30
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/sound_manager.d.ts +1 -0
- package/types/phaser/core/sound_manager.d.ts.map +1 -1
- package/types/phaser/core/tween.d.ts +4 -4
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +6 -6
- package/types/phaser/core/tween_data.d.ts.map +1 -1
- package/types/phaser/core/tween_easing.d.ts +0 -155
- package/types/phaser/core/tween_easing.d.ts.map +1 -1
- package/types/phaser/core/tween_manager.d.ts +41 -72
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/display/canvas/graphics.d.ts +0 -14
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/masker.d.ts +0 -9
- package/types/phaser/display/canvas/masker.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +0 -32
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/tinter.d.ts +2 -36
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts +0 -60
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/graphics_data_util.d.ts +0 -5
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/types/phaser/display/sprite_util.d.ts +0 -29
- package/types/phaser/display/sprite_util.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics.d.ts +0 -65
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/mask_manager.d.ts +0 -10
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture_util.d.ts +0 -12
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/display/webgl/util.d.ts +7 -46
- package/types/phaser/display/webgl/util.d.ts.map +1 -1
- package/types/phaser/geom/util/circle.d.ts +0 -47
- package/types/phaser/geom/util/circle.d.ts.map +1 -1
- package/types/phaser/geom/util/ellipse.d.ts +0 -7
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/util/line.d.ts +0 -36
- package/types/phaser/geom/util/line.d.ts.map +1 -1
- package/types/phaser/geom/util/matrix.d.ts +0 -14
- package/types/phaser/geom/util/matrix.d.ts.map +1 -1
- package/types/phaser/geom/util/point.d.ts +0 -137
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/types/phaser/geom/util/polygon.d.ts +0 -6
- package/types/phaser/geom/util/polygon.d.ts.map +1 -1
- package/types/phaser/geom/util/rectangle.d.ts +0 -106
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/rounded_rectangle.d.ts +0 -6
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/util/math.d.ts +3 -134
- package/types/phaser/util/math.d.ts.map +1 -1
|
@@ -7,7 +7,7 @@ import { Texture } from './texture.js';
|
|
|
7
7
|
* @param {number} scaleMode - TBD.
|
|
8
8
|
* @returns {object} TBD.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export const baseTextureFromCanvas = (canvas, scaleMode) => {
|
|
11
11
|
if (canvas.width === 0) {
|
|
12
12
|
canvas.width = 1;
|
|
13
13
|
}
|
|
@@ -15,7 +15,7 @@ export function baseTextureFromCanvas(canvas, scaleMode) {
|
|
|
15
15
|
canvas.height = 1;
|
|
16
16
|
}
|
|
17
17
|
return new BaseTexture(canvas, scaleMode);
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* TBD.
|
|
@@ -23,6 +23,6 @@ export function baseTextureFromCanvas(canvas, scaleMode) {
|
|
|
23
23
|
* @param {number} scaleMode - TBD.
|
|
24
24
|
* @returns {object} TBD.
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export const textureFromCanvas = (canvas, scaleMode) => {
|
|
27
27
|
return new Texture(baseTextureFromCanvas(canvas, scaleMode));
|
|
28
|
-
}
|
|
28
|
+
};
|
|
@@ -18,16 +18,16 @@ export const CONTEXT_LOST_WEBGL = 0x9242;
|
|
|
18
18
|
* @param {WebGLRenderingContext} gl - TBD.
|
|
19
19
|
* @returns {number} TBD.
|
|
20
20
|
*/
|
|
21
|
-
export
|
|
21
|
+
export const getWebGLContextErrorCode = (gl) => {
|
|
22
22
|
return gl?.getError() ?? 0;
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* TBD.
|
|
27
27
|
* @param {number} errorCode - TBD.
|
|
28
28
|
* @returns {string} TBD.
|
|
29
29
|
*/
|
|
30
|
-
export
|
|
30
|
+
export const getWebGLContextErrorName = (errorCode) => {
|
|
31
31
|
switch (errorCode) {
|
|
32
32
|
case NO_ERROR:
|
|
33
33
|
return 'NO_ERROR';
|
|
@@ -46,12 +46,12 @@ export function getWebGLContextErrorName(errorCode) {
|
|
|
46
46
|
default:
|
|
47
47
|
return `UNKNOWN_ERROR_${errorCode}`;
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
};
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* TBD.
|
|
53
53
|
*/
|
|
54
|
-
export
|
|
54
|
+
export const initDefaultShaders = () => {};
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* TBD.
|
|
@@ -60,7 +60,7 @@ export function initDefaultShaders() {}
|
|
|
60
60
|
* @param {object} shaderType - TBD.
|
|
61
61
|
* @returns {WebGLShader} TBD.
|
|
62
62
|
*/
|
|
63
|
-
export
|
|
63
|
+
export const compileShader = (gl, shaderSrc, shaderType) => {
|
|
64
64
|
let src = shaderSrc;
|
|
65
65
|
if (Array.isArray(shaderSrc)) {
|
|
66
66
|
src = shaderSrc.join('\n');
|
|
@@ -76,7 +76,7 @@ export function compileShader(gl, shaderSrc, shaderType) {
|
|
|
76
76
|
return null;
|
|
77
77
|
}
|
|
78
78
|
return shader;
|
|
79
|
-
}
|
|
79
|
+
};
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* TBD.
|
|
@@ -84,9 +84,9 @@ export function compileShader(gl, shaderSrc, shaderType) {
|
|
|
84
84
|
* @param {string[]|string} shaderSrc - TBD.
|
|
85
85
|
* @returns {WebGLShader} TBD.
|
|
86
86
|
*/
|
|
87
|
-
export
|
|
87
|
+
export const compileVertexShader = (gl, shaderSrc) => {
|
|
88
88
|
return compileShader(gl, shaderSrc, gl.VERTEX_SHADER);
|
|
89
|
-
}
|
|
89
|
+
};
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* TBD.
|
|
@@ -94,9 +94,9 @@ export function compileVertexShader(gl, shaderSrc) {
|
|
|
94
94
|
* @param {string[]|string} shaderSrc - TBD.
|
|
95
95
|
* @returns {WebGLShader} TBD.
|
|
96
96
|
*/
|
|
97
|
-
export
|
|
97
|
+
export const compileFragmentShader = (gl, shaderSrc) => {
|
|
98
98
|
return compileShader(gl, shaderSrc, gl.FRAGMENT_SHADER);
|
|
99
|
-
}
|
|
99
|
+
};
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* TBD.
|
|
@@ -105,7 +105,7 @@ export function compileFragmentShader(gl, shaderSrc) {
|
|
|
105
105
|
* @param {string[]|string} fragmentSrc - TBD.
|
|
106
106
|
* @returns {WebGLProgram} TBD.
|
|
107
107
|
*/
|
|
108
|
-
export
|
|
108
|
+
export const compileProgram = (gl, vertexSrc, fragmentSrc) => {
|
|
109
109
|
const fragmentShader = compileFragmentShader(gl, fragmentSrc);
|
|
110
110
|
const vertexShader = compileVertexShader(gl, vertexSrc);
|
|
111
111
|
|
|
@@ -122,4 +122,4 @@ export function compileProgram(gl, vertexSrc, fragmentSrc) {
|
|
|
122
122
|
window.PhaserRegistry.GL_PROGRAM_INFO_LOG = gl.getProgramInfoLog(shaderProgram);
|
|
123
123
|
}
|
|
124
124
|
return shaderProgram;
|
|
125
|
-
}
|
|
125
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { degToRad, distance } from '../../util/math.js';
|
|
1
2
|
import { Circle } from '../circle.js';
|
|
2
3
|
import { Point } from '../point.js';
|
|
3
|
-
import { degToRad, distance } from '../../util/math.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* TBD.
|
|
@@ -8,13 +8,13 @@ import { degToRad, distance } from '../../util/math.js';
|
|
|
8
8
|
* @param {Circle} output - TBD.
|
|
9
9
|
* @returns {Circle} TBD.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export const clone = (input, output = null) => {
|
|
12
12
|
const result = output || new Circle();
|
|
13
13
|
result.x = input.x;
|
|
14
14
|
result.y = input.y;
|
|
15
15
|
result.diameter = input.diameter;
|
|
16
16
|
return result;
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* TBD.
|
|
@@ -23,14 +23,14 @@ export function clone(input, output = null) {
|
|
|
23
23
|
* @param {number} y - TBD.
|
|
24
24
|
* @returns {boolean} TBD.
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export const contains = (a, x, y) => {
|
|
27
27
|
if (a.radius > 0 && x >= a.left && x <= a.right && y >= a.top && y <= a.bottom) {
|
|
28
28
|
const dx = (a.x - x) * (a.x - x);
|
|
29
29
|
const dy = (a.y - y) * (a.y - y);
|
|
30
30
|
return dx + dy <= a.radius * a.radius;
|
|
31
31
|
}
|
|
32
32
|
return false;
|
|
33
|
-
}
|
|
33
|
+
};
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* TBD.
|
|
@@ -38,9 +38,9 @@ export function contains(a, x, y) {
|
|
|
38
38
|
* @param {Circle} b - TBD.
|
|
39
39
|
* @returns {boolean} TBD.
|
|
40
40
|
*/
|
|
41
|
-
export
|
|
41
|
+
export const equals = (a, b) => {
|
|
42
42
|
return a.x === b.x && a.y === b.y && a.diameter === b.diameter;
|
|
43
|
-
}
|
|
43
|
+
};
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* TBD.
|
|
@@ -48,9 +48,9 @@ export function equals(a, b) {
|
|
|
48
48
|
* @param {Circle} b - TBD.
|
|
49
49
|
* @returns {boolean} TBD.
|
|
50
50
|
*/
|
|
51
|
-
export
|
|
51
|
+
export const intersects = (a, b) => {
|
|
52
52
|
return distance(a.x, a.y, b.x, b.y) <= a.radius + b.radius;
|
|
53
|
-
}
|
|
53
|
+
};
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* TBD.
|
|
@@ -60,7 +60,7 @@ export function intersects(a, b) {
|
|
|
60
60
|
* @param {Point} output - TBD.
|
|
61
61
|
* @returns {Point} TBD.
|
|
62
62
|
*/
|
|
63
|
-
export
|
|
63
|
+
export const circumferencePoint = (a, angle, asDegrees = false, output = null) => {
|
|
64
64
|
const result = output || new Point();
|
|
65
65
|
if (asDegrees === true) {
|
|
66
66
|
angle = degToRad(angle);
|
|
@@ -68,7 +68,7 @@ export function circumferencePoint(a, angle, asDegrees = false, output = null) {
|
|
|
68
68
|
result.x = a.x + a.radius * Math.cos(angle);
|
|
69
69
|
result.y = a.y + a.radius * Math.sin(angle);
|
|
70
70
|
return result;
|
|
71
|
-
}
|
|
71
|
+
};
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* TBD.
|
|
@@ -78,7 +78,7 @@ export function circumferencePoint(a, angle, asDegrees = false, output = null) {
|
|
|
78
78
|
* @param {Point} output - TBD.
|
|
79
79
|
* @returns {Point} TBD.
|
|
80
80
|
*/
|
|
81
|
-
export
|
|
81
|
+
export const intersectsPoint = (a, angle, asDegrees = false, output = null) => {
|
|
82
82
|
const result = output || new Point();
|
|
83
83
|
if (asDegrees === true) {
|
|
84
84
|
angle = degToRad(angle);
|
|
@@ -86,7 +86,7 @@ export function intersectsPoint(a, angle, asDegrees = false, output = null) {
|
|
|
86
86
|
result.x = a.x + a.radius * Math.cos(angle);
|
|
87
87
|
result.y = a.y + a.radius * Math.sin(angle);
|
|
88
88
|
return result;
|
|
89
|
-
}
|
|
89
|
+
};
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* TBD.
|
|
@@ -94,7 +94,7 @@ export function intersectsPoint(a, angle, asDegrees = false, output = null) {
|
|
|
94
94
|
* @param {object} r - TBD.
|
|
95
95
|
* @returns {boolean} TBD.
|
|
96
96
|
*/
|
|
97
|
-
export
|
|
97
|
+
export const intersectsRectangle = (c, r) => {
|
|
98
98
|
const cx = Math.abs(c.x - r.x - r.halfWidth);
|
|
99
99
|
const xDist = r.halfWidth + c.radius;
|
|
100
100
|
if (cx > xDist) {
|
|
@@ -114,4 +114,4 @@ export function intersectsRectangle(c, r) {
|
|
|
114
114
|
const yCornerDistSq = yCornerDist * yCornerDist;
|
|
115
115
|
const maxCornerDistSq = c.radius * c.radius;
|
|
116
116
|
return xCornerDistSq + yCornerDistSq <= maxCornerDistSq;
|
|
117
|
-
}
|
|
117
|
+
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param {number} y - TBD.
|
|
6
6
|
* @returns {boolean} TBD.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export const contains = (a, x, y) => {
|
|
9
9
|
if (a.width <= 0 || a.height <= 0) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
@@ -15,4 +15,4 @@ export function contains(a, x, y) {
|
|
|
15
15
|
normx *= normx;
|
|
16
16
|
normy *= normy;
|
|
17
17
|
return normx + normy < 0.25;
|
|
18
|
-
}
|
|
18
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Point } from '../point.js';
|
|
2
1
|
import { Line } from '../line.js';
|
|
2
|
+
import { Point } from '../point.js';
|
|
3
3
|
import { intersects as intersectsRect } from './rectangle.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -8,14 +8,14 @@ import { intersects as intersectsRect } from './rectangle.js';
|
|
|
8
8
|
* @param {Line} output - TBD.
|
|
9
9
|
* @returns {Line} TBD.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export const clone = (input, output = null) => {
|
|
12
12
|
const result = output || new Line();
|
|
13
13
|
result.start.x = input.start.x;
|
|
14
14
|
result.start.y = input.start.y;
|
|
15
15
|
result.end.x = input.end.x;
|
|
16
16
|
result.end.y = input.end.y;
|
|
17
17
|
return result;
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* TBD.
|
|
@@ -27,7 +27,7 @@ export function clone(input, output = null) {
|
|
|
27
27
|
* @param {Point} output - TBD.
|
|
28
28
|
* @returns {Point} TBD.
|
|
29
29
|
*/
|
|
30
|
-
export
|
|
30
|
+
export const intersectsPoints = (a, b, e, f, asSegment = true, output = null) => {
|
|
31
31
|
const result = output || new Point();
|
|
32
32
|
const a1 = b.y - a.y;
|
|
33
33
|
const a2 = f.y - e.y;
|
|
@@ -51,7 +51,7 @@ export function intersectsPoints(a, b, e, f, asSegment = true, output = null) {
|
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
53
|
return result;
|
|
54
|
-
}
|
|
54
|
+
};
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* TBD.
|
|
@@ -61,9 +61,9 @@ export function intersectsPoints(a, b, e, f, asSegment = true, output = null) {
|
|
|
61
61
|
* @param {Point} result - TBD.
|
|
62
62
|
* @returns {Point} TBD.
|
|
63
63
|
*/
|
|
64
|
-
export
|
|
64
|
+
export const intersects = (a, b, asSegment, result) => {
|
|
65
65
|
return intersectsPoints(a.start, a.end, b.start, b.end, asSegment, result);
|
|
66
|
-
}
|
|
66
|
+
};
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* TBD.
|
|
@@ -71,7 +71,7 @@ export function intersects(a, b, asSegment, result) {
|
|
|
71
71
|
* @param {object} rect - TBD.
|
|
72
72
|
* @returns {boolean} TBD.
|
|
73
73
|
*/
|
|
74
|
-
export
|
|
74
|
+
export const intersectsRectangle = (line, rect) => {
|
|
75
75
|
// Quick bail out of the Line and Rect bounds don't intersect
|
|
76
76
|
if (intersectsRect(line, rect)) {
|
|
77
77
|
return false;
|
|
@@ -117,7 +117,7 @@ export function intersectsRectangle(line, rect) {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
return false;
|
|
120
|
-
}
|
|
120
|
+
};
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* TBD.
|
|
@@ -125,6 +125,6 @@ export function intersectsRectangle(line, rect) {
|
|
|
125
125
|
* @param {object} b - TBD.
|
|
126
126
|
* @returns {number} TBD.
|
|
127
127
|
*/
|
|
128
|
-
export
|
|
128
|
+
export const reflect = (a, b) => {
|
|
129
129
|
return 2 * b.normalAngle - 3.141592653589793 - a.angle;
|
|
130
|
-
}
|
|
130
|
+
};
|
|
@@ -6,7 +6,7 @@ import { Matrix } from '../matrix.js';
|
|
|
6
6
|
* @param {Matrix} output - TBD.
|
|
7
7
|
* @returns {Matrix} TBD.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export const clone = (input, output = null) => {
|
|
10
10
|
const result = output || new Matrix();
|
|
11
11
|
result.a = input.a;
|
|
12
12
|
result.b = input.b;
|
|
@@ -15,13 +15,13 @@ export function clone(input, output = null) {
|
|
|
15
15
|
result.tx = input.tx;
|
|
16
16
|
result.ty = input.ty;
|
|
17
17
|
return result;
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* TBD.
|
|
22
22
|
* @returns {Matrix} TBD.
|
|
23
23
|
*/
|
|
24
|
-
export
|
|
24
|
+
export const getIdentityMatrix = () => {
|
|
25
25
|
if (!window.PhaserRegistry) {
|
|
26
26
|
window.PhaserRegistry = {};
|
|
27
27
|
}
|
|
@@ -29,13 +29,13 @@ export function getIdentityMatrix() {
|
|
|
29
29
|
window.PhaserRegistry.IDENTITY_MATRIX = new Matrix();
|
|
30
30
|
}
|
|
31
31
|
return window.PhaserRegistry.IDENTITY_MATRIX;
|
|
32
|
-
}
|
|
32
|
+
};
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* TBD.
|
|
36
36
|
* @returns {Matrix} TBD.
|
|
37
37
|
*/
|
|
38
|
-
export
|
|
38
|
+
export const getTempMatrix = () => {
|
|
39
39
|
if (!window.PhaserRegistry) {
|
|
40
40
|
window.PhaserRegistry = {};
|
|
41
41
|
}
|
|
@@ -43,4 +43,4 @@ export function getTempMatrix() {
|
|
|
43
43
|
window.PhaserRegistry.TEMP_MATRIX = new Matrix();
|
|
44
44
|
}
|
|
45
45
|
return window.PhaserRegistry.TEMP_MATRIX;
|
|
46
|
-
}
|
|
46
|
+
};
|
|
@@ -7,12 +7,12 @@ import { Point } from '../point.js';
|
|
|
7
7
|
* @param {Point} output - TBD.
|
|
8
8
|
* @returns {Point} TBD.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export const add = (a, b, output = null) => {
|
|
11
11
|
const result = output || new Point();
|
|
12
12
|
result.x = a.x + b.x;
|
|
13
13
|
result.y = a.y + b.y;
|
|
14
14
|
return result;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* TBD.
|
|
@@ -21,12 +21,12 @@ export function add(a, b, output = null) {
|
|
|
21
21
|
* @param {Point} output - TBD.
|
|
22
22
|
* @returns {Point} TBD.
|
|
23
23
|
*/
|
|
24
|
-
export
|
|
24
|
+
export const subtract = (a, b, output = null) => {
|
|
25
25
|
const result = output || new Point();
|
|
26
26
|
result.x = a.x - b.x;
|
|
27
27
|
result.y = a.y - b.y;
|
|
28
28
|
return result;
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* TBD.
|
|
@@ -35,12 +35,12 @@ export function subtract(a, b, output = null) {
|
|
|
35
35
|
* @param {Point} output - TBD.
|
|
36
36
|
* @returns {Point} TBD.
|
|
37
37
|
*/
|
|
38
|
-
export
|
|
38
|
+
export const multiply = (a, b, output = null) => {
|
|
39
39
|
const result = output || new Point();
|
|
40
40
|
result.x = a.x * b.x;
|
|
41
41
|
result.y = a.y * b.y;
|
|
42
42
|
return result;
|
|
43
|
-
}
|
|
43
|
+
};
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* TBD.
|
|
@@ -49,12 +49,12 @@ export function multiply(a, b, output = null) {
|
|
|
49
49
|
* @param {Point} output - TBD.
|
|
50
50
|
* @returns {Point} TBD.
|
|
51
51
|
*/
|
|
52
|
-
export
|
|
52
|
+
export const divide = (a, b, output = null) => {
|
|
53
53
|
const result = output || new Point();
|
|
54
54
|
result.x = a.x / b.x;
|
|
55
55
|
result.y = a.y / b.y;
|
|
56
56
|
return result;
|
|
57
|
-
}
|
|
57
|
+
};
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* TBD.
|
|
@@ -62,9 +62,9 @@ export function divide(a, b, output = null) {
|
|
|
62
62
|
* @param {Point} b - TBD.
|
|
63
63
|
* @returns {boolean} TBD.
|
|
64
64
|
*/
|
|
65
|
-
export
|
|
65
|
+
export const equals = (a, b) => {
|
|
66
66
|
return a.x === b.x && a.y === b.y;
|
|
67
|
-
}
|
|
67
|
+
};
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* TBD.
|
|
@@ -72,9 +72,9 @@ export function equals(a, b) {
|
|
|
72
72
|
* @param {Point} b - TBD.
|
|
73
73
|
* @returns {number} TBD.
|
|
74
74
|
*/
|
|
75
|
-
export
|
|
75
|
+
export const angle = (a, b) => {
|
|
76
76
|
return Math.atan2(a.y - b.y, a.x - b.x);
|
|
77
|
-
}
|
|
77
|
+
};
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* TBD.
|
|
@@ -82,10 +82,10 @@ export function angle(a, b) {
|
|
|
82
82
|
* @param {Point} output - TBD.
|
|
83
83
|
* @returns {Point} TBD.
|
|
84
84
|
*/
|
|
85
|
-
export
|
|
85
|
+
export const negative = (a, output = null) => {
|
|
86
86
|
const result = output || new Point();
|
|
87
87
|
return result.setTo(-a.x, -a.y);
|
|
88
|
-
}
|
|
88
|
+
};
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* TBD.
|
|
@@ -95,10 +95,10 @@ export function negative(a, output = null) {
|
|
|
95
95
|
* @param {Point} output - TBD.
|
|
96
96
|
* @returns {Point} TBD.
|
|
97
97
|
*/
|
|
98
|
-
export
|
|
98
|
+
export const multiplyAdd = (a, b, s, output = null) => {
|
|
99
99
|
const result = output || new Point();
|
|
100
100
|
return result.setTo(a.x + b.x * s, a.y + b.y * s);
|
|
101
|
-
}
|
|
101
|
+
};
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* TBD.
|
|
@@ -108,10 +108,10 @@ export function multiplyAdd(a, b, s, output = null) {
|
|
|
108
108
|
* @param {Point} output - TBD.
|
|
109
109
|
* @returns {Point} TBD.
|
|
110
110
|
*/
|
|
111
|
-
export
|
|
111
|
+
export const interpolate = (a, b, f, output = null) => {
|
|
112
112
|
const result = output || new Point();
|
|
113
113
|
return result.setTo(a.x + (b.x - a.x) * f, a.y + (b.y - a.y) * f);
|
|
114
|
-
}
|
|
114
|
+
};
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* TBD.
|
|
@@ -119,10 +119,10 @@ export function interpolate(a, b, f, output = null) {
|
|
|
119
119
|
* @param {Point} output - TBD.
|
|
120
120
|
* @returns {Point} TBD.
|
|
121
121
|
*/
|
|
122
|
-
export
|
|
122
|
+
export const perp = (a, output = null) => {
|
|
123
123
|
const result = output || new Point();
|
|
124
124
|
return result.setTo(-a.y, a.x);
|
|
125
|
-
}
|
|
125
|
+
};
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* TBD.
|
|
@@ -130,10 +130,10 @@ export function perp(a, output = null) {
|
|
|
130
130
|
* @param {Point} output - TBD.
|
|
131
131
|
* @returns {Point} TBD.
|
|
132
132
|
*/
|
|
133
|
-
export
|
|
133
|
+
export const rperp = (a, output = null) => {
|
|
134
134
|
const result = output || new Point();
|
|
135
135
|
return result.setTo(a.y, -a.x);
|
|
136
|
-
}
|
|
136
|
+
};
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
139
|
* TBD.
|
|
@@ -142,12 +142,12 @@ export function rperp(a, output = null) {
|
|
|
142
142
|
* @param {boolean} round - TBD.
|
|
143
143
|
* @returns {number} TBD.
|
|
144
144
|
*/
|
|
145
|
-
export
|
|
145
|
+
export const distance = (a, b, round = false) => {
|
|
146
146
|
const dx = a.x - b.x;
|
|
147
147
|
const dy = a.y - b.y;
|
|
148
148
|
const abDistance = Math.sqrt(dx * dx + dy * dy);
|
|
149
149
|
return round ? Math.round(abDistance) : abDistance;
|
|
150
|
-
}
|
|
150
|
+
};
|
|
151
151
|
|
|
152
152
|
/**
|
|
153
153
|
* TBD.
|
|
@@ -156,14 +156,14 @@ export function distance(a, b, round = false) {
|
|
|
156
156
|
* @param {Point} output - TBD.
|
|
157
157
|
* @returns {Point} TBD.
|
|
158
158
|
*/
|
|
159
|
-
export
|
|
159
|
+
export const project = (a, b, output = null) => {
|
|
160
160
|
const result = output || new Point();
|
|
161
161
|
const amt = a.dot(b) / b.getMagnitudeSq();
|
|
162
162
|
if (amt !== 0) {
|
|
163
163
|
result.setTo(amt * b.x, amt * b.y);
|
|
164
164
|
}
|
|
165
165
|
return result;
|
|
166
|
-
}
|
|
166
|
+
};
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
169
|
* TBD.
|
|
@@ -172,14 +172,14 @@ export function project(a, b, output = null) {
|
|
|
172
172
|
* @param {Point} output - TBD.
|
|
173
173
|
* @returns {Point} TBD.
|
|
174
174
|
*/
|
|
175
|
-
export
|
|
175
|
+
export const projectUnit = (a, b, output = null) => {
|
|
176
176
|
const result = output || new Point();
|
|
177
177
|
const amt = a.dot(b);
|
|
178
178
|
if (amt !== 0) {
|
|
179
179
|
result.setTo(amt * b.x, amt * b.y);
|
|
180
180
|
}
|
|
181
181
|
return result;
|
|
182
|
-
}
|
|
182
|
+
};
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
185
|
* TBD.
|
|
@@ -187,10 +187,10 @@ export function projectUnit(a, b, output = null) {
|
|
|
187
187
|
* @param {Point} output - TBD.
|
|
188
188
|
* @returns {Point} TBD.
|
|
189
189
|
*/
|
|
190
|
-
export
|
|
190
|
+
export const normalRightHand = (a, output = null) => {
|
|
191
191
|
const result = output || new Point();
|
|
192
192
|
return result.setTo(a.y * -1, a.x);
|
|
193
|
-
}
|
|
193
|
+
};
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
196
|
* TBD.
|
|
@@ -198,14 +198,14 @@ export function normalRightHand(a, output = null) {
|
|
|
198
198
|
* @param {Point} output - TBD.
|
|
199
199
|
* @returns {Point} TBD.
|
|
200
200
|
*/
|
|
201
|
-
export
|
|
201
|
+
export const normalize = (a, output = null) => {
|
|
202
202
|
const result = output || new Point();
|
|
203
203
|
const m = a.getMagnitude();
|
|
204
204
|
if (m !== 0) {
|
|
205
205
|
result.setTo(a.x / m, a.y / m);
|
|
206
206
|
}
|
|
207
207
|
return result;
|
|
208
|
-
}
|
|
208
|
+
};
|
|
209
209
|
|
|
210
210
|
/**
|
|
211
211
|
* TBD.
|
|
@@ -217,7 +217,7 @@ export function normalize(a, output = null) {
|
|
|
217
217
|
* @param {number} dist - TBD.
|
|
218
218
|
* @returns {object} TBD.
|
|
219
219
|
*/
|
|
220
|
-
export
|
|
220
|
+
export const rotate = (a, x, y, ang, asDegrees, dist) => {
|
|
221
221
|
if (asDegrees) {
|
|
222
222
|
ang *= Math.PI / 180;
|
|
223
223
|
}
|
|
@@ -235,7 +235,7 @@ export function rotate(a, x, y, ang, asDegrees, dist) {
|
|
|
235
235
|
a.y = y + dist * Math.sin(t);
|
|
236
236
|
}
|
|
237
237
|
return a;
|
|
238
|
-
}
|
|
238
|
+
};
|
|
239
239
|
|
|
240
240
|
/**
|
|
241
241
|
* TBD.
|
|
@@ -244,7 +244,7 @@ export function rotate(a, x, y, ang, asDegrees, dist) {
|
|
|
244
244
|
* @returns {Point} TBD.
|
|
245
245
|
* @throws Error TBD.
|
|
246
246
|
*/
|
|
247
|
-
export
|
|
247
|
+
export const centroid = (points, output = null) => {
|
|
248
248
|
const result = output || new Point();
|
|
249
249
|
const pointsLen = points.length;
|
|
250
250
|
if (pointsLen < 1) {
|
|
@@ -259,7 +259,7 @@ export function centroid(points, output = null) {
|
|
|
259
259
|
}
|
|
260
260
|
result.divide(pointsLen, pointsLen);
|
|
261
261
|
return result;
|
|
262
|
-
}
|
|
262
|
+
};
|
|
263
263
|
|
|
264
264
|
/**
|
|
265
265
|
* TBD.
|
|
@@ -268,16 +268,16 @@ export function centroid(points, output = null) {
|
|
|
268
268
|
* @param {string} yProp - TBD.
|
|
269
269
|
* @returns {Point} TBD.
|
|
270
270
|
*/
|
|
271
|
-
export
|
|
271
|
+
export const parse = (obj, xProp = 'x', yProp = 'y') => {
|
|
272
272
|
const point = new Point();
|
|
273
273
|
if (obj[xProp]) {
|
|
274
|
-
point.x = parseInt(obj[xProp], 10);
|
|
274
|
+
point.x = Number.parseInt(obj[xProp], 10);
|
|
275
275
|
}
|
|
276
276
|
if (obj[yProp]) {
|
|
277
|
-
point.y = parseInt(obj[yProp], 10);
|
|
277
|
+
point.y = Number.parseInt(obj[yProp], 10);
|
|
278
278
|
}
|
|
279
279
|
return point;
|
|
280
|
-
}
|
|
280
|
+
};
|
|
281
281
|
|
|
282
282
|
/**
|
|
283
283
|
* TBD.
|
|
@@ -285,8 +285,8 @@ export function parse(obj, xProp = 'x', yProp = 'y') {
|
|
|
285
285
|
* @param {Point} output - TBD.
|
|
286
286
|
* @returns {Point} TBD.
|
|
287
287
|
*/
|
|
288
|
-
export
|
|
288
|
+
export const clone = (input, output = null) => {
|
|
289
289
|
const result = output || new Point();
|
|
290
290
|
result.setTo(input.x, input.y);
|
|
291
291
|
return result;
|
|
292
|
-
}
|
|
292
|
+
};
|
|
@@ -6,8 +6,8 @@ import { Polygon } from '../polygon.js';
|
|
|
6
6
|
* @param {Polygon} output - TBD.
|
|
7
7
|
* @returns {Polygon} TBD.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export const clone = (input, output = null) => {
|
|
10
10
|
const result = output || new Polygon();
|
|
11
11
|
result.setTo(input._points.slice());
|
|
12
12
|
return result;
|
|
13
|
-
}
|
|
13
|
+
};
|