@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,11 +7,11 @@ import { create, removeByCanvas } from './pool.js';
|
|
|
7
7
|
* @param {object} color - TBD.
|
|
8
8
|
* @returns {object} TBD.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export const getTintedTexture = (sprite, color) => {
|
|
11
11
|
const canvas = sprite.tintedTexture || create('CanvasTinter', 1, 1);
|
|
12
12
|
window.PhaserRegistry.CANVAS_TINT_METHOD(sprite.texture, color, canvas);
|
|
13
13
|
return canvas;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* TBD.
|
|
@@ -19,7 +19,7 @@ export function getTintedTexture(sprite, color) {
|
|
|
19
19
|
* @param {object} color - TBD.
|
|
20
20
|
* @param {HTMLCanvasElement} canvas - TBD.
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
22
|
+
export const tintWithMultiply = (texture, color, canvas) => {
|
|
23
23
|
const context = canvas.getContext('2d', { willReadFrequently: false });
|
|
24
24
|
const crop = texture.crop;
|
|
25
25
|
if (canvas.width !== crop.width || canvas.height !== crop.height) {
|
|
@@ -33,7 +33,7 @@ export function tintWithMultiply(texture, color, canvas) {
|
|
|
33
33
|
context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height);
|
|
34
34
|
context.globalCompositeOperation = 'destination-atop';
|
|
35
35
|
context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height);
|
|
36
|
-
}
|
|
36
|
+
};
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* TBD.
|
|
@@ -41,7 +41,7 @@ export function tintWithMultiply(texture, color, canvas) {
|
|
|
41
41
|
* @param {object} color - TBD.
|
|
42
42
|
* @param {HTMLCanvasElement} canvas - TBD.
|
|
43
43
|
*/
|
|
44
|
-
export
|
|
44
|
+
export const tintWithPerPixel = (texture, color, canvas) => {
|
|
45
45
|
const context = canvas.getContext('2d', { willReadFrequently: false });
|
|
46
46
|
const crop = texture.crop;
|
|
47
47
|
canvas.width = crop.width;
|
|
@@ -67,15 +67,14 @@ export function tintWithPerPixel(texture, color, canvas) {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
context.putImageData(pixelData, 0, 0);
|
|
70
|
-
}
|
|
70
|
+
};
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* TBD.
|
|
74
|
-
* @param {import('../../core/game.js').Game} game - TBD.
|
|
75
74
|
* @returns {boolean} TBD.
|
|
76
75
|
* @throws {Error} TBD.
|
|
77
76
|
*/
|
|
78
|
-
export
|
|
77
|
+
export const checkInverseAlpha = () => {
|
|
79
78
|
// Check for DOM
|
|
80
79
|
if (document === undefined) {
|
|
81
80
|
throw new Error('Error getting Document for checkInverseAlpha()');
|
|
@@ -110,15 +109,14 @@ export function checkInverseAlpha(game) {
|
|
|
110
109
|
return (
|
|
111
110
|
s2.data[0] === s1.data[0] && s2.data[1] === s1.data[1] && s2.data[2] === s1.data[2] && s2.data[3] === s1.data[3]
|
|
112
111
|
);
|
|
113
|
-
}
|
|
112
|
+
};
|
|
114
113
|
|
|
115
114
|
/**
|
|
116
115
|
* TBD.
|
|
117
|
-
* @param {import('../../core/game.js').Game} game - TBD.
|
|
118
116
|
* @returns {boolean} TBD.
|
|
119
117
|
* @throws {Error} TBD.
|
|
120
118
|
*/
|
|
121
|
-
export
|
|
119
|
+
export const canUseNewCanvasBlendModes = () => {
|
|
122
120
|
// Check for DOM
|
|
123
121
|
if (document === undefined) {
|
|
124
122
|
throw new Error('Error getting Document for canUseNewCanvasBlendModes()');
|
|
@@ -153,24 +151,24 @@ export function canUseNewCanvasBlendModes(game) {
|
|
|
153
151
|
removeByCanvas(canvas);
|
|
154
152
|
// Compare and return
|
|
155
153
|
return data[0] === 255 && data[1] === 0 && data[2] === 0;
|
|
156
|
-
}
|
|
154
|
+
};
|
|
157
155
|
|
|
158
156
|
/**
|
|
159
157
|
* TBD.
|
|
160
158
|
* @param {import('../../core/game.js').Game} game - TBD.
|
|
161
159
|
*/
|
|
162
|
-
export
|
|
160
|
+
export const detectCapabilities = (game) => {
|
|
163
161
|
if (!window.PhaserRegistry) {
|
|
164
162
|
window.PhaserRegistry = {};
|
|
165
163
|
}
|
|
166
164
|
try {
|
|
167
|
-
window.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA = checkInverseAlpha(
|
|
165
|
+
window.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA = checkInverseAlpha();
|
|
168
166
|
} catch (error) {
|
|
169
167
|
game.exceptionHandler(error);
|
|
170
168
|
window.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA = false;
|
|
171
169
|
}
|
|
172
170
|
try {
|
|
173
|
-
window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY = canUseNewCanvasBlendModes(
|
|
171
|
+
window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY = canUseNewCanvasBlendModes();
|
|
174
172
|
} catch (error) {
|
|
175
173
|
game.exceptionHandler(error);
|
|
176
174
|
window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY = false;
|
|
@@ -178,4 +176,4 @@ export function detectCapabilities(game) {
|
|
|
178
176
|
window.PhaserRegistry.CANVAS_TINT_METHOD = window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY
|
|
179
177
|
? tintWithMultiply
|
|
180
178
|
: tintWithPerPixel;
|
|
181
|
-
}
|
|
179
|
+
};
|
|
@@ -9,7 +9,7 @@ import { create as createCanvas } from './pool.js';
|
|
|
9
9
|
* @param {boolean} skipPool - TBD.
|
|
10
10
|
* @returns {HTMLCanvasElement} TBD.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export const create = (parent, width, height, id, skipPool) => {
|
|
13
13
|
width = width || 256;
|
|
14
14
|
height = height || 256;
|
|
15
15
|
const canvas = skipPool ? document.createElement('canvas') : createCanvas(parent, width, height);
|
|
@@ -20,7 +20,7 @@ export function create(parent, width, height, id, skipPool) {
|
|
|
20
20
|
canvas.height = height;
|
|
21
21
|
canvas.style.display = 'block';
|
|
22
22
|
return canvas;
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* TBD.
|
|
@@ -28,11 +28,11 @@ export function create(parent, width, height, id, skipPool) {
|
|
|
28
28
|
* @param {string} color - TBD.
|
|
29
29
|
* @returns {object} TBD.
|
|
30
30
|
*/
|
|
31
|
-
export
|
|
31
|
+
export const setBackgroundColor = (canvas, color) => {
|
|
32
32
|
color = color || 'rgb(0,0,0)';
|
|
33
33
|
canvas.style.backgroundColor = color;
|
|
34
34
|
return canvas;
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* TBD.
|
|
@@ -40,13 +40,13 @@ export function setBackgroundColor(canvas, color) {
|
|
|
40
40
|
* @param {string} value - TBD.
|
|
41
41
|
* @returns {object} TBD.
|
|
42
42
|
*/
|
|
43
|
-
export
|
|
43
|
+
export const setTouchAction = (canvas, value = 'none') => {
|
|
44
44
|
value = value || 'none';
|
|
45
45
|
canvas.style.msTouchAction = value;
|
|
46
46
|
canvas.style['ms-touch-action'] = value;
|
|
47
47
|
canvas.style['touch-action'] = value;
|
|
48
48
|
return canvas;
|
|
49
|
-
}
|
|
49
|
+
};
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* TBD.
|
|
@@ -54,7 +54,7 @@ export function setTouchAction(canvas, value = 'none') {
|
|
|
54
54
|
* @param {string} value - TBD.
|
|
55
55
|
* @returns {object} TBD.
|
|
56
56
|
*/
|
|
57
|
-
export
|
|
57
|
+
export const setUserSelect = (canvas, value = 'none') => {
|
|
58
58
|
value = value || 'none';
|
|
59
59
|
canvas.style['-webkit-touch-callout'] = value;
|
|
60
60
|
canvas.style['-webkit-user-select'] = value;
|
|
@@ -64,7 +64,7 @@ export function setUserSelect(canvas, value = 'none') {
|
|
|
64
64
|
canvas.style['user-select'] = value;
|
|
65
65
|
canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)';
|
|
66
66
|
return canvas;
|
|
67
|
-
}
|
|
67
|
+
};
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* TBD.
|
|
@@ -73,7 +73,7 @@ export function setUserSelect(canvas, value = 'none') {
|
|
|
73
73
|
* @param {boolean} overflowHidden - TBD.
|
|
74
74
|
* @returns {object} TBD.
|
|
75
75
|
*/
|
|
76
|
-
export
|
|
76
|
+
export const addToDOM = (canvas, parent, overflowHidden = true) => {
|
|
77
77
|
let target;
|
|
78
78
|
if (parent) {
|
|
79
79
|
if (typeof parent === 'string') {
|
|
@@ -93,17 +93,17 @@ export function addToDOM(canvas, parent, overflowHidden = true) {
|
|
|
93
93
|
}
|
|
94
94
|
target.appendChild(canvas);
|
|
95
95
|
return canvas;
|
|
96
|
-
}
|
|
96
|
+
};
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* TBD.
|
|
100
100
|
* @param {HTMLCanvasElement} canvas - TBD.
|
|
101
101
|
*/
|
|
102
|
-
export
|
|
102
|
+
export const removeFromDOM = (canvas) => {
|
|
103
103
|
if (canvas && canvas.parentNode) {
|
|
104
104
|
canvas.parentNode.removeChild(canvas);
|
|
105
105
|
}
|
|
106
|
-
}
|
|
106
|
+
};
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* TBD.
|
|
@@ -116,17 +116,17 @@ export function removeFromDOM(canvas) {
|
|
|
116
116
|
* @param {number} skewY - TBD.
|
|
117
117
|
* @returns {object} TBD.
|
|
118
118
|
*/
|
|
119
|
-
export
|
|
119
|
+
export const setTransform = (context, translateX, translateY, scaleX, scaleY, skewX, skewY) => {
|
|
120
120
|
context.setTransform(scaleX, skewX, skewY, scaleY, translateX, translateY);
|
|
121
121
|
return context;
|
|
122
|
-
}
|
|
122
|
+
};
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* TBD.
|
|
126
126
|
* @param {object} context - TBD.
|
|
127
127
|
* @returns {object} TBD.
|
|
128
128
|
*/
|
|
129
|
-
export
|
|
129
|
+
export const getSmoothingPrefix = (context) => {
|
|
130
130
|
const VENDORS = ['i', 'webkitI', 'msI', 'mozI', 'oI'];
|
|
131
131
|
for (let i = 0; i < VENDORS.length; i += 1) {
|
|
132
132
|
const s = `${VENDORS[i]}mageSmoothingEnabled`;
|
|
@@ -135,7 +135,7 @@ export function getSmoothingPrefix(context) {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
return null;
|
|
138
|
-
}
|
|
138
|
+
};
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
141
|
* TBD.
|
|
@@ -143,10 +143,10 @@ export function getSmoothingPrefix(context) {
|
|
|
143
143
|
* @param {number} value - TBD.
|
|
144
144
|
* @returns {object} TBD.
|
|
145
145
|
*/
|
|
146
|
-
export
|
|
146
|
+
export const setSmoothingEnabled = (context, value) => {
|
|
147
147
|
const s = getSmoothingPrefix(context);
|
|
148
148
|
if (s) {
|
|
149
149
|
context[s] = value;
|
|
150
150
|
}
|
|
151
151
|
return context;
|
|
152
|
-
}
|
|
152
|
+
};
|
|
@@ -5,7 +5,7 @@ import { GraphicsData } from './graphics_data.js';
|
|
|
5
5
|
* @param {GraphicsData} source - TBD.
|
|
6
6
|
* @returns {GraphicsData} TBD.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export const clone = (source) => {
|
|
9
9
|
return new GraphicsData(
|
|
10
10
|
source.lineWidth,
|
|
11
11
|
source.lineColor,
|
|
@@ -15,4 +15,4 @@ export function clone(source) {
|
|
|
15
15
|
source.fill,
|
|
16
16
|
source.shape
|
|
17
17
|
);
|
|
18
|
-
}
|
|
18
|
+
};
|
|
@@ -8,7 +8,7 @@ import { getTintedTexture } from './canvas/tinter.js';
|
|
|
8
8
|
* @param {import('./webgl/texture.js').Texture} texture - TBD.
|
|
9
9
|
* @param {boolean} destroyBase - TBD.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export const setTexture = (target, texture, destroyBase = false) => {
|
|
12
12
|
if (destroyBase) {
|
|
13
13
|
target.texture.baseTexture.destroy();
|
|
14
14
|
}
|
|
@@ -16,7 +16,7 @@ export function setTexture(target, texture, destroyBase = false) {
|
|
|
16
16
|
target.texture = texture;
|
|
17
17
|
target.texture.valid = true;
|
|
18
18
|
target.cachedTint = -1;
|
|
19
|
-
}
|
|
19
|
+
};
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* TBD.
|
|
@@ -24,7 +24,7 @@ export function setTexture(target, texture, destroyBase = false) {
|
|
|
24
24
|
* @param {object} matrix - TBD.
|
|
25
25
|
* @returns {import('../geom/rectangle.js').Rectangle} TBD.
|
|
26
26
|
*/
|
|
27
|
-
export
|
|
27
|
+
export const getBounds = (target, matrix = null) => {
|
|
28
28
|
// TODO verify
|
|
29
29
|
if (target.currentBounds) {
|
|
30
30
|
return target.currentBounds;
|
|
@@ -99,14 +99,14 @@ export function getBounds(target, matrix = null) {
|
|
|
99
99
|
bounds.height = maxY - minY;
|
|
100
100
|
target.currentBounds = bounds;
|
|
101
101
|
return bounds;
|
|
102
|
-
}
|
|
102
|
+
};
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* TBD.
|
|
106
106
|
* @param {import('./image.js').Image} target - TBD.
|
|
107
107
|
* @returns {import('../geom/rectangle.js').Rectangle} TBD.
|
|
108
108
|
*/
|
|
109
|
-
export
|
|
109
|
+
export const getLocalBounds = (target) => {
|
|
110
110
|
const matrixCache = target.worldTransform;
|
|
111
111
|
target.worldTransform = getIdentityMatrix();
|
|
112
112
|
let i;
|
|
@@ -119,7 +119,7 @@ export function getLocalBounds(target) {
|
|
|
119
119
|
target.children[i].updateTransform();
|
|
120
120
|
}
|
|
121
121
|
return bounds;
|
|
122
|
-
}
|
|
122
|
+
};
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* TBD.
|
|
@@ -127,7 +127,7 @@ export function getLocalBounds(target) {
|
|
|
127
127
|
* @param {object} renderSession - TBD.
|
|
128
128
|
* @param {import('../geom/matrix.js').Matrix} matrix - TBD.
|
|
129
129
|
*/
|
|
130
|
-
export
|
|
130
|
+
export const renderWebGL = (target, renderSession, matrix) => {
|
|
131
131
|
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
|
132
132
|
if (!target.visible || target.alpha <= 0 || !target.renderable) {
|
|
133
133
|
return;
|
|
@@ -168,7 +168,7 @@ export function renderWebGL(target, renderSession, matrix) {
|
|
|
168
168
|
target.children[i].renderWebGL(renderSession, wt);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
}
|
|
171
|
+
};
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
174
|
* TBD.
|
|
@@ -176,7 +176,7 @@ export function renderWebGL(target, renderSession, matrix) {
|
|
|
176
176
|
* @param {object} renderSession - TBD.
|
|
177
177
|
* @param {import('../geom/matrix.js').Matrix} matrix - TBD.
|
|
178
178
|
*/
|
|
179
|
-
export
|
|
179
|
+
export const renderCanvas = (target, renderSession, matrix) => {
|
|
180
180
|
// If the sprite is not visible or the alpha is 0 then no need to render this element
|
|
181
181
|
if (
|
|
182
182
|
!target.visible ||
|
|
@@ -263,4 +263,4 @@ export function renderCanvas(target, renderSession, matrix) {
|
|
|
263
263
|
if (target._mask) {
|
|
264
264
|
renderSession.maskManager.popMask(renderSession);
|
|
265
265
|
}
|
|
266
|
-
}
|
|
266
|
+
};
|
|
@@ -1053,7 +1053,7 @@ export class Text extends Image {
|
|
|
1053
1053
|
get fontSize() {
|
|
1054
1054
|
const size = this._fontComponents.fontSize;
|
|
1055
1055
|
if (size && /(?:^0$|px$)/.exec(size)) {
|
|
1056
|
-
return parseInt(size, 10);
|
|
1056
|
+
return Number.parseInt(size, 10);
|
|
1057
1057
|
}
|
|
1058
1058
|
return size;
|
|
1059
1059
|
}
|
|
@@ -1311,7 +1311,7 @@ export class Text extends Image {
|
|
|
1311
1311
|
*/
|
|
1312
1312
|
set lineSpacing(value) {
|
|
1313
1313
|
if (value !== this._lineSpacing) {
|
|
1314
|
-
this._lineSpacing = parseFloat(value);
|
|
1314
|
+
this._lineSpacing = Number.parseFloat(value);
|
|
1315
1315
|
this.dirty = true;
|
|
1316
1316
|
if (this.parent) {
|
|
1317
1317
|
this.updateTransform();
|
|
@@ -8,23 +8,23 @@ import { GraphicsData } from './graphics_data.js';
|
|
|
8
8
|
* TBD.
|
|
9
9
|
* @returns {number} TBD.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export const getStencilBufferLimit = () => {
|
|
12
12
|
if (!window.PhaserRegistry.stencilBufferLimit) {
|
|
13
13
|
window.PhaserRegistry.stencilBufferLimit = 6;
|
|
14
14
|
}
|
|
15
15
|
return window.PhaserRegistry.stencilBufferLimit;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* TBD.
|
|
20
20
|
* @returns {object[]} TBD.
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
22
|
+
export const getGraphicsDataPool = () => {
|
|
23
23
|
if (!window.PhaserRegistry.graphicsDataPool) {
|
|
24
24
|
window.PhaserRegistry.graphicsDataPool = [];
|
|
25
25
|
}
|
|
26
26
|
return window.PhaserRegistry.graphicsDataPool;
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* TBD.
|
|
@@ -32,7 +32,7 @@ export function getGraphicsDataPool() {
|
|
|
32
32
|
* @param {number} type - TBD.
|
|
33
33
|
* @returns {object} TBD.
|
|
34
34
|
*/
|
|
35
|
-
export
|
|
35
|
+
export const switchMode = (webGL, type) => {
|
|
36
36
|
let webGLData;
|
|
37
37
|
if (!webGL.data.length) {
|
|
38
38
|
webGLData = getGraphicsDataPool().pop() || new GraphicsData(webGL.gl);
|
|
@@ -48,14 +48,14 @@ export function switchMode(webGL, type) {
|
|
|
48
48
|
}
|
|
49
49
|
webGLData.dirty = true;
|
|
50
50
|
return webGLData;
|
|
51
|
-
}
|
|
51
|
+
};
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* TBD.
|
|
55
55
|
* @param {object} graphicsData - TBD.
|
|
56
56
|
* @param {GraphicsData} webGLData - TBD.
|
|
57
57
|
*/
|
|
58
|
-
export
|
|
58
|
+
export const buildLine = (graphicsData, webGLData) => {
|
|
59
59
|
// TODO OPTIMISE!
|
|
60
60
|
let i = 0;
|
|
61
61
|
let points = graphicsData.points;
|
|
@@ -213,14 +213,14 @@ export function buildLine(graphicsData, webGLData) {
|
|
|
213
213
|
indexStart += 1;
|
|
214
214
|
}
|
|
215
215
|
indices.push(indexStart - 1);
|
|
216
|
-
}
|
|
216
|
+
};
|
|
217
217
|
|
|
218
218
|
/**
|
|
219
219
|
* TBD.
|
|
220
220
|
* @param {object} graphicsData - TBD.
|
|
221
221
|
* @param {GraphicsData} webGLData - TBD.
|
|
222
222
|
*/
|
|
223
|
-
export
|
|
223
|
+
export const buildRectangle = (graphicsData, webGLData) => {
|
|
224
224
|
//
|
|
225
225
|
// need to convert points to a nice regular data
|
|
226
226
|
//
|
|
@@ -257,7 +257,7 @@ export function buildRectangle(graphicsData, webGLData) {
|
|
|
257
257
|
buildLine(graphicsData, webGLData);
|
|
258
258
|
graphicsData.points = tempPoints;
|
|
259
259
|
}
|
|
260
|
-
}
|
|
260
|
+
};
|
|
261
261
|
|
|
262
262
|
/**
|
|
263
263
|
* TBD.
|
|
@@ -269,7 +269,7 @@ export function buildRectangle(graphicsData, webGLData) {
|
|
|
269
269
|
* @param {number} toY - TBD.
|
|
270
270
|
* @returns {number[]} TBD.
|
|
271
271
|
*/
|
|
272
|
-
export
|
|
272
|
+
export const quadraticBezierCurve = (fromX, fromY, cpX, cpY, toX, toY) => {
|
|
273
273
|
let xa;
|
|
274
274
|
let ya;
|
|
275
275
|
let xb;
|
|
@@ -296,14 +296,14 @@ export function quadraticBezierCurve(fromX, fromY, cpX, cpY, toX, toY) {
|
|
|
296
296
|
points.push(x, y);
|
|
297
297
|
}
|
|
298
298
|
return points;
|
|
299
|
-
}
|
|
299
|
+
};
|
|
300
300
|
|
|
301
301
|
/**
|
|
302
302
|
* TBD.
|
|
303
303
|
* @param {object} graphicsData - TBD.
|
|
304
304
|
* @param {GraphicsData} webGLData - TBD.
|
|
305
305
|
*/
|
|
306
|
-
export
|
|
306
|
+
export const buildRoundedRectangle = (graphicsData, webGLData) => {
|
|
307
307
|
const rrectData = graphicsData.shape;
|
|
308
308
|
const x = rrectData.x;
|
|
309
309
|
const y = rrectData.y;
|
|
@@ -346,14 +346,14 @@ export function buildRoundedRectangle(graphicsData, webGLData) {
|
|
|
346
346
|
buildLine(graphicsData, webGLData);
|
|
347
347
|
graphicsData.points = tempPoints;
|
|
348
348
|
}
|
|
349
|
-
}
|
|
349
|
+
};
|
|
350
350
|
|
|
351
351
|
/**
|
|
352
352
|
* TBD.
|
|
353
353
|
* @param {object} graphicsData - TBD.
|
|
354
354
|
* @param {GraphicsData} webGLData - TBD.
|
|
355
355
|
*/
|
|
356
|
-
export
|
|
356
|
+
export const buildCircle = (graphicsData, webGLData) => {
|
|
357
357
|
// need to convert points to a nice regular data
|
|
358
358
|
const circleData = graphicsData.shape;
|
|
359
359
|
const x = circleData.x;
|
|
@@ -397,14 +397,14 @@ export function buildCircle(graphicsData, webGLData) {
|
|
|
397
397
|
buildLine(graphicsData, webGLData);
|
|
398
398
|
graphicsData.points = tempPoints;
|
|
399
399
|
}
|
|
400
|
-
}
|
|
400
|
+
};
|
|
401
401
|
|
|
402
402
|
/**
|
|
403
403
|
* TBD.
|
|
404
404
|
* @param {object} graphicsData - TBD.
|
|
405
405
|
* @param {GraphicsData} webGLData - TBD.
|
|
406
406
|
*/
|
|
407
|
-
export
|
|
407
|
+
export const buildComplexPoly = (graphicsData, webGLData) => {
|
|
408
408
|
// TODO - no need to copy this as it gets turned into a Float32Array anyways..
|
|
409
409
|
const points = graphicsData.points.slice();
|
|
410
410
|
if (points.length < 6) {
|
|
@@ -441,7 +441,7 @@ export function buildComplexPoly(graphicsData, webGLData) {
|
|
|
441
441
|
for (let i = 0; i < length; i += 1) {
|
|
442
442
|
indices.push(i);
|
|
443
443
|
}
|
|
444
|
-
}
|
|
444
|
+
};
|
|
445
445
|
|
|
446
446
|
/**
|
|
447
447
|
* TBD.
|
|
@@ -449,7 +449,7 @@ export function buildComplexPoly(graphicsData, webGLData) {
|
|
|
449
449
|
* @param {GraphicsData} webGLData - TBD.
|
|
450
450
|
* @returns {boolean} TBD.
|
|
451
451
|
*/
|
|
452
|
-
export
|
|
452
|
+
export const buildPoly = (graphicsData, webGLData) => {
|
|
453
453
|
const points = graphicsData.points;
|
|
454
454
|
if (points.length < 6) {
|
|
455
455
|
return false;
|
|
@@ -480,14 +480,14 @@ export function buildPoly(graphicsData, webGLData) {
|
|
|
480
480
|
verts.push(points[i * 2], points[i * 2 + 1], r, g, b, alpha);
|
|
481
481
|
}
|
|
482
482
|
return true;
|
|
483
|
-
}
|
|
483
|
+
};
|
|
484
484
|
|
|
485
485
|
/**
|
|
486
486
|
* TBD.
|
|
487
487
|
* @param {object} graphics - TBD.
|
|
488
488
|
* @param {WebGLRenderingContext & { id: number }} gl - TBD.
|
|
489
489
|
*/
|
|
490
|
-
export
|
|
490
|
+
export const updateGraphics = (graphics, gl) => {
|
|
491
491
|
const stencilBufferLimit = getStencilBufferLimit();
|
|
492
492
|
// get the contexts graphics object
|
|
493
493
|
let webGL = graphics._webGL[gl.id];
|
|
@@ -569,14 +569,14 @@ export function updateGraphics(graphics, gl) {
|
|
|
569
569
|
webGLData.upload();
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
|
-
}
|
|
572
|
+
};
|
|
573
573
|
|
|
574
574
|
/**
|
|
575
575
|
* TBD.
|
|
576
576
|
* @param {object} graphics - TBD.
|
|
577
577
|
* @param {object} renderSession - TBD.
|
|
578
578
|
*/
|
|
579
|
-
export
|
|
579
|
+
export const renderGraphics = (graphics, renderSession) => {
|
|
580
580
|
const gl = renderSession.gl;
|
|
581
581
|
const projection = renderSession.projection;
|
|
582
582
|
const offset = renderSession.offset;
|
|
@@ -616,4 +616,4 @@ export function renderGraphics(graphics, renderSession) {
|
|
|
616
616
|
gl.drawElements(gl.TRIANGLE_STRIP, webGLData.indices.length, gl.UNSIGNED_SHORT, 0);
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
|
-
}
|
|
619
|
+
};
|
|
@@ -5,7 +5,7 @@ import { updateGraphics } from './graphics.js';
|
|
|
5
5
|
* @param {object} maskData - TBD.
|
|
6
6
|
* @param {object} renderSession - TBD.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export const pushMask = (maskData, renderSession) => {
|
|
9
9
|
const gl = renderSession.gl;
|
|
10
10
|
if (maskData.dirty) {
|
|
11
11
|
updateGraphics(maskData, gl);
|
|
@@ -18,14 +18,14 @@ export function pushMask(maskData, renderSession) {
|
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
renderSession.stencilManager.pushStencil(maskData, maskData._webGL[gl.id].data[0], renderSession);
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* TBD.
|
|
25
25
|
* @param {object} maskData - TBD.
|
|
26
26
|
* @param {object} renderSession - TBD.
|
|
27
27
|
*/
|
|
28
|
-
export
|
|
28
|
+
export const popMask = (maskData, renderSession) => {
|
|
29
29
|
const gl = renderSession.gl;
|
|
30
30
|
if (
|
|
31
31
|
maskData._webGL[gl.id] === undefined ||
|
|
@@ -35,4 +35,4 @@ export function popMask(maskData, renderSession) {
|
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
renderSession.stencilManager.popStencil(maskData, maskData._webGL[gl.id].data[0], renderSession);
|
|
38
|
-
}
|
|
38
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { compileProgram } from '../util.js';
|
|
3
3
|
|
|
4
4
|
// the next one is used for rendering triangle strips
|
|
@@ -10,7 +10,7 @@ export class ComplexPrimitiveShader {
|
|
|
10
10
|
*/
|
|
11
11
|
constructor(gl) {
|
|
12
12
|
this.gl = gl;
|
|
13
|
-
this._UID =
|
|
13
|
+
this._UID = uuidv4();
|
|
14
14
|
this.program = null;
|
|
15
15
|
this.fragmentSrc = [
|
|
16
16
|
'precision mediump float;',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { compileProgram } from '../util.js';
|
|
3
3
|
|
|
4
4
|
// this shader is used for the fast sprite rendering
|
|
@@ -10,7 +10,7 @@ export class FastShader {
|
|
|
10
10
|
*/
|
|
11
11
|
constructor(gl) {
|
|
12
12
|
this.gl = gl;
|
|
13
|
-
this._UID =
|
|
13
|
+
this._UID = uuidv4();
|
|
14
14
|
this.program = null;
|
|
15
15
|
this.textureCount = 0;
|
|
16
16
|
this.fragmentSrc = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { compileProgram } from '../util.js';
|
|
3
3
|
|
|
4
4
|
const defaultVertexSrc = [
|
|
@@ -30,7 +30,7 @@ export class NormalShader {
|
|
|
30
30
|
*/
|
|
31
31
|
constructor(gl) {
|
|
32
32
|
this.gl = gl;
|
|
33
|
-
this._UID =
|
|
33
|
+
this._UID = uuidv4();
|
|
34
34
|
this.program = null;
|
|
35
35
|
this.fragmentSrc = [
|
|
36
36
|
'precision lowp float;',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { compileProgram } from '../util.js';
|
|
3
3
|
|
|
4
4
|
// the next one is used for rendering primitives
|
|
@@ -10,7 +10,7 @@ export class PrimitiveShader {
|
|
|
10
10
|
*/
|
|
11
11
|
constructor(gl) {
|
|
12
12
|
this.gl = gl;
|
|
13
|
-
this._UID =
|
|
13
|
+
this._UID = uuidv4();
|
|
14
14
|
this.program = null;
|
|
15
15
|
this.fragmentSrc = [
|
|
16
16
|
'precision mediump float;',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { compileProgram } from '../util.js';
|
|
3
3
|
|
|
4
4
|
// the next one is used for rendering triangle strips
|
|
@@ -10,7 +10,7 @@ export class StripShader {
|
|
|
10
10
|
*/
|
|
11
11
|
constructor(gl) {
|
|
12
12
|
this.gl = gl;
|
|
13
|
-
this._UID =
|
|
13
|
+
this._UID = uuidv4();
|
|
14
14
|
this.program = null;
|
|
15
15
|
this.fragmentSrc = [
|
|
16
16
|
'precision mediump float;',
|