@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
|
@@ -13,7 +13,6 @@ import { snapToCeil } from '../util/math';
|
|
|
13
13
|
import { renderCanvas, renderWebGL, getBounds } from './sprite_util';
|
|
14
14
|
|
|
15
15
|
export default class extends Image {
|
|
16
|
-
|
|
17
16
|
constructor(game, x, y, text = '', style = {}) {
|
|
18
17
|
super(game, x, y, null);
|
|
19
18
|
this.game = game;
|
|
@@ -60,7 +59,14 @@ export default class extends Image {
|
|
|
60
59
|
super.destroy();
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
setShadow(
|
|
62
|
+
setShadow(
|
|
63
|
+
x = 0,
|
|
64
|
+
y = 0,
|
|
65
|
+
color = 'rgba(0, 0, 0, 1)',
|
|
66
|
+
blur = 0,
|
|
67
|
+
shadowStroke = true,
|
|
68
|
+
shadowFill = true
|
|
69
|
+
) {
|
|
64
70
|
this.style.shadowOffsetX = x;
|
|
65
71
|
this.style.shadowOffsetY = y;
|
|
66
72
|
this.style.shadowColor = color;
|
|
@@ -139,7 +145,12 @@ export default class extends Image {
|
|
|
139
145
|
if (tabs === 0) {
|
|
140
146
|
// Simple layout (no tabs)
|
|
141
147
|
lineWidth = this.style.strokeThickness + this.padding.x;
|
|
142
|
-
if (
|
|
148
|
+
if (
|
|
149
|
+
this.colors.length > 0 ||
|
|
150
|
+
this.strokeColors.length > 0 ||
|
|
151
|
+
this.fontWeights.length > 0 ||
|
|
152
|
+
this.fontStyles.length > 0
|
|
153
|
+
) {
|
|
143
154
|
lineWidth += this.measureLine(lines[i]);
|
|
144
155
|
} else {
|
|
145
156
|
lineWidth += this.context.measureText(lines[i]).width;
|
|
@@ -156,7 +167,12 @@ export default class extends Image {
|
|
|
156
167
|
let tab = 0;
|
|
157
168
|
for (let c = 0; c < line.length; c += 1) {
|
|
158
169
|
let section = 0;
|
|
159
|
-
if (
|
|
170
|
+
if (
|
|
171
|
+
this.colors.length > 0 ||
|
|
172
|
+
this.strokeColors.length > 0 ||
|
|
173
|
+
this.fontWeights.length > 0 ||
|
|
174
|
+
this.fontStyles.length > 0
|
|
175
|
+
) {
|
|
160
176
|
section = this.measureLine(line[c]);
|
|
161
177
|
} else {
|
|
162
178
|
section = Math.ceil(this.context.measureText(line[c]).width);
|
|
@@ -169,7 +185,12 @@ export default class extends Image {
|
|
|
169
185
|
} else {
|
|
170
186
|
for (let c = 0; c < line.length; c += 1) {
|
|
171
187
|
// How far to the next tab?
|
|
172
|
-
if (
|
|
188
|
+
if (
|
|
189
|
+
this.colors.length > 0 ||
|
|
190
|
+
this.strokeColors.length > 0 ||
|
|
191
|
+
this.fontWeights.length > 0 ||
|
|
192
|
+
this.fontStyles.length > 0
|
|
193
|
+
) {
|
|
173
194
|
lineWidth += this.measureLine(line[c]);
|
|
174
195
|
} else {
|
|
175
196
|
lineWidth += Math.ceil(this.context.measureText(line[c]).width);
|
|
@@ -192,7 +213,7 @@ export default class extends Image {
|
|
|
192
213
|
}
|
|
193
214
|
// Adjust for line spacing
|
|
194
215
|
if (lineSpacing !== 0) {
|
|
195
|
-
height +=
|
|
216
|
+
height += lineSpacing > 0 ? lineSpacing * lines.length : lineSpacing * (lines.length - 1);
|
|
196
217
|
}
|
|
197
218
|
this.canvas.height = height * this._res;
|
|
198
219
|
this.context.scale(this._res, this._res);
|
|
@@ -214,9 +235,9 @@ export default class extends Image {
|
|
|
214
235
|
for (let i = 0; i < drawnLines; i += 1) {
|
|
215
236
|
// Split the line by
|
|
216
237
|
linePositionX = this.style.strokeThickness / 2;
|
|
217
|
-
linePositionY =
|
|
238
|
+
linePositionY = this.style.strokeThickness / 2 + i * lineHeight + fontProperties.ascent;
|
|
218
239
|
if (i > 0) {
|
|
219
|
-
linePositionY +=
|
|
240
|
+
linePositionY += lineSpacing * i;
|
|
220
241
|
}
|
|
221
242
|
if (this.style.align === 'right') {
|
|
222
243
|
linePositionX += maxLineWidth - lineWidths[i];
|
|
@@ -227,7 +248,12 @@ export default class extends Image {
|
|
|
227
248
|
linePositionX = Math.round(linePositionX);
|
|
228
249
|
linePositionY = Math.round(linePositionY);
|
|
229
250
|
}
|
|
230
|
-
if (
|
|
251
|
+
if (
|
|
252
|
+
this.colors.length > 0 ||
|
|
253
|
+
this.strokeColors.length > 0 ||
|
|
254
|
+
this.fontWeights.length > 0 ||
|
|
255
|
+
this.fontStyles.length > 0
|
|
256
|
+
) {
|
|
231
257
|
this.updateLine(lines[i], linePositionX, linePositionY);
|
|
232
258
|
} else {
|
|
233
259
|
if (this.style.stroke && this.style.strokeThickness) {
|
|
@@ -456,7 +482,9 @@ export default class extends Image {
|
|
|
456
482
|
// if wordWrapWidth is too small for even a single
|
|
457
483
|
// letter, shame user failure with a fatal error
|
|
458
484
|
if (!newWord.length) {
|
|
459
|
-
throw new Error(
|
|
485
|
+
throw new Error(
|
|
486
|
+
"This text's wordWrapWidth setting is less than a single character!"
|
|
487
|
+
);
|
|
460
488
|
}
|
|
461
489
|
// replace current word in array with remainder
|
|
462
490
|
const secondPart = word.substr(newWord.length);
|
|
@@ -465,10 +493,13 @@ export default class extends Image {
|
|
|
465
493
|
out += newWord;
|
|
466
494
|
}
|
|
467
495
|
// if existing word length is 0, don't include it
|
|
468
|
-
const offset =
|
|
496
|
+
const offset = words[j].length ? j : j + 1;
|
|
469
497
|
// collapse rest of sentence
|
|
470
498
|
// remove any trailing white space
|
|
471
|
-
const remainder = words
|
|
499
|
+
const remainder = words
|
|
500
|
+
.slice(offset)
|
|
501
|
+
.join(' ')
|
|
502
|
+
.replace(/[ \n]*$/gi, '');
|
|
472
503
|
// prepend remainder to next line
|
|
473
504
|
lines[i + 1] = remainder + ' ' + (lines[i + 1] || '');
|
|
474
505
|
linesCount = lines.length;
|
|
@@ -536,11 +567,16 @@ export default class extends Image {
|
|
|
536
567
|
// larger | smaller
|
|
537
568
|
// {number} (em | ex | ch | rem | vh | vw | vmin | vmax | px | mm | cm | in | pt | pc | %)
|
|
538
569
|
// font-family - rest (but identifiers or quoted with comma separation)
|
|
539
|
-
const m = font.match(
|
|
570
|
+
const m = font.match(
|
|
571
|
+
/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/
|
|
572
|
+
);
|
|
540
573
|
if (m) {
|
|
541
574
|
let family = m[5].trim();
|
|
542
575
|
// If it looks like the value should be quoted, but isn't, then quote it.
|
|
543
|
-
if (
|
|
576
|
+
if (
|
|
577
|
+
!/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(family) &&
|
|
578
|
+
!/['",]/.exec(family)
|
|
579
|
+
) {
|
|
544
580
|
family = "'" + family + "'";
|
|
545
581
|
}
|
|
546
582
|
return {
|
|
@@ -560,15 +596,25 @@ export default class extends Image {
|
|
|
560
596
|
const parts = [];
|
|
561
597
|
let v;
|
|
562
598
|
v = components.fontStyle;
|
|
563
|
-
if (v && v !== 'normal') {
|
|
599
|
+
if (v && v !== 'normal') {
|
|
600
|
+
parts.push(v);
|
|
601
|
+
}
|
|
564
602
|
v = components.fontVariant;
|
|
565
|
-
if (v && v !== 'normal') {
|
|
603
|
+
if (v && v !== 'normal') {
|
|
604
|
+
parts.push(v);
|
|
605
|
+
}
|
|
566
606
|
v = components.fontWeight;
|
|
567
|
-
if (v && v !== 'normal') {
|
|
607
|
+
if (v && v !== 'normal') {
|
|
608
|
+
parts.push(v);
|
|
609
|
+
}
|
|
568
610
|
v = components.fontSize;
|
|
569
|
-
if (v && v !== 'medium') {
|
|
611
|
+
if (v && v !== 'medium') {
|
|
612
|
+
parts.push(v);
|
|
613
|
+
}
|
|
570
614
|
v = components.fontFamily;
|
|
571
|
-
if (v) {
|
|
615
|
+
if (v) {
|
|
616
|
+
parts.push(v);
|
|
617
|
+
}
|
|
572
618
|
if (!parts.length) {
|
|
573
619
|
// Fallback to whatever value the 'font' was
|
|
574
620
|
parts.push(components.font);
|
|
@@ -649,18 +695,18 @@ export default class extends Image {
|
|
|
649
695
|
if (this.style.boundsAlignH === 'right') {
|
|
650
696
|
x += this.textBounds.width - this.canvas.width / this.resolution;
|
|
651
697
|
} else if (this.style.boundsAlignH === 'center') {
|
|
652
|
-
x += this.textBounds.halfWidth -
|
|
698
|
+
x += this.textBounds.halfWidth - this.canvas.width / this.resolution / 2;
|
|
653
699
|
}
|
|
654
700
|
if (this.style.boundsAlignV === 'bottom') {
|
|
655
701
|
y += this.textBounds.height - this.canvas.height / this.resolution;
|
|
656
702
|
} else if (this.style.boundsAlignV === 'middle') {
|
|
657
|
-
y += this.textBounds.halfHeight -
|
|
703
|
+
y += this.textBounds.halfHeight - this.canvas.height / this.resolution / 2;
|
|
658
704
|
}
|
|
659
705
|
this.pivot.x = -x;
|
|
660
706
|
this.pivot.y = -y;
|
|
661
707
|
}
|
|
662
708
|
// Can't render something with a zero sized dimension
|
|
663
|
-
this.renderable =
|
|
709
|
+
this.renderable = w !== 0 && h !== 0;
|
|
664
710
|
this.texture.requiresReTint = true;
|
|
665
711
|
this.texture.baseTexture.dirty();
|
|
666
712
|
}
|
|
@@ -697,7 +743,10 @@ export default class extends Image {
|
|
|
697
743
|
|
|
698
744
|
getFontPropertiesContext() {
|
|
699
745
|
if (!window.PhaserRegistry.fontPropertiesContext) {
|
|
700
|
-
window.PhaserRegistry.fontPropertiesContext = this.getFontPropertiesCanvas().getContext(
|
|
746
|
+
window.PhaserRegistry.fontPropertiesContext = this.getFontPropertiesCanvas().getContext(
|
|
747
|
+
'2d',
|
|
748
|
+
{ willReadFrequently: true }
|
|
749
|
+
);
|
|
701
750
|
}
|
|
702
751
|
return window.PhaserRegistry.fontPropertiesContext;
|
|
703
752
|
}
|
|
@@ -713,7 +762,7 @@ export default class extends Image {
|
|
|
713
762
|
const width = Math.ceil(context.measureText('|MÉq').width);
|
|
714
763
|
let baseline = Math.ceil(context.measureText('|MÉq').width);
|
|
715
764
|
const height = 2 * baseline;
|
|
716
|
-
baseline = baseline * 1.4 | 0;
|
|
765
|
+
baseline = (baseline * 1.4) | 0;
|
|
717
766
|
canvas.width = width;
|
|
718
767
|
canvas.height = height;
|
|
719
768
|
context.fillStyle = '#f00';
|
|
@@ -815,7 +864,10 @@ export default class extends Image {
|
|
|
815
864
|
let mutatedValue = value || 'Arial';
|
|
816
865
|
mutatedValue = mutatedValue.trim();
|
|
817
866
|
// If it looks like the value should be quoted, but isn't, then quote it.
|
|
818
|
-
if (
|
|
867
|
+
if (
|
|
868
|
+
!/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(mutatedValue) &&
|
|
869
|
+
!/['",]/.exec(mutatedValue)
|
|
870
|
+
) {
|
|
819
871
|
mutatedValue = "'" + mutatedValue + "'";
|
|
820
872
|
}
|
|
821
873
|
|
|
@@ -1082,5 +1134,4 @@ export default class extends Image {
|
|
|
1082
1134
|
this.scale.y = value / this.texture.frame.height;
|
|
1083
1135
|
this._height = value;
|
|
1084
1136
|
}
|
|
1085
|
-
|
|
1086
1137
|
}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
import { removeByCanvas } from '../canvas/pool';
|
|
8
8
|
|
|
9
9
|
export default class {
|
|
10
|
-
|
|
11
10
|
constructor(source, scaleMode) {
|
|
12
11
|
this.resolution = 1;
|
|
13
12
|
this.width = 100;
|
|
@@ -22,7 +21,11 @@ export default class {
|
|
|
22
21
|
this._powerOf2 = false;
|
|
23
22
|
this._dirty = [true, true, true, true];
|
|
24
23
|
if (source) {
|
|
25
|
-
if (
|
|
24
|
+
if (
|
|
25
|
+
(this.source.complete || this.source.getContext) &&
|
|
26
|
+
this.source.width &&
|
|
27
|
+
this.source.height
|
|
28
|
+
) {
|
|
26
29
|
this.hasLoaded = true;
|
|
27
30
|
this.width = this.source.naturalWidth || this.source.width;
|
|
28
31
|
this.height = this.source.naturalHeight || this.source.height;
|
|
@@ -64,5 +67,4 @@ export default class {
|
|
|
64
67
|
this._glTextures.length = 0;
|
|
65
68
|
this.dirty();
|
|
66
69
|
}
|
|
67
|
-
|
|
68
70
|
}
|
|
@@ -93,14 +93,14 @@ export function compareX(a, b) {
|
|
|
93
93
|
*/
|
|
94
94
|
export function zOrder(x, y, minX, minY, size) {
|
|
95
95
|
// coords are transformed into non-negative 15-bit integer range
|
|
96
|
-
x = 32767 * (x - minX) / size;
|
|
97
|
-
y = 32767 * (y - minY) / size;
|
|
98
|
-
x = (x | (x << 8)) &
|
|
99
|
-
x = (x | (x << 4)) &
|
|
96
|
+
x = (32767 * (x - minX)) / size;
|
|
97
|
+
y = (32767 * (y - minY)) / size;
|
|
98
|
+
x = (x | (x << 8)) & 0x00ff00ff;
|
|
99
|
+
x = (x | (x << 4)) & 0x0f0f0f0f;
|
|
100
100
|
x = (x | (x << 2)) & 0x33333333;
|
|
101
101
|
x = (x | (x << 1)) & 0x55555555;
|
|
102
|
-
y = (y | (y << 8)) &
|
|
103
|
-
y = (y | (y << 4)) &
|
|
102
|
+
y = (y | (y << 8)) & 0x00ff00ff;
|
|
103
|
+
y = (y | (y << 4)) & 0x0f0f0f0f;
|
|
104
104
|
y = (y | (y << 2)) & 0x33333333;
|
|
105
105
|
y = (y | (y << 1)) & 0x55555555;
|
|
106
106
|
return x | (y << 1);
|
|
@@ -154,7 +154,11 @@ export function getLeftmost(start) {
|
|
|
154
154
|
* @returns {object} TBD
|
|
155
155
|
*/
|
|
156
156
|
export function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
157
|
-
return (
|
|
157
|
+
return (
|
|
158
|
+
(cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
|
|
159
|
+
(ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
|
|
160
|
+
(bx - px) * (cy - py) - (cx - px) * (by - py) >= 0
|
|
161
|
+
);
|
|
158
162
|
}
|
|
159
163
|
|
|
160
164
|
/**
|
|
@@ -187,7 +191,9 @@ export function equals(p1, p2) {
|
|
|
187
191
|
* @returns {boolean} TBD
|
|
188
192
|
*/
|
|
189
193
|
export function intersects(p1, q1, p2, q2) {
|
|
190
|
-
return
|
|
194
|
+
return (
|
|
195
|
+
area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0
|
|
196
|
+
);
|
|
191
197
|
}
|
|
192
198
|
|
|
193
199
|
/**
|
|
@@ -199,7 +205,14 @@ export function intersects(p1, q1, p2, q2) {
|
|
|
199
205
|
export function intersectsPolygon(a, b) {
|
|
200
206
|
let p = a;
|
|
201
207
|
do {
|
|
202
|
-
if (
|
|
208
|
+
if (
|
|
209
|
+
p.i !== a.i &&
|
|
210
|
+
p.next.i !== a.i &&
|
|
211
|
+
p.i !== b.i &&
|
|
212
|
+
p.next.i !== b.i &&
|
|
213
|
+
intersects(p, p.next, a, b)
|
|
214
|
+
)
|
|
215
|
+
return true;
|
|
203
216
|
p = p.next;
|
|
204
217
|
} while (p !== a);
|
|
205
218
|
return false;
|
|
@@ -212,7 +225,9 @@ export function intersectsPolygon(a, b) {
|
|
|
212
225
|
* @returns {object} TBD
|
|
213
226
|
*/
|
|
214
227
|
export function locallyInside(a, b) {
|
|
215
|
-
return area(a.prev, a, a.next) < 0
|
|
228
|
+
return area(a.prev, a, a.next) < 0
|
|
229
|
+
? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0
|
|
230
|
+
: area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
|
|
216
231
|
}
|
|
217
232
|
|
|
218
233
|
/**
|
|
@@ -227,7 +242,10 @@ export function middleInside(a, b) {
|
|
|
227
242
|
const px = (a.x + b.x) / 2;
|
|
228
243
|
const py = (a.y + b.y) / 2;
|
|
229
244
|
do {
|
|
230
|
-
if (
|
|
245
|
+
if (
|
|
246
|
+
p.y > py !== p.next.y > py &&
|
|
247
|
+
px < ((p.next.x - p.x) * (py - p.y)) / (p.next.y - p.y) + p.x
|
|
248
|
+
) {
|
|
231
249
|
inside = !inside;
|
|
232
250
|
}
|
|
233
251
|
p = p.next;
|
|
@@ -242,7 +260,15 @@ export function middleInside(a, b) {
|
|
|
242
260
|
* @returns {boolean} TBD
|
|
243
261
|
*/
|
|
244
262
|
export function isValidDiagonal(a, b) {
|
|
245
|
-
return
|
|
263
|
+
return (
|
|
264
|
+
equals(a, b) ||
|
|
265
|
+
(a.next.i !== b.i &&
|
|
266
|
+
a.prev.i !== b.i &&
|
|
267
|
+
!intersectsPolygon(a, b) &&
|
|
268
|
+
locallyInside(a, b) &&
|
|
269
|
+
locallyInside(b, a) &&
|
|
270
|
+
middleInside(a, b))
|
|
271
|
+
);
|
|
246
272
|
}
|
|
247
273
|
|
|
248
274
|
/**
|
|
@@ -317,7 +343,8 @@ export function isEar(ear) {
|
|
|
317
343
|
// now make sure we don't have other points inside the potential ear
|
|
318
344
|
let p = ear.next.next;
|
|
319
345
|
while (p !== ear.prev) {
|
|
320
|
-
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)
|
|
346
|
+
if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
|
|
347
|
+
return false;
|
|
321
348
|
p = p.next;
|
|
322
349
|
}
|
|
323
350
|
return true;
|
|
@@ -337,17 +364,22 @@ export function isEarHashed(ear, minX, minY, size) {
|
|
|
337
364
|
const c = ear.next;
|
|
338
365
|
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
339
366
|
// triangle bbox; min & max are calculated like this for speed
|
|
340
|
-
const minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) :
|
|
341
|
-
const minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) :
|
|
342
|
-
const maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) :
|
|
343
|
-
const maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) :
|
|
367
|
+
const minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : b.x < c.x ? b.x : c.x;
|
|
368
|
+
const minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : b.y < c.y ? b.y : c.y;
|
|
369
|
+
const maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : b.x > c.x ? b.x : c.x;
|
|
370
|
+
const maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : b.y > c.y ? b.y : c.y;
|
|
344
371
|
// z-order range for the current triangle bbox;
|
|
345
372
|
const minZ = zOrder(minTX, minTY, minX, minY, size);
|
|
346
373
|
const maxZ = zOrder(maxTX, maxTY, minX, minY, size);
|
|
347
374
|
// first look for points inside the triangle in increasing z-order
|
|
348
375
|
let p = ear.nextZ;
|
|
349
376
|
while (p && p.z <= maxZ) {
|
|
350
|
-
if (
|
|
377
|
+
if (
|
|
378
|
+
p !== ear.prev &&
|
|
379
|
+
p !== ear.next &&
|
|
380
|
+
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
|
|
381
|
+
area(p.prev, p, p.next) >= 0
|
|
382
|
+
) {
|
|
351
383
|
return false;
|
|
352
384
|
}
|
|
353
385
|
p = p.nextZ;
|
|
@@ -355,7 +387,12 @@ export function isEarHashed(ear, minX, minY, size) {
|
|
|
355
387
|
// then look for points in decreasing z-order
|
|
356
388
|
p = ear.prevZ;
|
|
357
389
|
while (p && p.z >= minZ) {
|
|
358
|
-
if (
|
|
390
|
+
if (
|
|
391
|
+
p !== ear.prev &&
|
|
392
|
+
p !== ear.next &&
|
|
393
|
+
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
|
|
394
|
+
area(p.prev, p, p.next) >= 0
|
|
395
|
+
) {
|
|
359
396
|
return false;
|
|
360
397
|
}
|
|
361
398
|
p = p.prevZ;
|
|
@@ -383,7 +420,7 @@ export function linkedList(data, start, end, dim, clockwise) {
|
|
|
383
420
|
j = i;
|
|
384
421
|
}
|
|
385
422
|
// link points into circular doubly-linked list in the specified winding order
|
|
386
|
-
if (clockwise ===
|
|
423
|
+
if (clockwise === sum > 0) {
|
|
387
424
|
for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
|
|
388
425
|
} else {
|
|
389
426
|
for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
|
|
@@ -433,7 +470,7 @@ export function findHoleBridge(hole, outerNode) {
|
|
|
433
470
|
// segment's endpoint with lesser x will be potential connection point
|
|
434
471
|
do {
|
|
435
472
|
if (hy <= p.y && hy >= p.next.y) {
|
|
436
|
-
const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
|
|
473
|
+
const x = p.x + ((hy - p.y) * (p.next.x - p.x)) / (p.next.y - p.y);
|
|
437
474
|
if (x <= hx && x > qx) {
|
|
438
475
|
qx = x;
|
|
439
476
|
m = p.x < p.next.x ? p : p.next;
|
|
@@ -451,7 +488,11 @@ export function findHoleBridge(hole, outerNode) {
|
|
|
451
488
|
let tan;
|
|
452
489
|
p = m.next;
|
|
453
490
|
while (p !== stop) {
|
|
454
|
-
if (
|
|
491
|
+
if (
|
|
492
|
+
hx >= p.x &&
|
|
493
|
+
p.x >= m.x &&
|
|
494
|
+
pointInTriangle(hy < m.y ? hx : qx, hy, m.x, m.y, hy < m.y ? qx : hx, hy, p.x, p.y)
|
|
495
|
+
) {
|
|
455
496
|
tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
|
|
456
497
|
if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) {
|
|
457
498
|
m = p;
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
// TODO: fix ++ +=1 conversion issues (when a is 0 than a++ is 0 but a+=1 is 1)
|
|
9
9
|
|
|
10
10
|
export default class {
|
|
11
|
-
|
|
12
11
|
constructor(gl) {
|
|
13
12
|
this.vertSize = 10;
|
|
14
13
|
this.maxSize = 6000; // Math.pow(2, 16) / this.vertSize;
|
|
@@ -89,7 +88,10 @@ export default class {
|
|
|
89
88
|
return;
|
|
90
89
|
}
|
|
91
90
|
// TODO trim??
|
|
92
|
-
if (
|
|
91
|
+
if (
|
|
92
|
+
sprite.texture.baseTexture !== this.currentBaseTexture &&
|
|
93
|
+
!sprite.texture.baseTexture.skipRender
|
|
94
|
+
) {
|
|
93
95
|
this.flush();
|
|
94
96
|
this.currentBaseTexture = sprite.texture.baseTexture;
|
|
95
97
|
if (!sprite.texture._uvs) {
|
|
@@ -113,73 +115,73 @@ export default class {
|
|
|
113
115
|
h1 = trim.y - sprite.anchor.y * trim.height;
|
|
114
116
|
h0 = h1 + sprite.texture.crop.height;
|
|
115
117
|
} else {
|
|
116
|
-
w0 =
|
|
117
|
-
w1 =
|
|
118
|
+
w0 = sprite.texture.frame.width * (1 - sprite.anchor.x);
|
|
119
|
+
w1 = sprite.texture.frame.width * -sprite.anchor.x;
|
|
118
120
|
h0 = sprite.texture.frame.height * (1 - sprite.anchor.y);
|
|
119
121
|
h1 = sprite.texture.frame.height * -sprite.anchor.y;
|
|
120
122
|
}
|
|
121
123
|
index = this.currentBatchSize * 4 * this.vertSize;
|
|
122
124
|
index -= 1;
|
|
123
125
|
// xy
|
|
124
|
-
vertices[index += 1] = w1;
|
|
125
|
-
vertices[index += 1] = h1;
|
|
126
|
-
vertices[index += 1] = sprite.position.x;
|
|
127
|
-
vertices[index += 1] = sprite.position.y;
|
|
126
|
+
vertices[(index += 1)] = w1;
|
|
127
|
+
vertices[(index += 1)] = h1;
|
|
128
|
+
vertices[(index += 1)] = sprite.position.x;
|
|
129
|
+
vertices[(index += 1)] = sprite.position.y;
|
|
128
130
|
// scale
|
|
129
|
-
vertices[index += 1] = sprite.scale.x;
|
|
130
|
-
vertices[index += 1] = sprite.scale.y;
|
|
131
|
+
vertices[(index += 1)] = sprite.scale.x;
|
|
132
|
+
vertices[(index += 1)] = sprite.scale.y;
|
|
131
133
|
// rotation
|
|
132
|
-
vertices[index += 1] = sprite.rotation;
|
|
134
|
+
vertices[(index += 1)] = sprite.rotation;
|
|
133
135
|
// uv
|
|
134
|
-
vertices[index += 1] = uvs.x0;
|
|
135
|
-
vertices[index += 1] = uvs.y1;
|
|
136
|
+
vertices[(index += 1)] = uvs.x0;
|
|
137
|
+
vertices[(index += 1)] = uvs.y1;
|
|
136
138
|
// color
|
|
137
|
-
vertices[index += 1] = sprite.alpha;
|
|
139
|
+
vertices[(index += 1)] = sprite.alpha;
|
|
138
140
|
// xy
|
|
139
|
-
vertices[index += 1] = w0;
|
|
140
|
-
vertices[index += 1] = h1;
|
|
141
|
-
vertices[index += 1] = sprite.position.x;
|
|
142
|
-
vertices[index += 1] = sprite.position.y;
|
|
141
|
+
vertices[(index += 1)] = w0;
|
|
142
|
+
vertices[(index += 1)] = h1;
|
|
143
|
+
vertices[(index += 1)] = sprite.position.x;
|
|
144
|
+
vertices[(index += 1)] = sprite.position.y;
|
|
143
145
|
// scale
|
|
144
|
-
vertices[index += 1] = sprite.scale.x;
|
|
145
|
-
vertices[index += 1] = sprite.scale.y;
|
|
146
|
+
vertices[(index += 1)] = sprite.scale.x;
|
|
147
|
+
vertices[(index += 1)] = sprite.scale.y;
|
|
146
148
|
// rotation
|
|
147
|
-
vertices[index += 1] = sprite.rotation;
|
|
149
|
+
vertices[(index += 1)] = sprite.rotation;
|
|
148
150
|
// uv
|
|
149
|
-
vertices[index += 1] = uvs.x1;
|
|
150
|
-
vertices[index += 1] = uvs.y1;
|
|
151
|
+
vertices[(index += 1)] = uvs.x1;
|
|
152
|
+
vertices[(index += 1)] = uvs.y1;
|
|
151
153
|
// color
|
|
152
|
-
vertices[index += 1] = sprite.alpha;
|
|
154
|
+
vertices[(index += 1)] = sprite.alpha;
|
|
153
155
|
// xy
|
|
154
|
-
vertices[index += 1] = w0;
|
|
155
|
-
vertices[index += 1] = h0;
|
|
156
|
-
vertices[index += 1] = sprite.position.x;
|
|
157
|
-
vertices[index += 1] = sprite.position.y;
|
|
156
|
+
vertices[(index += 1)] = w0;
|
|
157
|
+
vertices[(index += 1)] = h0;
|
|
158
|
+
vertices[(index += 1)] = sprite.position.x;
|
|
159
|
+
vertices[(index += 1)] = sprite.position.y;
|
|
158
160
|
// scale
|
|
159
|
-
vertices[index += 1] = sprite.scale.x;
|
|
160
|
-
vertices[index += 1] = sprite.scale.y;
|
|
161
|
+
vertices[(index += 1)] = sprite.scale.x;
|
|
162
|
+
vertices[(index += 1)] = sprite.scale.y;
|
|
161
163
|
// rotation
|
|
162
|
-
vertices[index += 1] = sprite.rotation;
|
|
164
|
+
vertices[(index += 1)] = sprite.rotation;
|
|
163
165
|
// uv
|
|
164
|
-
vertices[index += 1] = uvs.x2;
|
|
165
|
-
vertices[index += 1] = uvs.y2;
|
|
166
|
+
vertices[(index += 1)] = uvs.x2;
|
|
167
|
+
vertices[(index += 1)] = uvs.y2;
|
|
166
168
|
// color
|
|
167
|
-
vertices[index += 1] = sprite.alpha;
|
|
169
|
+
vertices[(index += 1)] = sprite.alpha;
|
|
168
170
|
// xy
|
|
169
|
-
vertices[index += 1] = w1;
|
|
170
|
-
vertices[index += 1] = h0;
|
|
171
|
-
vertices[index += 1] = sprite.position.x;
|
|
172
|
-
vertices[index += 1] = sprite.position.y;
|
|
171
|
+
vertices[(index += 1)] = w1;
|
|
172
|
+
vertices[(index += 1)] = h0;
|
|
173
|
+
vertices[(index += 1)] = sprite.position.x;
|
|
174
|
+
vertices[(index += 1)] = sprite.position.y;
|
|
173
175
|
// scale
|
|
174
|
-
vertices[index += 1] = sprite.scale.x;
|
|
175
|
-
vertices[index += 1] = sprite.scale.y;
|
|
176
|
+
vertices[(index += 1)] = sprite.scale.x;
|
|
177
|
+
vertices[(index += 1)] = sprite.scale.y;
|
|
176
178
|
// rotation
|
|
177
|
-
vertices[index += 1] = sprite.rotation;
|
|
179
|
+
vertices[(index += 1)] = sprite.rotation;
|
|
178
180
|
// uv
|
|
179
|
-
vertices[index += 1] = uvs.x3;
|
|
180
|
-
vertices[index += 1] = uvs.y3;
|
|
181
|
+
vertices[(index += 1)] = uvs.x3;
|
|
182
|
+
vertices[(index += 1)] = uvs.y3;
|
|
181
183
|
// color
|
|
182
|
-
vertices[index += 1] = sprite.alpha;
|
|
184
|
+
vertices[(index += 1)] = sprite.alpha;
|
|
183
185
|
// increment the batch
|
|
184
186
|
this.currentBatchSize += 1;
|
|
185
187
|
if (this.currentBatchSize >= this.size) {
|
|
@@ -199,7 +201,7 @@ export default class {
|
|
|
199
201
|
}
|
|
200
202
|
gl.bindTexture(gl.TEXTURE_2D, this.currentBaseTexture._glTextures[gl.id]);
|
|
201
203
|
// upload the verts to the buffer
|
|
202
|
-
if (this.currentBatchSize >
|
|
204
|
+
if (this.currentBatchSize > this.size * 0.5) {
|
|
203
205
|
gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertices);
|
|
204
206
|
} else {
|
|
205
207
|
const view = this.vertices.subarray(0, this.currentBatchSize * 4 * this.vertSize);
|
|
@@ -238,5 +240,4 @@ export default class {
|
|
|
238
240
|
gl.vertexAttribPointer(this.shader.aTextureCoord, 2, gl.FLOAT, false, stride, 7 * 4);
|
|
239
241
|
gl.vertexAttribPointer(this.shader.colorAttribute, 1, gl.FLOAT, false, stride, 9 * 4);
|
|
240
242
|
}
|
|
241
|
-
|
|
242
243
|
}
|