@vpmedia/phaser 1.67.0 → 1.69.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/device_util.js +18 -18
- package/src/phaser/core/frame_util.js +4 -4
- package/src/phaser/core/loader.js +2 -1
- package/src/phaser/core/loader_parser.js +8 -8
- 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/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 +40 -40
- 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 +40 -56
- 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/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.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/tween_data.d.ts +1 -1
- package/types/phaser/core/tween_data.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
|
@@ -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
|
+
};
|
|
@@ -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;',
|
|
@@ -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
|
+
};
|