@vpmedia/phaser 1.15.0 → 1.16.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 +3 -3
- package/package.json +6 -5
- package/src/index.js +15 -18
- package/src/phaser/core/animation.js +102 -6
- package/src/phaser/core/animation_manager.js +88 -10
- package/src/phaser/core/animation_parser.js +5 -18
- package/src/phaser/core/array_set.js +51 -5
- package/src/phaser/core/cache.js +291 -6
- package/src/phaser/core/const.js +107 -4
- package/src/phaser/core/device.js +3 -6
- package/src/phaser/core/device_util.js +3 -16
- package/src/phaser/core/dom.js +127 -29
- package/src/phaser/core/event_manager.js +128 -6
- package/src/phaser/core/factory.js +69 -34
- package/src/phaser/core/frame.js +43 -6
- package/src/phaser/core/frame_data.js +55 -5
- package/src/phaser/core/frame_util.js +7 -12
- package/src/phaser/core/game.js +35 -7
- package/src/phaser/core/input.js +116 -17
- package/src/phaser/core/input_handler.js +242 -42
- package/src/phaser/core/input_mouse.js +66 -5
- package/src/phaser/core/input_mspointer.js +40 -9
- package/src/phaser/core/input_pointer.js +79 -17
- package/src/phaser/core/input_touch.js +42 -5
- package/src/phaser/core/loader.js +274 -101
- package/src/phaser/core/loader_parser.js +2 -10
- package/src/phaser/core/raf.js +16 -5
- package/src/phaser/core/scale_manager.js +204 -39
- package/src/phaser/core/scene.js +24 -5
- package/src/phaser/core/scene_manager.js +81 -11
- package/src/phaser/core/signal.js +88 -11
- package/src/phaser/core/signal_binding.js +35 -15
- package/src/phaser/core/sound.js +99 -10
- package/src/phaser/core/sound_manager.js +89 -13
- package/src/phaser/core/sound_sprite.js +20 -5
- package/src/phaser/core/stage.js +43 -7
- package/src/phaser/core/time.js +67 -5
- package/src/phaser/core/timer.js +107 -30
- package/src/phaser/core/timer_event.js +11 -6
- package/src/phaser/core/tween.js +124 -30
- package/src/phaser/core/tween_data.js +42 -18
- package/src/phaser/core/tween_easing.js +1 -8
- package/src/phaser/core/tween_manager.js +47 -5
- package/src/phaser/core/world.js +9 -6
- package/src/phaser/display/bitmap_text.js +91 -10
- package/src/phaser/display/button.js +63 -12
- package/src/phaser/display/canvas/buffer.js +16 -6
- package/src/phaser/display/canvas/graphics.js +1 -13
- package/src/phaser/display/canvas/masker.js +0 -6
- package/src/phaser/display/canvas/pool.js +0 -7
- package/src/phaser/display/canvas/renderer.js +28 -8
- package/src/phaser/display/canvas/tinter.js +4 -43
- package/src/phaser/display/canvas/util.js +0 -6
- package/src/phaser/display/display_object.js +192 -20
- package/src/phaser/display/graphics.js +161 -26
- package/src/phaser/display/graphics_data.js +14 -6
- package/src/phaser/display/graphics_data_util.js +2 -8
- package/src/phaser/display/group.js +74 -9
- package/src/phaser/display/image.js +85 -9
- package/src/phaser/display/sprite_batch.js +3 -8
- package/src/phaser/display/sprite_util.js +3 -23
- package/src/phaser/display/text.js +331 -31
- package/src/phaser/display/webgl/abstract_filter.js +8 -7
- package/src/phaser/display/webgl/base_texture.js +20 -12
- package/src/phaser/display/webgl/blend_manager.js +14 -7
- package/src/phaser/display/webgl/earcut.js +4 -23
- package/src/phaser/display/webgl/earcut_node.js +6 -7
- package/src/phaser/display/webgl/fast_sprite_batch.js +34 -11
- package/src/phaser/display/webgl/filter_manager.js +25 -7
- package/src/phaser/display/webgl/filter_texture.js +21 -22
- package/src/phaser/display/webgl/graphics.js +5 -28
- package/src/phaser/display/webgl/graphics_data.js +10 -7
- package/src/phaser/display/webgl/mask_manager.js +0 -6
- package/src/phaser/display/webgl/render_texture.js +33 -21
- package/src/phaser/display/webgl/renderer.js +38 -11
- package/src/phaser/display/webgl/shader/complex.js +10 -6
- package/src/phaser/display/webgl/shader/fast.js +10 -6
- package/src/phaser/display/webgl/shader/normal.js +23 -32
- package/src/phaser/display/webgl/shader/primitive.js +10 -6
- package/src/phaser/display/webgl/shader/strip.js +10 -6
- package/src/phaser/display/webgl/shader_manager.js +18 -6
- package/src/phaser/display/webgl/sprite_batch.js +41 -8
- package/src/phaser/display/webgl/stencil_manager.js +28 -6
- package/src/phaser/display/webgl/texture.js +28 -15
- package/src/phaser/display/webgl/texture_util.js +0 -6
- package/src/phaser/display/webgl/util.js +0 -7
- package/src/phaser/geom/circle.js +123 -18
- package/src/phaser/geom/ellipse.js +39 -18
- package/src/phaser/geom/line.js +148 -16
- package/src/phaser/geom/matrix.js +73 -6
- package/src/phaser/geom/point.js +152 -6
- package/src/phaser/geom/polygon.js +42 -14
- package/src/phaser/geom/rectangle.js +233 -6
- package/src/phaser/geom/rounded_rectangle.js +10 -6
- package/src/phaser/geom/util/circle.js +3 -9
- package/src/phaser/geom/util/ellipse.js +0 -7
- package/src/phaser/geom/util/line.js +5 -14
- package/src/phaser/geom/util/matrix.js +1 -7
- package/src/phaser/geom/util/point.js +0 -6
- package/src/phaser/geom/util/polygon.js +1 -7
- package/src/phaser/geom/util/rectangle.js +1 -7
- package/src/phaser/geom/util/rounded_rectangle.js +1 -7
- package/src/phaser/util/math.js +3 -21
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/phaser/core/animation.d.ts +105 -4
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +87 -0
- package/types/phaser/core/animation_manager.d.ts.map +1 -1
- package/types/phaser/core/animation_parser.d.ts +5 -4
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/array_set.d.ts +53 -7
- package/types/phaser/core/array_set.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +346 -56
- package/types/phaser/core/cache.d.ts.map +1 -1
- package/types/phaser/core/const.d.ts +143 -40
- package/types/phaser/core/const.d.ts.map +1 -1
- package/types/phaser/core/device.d.ts +0 -5
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/device_util.d.ts +1 -1
- package/types/phaser/core/device_util.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +119 -0
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +127 -0
- package/types/phaser/core/event_manager.d.ts.map +1 -1
- package/types/phaser/core/factory.d.ts +74 -7
- package/types/phaser/core/factory.d.ts.map +1 -1
- package/types/phaser/core/frame.d.ts +64 -21
- package/types/phaser/core/frame.d.ts.map +1 -1
- package/types/phaser/core/frame_data.d.ts +61 -9
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/frame_util.d.ts +10 -8
- package/types/phaser/core/frame_util.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +40 -6
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input.d.ts +114 -3
- package/types/phaser/core/input.d.ts.map +1 -1
- package/types/phaser/core/input_handler.d.ts +257 -24
- package/types/phaser/core/input_handler.d.ts.map +1 -1
- package/types/phaser/core/input_mouse.d.ts +51 -4
- package/types/phaser/core/input_mouse.d.ts.map +1 -1
- package/types/phaser/core/input_mspointer.d.ts +43 -9
- package/types/phaser/core/input_mspointer.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +78 -2
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/input_touch.d.ts +45 -8
- package/types/phaser/core/input_touch.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +264 -19
- 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 +17 -7
- package/types/phaser/core/raf.d.ts.map +1 -1
- package/types/phaser/core/scale_manager.d.ts +201 -6
- package/types/phaser/core/scale_manager.d.ts.map +1 -1
- package/types/phaser/core/scene.d.ts +21 -5
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +90 -10
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +93 -9
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/signal_binding.d.ts +34 -5
- package/types/phaser/core/signal_binding.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +111 -14
- package/types/phaser/core/sound.d.ts.map +1 -1
- package/types/phaser/core/sound_manager.d.ts +93 -7
- package/types/phaser/core/sound_manager.d.ts.map +1 -1
- package/types/phaser/core/sound_sprite.d.ts +22 -8
- package/types/phaser/core/sound_sprite.d.ts.map +1 -1
- package/types/phaser/core/stage.d.ts +32 -3
- package/types/phaser/core/stage.d.ts.map +1 -1
- package/types/phaser/core/time.d.ts +73 -6
- package/types/phaser/core/time.d.ts.map +1 -1
- package/types/phaser/core/timer.d.ts +103 -2
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +11 -5
- package/types/phaser/core/timer_event.d.ts.map +1 -1
- package/types/phaser/core/tween.d.ts +122 -2
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +41 -2
- package/types/phaser/core/tween_data.d.ts.map +1 -1
- package/types/phaser/core/tween_easing.d.ts +0 -5
- package/types/phaser/core/tween_easing.d.ts.map +1 -1
- package/types/phaser/core/tween_manager.d.ts +49 -2
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +9 -1
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +84 -7
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +65 -8
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +20 -4
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/masker.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +0 -6
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +29 -2
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +195 -8
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +132 -6
- package/types/phaser/display/graphics.d.ts.map +1 -1
- package/types/phaser/display/graphics_data.d.ts +15 -1
- package/types/phaser/display/graphics_data.d.ts.map +1 -1
- package/types/phaser/display/graphics_data_util.d.ts +3 -2
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/types/phaser/display/group.d.ts +62 -0
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +66 -2
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/sprite_batch.d.ts +4 -3
- package/types/phaser/display/sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/sprite_util.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +366 -46
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +8 -6
- package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/types/phaser/display/webgl/base_texture.d.ts +20 -1
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/blend_manager.d.ts +11 -6
- package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/types/phaser/display/webgl/earcut_node.d.ts +9 -9
- package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +33 -6
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/webgl/filter_manager.d.ts +22 -6
- package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/filter_texture.d.ts +21 -3
- package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +10 -6
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/render_texture.d.ts +30 -3
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/renderer.d.ts +41 -4
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +10 -0
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/fast.d.ts +10 -0
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/normal.d.ts +20 -0
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/primitive.d.ts +10 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/strip.d.ts +10 -0
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader_manager.d.ts +15 -0
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/sprite_batch.d.ts +37 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/webgl/stencil_manager.d.ts +25 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture.d.ts +21 -0
- package/types/phaser/display/webgl/texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/display/webgl/util.d.ts +0 -6
- package/types/phaser/display/webgl/util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +131 -9
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +43 -5
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +159 -13
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +85 -11
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +170 -18
- package/types/phaser/geom/point.d.ts.map +1 -1
- package/types/phaser/geom/polygon.d.ts +45 -5
- package/types/phaser/geom/polygon.d.ts.map +1 -1
- package/types/phaser/geom/rectangle.d.ts +253 -20
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +11 -1
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/circle.d.ts +3 -3
- package/types/phaser/geom/util/circle.d.ts.map +1 -1
- package/types/phaser/geom/util/ellipse.d.ts +0 -6
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/util/line.d.ts +5 -5
- package/types/phaser/geom/util/line.d.ts.map +1 -1
- package/types/phaser/geom/util/matrix.d.ts.map +1 -1
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/types/phaser/geom/util/polygon.d.ts.map +1 -1
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/util/math.d.ts +0 -5
- package/types/phaser/util/math.d.ts.map +1 -1
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
export class AbstractFilter {
|
|
2
|
+
/**
|
|
3
|
+
* TBD.
|
|
4
|
+
* @param fragmentSrc
|
|
5
|
+
* @param uniforms
|
|
6
|
+
*/
|
|
9
7
|
constructor(fragmentSrc, uniforms) {
|
|
10
8
|
this.passes = [this];
|
|
11
9
|
this.shaders = [];
|
|
@@ -15,6 +13,9 @@ export class AbstractFilter {
|
|
|
15
13
|
this.fragmentSrc = fragmentSrc || [];
|
|
16
14
|
}
|
|
17
15
|
|
|
16
|
+
/**
|
|
17
|
+
* TBD.
|
|
18
|
+
*/
|
|
18
19
|
syncUniforms() {
|
|
19
20
|
for (let i = 0, j = this.shaders.length; i < j; i += 1) {
|
|
20
21
|
this.shaders[i].dirty = true;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module display/webgl/base_texture
|
|
3
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
4
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
5
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
6
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
7
|
-
*/
|
|
8
1
|
import { removeByCanvas } from '../canvas/pool';
|
|
9
2
|
|
|
10
3
|
export class BaseTexture {
|
|
4
|
+
/**
|
|
5
|
+
* TBD.
|
|
6
|
+
* @param source
|
|
7
|
+
* @param scaleMode
|
|
8
|
+
*/
|
|
11
9
|
constructor(source, scaleMode) {
|
|
12
10
|
this.resolution = 1;
|
|
13
11
|
this.width = 100;
|
|
@@ -22,11 +20,7 @@ export class BaseTexture {
|
|
|
22
20
|
this._powerOf2 = false;
|
|
23
21
|
this._dirty = [true, true, true, true];
|
|
24
22
|
if (source) {
|
|
25
|
-
if (
|
|
26
|
-
(this.source.complete || this.source.getContext) &&
|
|
27
|
-
this.source.width &&
|
|
28
|
-
this.source.height
|
|
29
|
-
) {
|
|
23
|
+
if ((this.source.complete || this.source.getContext) && this.source.width && this.source.height) {
|
|
30
24
|
this.hasLoaded = true;
|
|
31
25
|
this.width = this.source.naturalWidth || this.source.width;
|
|
32
26
|
this.height = this.source.naturalHeight || this.source.height;
|
|
@@ -35,6 +29,11 @@ export class BaseTexture {
|
|
|
35
29
|
}
|
|
36
30
|
}
|
|
37
31
|
|
|
32
|
+
/**
|
|
33
|
+
* TBD.
|
|
34
|
+
* @param {number} width - TBD.
|
|
35
|
+
* @param {number} height - TBD.
|
|
36
|
+
*/
|
|
38
37
|
forceLoaded(width, height) {
|
|
39
38
|
this.hasLoaded = true;
|
|
40
39
|
this.width = width;
|
|
@@ -42,6 +41,9 @@ export class BaseTexture {
|
|
|
42
41
|
this.dirty();
|
|
43
42
|
}
|
|
44
43
|
|
|
44
|
+
/**
|
|
45
|
+
* TBD.
|
|
46
|
+
*/
|
|
45
47
|
destroy() {
|
|
46
48
|
if (this.source) {
|
|
47
49
|
removeByCanvas(this.source);
|
|
@@ -50,12 +52,18 @@ export class BaseTexture {
|
|
|
50
52
|
this.unloadFromGPU();
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
/**
|
|
56
|
+
* TBD.
|
|
57
|
+
*/
|
|
53
58
|
dirty() {
|
|
54
59
|
for (let i = 0; i < this._glTextures.length; i += 1) {
|
|
55
60
|
this._dirty[i] = true;
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
63
|
|
|
64
|
+
/**
|
|
65
|
+
* TBD.
|
|
66
|
+
*/
|
|
59
67
|
unloadFromGPU() {
|
|
60
68
|
this.dirty();
|
|
61
69
|
for (let i = this._glTextures.length - 1; i >= 0; i -= 1) {
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
export class WebGLBlendModeManager {
|
|
2
|
+
/**
|
|
3
|
+
* TBD.
|
|
4
|
+
*/
|
|
9
5
|
constructor() {
|
|
10
6
|
this.gl = null;
|
|
11
7
|
this.currentBlendMode = 99999;
|
|
12
8
|
}
|
|
13
9
|
|
|
10
|
+
/**
|
|
11
|
+
* TBD.
|
|
12
|
+
* @param gl - TBD.
|
|
13
|
+
*/
|
|
14
14
|
setContext(gl) {
|
|
15
15
|
this.gl = gl;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* TBD.
|
|
20
|
+
* @param blendMode
|
|
21
|
+
*/
|
|
18
22
|
setBlendMode(blendMode) {
|
|
19
23
|
if (this.currentBlendMode === blendMode) {
|
|
20
24
|
return false;
|
|
@@ -27,6 +31,9 @@ export class WebGLBlendModeManager {
|
|
|
27
31
|
return true;
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
/**
|
|
35
|
+
* TBD.
|
|
36
|
+
*/
|
|
30
37
|
destroy() {
|
|
31
38
|
this.gl = null;
|
|
32
39
|
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
1
|
import { Node } from './earcut_node';
|
|
8
2
|
|
|
9
3
|
/**
|
|
@@ -191,9 +185,7 @@ export function equals(p1, p2) {
|
|
|
191
185
|
* @returns {boolean} TBD.
|
|
192
186
|
*/
|
|
193
187
|
export function intersects(p1, q1, p2, q2) {
|
|
194
|
-
return (
|
|
195
|
-
area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0
|
|
196
|
-
);
|
|
188
|
+
return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
|
|
197
189
|
}
|
|
198
190
|
|
|
199
191
|
/**
|
|
@@ -205,14 +197,7 @@ export function intersects(p1, q1, p2, q2) {
|
|
|
205
197
|
export function intersectsPolygon(a, b) {
|
|
206
198
|
let p = a;
|
|
207
199
|
do {
|
|
208
|
-
if (
|
|
209
|
-
p.i !== a.i &&
|
|
210
|
-
p.next.i !== a.i &&
|
|
211
|
-
p.i !== b.i &&
|
|
212
|
-
p.next.i !== b.i &&
|
|
213
|
-
intersects(p, p.next, a, b)
|
|
214
|
-
)
|
|
215
|
-
return true;
|
|
200
|
+
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)) return true;
|
|
216
201
|
p = p.next;
|
|
217
202
|
} while (p !== a);
|
|
218
203
|
return false;
|
|
@@ -242,10 +227,7 @@ export function middleInside(a, b) {
|
|
|
242
227
|
const px = (a.x + b.x) / 2;
|
|
243
228
|
const py = (a.y + b.y) / 2;
|
|
244
229
|
do {
|
|
245
|
-
if (
|
|
246
|
-
p.y > py !== p.next.y > py &&
|
|
247
|
-
px < ((p.next.x - p.x) * (py - p.y)) / (p.next.y - p.y) + p.x
|
|
248
|
-
) {
|
|
230
|
+
if (p.y > py !== p.next.y > py && px < ((p.next.x - p.x) * (py - p.y)) / (p.next.y - p.y) + p.x) {
|
|
249
231
|
inside = !inside;
|
|
250
232
|
}
|
|
251
233
|
p = p.next;
|
|
@@ -343,8 +325,7 @@ export function isEar(ear) {
|
|
|
343
325
|
// now make sure we don't have other points inside the potential ear
|
|
344
326
|
let p = ear.next.next;
|
|
345
327
|
while (p !== ear.prev) {
|
|
346
|
-
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)
|
|
347
|
-
return false;
|
|
328
|
+
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) return false;
|
|
348
329
|
p = p.next;
|
|
349
330
|
}
|
|
350
331
|
return true;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
export class Node {
|
|
2
|
+
/**
|
|
3
|
+
* TBD.
|
|
4
|
+
* @param i
|
|
5
|
+
* @param {number} x - TBD.
|
|
6
|
+
* @param {number} y - TBD.
|
|
7
|
+
*/
|
|
9
8
|
constructor(i, x, y) {
|
|
10
9
|
// vertice index in coordinates array
|
|
11
10
|
this.i = i;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
export class FastSpriteBatch {
|
|
2
|
+
/**
|
|
3
|
+
* TBD.
|
|
4
|
+
* @param gl - TBD.
|
|
5
|
+
*/
|
|
9
6
|
constructor(gl) {
|
|
10
7
|
this.vertSize = 10;
|
|
11
8
|
this.maxSize = 6000; // Math.pow(2, 16) / this.vertSize;
|
|
@@ -37,6 +34,10 @@ export class FastSpriteBatch {
|
|
|
37
34
|
this.setContext(gl);
|
|
38
35
|
}
|
|
39
36
|
|
|
37
|
+
/**
|
|
38
|
+
* TBD.
|
|
39
|
+
* @param gl - TBD.
|
|
40
|
+
*/
|
|
40
41
|
setContext(gl) {
|
|
41
42
|
this.gl = gl;
|
|
42
43
|
// create a couple of buffers
|
|
@@ -50,6 +51,11 @@ export class FastSpriteBatch {
|
|
|
50
51
|
gl.bufferData(gl.ARRAY_BUFFER, this.vertices, gl.DYNAMIC_DRAW);
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
/**
|
|
55
|
+
* TBD.
|
|
56
|
+
* @param spriteBatch
|
|
57
|
+
* @param renderSession - TBD.
|
|
58
|
+
*/
|
|
53
59
|
begin(spriteBatch, renderSession) {
|
|
54
60
|
this.renderSession = renderSession;
|
|
55
61
|
this.shader = this.renderSession.shaderManager.fastShader;
|
|
@@ -57,10 +63,17 @@ export class FastSpriteBatch {
|
|
|
57
63
|
this.start();
|
|
58
64
|
}
|
|
59
65
|
|
|
66
|
+
/**
|
|
67
|
+
* TBD.
|
|
68
|
+
*/
|
|
60
69
|
end() {
|
|
61
70
|
this.flush();
|
|
62
71
|
}
|
|
63
72
|
|
|
73
|
+
/**
|
|
74
|
+
* TBD.
|
|
75
|
+
* @param spriteBatch
|
|
76
|
+
*/
|
|
64
77
|
render(spriteBatch) {
|
|
65
78
|
const children = spriteBatch.children;
|
|
66
79
|
const sprite = children[0];
|
|
@@ -81,15 +94,16 @@ export class FastSpriteBatch {
|
|
|
81
94
|
this.flush();
|
|
82
95
|
}
|
|
83
96
|
|
|
97
|
+
/**
|
|
98
|
+
* TBD.
|
|
99
|
+
* @param sprite
|
|
100
|
+
*/
|
|
84
101
|
renderSprite(sprite) {
|
|
85
102
|
if (!sprite.visible) {
|
|
86
103
|
return;
|
|
87
104
|
}
|
|
88
105
|
// TODO trim??
|
|
89
|
-
if (
|
|
90
|
-
sprite.texture.baseTexture !== this.currentBaseTexture &&
|
|
91
|
-
!sprite.texture.baseTexture.skipRender
|
|
92
|
-
) {
|
|
106
|
+
if (sprite.texture.baseTexture !== this.currentBaseTexture && !sprite.texture.baseTexture.skipRender) {
|
|
93
107
|
this.flush();
|
|
94
108
|
this.currentBaseTexture = sprite.texture.baseTexture;
|
|
95
109
|
if (!sprite.texture._uvs) {
|
|
@@ -187,6 +201,9 @@ export class FastSpriteBatch {
|
|
|
187
201
|
}
|
|
188
202
|
}
|
|
189
203
|
|
|
204
|
+
/**
|
|
205
|
+
* TBD.
|
|
206
|
+
*/
|
|
190
207
|
flush() {
|
|
191
208
|
// If the batch is length 0 then return as there is nothing to draw
|
|
192
209
|
if (this.currentBatchSize === 0) {
|
|
@@ -213,10 +230,16 @@ export class FastSpriteBatch {
|
|
|
213
230
|
this.renderSession.drawCount += 1;
|
|
214
231
|
}
|
|
215
232
|
|
|
233
|
+
/**
|
|
234
|
+
* TBD.
|
|
235
|
+
*/
|
|
216
236
|
stop() {
|
|
217
237
|
this.flush();
|
|
218
238
|
}
|
|
219
239
|
|
|
240
|
+
/**
|
|
241
|
+
* TBD.
|
|
242
|
+
*/
|
|
220
243
|
start() {
|
|
221
244
|
const gl = this.gl;
|
|
222
245
|
// bind the main texture
|
|
@@ -1,43 +1,61 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
export class WebGLFilterManager {
|
|
2
|
+
/**
|
|
3
|
+
* TBD.
|
|
4
|
+
*/
|
|
9
5
|
constructor() {
|
|
10
6
|
this.filterStack = [];
|
|
11
7
|
this.offsetX = 0;
|
|
12
8
|
this.offsetY = 0;
|
|
13
9
|
}
|
|
14
10
|
|
|
11
|
+
/**
|
|
12
|
+
* TBD.
|
|
13
|
+
* @param gl - TBD.
|
|
14
|
+
*/
|
|
15
15
|
setContext(gl) {
|
|
16
16
|
this.gl = gl;
|
|
17
17
|
this.texturePool = [];
|
|
18
18
|
this.initShaderBuffers();
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* TBD.
|
|
23
|
+
*/
|
|
21
24
|
begin() {
|
|
22
25
|
// TODO
|
|
23
26
|
}
|
|
24
27
|
|
|
28
|
+
/**
|
|
29
|
+
* TBD.
|
|
30
|
+
*/
|
|
25
31
|
pushFilter() {
|
|
26
32
|
// TODO
|
|
27
33
|
}
|
|
28
34
|
|
|
35
|
+
/**
|
|
36
|
+
* TBD.
|
|
37
|
+
*/
|
|
29
38
|
popFilter() {
|
|
30
39
|
// TODO
|
|
31
40
|
}
|
|
32
41
|
|
|
42
|
+
/**
|
|
43
|
+
* TBD.
|
|
44
|
+
*/
|
|
33
45
|
applyFilterPass() {
|
|
34
46
|
// TODO
|
|
35
47
|
}
|
|
36
48
|
|
|
49
|
+
/**
|
|
50
|
+
* TBD.
|
|
51
|
+
*/
|
|
37
52
|
initShaderBuffers() {
|
|
38
53
|
// TODO
|
|
39
54
|
}
|
|
40
55
|
|
|
56
|
+
/**
|
|
57
|
+
* TBD.
|
|
58
|
+
*/
|
|
41
59
|
destroy() {
|
|
42
60
|
// TODO
|
|
43
61
|
}
|
|
@@ -1,28 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
1
|
import { SCALE_LINEAR } from '../../core/const';
|
|
8
2
|
|
|
9
3
|
export class FilterTexture {
|
|
4
|
+
/**
|
|
5
|
+
* TBD.
|
|
6
|
+
* @param gl - TBD.
|
|
7
|
+
* @param {number} width - TBD.
|
|
8
|
+
* @param {number} height - TBD.
|
|
9
|
+
* @param scaleMode
|
|
10
|
+
*/
|
|
10
11
|
constructor(gl, width, height, scaleMode) {
|
|
11
12
|
this.gl = gl;
|
|
12
13
|
this.frameBuffer = gl.createFramebuffer();
|
|
13
14
|
this.texture = gl.createTexture();
|
|
14
15
|
scaleMode = scaleMode || window.PhaserRegistry.TEXTURE_SCALE_MODE;
|
|
15
16
|
gl.bindTexture(gl.TEXTURE_2D, this.texture);
|
|
16
|
-
gl.texParameteri(
|
|
17
|
-
|
|
18
|
-
gl.TEXTURE_MAG_FILTER,
|
|
19
|
-
scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST
|
|
20
|
-
);
|
|
21
|
-
gl.texParameteri(
|
|
22
|
-
gl.TEXTURE_2D,
|
|
23
|
-
gl.TEXTURE_MIN_FILTER,
|
|
24
|
-
scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST
|
|
25
|
-
);
|
|
17
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST);
|
|
18
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST);
|
|
26
19
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
27
20
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
28
21
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer);
|
|
@@ -31,21 +24,24 @@ export class FilterTexture {
|
|
|
31
24
|
// required for masking a mask??
|
|
32
25
|
this.renderBuffer = gl.createRenderbuffer();
|
|
33
26
|
gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderBuffer);
|
|
34
|
-
gl.framebufferRenderbuffer(
|
|
35
|
-
gl.FRAMEBUFFER,
|
|
36
|
-
gl.DEPTH_STENCIL_ATTACHMENT,
|
|
37
|
-
gl.RENDERBUFFER,
|
|
38
|
-
this.renderBuffer
|
|
39
|
-
);
|
|
27
|
+
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this.renderBuffer);
|
|
40
28
|
this.resize(width, height);
|
|
41
29
|
}
|
|
42
30
|
|
|
31
|
+
/**
|
|
32
|
+
* TBD.
|
|
33
|
+
*/
|
|
43
34
|
clear() {
|
|
44
35
|
const gl = this.gl;
|
|
45
36
|
gl.clearColor(0, 0, 0, 0);
|
|
46
37
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
47
38
|
}
|
|
48
39
|
|
|
40
|
+
/**
|
|
41
|
+
* TBD.
|
|
42
|
+
* @param {number} width - TBD.
|
|
43
|
+
* @param {number} height - TBD.
|
|
44
|
+
*/
|
|
49
45
|
resize(width, height) {
|
|
50
46
|
if (this.width === width && this.height === height) {
|
|
51
47
|
return;
|
|
@@ -60,6 +56,9 @@ export class FilterTexture {
|
|
|
60
56
|
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
|
|
61
57
|
}
|
|
62
58
|
|
|
59
|
+
/**
|
|
60
|
+
* TBD.
|
|
61
|
+
*/
|
|
63
62
|
destroy() {
|
|
64
63
|
const gl = this.gl;
|
|
65
64
|
gl.deleteFramebuffer(this.frameBuffer);
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
|
-
import { GraphicsData } from './graphics_data';
|
|
1
|
+
import { GraphicsData } from './graphics_data';
|
|
8
2
|
import { Point } from '../../geom/point';
|
|
9
|
-
import {
|
|
10
|
-
GEOM_CIRCLE,
|
|
11
|
-
GEOM_ELLIPSE,
|
|
12
|
-
GEOM_POLYGON,
|
|
13
|
-
GEOM_RECTANGLE,
|
|
14
|
-
GEOM_ROUNDED_RECTANGLE,
|
|
15
|
-
} from '../../core/const';
|
|
3
|
+
import { GEOM_CIRCLE, GEOM_ELLIPSE, GEOM_POLYGON, GEOM_RECTANGLE, GEOM_ROUNDED_RECTANGLE } from '../../core/const';
|
|
16
4
|
import { hex2rgb } from '../../util/math';
|
|
17
5
|
import { triangulate } from './earcut';
|
|
18
6
|
|
|
@@ -324,22 +312,11 @@ export function buildRoundedRectangle(graphicsData, webGLData) {
|
|
|
324
312
|
const radius = rrectData.radius;
|
|
325
313
|
let recPoints = [];
|
|
326
314
|
recPoints.push(x, y + radius);
|
|
315
|
+
recPoints = recPoints.concat(quadraticBezierCurve(x, y + height - radius, x, y + height, x + radius, y + height));
|
|
327
316
|
recPoints = recPoints.concat(
|
|
328
|
-
quadraticBezierCurve(x, y + height
|
|
329
|
-
);
|
|
330
|
-
recPoints = recPoints.concat(
|
|
331
|
-
quadraticBezierCurve(
|
|
332
|
-
x + width - radius,
|
|
333
|
-
y + height,
|
|
334
|
-
x + width,
|
|
335
|
-
y + height,
|
|
336
|
-
x + width,
|
|
337
|
-
y + height - radius
|
|
338
|
-
)
|
|
339
|
-
);
|
|
340
|
-
recPoints = recPoints.concat(
|
|
341
|
-
quadraticBezierCurve(x + width, y + radius, x + width, y, x + width - radius, y)
|
|
317
|
+
quadraticBezierCurve(x + width - radius, y + height, x + width, y + height, x + width, y + height - radius)
|
|
342
318
|
);
|
|
319
|
+
recPoints = recPoints.concat(quadraticBezierCurve(x + width, y + radius, x + width, y, x + width - radius, y));
|
|
343
320
|
recPoints = recPoints.concat(quadraticBezierCurve(x + radius, y, x, y, x, y + radius));
|
|
344
321
|
if (graphicsData.fill) {
|
|
345
322
|
const color = hex2rgb(graphicsData.fillColor);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
export class GraphicsData {
|
|
2
|
+
/**
|
|
3
|
+
* TBD.
|
|
4
|
+
* @param gl - TBD.
|
|
5
|
+
*/
|
|
9
6
|
constructor(gl) {
|
|
10
7
|
this.gl = gl;
|
|
11
8
|
// TODO does this need to be split before uploading??
|
|
@@ -19,6 +16,9 @@ export class GraphicsData {
|
|
|
19
16
|
this.dirty = true;
|
|
20
17
|
}
|
|
21
18
|
|
|
19
|
+
/**
|
|
20
|
+
* TBD.
|
|
21
|
+
*/
|
|
22
22
|
reset() {
|
|
23
23
|
this.points = [];
|
|
24
24
|
this.indices = [];
|
|
@@ -26,6 +26,9 @@ export class GraphicsData {
|
|
|
26
26
|
this.glIndicies = null;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* TBD.
|
|
31
|
+
*/
|
|
29
32
|
upload() {
|
|
30
33
|
const gl = this.gl;
|
|
31
34
|
// this.lastIndex = graphics.graphicsData.length;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
1
|
import { updateGraphics } from './graphics';
|
|
8
2
|
|
|
9
3
|
/**
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
|
-
import { Rectangle } from '../../geom/rectangle';
|
|
1
|
+
import { Rectangle } from '../../geom/rectangle';
|
|
8
2
|
import { Point } from '../../geom/point';
|
|
9
3
|
import { Texture } from './texture';
|
|
10
4
|
import { BaseTexture } from './base_texture';
|
|
@@ -13,14 +7,19 @@ import { CanvasBuffer } from '../canvas/buffer';
|
|
|
13
7
|
import { RENDER_WEBGL } from '../../core/const';
|
|
14
8
|
|
|
15
9
|
export class RenderTexture extends Texture {
|
|
10
|
+
/**
|
|
11
|
+
* TBD.
|
|
12
|
+
* @param {number} width - TBD.
|
|
13
|
+
* @param {number} height - TBD.
|
|
14
|
+
* @param renderer
|
|
15
|
+
* @param scaleMode
|
|
16
|
+
* @param resolution
|
|
17
|
+
*/
|
|
16
18
|
constructor(width, height, renderer, scaleMode, resolution = 1) {
|
|
17
19
|
const w = width || 100;
|
|
18
20
|
const h = height || 100;
|
|
19
21
|
const res = resolution || 1;
|
|
20
|
-
const baseTexture = new BaseTexture(
|
|
21
|
-
null,
|
|
22
|
-
scaleMode || window.PhaserRegistry.TEXTURE_SCALE_MODE
|
|
23
|
-
);
|
|
22
|
+
const baseTexture = new BaseTexture(null, scaleMode || window.PhaserRegistry.TEXTURE_SCALE_MODE);
|
|
24
23
|
baseTexture.width = width * res;
|
|
25
24
|
baseTexture.height = height * res;
|
|
26
25
|
baseTexture._glTextures = [];
|
|
@@ -37,53 +36,66 @@ export class RenderTexture extends Texture {
|
|
|
37
36
|
if (this.renderer.type === RENDER_WEBGL) {
|
|
38
37
|
const gl = this.renderer.gl;
|
|
39
38
|
this.baseTexture._dirty[gl.id] = false;
|
|
40
|
-
this.textureBuffer = new FilterTexture(
|
|
41
|
-
gl,
|
|
42
|
-
this.width,
|
|
43
|
-
this.height,
|
|
44
|
-
this.baseTexture.scaleMode
|
|
45
|
-
);
|
|
39
|
+
this.textureBuffer = new FilterTexture(gl, this.width, this.height, this.baseTexture.scaleMode);
|
|
46
40
|
this.baseTexture._glTextures[gl.id] = this.textureBuffer.texture;
|
|
47
41
|
this.render = this.renderWebGL;
|
|
48
42
|
this.projection = new Point(this.width * 0.5, -this.height * 0.5);
|
|
49
43
|
} else {
|
|
50
44
|
this.render = this.renderCanvas;
|
|
51
|
-
this.textureBuffer = new CanvasBuffer(
|
|
52
|
-
this.width * this.resolution,
|
|
53
|
-
this.height * this.resolution
|
|
54
|
-
);
|
|
45
|
+
this.textureBuffer = new CanvasBuffer(this.width * this.resolution, this.height * this.resolution);
|
|
55
46
|
this.baseTexture.source = this.textureBuffer.canvas;
|
|
56
47
|
}
|
|
57
48
|
this.valid = true;
|
|
58
49
|
this._updateUvs();
|
|
59
50
|
}
|
|
60
51
|
|
|
52
|
+
/**
|
|
53
|
+
* TBD.
|
|
54
|
+
*/
|
|
61
55
|
resize() {
|
|
62
56
|
// TODO
|
|
63
57
|
}
|
|
64
58
|
|
|
59
|
+
/**
|
|
60
|
+
* TBD.
|
|
61
|
+
*/
|
|
65
62
|
clear() {
|
|
66
63
|
// TODO
|
|
67
64
|
}
|
|
68
65
|
|
|
66
|
+
/**
|
|
67
|
+
* TBD.
|
|
68
|
+
*/
|
|
69
69
|
renderWebGL() {
|
|
70
70
|
// TODO
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* TBD.
|
|
75
|
+
*/
|
|
73
76
|
renderCanvas() {
|
|
74
77
|
// TODO
|
|
75
78
|
}
|
|
76
79
|
|
|
80
|
+
/**
|
|
81
|
+
* TBD.
|
|
82
|
+
*/
|
|
77
83
|
getImage() {
|
|
78
84
|
const image = new Image();
|
|
79
85
|
image.src = this.getBase64();
|
|
80
86
|
return image;
|
|
81
87
|
}
|
|
82
88
|
|
|
89
|
+
/**
|
|
90
|
+
* TBD.
|
|
91
|
+
*/
|
|
83
92
|
getBase64() {
|
|
84
93
|
return this.getCanvas().toDataURL();
|
|
85
94
|
}
|
|
86
95
|
|
|
96
|
+
/**
|
|
97
|
+
* TBD.
|
|
98
|
+
*/
|
|
87
99
|
getCanvas() {
|
|
88
100
|
// TODO
|
|
89
101
|
}
|