@vpmedia/phaser 1.112.0 → 1.113.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/dist/index.js +1261 -1314
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +14 -10
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +10 -8
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +5 -4
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +4 -3
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/const.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +3 -2
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +1 -1
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +8 -6
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +40 -30
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +3 -2
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +3 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +6 -4
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +3 -2
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +4 -3
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +9 -8
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts +3 -2
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/registry.d.ts +7 -0
- package/dist/phaser/core/registry.d.ts.map +1 -0
- package/dist/phaser/core/scale_manager.d.ts +1 -1
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +0 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +1 -1
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts +0 -1
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts +4 -3
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +6 -4
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +3 -2
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +5 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +3 -2
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +1 -1
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +1 -1
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +10 -7
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +3 -2
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_easing.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +3 -2
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts +3 -2
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +3 -2
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +3 -2
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/graphics.d.ts +7 -6
- package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts +2 -2
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +10 -8
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts +3 -2
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts +2 -2
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +14 -12
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +8 -5
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +4 -3
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +13 -10
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_batch.d.ts +3 -2
- package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +18 -15
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +11 -9
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +0 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +4 -3
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +7 -6
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +4 -2
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +16 -11
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +16 -6
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +19 -7
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +33 -12
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +15 -6
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +15 -6
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +16 -11
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +29 -20
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +12 -10
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +3 -2
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts +4 -1
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts +1 -1
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/point.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts +3 -2
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts +2 -2
- package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/phaser/core/animation.ts +64 -60
- package/src/phaser/core/animation_manager.ts +50 -53
- package/src/phaser/core/animation_parser.ts +9 -9
- package/src/phaser/core/array_set.ts +16 -17
- package/src/phaser/core/cache.ts +92 -93
- package/src/phaser/core/const.ts +1 -1
- package/src/phaser/core/device.ts +24 -29
- package/src/phaser/core/device_util.ts +22 -26
- package/src/phaser/core/dom.ts +54 -65
- package/src/phaser/core/event_manager.ts +64 -94
- package/src/phaser/core/factory.ts +14 -14
- package/src/phaser/core/frame.ts +28 -28
- package/src/phaser/core/frame_data.test.ts +100 -0
- package/src/phaser/core/frame_data.ts +24 -24
- package/src/phaser/core/frame_util.ts +2 -2
- package/src/phaser/core/game.ts +47 -48
- package/src/phaser/core/input.ts +104 -110
- package/src/phaser/core/input_handler.test.ts +113 -0
- package/src/phaser/core/input_handler.ts +199 -218
- package/src/phaser/core/input_mouse.ts +71 -54
- package/src/phaser/core/input_mspointer.ts +52 -39
- package/src/phaser/core/input_pointer.ts +81 -80
- package/src/phaser/core/input_touch.ts +49 -36
- package/src/phaser/core/loader.ts +173 -152
- package/src/phaser/core/loader_parser.ts +39 -57
- package/src/phaser/core/raf.ts +8 -7
- package/src/phaser/core/registry.test.ts +31 -0
- package/src/phaser/core/registry.ts +9 -0
- package/src/phaser/core/scale_manager.ts +156 -152
- package/src/phaser/core/scene.ts +9 -13
- package/src/phaser/core/scene_manager.ts +47 -47
- package/src/phaser/core/signal.test.ts +4 -4
- package/src/phaser/core/signal.ts +41 -52
- package/src/phaser/core/signal_binding.ts +26 -25
- package/src/phaser/core/signal_dispatch.test.ts +180 -0
- package/src/phaser/core/sound.ts +75 -83
- package/src/phaser/core/sound_manager.ts +52 -51
- package/src/phaser/core/sound_sprite.ts +17 -16
- package/src/phaser/core/stage.ts +25 -24
- package/src/phaser/core/time.ts +52 -52
- package/src/phaser/core/timer.test.ts +187 -0
- package/src/phaser/core/timer.ts +82 -69
- package/src/phaser/core/timer_event.ts +10 -10
- package/src/phaser/core/tween.ts +90 -93
- package/src/phaser/core/tween_data.ts +45 -51
- package/src/phaser/core/tween_easing.test.ts +106 -0
- package/src/phaser/core/tween_easing.ts +151 -123
- package/src/phaser/core/tween_manager.ts +19 -18
- package/src/phaser/core/world.ts +4 -3
- package/src/phaser/display/bitmap_text.ts +56 -64
- package/src/phaser/display/button.ts +33 -32
- package/src/phaser/display/canvas/buffer.ts +8 -8
- package/src/phaser/display/canvas/graphics.ts +36 -37
- package/src/phaser/display/canvas/masker.ts +2 -2
- package/src/phaser/display/canvas/pool.test.ts +106 -0
- package/src/phaser/display/canvas/pool.ts +25 -27
- package/src/phaser/display/canvas/renderer.ts +32 -31
- package/src/phaser/display/canvas/tinter.ts +25 -25
- package/src/phaser/display/canvas/util.ts +7 -10
- package/src/phaser/display/display_object.ts +114 -118
- package/src/phaser/display/graphics.ts +121 -119
- package/src/phaser/display/graphics_data.ts +12 -12
- package/src/phaser/display/graphics_data_util.ts +2 -3
- package/src/phaser/display/group.ts +50 -57
- package/src/phaser/display/image.ts +55 -52
- package/src/phaser/display/sprite_batch.ts +3 -2
- package/src/phaser/display/sprite_util.ts +48 -54
- package/src/phaser/display/text.ts +199 -204
- package/src/phaser/display/webgl/abstract_filter.ts +9 -9
- package/src/phaser/display/webgl/base_texture.ts +21 -24
- package/src/phaser/display/webgl/blend_manager.ts +6 -10
- package/src/phaser/display/webgl/earcut.ts +73 -37
- package/src/phaser/display/webgl/earcut_node.ts +10 -10
- package/src/phaser/display/webgl/fast_sprite_batch.ts +34 -34
- package/src/phaser/display/webgl/filter_manager.ts +13 -12
- package/src/phaser/display/webgl/filter_texture.ts +14 -13
- package/src/phaser/display/webgl/graphics.ts +51 -57
- package/src/phaser/display/webgl/graphics_data.ts +15 -14
- package/src/phaser/display/webgl/mask_manager.ts +2 -2
- package/src/phaser/display/webgl/render_texture.ts +26 -25
- package/src/phaser/display/webgl/renderer.ts +57 -62
- package/src/phaser/display/webgl/shader/complex.ts +28 -12
- package/src/phaser/display/webgl/shader/fast.ts +30 -12
- package/src/phaser/display/webgl/shader/normal.ts +70 -57
- package/src/phaser/display/webgl/shader/primitive.ts +26 -11
- package/src/phaser/display/webgl/shader/shader.test.ts +148 -0
- package/src/phaser/display/webgl/shader/strip.ts +27 -12
- package/src/phaser/display/webgl/shader_manager.test.ts +124 -0
- package/src/phaser/display/webgl/shader_manager.ts +26 -34
- package/src/phaser/display/webgl/sprite_batch.ts +67 -61
- package/src/phaser/display/webgl/stencil_manager.ts +23 -34
- package/src/phaser/display/webgl/texture.ts +43 -50
- package/src/phaser/display/webgl/texture_util.ts +2 -3
- package/src/phaser/display/webgl/util.ts +26 -25
- package/src/phaser/geom/circle.test.ts +2 -3
- package/src/phaser/geom/circle.ts +36 -36
- package/src/phaser/geom/ellipse.test.ts +73 -71
- package/src/phaser/geom/ellipse.ts +14 -14
- package/src/phaser/geom/line.test.ts +5 -5
- package/src/phaser/geom/line.ts +35 -35
- package/src/phaser/geom/matrix.test.ts +1 -1
- package/src/phaser/geom/matrix.ts +27 -27
- package/src/phaser/geom/point.test.ts +1 -2
- package/src/phaser/geom/point.ts +35 -35
- package/src/phaser/geom/polygon.test.ts +82 -0
- package/src/phaser/geom/polygon.ts +16 -16
- package/src/phaser/geom/rectangle.test.ts +14 -14
- package/src/phaser/geom/rectangle.ts +83 -75
- package/src/phaser/geom/rounded_rectangle.test.ts +1 -7
- package/src/phaser/geom/rounded_rectangle.ts +9 -9
- package/src/phaser/geom/util/circle.test.ts +25 -23
- package/src/phaser/geom/util/circle.ts +9 -18
- package/src/phaser/geom/util/ellipse.test.ts +7 -5
- package/src/phaser/geom/util/ellipse.ts +3 -2
- package/src/phaser/geom/util/line.test.ts +10 -8
- package/src/phaser/geom/util/line.ts +6 -16
- package/src/phaser/geom/util/matrix.test.ts +20 -18
- package/src/phaser/geom/util/matrix.ts +8 -15
- package/src/phaser/geom/util/point.test.ts +8 -6
- package/src/phaser/geom/util/point.ts +24 -28
- package/src/phaser/geom/util/polygon.test.ts +12 -10
- package/src/phaser/geom/util/polygon.ts +2 -2
- package/src/phaser/geom/util/rectangle.test.ts +10 -8
- package/src/phaser/geom/util/rectangle.ts +18 -37
- package/src/phaser/geom/util/rounded_rectangle.test.ts +11 -9
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
- package/src/phaser/util/math.test.ts +11 -11
- package/src/phaser/util/math.ts +29 -46
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
export class AbstractFilter {
|
|
2
2
|
[key: string]: any;
|
|
3
|
-
passes!: any;
|
|
4
|
-
shaders!: any;
|
|
5
|
-
dirty!: any;
|
|
6
|
-
padding!: any;
|
|
7
|
-
uniforms!: any;
|
|
8
|
-
fragmentSrc!: any;
|
|
3
|
+
public passes!: any;
|
|
4
|
+
public shaders!: any;
|
|
5
|
+
public dirty!: any;
|
|
6
|
+
public padding!: any;
|
|
7
|
+
public uniforms!: any;
|
|
8
|
+
public fragmentSrc!: any;
|
|
9
9
|
/**
|
|
10
10
|
* Creates a new AbstractFilter instance.
|
|
11
11
|
* @param {string[]} fragmentSrc - The fragment shader source.
|
|
12
12
|
* @param {object} uniforms - The uniform variables for the shader.
|
|
13
13
|
*/
|
|
14
|
-
constructor(fragmentSrc: string[], uniforms?: any) {
|
|
14
|
+
public constructor(fragmentSrc: string[], uniforms?: any) {
|
|
15
15
|
this.passes = [this];
|
|
16
16
|
this.shaders = [];
|
|
17
17
|
this.dirty = true;
|
|
18
18
|
this.padding = 0;
|
|
19
|
-
this.uniforms = uniforms
|
|
19
|
+
this.uniforms = uniforms ?? {};
|
|
20
20
|
this.fragmentSrc = fragmentSrc || [];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Initializes the filter.
|
|
25
25
|
*/
|
|
26
|
-
syncUniforms() {
|
|
26
|
+
public syncUniforms() {
|
|
27
27
|
for (let i = 0, j = this.shaders.length; i < j; i += 1) {
|
|
28
28
|
this.shaders[i].dirty = true;
|
|
29
29
|
}
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
import { removeByCanvas } from '../canvas/pool.js';
|
|
2
2
|
|
|
3
3
|
export class BaseTexture {
|
|
4
|
-
resolution
|
|
5
|
-
width
|
|
6
|
-
height
|
|
7
|
-
scaleMode!: any;
|
|
8
|
-
hasLoaded!: any;
|
|
9
|
-
source!: any;
|
|
10
|
-
premultipliedAlpha!: any;
|
|
11
|
-
_glTextures!: any;
|
|
12
|
-
mipmap!: any;
|
|
13
|
-
skipRender!: any;
|
|
14
|
-
_powerOf2!: any;
|
|
15
|
-
_dirty!: any;
|
|
4
|
+
public resolution: any = 1;
|
|
5
|
+
public width: any = 100;
|
|
6
|
+
public height: any = 100;
|
|
7
|
+
public scaleMode!: any;
|
|
8
|
+
public hasLoaded!: any;
|
|
9
|
+
public source!: any;
|
|
10
|
+
public premultipliedAlpha!: any;
|
|
11
|
+
public _glTextures!: any;
|
|
12
|
+
public mipmap!: any;
|
|
13
|
+
public skipRender!: any;
|
|
14
|
+
public _powerOf2!: any;
|
|
15
|
+
public _dirty!: any;
|
|
16
16
|
/**
|
|
17
17
|
* Updates the base texture with a new source.
|
|
18
18
|
* @param {HTMLCanvasElement} source - The new canvas element to use as the texture source.
|
|
19
19
|
* @param {number} [scaleMode] - The scale mode to use for the texture.
|
|
20
20
|
*/
|
|
21
|
-
constructor(source: any, scaleMode?: any) {
|
|
22
|
-
this.
|
|
23
|
-
this.width = 100;
|
|
24
|
-
this.height = 100;
|
|
25
|
-
this.scaleMode = scaleMode || window.PhaserRegistry.TEXTURE_SCALE_MODE;
|
|
21
|
+
public constructor(source: any, scaleMode?: any) {
|
|
22
|
+
this.scaleMode = scaleMode ?? globalThis.PhaserRegistry.TEXTURE_SCALE_MODE;
|
|
26
23
|
this.hasLoaded = false;
|
|
27
24
|
this.source = source;
|
|
28
25
|
this.premultipliedAlpha = true;
|
|
@@ -34,8 +31,8 @@ export class BaseTexture {
|
|
|
34
31
|
if (source) {
|
|
35
32
|
if ((this.source.complete || this.source.getContext) && this.source.width && this.source.height) {
|
|
36
33
|
this.hasLoaded = true;
|
|
37
|
-
this.width = this.source.naturalWidth
|
|
38
|
-
this.height = this.source.naturalHeight
|
|
34
|
+
this.width = this.source.naturalWidth ?? this.source.width;
|
|
35
|
+
this.height = this.source.naturalHeight ?? this.source.height;
|
|
39
36
|
this.dirty();
|
|
40
37
|
}
|
|
41
38
|
}
|
|
@@ -46,7 +43,7 @@ export class BaseTexture {
|
|
|
46
43
|
* @param {number} width - The new width of the texture.
|
|
47
44
|
* @param {number} height - The new height of the texture.
|
|
48
45
|
*/
|
|
49
|
-
forceLoaded(width: number, height: number) {
|
|
46
|
+
public forceLoaded(width: number, height: number) {
|
|
50
47
|
this.hasLoaded = true;
|
|
51
48
|
this.width = width;
|
|
52
49
|
this.height = height;
|
|
@@ -56,7 +53,7 @@ export class BaseTexture {
|
|
|
56
53
|
/**
|
|
57
54
|
* Destroys the texture.
|
|
58
55
|
*/
|
|
59
|
-
destroy() {
|
|
56
|
+
public destroy() {
|
|
60
57
|
if (this.source) {
|
|
61
58
|
removeByCanvas(this.source);
|
|
62
59
|
}
|
|
@@ -67,7 +64,7 @@ export class BaseTexture {
|
|
|
67
64
|
/**
|
|
68
65
|
* Marks the texture as dirty.
|
|
69
66
|
*/
|
|
70
|
-
dirty() {
|
|
67
|
+
public dirty() {
|
|
71
68
|
for (let i = 0; i < this._glTextures.length; i += 1) {
|
|
72
69
|
this._dirty[i] = true;
|
|
73
70
|
}
|
|
@@ -76,11 +73,11 @@ export class BaseTexture {
|
|
|
76
73
|
/**
|
|
77
74
|
* Unloads the texture from the GPU.
|
|
78
75
|
*/
|
|
79
|
-
unloadFromGPU() {
|
|
76
|
+
public unloadFromGPU() {
|
|
80
77
|
this.dirty();
|
|
81
78
|
for (let i = this._glTextures.length - 1; i >= 0; i -= 1) {
|
|
82
79
|
const glTexture = this._glTextures[i];
|
|
83
|
-
const gl =
|
|
80
|
+
const gl = globalThis.PhaserRegistry.GL_CONTEXTS[i];
|
|
84
81
|
if (gl && glTexture) {
|
|
85
82
|
gl.deleteTexture(glTexture);
|
|
86
83
|
}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
export class WebGLBlendModeManager {
|
|
2
2
|
[key: string]: any;
|
|
3
|
-
gl
|
|
4
|
-
currentBlendMode
|
|
3
|
+
public gl: any = null;
|
|
4
|
+
public currentBlendMode: any = 99_999;
|
|
5
5
|
/**
|
|
6
6
|
* Creates a new BlendModeManager instance.
|
|
7
7
|
*/
|
|
8
|
-
constructor() {
|
|
9
|
-
this.gl = null;
|
|
10
|
-
this.currentBlendMode = 99999;
|
|
11
|
-
}
|
|
12
8
|
|
|
13
9
|
/**
|
|
14
10
|
* Initializes the blend mode manager with a WebGL context.
|
|
15
11
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
16
12
|
*/
|
|
17
|
-
setContext(gl: WebGLRenderingContext) {
|
|
13
|
+
public setContext(gl: WebGLRenderingContext) {
|
|
18
14
|
this.gl = gl;
|
|
19
15
|
}
|
|
20
16
|
|
|
@@ -23,12 +19,12 @@ export class WebGLBlendModeManager {
|
|
|
23
19
|
* @param {number} blendMode - The blend mode to set.
|
|
24
20
|
* @returns {boolean} True if the blend mode was set successfully, false otherwise.
|
|
25
21
|
*/
|
|
26
|
-
setBlendMode(blendMode: number) {
|
|
22
|
+
public setBlendMode(blendMode: number) {
|
|
27
23
|
if (this.currentBlendMode === blendMode) {
|
|
28
24
|
return false;
|
|
29
25
|
}
|
|
30
26
|
this.currentBlendMode = blendMode;
|
|
31
|
-
const blendModeWebGL =
|
|
27
|
+
const blendModeWebGL = globalThis.PhaserRegistry.blendModesWebGL[this.currentBlendMode];
|
|
32
28
|
if (blendModeWebGL) {
|
|
33
29
|
this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
|
34
30
|
}
|
|
@@ -38,7 +34,7 @@ export class WebGLBlendModeManager {
|
|
|
38
34
|
/**
|
|
39
35
|
* Sets the blend mode for the WebGL context.
|
|
40
36
|
*/
|
|
41
|
-
destroy() {
|
|
37
|
+
public destroy() {
|
|
42
38
|
this.gl = null;
|
|
43
39
|
}
|
|
44
40
|
}
|
|
@@ -87,8 +87,8 @@ export function compareX(a: any, b: any) {
|
|
|
87
87
|
*/
|
|
88
88
|
export function zOrder(x: number, y: number, minX: number, minY: number, size: number) {
|
|
89
89
|
// coords are transformed into non-negative 15-bit integer range
|
|
90
|
-
x = (
|
|
91
|
-
y = (
|
|
90
|
+
x = (32_767 * (x - minX)) / size;
|
|
91
|
+
y = (32_767 * (y - minY)) / size;
|
|
92
92
|
x = (x | (x << 8)) & 0x00ff00ff;
|
|
93
93
|
x = (x | (x << 4)) & 0x0f0f0f0f;
|
|
94
94
|
x = (x | (x << 2)) & 0x33333333;
|
|
@@ -107,10 +107,12 @@ export function zOrder(x: number, y: number, minX: number, minY: number, size: n
|
|
|
107
107
|
* @param {number} minY - The minimum y-coordinate of the bounding box.
|
|
108
108
|
* @param {number} size - The size of the bounding box.
|
|
109
109
|
*/
|
|
110
|
-
export function indexCurve(start: any, minX
|
|
110
|
+
export function indexCurve(start: any, minX = 0, minY = 0, size = 0) {
|
|
111
111
|
let p = start;
|
|
112
112
|
do {
|
|
113
|
-
if (p.z === null)
|
|
113
|
+
if (p.z === null) {
|
|
114
|
+
p.z = zOrder(p.x, p.y, minX, minY, size);
|
|
115
|
+
}
|
|
114
116
|
p.prevZ = p.prev;
|
|
115
117
|
p.nextZ = p.next;
|
|
116
118
|
p = p.next;
|
|
@@ -129,7 +131,9 @@ export function getLeftmost(start: any) {
|
|
|
129
131
|
let p = start;
|
|
130
132
|
let leftmost = start;
|
|
131
133
|
do {
|
|
132
|
-
if (p.x < leftmost.x)
|
|
134
|
+
if (p.x < leftmost.x) {
|
|
135
|
+
leftmost = p;
|
|
136
|
+
}
|
|
133
137
|
p = p.next;
|
|
134
138
|
} while (p !== start);
|
|
135
139
|
return leftmost;
|
|
@@ -206,7 +210,9 @@ export function intersects(p1: any, q1: any, p2: any, q2: any) {
|
|
|
206
210
|
export function intersectsPolygon(a: any, b: any) {
|
|
207
211
|
let p = a;
|
|
208
212
|
do {
|
|
209
|
-
if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b))
|
|
213
|
+
if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b)) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
210
216
|
p = p.next;
|
|
211
217
|
} while (p !== a);
|
|
212
218
|
return false;
|
|
@@ -330,11 +336,15 @@ export function isEar(ear: any) {
|
|
|
330
336
|
const a = ear.prev;
|
|
331
337
|
const b = ear;
|
|
332
338
|
const c = ear.next;
|
|
333
|
-
if (area(a, b, c) >= 0)
|
|
339
|
+
if (area(a, b, c) >= 0) {
|
|
340
|
+
return false;
|
|
341
|
+
} // reflex, can't be an ear
|
|
334
342
|
// now make sure we don't have other points inside the potential ear
|
|
335
343
|
let p = ear.next.next;
|
|
336
344
|
while (p !== ear.prev) {
|
|
337
|
-
if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
|
|
345
|
+
if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
338
348
|
p = p.next;
|
|
339
349
|
}
|
|
340
350
|
return true;
|
|
@@ -348,11 +358,13 @@ export function isEar(ear: any) {
|
|
|
348
358
|
* @param {number} size - TBD.
|
|
349
359
|
* @returns {boolean} TBD.
|
|
350
360
|
*/
|
|
351
|
-
export function isEarHashed(ear: any, minX
|
|
361
|
+
export function isEarHashed(ear: any, minX = 0, minY = 0, size = 0) {
|
|
352
362
|
const a = ear.prev;
|
|
353
363
|
const b = ear;
|
|
354
364
|
const c = ear.next;
|
|
355
|
-
if (area(a, b, c) >= 0)
|
|
365
|
+
if (area(a, b, c) >= 0) {
|
|
366
|
+
return false;
|
|
367
|
+
} // reflex, can't be an ear
|
|
356
368
|
// triangle bbox; min & max are calculated like this for speed
|
|
357
369
|
const minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : b.x < c.x ? b.x : c.x;
|
|
358
370
|
const minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : b.y < c.y ? b.y : c.y;
|
|
@@ -411,9 +423,13 @@ export function linkedList(data: any, start: number, end: number, dim: number, c
|
|
|
411
423
|
}
|
|
412
424
|
// link points into circular doubly-linked list in the specified winding order
|
|
413
425
|
if (clockwise === sum > 0) {
|
|
414
|
-
for (i = start; i < end; i += dim)
|
|
426
|
+
for (i = start; i < end; i += dim) {
|
|
427
|
+
last = insertNode(i, data[i], data[i + 1], last);
|
|
428
|
+
}
|
|
415
429
|
} else {
|
|
416
|
-
for (i = end - dim; i >= start; i -= dim)
|
|
430
|
+
for (i = end - dim; i >= start; i -= dim) {
|
|
431
|
+
last = insertNode(i, data[i], data[i + 1], last);
|
|
432
|
+
}
|
|
417
433
|
}
|
|
418
434
|
return last;
|
|
419
435
|
}
|
|
@@ -425,8 +441,10 @@ export function linkedList(data: any, start: number, end: number, dim: number, c
|
|
|
425
441
|
* @returns {object} The calculated bounding box with min and max coordinates.
|
|
426
442
|
*/
|
|
427
443
|
export function filterPoints(start: any, end?: any) {
|
|
428
|
-
if (!start)
|
|
429
|
-
|
|
444
|
+
if (!start) {
|
|
445
|
+
return start;
|
|
446
|
+
}
|
|
447
|
+
end ??= start;
|
|
430
448
|
let p = start;
|
|
431
449
|
let again;
|
|
432
450
|
do {
|
|
@@ -435,7 +453,9 @@ export function filterPoints(start: any, end?: any) {
|
|
|
435
453
|
removeNode(p);
|
|
436
454
|
p = p.prev;
|
|
437
455
|
end = p;
|
|
438
|
-
if (p === p.next)
|
|
456
|
+
if (p === p.next) {
|
|
457
|
+
return null;
|
|
458
|
+
}
|
|
439
459
|
again = true;
|
|
440
460
|
} else {
|
|
441
461
|
p = p.next;
|
|
@@ -468,8 +488,12 @@ export function findHoleBridge(hole: any, outerNode: any) {
|
|
|
468
488
|
}
|
|
469
489
|
p = p.next;
|
|
470
490
|
} while (p !== outerNode);
|
|
471
|
-
if (!m)
|
|
472
|
-
|
|
491
|
+
if (!m) {
|
|
492
|
+
return null;
|
|
493
|
+
}
|
|
494
|
+
if (hole.x === m.x) {
|
|
495
|
+
return m.prev;
|
|
496
|
+
} // hole touches outer segment; pick lower endpoint
|
|
473
497
|
// look for points inside the triangle of hole point, segment intersection and endpoint;
|
|
474
498
|
// if there are no points found, we have a valid connection;
|
|
475
499
|
// otherwise choose the point of the minimum angle with the ray as connection point
|
|
@@ -526,8 +550,12 @@ export function eliminateHoles(data: any, holeIndices: any, outerNode: any, dim:
|
|
|
526
550
|
start = holeIndices[i] * dim;
|
|
527
551
|
end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
528
552
|
list = linkedList(data, start, end, dim, false);
|
|
529
|
-
if (!list)
|
|
530
|
-
|
|
553
|
+
if (!list) {
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
if (list === list.next) {
|
|
557
|
+
list.steiner = true;
|
|
558
|
+
}
|
|
531
559
|
queue.push(getLeftmost(list));
|
|
532
560
|
}
|
|
533
561
|
queue.sort(compareX);
|
|
@@ -576,14 +604,7 @@ export function cureLocalIntersections(start: any, triangles: any, dim: number)
|
|
|
576
604
|
* @param {number} minY - The minimum y-coordinate of the bounding box.
|
|
577
605
|
* @param {number} size - The size of the bounding box.
|
|
578
606
|
*/
|
|
579
|
-
export function splitEarcut(
|
|
580
|
-
start: any,
|
|
581
|
-
triangles: any,
|
|
582
|
-
dim: number,
|
|
583
|
-
minX: number = 0,
|
|
584
|
-
minY: number = 0,
|
|
585
|
-
size: number = 0
|
|
586
|
-
) {
|
|
607
|
+
export function splitEarcut(start: any, triangles: any, dim: number, minX = 0, minY = 0, size = 0) {
|
|
587
608
|
// look for a valid diagonal that divides the polygon into two
|
|
588
609
|
let a = start;
|
|
589
610
|
do {
|
|
@@ -625,9 +646,13 @@ export function earcutLinked(
|
|
|
625
646
|
size?: number,
|
|
626
647
|
pass?: any
|
|
627
648
|
) {
|
|
628
|
-
if (!ear)
|
|
649
|
+
if (!ear) {
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
629
652
|
// interlink polygon nodes in z-order
|
|
630
|
-
if (!pass && size)
|
|
653
|
+
if (!pass && size) {
|
|
654
|
+
indexCurve(ear, minX, minY, size);
|
|
655
|
+
}
|
|
631
656
|
let stop = ear;
|
|
632
657
|
let prev;
|
|
633
658
|
let next;
|
|
@@ -672,13 +697,14 @@ export function earcutLinked(
|
|
|
672
697
|
* @param {number} dim - The dimension of the data (2 or 3).
|
|
673
698
|
* @returns {object} The processed earcut data structure with triangulation information.
|
|
674
699
|
*/
|
|
675
|
-
export function triangulate(data: any, holeIndices: any, dim
|
|
676
|
-
dim = dim || 2;
|
|
700
|
+
export function triangulate(data: any, holeIndices: any, dim = 2) {
|
|
677
701
|
const hasHoles = holeIndices && holeIndices.length;
|
|
678
702
|
const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
|
|
679
703
|
let outerNode = linkedList(data, 0, outerLen, dim, true);
|
|
680
704
|
const triangles: number[] = [];
|
|
681
|
-
if (!outerNode)
|
|
705
|
+
if (!outerNode) {
|
|
706
|
+
return triangles;
|
|
707
|
+
}
|
|
682
708
|
let minX;
|
|
683
709
|
let minY;
|
|
684
710
|
let maxX;
|
|
@@ -686,7 +712,9 @@ export function triangulate(data: any, holeIndices: any, dim: number) {
|
|
|
686
712
|
let x;
|
|
687
713
|
let y;
|
|
688
714
|
let size;
|
|
689
|
-
if (hasHoles)
|
|
715
|
+
if (hasHoles) {
|
|
716
|
+
outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
|
|
717
|
+
}
|
|
690
718
|
// if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
|
|
691
719
|
if (data.length > 80 * dim) {
|
|
692
720
|
minX = data[0];
|
|
@@ -696,10 +724,18 @@ export function triangulate(data: any, holeIndices: any, dim: number) {
|
|
|
696
724
|
for (let i = dim; i < outerLen; i += dim) {
|
|
697
725
|
x = data[i];
|
|
698
726
|
y = data[i + 1];
|
|
699
|
-
if (x < minX)
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
if (y
|
|
727
|
+
if (x < minX) {
|
|
728
|
+
minX = x;
|
|
729
|
+
}
|
|
730
|
+
if (y < minY) {
|
|
731
|
+
minY = y;
|
|
732
|
+
}
|
|
733
|
+
if (x > maxX) {
|
|
734
|
+
maxX = x;
|
|
735
|
+
}
|
|
736
|
+
if (y > maxY) {
|
|
737
|
+
maxY = y;
|
|
738
|
+
}
|
|
703
739
|
}
|
|
704
740
|
// minX, minY and size are later used to transform coords into integers for z-order calculation
|
|
705
741
|
size = Math.max(maxX - minX, maxY - minY);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export class Node {
|
|
2
|
-
i: number;
|
|
3
|
-
x: number;
|
|
4
|
-
y: number;
|
|
5
|
-
prev: Node | null;
|
|
6
|
-
next: Node | null;
|
|
7
|
-
z: number | null;
|
|
8
|
-
prevZ: Node | null;
|
|
9
|
-
nextZ: Node | null;
|
|
10
|
-
steiner: boolean;
|
|
2
|
+
public i: number;
|
|
3
|
+
public x: number;
|
|
4
|
+
public y: number;
|
|
5
|
+
public prev: Node | null;
|
|
6
|
+
public next: Node | null;
|
|
7
|
+
public z: number | null;
|
|
8
|
+
public prevZ: Node | null;
|
|
9
|
+
public nextZ: Node | null;
|
|
10
|
+
public steiner: boolean;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Creates a new Node instance.
|
|
@@ -15,7 +15,7 @@ export class Node {
|
|
|
15
15
|
* @param {number} x - The x coordinate of the vertex.
|
|
16
16
|
* @param {number} y - The y coordinate of the vertex.
|
|
17
17
|
*/
|
|
18
|
-
constructor(i: number, x: number, y: number) {
|
|
18
|
+
public constructor(i: number, x: number, y: number) {
|
|
19
19
|
// vertice index in coordinates array
|
|
20
20
|
this.i = i;
|
|
21
21
|
// vertex coordinates
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import type { IdentifiedWebGLRenderingContext } from './util.js';
|
|
2
|
+
import type { Image } from '../../display/image.js';
|
|
2
3
|
|
|
3
4
|
export class FastSpriteBatch {
|
|
4
|
-
|
|
5
|
-
vertSize
|
|
6
|
-
maxSize
|
|
7
|
-
size!: any;
|
|
8
|
-
vertices!: any;
|
|
9
|
-
indices!: any;
|
|
10
|
-
vertexBuffer!: any;
|
|
11
|
-
indexBuffer!: any;
|
|
12
|
-
lastIndexCount!: any;
|
|
13
|
-
drawing!: any;
|
|
14
|
-
currentBatchSize!: any;
|
|
15
|
-
currentBaseTexture!: any;
|
|
16
|
-
currentBlendMode!: any;
|
|
17
|
-
renderSession!: any;
|
|
18
|
-
shader!: any;
|
|
19
|
-
matrix!: any;
|
|
5
|
+
public gl!: any;
|
|
6
|
+
public vertSize: any = 10;
|
|
7
|
+
public maxSize: any = 6e3;
|
|
8
|
+
public size!: any;
|
|
9
|
+
public vertices!: any;
|
|
10
|
+
public indices!: any;
|
|
11
|
+
public vertexBuffer!: any;
|
|
12
|
+
public indexBuffer!: any;
|
|
13
|
+
public lastIndexCount!: any;
|
|
14
|
+
public drawing!: any;
|
|
15
|
+
public currentBatchSize!: any;
|
|
16
|
+
public currentBaseTexture!: any;
|
|
17
|
+
public currentBlendMode!: any;
|
|
18
|
+
public renderSession!: any;
|
|
19
|
+
public shader!: any;
|
|
20
|
+
public matrix!: any;
|
|
20
21
|
/**
|
|
21
22
|
* Creates a new FastSpriteBatch instance.
|
|
22
23
|
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
23
24
|
*/
|
|
24
|
-
constructor(gl: IdentifiedWebGLRenderingContext) {
|
|
25
|
-
this.vertSize
|
|
26
|
-
this.maxSize = 6000; // Math.pow(2, 16) / this.vertSize;
|
|
25
|
+
public constructor(gl: IdentifiedWebGLRenderingContext) {
|
|
26
|
+
// Math.pow(2, 16) / this.vertSize;
|
|
27
27
|
this.size = this.maxSize;
|
|
28
28
|
// the total number of floats in our batch
|
|
29
29
|
const numVerts = this.size * 4 * this.vertSize;
|
|
@@ -56,7 +56,7 @@ export class FastSpriteBatch {
|
|
|
56
56
|
* Sets the WebGL context for this batch.
|
|
57
57
|
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
58
58
|
*/
|
|
59
|
-
setContext(gl: IdentifiedWebGLRenderingContext) {
|
|
59
|
+
public setContext(gl: IdentifiedWebGLRenderingContext) {
|
|
60
60
|
this.gl = gl;
|
|
61
61
|
// create a couple of buffers
|
|
62
62
|
this.vertexBuffer = gl.createBuffer();
|
|
@@ -74,7 +74,7 @@ export class FastSpriteBatch {
|
|
|
74
74
|
* @param {object} spriteBatch - The sprite batch to render.
|
|
75
75
|
* @param {object} renderSession - The render session to use.
|
|
76
76
|
*/
|
|
77
|
-
begin(spriteBatch: any, renderSession: any) {
|
|
77
|
+
public begin(spriteBatch: any, renderSession: any) {
|
|
78
78
|
this.renderSession = renderSession;
|
|
79
79
|
this.shader = this.renderSession.shaderManager.fastShader;
|
|
80
80
|
this.matrix = spriteBatch.worldTransform.toArray(true);
|
|
@@ -84,7 +84,7 @@ export class FastSpriteBatch {
|
|
|
84
84
|
/**
|
|
85
85
|
* Updates the sprite batch.
|
|
86
86
|
*/
|
|
87
|
-
end() {
|
|
87
|
+
public end() {
|
|
88
88
|
this.flush();
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -92,8 +92,8 @@ export class FastSpriteBatch {
|
|
|
92
92
|
* Flushes the sprite batch to WebGL.
|
|
93
93
|
* @param {object} spriteBatch - The sprite batch to flush.
|
|
94
94
|
*/
|
|
95
|
-
render(spriteBatch: any) {
|
|
96
|
-
const children = spriteBatch
|
|
95
|
+
public render(spriteBatch: any) {
|
|
96
|
+
const { children } = spriteBatch;
|
|
97
97
|
const sprite = children[0];
|
|
98
98
|
// if the uvs have not updated then no point rendering just yet!
|
|
99
99
|
// check texture.
|
|
@@ -114,9 +114,9 @@ export class FastSpriteBatch {
|
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* Renders a sprite using WebGL.
|
|
117
|
-
* @param {
|
|
117
|
+
* @param {Image} sprite - The sprite to render.
|
|
118
118
|
*/
|
|
119
|
-
renderSprite(sprite:
|
|
119
|
+
public renderSprite(sprite: Image) {
|
|
120
120
|
if (!sprite.visible) {
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
@@ -129,7 +129,7 @@ export class FastSpriteBatch {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
const uvs = sprite.texture._uvs;
|
|
132
|
-
const vertices = this
|
|
132
|
+
const { vertices } = this;
|
|
133
133
|
// const width = sprite.texture.frame.width;
|
|
134
134
|
// const height = sprite.texture.frame.height;
|
|
135
135
|
let w0;
|
|
@@ -139,7 +139,7 @@ export class FastSpriteBatch {
|
|
|
139
139
|
let index;
|
|
140
140
|
if (sprite.texture.trim) {
|
|
141
141
|
// if the sprite is trimmed then we need to add the extra space before transforming the sprite coords..
|
|
142
|
-
const trim = sprite.texture
|
|
142
|
+
const { trim } = sprite.texture;
|
|
143
143
|
w1 = trim.x - sprite.anchor.x * trim.width;
|
|
144
144
|
w0 = w1 + sprite.texture.crop.width;
|
|
145
145
|
h1 = trim.y - sprite.anchor.y * trim.height;
|
|
@@ -222,12 +222,12 @@ export class FastSpriteBatch {
|
|
|
222
222
|
/**
|
|
223
223
|
* Binds the sprite batch to the WebGL context.
|
|
224
224
|
*/
|
|
225
|
-
flush() {
|
|
225
|
+
public flush() {
|
|
226
226
|
// If the batch is length 0 then return as there is nothing to draw
|
|
227
227
|
if (this.currentBatchSize === 0) {
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
|
-
const gl = this
|
|
230
|
+
const { gl } = this;
|
|
231
231
|
// bind the current texture
|
|
232
232
|
if (!this.currentBaseTexture._glTextures[gl.id]) {
|
|
233
233
|
this.renderSession.renderer.updateTexture(this.currentBaseTexture, gl);
|
|
@@ -251,22 +251,22 @@ export class FastSpriteBatch {
|
|
|
251
251
|
/**
|
|
252
252
|
* Renders a sprite using the sprite batch.
|
|
253
253
|
*/
|
|
254
|
-
stop() {
|
|
254
|
+
public stop() {
|
|
255
255
|
this.flush();
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
/**
|
|
259
259
|
* Sets up the sprite batch for WebGL rendering.
|
|
260
260
|
*/
|
|
261
|
-
start() {
|
|
262
|
-
const gl = this
|
|
261
|
+
public start() {
|
|
262
|
+
const { gl } = this;
|
|
263
263
|
// bind the main texture
|
|
264
264
|
gl.activeTexture(gl.TEXTURE0);
|
|
265
265
|
// bind the buffers
|
|
266
266
|
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
|
|
267
267
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
|
268
268
|
// set the projection
|
|
269
|
-
const projection = this.renderSession
|
|
269
|
+
const { projection } = this.renderSession;
|
|
270
270
|
gl.uniform2f(this.shader.projectionVector, projection.x, projection.y);
|
|
271
271
|
// set the matrix
|
|
272
272
|
gl.uniformMatrix3fv(this.shader.uMatrix, false, this.matrix);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export class WebGLFilterManager {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
public gl!: WebGLRenderingContext;
|
|
3
|
+
public texturePool!: any[];
|
|
4
|
+
public filterStack!: any;
|
|
5
|
+
public offsetX!: any;
|
|
6
|
+
public offsetY!: any;
|
|
6
7
|
/**
|
|
7
8
|
* Creates a new FilterManager instance.
|
|
8
9
|
*/
|
|
9
|
-
constructor() {
|
|
10
|
+
public constructor() {
|
|
10
11
|
this.filterStack = [];
|
|
11
12
|
this.offsetX = 0;
|
|
12
13
|
this.offsetY = 0;
|
|
@@ -16,7 +17,7 @@ export class WebGLFilterManager {
|
|
|
16
17
|
* Initializes the filter manager with a WebGL context.
|
|
17
18
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
18
19
|
*/
|
|
19
|
-
setContext(gl: WebGLRenderingContext) {
|
|
20
|
+
public setContext(gl: WebGLRenderingContext) {
|
|
20
21
|
this.gl = gl;
|
|
21
22
|
this.texturePool = [];
|
|
22
23
|
this.initShaderBuffers();
|
|
@@ -25,42 +26,42 @@ export class WebGLFilterManager {
|
|
|
25
26
|
/**
|
|
26
27
|
* Applies a filter to the specified texture.
|
|
27
28
|
*/
|
|
28
|
-
begin() {
|
|
29
|
+
public begin() {
|
|
29
30
|
// TODO
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* Updates the filter texture for the specified size.
|
|
34
35
|
*/
|
|
35
|
-
pushFilter() {
|
|
36
|
+
public pushFilter() {
|
|
36
37
|
// TODO
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* Resizes the filter manager to the specified dimensions.
|
|
41
42
|
*/
|
|
42
|
-
popFilter() {
|
|
43
|
+
public popFilter() {
|
|
43
44
|
// TODO
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
48
|
* Destroys this filter manager and cleans up resources.
|
|
48
49
|
*/
|
|
49
|
-
applyFilterPass() {
|
|
50
|
+
public applyFilterPass() {
|
|
50
51
|
// TODO
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
55
|
* Initializes the filter manager.
|
|
55
56
|
*/
|
|
56
|
-
initShaderBuffers() {
|
|
57
|
+
public initShaderBuffers() {
|
|
57
58
|
// TODO
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* Sets up the filter manager for WebGL rendering.
|
|
62
63
|
*/
|
|
63
|
-
destroy() {
|
|
64
|
+
public destroy() {
|
|
64
65
|
// TODO
|
|
65
66
|
}
|
|
66
67
|
}
|