@vpmedia/phaser 1.112.0 → 1.113.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 (295) hide show
  1. package/dist/index.js +1261 -1314
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation.d.ts +14 -10
  4. package/dist/phaser/core/animation.d.ts.map +1 -1
  5. package/dist/phaser/core/animation_manager.d.ts +10 -8
  6. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  7. package/dist/phaser/core/animation_parser.d.ts +5 -4
  8. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  9. package/dist/phaser/core/array_set.d.ts.map +1 -1
  10. package/dist/phaser/core/cache.d.ts +4 -3
  11. package/dist/phaser/core/cache.d.ts.map +1 -1
  12. package/dist/phaser/core/const.d.ts.map +1 -1
  13. package/dist/phaser/core/device.d.ts.map +1 -1
  14. package/dist/phaser/core/device_util.d.ts.map +1 -1
  15. package/dist/phaser/core/dom.d.ts +3 -2
  16. package/dist/phaser/core/dom.d.ts.map +1 -1
  17. package/dist/phaser/core/event_manager.d.ts.map +1 -1
  18. package/dist/phaser/core/factory.d.ts +1 -1
  19. package/dist/phaser/core/factory.d.ts.map +1 -1
  20. package/dist/phaser/core/frame.d.ts.map +1 -1
  21. package/dist/phaser/core/frame_data.d.ts.map +1 -1
  22. package/dist/phaser/core/game.d.ts.map +1 -1
  23. package/dist/phaser/core/input.d.ts +8 -6
  24. package/dist/phaser/core/input.d.ts.map +1 -1
  25. package/dist/phaser/core/input_handler.d.ts +40 -30
  26. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  27. package/dist/phaser/core/input_mouse.d.ts +3 -2
  28. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  29. package/dist/phaser/core/input_mspointer.d.ts +3 -2
  30. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  31. package/dist/phaser/core/input_pointer.d.ts +6 -4
  32. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  33. package/dist/phaser/core/input_touch.d.ts +3 -2
  34. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  35. package/dist/phaser/core/loader.d.ts +4 -3
  36. package/dist/phaser/core/loader.d.ts.map +1 -1
  37. package/dist/phaser/core/loader_parser.d.ts +9 -8
  38. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  39. package/dist/phaser/core/raf.d.ts +3 -2
  40. package/dist/phaser/core/raf.d.ts.map +1 -1
  41. package/dist/phaser/core/registry.d.ts +7 -0
  42. package/dist/phaser/core/registry.d.ts.map +1 -0
  43. package/dist/phaser/core/scale_manager.d.ts +1 -1
  44. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  45. package/dist/phaser/core/scene.d.ts +0 -1
  46. package/dist/phaser/core/scene.d.ts.map +1 -1
  47. package/dist/phaser/core/scene_manager.d.ts +1 -1
  48. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  49. package/dist/phaser/core/signal.d.ts +0 -1
  50. package/dist/phaser/core/signal.d.ts.map +1 -1
  51. package/dist/phaser/core/signal_binding.d.ts +4 -3
  52. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  53. package/dist/phaser/core/sound.d.ts +6 -4
  54. package/dist/phaser/core/sound.d.ts.map +1 -1
  55. package/dist/phaser/core/sound_manager.d.ts +3 -2
  56. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  57. package/dist/phaser/core/sound_sprite.d.ts +5 -4
  58. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  59. package/dist/phaser/core/stage.d.ts +3 -2
  60. package/dist/phaser/core/stage.d.ts.map +1 -1
  61. package/dist/phaser/core/time.d.ts +1 -1
  62. package/dist/phaser/core/time.d.ts.map +1 -1
  63. package/dist/phaser/core/timer.d.ts +1 -1
  64. package/dist/phaser/core/timer.d.ts.map +1 -1
  65. package/dist/phaser/core/timer_event.d.ts.map +1 -1
  66. package/dist/phaser/core/tween.d.ts +10 -7
  67. package/dist/phaser/core/tween.d.ts.map +1 -1
  68. package/dist/phaser/core/tween_data.d.ts +3 -2
  69. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  70. package/dist/phaser/core/tween_easing.d.ts.map +1 -1
  71. package/dist/phaser/core/tween_manager.d.ts +3 -2
  72. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  73. package/dist/phaser/core/world.d.ts +3 -2
  74. package/dist/phaser/core/world.d.ts.map +1 -1
  75. package/dist/phaser/display/bitmap_text.d.ts +3 -2
  76. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  77. package/dist/phaser/display/button.d.ts +3 -2
  78. package/dist/phaser/display/button.d.ts.map +1 -1
  79. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  80. package/dist/phaser/display/canvas/graphics.d.ts +7 -6
  81. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  82. package/dist/phaser/display/canvas/pool.d.ts +2 -2
  83. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  84. package/dist/phaser/display/canvas/renderer.d.ts +10 -8
  85. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  86. package/dist/phaser/display/canvas/tinter.d.ts +3 -2
  87. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  88. package/dist/phaser/display/canvas/util.d.ts +2 -2
  89. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  90. package/dist/phaser/display/display_object.d.ts +14 -12
  91. package/dist/phaser/display/display_object.d.ts.map +1 -1
  92. package/dist/phaser/display/graphics.d.ts +8 -5
  93. package/dist/phaser/display/graphics.d.ts.map +1 -1
  94. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  95. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  96. package/dist/phaser/display/group.d.ts +4 -3
  97. package/dist/phaser/display/group.d.ts.map +1 -1
  98. package/dist/phaser/display/image.d.ts +13 -10
  99. package/dist/phaser/display/image.d.ts.map +1 -1
  100. package/dist/phaser/display/sprite_batch.d.ts +3 -2
  101. package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
  102. package/dist/phaser/display/sprite_util.d.ts +18 -15
  103. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  104. package/dist/phaser/display/text.d.ts +11 -9
  105. package/dist/phaser/display/text.d.ts.map +1 -1
  106. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  107. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  108. package/dist/phaser/display/webgl/blend_manager.d.ts +0 -1
  109. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  110. package/dist/phaser/display/webgl/earcut.d.ts +1 -1
  111. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  112. package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  113. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +4 -3
  114. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  115. package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
  116. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  117. package/dist/phaser/display/webgl/filter_texture.d.ts +2 -1
  118. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  119. package/dist/phaser/display/webgl/graphics.d.ts +7 -6
  120. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  121. package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
  122. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  123. package/dist/phaser/display/webgl/render_texture.d.ts +4 -2
  124. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  125. package/dist/phaser/display/webgl/renderer.d.ts +16 -11
  126. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  127. package/dist/phaser/display/webgl/shader/complex.d.ts +16 -6
  128. package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  129. package/dist/phaser/display/webgl/shader/fast.d.ts +19 -7
  130. package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  131. package/dist/phaser/display/webgl/shader/normal.d.ts +33 -12
  132. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  133. package/dist/phaser/display/webgl/shader/primitive.d.ts +15 -6
  134. package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  135. package/dist/phaser/display/webgl/shader/strip.d.ts +15 -6
  136. package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  137. package/dist/phaser/display/webgl/shader_manager.d.ts +16 -11
  138. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  139. package/dist/phaser/display/webgl/sprite_batch.d.ts +29 -20
  140. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  141. package/dist/phaser/display/webgl/stencil_manager.d.ts +12 -10
  142. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  143. package/dist/phaser/display/webgl/texture.d.ts +3 -2
  144. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  145. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  146. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  147. package/dist/phaser/geom/circle.d.ts +4 -1
  148. package/dist/phaser/geom/circle.d.ts.map +1 -1
  149. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  150. package/dist/phaser/geom/line.d.ts +1 -1
  151. package/dist/phaser/geom/line.d.ts.map +1 -1
  152. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  153. package/dist/phaser/geom/point.d.ts.map +1 -1
  154. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  155. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  156. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  157. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  158. package/dist/phaser/geom/util/ellipse.d.ts +3 -2
  159. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  160. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  161. package/dist/phaser/geom/util/matrix.d.ts +2 -2
  162. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  163. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  164. package/dist/phaser/geom/util/rectangle.d.ts +1 -1
  165. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  166. package/dist/phaser/util/math.d.ts.map +1 -1
  167. package/package.json +5 -5
  168. package/src/phaser/core/animation.ts +64 -60
  169. package/src/phaser/core/animation_manager.ts +50 -53
  170. package/src/phaser/core/animation_parser.ts +9 -9
  171. package/src/phaser/core/array_set.ts +16 -17
  172. package/src/phaser/core/cache.ts +92 -93
  173. package/src/phaser/core/const.ts +1 -1
  174. package/src/phaser/core/device.ts +24 -29
  175. package/src/phaser/core/device_util.ts +22 -26
  176. package/src/phaser/core/dom.ts +54 -65
  177. package/src/phaser/core/event_manager.ts +64 -94
  178. package/src/phaser/core/factory.ts +14 -14
  179. package/src/phaser/core/frame.ts +28 -28
  180. package/src/phaser/core/frame_data.test.ts +100 -0
  181. package/src/phaser/core/frame_data.ts +24 -24
  182. package/src/phaser/core/frame_util.ts +2 -2
  183. package/src/phaser/core/game.ts +47 -48
  184. package/src/phaser/core/input.ts +104 -110
  185. package/src/phaser/core/input_handler.test.ts +113 -0
  186. package/src/phaser/core/input_handler.ts +199 -218
  187. package/src/phaser/core/input_mouse.ts +71 -54
  188. package/src/phaser/core/input_mspointer.ts +52 -39
  189. package/src/phaser/core/input_pointer.ts +81 -80
  190. package/src/phaser/core/input_touch.ts +49 -36
  191. package/src/phaser/core/loader.ts +173 -152
  192. package/src/phaser/core/loader_parser.ts +39 -57
  193. package/src/phaser/core/raf.ts +8 -7
  194. package/src/phaser/core/registry.test.ts +31 -0
  195. package/src/phaser/core/registry.ts +9 -0
  196. package/src/phaser/core/scale_manager.ts +156 -152
  197. package/src/phaser/core/scene.ts +9 -13
  198. package/src/phaser/core/scene_manager.ts +47 -47
  199. package/src/phaser/core/signal.test.ts +4 -4
  200. package/src/phaser/core/signal.ts +41 -52
  201. package/src/phaser/core/signal_binding.ts +26 -25
  202. package/src/phaser/core/signal_dispatch.test.ts +180 -0
  203. package/src/phaser/core/sound.ts +75 -83
  204. package/src/phaser/core/sound_manager.ts +52 -51
  205. package/src/phaser/core/sound_sprite.ts +17 -16
  206. package/src/phaser/core/stage.ts +25 -24
  207. package/src/phaser/core/time.ts +52 -52
  208. package/src/phaser/core/timer.test.ts +187 -0
  209. package/src/phaser/core/timer.ts +82 -69
  210. package/src/phaser/core/timer_event.ts +10 -10
  211. package/src/phaser/core/tween.ts +90 -93
  212. package/src/phaser/core/tween_data.ts +45 -51
  213. package/src/phaser/core/tween_easing.test.ts +106 -0
  214. package/src/phaser/core/tween_easing.ts +151 -123
  215. package/src/phaser/core/tween_manager.ts +19 -18
  216. package/src/phaser/core/world.ts +4 -3
  217. package/src/phaser/display/bitmap_text.ts +56 -64
  218. package/src/phaser/display/button.ts +33 -32
  219. package/src/phaser/display/canvas/buffer.ts +8 -8
  220. package/src/phaser/display/canvas/graphics.ts +36 -37
  221. package/src/phaser/display/canvas/masker.ts +2 -2
  222. package/src/phaser/display/canvas/pool.test.ts +106 -0
  223. package/src/phaser/display/canvas/pool.ts +25 -27
  224. package/src/phaser/display/canvas/renderer.ts +32 -31
  225. package/src/phaser/display/canvas/tinter.ts +25 -25
  226. package/src/phaser/display/canvas/util.ts +7 -10
  227. package/src/phaser/display/display_object.ts +114 -118
  228. package/src/phaser/display/graphics.ts +121 -119
  229. package/src/phaser/display/graphics_data.ts +12 -12
  230. package/src/phaser/display/graphics_data_util.ts +2 -3
  231. package/src/phaser/display/group.ts +50 -57
  232. package/src/phaser/display/image.ts +55 -52
  233. package/src/phaser/display/sprite_batch.ts +3 -2
  234. package/src/phaser/display/sprite_util.ts +48 -54
  235. package/src/phaser/display/text.ts +199 -204
  236. package/src/phaser/display/webgl/abstract_filter.ts +9 -9
  237. package/src/phaser/display/webgl/base_texture.ts +21 -24
  238. package/src/phaser/display/webgl/blend_manager.ts +6 -10
  239. package/src/phaser/display/webgl/earcut.ts +73 -37
  240. package/src/phaser/display/webgl/earcut_node.ts +10 -10
  241. package/src/phaser/display/webgl/fast_sprite_batch.ts +34 -34
  242. package/src/phaser/display/webgl/filter_manager.ts +13 -12
  243. package/src/phaser/display/webgl/filter_texture.ts +14 -13
  244. package/src/phaser/display/webgl/graphics.ts +51 -57
  245. package/src/phaser/display/webgl/graphics_data.ts +15 -14
  246. package/src/phaser/display/webgl/mask_manager.ts +2 -2
  247. package/src/phaser/display/webgl/render_texture.ts +26 -25
  248. package/src/phaser/display/webgl/renderer.ts +57 -62
  249. package/src/phaser/display/webgl/shader/complex.ts +28 -12
  250. package/src/phaser/display/webgl/shader/fast.ts +30 -12
  251. package/src/phaser/display/webgl/shader/normal.ts +70 -57
  252. package/src/phaser/display/webgl/shader/primitive.ts +26 -11
  253. package/src/phaser/display/webgl/shader/shader.test.ts +148 -0
  254. package/src/phaser/display/webgl/shader/strip.ts +27 -12
  255. package/src/phaser/display/webgl/shader_manager.test.ts +124 -0
  256. package/src/phaser/display/webgl/shader_manager.ts +26 -34
  257. package/src/phaser/display/webgl/sprite_batch.ts +67 -61
  258. package/src/phaser/display/webgl/stencil_manager.ts +23 -34
  259. package/src/phaser/display/webgl/texture.ts +43 -50
  260. package/src/phaser/display/webgl/texture_util.ts +2 -3
  261. package/src/phaser/display/webgl/util.ts +26 -25
  262. package/src/phaser/geom/circle.test.ts +2 -3
  263. package/src/phaser/geom/circle.ts +36 -36
  264. package/src/phaser/geom/ellipse.test.ts +73 -71
  265. package/src/phaser/geom/ellipse.ts +14 -14
  266. package/src/phaser/geom/line.test.ts +5 -5
  267. package/src/phaser/geom/line.ts +35 -35
  268. package/src/phaser/geom/matrix.test.ts +1 -1
  269. package/src/phaser/geom/matrix.ts +27 -27
  270. package/src/phaser/geom/point.test.ts +1 -2
  271. package/src/phaser/geom/point.ts +35 -35
  272. package/src/phaser/geom/polygon.test.ts +82 -0
  273. package/src/phaser/geom/polygon.ts +16 -16
  274. package/src/phaser/geom/rectangle.test.ts +14 -14
  275. package/src/phaser/geom/rectangle.ts +83 -75
  276. package/src/phaser/geom/rounded_rectangle.test.ts +1 -7
  277. package/src/phaser/geom/rounded_rectangle.ts +9 -9
  278. package/src/phaser/geom/util/circle.test.ts +25 -23
  279. package/src/phaser/geom/util/circle.ts +9 -18
  280. package/src/phaser/geom/util/ellipse.test.ts +7 -5
  281. package/src/phaser/geom/util/ellipse.ts +3 -2
  282. package/src/phaser/geom/util/line.test.ts +10 -8
  283. package/src/phaser/geom/util/line.ts +6 -16
  284. package/src/phaser/geom/util/matrix.test.ts +20 -18
  285. package/src/phaser/geom/util/matrix.ts +8 -15
  286. package/src/phaser/geom/util/point.test.ts +8 -6
  287. package/src/phaser/geom/util/point.ts +24 -28
  288. package/src/phaser/geom/util/polygon.test.ts +12 -10
  289. package/src/phaser/geom/util/polygon.ts +2 -2
  290. package/src/phaser/geom/util/rectangle.test.ts +10 -8
  291. package/src/phaser/geom/util/rectangle.ts +18 -37
  292. package/src/phaser/geom/util/rounded_rectangle.test.ts +11 -9
  293. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
  294. package/src/phaser/util/math.test.ts +11 -11
  295. package/src/phaser/util/math.ts +29 -46
