@vpmedia/phaser 1.17.0 → 1.19.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.
Files changed (172) hide show
  1. package/README.md +1 -1
  2. package/package.json +4 -4
  3. package/src/phaser/core/animation.js +3 -2
  4. package/src/phaser/core/animation_manager.js +3 -2
  5. package/src/phaser/core/cache.js +38 -17
  6. package/src/phaser/core/const.js +66 -0
  7. package/src/phaser/core/device.js +87 -0
  8. package/src/phaser/core/dom.js +13 -8
  9. package/src/phaser/core/event_manager.js +2 -1
  10. package/src/phaser/core/factory.js +11 -11
  11. package/src/phaser/core/game.js +1 -0
  12. package/src/phaser/core/input.js +13 -12
  13. package/src/phaser/core/input_handler.js +2 -1
  14. package/src/phaser/core/input_mouse.js +3 -2
  15. package/src/phaser/core/input_mspointer.js +6 -6
  16. package/src/phaser/core/input_pointer.js +3 -2
  17. package/src/phaser/core/loader.js +70 -69
  18. package/src/phaser/core/scale_manager.js +41 -24
  19. package/src/phaser/core/scene_manager.js +11 -7
  20. package/src/phaser/core/signal_binding.js +16 -7
  21. package/src/phaser/core/sound_manager.js +14 -7
  22. package/src/phaser/core/sound_sprite.js +7 -4
  23. package/src/phaser/core/timer.js +33 -21
  24. package/src/phaser/core/timer_event.js +8 -6
  25. package/src/phaser/core/tween.js +66 -45
  26. package/src/phaser/core/tween_data.js +23 -15
  27. package/src/phaser/core/tween_manager.js +10 -6
  28. package/src/phaser/display/bitmap_text.js +7 -6
  29. package/src/phaser/display/canvas/pool.js +1 -1
  30. package/src/phaser/display/canvas/renderer.js +9 -5
  31. package/src/phaser/display/canvas/util.js +2 -2
  32. package/src/phaser/display/display_object.js +35 -16
  33. package/src/phaser/display/graphics.js +61 -40
  34. package/src/phaser/display/graphics_data.js +7 -7
  35. package/src/phaser/display/image.js +19 -12
  36. package/src/phaser/display/sprite_util.js +3 -2
  37. package/src/phaser/display/text.js +57 -33
  38. package/src/phaser/display/webgl/abstract_filter.js +2 -2
  39. package/src/phaser/display/webgl/base_texture.js +2 -2
  40. package/src/phaser/display/webgl/blend_manager.js +3 -2
  41. package/src/phaser/display/webgl/earcut_node.js +1 -1
  42. package/src/phaser/display/webgl/fast_sprite_batch.js +8 -6
  43. package/src/phaser/display/webgl/filter_manager.js +1 -1
  44. package/src/phaser/display/webgl/filter_texture.js +2 -2
  45. package/src/phaser/display/webgl/graphics.js +6 -6
  46. package/src/phaser/display/webgl/graphics_data.js +1 -1
  47. package/src/phaser/display/webgl/render_texture.js +9 -3
  48. package/src/phaser/display/webgl/renderer.js +13 -6
  49. package/src/phaser/display/webgl/shader/complex.js +1 -1
  50. package/src/phaser/display/webgl/shader/fast.js +1 -1
  51. package/src/phaser/display/webgl/shader/normal.js +2 -2
  52. package/src/phaser/display/webgl/shader/primitive.js +1 -1
  53. package/src/phaser/display/webgl/shader/strip.js +1 -1
  54. package/src/phaser/display/webgl/shader_manager.js +4 -3
  55. package/src/phaser/display/webgl/sprite_batch.js +10 -7
  56. package/src/phaser/display/webgl/stencil_manager.js +12 -10
  57. package/src/phaser/display/webgl/texture.js +8 -6
  58. package/typedefs/global.d.ts +1 -1
  59. package/types/phaser/core/animation.d.ts +5 -4
  60. package/types/phaser/core/animation.d.ts.map +1 -1
  61. package/types/phaser/core/animation_manager.d.ts +7 -6
  62. package/types/phaser/core/animation_manager.d.ts.map +1 -1
  63. package/types/phaser/core/cache.d.ts +69 -45
  64. package/types/phaser/core/cache.d.ts.map +1 -1
  65. package/types/phaser/core/const.d.ts +88 -22
  66. package/types/phaser/core/const.d.ts.map +1 -1
  67. package/types/phaser/core/device.d.ts +87 -0
  68. package/types/phaser/core/device.d.ts.map +1 -1
  69. package/types/phaser/core/dom.d.ts +19 -27
  70. package/types/phaser/core/dom.d.ts.map +1 -1
  71. package/types/phaser/core/event_manager.d.ts +4 -3
  72. package/types/phaser/core/event_manager.d.ts.map +1 -1
  73. package/types/phaser/core/factory.d.ts +15 -15
  74. package/types/phaser/core/factory.d.ts.map +1 -1
  75. package/types/phaser/core/game.d.ts +1 -0
  76. package/types/phaser/core/game.d.ts.map +1 -1
  77. package/types/phaser/core/input.d.ts +22 -21
  78. package/types/phaser/core/input.d.ts.map +1 -1
  79. package/types/phaser/core/input_handler.d.ts +5 -4
  80. package/types/phaser/core/input_handler.d.ts.map +1 -1
  81. package/types/phaser/core/input_mouse.d.ts +1 -1
  82. package/types/phaser/core/input_mouse.d.ts.map +1 -1
  83. package/types/phaser/core/input_mspointer.d.ts +13 -13
  84. package/types/phaser/core/input_mspointer.d.ts.map +1 -1
  85. package/types/phaser/core/input_pointer.d.ts +5 -4
  86. package/types/phaser/core/input_pointer.d.ts.map +1 -1
  87. package/types/phaser/core/loader.d.ts +104 -103
  88. package/types/phaser/core/loader.d.ts.map +1 -1
  89. package/types/phaser/core/scale_manager.d.ts +57 -40
  90. package/types/phaser/core/scale_manager.d.ts.map +1 -1
  91. package/types/phaser/core/scene_manager.d.ts +16 -11
  92. package/types/phaser/core/scene_manager.d.ts.map +1 -1
  93. package/types/phaser/core/signal_binding.d.ts +23 -15
  94. package/types/phaser/core/signal_binding.d.ts.map +1 -1
  95. package/types/phaser/core/sound_manager.d.ts +16 -9
  96. package/types/phaser/core/sound_manager.d.ts.map +1 -1
  97. package/types/phaser/core/sound_sprite.d.ts +10 -7
  98. package/types/phaser/core/sound_sprite.d.ts.map +1 -1
  99. package/types/phaser/core/timer.d.ts +41 -29
  100. package/types/phaser/core/timer.d.ts.map +1 -1
  101. package/types/phaser/core/timer_event.d.ts +12 -11
  102. package/types/phaser/core/timer_event.d.ts.map +1 -1
  103. package/types/phaser/core/tween.d.ts +82 -62
  104. package/types/phaser/core/tween.d.ts.map +1 -1
  105. package/types/phaser/core/tween_data.d.ts +31 -23
  106. package/types/phaser/core/tween_data.d.ts.map +1 -1
  107. package/types/phaser/core/tween_manager.d.ts +16 -12
  108. package/types/phaser/core/tween_manager.d.ts.map +1 -1
  109. package/types/phaser/display/bitmap_text.d.ts +10 -9
  110. package/types/phaser/display/bitmap_text.d.ts.map +1 -1
  111. package/types/phaser/display/button.d.ts +3 -2
  112. package/types/phaser/display/button.d.ts.map +1 -1
  113. package/types/phaser/display/canvas/buffer.d.ts +2 -2
  114. package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
  115. package/types/phaser/display/canvas/pool.d.ts +2 -2
  116. package/types/phaser/display/canvas/pool.d.ts.map +1 -1
  117. package/types/phaser/display/canvas/renderer.d.ts +11 -7
  118. package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
  119. package/types/phaser/display/canvas/util.d.ts +2 -2
  120. package/types/phaser/display/canvas/util.d.ts.map +1 -1
  121. package/types/phaser/display/display_object.d.ts +55 -36
  122. package/types/phaser/display/display_object.d.ts.map +1 -1
  123. package/types/phaser/display/graphics.d.ts +71 -53
  124. package/types/phaser/display/graphics.d.ts.map +1 -1
  125. package/types/phaser/display/graphics_data.d.ts +16 -16
  126. package/types/phaser/display/graphics_data.d.ts.map +1 -1
  127. package/types/phaser/display/image.d.ts +27 -25
  128. package/types/phaser/display/image.d.ts.map +1 -1
  129. package/types/phaser/display/sprite_util.d.ts +5 -4
  130. package/types/phaser/display/sprite_util.d.ts.map +1 -1
  131. package/types/phaser/display/text.d.ts +82 -93
  132. package/types/phaser/display/text.d.ts.map +1 -1
  133. package/types/phaser/display/webgl/abstract_filter.d.ts +4 -4
  134. package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  135. package/types/phaser/display/webgl/base_texture.d.ts +4 -4
  136. package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
  137. package/types/phaser/display/webgl/blend_manager.d.ts +6 -5
  138. package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  139. package/types/phaser/display/webgl/earcut_node.d.ts +3 -3
  140. package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  141. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +14 -13
  142. package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  143. package/types/phaser/display/webgl/filter_manager.d.ts +3 -3
  144. package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  145. package/types/phaser/display/webgl/filter_texture.d.ts +7 -7
  146. package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  147. package/types/phaser/display/webgl/graphics.d.ts +13 -12
  148. package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
  149. package/types/phaser/display/webgl/graphics_data.d.ts +5 -5
  150. package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  151. package/types/phaser/display/webgl/render_texture.d.ts +12 -10
  152. package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
  153. package/types/phaser/display/webgl/renderer.d.ts +16 -9
  154. package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
  155. package/types/phaser/display/webgl/shader/complex.d.ts +11 -11
  156. package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  157. package/types/phaser/display/webgl/shader/fast.d.ts +15 -15
  158. package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  159. package/types/phaser/display/webgl/shader/normal.d.ts +12 -12
  160. package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  161. package/types/phaser/display/webgl/shader/primitive.d.ts +12 -12
  162. package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  163. package/types/phaser/display/webgl/shader/strip.d.ts +12 -12
  164. package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  165. package/types/phaser/display/webgl/shader_manager.d.ts +9 -8
  166. package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  167. package/types/phaser/display/webgl/sprite_batch.d.ts +17 -14
  168. package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  169. package/types/phaser/display/webgl/stencil_manager.d.ts +17 -15
  170. package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  171. package/types/phaser/display/webgl/texture.d.ts +15 -12
  172. package/types/phaser/display/webgl/texture.d.ts.map +1 -1
