@vpmedia/phaser 1.15.0 → 1.17.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 (290) hide show
  1. package/README.md +3 -3
  2. package/package.json +6 -5
  3. package/src/index.js +15 -18
  4. package/src/phaser/core/animation.js +114 -6
  5. package/src/phaser/core/animation_manager.js +102 -10
  6. package/src/phaser/core/animation_parser.js +6 -19
  7. package/src/phaser/core/array_set.js +59 -5
  8. package/src/phaser/core/cache.js +307 -6
  9. package/src/phaser/core/const.js +107 -4
  10. package/src/phaser/core/device.js +3 -6
  11. package/src/phaser/core/device_util.js +3 -16
  12. package/src/phaser/core/dom.js +127 -29
  13. package/src/phaser/core/event_manager.js +128 -6
  14. package/src/phaser/core/factory.js +69 -34
  15. package/src/phaser/core/frame.js +43 -6
  16. package/src/phaser/core/frame_data.js +55 -5
  17. package/src/phaser/core/frame_util.js +7 -12
  18. package/src/phaser/core/game.js +35 -7
  19. package/src/phaser/core/input.js +133 -17
  20. package/src/phaser/core/input_handler.js +243 -43
  21. package/src/phaser/core/input_mouse.js +70 -5
  22. package/src/phaser/core/input_mspointer.js +40 -9
  23. package/src/phaser/core/input_pointer.js +88 -17
  24. package/src/phaser/core/input_touch.js +42 -5
  25. package/src/phaser/core/loader.js +303 -101
  26. package/src/phaser/core/loader_parser.js +2 -10
  27. package/src/phaser/core/raf.js +16 -5
  28. package/src/phaser/core/scale_manager.js +204 -39
  29. package/src/phaser/core/scene.js +24 -5
  30. package/src/phaser/core/scene_manager.js +81 -11
  31. package/src/phaser/core/signal.js +88 -11
  32. package/src/phaser/core/signal_binding.js +35 -15
  33. package/src/phaser/core/sound.js +99 -10
  34. package/src/phaser/core/sound_manager.js +89 -13
  35. package/src/phaser/core/sound_sprite.js +20 -5
  36. package/src/phaser/core/stage.js +43 -7
  37. package/src/phaser/core/time.js +67 -5
  38. package/src/phaser/core/timer.js +107 -30
  39. package/src/phaser/core/timer_event.js +11 -6
  40. package/src/phaser/core/tween.js +124 -30
  41. package/src/phaser/core/tween_data.js +42 -18
  42. package/src/phaser/core/tween_easing.js +1 -8
  43. package/src/phaser/core/tween_manager.js +47 -5
  44. package/src/phaser/core/world.js +9 -6
  45. package/src/phaser/display/bitmap_text.js +91 -10
  46. package/src/phaser/display/button.js +63 -12
  47. package/src/phaser/display/canvas/buffer.js +16 -6
  48. package/src/phaser/display/canvas/graphics.js +1 -13
  49. package/src/phaser/display/canvas/masker.js +0 -6
  50. package/src/phaser/display/canvas/pool.js +0 -7
  51. package/src/phaser/display/canvas/renderer.js +28 -8
  52. package/src/phaser/display/canvas/tinter.js +4 -43
  53. package/src/phaser/display/canvas/util.js +0 -6
  54. package/src/phaser/display/display_object.js +192 -20
  55. package/src/phaser/display/graphics.js +161 -26
  56. package/src/phaser/display/graphics_data.js +14 -6
  57. package/src/phaser/display/graphics_data_util.js +2 -8
  58. package/src/phaser/display/group.js +82 -9
  59. package/src/phaser/display/image.js +87 -9
  60. package/src/phaser/display/sprite_batch.js +3 -8
  61. package/src/phaser/display/sprite_util.js +3 -23
  62. package/src/phaser/display/text.js +331 -31
  63. package/src/phaser/display/webgl/abstract_filter.js +8 -7
  64. package/src/phaser/display/webgl/base_texture.js +20 -12
  65. package/src/phaser/display/webgl/blend_manager.js +14 -7
  66. package/src/phaser/display/webgl/earcut.js +4 -23
  67. package/src/phaser/display/webgl/earcut_node.js +6 -7
  68. package/src/phaser/display/webgl/fast_sprite_batch.js +34 -11
  69. package/src/phaser/display/webgl/filter_manager.js +25 -7
  70. package/src/phaser/display/webgl/filter_texture.js +21 -22
  71. package/src/phaser/display/webgl/graphics.js +5 -28
  72. package/src/phaser/display/webgl/graphics_data.js +10 -7
  73. package/src/phaser/display/webgl/mask_manager.js +0 -6
  74. package/src/phaser/display/webgl/render_texture.js +33 -21
  75. package/src/phaser/display/webgl/renderer.js +38 -11
  76. package/src/phaser/display/webgl/shader/complex.js +10 -6
  77. package/src/phaser/display/webgl/shader/fast.js +10 -6
  78. package/src/phaser/display/webgl/shader/normal.js +23 -32
  79. package/src/phaser/display/webgl/shader/primitive.js +10 -6
  80. package/src/phaser/display/webgl/shader/strip.js +10 -6
  81. package/src/phaser/display/webgl/shader_manager.js +18 -6
  82. package/src/phaser/display/webgl/sprite_batch.js +41 -8
  83. package/src/phaser/display/webgl/stencil_manager.js +28 -6
  84. package/src/phaser/display/webgl/texture.js +28 -15
  85. package/src/phaser/display/webgl/texture_util.js +0 -6
  86. package/src/phaser/display/webgl/util.js +0 -7
  87. package/src/phaser/geom/circle.js +123 -18
  88. package/src/phaser/geom/ellipse.js +39 -18
  89. package/src/phaser/geom/line.js +148 -16
  90. package/src/phaser/geom/matrix.js +73 -6
  91. package/src/phaser/geom/point.js +152 -6
  92. package/src/phaser/geom/polygon.js +42 -14
  93. package/src/phaser/geom/rectangle.js +233 -6
  94. package/src/phaser/geom/rounded_rectangle.js +10 -6
  95. package/src/phaser/geom/util/circle.js +3 -9
  96. package/src/phaser/geom/util/ellipse.js +0 -7
  97. package/src/phaser/geom/util/line.js +5 -14
  98. package/src/phaser/geom/util/matrix.js +1 -7
  99. package/src/phaser/geom/util/point.js +0 -6
  100. package/src/phaser/geom/util/polygon.js +1 -7
  101. package/src/phaser/geom/util/rectangle.js +1 -7
  102. package/src/phaser/geom/util/rounded_rectangle.js +1 -7
  103. package/src/phaser/util/math.js +3 -21
  104. package/types/index.d.ts +2 -1
  105. package/types/index.d.ts.map +1 -1
  106. package/types/phaser/core/animation.d.ts +126 -13
  107. package/types/phaser/core/animation.d.ts.map +1 -1
  108. package/types/phaser/core/animation_manager.d.ts +121 -19
  109. package/types/phaser/core/animation_manager.d.ts.map +1 -1
  110. package/types/phaser/core/animation_parser.d.ts +6 -5
  111. package/types/phaser/core/animation_parser.d.ts.map +1 -1
  112. package/types/phaser/core/array_set.d.ts +67 -13
  113. package/types/phaser/core/array_set.d.ts.map +1 -1
  114. package/types/phaser/core/cache.d.ts +365 -69
  115. package/types/phaser/core/cache.d.ts.map +1 -1
  116. package/types/phaser/core/const.d.ts +143 -40
  117. package/types/phaser/core/const.d.ts.map +1 -1
  118. package/types/phaser/core/device.d.ts +0 -5
  119. package/types/phaser/core/device.d.ts.map +1 -1
  120. package/types/phaser/core/device_util.d.ts +1 -1
  121. package/types/phaser/core/device_util.d.ts.map +1 -1
  122. package/types/phaser/core/dom.d.ts +119 -0
  123. package/types/phaser/core/dom.d.ts.map +1 -1
  124. package/types/phaser/core/event_manager.d.ts +127 -0
  125. package/types/phaser/core/event_manager.d.ts.map +1 -1
  126. package/types/phaser/core/factory.d.ts +75 -8
  127. package/types/phaser/core/factory.d.ts.map +1 -1
  128. package/types/phaser/core/frame.d.ts +64 -21
  129. package/types/phaser/core/frame.d.ts.map +1 -1
  130. package/types/phaser/core/frame_data.d.ts +61 -9
  131. package/types/phaser/core/frame_data.d.ts.map +1 -1
  132. package/types/phaser/core/frame_util.d.ts +10 -8
  133. package/types/phaser/core/frame_util.d.ts.map +1 -1
  134. package/types/phaser/core/game.d.ts +40 -6
  135. package/types/phaser/core/game.d.ts.map +1 -1
  136. package/types/phaser/core/input.d.ts +143 -15
  137. package/types/phaser/core/input.d.ts.map +1 -1
  138. package/types/phaser/core/input_handler.d.ts +258 -25
  139. package/types/phaser/core/input_handler.d.ts.map +1 -1
  140. package/types/phaser/core/input_mouse.d.ts +62 -14
  141. package/types/phaser/core/input_mouse.d.ts.map +1 -1
  142. package/types/phaser/core/input_mspointer.d.ts +51 -17
  143. package/types/phaser/core/input_mspointer.d.ts.map +1 -1
  144. package/types/phaser/core/input_pointer.d.ts +99 -14
  145. package/types/phaser/core/input_pointer.d.ts.map +1 -1
  146. package/types/phaser/core/input_touch.d.ts +53 -16
  147. package/types/phaser/core/input_touch.d.ts.map +1 -1
  148. package/types/phaser/core/loader.d.ts +299 -28
  149. package/types/phaser/core/loader.d.ts.map +1 -1
  150. package/types/phaser/core/loader_parser.d.ts.map +1 -1
  151. package/types/phaser/core/raf.d.ts +19 -9
  152. package/types/phaser/core/raf.d.ts.map +1 -1
  153. package/types/phaser/core/scale_manager.d.ts +208 -13
  154. package/types/phaser/core/scale_manager.d.ts.map +1 -1
  155. package/types/phaser/core/scene.d.ts +21 -5
  156. package/types/phaser/core/scene.d.ts.map +1 -1
  157. package/types/phaser/core/scene_manager.d.ts +90 -10
  158. package/types/phaser/core/scene_manager.d.ts.map +1 -1
  159. package/types/phaser/core/signal.d.ts +93 -9
  160. package/types/phaser/core/signal.d.ts.map +1 -1
  161. package/types/phaser/core/signal_binding.d.ts +34 -5
  162. package/types/phaser/core/signal_binding.d.ts.map +1 -1
  163. package/types/phaser/core/sound.d.ts +111 -14
  164. package/types/phaser/core/sound.d.ts.map +1 -1
  165. package/types/phaser/core/sound_manager.d.ts +97 -11
  166. package/types/phaser/core/sound_manager.d.ts.map +1 -1
  167. package/types/phaser/core/sound_sprite.d.ts +22 -8
  168. package/types/phaser/core/sound_sprite.d.ts.map +1 -1
  169. package/types/phaser/core/stage.d.ts +32 -3
  170. package/types/phaser/core/stage.d.ts.map +1 -1
  171. package/types/phaser/core/time.d.ts +73 -6
  172. package/types/phaser/core/time.d.ts.map +1 -1
  173. package/types/phaser/core/timer.d.ts +108 -7
  174. package/types/phaser/core/timer.d.ts.map +1 -1
  175. package/types/phaser/core/timer_event.d.ts +13 -7
  176. package/types/phaser/core/timer_event.d.ts.map +1 -1
  177. package/types/phaser/core/tween.d.ts +124 -4
  178. package/types/phaser/core/tween.d.ts.map +1 -1
  179. package/types/phaser/core/tween_data.d.ts +41 -2
  180. package/types/phaser/core/tween_data.d.ts.map +1 -1
  181. package/types/phaser/core/tween_easing.d.ts +0 -5
  182. package/types/phaser/core/tween_easing.d.ts.map +1 -1
  183. package/types/phaser/core/tween_manager.d.ts +49 -2
  184. package/types/phaser/core/tween_manager.d.ts.map +1 -1
  185. package/types/phaser/core/world.d.ts +9 -1
  186. package/types/phaser/core/world.d.ts.map +1 -1
  187. package/types/phaser/display/bitmap_text.d.ts +84 -7
  188. package/types/phaser/display/bitmap_text.d.ts.map +1 -1
  189. package/types/phaser/display/button.d.ts +65 -8
  190. package/types/phaser/display/button.d.ts.map +1 -1
  191. package/types/phaser/display/canvas/buffer.d.ts +20 -4
  192. package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
  193. package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
  194. package/types/phaser/display/canvas/masker.d.ts.map +1 -1
  195. package/types/phaser/display/canvas/pool.d.ts +0 -6
  196. package/types/phaser/display/canvas/pool.d.ts.map +1 -1
  197. package/types/phaser/display/canvas/renderer.d.ts +29 -2
  198. package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
  199. package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
  200. package/types/phaser/display/canvas/util.d.ts.map +1 -1
  201. package/types/phaser/display/display_object.d.ts +195 -8
  202. package/types/phaser/display/display_object.d.ts.map +1 -1
  203. package/types/phaser/display/graphics.d.ts +132 -6
  204. package/types/phaser/display/graphics.d.ts.map +1 -1
  205. package/types/phaser/display/graphics_data.d.ts +15 -1
  206. package/types/phaser/display/graphics_data.d.ts.map +1 -1
  207. package/types/phaser/display/graphics_data_util.d.ts +3 -2
  208. package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
  209. package/types/phaser/display/group.d.ts +80 -10
  210. package/types/phaser/display/group.d.ts.map +1 -1
  211. package/types/phaser/display/image.d.ts +72 -6
  212. package/types/phaser/display/image.d.ts.map +1 -1
  213. package/types/phaser/display/sprite_batch.d.ts +4 -3
  214. package/types/phaser/display/sprite_batch.d.ts.map +1 -1
  215. package/types/phaser/display/sprite_util.d.ts.map +1 -1
  216. package/types/phaser/display/text.d.ts +366 -46
  217. package/types/phaser/display/text.d.ts.map +1 -1
  218. package/types/phaser/display/webgl/abstract_filter.d.ts +8 -6
  219. package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  220. package/types/phaser/display/webgl/base_texture.d.ts +20 -1
  221. package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
  222. package/types/phaser/display/webgl/blend_manager.d.ts +11 -6
  223. package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  224. package/types/phaser/display/webgl/earcut.d.ts.map +1 -1
  225. package/types/phaser/display/webgl/earcut_node.d.ts +9 -9
  226. package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  227. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +33 -6
  228. package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  229. package/types/phaser/display/webgl/filter_manager.d.ts +22 -6
  230. package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  231. package/types/phaser/display/webgl/filter_texture.d.ts +21 -3
  232. package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  233. package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
  234. package/types/phaser/display/webgl/graphics_data.d.ts +10 -6
  235. package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  236. package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  237. package/types/phaser/display/webgl/render_texture.d.ts +30 -3
  238. package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
  239. package/types/phaser/display/webgl/renderer.d.ts +41 -4
  240. package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
  241. package/types/phaser/display/webgl/shader/complex.d.ts +10 -0
  242. package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  243. package/types/phaser/display/webgl/shader/fast.d.ts +10 -0
  244. package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  245. package/types/phaser/display/webgl/shader/normal.d.ts +20 -0
  246. package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  247. package/types/phaser/display/webgl/shader/primitive.d.ts +10 -0
  248. package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  249. package/types/phaser/display/webgl/shader/strip.d.ts +10 -0
  250. package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  251. package/types/phaser/display/webgl/shader_manager.d.ts +15 -0
  252. package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  253. package/types/phaser/display/webgl/sprite_batch.d.ts +37 -0
  254. package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  255. package/types/phaser/display/webgl/stencil_manager.d.ts +25 -0
  256. package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  257. package/types/phaser/display/webgl/texture.d.ts +21 -0
  258. package/types/phaser/display/webgl/texture.d.ts.map +1 -1
  259. package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
  260. package/types/phaser/display/webgl/util.d.ts +0 -6
  261. package/types/phaser/display/webgl/util.d.ts.map +1 -1
  262. package/types/phaser/geom/circle.d.ts +131 -9
  263. package/types/phaser/geom/circle.d.ts.map +1 -1
  264. package/types/phaser/geom/ellipse.d.ts +43 -5
  265. package/types/phaser/geom/ellipse.d.ts.map +1 -1
  266. package/types/phaser/geom/line.d.ts +159 -13
  267. package/types/phaser/geom/line.d.ts.map +1 -1
  268. package/types/phaser/geom/matrix.d.ts +85 -11
  269. package/types/phaser/geom/matrix.d.ts.map +1 -1
  270. package/types/phaser/geom/point.d.ts +170 -18
  271. package/types/phaser/geom/point.d.ts.map +1 -1
  272. package/types/phaser/geom/polygon.d.ts +45 -5
  273. package/types/phaser/geom/polygon.d.ts.map +1 -1
  274. package/types/phaser/geom/rectangle.d.ts +253 -20
  275. package/types/phaser/geom/rectangle.d.ts.map +1 -1
  276. package/types/phaser/geom/rounded_rectangle.d.ts +11 -1
  277. package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  278. package/types/phaser/geom/util/circle.d.ts +3 -3
  279. package/types/phaser/geom/util/circle.d.ts.map +1 -1
  280. package/types/phaser/geom/util/ellipse.d.ts +0 -6
  281. package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
  282. package/types/phaser/geom/util/line.d.ts +5 -5
  283. package/types/phaser/geom/util/line.d.ts.map +1 -1
  284. package/types/phaser/geom/util/matrix.d.ts.map +1 -1
  285. package/types/phaser/geom/util/point.d.ts.map +1 -1
  286. package/types/phaser/geom/util/polygon.d.ts.map +1 -1
  287. package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
  288. package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  289. package/types/phaser/util/math.d.ts +0 -5
  290. package/types/phaser/util/math.d.ts.map +1 -1
