@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,11 +1,9 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
-
8
1
  export class AbstractFilter {
2
+ /**
3
+ * TBD.
4
+ * @param fragmentSrc
5
+ * @param uniforms
6
+ */
9
7
  constructor(fragmentSrc, uniforms) {
10
8
  this.passes = [this];
11
9
  this.shaders = [];
@@ -15,6 +13,9 @@ export class AbstractFilter {
15
13
  this.fragmentSrc = fragmentSrc || [];
16
14
  }
17
15
 
16
+ /**
17
+ * TBD.
18
+ */
18
19
  syncUniforms() {
19
20
  for (let i = 0, j = this.shaders.length; i < j; i += 1) {
20
21
  this.shaders[i].dirty = true;
@@ -1,13 +1,11 @@
1
- /**
2
- * @module display/webgl/base_texture
3
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
4
- * @author Andras Csizmadia <andras@vpmedia.hu>
5
- * @author Richard Davey <rich@photonstorm.com>
6
- * @author Mat Groves http://matgroves.com/ @Doormat23
7
- */
8
1
  import { removeByCanvas } from '../canvas/pool';
9
2
 
10
3
  export class BaseTexture {
4
+ /**
5
+ * TBD.
6
+ * @param source
7
+ * @param scaleMode
8
+ */
11
9
  constructor(source, scaleMode) {
12
10
  this.resolution = 1;
13
11
  this.width = 100;
@@ -22,11 +20,7 @@ export class BaseTexture {
22
20
  this._powerOf2 = false;
23
21
  this._dirty = [true, true, true, true];
24
22
  if (source) {
25
- if (
26
- (this.source.complete || this.source.getContext) &&
27
- this.source.width &&
28
- this.source.height
29
- ) {
23
+ if ((this.source.complete || this.source.getContext) && this.source.width && this.source.height) {
30
24
  this.hasLoaded = true;
31
25
  this.width = this.source.naturalWidth || this.source.width;
32
26
  this.height = this.source.naturalHeight || this.source.height;
@@ -35,6 +29,11 @@ export class BaseTexture {
35
29
  }
36
30
  }
37
31
 
32
+ /**
33
+ * TBD.
34
+ * @param {number} width - TBD.
35
+ * @param {number} height - TBD.
36
+ */
38
37
  forceLoaded(width, height) {
39
38
  this.hasLoaded = true;
40
39
  this.width = width;
@@ -42,6 +41,9 @@ export class BaseTexture {
42
41
  this.dirty();
43
42
  }
44
43
 
44
+ /**
45
+ * TBD.
46
+ */
45
47
  destroy() {
46
48
  if (this.source) {
47
49
  removeByCanvas(this.source);
@@ -50,12 +52,18 @@ export class BaseTexture {
50
52
  this.unloadFromGPU();
51
53
  }
52
54
 
55
+ /**
56
+ * TBD.
57
+ */
53
58
  dirty() {
54
59
  for (let i = 0; i < this._glTextures.length; i += 1) {
55
60
  this._dirty[i] = true;
56
61
  }
57
62
  }
58
63
 
64
+ /**
65
+ * TBD.
66
+ */
59
67
  unloadFromGPU() {
60
68
  this.dirty();
61
69
  for (let i = this._glTextures.length - 1; i >= 0; i -= 1) {
@@ -1,20 +1,24 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
-
8
1
  export class WebGLBlendModeManager {
2
+ /**
3
+ * TBD.
4
+ */
9
5
  constructor() {
10
6
  this.gl = null;
11
7
  this.currentBlendMode = 99999;
12
8
  }
13
9
 
10
+ /**
11
+ * TBD.
12
+ * @param gl - TBD.
13
+ */
14
14
  setContext(gl) {
15
15
  this.gl = gl;
16
16
  }
17
17
 
18
+ /**
19
+ * TBD.
20
+ * @param blendMode
21
+ */
18
22
  setBlendMode(blendMode) {
19
23
  if (this.currentBlendMode === blendMode) {
20
24
  return false;
@@ -27,6 +31,9 @@ export class WebGLBlendModeManager {
27
31
  return true;
28
32
  }
29
33
 
34
+ /**
35
+ * TBD.
36
+ */
30
37
  destroy() {
31
38
  this.gl = null;
32
39
  }
@@ -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 { Node } from './earcut_node';
8
2
 
9
3
  /**
@@ -191,9 +185,7 @@ export function equals(p1, p2) {
191
185
  * @returns {boolean} TBD.
192
186
  */
193
187
  export function intersects(p1, q1, p2, q2) {
194
- return (
195
- area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0
196
- );
188
+ return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
197
189
  }
198
190
 
199
191
  /**
@@ -205,14 +197,7 @@ export function intersects(p1, q1, p2, q2) {
205
197
  export function intersectsPolygon(a, b) {
206
198
  let p = a;
207
199
  do {
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;
200
+ if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b)) return true;
216
201
  p = p.next;
217
202
  } while (p !== a);
218
203
  return false;
@@ -242,10 +227,7 @@ export function middleInside(a, b) {
242
227
  const px = (a.x + b.x) / 2;
243
228
  const py = (a.y + b.y) / 2;
244
229
  do {
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
- ) {
230
+ if (p.y > py !== p.next.y > py && px < ((p.next.x - p.x) * (py - p.y)) / (p.next.y - p.y) + p.x) {
249
231
  inside = !inside;
250
232
  }
251
233
  p = p.next;
@@ -343,8 +325,7 @@ export function isEar(ear) {
343
325
  // now make sure we don't have other points inside the potential ear
344
326
  let p = ear.next.next;
345
327
  while (p !== ear.prev) {
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;
328
+ 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) return false;
348
329
  p = p.next;
349
330
  }
350
331
  return true;
@@ -1,11 +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
-
8
1
  export class Node {
2
+ /**
3
+ * TBD.
4
+ * @param i
5
+ * @param {number} x - TBD.
6
+ * @param {number} y - TBD.
7
+ */
9
8
  constructor(i, x, y) {
10
9
  // vertice index in coordinates array
11
10
  this.i = i;
@@ -1,11 +1,8 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
-
8
1
  export class FastSpriteBatch {
2
+ /**
3
+ * TBD.
4
+ * @param gl - TBD.
5
+ */
9
6
  constructor(gl) {
10
7
  this.vertSize = 10;
11
8
  this.maxSize = 6000; // Math.pow(2, 16) / this.vertSize;
@@ -37,6 +34,10 @@ export class FastSpriteBatch {
37
34
  this.setContext(gl);
38
35
  }
39
36
 
37
+ /**
38
+ * TBD.
39
+ * @param gl - TBD.
40
+ */
40
41
  setContext(gl) {
41
42
  this.gl = gl;
42
43
  // create a couple of buffers
@@ -50,6 +51,11 @@ export class FastSpriteBatch {
50
51
  gl.bufferData(gl.ARRAY_BUFFER, this.vertices, gl.DYNAMIC_DRAW);
51
52
  }
52
53
 
54
+ /**
55
+ * TBD.
56
+ * @param spriteBatch
57
+ * @param renderSession - TBD.
58
+ */
53
59
  begin(spriteBatch, renderSession) {
54
60
  this.renderSession = renderSession;
55
61
  this.shader = this.renderSession.shaderManager.fastShader;
@@ -57,10 +63,17 @@ export class FastSpriteBatch {
57
63
  this.start();
58
64
  }
59
65
 
66
+ /**
67
+ * TBD.
68
+ */
60
69
  end() {
61
70
  this.flush();
62
71
  }
63
72
 
73
+ /**
74
+ * TBD.
75
+ * @param spriteBatch
76
+ */
64
77
  render(spriteBatch) {
65
78
  const children = spriteBatch.children;
66
79
  const sprite = children[0];
@@ -81,15 +94,16 @@ export class FastSpriteBatch {
81
94
  this.flush();
82
95
  }
83
96
 
97
+ /**
98
+ * TBD.
99
+ * @param sprite
100
+ */
84
101
  renderSprite(sprite) {
85
102
  if (!sprite.visible) {
86
103
  return;
87
104
  }
88
105
  // TODO trim??
89
- if (
90
- sprite.texture.baseTexture !== this.currentBaseTexture &&
91
- !sprite.texture.baseTexture.skipRender
92
- ) {
106
+ if (sprite.texture.baseTexture !== this.currentBaseTexture && !sprite.texture.baseTexture.skipRender) {
93
107
  this.flush();
94
108
  this.currentBaseTexture = sprite.texture.baseTexture;
95
109
  if (!sprite.texture._uvs) {
@@ -187,6 +201,9 @@ export class FastSpriteBatch {
187
201
  }
188
202
  }
189
203
 
204
+ /**
205
+ * TBD.
206
+ */
190
207
  flush() {
191
208
  // If the batch is length 0 then return as there is nothing to draw
192
209
  if (this.currentBatchSize === 0) {
@@ -213,10 +230,16 @@ export class FastSpriteBatch {
213
230
  this.renderSession.drawCount += 1;
214
231
  }
215
232
 
233
+ /**
234
+ * TBD.
235
+ */
216
236
  stop() {
217
237
  this.flush();
218
238
  }
219
239
 
240
+ /**
241
+ * TBD.
242
+ */
220
243
  start() {
221
244
  const gl = this.gl;
222
245
  // bind the main texture
@@ -1,43 +1,61 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
-
8
1
  export class WebGLFilterManager {
2
+ /**
3
+ * TBD.
4
+ */
9
5
  constructor() {
10
6
  this.filterStack = [];
11
7
  this.offsetX = 0;
12
8
  this.offsetY = 0;
13
9
  }
14
10
 
11
+ /**
12
+ * TBD.
13
+ * @param gl - TBD.
14
+ */
15
15
  setContext(gl) {
16
16
  this.gl = gl;
17
17
  this.texturePool = [];
18
18
  this.initShaderBuffers();
19
19
  }
20
20
 
21
+ /**
22
+ * TBD.
23
+ */
21
24
  begin() {
22
25
  // TODO
23
26
  }
24
27
 
28
+ /**
29
+ * TBD.
30
+ */
25
31
  pushFilter() {
26
32
  // TODO
27
33
  }
28
34
 
35
+ /**
36
+ * TBD.
37
+ */
29
38
  popFilter() {
30
39
  // TODO
31
40
  }
32
41
 
42
+ /**
43
+ * TBD.
44
+ */
33
45
  applyFilterPass() {
34
46
  // TODO
35
47
  }
36
48
 
49
+ /**
50
+ * TBD.
51
+ */
37
52
  initShaderBuffers() {
38
53
  // TODO
39
54
  }
40
55
 
56
+ /**
57
+ * TBD.
58
+ */
41
59
  destroy() {
42
60
  // TODO
43
61
  }
@@ -1,28 +1,21 @@
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 { SCALE_LINEAR } from '../../core/const';
8
2
 
9
3
  export class FilterTexture {
4
+ /**
5
+ * TBD.
6
+ * @param gl - TBD.
7
+ * @param {number} width - TBD.
8
+ * @param {number} height - TBD.
9
+ * @param scaleMode
10
+ */
10
11
  constructor(gl, width, height, scaleMode) {
11
12
  this.gl = gl;
12
13
  this.frameBuffer = gl.createFramebuffer();
13
14
  this.texture = gl.createTexture();
14
15
  scaleMode = scaleMode || window.PhaserRegistry.TEXTURE_SCALE_MODE;
15
16
  gl.bindTexture(gl.TEXTURE_2D, this.texture);
16
- gl.texParameteri(
17
- gl.TEXTURE_2D,
18
- gl.TEXTURE_MAG_FILTER,
19
- scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST
20
- );
21
- gl.texParameteri(
22
- gl.TEXTURE_2D,
23
- gl.TEXTURE_MIN_FILTER,
24
- scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST
25
- );
17
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST);
18
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === SCALE_LINEAR ? gl.LINEAR : gl.NEAREST);
26
19
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
27
20
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
28
21
  gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer);
@@ -31,21 +24,24 @@ export class FilterTexture {
31
24
  // required for masking a mask??
32
25
  this.renderBuffer = gl.createRenderbuffer();
33
26
  gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderBuffer);
34
- gl.framebufferRenderbuffer(
35
- gl.FRAMEBUFFER,
36
- gl.DEPTH_STENCIL_ATTACHMENT,
37
- gl.RENDERBUFFER,
38
- this.renderBuffer
39
- );
27
+ gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this.renderBuffer);
40
28
  this.resize(width, height);
41
29
  }
42
30
 
31
+ /**
32
+ * TBD.
33
+ */
43
34
  clear() {
44
35
  const gl = this.gl;
45
36
  gl.clearColor(0, 0, 0, 0);
46
37
  gl.clear(gl.COLOR_BUFFER_BIT);
47
38
  }
48
39
 
40
+ /**
41
+ * TBD.
42
+ * @param {number} width - TBD.
43
+ * @param {number} height - TBD.
44
+ */
49
45
  resize(width, height) {
50
46
  if (this.width === width && this.height === height) {
51
47
  return;
@@ -60,6 +56,9 @@ export class FilterTexture {
60
56
  gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
61
57
  }
62
58
 
59
+ /**
60
+ * TBD.
61
+ */
63
62
  destroy() {
64
63
  const gl = this.gl;
65
64
  gl.deleteFramebuffer(this.frameBuffer);
@@ -1,18 +1,6 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
- import { GraphicsData } from './graphics_data';
1
+ import { GraphicsData } from './graphics_data';
8
2
  import { Point } from '../../geom/point';
9
- import {
10
- GEOM_CIRCLE,
11
- GEOM_ELLIPSE,
12
- GEOM_POLYGON,
13
- GEOM_RECTANGLE,
14
- GEOM_ROUNDED_RECTANGLE,
15
- } from '../../core/const';
3
+ import { GEOM_CIRCLE, GEOM_ELLIPSE, GEOM_POLYGON, GEOM_RECTANGLE, GEOM_ROUNDED_RECTANGLE } from '../../core/const';
16
4
  import { hex2rgb } from '../../util/math';
17
5
  import { triangulate } from './earcut';
18
6
 
@@ -324,22 +312,11 @@ export function buildRoundedRectangle(graphicsData, webGLData) {
324
312
  const radius = rrectData.radius;
325
313
  let recPoints = [];
326
314
  recPoints.push(x, y + radius);
315
+ recPoints = recPoints.concat(quadraticBezierCurve(x, y + height - radius, x, y + height, x + radius, y + height));
327
316
  recPoints = recPoints.concat(
328
- quadraticBezierCurve(x, y + height - radius, x, y + height, x + radius, y + height)
329
- );
330
- recPoints = recPoints.concat(
331
- quadraticBezierCurve(
332
- x + width - radius,
333
- y + height,
334
- x + width,
335
- y + height,
336
- x + width,
337
- y + height - radius
338
- )
339
- );
340
- recPoints = recPoints.concat(
341
- quadraticBezierCurve(x + width, y + radius, x + width, y, x + width - radius, y)
317
+ quadraticBezierCurve(x + width - radius, y + height, x + width, y + height, x + width, y + height - radius)
342
318
  );
319
+ recPoints = recPoints.concat(quadraticBezierCurve(x + width, y + radius, x + width, y, x + width - radius, y));
343
320
  recPoints = recPoints.concat(quadraticBezierCurve(x + radius, y, x, y, x, y + radius));
344
321
  if (graphicsData.fill) {
345
322
  const color = hex2rgb(graphicsData.fillColor);
@@ -1,11 +1,8 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
-
8
1
  export class GraphicsData {
2
+ /**
3
+ * TBD.
4
+ * @param gl - TBD.
5
+ */
9
6
  constructor(gl) {
10
7
  this.gl = gl;
11
8
  // TODO does this need to be split before uploading??
@@ -19,6 +16,9 @@ export class GraphicsData {
19
16
  this.dirty = true;
20
17
  }
21
18
 
19
+ /**
20
+ * TBD.
21
+ */
22
22
  reset() {
23
23
  this.points = [];
24
24
  this.indices = [];
@@ -26,6 +26,9 @@ export class GraphicsData {
26
26
  this.glIndicies = null;
27
27
  }
28
28
 
29
+ /**
30
+ * TBD.
31
+ */
29
32
  upload() {
30
33
  const gl = this.gl;
31
34
  // this.lastIndex = graphics.graphicsData.length;
@@ -1,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 { updateGraphics } from './graphics';
8
2
 
9
3
  /**
@@ -1,10 +1,4 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
- import { Rectangle } from '../../geom/rectangle';
1
+ import { Rectangle } from '../../geom/rectangle';
8
2
  import { Point } from '../../geom/point';
9
3
  import { Texture } from './texture';
10
4
  import { BaseTexture } from './base_texture';
@@ -13,14 +7,19 @@ import { CanvasBuffer } from '../canvas/buffer';
13
7
  import { RENDER_WEBGL } from '../../core/const';
14
8
 
15
9
  export class RenderTexture extends Texture {
10
+ /**
11
+ * TBD.
12
+ * @param {number} width - TBD.
13
+ * @param {number} height - TBD.
14
+ * @param renderer
15
+ * @param scaleMode
16
+ * @param resolution
17
+ */
16
18
  constructor(width, height, renderer, scaleMode, resolution = 1) {
17
19
  const w = width || 100;
18
20
  const h = height || 100;
19
21
  const res = resolution || 1;
20
- const baseTexture = new BaseTexture(
21
- null,
22
- scaleMode || window.PhaserRegistry.TEXTURE_SCALE_MODE
23
- );
22
+ const baseTexture = new BaseTexture(null, scaleMode || window.PhaserRegistry.TEXTURE_SCALE_MODE);
24
23
  baseTexture.width = width * res;
25
24
  baseTexture.height = height * res;
26
25
  baseTexture._glTextures = [];
@@ -37,53 +36,66 @@ export class RenderTexture extends Texture {
37
36
  if (this.renderer.type === RENDER_WEBGL) {
38
37
  const gl = this.renderer.gl;
39
38
  this.baseTexture._dirty[gl.id] = false;
40
- this.textureBuffer = new FilterTexture(
41
- gl,
42
- this.width,
43
- this.height,
44
- this.baseTexture.scaleMode
45
- );
39
+ this.textureBuffer = new FilterTexture(gl, this.width, this.height, this.baseTexture.scaleMode);
46
40
  this.baseTexture._glTextures[gl.id] = this.textureBuffer.texture;
47
41
  this.render = this.renderWebGL;
48
42
  this.projection = new Point(this.width * 0.5, -this.height * 0.5);
49
43
  } else {
50
44
  this.render = this.renderCanvas;
51
- this.textureBuffer = new CanvasBuffer(
52
- this.width * this.resolution,
53
- this.height * this.resolution
54
- );
45
+ this.textureBuffer = new CanvasBuffer(this.width * this.resolution, this.height * this.resolution);
55
46
  this.baseTexture.source = this.textureBuffer.canvas;
56
47
  }
57
48
  this.valid = true;
58
49
  this._updateUvs();
59
50
  }
60
51
 
52
+ /**
53
+ * TBD.
54
+ */
61
55
  resize() {
62
56
  // TODO
63
57
  }
64
58
 
59
+ /**
60
+ * TBD.
61
+ */
65
62
  clear() {
66
63
  // TODO
67
64
  }
68
65
 
66
+ /**
67
+ * TBD.
68
+ */
69
69
  renderWebGL() {
70
70
  // TODO
71
71
  }
72
72
 
73
+ /**
74
+ * TBD.
75
+ */
73
76
  renderCanvas() {
74
77
  // TODO
75
78
  }
76
79
 
80
+ /**
81
+ * TBD.
82
+ */
77
83
  getImage() {
78
84
  const image = new Image();
79
85
  image.src = this.getBase64();
80
86
  return image;
81
87
  }
82
88
 
89
+ /**
90
+ * TBD.
91
+ */
83
92
  getBase64() {
84
93
  return this.getCanvas().toDataURL();
85
94
  }
86
95
 
96
+ /**
97
+ * TBD.
98
+ */
87
99
  getCanvas() {
88
100
  // TODO
89
101
  }