@@ -1,5 +1,6 @@
1
1
  import { Point } from '../geom/point';
2
2
  import { Rectangle } from '../geom/rectangle';
3
+ import { Matrix } from '../geom/matrix';
3
4
  import { Image } from './image';
4
5
  import { create, remove } from './canvas/pool';
5
6
  import { textureFromCanvas } from './webgl/texture_util';
@@ -70,10 +71,11 @@ export class Text extends Image {
70
71
  * TBD.
71
72
  * @param {number} x - TBD.
72
73
  * @param {number} y - TBD.
73
- * @param color - TBD.
74
- * @param blur
75
- * @param shadowStroke
76
- * @param shadowFill
74
+ * @param {string} color - TBD.
75
+ * @param {number} blur - TBD.
76
+ * @param {boolean} shadowStroke - TBD.
77
+ * @param {boolean} shadowFill - TBD.
78
+ * @returns {Text} TBD.
77
79
  */
78
80
  setShadow(x = 0, y = 0, color = 'rgba(0, 0, 0, 1)', blur = 0, shadowStroke = true, shadowFill = true) {
79
81
  this.style.shadowOffsetX = x;
@@ -88,8 +90,9 @@ export class Text extends Image {
88
90
 
89
91
  /**
90
92
  * TBD.
91
- * @param style
92
- * @param update
93
+ * @param {object} style - TBD.
94
+ * @param {boolean} update - TBD.
95
+ * @returns {Text} TBD.
93
96
  */
94
97
  setStyle(style = null, update = false) {
95
98
  style = JSON.parse(JSON.stringify(style)) || {};
@@ -297,10 +300,10 @@ export class Text extends Image {
297
300
 
298
301
  /**
299
302
  * TBD.
300
- * @param line
303
+ * @param {string} line - TBD.
301
304
  * @param {number} x - TBD.
302
305
  * @param {number} y - TBD.
303
- * @param fill
306
+ * @param {boolean} fill - TBD.
304
307
  */
305
308
  renderTabLine(line, x, y, fill) {
306
309
  const text = line.split(/(?:\t)/);
@@ -336,7 +339,7 @@ export class Text extends Image {
336
339
 
337
340
  /**
338
341
  * TBD.
339
- * @param state
342
+ * @param {string} state - TBD.
340
343
  */
341
344
  updateShadow(state) {
342
345
  if (state) {
@@ -354,7 +357,8 @@ export class Text extends Image {
354
357
 
355
358
  /**
356
359
  * TBD.
357
- * @param line
360
+ * @param {string} line - TBD.
361
+ * @returns {number} TBD.
358
362
  */
359
363
  measureLine(line) {
360
364
  let lineLength = 0;
@@ -390,7 +394,7 @@ export class Text extends Image {
390
394
 
391
395
  /**
392
396
  * TBD.
393
- * @param line
397
+ * @param {string} line - TBD.
394
398
  * @param {number} x - TBD.
395
399
  * @param {number} y - TBD.
396
400
  */
@@ -428,6 +432,7 @@ export class Text extends Image {
428
432
 
429
433
  /**
430
434
  * TBD.
435
+ * @returns {Text} TBD.
431
436
  */
432
437
  clearColors() {
433
438
  this.colors = [];
@@ -438,6 +443,7 @@ export class Text extends Image {
438
443
 
439
444
  /**
440
445
  * TBD.
446
+ * @returns {Text} TBD.
441
447
  */
442
448
  clearFontValues() {
443
449
  this.fontStyles = [];
@@ -448,8 +454,9 @@ export class Text extends Image {
448
454
 
449
455
  /**
450
456
  * TBD.
451
- * @param color - TBD.
452
- * @param position - TBD.
457
+ * @param {number} color - TBD.
458
+ * @param {number} position - TBD.
459
+ * @returns {Text} TBD.
453
460
  */
454
461
  addColor(color, position) {
455
462
  this.colors[position] = color;
@@ -459,8 +466,9 @@ export class Text extends Image {
459
466
 
460
467
  /**
461
468
  * TBD.
462
- * @param color - TBD.
463
- * @param position - TBD.
469
+ * @param {number} color - TBD.
470
+ * @param {number} position - TBD.
471
+ * @returns {Text} TBD.
464
472
  */
465
473
  addStrokeColor(color, position) {
466
474
  this.strokeColors[position] = color;
@@ -470,8 +478,9 @@ export class Text extends Image {
470
478
 
471
479
  /**
472
480
  * TBD.
473
- * @param style
474
- * @param position - TBD.
481
+ * @param {object} style - TBD.
482
+ * @param {number} position - TBD.
483
+ * @returns {Text} TBD.
475
484
  */
476
485
  addFontStyle(style, position) {
477
486
  this.fontStyles[position] = style;
@@ -481,8 +490,9 @@ export class Text extends Image {
481
490
 
482
491
  /**
483
492
  * TBD.
484
- * @param weight
485
- * @param position - TBD.
493
+ * @param {number} weight - TBD.
494
+ * @param {number} position - TBD.
495
+ * @returns {Text} TBD.
486
496
  */
487
497
  addFontWeight(weight, position) {
488
498
  this.fontWeights[position] = weight;
@@ -492,7 +502,8 @@ export class Text extends Image {
492
502
 
493
503
  /**
494
504
  * TBD.
495
- * @param text - TBD.
505
+ * @param {string} text - TBD.
506
+ * @returns {string[]} TBD.
496
507
  */
497
508
  precalculateWordWrap(text) {
498
509
  this.texture.baseTexture.resolution = this._res;
@@ -503,7 +514,8 @@ export class Text extends Image {
503
514
 
504
515
  /**
505
516
  * TBD.
506
- * @param text - TBD.
517
+ * @param {string} text - TBD.
518
+ * @returns {string} TBD.
507
519
  */
508
520
  runWordWrap(text) {
509
521
  if (this.useAdvancedWrap) {
@@ -514,7 +526,9 @@ export class Text extends Image {
514
526
 
515
527
  /**
516
528
  * TBD.
517
- * @param text - TBD.
529
+ * @param {string} text - TBD.
530
+ * @returns {string} TBD.
531
+ * @throws Error.
518
532
  */
519
533
  advancedWordWrap(text) {
520
534
  const context = this.context;
@@ -595,7 +609,8 @@ export class Text extends Image {
595
609
 
596
610
  /**
597
611
  * TBD.
598
- * @param text - TBD.
612
+ * @param {string} text - TBD.
613
+ * @returns {string} TBD.
599
614
  */
600
615
  basicWordWrap(text) {
601
616
  let result = '';
@@ -627,7 +642,7 @@ export class Text extends Image {
627
642
 
628
643
  /**
629
644
  * TBD.
630
- * @param components
645
+ * @param {object} components - TBD.
631
646
  */
632
647
  updateFont(components) {
633
648
  const font = this.componentsToFont(components);
@@ -642,7 +657,8 @@ export class Text extends Image {
642
657
 
643
658
  /**
644
659
  * TBD.
645
- * @param font - TBD.
660
+ * @param {string} font - TBD.
661
+ * @returns {object} TBD.
646
662
  */
647
663
  fontToComponents(font) {
648
664
  // The format is specified in http://www.w3.org/TR/CSS2/fonts.html#font-shorthand:
@@ -677,7 +693,8 @@ export class Text extends Image {
677
693
 
678
694
  /**
679
695
  * TBD.
680
- * @param components
696
+ * @param {object} components - TBD.
697
+ * @returns {string} TBD.
681
698
  */
682
699
  componentsToFont(components) {
683
700
  const parts = [];
@@ -711,8 +728,9 @@ export class Text extends Image {
711
728
 
712
729
  /**
713
730
  * TBD.
714
- * @param text - TBD.
715
- * @param immediate
731
+ * @param {string} text - TBD.
732
+ * @param {boolean} immediate - TBD.
733
+ * @returns {Text} TBD.
716
734
  */
717
735
  setText(text, immediate = false) {
718
736
  this.text = text.toString() || '';
@@ -726,7 +744,8 @@ export class Text extends Image {
726
744
 
727
745
  /**
728
746
  * TBD.
729
- * @param list
747
+ * @param {string[]|string[][]} list - TBD.
748
+ * @returns {Text} TBD.
730
749
  */
731
750
  parseList(list) {
732
751
  if (!Array.isArray(list)) {
@@ -757,6 +776,7 @@ export class Text extends Image {
757
776
  * @param {number} y - TBD.
758
777
  * @param {number} width - TBD.
759
778
  * @param {number} height - TBD.
779
+ * @returns {Text} TBD.
760
780
  */
761
781
  setTextBounds(x, y, width, height) {
762
782
  if (x === undefined) {
@@ -819,7 +839,7 @@ export class Text extends Image {
819
839
 
820
840
  /**
821
841
  * TBD.
822
- * @param renderSession - TBD.
842
+ * @param {object} renderSession - TBD.
823
843
  */
824
844
  renderWebGL(renderSession) {
825
845
  if (this.dirty) {
@@ -831,7 +851,7 @@ export class Text extends Image {
831
851
 
832
852
  /**
833
853
  * TBD.
834
- * @param renderSession - TBD.
854
+ * @param {object} renderSession - TBD.
835
855
  */
836
856
  renderCanvas(renderSession) {
837
857
  if (this.dirty) {
@@ -843,6 +863,7 @@ export class Text extends Image {
843
863
 
844
864
  /**
845
865
  * TBD.
866
+ * @returns {object} TBD.
846
867
  */
847
868
  getFontPropertiesCache() {
848
869
  if (!window.PhaserRegistry.fontPropertiesCache) {
@@ -853,6 +874,7 @@ export class Text extends Image {
853
874
 
854
875
  /**
855
876
  * TBD.
877
+ * @returns {HTMLCanvasElement} TBD.
856
878
  */
857
879
  getFontPropertiesCanvas() {
858
880
  if (!window.PhaserRegistry.fontPropertiesCanvas) {
@@ -863,6 +885,7 @@ export class Text extends Image {
863
885
 
864
886
  /**
865
887
  * TBD.
888
+ * @returns {CanvasRenderingContext2D} TBD.
866
889
  */
867
890
  getFontPropertiesContext() {
868
891
  if (!window.PhaserRegistry.fontPropertiesContext) {
@@ -875,7 +898,8 @@ export class Text extends Image {
875
898
 
876
899
  /**
877
900
  * TBD.
878
- * @param fontStyle
901
+ * @param {string} fontStyle - TBD.
902
+ * @returns {object} TBD.
879
903
  */
880
904
  determineFontProperties(fontStyle) {
881
905
  const fontPropertiesCache = this.getFontPropertiesCache();
@@ -953,7 +977,7 @@ export class Text extends Image {
953
977
 
954
978
  /**
955
979
  * TBD.
956
- * @param matrix - TBD.
980
+ * @param {Matrix} matrix - TBD.
957
981
  * @returns {Rectangle} TBD.
958
982
  */
959
983
  getBounds(matrix = null) {
@@ -1,8 +1,8 @@
1
1
  export class AbstractFilter {
2
2
  /**
3
3
  * TBD.
4
- * @param fragmentSrc
5
- * @param uniforms
4
+ * @param {string[]} fragmentSrc - TBD.
5
+ * @param {object} uniforms - TBD.
6
6
  */
7
7
  constructor(fragmentSrc, uniforms) {
8
8
  this.passes = [this];
@@ -3,8 +3,8 @@ import { removeByCanvas } from '../canvas/pool';
3
3
  export class BaseTexture {
4
4
  /**
5
5
  * TBD.
6
- * @param source
7
- * @param scaleMode
6
+ * @param {HTMLCanvasElement} source - TBD.
7
+ * @param {number} scaleMode - TBD.
8
8
  */
9
9
  constructor(source, scaleMode) {
10
10
  this.resolution = 1;
@@ -9,7 +9,7 @@ export class WebGLBlendModeManager {
9
9
 
10
10
  /**
11
11
  * TBD.
12
- * @param gl - TBD.
12
+ * @param {WebGLRenderingContext} gl - TBD.
13
13
  */
14
14
  setContext(gl) {
15
15
  this.gl = gl;
@@ -17,7 +17,8 @@ export class WebGLBlendModeManager {
17
17
 
18
18
  /**
19
19
  * TBD.
20
- * @param blendMode
20
+ * @param {number} blendMode - TBD.
21
+ * @returns {boolean} TBD.
21
22
  */
22
23
  setBlendMode(blendMode) {
23
24
  if (this.currentBlendMode === blendMode) {
@@ -1,7 +1,7 @@
1
1
  export class Node {
2
2
  /**
3
3
  * TBD.
4
- * @param i
4
+ * @param {number} i - TBD.
5
5
  * @param {number} x - TBD.
6
6
  * @param {number} y - TBD.
7
7
  */
@@ -1,7 +1,9 @@
1
+ import { Image } from '../image';
2
+
1
3
  export class FastSpriteBatch {
2
4
  /**
3
5
  * TBD.
4
- * @param gl - TBD.
6
+ * @param {WebGLRenderingContext} gl - TBD.
5
7
  */
6
8
  constructor(gl) {
7
9
  this.vertSize = 10;
@@ -36,7 +38,7 @@ export class FastSpriteBatch {
36
38
 
37
39
  /**
38
40
  * TBD.
39
- * @param gl - TBD.
41
+ * @param {WebGLRenderingContext} gl - TBD.
40
42
  */
41
43
  setContext(gl) {
42
44
  this.gl = gl;
@@ -53,8 +55,8 @@ export class FastSpriteBatch {
53
55
 
54
56
  /**
55
57
  * TBD.
56
- * @param spriteBatch
57
- * @param renderSession - TBD.
58
+ * @param spriteBatch - TBD.
59
+ * @param {object} renderSession - TBD.
58
60
  */
59
61
  begin(spriteBatch, renderSession) {
60
62
  this.renderSession = renderSession;
@@ -72,7 +74,7 @@ export class FastSpriteBatch {
72
74
 
73
75
  /**
74
76
  * TBD.
75
- * @param spriteBatch
77
+ * @param spriteBatch - TBD.
76
78
  */
77
79
  render(spriteBatch) {
78
80
  const children = spriteBatch.children;
@@ -96,7 +98,7 @@ export class FastSpriteBatch {
96
98
 
97
99
  /**
98
100
  * TBD.
99
- * @param sprite
101
+ * @param {Image} sprite - TBD.
100
102
  */
101
103
  renderSprite(sprite) {
102
104
  if (!sprite.visible) {
@@ -10,7 +10,7 @@ export class WebGLFilterManager {
10
10
 
11
11
  /**
12
12
  * TBD.
13
- * @param gl - TBD.
13
+ * @param {WebGLRenderingContext} gl - TBD.
14
14
  */
15
15
  setContext(gl) {
16
16
  this.gl = gl;
@@ -3,10 +3,10 @@ import { SCALE_LINEAR } from '../../core/const';
3
3
  export class FilterTexture {
4
4
  /**
5
5
  * TBD.
6
- * @param gl - TBD.
6
+ * @param {WebGLRenderingContext} gl - TBD.
7
7
  * @param {number} width - TBD.
8
8
  * @param {number} height - TBD.
9
- * @param scaleMode
9
+ * @param {number} scaleMode - TBD.
10
10
  */
11
11
  constructor(gl, width, height, scaleMode) {
12
12
  this.gl = gl;
@@ -53,7 +53,7 @@ export function switchMode(webGL, type) {
53
53
  /**
54
54
  * TBD.
55
55
  * @param {object} graphicsData - TBD.
56
- * @param {object} webGLData - TBD.
56
+ * @param {GraphicsData} webGLData - TBD.
57
57
  */
58
58
  export function buildLine(graphicsData, webGLData) {
59
59
  // TODO OPTIMISE!
@@ -218,7 +218,7 @@ export function buildLine(graphicsData, webGLData) {
218
218
  /**
219
219
  * TBD.
220
220
  * @param {object} graphicsData - TBD.
221
- * @param {object} webGLData - TBD.
221
+ * @param {GraphicsData} webGLData - TBD.
222
222
  */
223
223
  export function buildRectangle(graphicsData, webGLData) {
224
224
  //
@@ -301,7 +301,7 @@ export function quadraticBezierCurve(fromX, fromY, cpX, cpY, toX, toY) {
301
301
  /**
302
302
  * TBD.
303
303
  * @param {object} graphicsData - TBD.
304
- * @param {object} webGLData - TBD.
304
+ * @param {GraphicsData} webGLData - TBD.
305
305
  */
306
306
  export function buildRoundedRectangle(graphicsData, webGLData) {
307
307
  const rrectData = graphicsData.shape;
@@ -351,7 +351,7 @@ export function buildRoundedRectangle(graphicsData, webGLData) {
351
351
  /**
352
352
  * TBD.
353
353
  * @param {object} graphicsData - TBD.
354
- * @param {object} webGLData - TBD.
354
+ * @param {GraphicsData} webGLData - TBD.
355
355
  */
356
356
  export function buildCircle(graphicsData, webGLData) {
357
357
  // need to convert points to a nice regular data
@@ -402,7 +402,7 @@ export function buildCircle(graphicsData, webGLData) {
402
402
  /**
403
403
  * TBD.
404
404
  * @param {object} graphicsData - TBD.
405
- * @param {object} webGLData - TBD.
405
+ * @param {GraphicsData} webGLData - TBD.
406
406
  */
407
407
  export function buildComplexPoly(graphicsData, webGLData) {
408
408
  // TODO - no need to copy this as it gets turned into a Float32Array anyways..
@@ -446,7 +446,7 @@ export function buildComplexPoly(graphicsData, webGLData) {
446
446
  /**
447
447
  * TBD.
448
448
  * @param {object} graphicsData - TBD.
449
- * @param {object} webGLData - TBD.
449
+ * @param {GraphicsData} webGLData - TBD.
450
450
  * @returns {boolean} TBD.
451
451
  */
452
452
  export function buildPoly(graphicsData, webGLData) {
@@ -1,7 +1,7 @@
1
1
  export class GraphicsData {
2
2
  /**
3
3
  * TBD.
4
- * @param gl - TBD.
4
+ * @param {WebGLRenderingContext} gl - TBD.
5
5
  */
6
6
  constructor(gl) {
7
7
  this.gl = gl;
@@ -4,6 +4,8 @@ import { Texture } from './texture';
4
4
  import { BaseTexture } from './base_texture';
5
5
  import { FilterTexture } from './filter_texture';
6
6
  import { CanvasBuffer } from '../canvas/buffer';
7
+ import { CanvasRenderer } from '../canvas/renderer';
8
+ import { WebGLRenderer } from './renderer';
7
9
  import { RENDER_WEBGL } from '../../core/const';
8
10
 
9
11
  export class RenderTexture extends Texture {
@@ -11,9 +13,9 @@ export class RenderTexture extends Texture {
11
13
  * TBD.
12
14
  * @param {number} width - TBD.
13
15
  * @param {number} height - TBD.
14
- * @param renderer
15
- * @param scaleMode
16
- * @param resolution
16
+ * @param {WebGLRenderer|CanvasRenderer} renderer - TBD.
17
+ * @param {number} scaleMode - TBD.
18
+ * @param {number} resolution - TBD.
17
19
  */
18
20
  constructor(width, height, renderer, scaleMode, resolution = 1) {
19
21
  const w = width || 100;
@@ -79,6 +81,7 @@ export class RenderTexture extends Texture {
79
81
 
80
82
  /**
81
83
  * TBD.
84
+ * @returns {HTMLImageElement} TBD.
82
85
  */
83
86
  getImage() {
84
87
  const image = new Image();
@@ -88,6 +91,7 @@ export class RenderTexture extends Texture {
88
91
 
89
92
  /**
90
93
  * TBD.
94
+ * @returns {string} TBD.
91
95
  */
92
96
  getBase64() {
93
97
  return this.getCanvas().toDataURL();
@@ -95,8 +99,10 @@ export class RenderTexture extends Texture {
95
99
 
96
100
  /**
97
101
  * TBD.
102
+ * @returns {HTMLCanvasElement} TBD.
98
103
  */
99
104
  getCanvas() {
100
105
  // TODO
106
+ return null;
101
107
  }
102
108
  }
@@ -22,12 +22,16 @@ import {
22
22
  import { remove } from '../canvas/pool';
23
23
  import { isPowerOfTwo } from '../../util/math';
24
24
  import { Point } from '../../geom/point';
25
+ import { Matrix } from '../../geom/matrix';
25
26
  import { WebGLShaderManager } from './shader_manager';
26
27
  import { WebGLSpriteBatch } from './sprite_batch';
27
28
  import * as WebGLMaskManager from './mask_manager';
28
29
  import { WebGLFilterManager } from './filter_manager';
29
30
  import { WebGLStencilManager } from './stencil_manager';
30
31
  import { WebGLBlendModeManager } from './blend_manager';
32
+ import { BaseTexture } from './base_texture';
33
+ import { DisplayObject } from '../../display/display_object';
34
+ import { Stage } from '../../core/stage';
31
35
  import { Game } from '../../core/game';
32
36
 
33
37
  export class WebGLRenderer {
@@ -39,6 +43,7 @@ export class WebGLRenderer {
39
43
  this.type = RENDER_WEBGL;
40
44
  this.resolution = game.config.resolution;
41
45
  this.autoResize = false;
46
+ this.contextLost = false;
42
47
  this.clearBeforeRender = game.config.clearBeforeRender;
43
48
  this.width = game.width;
44
49
  this.height = game.height;
@@ -119,6 +124,7 @@ export class WebGLRenderer {
119
124
 
120
125
  /**
121
126
  * TBD.
127
+ * @throws Error.
122
128
  */
123
129
  initContext() {
124
130
  const gl =
@@ -152,7 +158,7 @@ export class WebGLRenderer {
152
158
 
153
159
  /**
154
160
  * TBD.
155
- * @param stage
161
+ * @param {Stage} stage - TBD.
156
162
  */
157
163
  render(stage) {
158
164
  if (this.contextLost) {
@@ -174,10 +180,10 @@ export class WebGLRenderer {
174
180
 
175
181
  /**
176
182
  * TBD.
177
- * @param displayObject
178
- * @param projection
179
- * @param buffer
180
- * @param matrix - TBD.
183
+ * @param {DisplayObject} displayObject - TBD.
184
+ * @param {Point} projection - TBD.
185
+ * @param {object} buffer - TBD.
186
+ * @param {Matrix} matrix - TBD.
181
187
  */
182
188
  renderDisplayObject(displayObject, projection, buffer, matrix) {
183
189
  this.renderSession.blendModeManager.setBlendMode(BLEND_NORMAL);
@@ -220,7 +226,8 @@ export class WebGLRenderer {
220
226
 
221
227
  /**
222
228
  * TBD.
223
- * @param texture
229
+ * @param {BaseTexture} texture - TBD.
230
+ * @returns {boolean} TBD.
224
231
  */
225
232
  updateTexture(texture) {
226
233
  if (!texture.hasLoaded) {
@@ -6,7 +6,7 @@ import { compileProgram } from '../util';
6
6
  export class ComplexPrimitiveShader {
7
7
  /**
8
8
  * TBD.
9
- * @param gl - TBD.
9
+ * @param {WebGLRenderingContext} gl - TBD.
10
10
  */
11
11
  constructor(gl) {
12
12
  this.gl = gl;
@@ -6,7 +6,7 @@ import { compileProgram } from '../util';
6
6
  export class FastShader {
7
7
  /**
8
8
  * TBD.
9
- * @param gl - TBD.
9
+ * @param {WebGLRenderingContext} gl - TBD.
10
10
  */
11
11
  constructor(gl) {
12
12
  this.gl = gl;
@@ -26,7 +26,7 @@ const defaultVertexSrc = [
26
26
  export class NormalShader {
27
27
  /**
28
28
  * TBD.
29
- * @param gl - TBD.
29
+ * @param {WebGLRenderingContext} gl - TBD.
30
30
  */
31
31
  constructor(gl) {
32
32
  this.gl = gl;
@@ -131,7 +131,7 @@ export class NormalShader {
131
131
 
132
132
  /**
133
133
  * TBD.
134
- * @param uniform
134
+ * @param {object} uniform - TBD.
135
135
  */
136
136
  initSampler2D(uniform) {
137
137
  if (!uniform.value || !uniform.value.baseTexture || !uniform.value.baseTexture.hasLoaded) {
@@ -6,7 +6,7 @@ import { compileProgram } from '../util';
6
6
  export class PrimitiveShader {
7
7
  /**
8
8
  * TBD.
9
- * @param gl - TBD.
9
+ * @param {WebGLRenderingContext} gl - TBD.
10
10
  */
11
11
  constructor(gl) {
12
12
  this.gl = gl;
@@ -6,7 +6,7 @@ import { compileProgram } from '../util';
6
6
  export class StripShader {
7
7
  /**
8
8
  * TBD.
9
- * @param gl - TBD.
9
+ * @param {WebGLRenderingContext} gl - TBD.
10
10
  */
11
11
  constructor(gl) {
12
12
  this.gl = gl;
@@ -26,7 +26,7 @@ export class WebGLShaderManager {
26
26
 
27
27
  /**
28
28
  * TBD.
29
- * @param gl - TBD.
29
+ * @param {WebGLRenderingContext} gl - TBD.
30
30
  */
31
31
  setContext(gl) {
32
32
  this.gl = gl;
@@ -40,7 +40,7 @@ export class WebGLShaderManager {
40
40
 
41
41
  /**
42
42
  * TBD.
43
- * @param attribs
43
+ * @param {number[]} attribs - TBD.
44
44
  */
45
45
  setAttribs(attribs) {
46
46
  // reset temp state
@@ -68,7 +68,8 @@ export class WebGLShaderManager {
68
68
 
69
69
  /**
70
70
  * TBD.
71
- * @param shader
71
+ * @param {NormalShader} shader - TBD.
72
+ * @returns {boolean} TBD.
72
73
  */
73
74
  setShader(shader) {
74
75
  if (this._currentId === shader._UID) {