@vpmedia/phaser 1.14.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 -20
- 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 +5 -6
- package/src/phaser/core/device_util.js +3 -25
- 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 -14
- 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 +68 -7
- 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 -14
- 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 -39
- package/src/phaser/core/tween_manager.js +47 -5
- package/src/phaser/core/world.js +9 -6
- package/src/phaser/display/bitmap_text.js +92 -11
- package/src/phaser/display/button.js +64 -13
- package/src/phaser/display/canvas/buffer.js +16 -6
- package/src/phaser/display/canvas/graphics.js +1 -16
- package/src/phaser/display/canvas/masker.js +0 -8
- package/src/phaser/display/canvas/pool.js +0 -14
- package/src/phaser/display/canvas/renderer.js +28 -8
- package/src/phaser/display/canvas/tinter.js +4 -48
- package/src/phaser/display/canvas/util.js +0 -15
- package/src/phaser/display/display_object.js +192 -20
- package/src/phaser/display/graphics.js +162 -27
- package/src/phaser/display/graphics_data.js +14 -6
- package/src/phaser/display/graphics_data_util.js +2 -9
- package/src/phaser/display/group.js +75 -10
- package/src/phaser/display/image.js +86 -10
- package/src/phaser/display/sprite_batch.js +3 -9
- package/src/phaser/display/sprite_util.js +3 -28
- package/src/phaser/display/text.js +332 -32
- 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 -50
- 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 -40
- package/src/phaser/display/webgl/graphics_data.js +10 -7
- package/src/phaser/display/webgl/mask_manager.js +0 -8
- 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 -8
- package/src/phaser/display/webgl/util.js +0 -11
- package/src/phaser/geom/circle.js +123 -19
- package/src/phaser/geom/ellipse.js +39 -19
- package/src/phaser/geom/line.js +148 -17
- package/src/phaser/geom/matrix.js +73 -7
- package/src/phaser/geom/point.js +152 -7
- package/src/phaser/geom/polygon.js +42 -14
- package/src/phaser/geom/rectangle.js +233 -7
- package/src/phaser/geom/rounded_rectangle.js +10 -7
- package/src/phaser/geom/util/circle.js +3 -16
- package/src/phaser/geom/util/ellipse.js +0 -8
- package/src/phaser/geom/util/line.js +5 -19
- package/src/phaser/geom/util/matrix.js +1 -10
- package/src/phaser/geom/util/point.js +0 -26
- package/src/phaser/geom/util/polygon.js +1 -8
- package/src/phaser/geom/util/rectangle.js +1 -23
- package/src/phaser/geom/util/rounded_rectangle.js +1 -8
- package/src/phaser/util/math.js +3 -43
- package/{types → typedefs}/global.d.ts +1 -1
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/phaser/core/animation.d.ts +106 -5
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +88 -1
- package/types/phaser/core/animation_manager.d.ts.map +1 -1
- package/types/phaser/core/animation_parser.d.ts +5 -6
- 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 +348 -58
- 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 +2 -5
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/device_util.d.ts +1 -10
- package/types/phaser/core/device_util.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +122 -3
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +142 -15
- 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 +68 -26
- 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 -10
- package/types/phaser/core/frame_util.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +54 -20
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input.d.ts +132 -21
- package/types/phaser/core/input.d.ts.map +1 -1
- package/types/phaser/core/input_handler.d.ts +258 -25
- package/types/phaser/core/input_handler.d.ts.map +1 -1
- package/types/phaser/core/input_mouse.d.ts +59 -12
- package/types/phaser/core/input_mouse.d.ts.map +1 -1
- package/types/phaser/core/input_mspointer.d.ts +49 -15
- package/types/phaser/core/input_mspointer.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +80 -4
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/input_touch.d.ts +52 -15
- package/types/phaser/core/input_touch.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +268 -23
- package/types/phaser/core/loader.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts +0 -4
- 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 +210 -15
- 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 +95 -11
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/signal_binding.d.ts +35 -6
- 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 +94 -8
- 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 +123 -3
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +42 -3
- package/types/phaser/core/tween_data.d.ts.map +1 -1
- package/types/phaser/core/tween_easing.d.ts +0 -36
- 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 +89 -12
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +68 -11
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +21 -5
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/types/phaser/display/canvas/graphics.d.ts +0 -3
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/masker.d.ts +0 -2
- package/types/phaser/display/canvas/masker.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +0 -13
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +30 -3
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/tinter.d.ts +0 -5
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts +0 -9
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +196 -9
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +142 -16
- 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 -3
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/types/phaser/display/group.d.ts +68 -6
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +77 -15
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/sprite_batch.d.ts +4 -4
- package/types/phaser/display/sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/sprite_util.d.ts +0 -5
- package/types/phaser/display/sprite_util.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +373 -53
- 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 +0 -27
- 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 +23 -7
- 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 +0 -12
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +12 -8
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/types/phaser/display/webgl/mask_manager.d.ts +0 -2
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/render_texture.d.ts +31 -4
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/renderer.d.ts +42 -5
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +12 -2
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/fast.d.ts +12 -2
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/normal.d.ts +21 -1
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/primitive.d.ts +12 -2
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/strip.d.ts +12 -2
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader_manager.d.ts +20 -5
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/sprite_batch.d.ts +38 -1
- 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 +22 -1
- package/types/phaser/display/webgl/texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture_util.d.ts +0 -2
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/display/webgl/util.d.ts +0 -10
- package/types/phaser/display/webgl/util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +130 -10
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +42 -6
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +159 -14
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +84 -12
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +170 -19
- 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 -21
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +11 -2
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/circle.d.ts +3 -10
- package/types/phaser/geom/util/circle.d.ts.map +1 -1
- package/types/phaser/geom/util/ellipse.d.ts +0 -7
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/util/line.d.ts +5 -10
- package/types/phaser/geom/util/line.d.ts.map +1 -1
- package/types/phaser/geom/util/matrix.d.ts +0 -3
- package/types/phaser/geom/util/matrix.d.ts.map +1 -1
- package/types/phaser/geom/util/point.d.ts +0 -20
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/types/phaser/geom/util/polygon.d.ts +0 -1
- package/types/phaser/geom/util/polygon.d.ts.map +1 -1
- package/types/phaser/geom/util/rectangle.d.ts +0 -16
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/rounded_rectangle.d.ts +0 -1
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/util/math.d.ts +0 -27
- 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,14 +1,7 @@
|
|
|
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
|
/**
|
|
10
4
|
* TBD.
|
|
11
|
-
*
|
|
12
5
|
* @param {object} list - TBD.
|
|
13
6
|
* @returns {object} TBD.
|
|
14
7
|
*/
|
|
@@ -75,7 +68,6 @@ export function sortLinked(list) {
|
|
|
75
68
|
|
|
76
69
|
/**
|
|
77
70
|
* TBD.
|
|
78
|
-
*
|
|
79
71
|
* @param {object} a - TBD.
|
|
80
72
|
* @param {object} b - TBD.
|
|
81
73
|
* @returns {number} TBD.
|
|
@@ -86,7 +78,6 @@ export function compareX(a, b) {
|
|
|
86
78
|
|
|
87
79
|
/**
|
|
88
80
|
* TBD.
|
|
89
|
-
*
|
|
90
81
|
* @param {number} x - TBD.
|
|
91
82
|
* @param {number} y - TBD.
|
|
92
83
|
* @param {number} minX - TBD.
|
|
@@ -111,7 +102,6 @@ export function zOrder(x, y, minX, minY, size) {
|
|
|
111
102
|
|
|
112
103
|
/**
|
|
113
104
|
* TBD.
|
|
114
|
-
*
|
|
115
105
|
* @param {object} start - TBD.
|
|
116
106
|
* @param {number} minX - TBD.
|
|
117
107
|
* @param {number} minY - TBD.
|
|
@@ -132,7 +122,6 @@ export function indexCurve(start, minX, minY, size) {
|
|
|
132
122
|
|
|
133
123
|
/**
|
|
134
124
|
* TBD.
|
|
135
|
-
*
|
|
136
125
|
* @param {object} start - TBD.
|
|
137
126
|
* @returns {object} TBD.
|
|
138
127
|
*/
|
|
@@ -148,7 +137,6 @@ export function getLeftmost(start) {
|
|
|
148
137
|
|
|
149
138
|
/**
|
|
150
139
|
* TBD.
|
|
151
|
-
*
|
|
152
140
|
* @param {number} ax - TBD.
|
|
153
141
|
* @param {number} ay - TBD.
|
|
154
142
|
* @param {number} bx - TBD.
|
|
@@ -169,7 +157,6 @@ export function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
|
169
157
|
|
|
170
158
|
/**
|
|
171
159
|
* TBD.
|
|
172
|
-
*
|
|
173
160
|
* @param {object} p - TBD.
|
|
174
161
|
* @param {object} q - TBD.
|
|
175
162
|
* @param {object} r - TBD.
|
|
@@ -181,7 +168,6 @@ export function area(p, q, r) {
|
|
|
181
168
|
|
|
182
169
|
/**
|
|
183
170
|
* TBD.
|
|
184
|
-
*
|
|
185
171
|
* @param {object} p1 - TBD.
|
|
186
172
|
* @param {object} p2 - TBD.
|
|
187
173
|
* @returns {boolean} TBD.
|
|
@@ -192,7 +178,6 @@ export function equals(p1, p2) {
|
|
|
192
178
|
|
|
193
179
|
/**
|
|
194
180
|
* TBD.
|
|
195
|
-
*
|
|
196
181
|
* @param {object} p1 - TBD.
|
|
197
182
|
* @param {object} q1 - TBD.
|
|
198
183
|
* @param {object} p2 - TBD.
|
|
@@ -200,14 +185,11 @@ export function equals(p1, p2) {
|
|
|
200
185
|
* @returns {boolean} TBD.
|
|
201
186
|
*/
|
|
202
187
|
export function intersects(p1, q1, p2, q2) {
|
|
203
|
-
return (
|
|
204
|
-
area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0
|
|
205
|
-
);
|
|
188
|
+
return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
|
|
206
189
|
}
|
|
207
190
|
|
|
208
191
|
/**
|
|
209
192
|
* TBD.
|
|
210
|
-
*
|
|
211
193
|
* @param {object} a - TBD.
|
|
212
194
|
* @param {object} b - TBD.
|
|
213
195
|
* @returns {boolean} TBD.
|
|
@@ -215,14 +197,7 @@ export function intersects(p1, q1, p2, q2) {
|
|
|
215
197
|
export function intersectsPolygon(a, b) {
|
|
216
198
|
let p = a;
|
|
217
199
|
do {
|
|
218
|
-
if (
|
|
219
|
-
p.i !== a.i &&
|
|
220
|
-
p.next.i !== a.i &&
|
|
221
|
-
p.i !== b.i &&
|
|
222
|
-
p.next.i !== b.i &&
|
|
223
|
-
intersects(p, p.next, a, b)
|
|
224
|
-
)
|
|
225
|
-
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;
|
|
226
201
|
p = p.next;
|
|
227
202
|
} while (p !== a);
|
|
228
203
|
return false;
|
|
@@ -230,7 +205,6 @@ export function intersectsPolygon(a, b) {
|
|
|
230
205
|
|
|
231
206
|
/**
|
|
232
207
|
* TBD.
|
|
233
|
-
*
|
|
234
208
|
* @param {object} a - TBD.
|
|
235
209
|
* @param {object} b - TBD.
|
|
236
210
|
* @returns {object} TBD.
|
|
@@ -243,7 +217,6 @@ export function locallyInside(a, b) {
|
|
|
243
217
|
|
|
244
218
|
/**
|
|
245
219
|
* TBD.
|
|
246
|
-
*
|
|
247
220
|
* @param {object} a - TBD.
|
|
248
221
|
* @param {object} b - TBD.
|
|
249
222
|
* @returns {boolean} TBD.
|
|
@@ -254,10 +227,7 @@ export function middleInside(a, b) {
|
|
|
254
227
|
const px = (a.x + b.x) / 2;
|
|
255
228
|
const py = (a.y + b.y) / 2;
|
|
256
229
|
do {
|
|
257
|
-
if (
|
|
258
|
-
p.y > py !== p.next.y > py &&
|
|
259
|
-
px < ((p.next.x - p.x) * (py - p.y)) / (p.next.y - p.y) + p.x
|
|
260
|
-
) {
|
|
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) {
|
|
261
231
|
inside = !inside;
|
|
262
232
|
}
|
|
263
233
|
p = p.next;
|
|
@@ -267,7 +237,6 @@ export function middleInside(a, b) {
|
|
|
267
237
|
|
|
268
238
|
/**
|
|
269
239
|
* TBD.
|
|
270
|
-
*
|
|
271
240
|
* @param {object} a - TBD.
|
|
272
241
|
* @param {object} b - TBD.
|
|
273
242
|
* @returns {boolean} TBD.
|
|
@@ -286,7 +255,6 @@ export function isValidDiagonal(a, b) {
|
|
|
286
255
|
|
|
287
256
|
/**
|
|
288
257
|
* TBD.
|
|
289
|
-
*
|
|
290
258
|
* @param {object} a - TBD.
|
|
291
259
|
* @param {object} b - TBD.
|
|
292
260
|
* @returns {object} TBD.
|
|
@@ -309,7 +277,6 @@ export function splitPolygon(a, b) {
|
|
|
309
277
|
|
|
310
278
|
/**
|
|
311
279
|
* TBD.
|
|
312
|
-
*
|
|
313
280
|
* @param {number} i - TBD.
|
|
314
281
|
* @param {number} x - TBD.
|
|
315
282
|
* @param {number} y - TBD.
|
|
@@ -332,7 +299,6 @@ export function insertNode(i, x, y, last) {
|
|
|
332
299
|
|
|
333
300
|
/**
|
|
334
301
|
* TBD.
|
|
335
|
-
*
|
|
336
302
|
* @param {object} p - TBD.
|
|
337
303
|
*/
|
|
338
304
|
export function removeNode(p) {
|
|
@@ -348,7 +314,6 @@ export function removeNode(p) {
|
|
|
348
314
|
|
|
349
315
|
/**
|
|
350
316
|
* TBD.
|
|
351
|
-
*
|
|
352
317
|
* @param {object} ear - TBD.
|
|
353
318
|
* @returns {boolean} TBD.
|
|
354
319
|
*/
|
|
@@ -360,8 +325,7 @@ export function isEar(ear) {
|
|
|
360
325
|
// now make sure we don't have other points inside the potential ear
|
|
361
326
|
let p = ear.next.next;
|
|
362
327
|
while (p !== ear.prev) {
|
|
363
|
-
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)
|
|
364
|
-
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;
|
|
365
329
|
p = p.next;
|
|
366
330
|
}
|
|
367
331
|
return true;
|
|
@@ -369,7 +333,6 @@ export function isEar(ear) {
|
|
|
369
333
|
|
|
370
334
|
/**
|
|
371
335
|
* TBD.
|
|
372
|
-
*
|
|
373
336
|
* @param {object} ear - TBD.
|
|
374
337
|
* @param {number} minX - TBD.
|
|
375
338
|
* @param {number} minY - TBD.
|
|
@@ -420,7 +383,6 @@ export function isEarHashed(ear, minX, minY, size) {
|
|
|
420
383
|
|
|
421
384
|
/**
|
|
422
385
|
* TBD.
|
|
423
|
-
*
|
|
424
386
|
* @param {object} data - TBD.
|
|
425
387
|
* @param {number} start - TBD.
|
|
426
388
|
* @param {number} end - TBD.
|
|
@@ -449,7 +411,6 @@ export function linkedList(data, start, end, dim, clockwise) {
|
|
|
449
411
|
|
|
450
412
|
/**
|
|
451
413
|
* TBD.
|
|
452
|
-
*
|
|
453
414
|
* @param {object} start - TBD.
|
|
454
415
|
* @param {object} end - TBD.
|
|
455
416
|
* @returns {object} TBD.
|
|
@@ -476,7 +437,6 @@ export function filterPoints(start, end) {
|
|
|
476
437
|
|
|
477
438
|
/**
|
|
478
439
|
* TBD.
|
|
479
|
-
*
|
|
480
440
|
* @param {object} hole - TBD.
|
|
481
441
|
* @param {object} outerNode - TBD.
|
|
482
442
|
* @returns {object} TBD.
|
|
@@ -527,7 +487,6 @@ export function findHoleBridge(hole, outerNode) {
|
|
|
527
487
|
|
|
528
488
|
/**
|
|
529
489
|
* TBD.
|
|
530
|
-
*
|
|
531
490
|
* @param {object} hole - TBD.
|
|
532
491
|
* @param {object} outerNode - TBD.
|
|
533
492
|
*/
|
|
@@ -541,7 +500,6 @@ export function eliminateHole(hole, outerNode) {
|
|
|
541
500
|
|
|
542
501
|
/**
|
|
543
502
|
* TBD.
|
|
544
|
-
*
|
|
545
503
|
* @param {object} data - TBD.
|
|
546
504
|
* @param {object} holeIndices - TBD.
|
|
547
505
|
* @param {object} outerNode - TBD.
|
|
@@ -573,7 +531,6 @@ export function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
|
573
531
|
|
|
574
532
|
/**
|
|
575
533
|
* TBD.
|
|
576
|
-
*
|
|
577
534
|
* @param {object} start - TBD.
|
|
578
535
|
* @param {object} triangles - TBD.
|
|
579
536
|
* @param {number} dim - TBD.
|
|
@@ -602,7 +559,6 @@ export function cureLocalIntersections(start, triangles, dim) {
|
|
|
602
559
|
|
|
603
560
|
/**
|
|
604
561
|
* TBD.
|
|
605
|
-
*
|
|
606
562
|
* @param {object} start - TBD.
|
|
607
563
|
* @param {object} triangles - TBD.
|
|
608
564
|
* @param {number} dim - TBD.
|
|
@@ -635,7 +591,6 @@ export function splitEarcut(start, triangles, dim, minX, minY, size) {
|
|
|
635
591
|
|
|
636
592
|
/**
|
|
637
593
|
* TBD.
|
|
638
|
-
*
|
|
639
594
|
* @param {object} ear - TBD.
|
|
640
595
|
* @param {object} triangles - TBD.
|
|
641
596
|
* @param {number} dim - TBD.
|
|
@@ -687,7 +642,6 @@ export function earcutLinked(ear, triangles, dim, minX, minY, size, pass) {
|
|
|
687
642
|
|
|
688
643
|
/**
|
|
689
644
|
* TBD.
|
|
690
|
-
*
|
|
691
645
|
* @param {object} data - TBD.
|
|
692
646
|
* @param {object} holeIndices - TBD.
|
|
693
647
|
* @param {number} dim - TBD.
|
|
@@ -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);
|