melonjs 15.2.1 → 15.4.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 (291) hide show
  1. package/README.md +1 -1
  2. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  3. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  5. package/dist/melonjs.mjs/_virtual/index.js +1 -1
  6. package/dist/melonjs.mjs/application/application.js +75 -23
  7. package/dist/melonjs.mjs/application/header.js +2 -2
  8. package/dist/melonjs.mjs/application/resize.js +13 -11
  9. package/dist/melonjs.mjs/application/settings.js +37 -1
  10. package/dist/melonjs.mjs/audio/audio.js +4 -6
  11. package/dist/melonjs.mjs/camera/camera2d.js +12 -14
  12. package/dist/melonjs.mjs/const.js +1 -1
  13. package/dist/melonjs.mjs/entity/entity.js +3 -4
  14. package/dist/melonjs.mjs/geometries/ellipse.js +26 -59
  15. package/dist/melonjs.mjs/geometries/line.js +18 -25
  16. package/dist/melonjs.mjs/geometries/path2d.js +16 -13
  17. package/dist/melonjs.mjs/geometries/point.js +8 -16
  18. package/dist/melonjs.mjs/geometries/poly.js +40 -97
  19. package/dist/melonjs.mjs/geometries/rectangle.js +37 -91
  20. package/dist/melonjs.mjs/geometries/roundrect.js +26 -35
  21. package/dist/melonjs.mjs/index.js +6 -6
  22. package/dist/melonjs.mjs/input/gamepad.js +1 -1
  23. package/dist/melonjs.mjs/input/input.js +1 -1
  24. package/dist/melonjs.mjs/input/keyboard.js +3 -3
  25. package/dist/melonjs.mjs/input/pointer.js +4 -4
  26. package/dist/melonjs.mjs/input/pointerevent.js +6 -7
  27. package/dist/melonjs.mjs/lang/console.js +1 -1
  28. package/dist/melonjs.mjs/lang/deprecated.js +2 -2
  29. package/dist/melonjs.mjs/level/level.js +1 -1
  30. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
  31. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +16 -33
  32. package/dist/melonjs.mjs/level/tiled/TMXObject.js +3 -4
  33. package/dist/melonjs.mjs/level/tiled/TMXTile.js +4 -4
  34. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +3 -3
  35. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +4 -7
  36. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +2 -2
  37. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +37 -47
  38. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  39. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +3 -3
  40. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
  41. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
  42. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
  43. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
  44. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  45. package/dist/melonjs.mjs/loader/cache.js +1 -1
  46. package/dist/melonjs.mjs/loader/loader.js +1 -1
  47. package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
  48. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  49. package/dist/melonjs.mjs/loader/parser.js +4 -5
  50. package/dist/melonjs.mjs/loader/settings.js +1 -1
  51. package/dist/melonjs.mjs/math/color.js +5 -5
  52. package/dist/melonjs.mjs/math/math.js +1 -1
  53. package/dist/melonjs.mjs/math/matrix2.js +5 -59
  54. package/dist/melonjs.mjs/math/matrix3.js +82 -141
  55. package/dist/melonjs.mjs/math/observable_vector2.js +7 -7
  56. package/dist/melonjs.mjs/math/observable_vector3.js +5 -5
  57. package/dist/melonjs.mjs/math/vector2.js +7 -91
  58. package/dist/melonjs.mjs/math/vector3.js +6 -90
  59. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
  60. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
  61. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  62. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
  63. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  64. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  65. package/dist/melonjs.mjs/particles/emitter.js +2 -2
  66. package/dist/melonjs.mjs/particles/particle.js +2 -2
  67. package/dist/melonjs.mjs/particles/settings.js +1 -1
  68. package/dist/melonjs.mjs/physics/body.js +22 -20
  69. package/dist/melonjs.mjs/physics/bounds.js +27 -33
  70. package/dist/melonjs.mjs/physics/collision.js +5 -5
  71. package/dist/melonjs.mjs/physics/detector.js +10 -10
  72. package/dist/melonjs.mjs/physics/quadtree.js +5 -5
  73. package/dist/melonjs.mjs/physics/response.js +1 -1
  74. package/dist/melonjs.mjs/physics/sat.js +3 -4
  75. package/dist/melonjs.mjs/physics/world.js +6 -9
  76. package/dist/melonjs.mjs/plugin/plugin.js +3 -3
  77. package/dist/melonjs.mjs/renderable/collectable.js +2 -2
  78. package/dist/melonjs.mjs/renderable/colorlayer.js +4 -4
  79. package/dist/melonjs.mjs/renderable/container.js +25 -25
  80. package/dist/melonjs.mjs/renderable/draggable.js +1 -1
  81. package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
  82. package/dist/melonjs.mjs/renderable/imagelayer.js +4 -4
  83. package/dist/melonjs.mjs/renderable/light2d.js +3 -3
  84. package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
  85. package/dist/melonjs.mjs/renderable/renderable.js +31 -39
  86. package/dist/melonjs.mjs/renderable/sprite.js +3 -3
  87. package/dist/melonjs.mjs/renderable/text/bitmaptext.js +421 -0
  88. package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +195 -0
  89. package/dist/melonjs.mjs/renderable/text/glyph.js +65 -0
  90. package/dist/melonjs.mjs/renderable/text/text.js +422 -0
  91. package/dist/melonjs.mjs/renderable/text/textmetrics.js +175 -0
  92. package/dist/melonjs.mjs/renderable/text/textstyle.js +21 -0
  93. package/dist/melonjs.mjs/renderable/trigger.js +10 -10
  94. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +7 -7
  95. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +7 -7
  96. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +3 -3
  97. package/dist/melonjs.mjs/state/stage.js +13 -14
  98. package/dist/melonjs.mjs/state/state.js +4 -51
  99. package/dist/melonjs.mjs/system/device.js +51 -10
  100. package/dist/melonjs.mjs/system/dom.js +1 -1
  101. package/dist/melonjs.mjs/system/event.js +46 -2
  102. package/dist/melonjs.mjs/system/platform.js +18 -18
  103. package/dist/melonjs.mjs/system/pooling.js +10 -10
  104. package/dist/melonjs.mjs/system/save.js +1 -1
  105. package/dist/melonjs.mjs/system/timer.js +1 -1
  106. package/dist/melonjs.mjs/text/bitmaptext.js +1 -1
  107. package/dist/melonjs.mjs/text/bitmaptextdata.js +3 -6
  108. package/dist/melonjs.mjs/text/glyph.js +1 -1
  109. package/dist/melonjs.mjs/text/text.js +1 -1
  110. package/dist/melonjs.mjs/text/textmetrics.js +1 -1
  111. package/dist/melonjs.mjs/text/textstyle.js +1 -1
  112. package/dist/melonjs.mjs/tweens/easing.js +1 -1
  113. package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
  114. package/dist/melonjs.mjs/tweens/tween.js +2 -2
  115. package/dist/melonjs.mjs/utils/agent.js +1 -1
  116. package/dist/melonjs.mjs/utils/array.js +1 -1
  117. package/dist/melonjs.mjs/utils/file.js +1 -1
  118. package/dist/melonjs.mjs/utils/function.js +2 -3
  119. package/dist/melonjs.mjs/utils/string.js +1 -1
  120. package/dist/melonjs.mjs/utils/utils.js +1 -1
  121. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +5 -18
  122. package/dist/melonjs.mjs/video/renderer.js +17 -30
  123. package/dist/melonjs.mjs/video/texture/atlas.js +13 -13
  124. package/dist/melonjs.mjs/video/texture/cache.js +1 -1
  125. package/dist/melonjs.mjs/video/texture/canvas_texture.js +15 -15
  126. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  127. package/dist/melonjs.mjs/video/video.js +5 -29
  128. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
  129. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +13 -14
  130. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
  131. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +2 -3
  132. package/dist/melonjs.mjs/video/webgl/glshader.js +2 -2
  133. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  134. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
  135. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  136. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
  137. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
  138. package/dist/melonjs.mjs/video/webgl/utils/precision.js +4 -4
  139. package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
  140. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  141. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
  142. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +62 -67
  143. package/dist/melonjs.module.js +1272 -1713
  144. package/dist/types/application/application.d.ts +32 -31
  145. package/dist/types/application/header.d.ts +2 -2
  146. package/dist/types/application/settings.d.ts +80 -16
  147. package/dist/types/audio/audio.d.ts +4 -6
  148. package/dist/types/camera/camera2d.d.ts +13 -16
  149. package/dist/types/entity/entity.d.ts +0 -1
  150. package/dist/types/geometries/ellipse.d.ts +18 -50
  151. package/dist/types/geometries/path2d.d.ts +1 -1
  152. package/dist/types/geometries/point.d.ts +5 -13
  153. package/dist/types/geometries/poly.d.ts +26 -75
  154. package/dist/types/geometries/rectangle.d.ts +12 -58
  155. package/dist/types/geometries/roundrect.d.ts +2 -11
  156. package/dist/types/index.d.ts +3 -3
  157. package/dist/types/input/gamepad.d.ts +31 -31
  158. package/dist/types/input/keyboard.d.ts +105 -105
  159. package/dist/types/input/pointer.d.ts +21 -21
  160. package/dist/types/input/pointerevent.d.ts +6 -6
  161. package/dist/types/level/tiled/TMXLayer.d.ts +1 -1
  162. package/dist/types/level/tiled/TMXUtils.d.ts +4 -6
  163. package/dist/types/math/matrix2.d.ts +9 -63
  164. package/dist/types/math/matrix3.d.ts +9 -68
  165. package/dist/types/math/observable_vector2.d.ts +2 -2
  166. package/dist/types/math/observable_vector3.d.ts +2 -2
  167. package/dist/types/math/vector2.d.ts +8 -92
  168. package/dist/types/math/vector3.d.ts +8 -92
  169. package/dist/types/particles/settings.d.ts +29 -29
  170. package/dist/types/physics/body.d.ts +10 -8
  171. package/dist/types/physics/bounds.d.ts +24 -30
  172. package/dist/types/physics/collision.d.ts +12 -12
  173. package/dist/types/physics/detector.d.ts +1 -1
  174. package/dist/types/physics/world.d.ts +4 -7
  175. package/dist/types/renderable/container.d.ts +19 -19
  176. package/dist/types/renderable/imagelayer.d.ts +6 -6
  177. package/dist/types/renderable/light2d.d.ts +7 -7
  178. package/dist/types/renderable/renderable.d.ts +10 -18
  179. package/dist/types/renderable/text/bitmaptext.d.ts +151 -0
  180. package/dist/types/renderable/text/bitmaptextdata.d.ts +35 -0
  181. package/dist/types/renderable/text/glyph.d.ts +28 -0
  182. package/dist/types/renderable/text/text.d.ts +159 -0
  183. package/dist/types/renderable/text/textmetrics.d.ts +47 -0
  184. package/dist/types/renderable/text/textstyle.d.ts +5 -0
  185. package/dist/types/renderable/ui/uibaseelement.d.ts +0 -1
  186. package/dist/types/renderable/ui/uispriteelement.d.ts +0 -1
  187. package/dist/types/renderable/ui/uitextbutton.d.ts +2 -7
  188. package/dist/types/state/stage.d.ts +3 -2
  189. package/dist/types/state/state.d.ts +11 -11
  190. package/dist/types/system/device.d.ts +16 -9
  191. package/dist/types/system/event.d.ts +40 -0
  192. package/dist/types/system/platform.d.ts +17 -17
  193. package/dist/types/utils/function.d.ts +1 -2
  194. package/dist/types/video/canvas/canvas_renderer.d.ts +0 -23
  195. package/dist/types/video/renderer.d.ts +16 -43
  196. package/dist/types/video/texture/canvas_texture.d.ts +14 -14
  197. package/dist/types/video/video.d.ts +4 -38
  198. package/dist/types/video/webgl/buffer/vertex.d.ts +2 -2
  199. package/dist/types/video/webgl/compositors/compositor.d.ts +24 -13
  200. package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +0 -1
  201. package/dist/types/video/webgl/compositors/quad_compositor.d.ts +0 -1
  202. package/dist/types/video/webgl/utils/precision.d.ts +1 -1
  203. package/dist/types/video/webgl/webgl_renderer.d.ts +48 -84
  204. package/package.json +15 -15
  205. package/src/application/application.js +73 -21
  206. package/src/application/header.js +1 -1
  207. package/src/application/resize.js +11 -9
  208. package/src/application/settings.js +36 -0
  209. package/src/audio/audio.js +3 -5
  210. package/src/camera/camera2d.js +11 -13
  211. package/src/entity/entity.js +2 -3
  212. package/src/geometries/ellipse.js +25 -58
  213. package/src/geometries/line.js +17 -24
  214. package/src/geometries/path2d.js +15 -12
  215. package/src/geometries/point.js +7 -15
  216. package/src/geometries/poly.js +39 -96
  217. package/src/geometries/rectangle.js +36 -90
  218. package/src/geometries/roundrect.js +25 -34
  219. package/src/index.js +4 -4
  220. package/src/input/keyboard.js +2 -2
  221. package/src/input/pointer.js +3 -3
  222. package/src/input/pointerevent.js +5 -6
  223. package/src/lang/deprecated.js +1 -1
  224. package/src/level/tiled/TMXLayer.js +15 -32
  225. package/src/level/tiled/TMXObject.js +2 -3
  226. package/src/level/tiled/TMXTile.js +3 -3
  227. package/src/level/tiled/TMXTileMap.js +2 -2
  228. package/src/level/tiled/TMXTileset.js +3 -6
  229. package/src/level/tiled/TMXTilesetGroup.js +1 -1
  230. package/src/level/tiled/TMXUtils.js +36 -46
  231. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
  232. package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  233. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  234. package/src/level/tiled/renderer/TMXRenderer.js +1 -1
  235. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  236. package/src/loader/parser.js +3 -4
  237. package/src/math/color.js +4 -4
  238. package/src/math/matrix2.js +4 -58
  239. package/src/math/matrix3.js +81 -140
  240. package/src/math/observable_vector2.js +6 -6
  241. package/src/math/observable_vector3.js +4 -4
  242. package/src/math/vector2.js +6 -90
  243. package/src/math/vector3.js +5 -89
  244. package/src/particles/emitter.js +1 -1
  245. package/src/particles/particle.js +1 -1
  246. package/src/physics/body.js +21 -19
  247. package/src/physics/bounds.js +26 -32
  248. package/src/physics/collision.js +4 -4
  249. package/src/physics/detector.js +9 -9
  250. package/src/physics/quadtree.js +4 -4
  251. package/src/physics/sat.js +2 -3
  252. package/src/physics/world.js +5 -8
  253. package/src/polyfill/roundrect.js +163 -163
  254. package/src/renderable/collectable.js +1 -1
  255. package/src/renderable/colorlayer.js +3 -3
  256. package/src/renderable/container.js +24 -24
  257. package/src/renderable/imagelayer.js +3 -3
  258. package/src/renderable/light2d.js +2 -2
  259. package/src/renderable/nineslicesprite.js +1 -1
  260. package/src/renderable/renderable.js +30 -38
  261. package/src/renderable/sprite.js +2 -2
  262. package/src/{text → renderable/text}/bitmaptext.js +8 -8
  263. package/src/{text → renderable/text}/bitmaptextdata.js +4 -7
  264. package/src/{text → renderable/text}/glyph.js +1 -1
  265. package/src/{text → renderable/text}/text.js +16 -17
  266. package/src/{text → renderable/text}/textmetrics.js +2 -2
  267. package/src/renderable/trigger.js +9 -9
  268. package/src/renderable/ui/uibaseelement.js +6 -6
  269. package/src/renderable/ui/uispriteelement.js +6 -6
  270. package/src/renderable/ui/uitextbutton.js +2 -2
  271. package/src/state/stage.js +12 -13
  272. package/src/state/state.js +2 -61
  273. package/src/system/device.js +50 -9
  274. package/src/system/event.js +44 -0
  275. package/src/system/platform.js +18 -18
  276. package/src/system/pooling.js +9 -9
  277. package/src/tweens/tween.js +1 -1
  278. package/src/utils/function.js +1 -2
  279. package/src/video/canvas/canvas_renderer.js +4 -17
  280. package/src/video/renderer.js +16 -29
  281. package/src/video/texture/atlas.js +12 -12
  282. package/src/video/texture/canvas_texture.js +14 -14
  283. package/src/video/video.js +7 -28
  284. package/src/video/webgl/buffer/vertex.js +2 -2
  285. package/src/video/webgl/compositors/compositor.js +12 -13
  286. package/src/video/webgl/compositors/primitive_compositor.js +4 -4
  287. package/src/video/webgl/compositors/quad_compositor.js +1 -2
  288. package/src/video/webgl/glshader.js +1 -1
  289. package/src/video/webgl/utils/precision.js +3 -3
  290. package/src/video/webgl/webgl_renderer.js +61 -66
  291. /package/src/{text → renderable/text}/textstyle.js +0 -0
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.2.1
2
+ * melonJS Game Engine - v15.4.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.2.1
2
+ * melonJS Game Engine - v15.4.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.2.1
2
+ * melonJS Game Engine - v15.4.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -20,17 +20,17 @@ function setPrecision(src, precision) {
20
20
  /**
21
21
  * return the highest precision format supported by this device for GL Shaders
22
22
  * @ignore
23
- * @param {WebGLRenderingContext} gl
23
+ * @param {WebGLRenderingContext} gl - the current WebGL context
24
24
  * @returns {boolean} "lowp", "mediump", or "highp"
25
25
  */
26
26
  function getMaxShaderPrecision(gl) {
27
27
  if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&
28
28
  gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0) {
29
- return "highp";
29
+ return "highp";
30
30
  }
31
31
  if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 &&
32
32
  gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0) {
33
- return "mediump";
33
+ return "mediump";
34
34
  }
