@vpmedia/phaser 1.11.0 → 1.12.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/phaser/core/animation.js +9 -6
- package/src/phaser/core/animation_manager.js +14 -4
- package/src/phaser/core/animation_parser.js +24 -3
- package/src/phaser/core/array_set.js +1 -3
- package/src/phaser/core/cache.js +6 -6
- package/src/phaser/core/device.js +0 -2
- package/src/phaser/core/device_util.js +21 -6
- package/src/phaser/core/dom.js +34 -25
- package/src/phaser/core/event_manager.js +45 -17
- package/src/phaser/core/factory.js +26 -4
- package/src/phaser/core/frame.js +0 -2
- package/src/phaser/core/frame_data.js +0 -2
- package/src/phaser/core/game.js +8 -6
- package/src/phaser/core/input.js +17 -9
- package/src/phaser/core/input_handler.js +100 -26
- package/src/phaser/core/input_mouse.js +10 -14
- package/src/phaser/core/input_mspointer.js +10 -9
- package/src/phaser/core/input_pointer.js +58 -17
- package/src/phaser/core/input_touch.js +6 -8
- package/src/phaser/core/loader.js +168 -51
- package/src/phaser/core/loader_parser.js +4 -1
- package/src/phaser/core/raf.js +0 -2
- package/src/phaser/core/scale_manager.js +69 -25
- package/src/phaser/core/scene.js +0 -2
- package/src/phaser/core/scene_manager.js +6 -3
- package/src/phaser/core/signal.js +15 -8
- package/src/phaser/core/signal_binding.js +10 -5
- package/src/phaser/core/sound.js +20 -11
- package/src/phaser/core/sound_manager.js +56 -20
- package/src/phaser/core/sound_sprite.js +32 -32
- package/src/phaser/core/stage.js +0 -3
- package/src/phaser/core/time.js +0 -2
- package/src/phaser/core/timer.js +24 -7
- package/src/phaser/core/timer_event.js +0 -2
- package/src/phaser/core/tween.js +32 -8
- package/src/phaser/core/tween_data.js +15 -7
- package/src/phaser/core/tween_easing.js +24 -20
- package/src/phaser/core/tween_manager.js +31 -13
- package/src/phaser/core/world.js +0 -2
- package/src/phaser/display/bitmap_text.js +8 -9
- package/src/phaser/display/button.js +16 -4
- package/src/phaser/display/canvas/buffer.js +0 -2
- package/src/phaser/display/canvas/graphics.js +21 -9
- package/src/phaser/display/canvas/masker.js +1 -1
- package/src/phaser/display/canvas/renderer.js +39 -19
- package/src/phaser/display/canvas/tinter.js +43 -6
- package/src/phaser/display/canvas/util.js +1 -1
- package/src/phaser/display/display_object.js +33 -19
- package/src/phaser/display/graphics.js +52 -27
- package/src/phaser/display/graphics_data.js +0 -2
- package/src/phaser/display/graphics_data_util.js +9 -1
- package/src/phaser/display/group.js +1 -4
- package/src/phaser/display/image.js +2 -4
- package/src/phaser/display/sprite_batch.js +0 -2
- package/src/phaser/display/sprite_util.js +46 -11
- package/src/phaser/display/text.js +77 -26
- package/src/phaser/display/webgl/abstract_filter.js +0 -2
- package/src/phaser/display/webgl/base_texture.js +5 -3
- package/src/phaser/display/webgl/blend_manager.js +0 -2
- package/src/phaser/display/webgl/earcut.js +63 -22
- package/src/phaser/display/webgl/earcut_node.js +0 -2
- package/src/phaser/display/webgl/fast_sprite_batch.js +47 -46
- package/src/phaser/display/webgl/filter_manager.js +0 -2
- package/src/phaser/display/webgl/filter_texture.js +16 -5
- package/src/phaser/display/webgl/graphics.js +38 -16
- package/src/phaser/display/webgl/graphics_data.js +0 -2
- package/src/phaser/display/webgl/mask_manager.js +10 -2
- package/src/phaser/display/webgl/render_texture.js +14 -5
- package/src/phaser/display/webgl/renderer.js +39 -7
- package/src/phaser/display/webgl/shader/complex.js +0 -2
- package/src/phaser/display/webgl/shader/fast.js +8 -3
- package/src/phaser/display/webgl/shader/normal.js +42 -14
- package/src/phaser/display/webgl/shader/primitive.js +0 -2
- package/src/phaser/display/webgl/shader/strip.js +0 -2
- package/src/phaser/display/webgl/shader_manager.js +0 -2
- package/src/phaser/display/webgl/sprite_batch.js +13 -14
- package/src/phaser/display/webgl/stencil_manager.js +18 -20
- package/src/phaser/display/webgl/texture.js +10 -7
- package/src/phaser/display/webgl/util.js +1 -2
- package/src/phaser/geom/circle.js +15 -7
- package/src/phaser/geom/ellipse.js +13 -6
- package/src/phaser/geom/line.js +19 -10
- package/src/phaser/geom/matrix.js +0 -2
- package/src/phaser/geom/point.js +9 -11
- package/src/phaser/geom/polygon.js +9 -5
- package/src/phaser/geom/rectangle.js +44 -10
- package/src/phaser/geom/rounded_rectangle.js +0 -2
- package/src/phaser/geom/util/circle.js +3 -3
- package/src/phaser/geom/util/ellipse.js +3 -3
- package/src/phaser/geom/util/line.js +16 -13
- package/src/phaser/geom/util/point.js +1 -1
- package/src/phaser/geom/util/rectangle.js +17 -7
- package/src/phaser/util/math.js +37 -23
- package/tsconfig.json +110 -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 +20 -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 +48 -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 +15 -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 +35 -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 +48 -0
- package/types/phaser/display/bitmap_text.d.ts.map +1 -0
- package/types/phaser/display/button.d.ts +33 -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 +18 -0
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -0
- package/types/phaser/display/canvas/masker.d.ts +12 -0
- package/types/phaser/display/canvas/masker.d.ts.map +1 -0
- package/types/phaser/display/canvas/pool.d.ts +45 -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 +36 -0
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -0
- package/types/phaser/display/canvas/util.d.ts +70 -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 +53 -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 +7 -0
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -0
- package/types/phaser/display/group.d.ts +41 -0
- package/types/phaser/display/group.d.ts.map +1 -0
- package/types/phaser/display/image.d.ts +43 -0
- package/types/phaser/display/image.d.ts.map +1 -0
- package/types/phaser/display/sprite_batch.d.ts +6 -0
- package/types/phaser/display/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/sprite_util.d.ts +35 -0
- package/types/phaser/display/sprite_util.d.ts.map +1 -0
- package/types/phaser/display/text.d.ts +116 -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 +13 -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 +15 -0
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -0
- package/types/phaser/display/webgl/util.d.ts +41 -0
- package/types/phaser/display/webgl/util.d.ts.map +1 -0
- package/types/phaser/geom/circle.d.ts +39 -0
- package/types/phaser/geom/circle.d.ts.map +1 -0
- package/types/phaser/geom/ellipse.d.ts +18 -0
- package/types/phaser/geom/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/line.d.ts +37 -0
- package/types/phaser/geom/line.d.ts.map +1 -0
- package/types/phaser/geom/matrix.d.ts +25 -0
- package/types/phaser/geom/matrix.d.ts.map +1 -0
- package/types/phaser/geom/point.d.ts +37 -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 +63 -0
- package/types/phaser/geom/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -0
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/circle.d.ts +55 -0
- package/types/phaser/geom/util/circle.d.ts.map +1 -0
- package/types/phaser/geom/util/ellipse.d.ts +21 -0
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/util/line.d.ts +42 -0
- package/types/phaser/geom/util/line.d.ts.map +1 -0
- package/types/phaser/geom/util/matrix.d.ts +20 -0
- package/types/phaser/geom/util/matrix.d.ts.map +1 -0
- package/types/phaser/geom/util/point.d.ts +157 -0
- package/types/phaser/geom/util/point.d.ts.map +1 -0
- package/types/phaser/geom/util/polygon.d.ts +15 -0
- package/types/phaser/geom/util/polygon.d.ts.map +1 -0
- package/types/phaser/geom/util/rectangle.d.ts +124 -0
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts +15 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/util/math.d.ts +162 -0
- package/types/phaser/util/math.d.ts.map +1 -0
|
@@ -7,15 +7,22 @@
|
|
|
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
|
}
|
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import GraphicsData from './graphics_data';
|
|
8
8
|
import Point from '../../geom/point';
|
|
9
|
-
import {
|
|
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
|
|
|
@@ -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;
|
|
@@ -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) {
|
|
@@ -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);
|
|
@@ -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
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
export default class {
|
|
9
|
-
|
|
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
|
}
|
|
@@ -16,7 +16,11 @@ export function pushMask(maskData, renderSession) {
|
|
|
16
16
|
if (maskData.dirty) {
|
|
17
17
|
updateGraphics(maskData, gl);
|
|
18
18
|
}
|
|
19
|
-
if (
|
|
19
|
+
if (
|
|
20
|
+
maskData._webGL[gl.id] === undefined ||
|
|
21
|
+
maskData._webGL[gl.id].data === undefined ||
|
|
22
|
+
maskData._webGL[gl.id].data.length === 0
|
|
23
|
+
) {
|
|
20
24
|
return;
|
|
21
25
|
}
|
|
22
26
|
renderSession.stencilManager.pushStencil(maskData, maskData._webGL[gl.id].data[0], renderSession);
|
|
@@ -29,7 +33,11 @@ export function pushMask(maskData, renderSession) {
|
|
|
29
33
|
*/
|
|
30
34
|
export function popMask(maskData, renderSession) {
|
|
31
35
|
const gl = renderSession.gl;
|
|
32
|
-
if (
|
|
36
|
+
if (
|
|
37
|
+
maskData._webGL[gl.id] === undefined ||
|
|
38
|
+
maskData._webGL[gl.id].data === undefined ||
|
|
39
|
+
maskData._webGL[gl.id].data.length === 0
|
|
40
|
+
) {
|
|
33
41
|
return;
|
|
34
42
|
}
|
|
35
43
|
renderSession.stencilManager.popStencil(maskData, maskData._webGL[gl.id].data[0], renderSession);
|
|
@@ -13,12 +13,14 @@ 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
|
}
|
|
@@ -4,7 +4,27 @@
|
|
|
4
4
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
5
|
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
RENDER_WEBGL,
|
|
9
|
+
SCALE_LINEAR,
|
|
10
|
+
BLEND_NORMAL,
|
|
11
|
+
BLEND_ADD,
|
|
12
|
+
BLEND_MULTIPLY,
|
|
13
|
+
BLEND_SCREEN,
|
|
14
|
+
BLEND_OVERLAY,
|
|
15
|
+
BLEND_DARKEN,
|
|
16
|
+
BLEND_LIGHTEN,
|
|
17
|
+
BLEND_COLOR_DODGE,
|
|
18
|
+
BLEND_COLOR_BURN,
|
|
19
|
+
BLEND_HARD_LIGHT,
|
|
20
|
+
BLEND_SOFT_LIGHT,
|
|
21
|
+
BLEND_DIFFERENCE,
|
|
22
|
+
BLEND_EXCLUSION,
|
|
23
|
+
BLEND_HUE,
|
|
24
|
+
BLEND_SATURATION,
|
|
25
|
+
BLEND_COLOR,
|
|
26
|
+
BLEND_LUMINOSITY,
|
|
27
|
+
} from '../../core/const';
|
|
8
28
|
import { remove } from '../canvas/pool';
|
|
9
29
|
import { isPowerOfTwo } from '../../util/math';
|
|
10
30
|
import Point from '../../geom/point';
|
|
@@ -16,7 +36,6 @@ import WebGLStencilManager from './stencil_manager';
|
|
|
16
36
|
import WebGLBlendModeManager from './blend_manager';
|
|
17
37
|
|
|
18
38
|
export default class {
|
|
19
|
-
|
|
20
39
|
constructor(game) {
|
|
21
40
|
this.type = RENDER_WEBGL;
|
|
22
41
|
this.resolution = game.config.resolution;
|
|
@@ -94,7 +113,9 @@ export default class {
|
|
|
94
113
|
}
|
|
95
114
|
|
|
96
115
|
initContext() {
|
|
97
|
-
const gl =
|
|
116
|
+
const gl =
|
|
117
|
+
this.view.getContext('webgl', this._contextOptions) ||
|
|
118
|
+
this.view.getContext('experimental-webgl', this._contextOptions);
|
|
98
119
|
this.gl = gl;
|
|
99
120
|
if (!gl) {
|
|
100
121
|
// fail, not able to get a context
|
|
@@ -184,12 +205,24 @@ export default class {
|
|
|
184
205
|
gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id]);
|
|
185
206
|
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha);
|
|
186
207
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source);
|
|
187
|
-
gl.texParameteri(
|
|
208
|
+
gl.texParameteri(
|
|
209
|
+
gl.TEXTURE_2D,
|
|
210
|
+
gl.TEXTURE_MAG_FILTER,
|
|
211
|
+
texture.scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST
|
|
212
|
+
);
|
|
188
213
|
if (texture.mipmap && isPowerOfTwo(texture.width, texture.height)) {
|
|
189
|
-
gl.texParameteri(
|
|
214
|
+
gl.texParameteri(
|
|
215
|
+
gl.TEXTURE_2D,
|
|
216
|
+
gl.TEXTURE_MIN_FILTER,
|
|
217
|
+
texture.scaleMode === SCALE_LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST
|
|
218
|
+
);
|
|
190
219
|
gl.generateMipmap(gl.TEXTURE_2D);
|
|
191
220
|
} else {
|
|
192
|
-
gl.texParameteri(
|
|
221
|
+
gl.texParameteri(
|
|
222
|
+
gl.TEXTURE_2D,
|
|
223
|
+
gl.TEXTURE_MIN_FILTER,
|
|
224
|
+
texture.scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST
|
|
225
|
+
);
|
|
193
226
|
}
|
|
194
227
|
if (!texture._powerOf2) {
|
|
195
228
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
@@ -228,5 +261,4 @@ export default class {
|
|
|
228
261
|
b[BLEND_LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
|
|
229
262
|
window.PhaserRegistry.blendModesWebGL = b;
|
|
230
263
|
}
|
|
231
|
-
|
|
232
264
|
}
|
|
@@ -10,7 +10,6 @@ import { compileProgram } from '../util';
|
|
|
10
10
|
// the next one is used for rendering triangle strips
|
|
11
11
|
|
|
12
12
|
export default class {
|
|
13
|
-
|
|
14
13
|
constructor(gl) {
|
|
15
14
|
this.gl = gl;
|
|
16
15
|
this._UID = generateShaderID();
|
|
@@ -70,5 +69,4 @@ export default class {
|
|
|
70
69
|
this.gl = null;
|
|
71
70
|
this.attribute = null;
|
|
72
71
|
}
|
|
73
|
-
|
|
74
72
|
}
|
|
@@ -10,7 +10,6 @@ import { compileProgram } from '../util';
|
|
|
10
10
|
// this shader is used for the fast sprite rendering
|
|
11
11
|
|
|
12
12
|
export default class {
|
|
13
|
-
|
|
14
13
|
constructor(gl) {
|
|
15
14
|
this.gl = gl;
|
|
16
15
|
this._UID = generateShaderID();
|
|
@@ -82,7 +81,14 @@ export default class {
|
|
|
82
81
|
if (this.colorAttribute === -1) {
|
|
83
82
|
this.colorAttribute = 2;
|
|
84
83
|
}
|
|
85
|
-
this.attributes = [
|
|
84
|
+
this.attributes = [
|
|
85
|
+
this.aVertexPosition,
|
|
86
|
+
this.aPositionCoord,
|
|
87
|
+
this.aScale,
|
|
88
|
+
this.aRotation,
|
|
89
|
+
this.aTextureCoord,
|
|
90
|
+
this.colorAttribute,
|
|
91
|
+
];
|
|
86
92
|
// End worst hack eva //
|
|
87
93
|
this.program = program;
|
|
88
94
|
}
|
|
@@ -93,5 +99,4 @@ export default class {
|
|
|
93
99
|
this.gl = null;
|
|
94
100
|
this.attributes = null;
|
|
95
101
|
}
|
|
96
|
-
|
|
97
102
|
}
|
|
@@ -30,7 +30,6 @@ const defaultVertexSrc = [
|
|
|
30
30
|
// this shader is used for the default sprite rendering
|
|
31
31
|
|
|
32
32
|
export default class {
|
|
33
|
-
|
|
34
33
|
constructor(gl) {
|
|
35
34
|
this.gl = gl;
|
|
36
35
|
this._UID = generateShaderID();
|
|
@@ -144,26 +143,43 @@ export default class {
|
|
|
144
143
|
// KeyTexture = whatever + luminance + width 256, height 2, border 0
|
|
145
144
|
// magFilter can be: gl.LINEAR, gl.LINEAR_MIPMAP_LINEAR or gl.NEAREST
|
|
146
145
|
// wrapS/T can be: gl.CLAMP_TO_EDGE or gl.REPEAT
|
|
147
|
-
const magFilter =
|
|
148
|
-
const minFilter =
|
|
149
|
-
let wrapS =
|
|
150
|
-
let wrapT =
|
|
151
|
-
const format =
|
|
146
|
+
const magFilter = data.magFilter ? data.magFilter : gl.LINEAR;
|
|
147
|
+
const minFilter = data.minFilter ? data.minFilter : gl.LINEAR;
|
|
148
|
+
let wrapS = data.wrapS ? data.wrapS : gl.CLAMP_TO_EDGE;
|
|
149
|
+
let wrapT = data.wrapT ? data.wrapT : gl.CLAMP_TO_EDGE;
|
|
150
|
+
const format = data.luminance ? gl.LUMINANCE : gl.RGBA;
|
|
152
151
|
if (data.repeat) {
|
|
153
152
|
wrapS = gl.REPEAT;
|
|
154
153
|
wrapT = gl.REPEAT;
|
|
155
154
|
}
|
|
156
155
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, !!data.flipY);
|
|
157
156
|
if (data.width) {
|
|
158
|
-
const width =
|
|
159
|
-
const height =
|
|
160
|
-
const border =
|
|
157
|
+
const width = data.width ? data.width : 512;
|
|
158
|
+
const height = data.height ? data.height : 2;
|
|
159
|
+
const border = data.border ? data.border : 0;
|
|
161
160
|
|
|
162
161
|
// void texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels);
|
|
163
|
-
gl.texImage2D(
|
|
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
|
+
);
|
|
164
173
|
} else {
|
|
165
174
|
// void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, ImageData? pixels);
|
|
166
|
-
gl.texImage2D(
|
|
175
|
+
gl.texImage2D(
|
|
176
|
+
gl.TEXTURE_2D,
|
|
177
|
+
0,
|
|
178
|
+
format,
|
|
179
|
+
gl.RGBA,
|
|
180
|
+
gl.UNSIGNED_BYTE,
|
|
181
|
+
uniform.value.baseTexture.source
|
|
182
|
+
);
|
|
167
183
|
}
|
|
168
184
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
|
|
169
185
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
|
|
@@ -193,9 +209,22 @@ export default class {
|
|
|
193
209
|
} else if (uniform.glValueLength === 2) {
|
|
194
210
|
uniform.glFunc.call(gl, uniform.uniformLocation, uniform.value.x, uniform.value.y);
|
|
195
211
|
} else if (uniform.glValueLength === 3) {
|
|
196
|
-
uniform.glFunc.call(
|
|
212
|
+
uniform.glFunc.call(
|
|
213
|
+
gl,
|
|
214
|
+
uniform.uniformLocation,
|
|
215
|
+
uniform.value.x,
|
|
216
|
+
uniform.value.y,
|
|
217
|
+
uniform.value.z
|
|
218
|
+
);
|
|
197
219
|
} else if (uniform.glValueLength === 4) {
|
|
198
|
-
uniform.glFunc.call(
|
|
220
|
+
uniform.glFunc.call(
|
|
221
|
+
gl,
|
|
222
|
+
uniform.uniformLocation,
|
|
223
|
+
uniform.value.x,
|
|
224
|
+
uniform.value.y,
|
|
225
|
+
uniform.value.z,
|
|
226
|
+
uniform.value.w
|
|
227
|
+
);
|
|
199
228
|
} else if (uniform.type === 'sampler2D') {
|
|
200
229
|
if (uniform._init) {
|
|
201
230
|
gl.activeTexture(gl['TEXTURE' + this.textureCount]);
|
|
@@ -221,5 +250,4 @@ export default class {
|
|
|
221
250
|
this.gl = null;
|
|
222
251
|
this.attributes = null;
|
|
223
252
|
}
|
|
224
|
-
|
|
225
253
|
}
|
|
@@ -10,7 +10,6 @@ import { compileProgram } from '../util';
|
|
|
10
10
|
// the next one is used for rendering primitives
|
|
11
11
|
|
|
12
12
|
export default class {
|
|
13
|
-
|
|
14
13
|
constructor(gl) {
|
|
15
14
|
this.gl = gl;
|
|
16
15
|
this._UID = generateShaderID();
|
|
@@ -68,5 +67,4 @@ export default class {
|
|
|
68
67
|
this.gl = null;
|
|
69
68
|
this.attributes = null;
|
|
70
69
|
}
|
|
71
|
-
|
|
72
70
|
}
|
|
@@ -10,7 +10,6 @@ import { compileProgram } from '../util';
|
|
|
10
10
|
// the next one is used for rendering triangle strips
|
|
11
11
|
|
|
12
12
|
export default class {
|
|
13
|
-
|
|
14
13
|
constructor(gl) {
|
|
15
14
|
this.gl = gl;
|
|
16
15
|
this._UID = generateShaderID();
|
|
@@ -73,5 +72,4 @@ export default class {
|
|
|
73
72
|
this.gl = null;
|
|
74
73
|
this.attribute = null;
|
|
75
74
|
}
|
|
76
|
-
|
|
77
75
|
}
|
|
@@ -11,7 +11,6 @@ import FastShader from './shader/fast';
|
|
|
11
11
|
import StripShader from './shader/strip';
|
|
12
12
|
|
|
13
13
|
export default class {
|
|
14
|
-
|
|
15
14
|
constructor() {
|
|
16
15
|
this.gl = null;
|
|
17
16
|
this.primitiveShader = null;
|
|
@@ -85,5 +84,4 @@ export default class {
|
|
|
85
84
|
this.stripShader.destroy();
|
|
86
85
|
this.gl = null;
|
|
87
86
|
}
|
|
88
|
-
|
|
89
87
|
}
|
|
@@ -10,7 +10,6 @@ import NormalShader from './shader/normal';
|
|
|
10
10
|
// TODO: fix ++ +=1 conversion issues (when a is 0 than a++ is 0 but a+=1 is 1)
|
|
11
11
|
|
|
12
12
|
export default class {
|
|
13
|
-
|
|
14
13
|
constructor() {
|
|
15
14
|
this.vertSize = 5;
|
|
16
15
|
this.size = 2000; // Math.pow(2, 16) / this.vertSize;
|
|
@@ -111,8 +110,8 @@ export default class {
|
|
|
111
110
|
h1 = trim.y - aY * trim.height;
|
|
112
111
|
h0 = h1 + texture.crop.height;
|
|
113
112
|
} else {
|
|
114
|
-
w0 =
|
|
115
|
-
w1 =
|
|
113
|
+
w0 = texture.frame.width * (1 - aX);
|
|
114
|
+
w1 = texture.frame.width * -aX;
|
|
116
115
|
h0 = texture.frame.height * (1 - aY);
|
|
117
116
|
h1 = texture.frame.height * -aY;
|
|
118
117
|
}
|
|
@@ -128,17 +127,17 @@ export default class {
|
|
|
128
127
|
const positions = this.positions;
|
|
129
128
|
if (this.renderSession.roundPixels) {
|
|
130
129
|
// xy
|
|
131
|
-
positions[i] = a * w1 + c * h1 + tx | 0;
|
|
132
|
-
positions[i + 1] = d * h1 + b * w1 + ty | 0;
|
|
130
|
+
positions[i] = (a * w1 + c * h1 + tx) | 0;
|
|
131
|
+
positions[i + 1] = (d * h1 + b * w1 + ty) | 0;
|
|
133
132
|
// xy
|
|
134
|
-
positions[i + 5] = a * w0 + c * h1 + tx | 0;
|
|
135
|
-
positions[i + 6] = d * h1 + b * w0 + ty | 0;
|
|
133
|
+
positions[i + 5] = (a * w0 + c * h1 + tx) | 0;
|
|
134
|
+
positions[i + 6] = (d * h1 + b * w0 + ty) | 0;
|
|
136
135
|
// xy
|
|
137
|
-
positions[i + 10] = a * w0 + c * h0 + tx | 0;
|
|
138
|
-
positions[i + 11] = d * h0 + b * w0 + ty | 0;
|
|
136
|
+
positions[i + 10] = (a * w0 + c * h0 + tx) | 0;
|
|
137
|
+
positions[i + 11] = (d * h0 + b * w0 + ty) | 0;
|
|
139
138
|
// xy
|
|
140
|
-
positions[i + 15] = a * w1 + c * h0 + tx | 0;
|
|
141
|
-
positions[i + 16] = d * h0 + b * w1 + ty | 0;
|
|
139
|
+
positions[i + 15] = (a * w1 + c * h0 + tx) | 0;
|
|
140
|
+
positions[i + 16] = (d * h0 + b * w1 + ty) | 0;
|
|
142
141
|
} else {
|
|
143
142
|
// xy
|
|
144
143
|
positions[i] = a * w1 + c * h1 + tx;
|
|
@@ -167,7 +166,8 @@ export default class {
|
|
|
167
166
|
positions[i + 18] = uvs.y3;
|
|
168
167
|
// color and alpha
|
|
169
168
|
const tint = sprite.tint;
|
|
170
|
-
colors[i + 4] =
|
|
169
|
+
colors[i + 4] =
|
|
170
|
+
(tint >> 16) + (tint & 0xff00) + ((tint & 0xff) << 16) + ((sprite.worldAlpha * 255) << 24);
|
|
171
171
|
colors[i + 9] = colors[i + 4];
|
|
172
172
|
colors[i + 14] = colors[i + 4];
|
|
173
173
|
colors[i + 19] = colors[i + 4];
|
|
@@ -203,7 +203,7 @@ export default class {
|
|
|
203
203
|
gl.vertexAttribPointer(shader.colorAttribute, 4, gl.UNSIGNED_BYTE, true, stride, 4 * 4);
|
|
204
204
|
}
|
|
205
205
|
// upload the verts to the buffer
|
|
206
|
-
if (this.currentBatchSize >
|
|
206
|
+
if (this.currentBatchSize > this.size * 0.5) {
|
|
207
207
|
gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertices);
|
|
208
208
|
} else {
|
|
209
209
|
const view = this.positions.subarray(0, this.currentBatchSize * 4 * this.vertSize);
|
|
@@ -316,5 +316,4 @@ export default class {
|
|
|
316
316
|
this.currentBaseTexture = null;
|
|
317
317
|
this.gl = null;
|
|
318
318
|
}
|
|
319
|
-
|
|
320
319
|
}
|