@@ -1,9 +1,3 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
1
  import {
8
2
  RENDER_WEBGL,
9
3
  SCALE_LINEAR,
@@ -34,8 +28,13 @@ import * as WebGLMaskManager from './mask_manager';
34
28
  import { WebGLFilterManager } from './filter_manager';
35
29
  import { WebGLStencilManager } from './stencil_manager';
36
30
  import { WebGLBlendModeManager } from './blend_manager';
31
+ import { Game } from '../../core/game';
37
32
 
38
33
  export class WebGLRenderer {
34
+ /**
35
+ * TBD.
36
+ * @param {Game} game - TBD.
37
+ */
39
38
  constructor(game) {
40
39
  this.type = RENDER_WEBGL;
41
40
  this.resolution = game.config.resolution;
@@ -75,6 +74,9 @@ export class WebGLRenderer {
75
74
  this.mapBlendModes();
76
75
  }
77
76
 
77
+ /**
78
+ * TBD.
79
+ */
78
80
  destroy() {
79
81
  window.PhaserRegistry.GL_CONTEXTS[this.glContextId] = null;
80
82
  this.projection = null;
@@ -100,6 +102,9 @@ export class WebGLRenderer {
100
102
  window.PhaserRegistry.GL_CONTEXT_ID -= 1;
101
103
  }
102
104
 
105
+ /**
106
+ * TBD.
107
+ */
103
108
  initRegistry() {
104
109
  if (!window.PhaserRegistry.GL_CONTEXT_ID) {
105
110
  window.PhaserRegistry.GL_CONTEXT_ID = 0;
@@ -112,6 +117,9 @@ export class WebGLRenderer {
112
117
  }
113
118
  }
114
119
 
120
+ /**
121
+ * TBD.
122
+ */
115
123
  initContext() {
116
124
  const gl =
117
125
  this.view.getContext('webgl', this._contextOptions) ||
@@ -142,6 +150,10 @@ export class WebGLRenderer {
142
150
  this.resize(this.width, this.height);
143
151
  }
144
152
 
153
+ /**
154
+ * TBD.
155
+ * @param stage
156
+ */
145
157
  render(stage) {
146
158
  if (this.contextLost) {
147
159
  return;
@@ -160,6 +172,13 @@ export class WebGLRenderer {
160
172
  this.renderDisplayObject(stage, this.projection);
161
173
  }
162
174
 
175
+ /**
176
+ * TBD.
177
+ * @param displayObject
178
+ * @param projection
179
+ * @param buffer
180
+ * @param matrix - TBD.
181
+ */
163
182
  renderDisplayObject(displayObject, projection, buffer, matrix) {
164
183
  this.renderSession.blendModeManager.setBlendMode(BLEND_NORMAL);
165
184
  // reset the render session data..
@@ -180,6 +199,11 @@ export class WebGLRenderer {
180
199
  this.spriteBatch.end();
181
200
  }
182
201
 
202
+ /**
203
+ * TBD.
204
+ * @param {number} width - TBD.
205
+ * @param {number} height - TBD.
206
+ */
183
207
  resize(width, height) {
184
208
  this.width = width * this.resolution;
185
209
  this.height = height * this.resolution;
@@ -194,6 +218,10 @@ export class WebGLRenderer {
194
218
  this.projection.y = -this.height / 2 / this.resolution;
195
219
  }
196
220
 
221
+ /**
222
+ * TBD.
223
+ * @param texture
224
+ */
197
225
  updateTexture(texture) {
198
226
  if (!texture.hasLoaded) {
199
227
  return false;
@@ -205,11 +233,7 @@ export class WebGLRenderer {
205
233
  gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id]);
206
234
  gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha);
207
235
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source);
208
- gl.texParameteri(
209
- gl.TEXTURE_2D,
210
- gl.TEXTURE_MAG_FILTER,
211
- texture.scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST
212
- );
236
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST);
213
237
  if (texture.mipmap && isPowerOfTwo(texture.width, texture.height)) {
214
238
  gl.texParameteri(
215
239
  gl.TEXTURE_2D,
@@ -236,6 +260,9 @@ export class WebGLRenderer {
236
260
  return true;
237
261
  }
238
262
 
263
+ /**
264
+ * TBD.
265
+ */
239
266
  mapBlendModes() {
240
267
  if (window.PhaserRegistry.blendModesWebGL) {
241
268
  return;
@@ -1,15 +1,13 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
1
  import { generateShaderID } from '../../../util/math';
8
2
  import { compileProgram } from '../util';
9
3
 
10
4
  // the next one is used for rendering triangle strips
11
5
 
12
6
  export class ComplexPrimitiveShader {
7
+ /**
8
+ * TBD.
9
+ * @param gl - TBD.
10
+ */
13
11
  constructor(gl) {
14
12
  this.gl = gl;
15
13
  this._UID = generateShaderID();
@@ -44,6 +42,9 @@ export class ComplexPrimitiveShader {
44
42
  this.init();
45
43
  }
46
44
 
45
+ /**
46
+ * TBD.
47
+ */
47
48
  init() {
48
49
  const gl = this.gl;
49
50
  const program = compileProgram(gl, this.vertexSrc, this.fragmentSrc);
@@ -63,6 +64,9 @@ export class ComplexPrimitiveShader {
63
64
  this.program = program;
64
65
  }
65
66
 
67
+ /**
68
+ * TBD.
69
+ */
66
70
  destroy() {
67
71
  this.gl.deleteProgram(this.program);
68
72
  this.uniforms = null;
@@ -1,15 +1,13 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
1
  import { generateShaderID } from '../../../util/math';
8
2
  import { compileProgram } from '../util';
9
3
 
10
4
  // this shader is used for the fast sprite rendering
11
5
 
12
6
  export class FastShader {
7
+ /**
8
+ * TBD.
9
+ * @param gl - TBD.
10
+ */
13
11
  constructor(gl) {
14
12
  this.gl = gl;
15
13
  this._UID = generateShaderID();
@@ -56,6 +54,9 @@ export class FastShader {
56
54
  this.init();
57
55
  }
58
56
 
57
+ /**
58
+ * TBD.
59
+ */
59
60
  init() {
60
61
  const gl = this.gl;
61
62
  const program = compileProgram(gl, this.vertexSrc, this.fragmentSrc);
@@ -93,6 +94,9 @@ export class FastShader {
93
94
  this.program = program;
94
95
  }
95
96
 
97
+ /**
98
+ * TBD.
99
+ */
96
100
  destroy() {
97
101
  this.gl.deleteProgram(this.program);
98
102
  this.uniforms = null;
@@ -1,9 +1,3 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
1
  import { generateShaderID } from '../../../util/math';
8
2
  import { compileProgram } from '../util';
9
3
 
@@ -30,6 +24,10 @@ const defaultVertexSrc = [
30
24
  // this shader is used for the default sprite rendering
31
25
 
32
26
  export class NormalShader {
27
+ /**
28
+ * TBD.
29
+ * @param gl - TBD.
30
+ */
33
31
  constructor(gl) {
34
32
  this.gl = gl;
35
33
  this._UID = generateShaderID();
@@ -51,6 +49,9 @@ export class NormalShader {
51
49
  this.init();
52
50
  }
53
51
 
52
+ /**
53
+ * TBD.
54
+ */
54
55
  init() {
55
56
  const gl = this.gl;
56
57
  const program = compileProgram(gl, this.vertexSrc || defaultVertexSrc, this.fragmentSrc);
@@ -84,6 +85,9 @@ export class NormalShader {
84
85
  this.program = program;
85
86
  }
86
87
 
88
+ /**
89
+ * TBD.
90
+ */
87
91
  initUniforms() {
88
92
  this.textureCount = 1;
89
93
  const gl = this.gl;
@@ -125,6 +129,10 @@ export class NormalShader {
125
129
  }
126
130
  }
127
131
 
132
+ /**
133
+ * TBD.
134
+ * @param uniform
135
+ */
128
136
  initSampler2D(uniform) {
129
137
  if (!uniform.value || !uniform.value.baseTexture || !uniform.value.baseTexture.hasLoaded) {
130
138
  return;
@@ -159,27 +167,10 @@ export class NormalShader {
159
167
  const border = data.border ? data.border : 0;
160
168
 
161
169
  // void texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels);
162
- gl.texImage2D(
163
- gl.TEXTURE_2D,
164
- 0,
165
- format,
166
- width,
167
- height,
168
- border,
169
- format,
170
- gl.UNSIGNED_BYTE,
171
- null
172
- );
170
+ gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, border, format, gl.UNSIGNED_BYTE, null);
173
171
  } else {
174
172
  // void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, ImageData? pixels);
175
- gl.texImage2D(
176
- gl.TEXTURE_2D,
177
- 0,
178
- format,
179
- gl.RGBA,
180
- gl.UNSIGNED_BYTE,
181
- uniform.value.baseTexture.source
182
- );
173
+ gl.texImage2D(gl.TEXTURE_2D, 0, format, gl.RGBA, gl.UNSIGNED_BYTE, uniform.value.baseTexture.source);
183
174
  }
184
175
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
185
176
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
@@ -191,6 +182,9 @@ export class NormalShader {
191
182
  this.textureCount += 1;
192
183
  }
193
184
 
185
+ /**
186
+ * TBD.
187
+ */
194
188
  syncUniforms() {
195
189
  this.textureCount = 1;
196
190
  let uniform;
@@ -209,13 +203,7 @@ export class NormalShader {
209
203
  } else if (uniform.glValueLength === 2) {
210
204
  uniform.glFunc.call(gl, uniform.uniformLocation, uniform.value.x, uniform.value.y);
211
205
  } else if (uniform.glValueLength === 3) {
212
- uniform.glFunc.call(
213
- gl,
214
- uniform.uniformLocation,
215
- uniform.value.x,
216
- uniform.value.y,
217
- uniform.value.z
218
- );
206
+ uniform.glFunc.call(gl, uniform.uniformLocation, uniform.value.x, uniform.value.y, uniform.value.z);
219
207
  } else if (uniform.glValueLength === 4) {
220
208
  uniform.glFunc.call(
221
209
  gl,
@@ -244,6 +232,9 @@ export class NormalShader {
244
232
  }
245
233
  }
246
234
 
235
+ /**
236
+ * TBD.
237
+ */
247
238
  destroy() {
248
239
  this.gl.deleteProgram(this.program);
249
240
  this.uniforms = null;
@@ -1,15 +1,13 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
1
  import { generateShaderID } from '../../../util/math';
8
2
  import { compileProgram } from '../util';
9
3
 
10
4
  // the next one is used for rendering primitives
11
5
 
12
6
  export class PrimitiveShader {
7
+ /**
8
+ * TBD.
9
+ * @param gl - TBD.
10
+ */
13
11
  constructor(gl) {
14
12
  this.gl = gl;
15
13
  this._UID = generateShaderID();
@@ -43,6 +41,9 @@ export class PrimitiveShader {
43
41
  this.init();
44
42
  }
45
43
 
44
+ /**
45
+ * TBD.
46
+ */
46
47
  init() {
47
48
  const gl = this.gl;
48
49
  const program = compileProgram(gl, this.vertexSrc, this.fragmentSrc);
@@ -61,6 +62,9 @@ export class PrimitiveShader {
61
62
  this.program = program;
62
63
  }
63
64
 
65
+ /**
66
+ * TBD.
67
+ */
64
68
  destroy() {
65
69
  this.gl.deleteProgram(this.program);
66
70
  this.uniforms = null;
@@ -1,15 +1,13 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
1
  import { generateShaderID } from '../../../util/math';
8
2
  import { compileProgram } from '../util';
9
3
 
10
4
  // the next one is used for rendering triangle strips
11
5
 
12
6
  export class StripShader {
7
+ /**
8
+ * TBD.
9
+ * @param gl - TBD.
10
+ */
13
11
  constructor(gl) {
14
12
  this.gl = gl;
15
13
  this._UID = generateShaderID();
@@ -47,6 +45,9 @@ export class StripShader {
47
45
  this.init();
48
46
  }
49
47
 
48
+ /**
49
+ * TBD.
50
+ */
50
51
  init() {
51
52
  const gl = this.gl;
52
53
  const program = compileProgram(gl, this.vertexSrc, this.fragmentSrc);
@@ -66,6 +67,9 @@ export class StripShader {
66
67
  this.program = program;
67
68
  }
68
69
 
70
+ /**
71
+ * TBD.
72
+ */
69
73
  destroy() {
70
74
  this.gl.deleteProgram(this.program);
71
75
  this.uniforms = null;
@@ -1,9 +1,3 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
1
  import { PrimitiveShader } from './shader/primitive';
8
2
  import { ComplexPrimitiveShader } from './shader/complex';
9
3
  import { NormalShader } from './shader/normal';
@@ -11,6 +5,9 @@ import { FastShader } from './shader/fast';
11
5
  import { StripShader } from './shader/strip';
12
6
 
13
7
  export class WebGLShaderManager {
8
+ /**
9
+ * TBD.
10
+ */
14
11
  constructor() {
15
12
  this.gl = null;
16
13
  this.primitiveShader = null;
@@ -27,6 +24,10 @@ export class WebGLShaderManager {
27
24
  this.stack = [];
28
25
  }
29
26
 
27
+ /**
28
+ * TBD.
29
+ * @param gl - TBD.
30
+ */
30
31
  setContext(gl) {
31
32
  this.gl = gl;
32
33
  this.primitiveShader = new PrimitiveShader(gl);
@@ -37,6 +38,10 @@ export class WebGLShaderManager {
37
38
  this.setShader(this.defaultShader);
38
39
  }
39
40
 
41
+ /**
42
+ * TBD.
43
+ * @param attribs
44
+ */
40
45
  setAttribs(attribs) {
41
46
  // reset temp state
42
47
  let i;
@@ -61,6 +66,10 @@ export class WebGLShaderManager {
61
66
  }
62
67
  }
63
68
 
69
+ /**
70
+ * TBD.
71
+ * @param shader
72
+ */
64
73
  setShader(shader) {
65
74
  if (this._currentId === shader._UID) {
66
75
  return false;
@@ -72,6 +81,9 @@ export class WebGLShaderManager {
72
81
  return true;
73
82
  }
74
83
 
84
+ /**
85
+ * TBD.
86
+ */
75
87
  destroy() {
76
88
  this.attribState = null;
77
89
  this.tempAttribState = null;
@@ -1,13 +1,10 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
1
  import { AbstractFilter } from './abstract_filter';
8
2
  import { NormalShader } from './shader/normal';
9
3
 
10
4
  export class WebGLSpriteBatch {
5
+ /**
6
+ * TBD.
7
+ */
11
8
  constructor() {
12
9
  this.vertSize = 5;
13
10
  this.size = 2000; // Math.pow(2, 16) / this.vertSize;
@@ -47,6 +44,10 @@ export class WebGLSpriteBatch {
47
44
  ]);
48
45
  }
49
46
 
47
+ /**
48
+ * TBD.
49
+ * @param gl - TBD.
50
+ */
50
51
  setContext(gl) {
51
52
  this.gl = gl;
52
53
  // create a couple of buffers
@@ -66,16 +67,28 @@ export class WebGLSpriteBatch {
66
67
  this.defaultShader.shaders[gl.id] = shader;
67
68
  }
68
69
 
70
+ /**
71
+ * TBD.
72
+ * @param renderSession - TBD.
73
+ */
69
74
  begin(renderSession) {
70
75
  this.renderSession = renderSession;
71
76
  this.shader = this.renderSession.shaderManager.defaultShader;
72
77
  this.start();
73
78
  }
74
79
 
80
+ /**
81
+ * TBD.
82
+ */
75
83
  end() {
76
84
  this.flush();
77
85
  }
78
86
 
87
+ /**
88
+ * TBD.
89
+ * @param sprite
90
+ * @param matrix - TBD.
91
+ */
79
92
  render(sprite, matrix) {
80
93
  const texture = sprite.texture;
81
94
  // They provided an alternative rendering matrix, so use it
@@ -164,8 +177,7 @@ export class WebGLSpriteBatch {
164
177
  positions[i + 18] = uvs.y3;
165
178
  // color and alpha
166
179
  const tint = sprite.tint;
167
- colors[i + 4] =
168
- (tint >> 16) + (tint & 0xff00) + ((tint & 0xff) << 16) + ((sprite.worldAlpha * 255) << 24);
180
+ colors[i + 4] = (tint >> 16) + (tint & 0xff00) + ((tint & 0xff) << 16) + ((sprite.worldAlpha * 255) << 24);
169
181
  colors[i + 9] = colors[i + 4];
170
182
  colors[i + 14] = colors[i + 4];
171
183
  colors[i + 19] = colors[i + 4];
@@ -174,10 +186,16 @@ export class WebGLSpriteBatch {
174
186
  this.currentBatchSize += 1;
175
187
  }
176
188
 
189
+ /**
190
+ * TBD.
191
+ */
177
192
  renderTilingSprite() {
178
193
  // TODO
179
194
  }
180
195
 
196
+ /**
197
+ * TBD.
198
+ */
181
199
  flush() {
182
200
  // If the batch is length 0 then return as there is nothing to draw
183
201
  if (this.currentBatchSize === 0) {
@@ -274,6 +292,12 @@ export class WebGLSpriteBatch {
274
292
  this.currentBatchSize = 0;
275
293
  }
276
294
 
295
+ /**
296
+ * TBD.
297
+ * @param texture
298
+ * @param size
299
+ * @param startIndex
300
+ */
277
301
  renderBatch(texture, size, startIndex) {
278
302
  if (size === 0) {
279
303
  return;
@@ -295,15 +319,24 @@ export class WebGLSpriteBatch {
295
319
  this.renderSession.drawCount += 1;
296
320
  }
297
321
 
322
+ /**
323
+ * TBD.
324
+ */
298
325
  stop() {
299
326
  this.flush();
300
327
  this.dirty = true;
301
328
  }
302
329
 
330
+ /**
331
+ * TBD.
332
+ */
303
333
  start() {
304
334
  this.dirty = true;
305
335
  }
306
336
 
337
+ /**
338
+ * TBD.
339
+ */
307
340
  destroy() {
308
341
  this.vertices = null;
309
342
  this.positions = null;
@@ -1,27 +1,37 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
1
  import { hex2rgb } from '../../util/math';
8
2
 
9
3
  export class WebGLStencilManager {
4
+ /**
5
+ * TBD.
6
+ */
10
7
  constructor() {
11
8
  this.stencilStack = [];
12
9
  this.reverse = true;
13
10
  this.count = 0;
14
11
  }
15
12
 
13
+ /**
14
+ * TBD.
15
+ * @param gl - TBD.
16
+ */
16
17
  setContext(gl) {
17
18
  this.gl = gl;
18
19
  }
19
20
 
21
+ /**
22
+ * TBD.
23
+ */
20
24
  destroy() {
21
25
  this.stencilStack = null;
22
26
  this.gl = null;
23
27
  }
24
28
 
29
+ /**
30
+ * TBD.
31
+ * @param graphics - TBD.
32
+ * @param webGLData
33
+ * @param renderSession - TBD.
34
+ */
25
35
  pushStencil(graphics, webGLData, renderSession) {
26
36
  const gl = renderSession.gl;
27
37
  this.bindGraphics(graphics, webGLData, renderSession);
@@ -74,6 +84,12 @@ export class WebGLStencilManager {
74
84
  this.count += 1;
75
85
  }
76
86
 
87
+ /**
88
+ * TBD.
89
+ * @param graphics - TBD.
90
+ * @param webGLData
91
+ * @param renderSession - TBD.
92
+ */
77
93
  bindGraphics(graphics, webGLData, renderSession) {
78
94
  // if(this._currentGraphics === graphics)return;
79
95
  // this._currentGraphics = graphics;
@@ -115,6 +131,12 @@ export class WebGLStencilManager {
115
131
  }
116
132
  }
117
133
 
134
+ /**
135
+ * TBD.
136
+ * @param graphics - TBD.
137
+ * @param webGLData
138
+ * @param renderSession - TBD.
139
+ */
118
140
  popStencil(graphics, webGLData, renderSession) {
119
141
  const gl = renderSession.gl;
120
142
  this.stencilStack.pop();