35
35
  return "lowp";
36
36
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.2.1
2
+ * melonJS Game Engine - v15.4.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.2.1
2
+ * melonJS Game Engine - v15.4.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.2.1
2
+ * melonJS Game Engine - v15.4.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.2.1
2
+ * melonJS Game Engine - v15.4.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -22,23 +22,9 @@ import { isPowerOfTwo } from '../../math/math.js';
22
22
  * a WebGL renderer object
23
23
  * @augments Renderer
24
24
  */
25
- class WebGLRenderer extends Renderer {
25
+ class WebGLRenderer extends Renderer {
26
26
  /**
27
- * @param {object} options - The renderer parameters
28
- * @param {number} options.width - The width of the canvas without scaling
29
- * @param {number} options.height - The height of the canvas without scaling
30
- * @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
31
- * @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing
32
- * @param {boolean} [options.failIfMajorPerformanceCaveat=true] - If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
33
- * @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas
34
- * @param {boolean} [options.premultipliedAlpha=true] - in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
35
- * @param {boolean} [options.subPixel=false] - Whether to enable subpixel renderering (performance hit when enabled)
36
- * @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
37
- * @param {boolean} [options.depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
38
- * @param {string} [options.powerPreference="default"] - a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
39
- * @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
40
- * @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
41
- * @param {Compositor} [options.compositor] - A class that implements the compositor API for sprite rendering
27
+ * @param {Application.Settings} [options] - optional parameters for the renderer
42
28
  */
43
29
  constructor(options) {
44
30
  // parent contructor
@@ -209,6 +195,17 @@ import { isPowerOfTwo } from '../../math/math.js';
209
195
  reset() {
210
196
  super.reset();
211
197
 
198
+ // clear all stacks
199
+ this._colorStack.forEach((color) => {
200
+ pool.push(color);
201
+ });
202
+ this._matrixStack.forEach((matrix) => {
203
+ pool.push(matrix);
204
+ });
205
+ this._colorStack.length = 0;
206
+ this._matrixStack.length = 0;
207
+ this._blendStack.length = 0;
208
+
212
209
  // clear gl context
213
210
  this.clear();
214
211
 
@@ -241,8 +238,8 @@ import { isPowerOfTwo } from '../../math/math.js';
241
238
  /**
242
239
  * add a new compositor to this renderer
243
240
  * @param {Compositor} compositor - a compositor instance
244
- * @param {String} name - a name uniquely identifying this compositor
245
- * @param {Boolean} [activate=false] - true if the given compositor should be set as the active one
241
+ * @param {string} name - a name uniquely identifying this compositor
242
+ * @param {boolean} [activate=false] - true if the given compositor should be set as the active one
246
243
  */
247
244
  addCompositor(compositor, name = "default", activate = false) {
248
245
  // make sure there is no existing compositor with the same name
@@ -261,9 +258,9 @@ import { isPowerOfTwo } from '../../math/math.js';
261
258
 
262
259
  /**
263
260
  * set the active compositor for this renderer
264
- * @param {String} name - a compositor name
261
+ * @param {string} name - a compositor name
265
262
  * @param {GLShader} [shader] - an optional shader program to be used, instead of the default one, when activating the compositor
266
- * @return {Compositor} an instance to the current active compositor
263
+ * @returns {Compositor} an instance to the current active compositor
267
264
  */
268
265
  setCompositor(name = "default", shader = this.customShader) {
269
266
  let compositor = this.compositors.get(name);
@@ -302,7 +299,7 @@ import { isPowerOfTwo } from '../../math/math.js';
302
299
  * Create a pattern with the specified repetition
303
300
  * @param {HTMLImageElement|SVGImageElement|HTMLVideoElement|HTMLCanvasElement|ImageBitmap|OffscreenCanvas|VideoFrame} image - Source image to be used as the pattern's image
304
301
  * @param {string} repeat - Define how the pattern should be repeated
305
- * @returns {TextureAtlas}
302
+ * @returns {TextureAtlas} the patterned texture created
306
303
  * @see ImageLayer#repeat
307
304
  * @example
308
305
  * let tileable = renderer.createPattern(image, "repeat");
@@ -339,7 +336,7 @@ import { isPowerOfTwo } from '../../math/math.js';
339
336
 
340
337
  /**
341
338
  * set/change the current projection matrix (WebGL only)
342
- * @param {Matrix3d} matrix
339
+ * @param {Matrix3d} matrix - the new projection matrix
343
340
  */
344
341
  setProjection(matrix) {
345
342
  super.setProjection(matrix);
@@ -462,10 +459,10 @@ import { isPowerOfTwo } from '../../math/math.js';
462
459
  /**
463
460
  * Draw a pattern within the given rectangle.
464
461
  * @param {TextureAtlas} pattern - Pattern object
465
- * @param {number} x
466
- * @param {number} y
467
- * @param {number} width
468
- * @param {number} height
462
+ * @param {number} x - x position where to draw the pattern
463
+ * @param {number} y - y position where to draw the pattern
464
+ * @param {number} width - width of the pattern
465
+ * @param {number} height - height of the pattern
469
466
  * @see WebGLRenderer#createPattern
470
467
  */
471
468
  drawPattern(pattern, x, y, width, height) {
@@ -476,10 +473,10 @@ import { isPowerOfTwo } from '../../math/math.js';
476
473
 
477
474
  /**
478
475
  * Returns the WebGL Context object of the given canvas element
479
- * @param {HTMLCanvasElement} canvas
476
+ * @param {HTMLCanvasElement} canvas - the canvas element
480
477
  * @param {boolean} [transparent=false] - use true to enable transparency
481
478
  * @param {boolean} [depth=false] - use true to enable depth buffer testing
482
- * @returns {WebGLRenderingContext}
479
+ * @returns {WebGLRenderingContext} the WebGL Context object
483
480
  */
484
481
  getContextGL(canvas, transparent = false, depth = false) {
485
482
  if (typeof canvas === "undefined" || canvas === null) {
@@ -528,7 +525,7 @@ import { isPowerOfTwo } from '../../math/math.js';
528
525
  /**
529
526
  * Returns the WebGLContext instance for the renderer
530
527
  * return a reference to the system 2d Context
531
- * @returns {WebGLRenderingContext}
528
+ * @returns {WebGLRenderingContext} the current WebGL context
532
529
  */
533
530
  getContext() {
534
531
  return this.gl;
@@ -547,7 +544,7 @@ import { isPowerOfTwo } from '../../math/math.js';
547
544
  * <img src="images/screen-blendmode.png" width="510"/> <br>
548
545
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
549
546
  * @param {string} [mode="normal"] - blend mode : "normal", "multiply", "lighter", "additive", "screen"
550
- * @param {WebGLRenderingContext} [gl]
547
+ * @param {WebGLRenderingContext} [gl] - a WebGL context
551
548
  */
552
549
  setBlendMode(mode = "normal", gl = this.gl) {
553
550
 
@@ -636,8 +633,8 @@ import { isPowerOfTwo } from '../../math/math.js';
636
633
 
637
634
  /**
638
635
  * scales the uniform matrix
639
- * @param {number} x
640
- * @param {number} y
636
+ * @param {number} x - x-axis scale
637
+ * @param {number} y - y-axis scale
641
638
  */
642
639
  scale(x, y) {
643
640
  this.currentTransform.scale(x, y);
@@ -691,11 +688,11 @@ import { isPowerOfTwo } from '../../math/math.js';
691
688
  * Stroke an arc at the specified coordinates with given radius, start and end points
692
689
  * @param {number} x - arc center point x-axis
693
690
  * @param {number} y - arc center point y-axis
694
- * @param {number} radius
691
+ * @param {number} radius - arc radius
695
692
  * @param {number} start - start angle in radians
696
693
  * @param {number} end - end angle in radians
697
694
  * @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
698
- * @param {boolean} [fill=false]
695
+ * @param {boolean} [fill=false] - also fill the shape with the current color if true
699
696
  */
700
697
  strokeArc(x, y, radius, start, end, antiClockwise = false, fill = false) {
701
698
  this.setCompositor("primitive");
@@ -713,7 +710,7 @@ import { isPowerOfTwo } from '../../math/math.js';
713
710
  * Fill an arc at the specified coordinates with given radius, start and end points
714
711
  * @param {number} x - arc center point x-axis
715
712
  * @param {number} y - arc center point y-axis
716
- * @param {number} radius
713
+ * @param {number} radius - arc radius
717
714
  * @param {number} start - start angle in radians
718
715
  * @param {number} end - end angle in radians
719
716
  * @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
@@ -816,10 +813,10 @@ import { isPowerOfTwo } from '../../math/math.js';
816
813
 
817
814
  /**
818
815
  * Draw a stroke rectangle at the specified coordinates
819
- * @param {number} x
820
- * @param {number} y
821
- * @param {number} width
822
- * @param {number} height
816
+ * @param {number} x - x axis of the coordinate for the rectangle starting point.
817
+ * @param {number} y - y axis of the coordinate for the rectangle starting point.
818
+ * @param {number} width - The rectangle's width.
819
+ * @param {number} height - The rectangle's height.
823
820
  * @param {boolean} [fill=false] - also fill the shape with the current color if true
824
821
  */
825
822
  strokeRect(x, y, width, height, fill = false) {
@@ -835,10 +832,10 @@ import { isPowerOfTwo } from '../../math/math.js';
835
832
 
836
833
  /**
837
834
  * Draw a filled rectangle at the specified coordinates
838
- * @param {number} x
839
- * @param {number} y
840
- * @param {number} width
841
- * @param {number} height
835
+ * @param {number} x - x axis of the coordinate for the rectangle starting point.
836
+ * @param {number} y - y axis of the coordinate for the rectangle starting point.
837
+ * @param {number} width - The rectangle's width.
838
+ * @param {number} height - The rectangle's height.
842
839
  */
843
840
  fillRect(x, y, width, height) {
844
841
  this.strokeRect(x, y, width, height, true);
@@ -846,11 +843,11 @@ import { isPowerOfTwo } from '../../math/math.js';
846
843
 
847
844
  /**
848
845
  * Stroke a rounded rectangle at the specified coordinates
849
- * @param {number} x
850
- * @param {number} y
851
- * @param {number} width
852
- * @param {number} height
853
- * @param {number} radius
846
+ * @param {number} x - x axis of the coordinate for the rounded rectangle starting point.
847
+ * @param {number} y - y axis of the coordinate for the rounded rectangle starting point.
848
+ * @param {number} width - The rounded rectangle's width.
849
+ * @param {number} height - The rounded rectangle's height.
850
+ * @param {number} radius - The rounded corner's radius.
854
851
  * @param {boolean} [fill=false] - also fill the shape with the current color if true
855
852
  */
856
853
  strokeRoundRect(x, y, width, height, radius, fill = false) {
@@ -867,11 +864,11 @@ import { isPowerOfTwo } from '../../math/math.js';
867
864
 
868
865
  /**
869
866
  * Draw a rounded filled rectangle at the specified coordinates
870
- * @param {number} x
871
- * @param {number} y
872
- * @param {number} width
873
- * @param {number} height
874
- * @param {number} radius
867
+ * @param {number} x - x axis of the coordinate for the rounded rectangle starting point.
868
+ * @param {number} y - y axis of the coordinate for the rounded rectangle starting point.
869
+ * @param {number} width - The rounded rectangle's width.
870
+ * @param {number} height - The rounded rectangle's height.
871
+ * @param {number} radius - The rounded corner's radius.
875
872
  */
876
873
  fillRoundRect(x, y, width, height, radius) {
877
874
  this.strokeRoundRect(x, y, width, height, radius, true);
@@ -879,8 +876,8 @@ import { isPowerOfTwo } from '../../math/math.js';
879
876
 
880
877
  /**
881
878
  * Stroke a Point at the specified coordinates
882
- * @param {number} x
883
- * @param {number} y
879
+ * @param {number} x - x axis of the coordinate for the point.
880
+ * @param {number} y - y axis of the coordinate for the point.
884
881
  */
885
882
  strokePoint(x, y) {
886
883
  this.strokeLine(x, y, x + 1, y + 1);
@@ -888,10 +885,8 @@ import { isPowerOfTwo } from '../../math/math.js';
888
885
 
889
886
  /**
890
887
  * Draw a a point at the specified coordinates
891
- * @param {number} x
892
- * @param {number} y
893
- * @param {number} width
894
- * @param {number} height
888
+ * @param {number} x - x axis of the coordinate for the point.
889
+ * @param {number} y - y axis of the coordinate for the point.
895
890
  */
896
891
  fillPoint(x, y) {
897
892
  this.strokePoint(x, y);
@@ -924,8 +919,8 @@ import { isPowerOfTwo } from '../../math/math.js';
924
919
 
925
920
  /**
926
921
  * Translates the uniform matrix by the given coordinates
927
- * @param {number} x
928
- * @param {number} y
922
+ * @param {number} x - x axis of the coordinate for the translation.
923
+ * @param {number} y - y axis of the coordinate for the translation.
929
924
  */
930
925
  translate(x, y) {
931
926
  let currentTransform = this.currentTransform;
@@ -944,10 +939,10 @@ import { isPowerOfTwo } from '../../math/math.js';
944
939
  * You can however save the current region using the save(),
945
940
  * and restore it (with the restore() method) any time in the future.
946
941
  * (<u>this is an experimental feature !</u>)
947
- * @param {number} x
948
- * @param {number} y
949
- * @param {number} width
950
- * @param {number} height
942
+ * @param {number} x - x axis of the coordinate for the upper-left corner of the rectangle to start clipping from.
943
+ * @param {number} y - y axis of the coordinate for the upper-left corner of the rectangle to start clipping from.
944
+ * @param {number} width - the width of the rectangle to start clipping from.
945
+ * @param {number} height - the height of the rectangle to start clipping from.
951
946
  */
952
947
  clipRect(x, y, width, height) {
953
948
  let canvas = this.getCanvas();
@@ -959,7 +954,7 @@ import { isPowerOfTwo } from '../../math/math.js';
959
954
  // if same as the current scissor box do nothing
960
955
  if (currentScissor[0] === x && currentScissor[1] === y &&
961
956
  currentScissor[2] === width && currentScissor[3] === height) {
962
- return;
957
+ return;
963
958
  }
964
959
  }
965
960
  // flush the compositor