@vpmedia/phaser 1.11.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/src/index.js +19 -19
- package/src/phaser/core/animation.js +12 -9
- package/src/phaser/core/animation_manager.js +16 -6
- package/src/phaser/core/animation_parser.js +40 -17
- package/src/phaser/core/array_set.js +3 -5
- package/src/phaser/core/cache.js +12 -12
- package/src/phaser/core/const.js +1 -1
- package/src/phaser/core/device.js +2 -4
- package/src/phaser/core/device_util.js +50 -17
- package/src/phaser/core/dom.js +36 -27
- package/src/phaser/core/event_manager.js +47 -19
- package/src/phaser/core/factory.js +34 -12
- package/src/phaser/core/frame.js +3 -5
- package/src/phaser/core/frame_data.js +2 -4
- package/src/phaser/core/frame_util.js +11 -9
- package/src/phaser/core/game.js +22 -19
- package/src/phaser/core/input.js +24 -16
- package/src/phaser/core/input_handler.js +102 -28
- package/src/phaser/core/input_mouse.js +12 -16
- package/src/phaser/core/input_mspointer.js +11 -10
- package/src/phaser/core/input_pointer.js +61 -20
- package/src/phaser/core/input_touch.js +7 -9
- package/src/phaser/core/loader.js +171 -54
- package/src/phaser/core/loader_parser.js +29 -22
- package/src/phaser/core/raf.js +2 -4
- package/src/phaser/core/scale_manager.js +75 -31
- package/src/phaser/core/scene.js +2 -4
- package/src/phaser/core/scene_manager.js +9 -6
- package/src/phaser/core/signal.js +19 -11
- package/src/phaser/core/signal_binding.js +12 -7
- package/src/phaser/core/sound.js +23 -14
- package/src/phaser/core/sound_manager.js +62 -26
- package/src/phaser/core/sound_sprite.js +34 -34
- package/src/phaser/core/stage.js +4 -7
- package/src/phaser/core/time.js +3 -5
- package/src/phaser/core/timer.js +27 -10
- package/src/phaser/core/timer_event.js +1 -3
- package/src/phaser/core/tween.js +36 -12
- package/src/phaser/core/tween_data.js +17 -9
- package/src/phaser/core/tween_easing.js +87 -83
- package/src/phaser/core/tween_manager.js +34 -16
- package/src/phaser/core/world.js +3 -5
- package/src/phaser/display/bitmap_text.js +25 -14
- package/src/phaser/display/button.js +35 -8
- package/src/phaser/display/canvas/buffer.js +1 -3
- package/src/phaser/display/canvas/graphics.js +30 -15
- package/src/phaser/display/canvas/masker.js +7 -5
- package/src/phaser/display/canvas/pool.js +18 -11
- package/src/phaser/display/canvas/renderer.js +40 -20
- package/src/phaser/display/canvas/tinter.js +61 -19
- package/src/phaser/display/canvas/util.js +44 -35
- package/src/phaser/display/display_object.js +42 -24
- package/src/phaser/display/graphics.js +72 -39
- package/src/phaser/display/graphics_data.js +3 -4
- package/src/phaser/display/graphics_data_util.js +15 -5
- package/src/phaser/display/group.js +15 -9
- package/src/phaser/display/image.js +17 -9
- package/src/phaser/display/sprite_batch.js +8 -4
- package/src/phaser/display/sprite_util.js +67 -26
- package/src/phaser/display/text.js +92 -31
- package/src/phaser/display/webgl/abstract_filter.js +1 -3
- package/src/phaser/display/webgl/base_texture.js +8 -5
- package/src/phaser/display/webgl/blend_manager.js +1 -3
- package/src/phaser/display/webgl/earcut.js +170 -129
- package/src/phaser/display/webgl/earcut_node.js +1 -3
- package/src/phaser/display/webgl/fast_sprite_batch.js +48 -47
- package/src/phaser/display/webgl/filter_manager.js +1 -3
- package/src/phaser/display/webgl/filter_texture.js +17 -6
- package/src/phaser/display/webgl/graphics.js +72 -50
- package/src/phaser/display/webgl/graphics_data.js +2 -4
- package/src/phaser/display/webgl/mask_manager.js +17 -7
- package/src/phaser/display/webgl/render_texture.js +19 -10
- package/src/phaser/display/webgl/renderer.js +41 -9
- package/src/phaser/display/webgl/shader/complex.js +1 -3
- package/src/phaser/display/webgl/shader/fast.js +9 -4
- package/src/phaser/display/webgl/shader/normal.js +43 -15
- package/src/phaser/display/webgl/shader/primitive.js +1 -3
- package/src/phaser/display/webgl/shader/strip.js +1 -3
- package/src/phaser/display/webgl/shader_manager.js +1 -3
- package/src/phaser/display/webgl/sprite_batch.js +14 -15
- package/src/phaser/display/webgl/stencil_manager.js +19 -21
- package/src/phaser/display/webgl/texture.js +14 -10
- package/src/phaser/display/webgl/texture_util.js +11 -9
- package/src/phaser/display/webgl/util.js +21 -18
- package/src/phaser/geom/circle.js +27 -11
- package/src/phaser/geom/ellipse.js +26 -10
- package/src/phaser/geom/line.js +31 -13
- package/src/phaser/geom/matrix.js +14 -5
- package/src/phaser/geom/point.js +18 -13
- package/src/phaser/geom/polygon.js +13 -8
- package/src/phaser/geom/rectangle.js +57 -14
- package/src/phaser/geom/rounded_rectangle.js +12 -4
- package/src/phaser/geom/util/circle.js +40 -32
- package/src/phaser/geom/util/ellipse.js +10 -18
- package/src/phaser/geom/util/line.js +46 -37
- package/src/phaser/geom/util/matrix.js +11 -9
- package/src/phaser/geom/util/point.js +101 -79
- package/src/phaser/geom/util/polygon.js +7 -15
- package/src/phaser/geom/util/rectangle.js +95 -69
- package/src/phaser/geom/util/rounded_rectangle.js +7 -15
- package/src/phaser/util/math.js +123 -89
- package/types/global.d.ts +7 -0
- package/types/index.d.ts +22 -0
- package/types/index.d.ts.map +1 -0
- package/types/phaser/core/animation.d.ts +55 -0
- package/types/phaser/core/animation.d.ts.map +1 -0
- package/types/phaser/core/animation_manager.d.ts +35 -0
- package/types/phaser/core/animation_manager.d.ts.map +1 -0
- package/types/phaser/core/animation_parser.d.ts +22 -0
- package/types/phaser/core/animation_parser.d.ts.map +1 -0
- package/types/phaser/core/array_set.d.ts +23 -0
- package/types/phaser/core/array_set.d.ts.map +1 -0
- package/types/phaser/core/cache.d.ts +106 -0
- package/types/phaser/core/cache.d.ts.map +1 -0
- package/types/phaser/core/const.d.ts +81 -0
- package/types/phaser/core/const.d.ts.map +1 -0
- package/types/phaser/core/device.d.ts +36 -0
- package/types/phaser/core/device.d.ts.map +1 -0
- package/types/phaser/core/device_util.d.ts +58 -0
- package/types/phaser/core/device_util.d.ts.map +1 -0
- package/types/phaser/core/dom.d.ts +63 -0
- package/types/phaser/core/dom.d.ts.map +1 -0
- package/types/phaser/core/event_manager.d.ts +53 -0
- package/types/phaser/core/event_manager.d.ts.map +1 -0
- package/types/phaser/core/factory.d.ts +12 -0
- package/types/phaser/core/factory.d.ts.map +1 -0
- package/types/phaser/core/frame.d.ts +30 -0
- package/types/phaser/core/frame.d.ts.map +1 -0
- package/types/phaser/core/frame_data.d.ts +14 -0
- package/types/phaser/core/frame_data.d.ts.map +1 -0
- package/types/phaser/core/frame_util.d.ts +17 -0
- package/types/phaser/core/frame_util.d.ts.map +1 -0
- package/types/phaser/core/game.d.ts +57 -0
- package/types/phaser/core/game.d.ts.map +1 -0
- package/types/phaser/core/input.d.ts +92 -0
- package/types/phaser/core/input.d.ts.map +1 -0
- package/types/phaser/core/input_handler.d.ts +111 -0
- package/types/phaser/core/input_handler.d.ts.map +1 -0
- package/types/phaser/core/input_mouse.d.ts +39 -0
- package/types/phaser/core/input_mouse.d.ts.map +1 -0
- package/types/phaser/core/input_mspointer.d.ts +34 -0
- package/types/phaser/core/input_mspointer.d.ts.map +1 -0
- package/types/phaser/core/input_pointer.d.ts +68 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -0
- package/types/phaser/core/input_touch.d.ts +37 -0
- package/types/phaser/core/input_touch.d.ts.map +1 -0
- package/types/phaser/core/loader.d.ts +94 -0
- package/types/phaser/core/loader.d.ts.map +1 -0
- package/types/phaser/core/loader_parser.d.ts +39 -0
- package/types/phaser/core/loader_parser.d.ts.map +1 -0
- package/types/phaser/core/raf.d.ts +15 -0
- package/types/phaser/core/raf.d.ts.map +1 -0
- package/types/phaser/core/scale_manager.d.ts +137 -0
- package/types/phaser/core/scale_manager.d.ts.map +1 -0
- package/types/phaser/core/scene.d.ts +17 -0
- package/types/phaser/core/scene.d.ts.map +1 -0
- package/types/phaser/core/scene_manager.d.ts +39 -0
- package/types/phaser/core/scene_manager.d.ts.map +1 -0
- package/types/phaser/core/signal.d.ts +25 -0
- package/types/phaser/core/signal.d.ts.map +1 -0
- package/types/phaser/core/signal_binding.d.ts +26 -0
- package/types/phaser/core/signal_binding.d.ts.map +1 -0
- package/types/phaser/core/sound.d.ts +72 -0
- package/types/phaser/core/sound.d.ts.map +1 -0
- package/types/phaser/core/sound_manager.d.ts +50 -0
- package/types/phaser/core/sound_manager.d.ts.map +1 -0
- package/types/phaser/core/sound_sprite.d.ts +18 -0
- package/types/phaser/core/sound_sprite.d.ts.map +1 -0
- package/types/phaser/core/stage.d.ts +23 -0
- package/types/phaser/core/stage.d.ts.map +1 -0
- package/types/phaser/core/time.d.ts +49 -0
- package/types/phaser/core/time.d.ts.map +1 -0
- package/types/phaser/core/timer.d.ts +49 -0
- package/types/phaser/core/timer.d.ts.map +1 -0
- package/types/phaser/core/timer_event.d.ts +18 -0
- package/types/phaser/core/timer_event.d.ts.map +1 -0
- package/types/phaser/core/tween.d.ts +52 -0
- package/types/phaser/core/tween.d.ts.map +1 -0
- package/types/phaser/core/tween_data.d.ts +37 -0
- package/types/phaser/core/tween_data.d.ts.map +1 -0
- package/types/phaser/core/tween_easing.d.ts +192 -0
- package/types/phaser/core/tween_easing.d.ts.map +1 -0
- package/types/phaser/core/tween_manager.d.ts +94 -0
- package/types/phaser/core/tween_manager.d.ts.map +1 -0
- package/types/phaser/core/world.d.ts +6 -0
- package/types/phaser/core/world.d.ts.map +1 -0
- package/types/phaser/display/bitmap_text.d.ts +59 -0
- package/types/phaser/display/bitmap_text.d.ts.map +1 -0
- package/types/phaser/display/button.d.ts +47 -0
- package/types/phaser/display/button.d.ts.map +1 -0
- package/types/phaser/display/canvas/buffer.d.ts +11 -0
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -0
- package/types/phaser/display/canvas/graphics.d.ts +21 -0
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -0
- package/types/phaser/display/canvas/masker.d.ts +14 -0
- package/types/phaser/display/canvas/masker.d.ts.map +1 -0
- package/types/phaser/display/canvas/pool.d.ts +52 -0
- package/types/phaser/display/canvas/pool.d.ts.map +1 -0
- package/types/phaser/display/canvas/renderer.d.ts +28 -0
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -0
- package/types/phaser/display/canvas/tinter.d.ts +41 -0
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -0
- package/types/phaser/display/canvas/util.d.ts +79 -0
- package/types/phaser/display/canvas/util.d.ts.map +1 -0
- package/types/phaser/display/display_object.d.ts +83 -0
- package/types/phaser/display/display_object.d.ts.map +1 -0
- package/types/phaser/display/graphics.d.ts +60 -0
- package/types/phaser/display/graphics.d.ts.map +1 -0
- package/types/phaser/display/graphics_data.d.ts +15 -0
- package/types/phaser/display/graphics_data.d.ts.map +1 -0
- package/types/phaser/display/graphics_data_util.d.ts +8 -0
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -0
- package/types/phaser/display/group.d.ts +49 -0
- package/types/phaser/display/group.d.ts.map +1 -0
- package/types/phaser/display/image.d.ts +52 -0
- package/types/phaser/display/image.d.ts.map +1 -0
- package/types/phaser/display/sprite_batch.d.ts +11 -0
- package/types/phaser/display/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/sprite_util.d.ts +40 -0
- package/types/phaser/display/sprite_util.d.ts.map +1 -0
- package/types/phaser/display/text.d.ts +125 -0
- package/types/phaser/display/text.d.ts.map +1 -0
- package/types/phaser/display/webgl/abstract_filter.d.ts +17 -0
- package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -0
- package/types/phaser/display/webgl/base_texture.d.ts +20 -0
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/blend_manager.d.ts +14 -0
- package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/earcut.d.ts +215 -0
- package/types/phaser/display/webgl/earcut.d.ts.map +1 -0
- package/types/phaser/display/webgl/earcut_node.d.ts +19 -0
- package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -0
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +34 -0
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/webgl/filter_manager.d.ts +21 -0
- package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/filter_texture.d.ts +13 -0
- package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/graphics.d.ts +80 -0
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -0
- package/types/phaser/display/webgl/graphics_data.d.ts +23 -0
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -0
- package/types/phaser/display/webgl/mask_manager.d.ts +15 -0
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/render_texture.d.ts +25 -0
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/renderer.d.ts +44 -0
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/complex.d.ts +22 -0
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/fast.d.ts +25 -0
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/normal.d.ts +25 -0
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts +21 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/strip.d.ts +22 -0
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader_manager.d.ts +24 -0
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts +36 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts +12 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/texture.d.ts +30 -0
- package/types/phaser/display/webgl/texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/texture_util.d.ts +17 -0
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -0
- package/types/phaser/display/webgl/util.d.ts +45 -0
- package/types/phaser/display/webgl/util.d.ts.map +1 -0
- package/types/phaser/geom/circle.d.ts +46 -0
- package/types/phaser/geom/circle.d.ts.map +1 -0
- package/types/phaser/geom/ellipse.d.ts +26 -0
- package/types/phaser/geom/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/line.d.ts +45 -0
- package/types/phaser/geom/line.d.ts.map +1 -0
- package/types/phaser/geom/matrix.d.ts +35 -0
- package/types/phaser/geom/matrix.d.ts.map +1 -0
- package/types/phaser/geom/point.d.ts +43 -0
- package/types/phaser/geom/point.d.ts.map +1 -0
- package/types/phaser/geom/polygon.d.ts +17 -0
- package/types/phaser/geom/polygon.d.ts.map +1 -0
- package/types/phaser/geom/rectangle.d.ts +71 -0
- package/types/phaser/geom/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/rounded_rectangle.d.ts +21 -0
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/circle.d.ts +64 -0
- package/types/phaser/geom/util/circle.d.ts.map +1 -0
- package/types/phaser/geom/util/ellipse.d.ts +16 -0
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/util/line.d.ts +49 -0
- package/types/phaser/geom/util/line.d.ts.map +1 -0
- package/types/phaser/geom/util/matrix.d.ts +22 -0
- package/types/phaser/geom/util/matrix.d.ts.map +1 -0
- package/types/phaser/geom/util/point.d.ts +179 -0
- package/types/phaser/geom/util/point.d.ts.map +1 -0
- package/types/phaser/geom/util/polygon.d.ts +10 -0
- package/types/phaser/geom/util/polygon.d.ts.map +1 -0
- package/types/phaser/geom/util/rectangle.d.ts +141 -0
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts +10 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/util/math.d.ts +182 -0
- package/types/phaser/util/math.d.ts.map +1 -0
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// TODO: fix ++ +=1 conversion issues (when a is 0 than a++ is 0 but a+=1 is 1)
|
|
9
9
|
|
|
10
10
|
export default class {
|
|
11
|
-
|
|
12
11
|
constructor(gl) {
|
|
13
12
|
this.vertSize = 10;
|
|
14
13
|
this.maxSize = 6000; // Math.pow(2, 16) / this.vertSize;
|
|
@@ -89,7 +88,10 @@ export default class {
|
|
|
89
88
|
return;
|
|
90
89
|
}
|
|
91
90
|
// TODO trim??
|
|
92
|
-
if (
|
|
91
|
+
if (
|
|
92
|
+
sprite.texture.baseTexture !== this.currentBaseTexture &&
|
|
93
|
+
!sprite.texture.baseTexture.skipRender
|
|
94
|
+
) {
|
|
93
95
|
this.flush();
|
|
94
96
|
this.currentBaseTexture = sprite.texture.baseTexture;
|
|
95
97
|
if (!sprite.texture._uvs) {
|
|
@@ -113,73 +115,73 @@ export default class {
|
|
|
113
115
|
h1 = trim.y - sprite.anchor.y * trim.height;
|
|
114
116
|
h0 = h1 + sprite.texture.crop.height;
|
|
115
117
|
} else {
|
|
116
|
-
w0 =
|
|
117
|
-
w1 =
|
|
118
|
+
w0 = sprite.texture.frame.width * (1 - sprite.anchor.x);
|
|
119
|
+
w1 = sprite.texture.frame.width * -sprite.anchor.x;
|
|
118
120
|
h0 = sprite.texture.frame.height * (1 - sprite.anchor.y);
|
|
119
121
|
h1 = sprite.texture.frame.height * -sprite.anchor.y;
|
|
120
122
|
}
|
|
121
123
|
index = this.currentBatchSize * 4 * this.vertSize;
|
|
122
124
|
index -= 1;
|
|
123
125
|
// xy
|
|
124
|
-
vertices[index += 1] = w1;
|
|
125
|
-
vertices[index += 1] = h1;
|
|
126
|
-
vertices[index += 1] = sprite.position.x;
|
|
127
|
-
vertices[index += 1] = sprite.position.y;
|
|
126
|
+
vertices[(index += 1)] = w1;
|
|
127
|
+
vertices[(index += 1)] = h1;
|
|
128
|
+
vertices[(index += 1)] = sprite.position.x;
|
|
129
|
+
vertices[(index += 1)] = sprite.position.y;
|
|
128
130
|
// scale
|
|
129
|
-
vertices[index += 1] = sprite.scale.x;
|
|
130
|
-
vertices[index += 1] = sprite.scale.y;
|
|
131
|
+
vertices[(index += 1)] = sprite.scale.x;
|
|
132
|
+
vertices[(index += 1)] = sprite.scale.y;
|
|
131
133
|
// rotation
|
|
132
|
-
vertices[index += 1] = sprite.rotation;
|
|
134
|
+
vertices[(index += 1)] = sprite.rotation;
|
|
133
135
|
// uv
|
|
134
|
-
vertices[index += 1] = uvs.x0;
|
|
135
|
-
vertices[index += 1] = uvs.y1;
|
|
136
|
+
vertices[(index += 1)] = uvs.x0;
|
|
137
|
+
vertices[(index += 1)] = uvs.y1;
|
|
136
138
|
// color
|
|
137
|
-
vertices[index += 1] = sprite.alpha;
|
|
139
|
+
vertices[(index += 1)] = sprite.alpha;
|
|
138
140
|
// xy
|
|
139
|
-
vertices[index += 1] = w0;
|
|
140
|
-
vertices[index += 1] = h1;
|
|
141
|
-
vertices[index += 1] = sprite.position.x;
|
|
142
|
-
vertices[index += 1] = sprite.position.y;
|
|
141
|
+
vertices[(index += 1)] = w0;
|
|
142
|
+
vertices[(index += 1)] = h1;
|
|
143
|
+
vertices[(index += 1)] = sprite.position.x;
|
|
144
|
+
vertices[(index += 1)] = sprite.position.y;
|
|
143
145
|
// scale
|
|
144
|
-
vertices[index += 1] = sprite.scale.x;
|
|
145
|
-
vertices[index += 1] = sprite.scale.y;
|
|
146
|
+
vertices[(index += 1)] = sprite.scale.x;
|
|
147
|
+
vertices[(index += 1)] = sprite.scale.y;
|
|
146
148
|
// rotation
|
|
147
|
-
vertices[index += 1] = sprite.rotation;
|
|
149
|
+
vertices[(index += 1)] = sprite.rotation;
|
|
148
150
|
// uv
|
|
149
|
-
vertices[index += 1] = uvs.x1;
|
|
150
|
-
vertices[index += 1] = uvs.y1;
|
|
151
|
+
vertices[(index += 1)] = uvs.x1;
|
|
152
|
+
vertices[(index += 1)] = uvs.y1;
|
|
151
153
|
// color
|
|
152
|
-
vertices[index += 1] = sprite.alpha;
|
|
154
|
+
vertices[(index += 1)] = sprite.alpha;
|
|
153
155
|
// xy
|
|
154
|
-
vertices[index += 1] = w0;
|
|
155
|
-
vertices[index += 1] = h0;
|
|
156
|
-
vertices[index += 1] = sprite.position.x;
|
|
157
|
-
vertices[index += 1] = sprite.position.y;
|
|
156
|
+
vertices[(index += 1)] = w0;
|
|
157
|
+
vertices[(index += 1)] = h0;
|
|
158
|
+
vertices[(index += 1)] = sprite.position.x;
|
|
159
|
+
vertices[(index += 1)] = sprite.position.y;
|
|
158
160
|
// scale
|
|
159
|
-
vertices[index += 1] = sprite.scale.x;
|
|
160
|
-
vertices[index += 1] = sprite.scale.y;
|
|
161
|
+
vertices[(index += 1)] = sprite.scale.x;
|
|
162
|
+
vertices[(index += 1)] = sprite.scale.y;
|
|
161
163
|
// rotation
|
|
162
|
-
vertices[index += 1] = sprite.rotation;
|
|
164
|
+
vertices[(index += 1)] = sprite.rotation;
|
|
163
165
|
// uv
|
|
164
|
-
vertices[index += 1] = uvs.x2;
|
|
165
|
-
vertices[index += 1] = uvs.y2;
|
|
166
|
+
vertices[(index += 1)] = uvs.x2;
|
|
167
|
+
vertices[(index += 1)] = uvs.y2;
|
|
166
168
|
// color
|
|
167
|
-
vertices[index += 1] = sprite.alpha;
|
|
169
|
+
vertices[(index += 1)] = sprite.alpha;
|
|
168
170
|
// xy
|
|
169
|
-
vertices[index += 1] = w1;
|
|
170
|
-
vertices[index += 1] = h0;
|
|
171
|
-
vertices[index += 1] = sprite.position.x;
|
|
172
|
-
vertices[index += 1] = sprite.position.y;
|
|
171
|
+
vertices[(index += 1)] = w1;
|
|
172
|
+
vertices[(index += 1)] = h0;
|
|
173
|
+
vertices[(index += 1)] = sprite.position.x;
|
|
174
|
+
vertices[(index += 1)] = sprite.position.y;
|
|
173
175
|
// scale
|
|
174
|
-
vertices[index += 1] = sprite.scale.x;
|
|
175
|
-
vertices[index += 1] = sprite.scale.y;
|
|
176
|
+
vertices[(index += 1)] = sprite.scale.x;
|
|
177
|
+
vertices[(index += 1)] = sprite.scale.y;
|
|
176
178
|
// rotation
|
|
177
|
-
vertices[index += 1] = sprite.rotation;
|
|
179
|
+
vertices[(index += 1)] = sprite.rotation;
|
|
178
180
|
// uv
|
|
179
|
-
vertices[index += 1] = uvs.x3;
|
|
180
|
-
vertices[index += 1] = uvs.y3;
|
|
181
|
+
vertices[(index += 1)] = uvs.x3;
|
|
182
|
+
vertices[(index += 1)] = uvs.y3;
|
|
181
183
|
// color
|
|
182
|
-
vertices[index += 1] = sprite.alpha;
|
|
184
|
+
vertices[(index += 1)] = sprite.alpha;
|
|
183
185
|
// increment the batch
|
|
184
186
|
this.currentBatchSize += 1;
|
|
185
187
|
if (this.currentBatchSize >= this.size) {
|
|
@@ -199,7 +201,7 @@ export default class {
|
|
|
199
201
|
}
|
|
200
202
|
gl.bindTexture(gl.TEXTURE_2D, this.currentBaseTexture._glTextures[gl.id]);
|
|
201
203
|
// upload the verts to the buffer
|
|
202
|
-
if (this.currentBatchSize >
|
|
204
|
+
if (this.currentBatchSize > this.size * 0.5) {
|
|
203
205
|
gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertices);
|
|
204
206
|
} else {
|
|
205
207
|
const view = this.vertices.subarray(0, this.currentBatchSize * 4 * this.vertSize);
|
|
@@ -238,5 +240,4 @@ export default class {
|
|
|
238
240
|
gl.vertexAttribPointer(this.shader.aTextureCoord, 2, gl.FLOAT, false, stride, 7 * 4);
|
|
239
241
|
gl.vertexAttribPointer(this.shader.colorAttribute, 1, gl.FLOAT, false, stride, 9 * 4);
|
|
240
242
|
}
|
|
241
|
-
|
|
242
243
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
export default class {
|
|
9
|
-
|
|
10
9
|
constructor() {
|
|
11
10
|
this.filterStack = [];
|
|
12
11
|
this.offsetX = 0;
|
|
@@ -42,5 +41,4 @@ export default class {
|
|
|
42
41
|
destroy() {
|
|
43
42
|
// TODO
|
|
44
43
|
}
|
|
45
|
-
|
|
46
44
|
}
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
7
|
import { SCALE_LINEAR } from '../../core/const';
|
|
8
8
|
|
|
9
9
|
export default class {
|
|
10
|
-
|
|
11
10
|
constructor(gl, width, height, scaleMode) {
|
|
12
11
|
this.gl = gl;
|
|
13
12
|
this.frameBuffer = gl.createFramebuffer();
|
|
14
13
|
this.texture = gl.createTexture();
|
|
15
14
|
scaleMode = scaleMode || window.PhaserRegistry.TEXTURE_SCALE_MODE;
|
|
16
15
|
gl.bindTexture(gl.TEXTURE_2D, this.texture);
|
|
17
|
-
gl.texParameteri(
|
|
18
|
-
|
|
16
|
+
gl.texParameteri(
|
|
17
|
+
gl.TEXTURE_2D,
|
|
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
|
+
);
|
|
19
26
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
20
27
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
21
28
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer);
|
|
@@ -24,7 +31,12 @@ export default class {
|
|
|
24
31
|
// required for masking a mask??
|
|
25
32
|
this.renderBuffer = gl.createRenderbuffer();
|
|
26
33
|
gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderBuffer);
|
|
27
|
-
gl.framebufferRenderbuffer(
|
|
34
|
+
gl.framebufferRenderbuffer(
|
|
35
|
+
gl.FRAMEBUFFER,
|
|
36
|
+
gl.DEPTH_STENCIL_ATTACHMENT,
|
|
37
|
+
gl.RENDERBUFFER,
|
|
38
|
+
this.renderBuffer
|
|
39
|
+
);
|
|
28
40
|
this.resize(width, height);
|
|
29
41
|
}
|
|
30
42
|
|
|
@@ -57,5 +69,4 @@ export default class {
|
|
|
57
69
|
this.renderBuffer = null;
|
|
58
70
|
this.gl = null;
|
|
59
71
|
}
|
|
60
|
-
|
|
61
72
|
}
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
|
-
import GraphicsData from
|
|
8
|
-
import Point from '../../geom/point';
|
|
9
|
-
import {
|
|
7
|
+
import { GraphicsData } from './graphics_data';
|
|
8
|
+
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';
|
|
10
16
|
import { hex2rgb } from '../../util/math';
|
|
11
17
|
import { triangulate } from './earcut';
|
|
12
18
|
|
|
13
19
|
/**
|
|
14
|
-
* TBD
|
|
20
|
+
* TBD.
|
|
15
21
|
*
|
|
16
|
-
* @returns {number} TBD
|
|
22
|
+
* @returns {number} TBD.
|
|
17
23
|
*/
|
|
18
24
|
export function getStencilBufferLimit() {
|
|
19
25
|
if (!window.PhaserRegistry.stencilBufferLimit) {
|
|
@@ -23,9 +29,9 @@ export function getStencilBufferLimit() {
|
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
/**
|
|
26
|
-
* TBD
|
|
32
|
+
* TBD.
|
|
27
33
|
*
|
|
28
|
-
* @returns {object[]} TBD
|
|
34
|
+
* @returns {object[]} TBD.
|
|
29
35
|
*/
|
|
30
36
|
export function getGraphicsDataPool() {
|
|
31
37
|
if (!window.PhaserRegistry.graphicsDataPool) {
|
|
@@ -36,9 +42,9 @@ export function getGraphicsDataPool() {
|
|
|
36
42
|
|
|
37
43
|
/**
|
|
38
44
|
*
|
|
39
|
-
* @param {object} webGL TBD
|
|
40
|
-
* @param {number} type TBD
|
|
41
|
-
* @returns {object} TBD
|
|
45
|
+
* @param {object} webGL - TBD.
|
|
46
|
+
* @param {number} type - TBD.
|
|
47
|
+
* @returns {object} TBD.
|
|
42
48
|
*/
|
|
43
49
|
export function switchMode(webGL, type) {
|
|
44
50
|
let webGLData;
|
|
@@ -60,8 +66,8 @@ export function switchMode(webGL, type) {
|
|
|
60
66
|
|
|
61
67
|
/**
|
|
62
68
|
*
|
|
63
|
-
* @param {object} graphicsData TBD
|
|
64
|
-
* @param {object} webGLData TBD
|
|
69
|
+
* @param {object} graphicsData - TBD.
|
|
70
|
+
* @param {object} webGLData - TBD.
|
|
65
71
|
*/
|
|
66
72
|
export function buildLine(graphicsData, webGLData) {
|
|
67
73
|
// TODO OPTIMISE!
|
|
@@ -133,7 +139,7 @@ export function buildLine(graphicsData, webGLData) {
|
|
|
133
139
|
p2y = points[3];
|
|
134
140
|
perpx = -(p1y - p2y);
|
|
135
141
|
perpy = p1x - p2x;
|
|
136
|
-
dist = Math.sqrt(
|
|
142
|
+
dist = Math.sqrt(perpx * perpx + perpy * perpy);
|
|
137
143
|
perpx /= dist;
|
|
138
144
|
perpy /= dist;
|
|
139
145
|
perpx *= width;
|
|
@@ -144,13 +150,13 @@ export function buildLine(graphicsData, webGLData) {
|
|
|
144
150
|
for (i = 1; i < length - 1; i += 1) {
|
|
145
151
|
p1x = points[(i - 1) * 2];
|
|
146
152
|
p1y = points[(i - 1) * 2 + 1];
|
|
147
|
-
p2x = points[
|
|
148
|
-
p2y = points[
|
|
153
|
+
p2x = points[i * 2];
|
|
154
|
+
p2y = points[i * 2 + 1];
|
|
149
155
|
p3x = points[(i + 1) * 2];
|
|
150
156
|
p3y = points[(i + 1) * 2 + 1];
|
|
151
157
|
perpx = -(p1y - p2y);
|
|
152
158
|
perpy = p1x - p2x;
|
|
153
|
-
dist = Math.sqrt(
|
|
159
|
+
dist = Math.sqrt(perpx * perpx + perpy * perpy);
|
|
154
160
|
perpx /= dist;
|
|
155
161
|
perpy /= dist;
|
|
156
162
|
perpx *= width;
|
|
@@ -162,13 +168,13 @@ export function buildLine(graphicsData, webGLData) {
|
|
|
162
168
|
perp2y /= dist;
|
|
163
169
|
perp2x *= width;
|
|
164
170
|
perp2y *= width;
|
|
165
|
-
a1 =
|
|
166
|
-
b1 =
|
|
171
|
+
a1 = -perpy + p1y - (-perpy + p2y);
|
|
172
|
+
b1 = -perpx + p2x - (-perpx + p1x);
|
|
167
173
|
c1 = (-perpx + p1x) * (-perpy + p2y) - (-perpx + p2x) * (-perpy + p1y);
|
|
168
|
-
a2 =
|
|
169
|
-
b2 =
|
|
174
|
+
a2 = -perp2y + p3y - (-perp2y + p2y);
|
|
175
|
+
b2 = -perp2x + p2x - (-perp2x + p3x);
|
|
170
176
|
c2 = (-perp2x + p3x) * (-perp2y + p2y) - (-perp2x + p2x) * (-perp2y + p3y);
|
|
171
|
-
denom =
|
|
177
|
+
denom = a1 * b2 - a2 * b1;
|
|
172
178
|
if (Math.abs(denom) < 0.1) {
|
|
173
179
|
denom += 10.1;
|
|
174
180
|
verts.push(p2x - perpx, p2y - perpy, r, g, b, alpha);
|
|
@@ -206,7 +212,7 @@ export function buildLine(graphicsData, webGLData) {
|
|
|
206
212
|
p2y = points[(length - 1) * 2 + 1];
|
|
207
213
|
perpx = -(p1y - p2y);
|
|
208
214
|
perpy = p1x - p2x;
|
|
209
|
-
dist = Math.sqrt(
|
|
215
|
+
dist = Math.sqrt(perpx * perpx + perpy * perpy);
|
|
210
216
|
perpx /= dist;
|
|
211
217
|
perpy /= dist;
|
|
212
218
|
perpx *= width;
|
|
@@ -225,8 +231,8 @@ export function buildLine(graphicsData, webGLData) {
|
|
|
225
231
|
|
|
226
232
|
/**
|
|
227
233
|
*
|
|
228
|
-
* @param {object} graphicsData TBD
|
|
229
|
-
* @param {object} webGLData TBD
|
|
234
|
+
* @param {object} graphicsData - TBD.
|
|
235
|
+
* @param {object} webGLData - TBD.
|
|
230
236
|
*/
|
|
231
237
|
export function buildRectangle(graphicsData, webGLData) {
|
|
232
238
|
//
|
|
@@ -269,13 +275,13 @@ export function buildRectangle(graphicsData, webGLData) {
|
|
|
269
275
|
|
|
270
276
|
/**
|
|
271
277
|
*
|
|
272
|
-
* @param {number} fromX TBD
|
|
273
|
-
* @param {number} fromY TBD
|
|
274
|
-
* @param {number} cpX TBD
|
|
275
|
-
* @param {number} cpY TBD
|
|
276
|
-
* @param {number} toX TBD
|
|
277
|
-
* @param {number} toY TBD
|
|
278
|
-
* @returns {number[]} TBD
|
|
278
|
+
* @param {number} fromX - TBD.
|
|
279
|
+
* @param {number} fromY - TBD.
|
|
280
|
+
* @param {number} cpX - TBD.
|
|
281
|
+
* @param {number} cpY - TBD.
|
|
282
|
+
* @param {number} toX - TBD.
|
|
283
|
+
* @param {number} toY - TBD.
|
|
284
|
+
* @returns {number[]} TBD.
|
|
279
285
|
*/
|
|
280
286
|
export function quadraticBezierCurve(fromX, fromY, cpX, cpY, toX, toY) {
|
|
281
287
|
let xa;
|
|
@@ -288,7 +294,7 @@ export function quadraticBezierCurve(fromX, fromY, cpX, cpY, toX, toY) {
|
|
|
288
294
|
const points = [];
|
|
289
295
|
const getPt = (n1, n2, perc) => {
|
|
290
296
|
const diff = n2 - n1;
|
|
291
|
-
return n1 +
|
|
297
|
+
return n1 + diff * perc;
|
|
292
298
|
};
|
|
293
299
|
let j = 0;
|
|
294
300
|
for (let i = 0; i <= n; i += 1) {
|
|
@@ -308,8 +314,8 @@ export function quadraticBezierCurve(fromX, fromY, cpX, cpY, toX, toY) {
|
|
|
308
314
|
|
|
309
315
|
/**
|
|
310
316
|
*
|
|
311
|
-
* @param {object} graphicsData TBD
|
|
312
|
-
* @param {object} webGLData TBD
|
|
317
|
+
* @param {object} graphicsData - TBD.
|
|
318
|
+
* @param {object} webGLData - TBD.
|
|
313
319
|
*/
|
|
314
320
|
export function buildRoundedRectangle(graphicsData, webGLData) {
|
|
315
321
|
const rrectData = graphicsData.shape;
|
|
@@ -320,9 +326,22 @@ export function buildRoundedRectangle(graphicsData, webGLData) {
|
|
|
320
326
|
const radius = rrectData.radius;
|
|
321
327
|
let recPoints = [];
|
|
322
328
|
recPoints.push(x, y + radius);
|
|
323
|
-
recPoints = recPoints.concat(
|
|
324
|
-
|
|
325
|
-
|
|
329
|
+
recPoints = recPoints.concat(
|
|
330
|
+
quadraticBezierCurve(x, y + height - radius, x, y + height, x + radius, y + height)
|
|
331
|
+
);
|
|
332
|
+
recPoints = recPoints.concat(
|
|
333
|
+
quadraticBezierCurve(
|
|
334
|
+
x + width - radius,
|
|
335
|
+
y + height,
|
|
336
|
+
x + width,
|
|
337
|
+
y + height,
|
|
338
|
+
x + width,
|
|
339
|
+
y + height - radius
|
|
340
|
+
)
|
|
341
|
+
);
|
|
342
|
+
recPoints = recPoints.concat(
|
|
343
|
+
quadraticBezierCurve(x + width, y + radius, x + width, y, x + width - radius, y)
|
|
344
|
+
);
|
|
326
345
|
recPoints = recPoints.concat(quadraticBezierCurve(x + radius, y, x, y, x, y + radius));
|
|
327
346
|
if (graphicsData.fill) {
|
|
328
347
|
const color = hex2rgb(graphicsData.fillColor);
|
|
@@ -356,8 +375,8 @@ export function buildRoundedRectangle(graphicsData, webGLData) {
|
|
|
356
375
|
|
|
357
376
|
/**
|
|
358
377
|
*
|
|
359
|
-
* @param {object} graphicsData TBD
|
|
360
|
-
* @param {object} webGLData TBD
|
|
378
|
+
* @param {object} graphicsData - TBD.
|
|
379
|
+
* @param {object} webGLData - TBD.
|
|
361
380
|
*/
|
|
362
381
|
export function buildCircle(graphicsData, webGLData) {
|
|
363
382
|
// need to convert points to a nice regular data
|
|
@@ -407,8 +426,8 @@ export function buildCircle(graphicsData, webGLData) {
|
|
|
407
426
|
|
|
408
427
|
/**
|
|
409
428
|
*
|
|
410
|
-
* @param {object} graphicsData TBD
|
|
411
|
-
* @param {object} webGLData TBD
|
|
429
|
+
* @param {object} graphicsData - TBD.
|
|
430
|
+
* @param {object} webGLData - TBD.
|
|
412
431
|
*/
|
|
413
432
|
export function buildComplexPoly(graphicsData, webGLData) {
|
|
414
433
|
// TODO - no need to copy this as it gets turned into a Float32Array anyways..
|
|
@@ -451,9 +470,9 @@ export function buildComplexPoly(graphicsData, webGLData) {
|
|
|
451
470
|
|
|
452
471
|
/**
|
|
453
472
|
*
|
|
454
|
-
* @param {object} graphicsData TBD
|
|
455
|
-
* @param {object} webGLData TBD
|
|
456
|
-
* @returns {boolean} TBD
|
|
473
|
+
* @param {object} graphicsData - TBD.
|
|
474
|
+
* @param {object} webGLData - TBD.
|
|
475
|
+
* @returns {boolean} TBD.
|
|
457
476
|
*/
|
|
458
477
|
export function buildPoly(graphicsData, webGLData) {
|
|
459
478
|
const points = graphicsData.points;
|
|
@@ -490,8 +509,8 @@ export function buildPoly(graphicsData, webGLData) {
|
|
|
490
509
|
|
|
491
510
|
/**
|
|
492
511
|
*
|
|
493
|
-
* @param {object} graphics TBD
|
|
494
|
-
* @param {object} gl TBD
|
|
512
|
+
* @param {object} graphics - TBD.
|
|
513
|
+
* @param {object} gl - TBD.
|
|
495
514
|
*/
|
|
496
515
|
export function updateGraphics(graphics, gl) {
|
|
497
516
|
const stencilBufferLimit = getStencilBufferLimit();
|
|
@@ -529,7 +548,10 @@ export function updateGraphics(graphics, gl) {
|
|
|
529
548
|
data.points = data.shape.points.slice();
|
|
530
549
|
if (data.shape.closed) {
|
|
531
550
|
// close the poly if the value is true!
|
|
532
|
-
if (
|
|
551
|
+
if (
|
|
552
|
+
data.points[0] !== data.points[data.points.length - 2] ||
|
|
553
|
+
data.points[1] !== data.points[data.points.length - 1]
|
|
554
|
+
) {
|
|
533
555
|
data.points.push(data.points[0], data.points[1]);
|
|
534
556
|
}
|
|
535
557
|
}
|
|
@@ -576,8 +598,8 @@ export function updateGraphics(graphics, gl) {
|
|
|
576
598
|
|
|
577
599
|
/**
|
|
578
600
|
*
|
|
579
|
-
* @param {object} graphics TBD
|
|
580
|
-
* @param {object} renderSession TBD
|
|
601
|
+
* @param {object} graphics - TBD.
|
|
602
|
+
* @param {object} renderSession - TBD.
|
|
581
603
|
*/
|
|
582
604
|
export function renderGraphics(graphics, renderSession) {
|
|
583
605
|
const gl = renderSession.gl;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
|
|
8
|
+
export class GraphicsData {
|
|
10
9
|
constructor(gl) {
|
|
11
10
|
this.gl = gl;
|
|
12
11
|
// TODO does this need to be split before uploading??
|
|
@@ -38,5 +37,4 @@ export default class {
|
|
|
38
37
|
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.glIndicies, gl.STATIC_DRAW);
|
|
39
38
|
this.dirty = false;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
40
|
}
|
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
7
|
import { updateGraphics } from './graphics';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* TBD.
|
|
10
11
|
*
|
|
11
|
-
* @param {object} maskData TBD
|
|
12
|
-
* @param {object} renderSession TBD
|
|
12
|
+
* @param {object} maskData - TBD.
|
|
13
|
+
* @param {object} renderSession - TBD.
|
|
13
14
|
*/
|
|
14
15
|
export function pushMask(maskData, renderSession) {
|
|
15
16
|
const gl = renderSession.gl;
|
|
16
17
|
if (maskData.dirty) {
|
|
17
18
|
updateGraphics(maskData, gl);
|
|
18
19
|
}
|
|
19
|
-
if (
|
|
20
|
+
if (
|
|
21
|
+
maskData._webGL[gl.id] === undefined ||
|
|
22
|
+
maskData._webGL[gl.id].data === undefined ||
|
|
23
|
+
maskData._webGL[gl.id].data.length === 0
|
|
24
|
+
) {
|
|
20
25
|
return;
|
|
21
26
|
}
|
|
22
27
|
renderSession.stencilManager.pushStencil(maskData, maskData._webGL[gl.id].data[0], renderSession);
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
/**
|
|
31
|
+
* TBD.
|
|
26
32
|
*
|
|
27
|
-
* @param {object} maskData TBD
|
|
28
|
-
* @param {object} renderSession TBD
|
|
33
|
+
* @param {object} maskData - TBD.
|
|
34
|
+
* @param {object} renderSession - TBD.
|
|
29
35
|
*/
|
|
30
36
|
export function popMask(maskData, renderSession) {
|
|
31
37
|
const gl = renderSession.gl;
|
|
32
|
-
if (
|
|
38
|
+
if (
|
|
39
|
+
maskData._webGL[gl.id] === undefined ||
|
|
40
|
+
maskData._webGL[gl.id].data === undefined ||
|
|
41
|
+
maskData._webGL[gl.id].data.length === 0
|
|
42
|
+
) {
|
|
33
43
|
return;
|
|
34
44
|
}
|
|
35
45
|
renderSession.stencilManager.popStencil(maskData, maskData._webGL[gl.id].data[0], renderSession);
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
|
-
import Rectangle from
|
|
8
|
-
import Point from '../../geom/point';
|
|
9
|
-
import Texture from './texture';
|
|
10
|
-
import BaseTexture from './base_texture';
|
|
7
|
+
import { Rectangle } from '../../geom/rectangle';
|
|
8
|
+
import { Point } from '../../geom/point';
|
|
9
|
+
import { Texture } from './texture';
|
|
10
|
+
import { BaseTexture } from './base_texture';
|
|
11
11
|
import FilterTexture from './filter_texture';
|
|
12
12
|
import CanvasBuffer from '../canvas/buffer';
|
|
13
13
|
import { RENDER_WEBGL } from '../../core/const';
|
|
14
14
|
|
|
15
15
|
export default class extends Texture {
|
|
16
|
-
|
|
17
16
|
constructor(width, height, renderer, scaleMode, resolution = 1) {
|
|
18
17
|
const w = width || 100;
|
|
19
18
|
const h = height || 100;
|
|
20
19
|
const res = resolution || 1;
|
|
21
|
-
const baseTexture = new BaseTexture(
|
|
20
|
+
const baseTexture = new BaseTexture(
|
|
21
|
+
null,
|
|
22
|
+
scaleMode || window.PhaserRegistry.TEXTURE_SCALE_MODE
|
|
23
|
+
);
|
|
22
24
|
baseTexture.width = width * res;
|
|
23
25
|
baseTexture.height = height * res;
|
|
24
26
|
baseTexture._glTextures = [];
|
|
@@ -35,13 +37,21 @@ export default class extends Texture {
|
|
|
35
37
|
if (this.renderer.type === RENDER_WEBGL) {
|
|
36
38
|
const gl = this.renderer.gl;
|
|
37
39
|
this.baseTexture._dirty[gl.id] = false;
|
|
38
|
-
this.textureBuffer = new FilterTexture(
|
|
40
|
+
this.textureBuffer = new FilterTexture(
|
|
41
|
+
gl,
|
|
42
|
+
this.width,
|
|
43
|
+
this.height,
|
|
44
|
+
this.baseTexture.scaleMode
|
|
45
|
+
);
|
|
39
46
|
this.baseTexture._glTextures[gl.id] = this.textureBuffer.texture;
|
|
40
47
|
this.render = this.renderWebGL;
|
|
41
48
|
this.projection = new Point(this.width * 0.5, -this.height * 0.5);
|
|
42
49
|
} else {
|
|
43
50
|
this.render = this.renderCanvas;
|
|
44
|
-
this.textureBuffer = new CanvasBuffer(
|
|
51
|
+
this.textureBuffer = new CanvasBuffer(
|
|
52
|
+
this.width * this.resolution,
|
|
53
|
+
this.height * this.resolution
|
|
54
|
+
);
|
|
45
55
|
this.baseTexture.source = this.textureBuffer.canvas;
|
|
46
56
|
}
|
|
47
57
|
this.valid = true;
|
|
@@ -77,5 +87,4 @@ export default class extends Texture {
|
|
|
77
87
|
getCanvas() {
|
|
78
88
|
// TODO
|
|
79
89
|
}
|
|
80
|
-
|
|
81
90
|
}
|