@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,24 +1,11 @@
|
|
|
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
|
|
|
19
7
|
/**
|
|
20
8
|
* TBD.
|
|
21
|
-
*
|
|
22
9
|
* @returns {number} TBD.
|
|
23
10
|
*/
|
|
24
11
|
export function getStencilBufferLimit() {
|
|
@@ -30,7 +17,6 @@ export function getStencilBufferLimit() {
|
|
|
30
17
|
|
|
31
18
|
/**
|
|
32
19
|
* TBD.
|
|
33
|
-
*
|
|
34
20
|
* @returns {object[]} TBD.
|
|
35
21
|
*/
|
|
36
22
|
export function getGraphicsDataPool() {
|
|
@@ -42,7 +28,6 @@ export function getGraphicsDataPool() {
|
|
|
42
28
|
|
|
43
29
|
/**
|
|
44
30
|
* TBD.
|
|
45
|
-
*
|
|
46
31
|
* @param {object} webGL - TBD.
|
|
47
32
|
* @param {number} type - TBD.
|
|
48
33
|
* @returns {object} TBD.
|
|
@@ -67,7 +52,6 @@ export function switchMode(webGL, type) {
|
|
|
67
52
|
|
|
68
53
|
/**
|
|
69
54
|
* TBD.
|
|
70
|
-
*
|
|
71
55
|
* @param {object} graphicsData - TBD.
|
|
72
56
|
* @param {object} webGLData - TBD.
|
|
73
57
|
*/
|
|
@@ -233,7 +217,6 @@ export function buildLine(graphicsData, webGLData) {
|
|
|
233
217
|
|
|
234
218
|
/**
|
|
235
219
|
* TBD.
|
|
236
|
-
*
|
|
237
220
|
* @param {object} graphicsData - TBD.
|
|
238
221
|
* @param {object} webGLData - TBD.
|
|
239
222
|
*/
|
|
@@ -278,7 +261,6 @@ export function buildRectangle(graphicsData, webGLData) {
|
|
|
278
261
|
|
|
279
262
|
/**
|
|
280
263
|
* TBD.
|
|
281
|
-
*
|
|
282
264
|
* @param {number} fromX - TBD.
|
|
283
265
|
* @param {number} fromY - TBD.
|
|
284
266
|
* @param {number} cpX - TBD.
|
|
@@ -318,7 +300,6 @@ export function quadraticBezierCurve(fromX, fromY, cpX, cpY, toX, toY) {
|
|
|
318
300
|
|
|
319
301
|
/**
|
|
320
302
|
* TBD.
|
|
321
|
-
*
|
|
322
303
|
* @param {object} graphicsData - TBD.
|
|
323
304
|
* @param {object} webGLData - TBD.
|
|
324
305
|
*/
|
|
@@ -331,22 +312,11 @@ export function buildRoundedRectangle(graphicsData, webGLData) {
|
|
|
331
312
|
const radius = rrectData.radius;
|
|
332
313
|
let recPoints = [];
|
|
333
314
|
recPoints.push(x, y + radius);
|
|
315
|
+
recPoints = recPoints.concat(quadraticBezierCurve(x, y + height - radius, x, y + height, x + radius, y + height));
|
|
334
316
|
recPoints = recPoints.concat(
|
|
335
|
-
quadraticBezierCurve(x, y + height
|
|
336
|
-
);
|
|
337
|
-
recPoints = recPoints.concat(
|
|
338
|
-
quadraticBezierCurve(
|
|
339
|
-
x + width - radius,
|
|
340
|
-
y + height,
|
|
341
|
-
x + width,
|
|
342
|
-
y + height,
|
|
343
|
-
x + width,
|
|
344
|
-
y + height - radius
|
|
345
|
-
)
|
|
346
|
-
);
|
|
347
|
-
recPoints = recPoints.concat(
|
|
348
|
-
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)
|
|
349
318
|
);
|
|
319
|
+
recPoints = recPoints.concat(quadraticBezierCurve(x + width, y + radius, x + width, y, x + width - radius, y));
|
|
350
320
|
recPoints = recPoints.concat(quadraticBezierCurve(x + radius, y, x, y, x, y + radius));
|
|
351
321
|
if (graphicsData.fill) {
|
|
352
322
|
const color = hex2rgb(graphicsData.fillColor);
|
|
@@ -380,7 +350,6 @@ export function buildRoundedRectangle(graphicsData, webGLData) {
|
|
|
380
350
|
|
|
381
351
|
/**
|
|
382
352
|
* TBD.
|
|
383
|
-
*
|
|
384
353
|
* @param {object} graphicsData - TBD.
|
|
385
354
|
* @param {object} webGLData - TBD.
|
|
386
355
|
*/
|
|
@@ -432,7 +401,6 @@ export function buildCircle(graphicsData, webGLData) {
|
|
|
432
401
|
|
|
433
402
|
/**
|
|
434
403
|
* TBD.
|
|
435
|
-
*
|
|
436
404
|
* @param {object} graphicsData - TBD.
|
|
437
405
|
* @param {object} webGLData - TBD.
|
|
438
406
|
*/
|
|
@@ -477,7 +445,6 @@ export function buildComplexPoly(graphicsData, webGLData) {
|
|
|
477
445
|
|
|
478
446
|
/**
|
|
479
447
|
* TBD.
|
|
480
|
-
*
|
|
481
448
|
* @param {object} graphicsData - TBD.
|
|
482
449
|
* @param {object} webGLData - TBD.
|
|
483
450
|
* @returns {boolean} TBD.
|
|
@@ -517,7 +484,6 @@ export function buildPoly(graphicsData, webGLData) {
|
|
|
517
484
|
|
|
518
485
|
/**
|
|
519
486
|
* TBD.
|
|
520
|
-
*
|
|
521
487
|
* @param {object} graphics - TBD.
|
|
522
488
|
* @param {object} gl - TBD.
|
|
523
489
|
*/
|
|
@@ -607,7 +573,6 @@ export function updateGraphics(graphics, gl) {
|
|
|
607
573
|
|
|
608
574
|
/**
|
|
609
575
|
* TBD.
|
|
610
|
-
*
|
|
611
576
|
* @param {object} graphics - TBD.
|
|
612
577
|
* @param {object} renderSession - TBD.
|
|
613
578
|
*/
|
|
@@ -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,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 { updateGraphics } from './graphics';
|
|
8
2
|
|
|
9
3
|
/**
|
|
10
4
|
* TBD.
|
|
11
|
-
*
|
|
12
5
|
* @param {object} maskData - TBD.
|
|
13
6
|
* @param {object} renderSession - TBD.
|
|
14
7
|
*/
|
|
@@ -29,7 +22,6 @@ export function pushMask(maskData, renderSession) {
|
|
|
29
22
|
|
|
30
23
|
/**
|
|
31
24
|
* TBD.
|
|
32
|
-
*
|
|
33
25
|
* @param {object} maskData - TBD.
|
|
34
26
|
* @param {object} renderSession - TBD.
|
|
35
27
|
*/
|
|
@@ -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
|
}
|
|
@@ -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 {
|
|
8
2
|
RENDER_WEBGL,
|
|
9
3
|
SCALE_LINEAR,
|
|
@@ -34,8 +28,13 @@ import * as WebGLMaskManager from './mask_manager';
|
|
|
34
28
|
import { WebGLFilterManager } from './filter_manager';
|
|
35
29
|
import { WebGLStencilManager } from './stencil_manager';
|
|
36
30
|
import { WebGLBlendModeManager } from './blend_manager';
|
|
31
|
+
import { Game } from '../../core/game';
|
|
37
32
|
|
|
38
33
|
export class WebGLRenderer {
|
|
34
|
+
/**
|
|
35
|
+
* TBD.
|
|
36
|
+
* @param {Game} game - TBD.
|
|
37
|
+
*/
|
|
39
38
|
constructor(game) {
|
|
40
39
|
this.type = RENDER_WEBGL;
|
|
41
40
|
this.resolution = game.config.resolution;
|
|
@@ -75,6 +74,9 @@ export class WebGLRenderer {
|
|
|
75
74
|
this.mapBlendModes();
|
|
76
75
|
}
|
|
77
76
|
|
|
77
|
+
/**
|
|
78
|
+
* TBD.
|
|
79
|
+
*/
|
|
78
80
|
destroy() {
|
|
79
81
|
window.PhaserRegistry.GL_CONTEXTS[this.glContextId] = null;
|
|
80
82
|
this.projection = null;
|
|
@@ -100,6 +102,9 @@ export class WebGLRenderer {
|
|
|
100
102
|
window.PhaserRegistry.GL_CONTEXT_ID -= 1;
|
|
101
103
|
}
|
|
102
104
|
|
|
105
|
+
/**
|
|
106
|
+
* TBD.
|
|
107
|
+
*/
|
|
103
108
|
initRegistry() {
|
|
104
109
|
if (!window.PhaserRegistry.GL_CONTEXT_ID) {
|
|
105
110
|
window.PhaserRegistry.GL_CONTEXT_ID = 0;
|
|
@@ -112,6 +117,9 @@ export class WebGLRenderer {
|
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
|
|
120
|
+
/**
|
|
121
|
+
* TBD.
|
|
122
|
+
*/
|
|
115
123
|
initContext() {
|
|
116
124
|
const gl =
|
|
117
125
|
this.view.getContext('webgl', this._contextOptions) ||
|
|
@@ -142,6 +150,10 @@ export class WebGLRenderer {
|
|
|
142
150
|
this.resize(this.width, this.height);
|
|
143
151
|
}
|
|
144
152
|
|
|
153
|
+
/**
|
|
154
|
+
* TBD.
|
|
155
|
+
* @param stage
|
|
156
|
+
*/
|
|
145
157
|
render(stage) {
|
|
146
158
|
if (this.contextLost) {
|
|
147
159
|
return;
|
|
@@ -160,6 +172,13 @@ export class WebGLRenderer {
|
|
|
160
172
|
this.renderDisplayObject(stage, this.projection);
|
|
161
173
|
}
|
|
162
174
|
|
|
175
|
+
/**
|
|
176
|
+
* TBD.
|
|
177
|
+
* @param displayObject
|
|
178
|
+
* @param projection
|
|
179
|
+
* @param buffer
|
|
180
|
+
* @param matrix - TBD.
|
|
181
|
+
*/
|
|
163
182
|
renderDisplayObject(displayObject, projection, buffer, matrix) {
|
|
164
183
|
this.renderSession.blendModeManager.setBlendMode(BLEND_NORMAL);
|
|
165
184
|
// reset the render session data..
|
|
@@ -180,6 +199,11 @@ export class WebGLRenderer {
|
|
|
180
199
|
this.spriteBatch.end();
|
|
181
200
|
}
|
|
182
201
|
|
|
202
|
+
/**
|
|
203
|
+
* TBD.
|
|
204
|
+
* @param {number} width - TBD.
|
|
205
|
+
* @param {number} height - TBD.
|
|
206
|
+
*/
|
|
183
207
|
resize(width, height) {
|
|
184
208
|
this.width = width * this.resolution;
|
|
185
209
|
this.height = height * this.resolution;
|
|
@@ -194,6 +218,10 @@ export class WebGLRenderer {
|
|
|
194
218
|
this.projection.y = -this.height / 2 / this.resolution;
|
|
195
219
|
}
|
|
196
220
|
|
|
221
|
+
/**
|
|
222
|
+
* TBD.
|
|
223
|
+
* @param texture
|
|
224
|
+
*/
|
|
197
225
|
updateTexture(texture) {
|
|
198
226
|
if (!texture.hasLoaded) {
|
|
199
227
|
return false;
|
|
@@ -205,11 +233,7 @@ export class WebGLRenderer {
|
|
|
205
233
|
gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id]);
|
|
206
234
|
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha);
|
|
207
235
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source);
|
|
208
|
-
gl.texParameteri(
|
|
209
|
-
gl.TEXTURE_2D,
|
|
210
|
-
gl.TEXTURE_MAG_FILTER,
|
|
211
|
-
texture.scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST
|
|
212
|
-
);
|
|
236
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST);
|
|
213
237
|
if (texture.mipmap && isPowerOfTwo(texture.width, texture.height)) {
|
|
214
238
|
gl.texParameteri(
|
|
215
239
|
gl.TEXTURE_2D,
|
|
@@ -236,6 +260,9 @@ export class WebGLRenderer {
|
|
|
236
260
|
return true;
|
|
237
261
|
}
|
|
238
262
|
|
|
263
|
+
/**
|
|
264
|
+
* TBD.
|
|
265
|
+
*/
|
|
239
266
|
mapBlendModes() {
|
|
240
267
|
if (window.PhaserRegistry.blendModesWebGL) {
|
|
241
268
|
return;
|
|
@@ -1,15 +1,13 @@
|
|
|
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 { generateShaderID } from '../../../util/math';
|
|
8
2
|
import { compileProgram } from '../util';
|
|
9
3
|
|
|
10
4
|
// the next one is used for rendering triangle strips
|
|
11
5
|
|
|
12
6
|
export class ComplexPrimitiveShader {
|
|
7
|
+
/**
|
|
8
|
+
* TBD.
|
|
9
|
+
* @param gl - TBD.
|
|
10
|
+
*/
|
|
13
11
|
constructor(gl) {
|
|
14
12
|
this.gl = gl;
|
|
15
13
|
this._UID = generateShaderID();
|
|
@@ -44,6 +42,9 @@ export class ComplexPrimitiveShader {
|
|
|
44
42
|
this.init();
|
|
45
43
|
}
|
|
46
44
|
|
|
45
|
+
/**
|
|
46
|
+
* TBD.
|
|
47
|
+
*/
|
|
47
48
|
init() {
|
|
48
49
|
const gl = this.gl;
|
|
49
50
|
const program = compileProgram(gl, this.vertexSrc, this.fragmentSrc);
|
|
@@ -63,6 +64,9 @@ export class ComplexPrimitiveShader {
|
|
|
63
64
|
this.program = program;
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
/**
|
|
68
|
+
* TBD.
|
|
69
|
+
*/
|
|
66
70
|
destroy() {
|
|
67
71
|
this.gl.deleteProgram(this.program);
|
|
68
72
|
this.uniforms = null;
|
|
@@ -1,15 +1,13 @@
|
|
|
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 { generateShaderID } from '../../../util/math';
|
|
8
2
|
import { compileProgram } from '../util';
|
|
9
3
|
|
|
10
4
|
// this shader is used for the fast sprite rendering
|
|
11
5
|
|
|
12
6
|
export class FastShader {
|
|
7
|
+
/**
|
|
8
|
+
* TBD.
|
|
9
|
+
* @param gl - TBD.
|
|
10
|
+
*/
|
|
13
11
|
constructor(gl) {
|
|
14
12
|
this.gl = gl;
|
|
15
13
|
this._UID = generateShaderID();
|
|
@@ -56,6 +54,9 @@ export class FastShader {
|
|
|
56
54
|
this.init();
|
|
57
55
|
}
|
|
58
56
|
|
|
57
|
+
/**
|
|
58
|
+
* TBD.
|
|
59
|
+
*/
|
|
59
60
|
init() {
|
|
60
61
|
const gl = this.gl;
|
|
61
62
|
const program = compileProgram(gl, this.vertexSrc, this.fragmentSrc);
|
|
@@ -93,6 +94,9 @@ export class FastShader {
|
|
|
93
94
|
this.program = program;
|
|
94
95
|
}
|
|
95
96
|
|
|
97
|
+
/**
|
|
98
|
+
* TBD.
|
|
99
|
+
*/
|
|
96
100
|
destroy() {
|
|
97
101
|
this.gl.deleteProgram(this.program);
|
|
98
102
|
this.uniforms = null;
|
|
@@ -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 { generateShaderID } from '../../../util/math';
|
|
8
2
|
import { compileProgram } from '../util';
|
|
9
3
|
|
|
@@ -30,6 +24,10 @@ const defaultVertexSrc = [
|
|
|
30
24
|
// this shader is used for the default sprite rendering
|
|
31
25
|
|
|
32
26
|
export class NormalShader {
|
|
27
|
+
/**
|
|
28
|
+
* TBD.
|
|
29
|
+
* @param gl - TBD.
|
|
30
|
+
*/
|
|
33
31
|
constructor(gl) {
|
|
34
32
|
this.gl = gl;
|
|
35
33
|
this._UID = generateShaderID();
|
|
@@ -51,6 +49,9 @@ export class NormalShader {
|
|
|
51
49
|
this.init();
|
|
52
50
|
}
|
|
53
51
|
|
|
52
|
+
/**
|
|
53
|
+
* TBD.
|
|
54
|
+
*/
|
|
54
55
|
init() {
|
|
55
56
|
const gl = this.gl;
|
|
56
57
|
const program = compileProgram(gl, this.vertexSrc || defaultVertexSrc, this.fragmentSrc);
|
|
@@ -84,6 +85,9 @@ export class NormalShader {
|
|
|
84
85
|
this.program = program;
|
|
85
86
|
}
|
|
86
87
|
|
|
88
|
+
/**
|
|
89
|
+
* TBD.
|
|
90
|
+
*/
|
|
87
91
|
initUniforms() {
|
|
88
92
|
this.textureCount = 1;
|
|
89
93
|
const gl = this.gl;
|
|
@@ -125,6 +129,10 @@ export class NormalShader {
|
|
|
125
129
|
}
|
|
126
130
|
}
|
|
127
131
|
|
|
132
|
+
/**
|
|
133
|
+
* TBD.
|
|
134
|
+
* @param uniform
|
|
135
|
+
*/
|
|
128
136
|
initSampler2D(uniform) {
|
|
129
137
|
if (!uniform.value || !uniform.value.baseTexture || !uniform.value.baseTexture.hasLoaded) {
|
|
130
138
|
return;
|
|
@@ -159,27 +167,10 @@ export class NormalShader {
|
|
|
159
167
|
const border = data.border ? data.border : 0;
|
|
160
168
|
|
|
161
169
|
// void texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels);
|
|
162
|
-
gl.texImage2D(
|
|
163
|
-
gl.TEXTURE_2D,
|
|
164
|
-
0,
|
|
165
|
-
format,
|
|
166
|
-
width,
|
|
167
|
-
height,
|
|
168
|
-
border,
|
|
169
|
-
format,
|
|
170
|
-
gl.UNSIGNED_BYTE,
|
|
171
|
-
null
|
|
172
|
-
);
|
|
170
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, border, format, gl.UNSIGNED_BYTE, null);
|
|
173
171
|
} else {
|
|
174
172
|
// void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, ImageData? pixels);
|
|
175
|
-
gl.texImage2D(
|
|
176
|
-
gl.TEXTURE_2D,
|
|
177
|
-
0,
|
|
178
|
-
format,
|
|
179
|
-
gl.RGBA,
|
|
180
|
-
gl.UNSIGNED_BYTE,
|
|
181
|
-
uniform.value.baseTexture.source
|
|
182
|
-
);
|
|
173
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, format, gl.RGBA, gl.UNSIGNED_BYTE, uniform.value.baseTexture.source);
|
|
183
174
|
}
|
|
184
175
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
|
|
185
176
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
|
|
@@ -191,6 +182,9 @@ export class NormalShader {
|
|
|
191
182
|
this.textureCount += 1;
|
|
192
183
|
}
|
|
193
184
|
|
|
185
|
+
/**
|
|
186
|
+
* TBD.
|
|
187
|
+
*/
|
|
194
188
|
syncUniforms() {
|
|
195
189
|
this.textureCount = 1;
|
|
196
190
|
let uniform;
|
|
@@ -209,13 +203,7 @@ export class NormalShader {
|
|
|
209
203
|
} else if (uniform.glValueLength === 2) {
|
|
210
204
|
uniform.glFunc.call(gl, uniform.uniformLocation, uniform.value.x, uniform.value.y);
|
|
211
205
|
} else if (uniform.glValueLength === 3) {
|
|
212
|
-
uniform.glFunc.call(
|
|
213
|
-
gl,
|
|
214
|
-
uniform.uniformLocation,
|
|
215
|
-
uniform.value.x,
|
|
216
|
-
uniform.value.y,
|
|
217
|
-
uniform.value.z
|
|
218
|
-
);
|
|
206
|
+
uniform.glFunc.call(gl, uniform.uniformLocation, uniform.value.x, uniform.value.y, uniform.value.z);
|
|
219
207
|
} else if (uniform.glValueLength === 4) {
|
|
220
208
|
uniform.glFunc.call(
|
|
221
209
|
gl,
|
|
@@ -244,6 +232,9 @@ export class NormalShader {
|
|
|
244
232
|
}
|
|
245
233
|
}
|
|
246
234
|
|
|
235
|
+
/**
|
|
236
|
+
* TBD.
|
|
237
|
+
*/
|
|
247
238
|
destroy() {
|
|
248
239
|
this.gl.deleteProgram(this.program);
|
|
249
240
|
this.uniforms = null;
|
|
@@ -1,15 +1,13 @@
|
|
|
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 { generateShaderID } from '../../../util/math';
|
|
8
2
|
import { compileProgram } from '../util';
|
|
9
3
|
|
|
10
4
|
// the next one is used for rendering primitives
|
|
11
5
|
|
|
12
6
|
export class PrimitiveShader {
|
|
7
|
+
/**
|
|
8
|
+
* TBD.
|
|
9
|
+
* @param gl - TBD.
|
|
10
|
+
*/
|
|
13
11
|
constructor(gl) {
|
|
14
12
|
this.gl = gl;
|
|
15
13
|
this._UID = generateShaderID();
|
|
@@ -43,6 +41,9 @@ export class PrimitiveShader {
|
|
|
43
41
|
this.init();
|
|
44
42
|
}
|
|
45
43
|
|
|
44
|
+
/**
|
|
45
|
+
* TBD.
|
|
46
|
+
*/
|
|
46
47
|
init() {
|
|
47
48
|
const gl = this.gl;
|
|
48
49
|
const program = compileProgram(gl, this.vertexSrc, this.fragmentSrc);
|
|
@@ -61,6 +62,9 @@ export class PrimitiveShader {
|
|
|
61
62
|
this.program = program;
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
/**
|
|
66
|
+
* TBD.
|
|
67
|
+
*/
|
|
64
68
|
destroy() {
|
|
65
69
|
this.gl.deleteProgram(this.program);
|
|
66
70
|
this.uniforms = null;
|
|
@@ -1,15 +1,13 @@
|
|
|
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 { generateShaderID } from '../../../util/math';
|
|
8
2
|
import { compileProgram } from '../util';
|
|
9
3
|
|
|
10
4
|
// the next one is used for rendering triangle strips
|
|
11
5
|
|
|
12
6
|
export class StripShader {
|
|
7
|
+
/**
|
|
8
|
+
* TBD.
|
|
9
|
+
* @param gl - TBD.
|
|
10
|
+
*/
|
|
13
11
|
constructor(gl) {
|
|
14
12
|
this.gl = gl;
|
|
15
13
|
this._UID = generateShaderID();
|
|
@@ -47,6 +45,9 @@ export class StripShader {
|
|
|
47
45
|
this.init();
|
|
48
46
|
}
|
|
49
47
|
|
|
48
|
+
/**
|
|
49
|
+
* TBD.
|
|
50
|
+
*/
|
|
50
51
|
init() {
|
|
51
52
|
const gl = this.gl;
|
|
52
53
|
const program = compileProgram(gl, this.vertexSrc, this.fragmentSrc);
|
|
@@ -66,6 +67,9 @@ export class StripShader {
|
|
|
66
67
|
this.program = program;
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
/**
|
|
71
|
+
* TBD.
|
|
72
|
+
*/
|
|
69
73
|
destroy() {
|
|
70
74
|
this.gl.deleteProgram(this.program);
|
|
71
75
|
this.uniforms = null;
|