@@ -1,31 +1,38 @@
1
1
  import { AbstractFilter } from './abstract_filter.js';
2
2
  import { NormalShader } from './shader/normal.js';
3
3
  import type { IdentifiedWebGLRenderingContext } from './util.js';
4
+ import type { Image } from '../../display/image.js';
5
+ import type { Matrix } from '../../geom/matrix.js';
6
+ import type { BaseTexture } from './base_texture.js';
4
7
 
5
8
  export class WebGLSpriteBatch {
6
- [key: string]: any;
7
- vertSize!: any;
8
- size!: any;
9
- vertices!: any;
10
- positions!: any;
11
- colors!: any;
12
- indices!: any;
13
- lastIndexCount!: any;
14
- drawing!: any;
15
- currentBatchSize!: any;
16
- currentBaseTexture!: any;
17
- dirty!: any;
18
- textures!: any;
19
- blendModes!: any;
20
- shaders!: any;
21
- sprites!: any;
22
- defaultShader!: any;
9
+ public vertSize = 5;
10
+ public size = 2e3;
11
+ public vertices: ArrayBuffer | null;
12
+ public positions: Float32Array | null;
13
+ public colors: Uint32Array | null;
14
+ public indices: Uint16Array | null;
15
+ public lastIndexCount: number;
16
+ public drawing: boolean;
17
+ public currentBatchSize: number;
18
+ public currentBaseTexture: any;
19
+ public dirty: boolean;
20
+ public textures: any[];
21
+ public blendModes: number[];
22
+ public shaders: NormalShader[];
23
+ public sprites: any[];
24
+ public defaultShader: any;
25
+ public gl!: IdentifiedWebGLRenderingContext;
26
+ public vertexBuffer!: WebGLBuffer | null;
27
+ public indexBuffer!: WebGLBuffer | null;
28
+ public currentBlendMode!: number;
29
+ public renderSession!: any;
30
+ public shader!: NormalShader | null;
23
31
  /**
24
32
  * Creates a new SpriteBatch instance.
25
33
  */
26
- constructor() {
27
- this.vertSize = 5;
28
- this.size = 2000; // Math.pow(2, 16) / this.vertSize;
34
+ public constructor() {
35
+ // Math.pow(2, 16) / this.vertSize;
29
36
  // the total number of bytes in our batch
30
37
  const numVerts = this.size * 4 * 4 * this.vertSize;
31
38
  // the total number of indices in our batch
@@ -66,7 +73,7 @@ export class WebGLSpriteBatch {
66
73
  * Renders a sprite using WebGL.
67
74
  * @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
68
75
  */
69
- setContext(gl: IdentifiedWebGLRenderingContext) {
76
+ public setContext(gl: IdentifiedWebGLRenderingContext) {
70
77
  this.gl = gl;
71
78
  // create a couple of buffers
72
79
  this.vertexBuffer = gl.createBuffer();
@@ -77,7 +84,7 @@ export class WebGLSpriteBatch {
77
84
  gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW);
78
85
  gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
79
86
  gl.bufferData(gl.ARRAY_BUFFER, this.vertices, gl.DYNAMIC_DRAW);
80
- this.currentBlendMode = 99999;
87
+ this.currentBlendMode = 99_999;
81
88
  const shader = new NormalShader(gl);
82
89
  shader.fragmentSrc = this.defaultShader.fragmentSrc;
83
90
  shader.uniforms = {};
@@ -89,7 +96,7 @@ export class WebGLSpriteBatch {
89
96
  * Renders the sprite batch using WebGL.
90
97
  * @param {object} renderSession - The render session to use.
91
98
  */
92
- begin(renderSession: any) {
99
+ public begin(renderSession: any) {
93
100
  this.renderSession = renderSession;
94
101
  this.shader = this.renderSession.shaderManager.defaultShader;
95
102
  this.start();
@@ -98,17 +105,17 @@ export class WebGLSpriteBatch {
98
105
  /**
99
106
  * Updates the sprite batch.
100
107
  */
101
- end() {
108
+ public end() {
102
109
  this.flush();
103
110
  }
104
111
 
105
112
  /**
106
113
  * Renders a sprite using the sprite batch.
107
- * @param {import('../../display/image.js').Image} sprite - The sprite to render.
108
- * @param {import('../../geom/matrix.js').Matrix} matrix - The transformation matrix.
114
+ * @param {Image} sprite - The sprite to render.
115
+ * @param {Matrix} matrix - The transformation matrix.
109
116
  */
110
- render(sprite: import('../../display/image.js').Image, matrix: import('../../geom/matrix.js').Matrix) {
111
- const texture = sprite.texture;
117
+ public render(sprite: Image, matrix: Matrix) {
118
+ const { texture } = sprite;
112
119
  // They provided an alternative rendering matrix, so use it
113
120
  let wt = sprite.worldTransform;
114
121
  if (matrix) {
@@ -133,7 +140,7 @@ export class WebGLSpriteBatch {
133
140
  let h1;
134
141
  if (texture.trim) {
135
142
  // if the sprite is trimmed then we need to add the extra space before transforming the sprite coords.
136
- const trim = texture.trim;
143
+ const { trim } = texture;
137
144
  w1 = trim.x - aX * trim.width;
138
145
  w0 = w1 + texture.crop.width;
139
146
  h1 = trim.y - aY * trim.height;
@@ -145,28 +152,28 @@ export class WebGLSpriteBatch {
145
152
  h1 = texture.frame.height * -aY;
146
153
  }
147
154
  const i = this.currentBatchSize * 4 * this.vertSize;
148
- const resolution = texture.baseTexture.resolution;
155
+ const { resolution } = texture.baseTexture;
149
156
  const a = wt.a / resolution;
150
157
  const b = wt.b / resolution;
151
158
  const c = wt.c / resolution;
152
159
  const d = wt.d / resolution;
153
- const tx = wt.tx;
154
- const ty = wt.ty;
155
- const colors = this.colors;
156
- const positions = this.positions;
160
+ const { tx } = wt;
161
+ const { ty } = wt;
162
+ const colors = this.colors!;
163
+ const positions = this.positions!;
157
164
  if (this.renderSession.roundPixels) {
158
165
  // xy
159
- positions[i] = (a * w1 + c * h1 + tx) | 0;
160
- positions[i + 1] = (d * h1 + b * w1 + ty) | 0;
166
+ positions[i] = Math.trunc(a * w1 + c * h1 + tx);
167
+ positions[i + 1] = Math.trunc(d * h1 + b * w1 + ty);
161
168
  // xy
162
- positions[i + 5] = (a * w0 + c * h1 + tx) | 0;
163
- positions[i + 6] = (d * h1 + b * w0 + ty) | 0;
169
+ positions[i + 5] = Math.trunc(a * w0 + c * h1 + tx);
170
+ positions[i + 6] = Math.trunc(d * h1 + b * w0 + ty);
164
171
  // xy
165
- positions[i + 10] = (a * w0 + c * h0 + tx) | 0;
166
- positions[i + 11] = (d * h0 + b * w0 + ty) | 0;
172
+ positions[i + 10] = Math.trunc(a * w0 + c * h0 + tx);
173
+ positions[i + 11] = Math.trunc(d * h0 + b * w0 + ty);
167
174
  // xy
168
- positions[i + 15] = (a * w1 + c * h0 + tx) | 0;
169
- positions[i + 16] = (d * h0 + b * w1 + ty) | 0;
175
+ positions[i + 15] = Math.trunc(a * w1 + c * h0 + tx);
176
+ positions[i + 16] = Math.trunc(d * h0 + b * w1 + ty);
170
177
  } else {
171
178
  // xy
172
179
  positions[i] = a * w1 + c * h1 + tx;
@@ -194,11 +201,11 @@ export class WebGLSpriteBatch {
194
201
  positions[i + 17] = uvs.x3;
195
202
  positions[i + 18] = uvs.y3;
196
203
  // color and alpha
197
- const tint = sprite.tint;
204
+ const { tint } = sprite;
198
205
  colors[i + 4] = (tint >> 16) + (tint & 0xff00) + ((tint & 0xff) << 16) + ((sprite.worldAlpha * 255) << 24);
199
- colors[i + 9] = colors[i + 4];
200
- colors[i + 14] = colors[i + 4];
201
- colors[i + 19] = colors[i + 4];
206
+ colors[i + 9] = colors[i + 4]!;
207
+ colors[i + 14] = colors[i + 4]!;
208
+ colors[i + 19] = colors[i + 4]!;
202
209
  // increment the batchsize
203
210
  this.sprites[this.currentBatchSize] = sprite;
204
211
  this.currentBatchSize += 1;
@@ -207,19 +214,19 @@ export class WebGLSpriteBatch {
207
214
  /**
208
215
  * Binds the sprite batch to the WebGL context.
209
216
  */
210
- renderTilingSprite() {
217
+ public renderTilingSprite() {
211
218
  // TODO
212
219
  }
213
220
 
214
221
  /**
215
222
  * Updates the sprite batch.
216
223
  */
217
- flush() {
224
+ public flush() {
218
225
  // If the batch is length 0 then return as there is nothing to draw
219
226
  if (this.currentBatchSize === 0) {
220
227
  return;
221
228
  }
222
- const gl = this.gl;
229
+ const { gl } = this;
223
230
  let shader;
224
231
  if (this.dirty) {
225
232
  this.dirty = false;
@@ -238,9 +245,9 @@ export class WebGLSpriteBatch {
238
245
  }
239
246
  // upload the verts to the buffer
240
247
  if (this.currentBatchSize > this.size * 0.5) {
241
- gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertices);
248
+ gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertices!);
242
249
  } else {
243
- const view = this.positions.subarray(0, this.currentBatchSize * 4 * this.vertSize);
250
+ const view = this.positions!.subarray(0, this.currentBatchSize * 4 * this.vertSize);
244
251
  gl.bufferSubData(gl.ARRAY_BUFFER, 0, view);
245
252
  }
246
253
  let nextTexture;
@@ -249,7 +256,7 @@ export class WebGLSpriteBatch {
249
256
  let batchSize = 0;
250
257
  let start = 0;
251
258
  let currentBaseTexture = null;
252
- let currentBlendMode = this.renderSession.blendModeManager.currentBlendMode;
259
+ let { currentBlendMode } = this.renderSession.blendModeManager;
253
260
  let currentShader = null;
254
261
  let blendSwap = false;
255
262
  let shaderSwap = false;
@@ -262,7 +269,7 @@ export class WebGLSpriteBatch {
262
269
  nextTexture = sprite.texture.baseTexture;
263
270
  }
264
271
  nextBlendMode = sprite.blendMode;
265
- nextShader = sprite.shader || this.defaultShader;
272
+ nextShader = sprite.shader ?? this.defaultShader;
266
273
  blendSwap = currentBlendMode !== nextBlendMode;
267
274
  shaderSwap = !currentShader || !nextShader || currentShader._UID !== nextShader._UID;
268
275
  let skip = nextTexture.skipRender;
@@ -295,7 +302,7 @@ export class WebGLSpriteBatch {
295
302
  }
296
303
  // both these only need to be set if they are changing..
297
304
  // set the projection
298
- const projection = this.renderSession.projection;
305
+ const { projection } = this.renderSession;
299
306
  gl.uniform2f(shader.projectionVector, projection.x, projection.y);
300
307
  // TODO - this is temporary!
301
308
  const offsetVector = this.renderSession.offset;
@@ -312,15 +319,15 @@ export class WebGLSpriteBatch {
312
319
 
313
320
  /**
314
321
  * Updates the sprite batch with a new texture.
315
- * @param {import('./base_texture.js').BaseTexture} texture - The texture to use.
322
+ * @param {BaseTexture} texture - The texture to use.
316
323
  * @param {number} size - The size of the batch.
317
324
  * @param {number} startIndex - The start index in the batch.
318
325
  */
319
- renderBatch(texture: import('./base_texture.js').BaseTexture, size: number, startIndex: number) {
326
+ public renderBatch(texture: BaseTexture, size: number, startIndex: number) {
320
327
  if (size === 0) {
321
328
  return;
322
329
  }
323
- const gl = this.gl;
330
+ const { gl } = this;
324
331
  // check if a texture is dirty..
325
332
  if (texture._dirty[gl.id]) {
326
333
  if (!this.renderSession.renderer.updateTexture(texture)) {
@@ -340,7 +347,7 @@ export class WebGLSpriteBatch {
340
347
  /**
341
348
  * Destroys this sprite batch and cleans up resources.
342
349
  */
343
- stop() {
350
+ public stop() {
344
351
  this.flush();
345
352
  this.dirty = true;
346
353
  }
@@ -348,14 +355,14 @@ export class WebGLSpriteBatch {
348
355
  /**
349
356
  * Renders the sprite batch using Canvas.
350
357
  */
351
- start() {
358
+ public start(): void {
352
359
  this.dirty = true;
353
360
  }
354
361
 
355
362
  /**
356
363
  * Destroys the sprite batch instance.
357
364
  */
358
- destroy() {
365
+ public destroy(): void {
359
366
  this.vertices = null;
360
367
  this.positions = null;
361
368
  this.colors = null;
@@ -363,6 +370,5 @@ export class WebGLSpriteBatch {
363
370
  this.gl.deleteBuffer(this.vertexBuffer);
364
371
  this.gl.deleteBuffer(this.indexBuffer);
365
372
  this.currentBaseTexture = null;
366
- this.gl = null;
367
373
  }
368
374
  }
@@ -1,14 +1,16 @@
1
1
  import { hex2rgb } from '../../util/math.js';
2
+ import type { Graphics } from '../graphics.js';
3
+ import type { GraphicsData } from './graphics_data.js';
2
4
 
3
5
  export class WebGLStencilManager {
4
- [key: string]: any;
5
- stencilStack!: any;
6
- reverse!: any;
7
- count!: any;
6
+ public gl!: WebGLRenderingContext;
7
+ public stencilStack!: any;
8
+ public reverse!: any;
9
+ public count!: any;
8
10
  /**
9
11
  * Initializes the stencil manager.
10
12
  */
11
- constructor() {
13
+ public constructor() {
12
14
  this.stencilStack = [];
13
15
  this.reverse = true;
14
16
  this.count = 0;
@@ -18,30 +20,25 @@ export class WebGLStencilManager {
18
20
  * Binds the stencil buffer for rendering.
19
21
  * @param {WebGLRenderingContext} gl - The WebGL rendering context.
20
22
  */
21
- setContext(gl: WebGLRenderingContext) {
23
+ public setContext(gl: WebGLRenderingContext) {
22
24
  this.gl = gl;
23
25
  }
24
26
 
25
27
  /**
26
28
  * Sets up the stencil buffer for rendering.
27
29
  */
28
- destroy() {
30
+ public destroy(): void {
29
31
  this.stencilStack = null;
30
- this.gl = null;
31
32
  }
32
33
 
33
34
  /**
34
35
  * Renders the stencil buffer for graphics.
35
- * @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
36
- * @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
36
+ * @param {Graphics} graphics - The graphics object to render.
37
+ * @param {GraphicsData} webGLData - The WebGL graphics data.
37
38
  * @param {object} renderSession - The rendering session.
38
39
  */
39
- pushStencil(
40
- graphics: import('../graphics.js').Graphics,
41
- webGLData: import('./graphics_data.js').GraphicsData,
42
- renderSession: any
43
- ) {
44
- const gl = renderSession.gl;
40
+ public pushStencil(graphics: Graphics, webGLData: GraphicsData, renderSession: any) {
41
+ const { gl } = renderSession;
45
42
  this.bindGraphics(graphics, webGLData, renderSession);
46
43
  if (this.stencilStack.length === 0) {
47
44
  gl.enable(gl.STENCIL_TEST);
@@ -94,21 +91,17 @@ export class WebGLStencilManager {
94
91
 
95
92
  /**
96
93
  * Renders the stencil buffer for graphics.
97
- * @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
98
- * @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
94
+ * @param {Graphics} graphics - The graphics object to render.
95
+ * @param {GraphicsData} webGLData - The WebGL graphics data.
99
96
  * @param {object} renderSession - The rendering session.
100
97
  */
101
- bindGraphics(
102
- graphics: import('../graphics.js').Graphics,
103
- webGLData: import('./graphics_data.js').GraphicsData,
104
- renderSession: any
105
- ) {
98
+ public bindGraphics(graphics: Graphics, webGLData: GraphicsData, renderSession: any) {
106
99
  // if(this._currentGraphics === graphics)return;
107
100
  // this._currentGraphics = graphics;
108
- const gl = renderSession.gl;
101
+ const { gl } = renderSession;
109
102
  // bind the graphics object..
110
- const projection = renderSession.projection;
111
- const offset = renderSession.offset;
103
+ const { projection } = renderSession;
104
+ const { offset } = renderSession;
112
105
  let shader; // = renderSession.shaderManager.primitiveShader;
113
106
  if (webGLData.mode === 1) {
114
107
  shader = renderSession.shaderManager.complexPrimitiveShader;
@@ -145,16 +138,12 @@ export class WebGLStencilManager {
145
138
 
146
139
  /**
147
140
  * Renders the stencil buffer for graphics.
148
- * @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
149
- * @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
141
+ * @param {Graphics} graphics - The graphics object to render.
142
+ * @param {GraphicsData} webGLData - The WebGL graphics data.
150
143
  * @param {object} renderSession - The rendering session.
151
144
  */
152
- popStencil(
153
- graphics: import('../graphics.js').Graphics,
154
- webGLData: import('./graphics_data.js').GraphicsData,
155
- renderSession: any
156
- ) {
157
- const gl = renderSession.gl;
145
+ public popStencil(graphics: Graphics, webGLData: GraphicsData, renderSession: any) {
146
+ const { gl } = renderSession;
158
147
  this.stencilStack.pop();
159
148
  this.count -= 1;
160
149
  if (this.stencilStack.length === 0) {
@@ -1,35 +1,31 @@
1
1
  import { Rectangle } from '../../geom/rectangle.js';
2
+ import type { BaseTexture } from './base_texture.js';
2
3
 
3
4
  export class TextureUvs {
4
- noFrame!: any;
5
- baseTexture!: any;
6
- frame!: any;
7
- trim!: any;
8
- valid!: any;
9
- isTiling!: any;
10
- requiresUpdate!: any;
11
- requiresReTint!: any;
12
- _uvs!: any;
13
- width!: any;
14
- height!: any;
15
- crop!: any;
16
- x0!: any;
17
- y0!: any;
18
- x1!: any;
19
- y1!: any;
20
- x2!: any;
21
- y2!: any;
22
- x3!: any;
23
- y3!: any;
5
+ public noFrame!: any;
6
+ public baseTexture!: any;
7
+ public frame!: any;
8
+ public trim!: any;
9
+ public valid!: any;
10
+ public isTiling!: any;
11
+ public requiresUpdate!: any;
12
+ public requiresReTint!: any;
13
+ public _uvs!: any;
14
+ public width!: any;
15
+ public height!: any;
16
+ public crop!: any;
17
+ public x0: any = 0;
18
+ public y0: any = 0;
19
+ public x1: any = 0;
20
+ public y1: any = 0;
21
+ public x2: any = 0;
22
+ public y2!: any;
23
+ public x3!: any;
24
+ public y3!: any;
24
25
  /**
25
26
  * Creates a new Texture instance.
26
27
  */
27
- constructor() {
28
- this.x0 = 0;
29
- this.y0 = 0;
30
- this.x1 = 0;
31
- this.y1 = 0;
32
- this.x2 = 0;
28
+ public constructor() {
33
29
  this.y2 = 0;
34
30
  this.x3 = 0;
35
31
  this.y3 = 0;
@@ -37,32 +33,31 @@ export class TextureUvs {
37
33
  }
38
34
 
39
35
  export class Texture {
40
- noFrame!: any;
41
- baseTexture!: any;
42
- frame!: any;
43
- trim!: any;
44
- valid!: any;
45
- isTiling!: any;
46
- requiresUpdate!: any;
47
- requiresReTint!: any;
48
- _uvs!: any;
49
- width!: any;
50
- height!: any;
51
- crop!: any;
36
+ public noFrame: any = false;
37
+ public baseTexture!: any;
38
+ public frame!: any;
39
+ public trim!: any;
40
+ public valid!: any;
41
+ public isTiling!: any;
42
+ public requiresUpdate!: any;
43
+ public requiresReTint!: any;
44
+ public _uvs!: any;
45
+ public width!: any;
46
+ public height!: any;
47
+ public crop!: any;
52
48
  /**
53
49
  * Creates a new Texture instance.
54
- * @param {import('./base_texture.js').BaseTexture} baseTexture - The base texture to use.
50
+ * @param {BaseTexture} baseTexture - The base texture to use.
55
51
  * @param {Rectangle | null | undefined} frame - The frame rectangle.
56
52
  * @param {Rectangle | null | undefined} crop - The crop rectangle.
57
53
  * @param {Rectangle | null | undefined} trim - The trim rectangle.
58
54
  */
59
- constructor(
60
- baseTexture: import('./base_texture.js').BaseTexture,
55
+ public constructor(
56
+ baseTexture: BaseTexture,
61
57
  frame: Rectangle | null | undefined = null,
62
58
  crop: Rectangle | null | undefined = null,
63
59
  trim: Rectangle | null | undefined = null
64
60
  ) {
65
- this.noFrame = false;
66
61
  if (!frame) {
67
62
  this.noFrame = true;
68
63
  frame = new Rectangle(0, 0, 1, 1);
@@ -90,7 +85,7 @@ export class Texture {
90
85
  /** @type {number} */
91
86
  this.height = 0;
92
87
  /** @type {Rectangle} */
93
- this.crop = crop || new Rectangle(0, 0, 1, 1);
88
+ this.crop = crop ?? new Rectangle(0, 0, 1, 1);
94
89
  if (baseTexture.hasLoaded) {
95
90
  if (this.noFrame) {
96
91
  frame = new Rectangle(0, 0, baseTexture.width, baseTexture.height);
@@ -102,7 +97,7 @@ export class Texture {
102
97
  /**
103
98
  * Destroys this texture and cleans up resources.
104
99
  */
105
- onBaseTextureLoaded() {
100
+ public onBaseTextureLoaded() {
106
101
  if (this.noFrame) {
107
102
  this.frame = new Rectangle(0, 0, this.baseTexture.width, this.baseTexture.height);
108
103
  }
@@ -113,7 +108,7 @@ export class Texture {
113
108
  * Destroys this texture and cleans up resources.
114
109
  * @param {boolean} destroyBase - Whether to destroy the base texture as well.
115
110
  */
116
- destroy(destroyBase: boolean = false) {
111
+ public destroy(destroyBase: boolean = false) {
117
112
  if (destroyBase) {
118
113
  this.baseTexture.destroy();
119
114
  }
@@ -125,7 +120,7 @@ export class Texture {
125
120
  * @param {Rectangle} frame - The new frame rectangle.
126
121
  * @throws {Error} If the operation fails.
127
122
  */
128
- setFrame(frame: Rectangle) {
123
+ public setFrame(frame: Rectangle) {
129
124
  this.noFrame = false;
130
125
  this.frame = frame;
131
126
  this.width = frame.width;
@@ -163,10 +158,8 @@ export class Texture {
163
158
  /**
164
159
  * Updates the texture UVs based on the crop frame.
165
160
  */
166
- _updateUvs() {
167
- if (!this._uvs) {
168
- this._uvs = new TextureUvs();
169
- }
161
+ public _updateUvs() {
162
+ this._uvs ??= new TextureUvs();
170
163
  const frame = this.crop;
171
164
  const tw = this.baseTexture.width;
172
165
  const th = this.baseTexture.height;
@@ -23,6 +23,5 @@ export const baseTextureFromCanvas = (canvas: HTMLCanvasElement, scaleMode: numb
23
23
  * @param {number} [scaleMode] - The scale mode to use for the texture.
24
24
  * @returns {Texture} The newly created Texture instance.
25
25
  */
26
- export const textureFromCanvas = (canvas: HTMLCanvasElement, scaleMode?: any) => {
27
- return new Texture(baseTextureFromCanvas(canvas, scaleMode));
28
- };
26
+ export const textureFromCanvas = (canvas: HTMLCanvasElement, scaleMode?: any) =>
27
+ new Texture(baseTextureFromCanvas(canvas, scaleMode));
@@ -1,3 +1,4 @@
1
+ import { getRegistry } from '../../core/registry.js';
1
2
  /** WebGL context tagged with the per-context id the renderer assigns, used to key shader caches. */
2
3
  export type IdentifiedWebGLRenderingContext = WebGLRenderingContext & { id: number };
3
4
 
@@ -21,9 +22,7 @@ export const CONTEXT_LOST_WEBGL = 0x9242;
21
22
  * @param {WebGLRenderingContext} gl - The WebGL rendering context.
22
23
  * @returns {number} The error code from the WebGL context.
23
24
  */
24
- export const getWebGLContextErrorCode = (gl: WebGLRenderingContext) => {
25
- return gl?.getError() ?? 0;
26
- };
25
+ export const getWebGLContextErrorCode = (gl: WebGLRenderingContext) => gl?.getError() ?? 0;
27
26
 
28
27
  /**
29
28
  * Gets the WebGL context error name from an error code.
@@ -32,22 +31,30 @@ export const getWebGLContextErrorCode = (gl: WebGLRenderingContext) => {
32
31
  */
33
32
  export const getWebGLContextErrorName = (errorCode: number) => {
34
33
  switch (errorCode) {
35
- case NO_ERROR:
34
+ case NO_ERROR: {
36
35
  return 'NO_ERROR';
37
- case INVALID_ENUM:
36
+ }
37
+ case INVALID_ENUM: {
38
38
  return 'INVALID_ENUM';
39
- case INVALID_VALUE:
39
+ }
40
+ case INVALID_VALUE: {
40
41
  return 'INVALID_VALUE';
41
- case INVALID_OPERATION:
42
+ }
43
+ case INVALID_OPERATION: {
42
44
  return 'INVALID_OPERATION';
43
- case INVALID_FRAMEBUFFER_OPERATION:
45
+ }
46
+ case INVALID_FRAMEBUFFER_OPERATION: {
44
47
  return 'INVALID_FRAMEBUFFER_OPERATION';
45
- case OUT_OF_MEMORY:
48
+ }
49
+ case OUT_OF_MEMORY: {
46
50
  return 'OUT_OF_MEMORY';
47
- case CONTEXT_LOST_WEBGL:
51
+ }
52
+ case CONTEXT_LOST_WEBGL: {
48
53
  return 'CONTEXT_LOST_WEBGL';
49
- default:
54
+ }
55
+ default: {
50
56
  return `UNKNOWN_ERROR_${errorCode}`;
57
+ }
51
58
  }
52
59
  };
53
60
 
@@ -72,10 +79,8 @@ export const compileShader = (gl: WebGLRenderingContext, shaderSrc: string[] | s
72
79
  gl.shaderSource(shader, src);
73
80
  gl.compileShader(shader);
74
81
  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
75
- if (!window.PhaserRegistry) {
76
- window.PhaserRegistry = {};
77
- }
78
- window.PhaserRegistry.GL_SHADER_INFO_LOG = gl.getShaderInfoLog(shader);
82
+ getRegistry();
83
+ globalThis.PhaserRegistry.GL_SHADER_INFO_LOG = gl.getShaderInfoLog(shader);
79
84
  return null;
80
85
  }
81
86
  return shader;
@@ -87,9 +92,8 @@ export const compileShader = (gl: WebGLRenderingContext, shaderSrc: string[] | s
87
92
  * @param {string[]|string} shaderSrc - The vertex shader source code.
88
93
  * @returns {WebGLShader} The compiled WebGL vertex shader or null if compilation failed.
89
94
  */
90
- export const compileVertexShader = (gl: WebGLRenderingContext, shaderSrc: string[] | string) => {
91
- return compileShader(gl, shaderSrc, gl.VERTEX_SHADER);
92
- };
95
+ export const compileVertexShader = (gl: WebGLRenderingContext, shaderSrc: string[] | string) =>
96
+ compileShader(gl, shaderSrc, gl.VERTEX_SHADER);
93
97
 
94
98
  /**
95
99
  * Compiles a WebGL fragment shader.
@@ -97,9 +101,8 @@ export const compileVertexShader = (gl: WebGLRenderingContext, shaderSrc: string
97
101
  * @param {string[]|string} shaderSrc - The fragment shader source code.
98
102
  * @returns {WebGLShader} The compiled WebGL fragment shader or null if compilation failed.
99
103
  */
100
- export const compileFragmentShader = (gl: WebGLRenderingContext, shaderSrc: string[] | string) => {
101
- return compileShader(gl, shaderSrc, gl.FRAGMENT_SHADER);
102
- };
104
+ export const compileFragmentShader = (gl: WebGLRenderingContext, shaderSrc: string[] | string) =>
105
+ compileShader(gl, shaderSrc, gl.FRAGMENT_SHADER);
103
106
 
104
107
  /**
105
108
  * Compiles a WebGL shader program.
@@ -126,10 +129,8 @@ export const compileProgram = (
126
129
  gl.linkProgram(shaderProgram);
127
130
 
128
131
  if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
129
- if (!window.PhaserRegistry) {
130
- window.PhaserRegistry = {};
131
- }
132
- window.PhaserRegistry.GL_PROGRAM_INFO_LOG = gl.getProgramInfoLog(shaderProgram);
132
+ getRegistry();
133
+ globalThis.PhaserRegistry.GL_PROGRAM_INFO_LOG = gl.getProgramInfoLog(shaderProgram);
133
134
  }
134
135
  return shaderProgram;
135
136
  };
@@ -1,4 +1,4 @@
1
- import { expect } from 'vitest';
1
+ import { expect, describe, it } from 'vitest';
2
2
  import { Circle } from './circle.js';
3
3
  import { Point } from './point.js';
4
4
 
@@ -121,7 +121,7 @@ describe('Circle', () => {
121
121
  it('should return Infinity when diameter is 0', () => {
122
122
  const circle = new Circle();
123
123
  circle.diameter = 0;
124
- expect(circle.distance(new Point(1, 1))).toBeCloseTo(1.4142);
124
+ expect(circle.distance(new Point(1, 1))).toBeCloseTo(Math.SQRT2);
125
125
  });
126
126
  });
127
127
 
@@ -152,7 +152,6 @@ describe('Circle', () => {
152
152
  describe('circumferencePoint', () => {
153
153
  it('should generate a point on the circumference correctly', () => {
154
154
  const circle = new Circle();
155
- const output = new Point();
156
155
  expect(circle.circumferencePoint(Math.PI / 2).x).toBeCloseTo(0.5 * circle.radius);
157
156
  });
158
157