@vpmedia/phaser 1.94.0 → 1.96.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/CHANGELOG.md +41 -0
- package/package.json +11 -11
- package/src/phaser/core/animation.js +79 -56
- package/src/phaser/core/animation_manager.js +55 -55
- package/src/phaser/core/animation_parser.js +2 -2
- package/src/phaser/core/cache.js +154 -154
- package/src/phaser/core/device.js +2 -1
- package/src/phaser/core/device_util.js +27 -27
- package/src/phaser/core/dom.js +43 -43
- package/src/phaser/core/event_manager.js +63 -63
- package/src/phaser/core/factory.js +47 -47
- package/src/phaser/core/frame.js +30 -30
- package/src/phaser/core/frame_data.js +30 -28
- package/src/phaser/core/frame_util.js +8 -8
- package/src/phaser/core/game.js +35 -19
- package/src/phaser/core/input_pointer.js +18 -0
- package/src/phaser/core/loader.js +171 -171
- package/src/phaser/core/loader_parser.js +22 -22
- package/src/phaser/core/raf.js +1 -1
- package/src/phaser/core/scale_manager.js +3 -2
- package/src/phaser/core/scene.js +16 -10
- package/src/phaser/core/scene_manager.js +51 -43
- package/src/phaser/core/signal.js +56 -52
- package/src/phaser/core/sound.js +54 -54
- package/src/phaser/core/sound_manager.js +49 -49
- package/src/phaser/core/stage.js +16 -16
- package/src/phaser/core/time.js +54 -30
- package/src/phaser/core/timer.js +82 -64
- package/src/phaser/core/timer_event.js +9 -9
- package/src/phaser/core/tween.js +106 -90
- package/src/phaser/core/tween_data.js +30 -30
- package/src/phaser/core/tween_manager.js +32 -24
- package/src/phaser/core/world.js +4 -3
- package/src/phaser/display/bitmap_text.js +72 -54
- package/src/phaser/display/button.js +48 -47
- package/src/phaser/display/canvas/buffer.js +8 -8
- package/src/phaser/display/canvas/graphics.js +8 -8
- package/src/phaser/display/canvas/masker.js +5 -5
- package/src/phaser/display/canvas/pool.js +18 -18
- package/src/phaser/display/canvas/renderer.js +17 -16
- package/src/phaser/display/canvas/tinter.js +22 -22
- package/src/phaser/display/canvas/util.js +42 -42
- package/src/phaser/display/display_object.js +119 -108
- package/src/phaser/display/graphics.js +129 -112
- package/src/phaser/display/graphics_data.js +10 -10
- package/src/phaser/display/graphics_data_util.js +3 -3
- package/src/phaser/display/group.js +63 -50
- package/src/phaser/display/image.js +68 -50
- package/src/phaser/display/sprite_batch.js +2 -2
- package/src/phaser/display/sprite_util.js +19 -19
- package/src/phaser/display/text.js +217 -187
- package/src/phaser/display/webgl/abstract_filter.js +4 -4
- package/src/phaser/display/webgl/base_texture.js +9 -9
- package/src/phaser/display/webgl/blend_manager.js +7 -7
- package/src/phaser/display/webgl/earcut.js +95 -95
- package/src/phaser/display/webgl/earcut_node.js +4 -4
- package/src/phaser/display/webgl/fast_sprite_batch.js +15 -15
- package/src/phaser/display/webgl/filter_manager.js +9 -9
- package/src/phaser/display/webgl/filter_texture.js +10 -10
- package/src/phaser/display/webgl/graphics.js +37 -37
- package/src/phaser/display/webgl/graphics_data.js +4 -4
- package/src/phaser/display/webgl/mask_manager.js +6 -6
- package/src/phaser/display/webgl/render_texture.js +16 -16
- package/src/phaser/display/webgl/renderer.js +21 -20
- package/src/phaser/display/webgl/shader/complex.js +4 -4
- package/src/phaser/display/webgl/shader/fast.js +4 -4
- package/src/phaser/display/webgl/shader/normal.js +8 -8
- package/src/phaser/display/webgl/shader/primitive.js +4 -4
- package/src/phaser/display/webgl/shader/strip.js +4 -4
- package/src/phaser/display/webgl/shader_manager.js +9 -9
- package/src/phaser/display/webgl/sprite_batch.js +18 -18
- package/src/phaser/display/webgl/stencil_manager.js +16 -16
- package/src/phaser/display/webgl/texture.js +13 -13
- package/src/phaser/display/webgl/texture_util.js +8 -8
- package/src/phaser/display/webgl/util.js +25 -25
- package/src/phaser/geom/circle.js +74 -69
- package/src/phaser/geom/ellipse.js +33 -28
- package/src/phaser/geom/line.js +96 -93
- package/src/phaser/geom/matrix.js +61 -54
- package/src/phaser/geom/point.js +99 -96
- package/src/phaser/geom/polygon.js +27 -22
- package/src/phaser/geom/rectangle.js +137 -132
- package/src/phaser/geom/rounded_rectangle.js +12 -12
- package/src/phaser/geom/util/circle.js +33 -33
- package/src/phaser/geom/util/ellipse.js +5 -5
- package/src/phaser/geom/util/line.js +26 -26
- package/src/phaser/geom/util/matrix.js +8 -8
- package/src/phaser/geom/util/point.js +97 -97
- package/src/phaser/geom/util/polygon.js +4 -4
- package/src/phaser/geom/util/rectangle.js +74 -74
- package/src/phaser/geom/util/rounded_rectangle.js +4 -4
- package/src/phaser/util/math.js +81 -81
- package/types/phaser/core/animation.d.ts +79 -56
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +55 -55
- package/types/phaser/core/animation_parser.d.ts +3 -2
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +154 -154
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +51 -44
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +63 -63
- package/types/phaser/core/factory.d.ts +47 -47
- package/types/phaser/core/frame.d.ts +30 -30
- package/types/phaser/core/frame_data.d.ts +28 -27
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +54 -21
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +18 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +175 -172
- package/types/phaser/core/loader.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +1 -1
- package/types/phaser/core/scale_manager.d.ts +6 -5
- package/types/phaser/core/scale_manager.d.ts.map +1 -1
- package/types/phaser/core/scene.d.ts +15 -9
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +51 -43
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +54 -51
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +54 -54
- package/types/phaser/core/sound_manager.d.ts +49 -49
- package/types/phaser/core/stage.d.ts +10 -10
- package/types/phaser/core/time.d.ts +54 -30
- package/types/phaser/core/time.d.ts.map +1 -1
- package/types/phaser/core/timer.d.ts +82 -64
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +9 -9
- package/types/phaser/core/tween.d.ts +106 -90
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +30 -30
- package/types/phaser/core/tween_manager.d.ts +35 -67
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +4 -3
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +76 -53
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +47 -46
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +8 -8
- package/types/phaser/display/canvas/graphics.d.ts +3 -3
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +6 -3
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +18 -17
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts +6 -6
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +119 -108
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +118 -102
- package/types/phaser/display/graphics.d.ts.map +1 -1
- package/types/phaser/display/graphics_data.d.ts +10 -10
- package/types/phaser/display/group.d.ts +59 -47
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +58 -45
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +237 -188
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +4 -4
- package/types/phaser/display/webgl/base_texture.d.ts +10 -10
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/blend_manager.d.ts +6 -6
- package/types/phaser/display/webgl/earcut.d.ts +95 -95
- package/types/phaser/display/webgl/earcut_node.d.ts +4 -4
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +15 -15
- package/types/phaser/display/webgl/filter_manager.d.ts +8 -8
- package/types/phaser/display/webgl/filter_texture.d.ts +10 -10
- package/types/phaser/display/webgl/graphics.d.ts +2 -2
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +4 -4
- package/types/phaser/display/webgl/render_texture.d.ts +16 -16
- package/types/phaser/display/webgl/renderer.d.ts +21 -20
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +4 -4
- package/types/phaser/display/webgl/shader/fast.d.ts +4 -4
- package/types/phaser/display/webgl/shader/normal.d.ts +8 -8
- package/types/phaser/display/webgl/shader/primitive.d.ts +4 -4
- package/types/phaser/display/webgl/shader/strip.d.ts +4 -4
- package/types/phaser/display/webgl/shader_manager.d.ts +8 -8
- package/types/phaser/display/webgl/sprite_batch.d.ts +17 -17
- package/types/phaser/display/webgl/stencil_manager.d.ts +15 -15
- package/types/phaser/display/webgl/texture.d.ts +12 -12
- package/types/phaser/display/webgl/texture_util.d.ts +4 -2
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +74 -69
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +33 -28
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +96 -93
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +61 -54
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +99 -96
- package/types/phaser/geom/point.d.ts.map +1 -1
- package/types/phaser/geom/polygon.d.ts +29 -23
- package/types/phaser/geom/polygon.d.ts.map +1 -1
- package/types/phaser/geom/rectangle.d.ts +137 -132
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
- package/types/phaser/geom/util/point.d.ts +1 -1
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/pnpm-workspace.yaml +0 -4
|
@@ -5,8 +5,8 @@ import { triangulate } from './earcut.js';
|
|
|
5
5
|
import { GraphicsData } from './graphics_data.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @returns {number}
|
|
8
|
+
* Updates the graphics data for WebGL rendering.
|
|
9
|
+
* @returns {number} The number of vertices in the graphics data.
|
|
10
10
|
*/
|
|
11
11
|
export const getStencilBufferLimit = () => {
|
|
12
12
|
if (!window.PhaserRegistry.stencilBufferLimit) {
|
|
@@ -16,8 +16,8 @@ export const getStencilBufferLimit = () => {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @returns {object[]}
|
|
19
|
+
* Updates the graphics data for WebGL rendering.
|
|
20
|
+
* @returns {object[]} The graphics data array.
|
|
21
21
|
*/
|
|
22
22
|
export const getGraphicsDataPool = () => {
|
|
23
23
|
if (!window.PhaserRegistry.graphicsDataPool) {
|
|
@@ -27,10 +27,10 @@ export const getGraphicsDataPool = () => {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @param {object} webGL -
|
|
32
|
-
* @param {number} type -
|
|
33
|
-
* @returns {object}
|
|
30
|
+
* Updates the graphics data for WebGL rendering.
|
|
31
|
+
* @param {object} webGL - The WebGL context.
|
|
32
|
+
* @param {number} type - The type of graphics data to create.
|
|
33
|
+
* @returns {object} The newly created graphics data object.
|
|
34
34
|
*/
|
|
35
35
|
export const switchMode = (webGL, type) => {
|
|
36
36
|
let webGLData;
|
|
@@ -51,9 +51,9 @@ export const switchMode = (webGL, type) => {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
55
|
-
* @param {object} graphicsData -
|
|
56
|
-
* @param {GraphicsData} webGLData -
|
|
54
|
+
* Updates the graphics data for WebGL rendering.
|
|
55
|
+
* @param {object} graphicsData - The graphics data to update.
|
|
56
|
+
* @param {GraphicsData} webGLData - The WebGL graphics data object.
|
|
57
57
|
*/
|
|
58
58
|
export const buildLine = (graphicsData, webGLData) => {
|
|
59
59
|
// TODO OPTIMISE!
|
|
@@ -216,9 +216,9 @@ export const buildLine = (graphicsData, webGLData) => {
|
|
|
216
216
|
};
|
|
217
217
|
|
|
218
218
|
/**
|
|
219
|
-
*
|
|
220
|
-
* @param {object} graphicsData -
|
|
221
|
-
* @param {GraphicsData} webGLData -
|
|
219
|
+
* Updates the graphics data for WebGL rendering.
|
|
220
|
+
* @param {object} graphicsData - The graphics data to update.
|
|
221
|
+
* @param {GraphicsData} webGLData - The WebGL graphics data object.
|
|
222
222
|
*/
|
|
223
223
|
export const buildRectangle = (graphicsData, webGLData) => {
|
|
224
224
|
//
|
|
@@ -260,14 +260,14 @@ export const buildRectangle = (graphicsData, webGLData) => {
|
|
|
260
260
|
};
|
|
261
261
|
|
|
262
262
|
/**
|
|
263
|
-
*
|
|
264
|
-
* @param {number} fromX -
|
|
265
|
-
* @param {number} fromY -
|
|
266
|
-
* @param {number} cpX -
|
|
267
|
-
* @param {number} cpY -
|
|
268
|
-
* @param {number} toX -
|
|
269
|
-
* @param {number} toY -
|
|
270
|
-
* @returns {number[]}
|
|
263
|
+
* Updates the graphics data for WebGL rendering.
|
|
264
|
+
* @param {number} fromX - The starting x-coordinate.
|
|
265
|
+
* @param {number} fromY - The starting y-coordinate.
|
|
266
|
+
* @param {number} cpX - The control point x-coordinate.
|
|
267
|
+
* @param {number} cpY - The control point y-coordinate.
|
|
268
|
+
* @param {number} toX - The ending x-coordinate.
|
|
269
|
+
* @param {number} toY - The ending y-coordinate.
|
|
270
|
+
* @returns {number[]} The calculated points for the quadratic bezier curve.
|
|
271
271
|
*/
|
|
272
272
|
export const quadraticBezierCurve = (fromX, fromY, cpX, cpY, toX, toY) => {
|
|
273
273
|
let xa;
|
|
@@ -299,9 +299,9 @@ export const quadraticBezierCurve = (fromX, fromY, cpX, cpY, toX, toY) => {
|
|
|
299
299
|
};
|
|
300
300
|
|
|
301
301
|
/**
|
|
302
|
-
*
|
|
303
|
-
* @param {object} graphicsData -
|
|
304
|
-
* @param {GraphicsData} webGLData -
|
|
302
|
+
* Updates the graphics data for WebGL rendering.
|
|
303
|
+
* @param {object} graphicsData - The graphics data to update.
|
|
304
|
+
* @param {GraphicsData} webGLData - The WebGL graphics data object.
|
|
305
305
|
*/
|
|
306
306
|
export const buildRoundedRectangle = (graphicsData, webGLData) => {
|
|
307
307
|
const rrectData = graphicsData.shape;
|
|
@@ -349,9 +349,9 @@ export const buildRoundedRectangle = (graphicsData, webGLData) => {
|
|
|
349
349
|
};
|
|
350
350
|
|
|
351
351
|
/**
|
|
352
|
-
*
|
|
353
|
-
* @param {object} graphicsData -
|
|
354
|
-
* @param {GraphicsData} webGLData -
|
|
352
|
+
* Updates the graphics data for WebGL rendering.
|
|
353
|
+
* @param {object} graphicsData - The graphics data to update.
|
|
354
|
+
* @param {GraphicsData} webGLData - The WebGL graphics data object.
|
|
355
355
|
*/
|
|
356
356
|
export const buildCircle = (graphicsData, webGLData) => {
|
|
357
357
|
// need to convert points to a nice regular data
|
|
@@ -400,9 +400,9 @@ export const buildCircle = (graphicsData, webGLData) => {
|
|
|
400
400
|
};
|
|
401
401
|
|
|
402
402
|
/**
|
|
403
|
-
*
|
|
404
|
-
* @param {object} graphicsData -
|
|
405
|
-
* @param {GraphicsData} webGLData -
|
|
403
|
+
* Updates the graphics data for WebGL rendering.
|
|
404
|
+
* @param {object} graphicsData - The graphics data to update.
|
|
405
|
+
* @param {GraphicsData} webGLData - The WebGL graphics data object.
|
|
406
406
|
*/
|
|
407
407
|
export const buildComplexPoly = (graphicsData, webGLData) => {
|
|
408
408
|
// TODO - no need to copy this as it gets turned into a Float32Array anyways..
|
|
@@ -444,7 +444,7 @@ export const buildComplexPoly = (graphicsData, webGLData) => {
|
|
|
444
444
|
};
|
|
445
445
|
|
|
446
446
|
/**
|
|
447
|
-
*
|
|
447
|
+
* Updates the graphics data for WebGL rendering.
|
|
448
448
|
* @param {object} graphicsData - TBD.
|
|
449
449
|
* @param {GraphicsData} webGLData - TBD.
|
|
450
450
|
* @returns {boolean} TBD.
|
|
@@ -484,8 +484,8 @@ export const buildPoly = (graphicsData, webGLData) => {
|
|
|
484
484
|
|
|
485
485
|
/**
|
|
486
486
|
* TBD.
|
|
487
|
-
* @param {
|
|
488
|
-
* @param {WebGLRenderingContext & { id: number }} gl -
|
|
487
|
+
* @param {import('../graphics.js').Graphics} graphics - The graphics object to update.
|
|
488
|
+
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
489
489
|
*/
|
|
490
490
|
export const updateGraphics = (graphics, gl) => {
|
|
491
491
|
const stencilBufferLimit = getStencilBufferLimit();
|
|
@@ -572,9 +572,9 @@ export const updateGraphics = (graphics, gl) => {
|
|
|
572
572
|
};
|
|
573
573
|
|
|
574
574
|
/**
|
|
575
|
-
*
|
|
576
|
-
* @param {
|
|
577
|
-
* @param {object} renderSession -
|
|
575
|
+
* Updates the graphics data for WebGL rendering.
|
|
576
|
+
* @param {import('../graphics.js').Graphics} graphics - The graphics object to update.
|
|
577
|
+
* @param {object} renderSession - The rendering session.
|
|
578
578
|
*/
|
|
579
579
|
export const renderGraphics = (graphics, renderSession) => {
|
|
580
580
|
const gl = renderSession.gl;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export class GraphicsData {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {WebGLRenderingContext} gl -
|
|
3
|
+
* Creates a new GraphicsData instance.
|
|
4
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
5
5
|
*/
|
|
6
6
|
constructor(gl) {
|
|
7
7
|
this.gl = gl;
|
|
@@ -17,7 +17,7 @@ export class GraphicsData {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Destroys this graphics data and cleans up resources.
|
|
21
21
|
*/
|
|
22
22
|
reset() {
|
|
23
23
|
this.points = [];
|
|
@@ -27,7 +27,7 @@ export class GraphicsData {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Updates the graphics data for WebGL rendering.
|
|
31
31
|
*/
|
|
32
32
|
upload() {
|
|
33
33
|
const gl = this.gl;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { updateGraphics } from './graphics.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {object} maskData -
|
|
6
|
-
* @param {object} renderSession -
|
|
4
|
+
* Sets up the mask manager for WebGL rendering.
|
|
5
|
+
* @param {object} maskData - The mask data to apply.
|
|
6
|
+
* @param {object} renderSession - The rendering session.
|
|
7
7
|
*/
|
|
8
8
|
export const pushMask = (maskData, renderSession) => {
|
|
9
9
|
const gl = renderSession.gl;
|
|
@@ -21,9 +21,9 @@ export const pushMask = (maskData, renderSession) => {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @param {object} maskData -
|
|
26
|
-
* @param {object} renderSession -
|
|
24
|
+
* Sets up the mask manager for WebGL rendering.
|
|
25
|
+
* @param {object} maskData - The mask data to apply.
|
|
26
|
+
* @param {object} renderSession - The rendering session.
|
|
27
27
|
*/
|
|
28
28
|
export const popMask = (maskData, renderSession) => {
|
|
29
29
|
const gl = renderSession.gl;
|
|
@@ -8,12 +8,12 @@ import { Texture } from './texture.js';
|
|
|
8
8
|
|
|
9
9
|
export class RenderTexture extends Texture {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {number} width -
|
|
13
|
-
* @param {number} height -
|
|
14
|
-
* @param {import('./renderer.js').WebGLRenderer|import('../canvas/renderer.js').CanvasRenderer} renderer -
|
|
15
|
-
* @param {number} scaleMode -
|
|
16
|
-
* @param {number} resolution -
|
|
11
|
+
* Creates a new RenderTexture instance.
|
|
12
|
+
* @param {number} width - The width of the render texture.
|
|
13
|
+
* @param {number} height - The height of the render texture.
|
|
14
|
+
* @param {import('./renderer.js').WebGLRenderer|import('../canvas/renderer.js').CanvasRenderer} renderer - The renderer to use.
|
|
15
|
+
* @param {number} scaleMode - The scale mode to use.
|
|
16
|
+
* @param {number} resolution - The resolution to use.
|
|
17
17
|
*/
|
|
18
18
|
constructor(width, height, renderer, scaleMode, resolution = 1) {
|
|
19
19
|
const w = width || 100;
|
|
@@ -51,36 +51,36 @@ export class RenderTexture extends Texture {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Destroys this render texture and cleans up resources.
|
|
55
55
|
*/
|
|
56
56
|
resize() {
|
|
57
57
|
// TODO
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Updates the size of this render texture.
|
|
62
62
|
*/
|
|
63
63
|
clear() {
|
|
64
64
|
// TODO
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* Updates the resolution of this render texture.
|
|
69
69
|
*/
|
|
70
70
|
renderWebGL() {
|
|
71
71
|
// TODO
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
75
|
+
* Updates the scale mode of this render texture.
|
|
76
76
|
*/
|
|
77
77
|
renderCanvas() {
|
|
78
78
|
// TODO
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
|
-
*
|
|
83
|
-
* @returns {HTMLImageElement}
|
|
82
|
+
* Gets the HTML image element for this render texture.
|
|
83
|
+
* @returns {HTMLImageElement} The HTML image element.
|
|
84
84
|
*/
|
|
85
85
|
getImage() {
|
|
86
86
|
const image = new Image();
|
|
@@ -89,16 +89,16 @@ export class RenderTexture extends Texture {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
93
|
-
* @returns {string}
|
|
92
|
+
* Gets the base64 string representation of this render texture.
|
|
93
|
+
* @returns {string} The base64 string representation.
|
|
94
94
|
*/
|
|
95
95
|
getBase64() {
|
|
96
96
|
return this.getCanvas().toDataURL();
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
101
|
-
* @returns {HTMLCanvasElement}
|
|
100
|
+
* Gets the canvas element for this render texture.
|
|
101
|
+
* @returns {HTMLCanvasElement} The canvas element.
|
|
102
102
|
*/
|
|
103
103
|
getCanvas() {
|
|
104
104
|
// TODO
|
|
@@ -33,10 +33,11 @@ import { getWebGLContextErrorCode, getWebGLContextErrorName } from './util.js';
|
|
|
33
33
|
|
|
34
34
|
export class WebGLRenderer {
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param {import('../../core/game.js').Game} game -
|
|
36
|
+
* Creates a new WebGLRenderer instance.
|
|
37
|
+
* @param {import('../../core/game.js').Game} game - The game instance.
|
|
38
38
|
*/
|
|
39
39
|
constructor(game) {
|
|
40
|
+
/** @type {number} */
|
|
40
41
|
this.type = RENDER_WEBGL;
|
|
41
42
|
this.resolution = game.config.resolution;
|
|
42
43
|
this.autoResize = false;
|
|
@@ -77,7 +78,7 @@ export class WebGLRenderer {
|
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
|
-
*
|
|
81
|
+
* Destroys this renderer and cleans up resources.
|
|
81
82
|
*/
|
|
82
83
|
destroy() {
|
|
83
84
|
window.PhaserRegistry.GL_CONTEXTS[this.glContextId] = null;
|
|
@@ -105,7 +106,7 @@ export class WebGLRenderer {
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
/**
|
|
108
|
-
*
|
|
109
|
+
* Initializes the WebGL registry.
|
|
109
110
|
*/
|
|
110
111
|
initRegistry() {
|
|
111
112
|
if (!window.PhaserRegistry.GL_CONTEXT_ID) {
|
|
@@ -120,8 +121,8 @@ export class WebGLRenderer {
|
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
/**
|
|
123
|
-
*
|
|
124
|
-
* @param {import('../../core/game.js').Game} game -
|
|
124
|
+
* Initializes the WebGL context for rendering.
|
|
125
|
+
* @param {import('../../core/game.js').Game} game - The game instance.
|
|
125
126
|
* @throws {Error}
|
|
126
127
|
*/
|
|
127
128
|
initContext(game) {
|
|
@@ -165,8 +166,8 @@ export class WebGLRenderer {
|
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
/**
|
|
168
|
-
*
|
|
169
|
-
* @param {import('../../core/stage.js').Stage} stage -
|
|
169
|
+
* Renders the stage to WebGL.
|
|
170
|
+
* @param {import('../../core/stage.js').Stage} stage - The root stage to render.
|
|
170
171
|
*/
|
|
171
172
|
render(stage) {
|
|
172
173
|
if (this.contextLost) {
|
|
@@ -187,11 +188,11 @@ export class WebGLRenderer {
|
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
/**
|
|
190
|
-
*
|
|
191
|
-
* @param {import('../../display/display_object.js').DisplayObject} displayObject -
|
|
192
|
-
* @param {Point} projection -
|
|
193
|
-
* @param {object} buffer -
|
|
194
|
-
* @param {import('../../geom/matrix.js').Matrix} matrix -
|
|
191
|
+
* Renders a display object to WebGL.
|
|
192
|
+
* @param {import('../../display/display_object.js').DisplayObject} displayObject - The display object to render.
|
|
193
|
+
* @param {Point} projection - The projection matrix.
|
|
194
|
+
* @param {object} buffer - The render buffer.
|
|
195
|
+
* @param {import('../../geom/matrix.js').Matrix} matrix - The transformation matrix.
|
|
195
196
|
*/
|
|
196
197
|
renderDisplayObject(displayObject, projection, buffer, matrix) {
|
|
197
198
|
this.renderSession.blendModeManager.setBlendMode(BLEND_NORMAL);
|
|
@@ -214,9 +215,9 @@ export class WebGLRenderer {
|
|
|
214
215
|
}
|
|
215
216
|
|
|
216
217
|
/**
|
|
217
|
-
*
|
|
218
|
-
* @param {number} width -
|
|
219
|
-
* @param {number} height -
|
|
218
|
+
* Resizes the WebGL canvas to the specified dimensions.
|
|
219
|
+
* @param {number} width - The new width of the canvas.
|
|
220
|
+
* @param {number} height - The new height of the canvas.
|
|
220
221
|
*/
|
|
221
222
|
resize(width, height) {
|
|
222
223
|
this.width = width * this.resolution;
|
|
@@ -233,9 +234,9 @@ export class WebGLRenderer {
|
|
|
233
234
|
}
|
|
234
235
|
|
|
235
236
|
/**
|
|
236
|
-
*
|
|
237
|
-
* @param {import('./base_texture.js').BaseTexture} texture -
|
|
238
|
-
* @returns {boolean}
|
|
237
|
+
* Updates a texture in the WebGL context.
|
|
238
|
+
* @param {import('./base_texture.js').BaseTexture} texture - The base texture to update.
|
|
239
|
+
* @returns {boolean} Whether the update was successful.
|
|
239
240
|
*/
|
|
240
241
|
updateTexture(texture) {
|
|
241
242
|
if (!texture.hasLoaded) {
|
|
@@ -276,7 +277,7 @@ export class WebGLRenderer {
|
|
|
276
277
|
}
|
|
277
278
|
|
|
278
279
|
/**
|
|
279
|
-
*
|
|
280
|
+
* Maps blend modes to WebGL rendering operations.
|
|
280
281
|
*/
|
|
281
282
|
mapBlendModes() {
|
|
282
283
|
if (window.PhaserRegistry.blendModesWebGL) {
|
|
@@ -5,8 +5,8 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
|
|
6
6
|
export class ComplexPrimitiveShader {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {WebGLRenderingContext} gl -
|
|
8
|
+
* Creates a new ComplexShader instance.
|
|
9
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
10
10
|
*/
|
|
11
11
|
constructor(gl) {
|
|
12
12
|
this.gl = gl;
|
|
@@ -44,7 +44,7 @@ export class ComplexPrimitiveShader {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* Destroys this shader and cleans up resources.
|
|
48
48
|
*/
|
|
49
49
|
init() {
|
|
50
50
|
const gl = this.gl;
|
|
@@ -66,7 +66,7 @@ export class ComplexPrimitiveShader {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* Binds this shader to the WebGL context.
|
|
70
70
|
*/
|
|
71
71
|
destroy() {
|
|
72
72
|
this.gl.deleteProgram(this.program);
|
|
@@ -5,8 +5,8 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
|
|
6
6
|
export class FastShader {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {WebGLRenderingContext} gl -
|
|
8
|
+
* Creates a new FastShader instance.
|
|
9
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
10
10
|
*/
|
|
11
11
|
constructor(gl) {
|
|
12
12
|
this.gl = gl;
|
|
@@ -56,7 +56,7 @@ export class FastShader {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* Creates a new FastShader instance.
|
|
60
60
|
*/
|
|
61
61
|
init() {
|
|
62
62
|
const gl = this.gl;
|
|
@@ -96,7 +96,7 @@ export class FastShader {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
*
|
|
99
|
+
* Destroys this shader and cleans up resources.
|
|
100
100
|
*/
|
|
101
101
|
destroy() {
|
|
102
102
|
this.gl.deleteProgram(this.program);
|
|
@@ -25,8 +25,8 @@ const defaultVertexSrc = [
|
|
|
25
25
|
|
|
26
26
|
export class NormalShader {
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param {WebGLRenderingContext & { id: number }} gl -
|
|
28
|
+
* Creates a new NormalShader instance.
|
|
29
|
+
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
30
30
|
*/
|
|
31
31
|
constructor(gl) {
|
|
32
32
|
this.gl = gl;
|
|
@@ -53,7 +53,7 @@ export class NormalShader {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Destroys this shader and cleans up resources.
|
|
57
57
|
*/
|
|
58
58
|
init() {
|
|
59
59
|
const gl = this.gl;
|
|
@@ -89,7 +89,7 @@ export class NormalShader {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* Binds this shader to the WebGL context.
|
|
93
93
|
*/
|
|
94
94
|
initUniforms() {
|
|
95
95
|
this.textureCount = 1;
|
|
@@ -133,8 +133,8 @@ export class NormalShader {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
|
-
*
|
|
137
|
-
* @param {object} uniform -
|
|
136
|
+
* Sets a uniform value for this shader.
|
|
137
|
+
* @param {object} uniform - The uniform to set.
|
|
138
138
|
*/
|
|
139
139
|
initSampler2D(uniform) {
|
|
140
140
|
if (!uniform.value || !uniform.value.baseTexture || !uniform.value.baseTexture.hasLoaded) {
|
|
@@ -186,7 +186,7 @@ export class NormalShader {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/**
|
|
189
|
-
*
|
|
189
|
+
* Sets the shader to use for rendering.
|
|
190
190
|
*/
|
|
191
191
|
syncUniforms() {
|
|
192
192
|
this.textureCount = 1;
|
|
@@ -236,7 +236,7 @@ export class NormalShader {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
|
-
*
|
|
239
|
+
* Destroys this shader and cleans up resources.
|
|
240
240
|
*/
|
|
241
241
|
destroy() {
|
|
242
242
|
this.gl.deleteProgram(this.program);
|
|
@@ -5,8 +5,8 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
|
|
6
6
|
export class PrimitiveShader {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {WebGLRenderingContext} gl -
|
|
8
|
+
* Creates a new PrimitiveShader instance.
|
|
9
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
10
10
|
*/
|
|
11
11
|
constructor(gl) {
|
|
12
12
|
this.gl = gl;
|
|
@@ -43,7 +43,7 @@ export class PrimitiveShader {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Destroys this shader and cleans up resources.
|
|
47
47
|
*/
|
|
48
48
|
init() {
|
|
49
49
|
const gl = this.gl;
|
|
@@ -64,7 +64,7 @@ export class PrimitiveShader {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* Binds this shader to the WebGL context.
|
|
68
68
|
*/
|
|
69
69
|
destroy() {
|
|
70
70
|
this.gl.deleteProgram(this.program);
|
|
@@ -5,8 +5,8 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
|
|
6
6
|
export class StripShader {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {WebGLRenderingContext} gl -
|
|
8
|
+
* Creates a new StripShader instance.
|
|
9
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
10
10
|
*/
|
|
11
11
|
constructor(gl) {
|
|
12
12
|
this.gl = gl;
|
|
@@ -47,7 +47,7 @@ export class StripShader {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Destroys this shader and cleans up resources.
|
|
51
51
|
*/
|
|
52
52
|
init() {
|
|
53
53
|
const gl = this.gl;
|
|
@@ -69,7 +69,7 @@ export class StripShader {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Binds this shader to the WebGL context.
|
|
73
73
|
*/
|
|
74
74
|
destroy() {
|
|
75
75
|
this.gl.deleteProgram(this.program);
|
|
@@ -6,7 +6,7 @@ import { StripShader } from './shader/strip.js';
|
|
|
6
6
|
|
|
7
7
|
export class WebGLShaderManager {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Initializes the shader manager with a WebGL context.
|
|
10
10
|
*/
|
|
11
11
|
constructor() {
|
|
12
12
|
this.gl = null;
|
|
@@ -25,8 +25,8 @@ export class WebGLShaderManager {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param {WebGLRenderingContext & { id: number }} gl -
|
|
28
|
+
* Initializes the shader manager with a WebGL context.
|
|
29
|
+
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
30
30
|
*/
|
|
31
31
|
setContext(gl) {
|
|
32
32
|
this.gl = gl;
|
|
@@ -39,8 +39,8 @@ export class WebGLShaderManager {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param {number[]} attribs -
|
|
42
|
+
* Sets up the shader manager for WebGL rendering.
|
|
43
|
+
* @param {number[]} attribs - The attribute locations to set up.
|
|
44
44
|
*/
|
|
45
45
|
setAttribs(attribs) {
|
|
46
46
|
// reset temp state
|
|
@@ -67,9 +67,9 @@ export class WebGLShaderManager {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
71
|
-
* @param {NormalShader} shader -
|
|
72
|
-
* @returns {boolean}
|
|
70
|
+
* Sets up the shader manager for WebGL rendering.
|
|
71
|
+
* @param {NormalShader} shader - The shader to set up.
|
|
72
|
+
* @returns {boolean} Whether the shader setup was successful.
|
|
73
73
|
*/
|
|
74
74
|
setShader(shader) {
|
|
75
75
|
if (this._currentId === shader._UID) {
|
|
@@ -83,7 +83,7 @@ export class WebGLShaderManager {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
86
|
+
* Destroys the manager.
|
|
87
87
|
*/
|
|
88
88
|
destroy() {
|
|
89
89
|
this.attribState = null;
|