melonjs 14.0.2 → 14.1.1

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 (219) hide show
  1. package/README.md +2 -0
  2. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +10 -0
  3. package/dist/melonjs.mjs/_virtual/arraymultimap.js +10 -0
  4. package/dist/melonjs.mjs/_virtual/earcut.js +10 -0
  5. package/dist/melonjs.mjs/_virtual/howler.js +10 -0
  6. package/dist/melonjs.mjs/_virtual/index.js +10 -0
  7. package/dist/melonjs.mjs/_virtual/index2.js +10 -0
  8. package/dist/melonjs.mjs/_virtual/multimap.js +10 -0
  9. package/dist/melonjs.mjs/_virtual/setmultimap.js +10 -0
  10. package/dist/melonjs.mjs/application/application.js +238 -0
  11. package/dist/melonjs.mjs/audio/audio.js +536 -0
  12. package/dist/melonjs.mjs/camera/camera2d.js +731 -0
  13. package/dist/melonjs.mjs/entity/entity.js +247 -0
  14. package/dist/melonjs.mjs/game.js +29 -0
  15. package/dist/melonjs.mjs/geometries/ellipse.js +274 -0
  16. package/dist/melonjs.mjs/geometries/line.js +115 -0
  17. package/dist/melonjs.mjs/geometries/path2d.js +318 -0
  18. package/dist/melonjs.mjs/geometries/point.js +88 -0
  19. package/dist/melonjs.mjs/geometries/poly.js +498 -0
  20. package/dist/melonjs.mjs/geometries/rectangle.js +374 -0
  21. package/dist/melonjs.mjs/geometries/roundrect.js +167 -0
  22. package/dist/melonjs.mjs/index.js +248 -0
  23. package/dist/melonjs.mjs/input/gamepad.js +501 -0
  24. package/dist/melonjs.mjs/input/input.js +26 -0
  25. package/dist/melonjs.mjs/input/keyboard.js +470 -0
  26. package/dist/melonjs.mjs/input/pointer.js +393 -0
  27. package/dist/melonjs.mjs/input/pointerevent.js +818 -0
  28. package/dist/melonjs.mjs/lang/deprecated.js +157 -0
  29. package/dist/melonjs.mjs/level/level.js +297 -0
  30. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +141 -0
  31. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +446 -0
  32. package/dist/melonjs.mjs/level/tiled/TMXObject.js +355 -0
  33. package/dist/melonjs.mjs/level/tiled/TMXTile.js +193 -0
  34. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +636 -0
  35. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +309 -0
  36. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +81 -0
  37. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +367 -0
  38. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +504 -0
  39. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +218 -0
  40. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +155 -0
  41. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +124 -0
  42. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +107 -0
  43. package/dist/melonjs.mjs/loader/loader.js +801 -0
  44. package/dist/melonjs.mjs/loader/loadingscreen.js +120 -0
  45. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +11 -0
  46. package/dist/melonjs.mjs/math/color.js +616 -0
  47. package/dist/melonjs.mjs/math/math.js +218 -0
  48. package/dist/melonjs.mjs/math/matrix2.js +501 -0
  49. package/dist/melonjs.mjs/math/matrix3.js +679 -0
  50. package/dist/melonjs.mjs/math/observable_vector2.js +469 -0
  51. package/dist/melonjs.mjs/math/observable_vector3.js +559 -0
  52. package/dist/melonjs.mjs/math/vector2.js +526 -0
  53. package/dist/melonjs.mjs/math/vector3.js +567 -0
  54. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +73 -0
  55. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +21 -0
  56. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +324 -0
  57. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +69 -0
  58. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +691 -0
  59. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +350 -0
  60. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +3241 -0
  61. package/dist/melonjs.mjs/particles/emitter.js +265 -0
  62. package/dist/melonjs.mjs/particles/particle.js +186 -0
  63. package/dist/melonjs.mjs/particles/settings.js +319 -0
  64. package/dist/melonjs.mjs/physics/body.js +702 -0
  65. package/dist/melonjs.mjs/physics/bounds.js +459 -0
  66. package/dist/melonjs.mjs/physics/collision.js +132 -0
  67. package/dist/melonjs.mjs/physics/detector.js +194 -0
  68. package/dist/melonjs.mjs/physics/quadtree.js +394 -0
  69. package/dist/melonjs.mjs/physics/response.js +57 -0
  70. package/dist/melonjs.mjs/physics/sat.js +483 -0
  71. package/dist/melonjs.mjs/physics/world.js +219 -0
  72. package/dist/melonjs.mjs/plugin/plugin.js +141 -0
  73. package/dist/melonjs.mjs/renderable/collectable.js +60 -0
  74. package/dist/melonjs.mjs/renderable/colorlayer.js +78 -0
  75. package/dist/melonjs.mjs/renderable/container.js +1016 -0
  76. package/dist/melonjs.mjs/renderable/dragndrop.js +224 -0
  77. package/dist/melonjs.mjs/renderable/imagelayer.js +305 -0
  78. package/dist/melonjs.mjs/renderable/light2d.js +155 -0
  79. package/dist/melonjs.mjs/renderable/nineslicesprite.js +246 -0
  80. package/dist/melonjs.mjs/renderable/renderable.js +781 -0
  81. package/dist/melonjs.mjs/renderable/sprite.js +653 -0
  82. package/dist/melonjs.mjs/renderable/trigger.js +156 -0
  83. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +212 -0
  84. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +225 -0
  85. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +127 -0
  86. package/dist/melonjs.mjs/state/stage.js +236 -0
  87. package/dist/melonjs.mjs/state/state.js +596 -0
  88. package/dist/melonjs.mjs/system/device.js +909 -0
  89. package/dist/melonjs.mjs/system/dom.js +78 -0
  90. package/dist/melonjs.mjs/system/event.js +537 -0
  91. package/dist/melonjs.mjs/system/platform.js +41 -0
  92. package/dist/melonjs.mjs/system/pooling.js +209 -0
  93. package/dist/melonjs.mjs/system/save.js +157 -0
  94. package/dist/melonjs.mjs/system/timer.js +286 -0
  95. package/dist/melonjs.mjs/text/bitmaptext.js +363 -0
  96. package/dist/melonjs.mjs/text/bitmaptextdata.js +198 -0
  97. package/dist/melonjs.mjs/text/glyph.js +65 -0
  98. package/dist/melonjs.mjs/text/text.js +452 -0
  99. package/dist/melonjs.mjs/text/textmetrics.js +175 -0
  100. package/dist/melonjs.mjs/text/textstyle.js +23 -0
  101. package/dist/melonjs.mjs/tweens/easing.js +336 -0
  102. package/dist/melonjs.mjs/tweens/interpolation.js +112 -0
  103. package/dist/melonjs.mjs/tweens/tween.js +479 -0
  104. package/dist/melonjs.mjs/utils/agent.js +76 -0
  105. package/dist/melonjs.mjs/utils/array.js +63 -0
  106. package/dist/melonjs.mjs/utils/file.js +42 -0
  107. package/dist/melonjs.mjs/utils/function.js +70 -0
  108. package/dist/melonjs.mjs/utils/string.js +82 -0
  109. package/dist/melonjs.mjs/utils/utils.js +173 -0
  110. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +806 -0
  111. package/dist/melonjs.mjs/video/renderer.js +410 -0
  112. package/dist/melonjs.mjs/video/texture/atlas.js +519 -0
  113. package/dist/melonjs.mjs/video/texture/cache.js +143 -0
  114. package/dist/melonjs.mjs/video/texture/canvas_texture.js +144 -0
  115. package/dist/melonjs.mjs/video/video.js +462 -0
  116. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +142 -0
  117. package/dist/melonjs.mjs/video/webgl/glshader.js +167 -0
  118. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +10 -0
  119. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +10 -0
  120. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +10 -0
  121. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +10 -0
  122. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +25 -0
  123. package/dist/melonjs.mjs/video/webgl/utils/precision.js +20 -0
  124. package/dist/melonjs.mjs/video/webgl/utils/program.js +67 -0
  125. package/dist/melonjs.mjs/video/webgl/utils/string.js +25 -0
  126. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +92 -0
  127. package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +494 -0
  128. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1035 -0
  129. package/dist/melonjs.module.d.ts +1298 -1359
  130. package/dist/melonjs.module.js +2072 -3520
  131. package/package.json +21 -16
  132. package/src/application/application.js +4 -5
  133. package/src/audio/audio.js +32 -32
  134. package/src/camera/camera2d.js +32 -33
  135. package/src/entity/entity.js +18 -19
  136. package/src/geometries/ellipse.js +17 -18
  137. package/src/geometries/line.js +6 -7
  138. package/src/geometries/path2d.js +33 -34
  139. package/src/geometries/point.js +1 -2
  140. package/src/geometries/poly.js +16 -18
  141. package/src/geometries/rectangle.js +19 -20
  142. package/src/geometries/roundrect.js +9 -10
  143. package/src/input/gamepad.js +15 -15
  144. package/src/input/keyboard.js +12 -12
  145. package/src/input/pointer.js +6 -6
  146. package/src/input/pointerevent.js +12 -12
  147. package/src/lang/deprecated.js +12 -12
  148. package/src/level/level.js +25 -25
  149. package/src/level/tiled/TMXLayer.js +23 -24
  150. package/src/level/tiled/TMXTile.js +6 -7
  151. package/src/level/tiled/TMXTileMap.js +8 -10
  152. package/src/level/tiled/TMXTileset.js +3 -4
  153. package/src/level/tiled/TMXTilesetGroup.js +1 -2
  154. package/src/level/tiled/TMXUtils.js +5 -5
  155. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
  156. package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
  157. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
  158. package/src/level/tiled/renderer/TMXRenderer.js +20 -21
  159. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -2
  160. package/src/loader/loader.js +20 -20
  161. package/src/math/color.js +21 -22
  162. package/src/math/math.js +16 -16
  163. package/src/math/matrix2.js +17 -18
  164. package/src/math/matrix3.js +26 -27
  165. package/src/math/observable_vector2.js +15 -16
  166. package/src/math/observable_vector3.js +17 -18
  167. package/src/math/vector2.js +10 -11
  168. package/src/math/vector3.js +11 -12
  169. package/src/particles/emitter.js +7 -8
  170. package/src/particles/particle.js +3 -4
  171. package/src/physics/body.js +29 -30
  172. package/src/physics/bounds.js +10 -10
  173. package/src/physics/collision.js +2 -2
  174. package/src/physics/detector.js +6 -6
  175. package/src/physics/quadtree.js +18 -23
  176. package/src/physics/sat.js +31 -31
  177. package/src/physics/world.js +6 -7
  178. package/src/plugin/plugin.js +5 -5
  179. package/src/renderable/collectable.js +4 -6
  180. package/src/renderable/colorlayer.js +6 -8
  181. package/src/renderable/container.js +25 -27
  182. package/src/renderable/dragndrop.js +14 -14
  183. package/src/renderable/imagelayer.js +14 -15
  184. package/src/renderable/light2d.js +4 -5
  185. package/src/renderable/nineslicesprite.js +17 -18
  186. package/src/renderable/renderable.js +26 -28
  187. package/src/renderable/sprite.js +29 -30
  188. package/src/renderable/trigger.js +16 -17
  189. package/src/renderable/ui/uibaseelement.js +8 -9
  190. package/src/renderable/ui/uispriteelement.js +8 -8
  191. package/src/renderable/ui/uitextbutton.js +15 -15
  192. package/src/state/stage.js +8 -9
  193. package/src/state/state.js +17 -17
  194. package/src/system/device.js +11 -11
  195. package/src/system/event.js +10 -10
  196. package/src/system/pooling.js +9 -9
  197. package/src/system/save.js +2 -2
  198. package/src/system/timer.js +10 -10
  199. package/src/text/bitmaptext.js +19 -20
  200. package/src/text/bitmaptextdata.js +3 -4
  201. package/src/text/glyph.js +1 -2
  202. package/src/text/text.js +24 -25
  203. package/src/text/textmetrics.js +9 -10
  204. package/src/tweens/tween.js +20 -21
  205. package/src/utils/agent.js +5 -5
  206. package/src/utils/array.js +4 -4
  207. package/src/utils/file.js +2 -2
  208. package/src/utils/function.js +6 -6
  209. package/src/utils/string.js +5 -5
  210. package/src/utils/utils.js +4 -4
  211. package/src/video/canvas/canvas_renderer.js +72 -73
  212. package/src/video/renderer.js +27 -28
  213. package/src/video/texture/atlas.js +22 -22
  214. package/src/video/texture/canvas_texture.js +9 -9
  215. package/src/video/video.js +17 -17
  216. package/src/video/webgl/buffer/vertex.js +1 -2
  217. package/src/video/webgl/glshader.js +12 -12
  218. package/src/video/webgl/webgl_compositor.js +42 -43
  219. package/src/video/webgl/webgl_renderer.js +76 -77
@@ -17,21 +17,21 @@ import Point from "../geometries/point.js";
17
17
  * @classdesc
18
18
  * a base renderer object
19
19
  */
20
- class Renderer {
20
+ export default class Renderer {
21
21
  /**
22
- * @param {object} options The renderer parameters
23
- * @param {number} options.width The width of the canvas without scaling
24
- * @param {number} options.height The height of the canvas without scaling
25
- * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
26
- * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
27
- * @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.
28
- * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas
29
- * @param {boolean} [options.premultipliedAlpha=true] in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
30
- * @param {boolean} [options.blendMode="normal"] the default blend mode to use ("normal", "multiply")
31
- * @param {boolean} [options.subPixel=false] Whether to enable subpixel rendering (performance hit when enabled)
32
- * @param {boolean} [options.verbose=false] Enable the verbose mode that provides additional details as to what the renderer is doing
33
- * @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
34
- * @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
22
+ * @param {object} options - The renderer parameters
23
+ * @param {number} options.width - The width of the canvas without scaling
24
+ * @param {number} options.height - The height of the canvas without scaling
25
+ * @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
26
+ * @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing, use false (default) for a pixelated effect.
27
+ * @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.
28
+ * @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas
29
+ * @param {boolean} [options.premultipliedAlpha=true] - in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
30
+ * @param {boolean} [options.blendMode="normal"] - the default blend mode to use ("normal", "multiply")
31
+ * @param {boolean} [options.subPixel=false] - Whether to enable subpixel rendering (performance hit when enabled)
32
+ * @param {boolean} [options.verbose=false] - Enable the verbose mode that provides additional details as to what the renderer is doing
33
+ * @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
34
+ * @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
35
35
  */
36
36
  constructor(options) {
37
37
  /**
@@ -155,7 +155,7 @@ class Renderer {
155
155
  * Returns the 2D Context object of the given Canvas<br>
156
156
  * Also configures anti-aliasing and blend modes based on constructor options.
157
157
  * @param {HTMLCanvasElement} canvas
158
- * @param {boolean} [transparent=true] use false to disable transparency
158
+ * @param {boolean} [transparent=true] - use false to disable transparency
159
159
  * @returns {CanvasRenderingContext2D}
160
160
  */
161
161
  getContext2d(canvas, transparent) {
@@ -234,8 +234,8 @@ class Renderer {
234
234
 
235
235
  /**
236
236
  * resizes the system canvas
237
- * @param {number} width new width of the canvas
238
- * @param {number} height new height of the canvas
237
+ * @param {number} width - new width of the canvas
238
+ * @param {number} height - new height of the canvas
239
239
  */
240
240
  resize(width, height) {
241
241
  var canvas = this.getCanvas();
@@ -288,8 +288,8 @@ class Renderer {
288
288
 
289
289
  /**
290
290
  * stroke the given shape
291
- * @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to stroke
292
- * @param {boolean} [fill=false] fill the shape with the current color if true
291
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} shape - a shape object to stroke
292
+ * @param {boolean} [fill=false] - fill the shape with the current color if true
293
293
  */
294
294
  stroke(shape, fill) {
295
295
  if (shape instanceof RoundRect) {
@@ -325,7 +325,7 @@ class Renderer {
325
325
  * fill the given shape
326
326
  * @name fill
327
327
  * @memberof Renderer
328
- * @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to fill
328
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} shape - a shape object to fill
329
329
  */
330
330
  fill(shape) {
331
331
  this.stroke(shape, true);
@@ -333,9 +333,9 @@ class Renderer {
333
333
 
334
334
  /**
335
335
  * tint the given image or canvas using the given color
336
- * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} src the source image to be tinted
337
- * @param {Color|string} color the color that will be used to tint the image
338
- * @param {string} [mode="multiply"] the composition mode used to tint the image
336
+ * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} src - the source image to be tinted
337
+ * @param {Color|string} color - the color that will be used to tint the image
338
+ * @param {string} [mode="multiply"] - the composition mode used to tint the image
339
339
  * @returns {HTMLCanvasElement|OffscreenCanvas} a new canvas element representing the tinted image
340
340
  */
341
341
  tint(src, color, mode) {
@@ -361,8 +361,8 @@ class Renderer {
361
361
  * A mask limits rendering elements to the shape and position of the given mask object.
362
362
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
363
363
  * Mask are not preserved through renderer context save and restore.
364
- * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
365
- * @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
364
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] - the shape defining the mask to be applied
365
+ * @param {boolean} [invert=false] - either the given shape should define what is visible (default) or the opposite
366
366
  */
367
367
  // eslint-disable-next-line no-unused-vars
368
368
  setMask(mask) {}
@@ -375,8 +375,8 @@ class Renderer {
375
375
 
376
376
  /**
377
377
  * set a coloring tint for sprite based renderables
378
- * @param {Color} tint the tint color
379
- * @param {number} [alpha] an alpha value to be applied to the tint
378
+ * @param {Color} tint - the tint color
379
+ * @param {number} [alpha] - an alpha value to be applied to the tint
380
380
  */
381
381
  setTint(tint, alpha = tint.alpha) {
382
382
  // global tint color
@@ -399,4 +399,3 @@ class Renderer {
399
399
  drawFont(/*bounds*/) {}
400
400
 
401
401
  }
402
- export default Renderer;
@@ -38,9 +38,9 @@ export function createAtlas(width, height, name = "default", repeat = "no-repeat
38
38
  */
39
39
  export class TextureAtlas {
40
40
  /**
41
- * @param {object|object[]} atlases atlas information. See {@link loader.getJSON}
42
- * @param {HTMLImageElement|HTMLCanvasElement|string|HTMLImageElement[]|HTMLCanvasElement[]|string[]} [src=atlas.meta.image] Image source
43
- * @param {boolean} [cache=false] Use true to skip caching this Texture
41
+ * @param {object|object[]} atlases - atlas information. See {@link loader.getJSON}
42
+ * @param {HTMLImageElement|HTMLCanvasElement|string|HTMLImageElement[]|HTMLCanvasElement[]|string[]} [src=atlas.meta.image] - Image source
43
+ * @param {boolean} [cache=false] - Use true to skip caching this Texture
44
44
  * @example
45
45
  * // create a texture atlas from a JSON Object
46
46
  * game.texture = new me.TextureAtlas(
@@ -269,7 +269,7 @@ export class TextureAtlas {
269
269
 
270
270
  /**
271
271
  * return the default or specified atlas dictionnary
272
- * @param {string} [name] atlas name in case of multipack textures
272
+ * @param {string} [name] - atlas name in case of multipack textures
273
273
  * @returns {object}
274
274
  */
275
275
  getAtlas(name) {
@@ -290,7 +290,7 @@ export class TextureAtlas {
290
290
 
291
291
  /**
292
292
  * return the source texture for the given region (or default one if none specified)
293
- * @param {object} [region] region name in case of multipack textures
293
+ * @param {object} [region] - region name in case of multipack textures
294
294
  * @returns {HTMLImageElement|HTMLCanvasElement}
295
295
  */
296
296
  getTexture(region) {
@@ -303,11 +303,11 @@ export class TextureAtlas {
303
303
 
304
304
  /**
305
305
  * add a region to the atlas
306
- * @param {string} name region mame
307
- * @param {number} x x origin of the region
308
- * @param {number} y y origin of the region
309
- * @param {number} w width of the region
310
- * @param {number} h height of the region
306
+ * @param {string} name - region mame
307
+ * @param {number} x - x origin of the region
308
+ * @param {number} y - y origin of the region
309
+ * @param {number} w - width of the region
310
+ * @param {number} h - height of the region
311
311
  * @returns {object} the created region
312
312
  */
313
313
  addRegion(name, x, y, w, h) {
@@ -336,8 +336,8 @@ export class TextureAtlas {
336
336
 
337
337
  /**
338
338
  * return a normalized region (or frame) information for the specified sprite name
339
- * @param {string} name name of the sprite
340
- * @param {string} [atlas] name of a specific atlas where to search for the region
339
+ * @param {string} name - name of the sprite
340
+ * @param {string} [atlas] - name of a specific atlas where to search for the region
341
341
  * @returns {object}
342
342
  */
343
343
  getRegion(name, atlas) {
@@ -358,7 +358,7 @@ export class TextureAtlas {
358
358
 
359
359
  /**
360
360
  * return the uvs mapping for the given region
361
- * @param {object} name region (or frame) name
361
+ * @param {object} name - region (or frame) name
362
362
  * @returns {Float32Array} region Uvs
363
363
  */
364
364
  getUVs(name) {
@@ -379,10 +379,10 @@ export class TextureAtlas {
379
379
 
380
380
  /**
381
381
  * add uvs mapping for the given region
382
- * @param {object} atlas the atlas dictionnary where the region is define
383
- * @param {object} name region (or frame) name
384
- * @param {number} w the width of the region
385
- * @param {number} h the height of the region
382
+ * @param {object} atlas - the atlas dictionnary where the region is define
383
+ * @param {object} name - region (or frame) name
384
+ * @param {number} w - the width of the region
385
+ * @param {number} h - the height of the region
386
386
  * @returns {Float32Array} the created region UVs
387
387
  */
388
388
  addUVs(atlas, name, w, h) {
@@ -409,9 +409,9 @@ export class TextureAtlas {
409
409
 
410
410
  /**
411
411
  * Create a sprite object using the first region found using the specified name
412
- * @param {string} name name of the sprite
413
- * @param {object} [settings] Additional settings passed to the {@link Sprite} contructor
414
- * @param {boolean} [nineSlice=false] if true returns a 9-slice sprite
412
+ * @param {string} name - name of the sprite
413
+ * @param {object} [settings] - Additional settings passed to the {@link Sprite} contructor
414
+ * @param {boolean} [nineSlice=false] - if true returns a 9-slice sprite
415
415
  * @returns {Sprite|NineSliceSprite}
416
416
  * @example
417
417
  * // create a new texture object under the `game` namespace
@@ -449,9 +449,9 @@ export class TextureAtlas {
449
449
 
450
450
  /**
451
451
  * Create an animation object using the first region found using all specified names
452
- * @param {string[]|number[]} names list of names for each sprite
452
+ * @param {string[]|number[]} names - list of names for each sprite
453
453
  * (when manually creating a Texture out of a spritesheet, only numeric values are authorized)
454
- * @param {object} [settings] Additional settings passed to the {@link Sprite} contructor
454
+ * @param {object} [settings] - Additional settings passed to the {@link Sprite} contructor
455
455
  * @returns {Sprite}
456
456
  * @example
457
457
  * // create a new texture object under the `game` namespace
@@ -14,13 +14,13 @@ var defaultAttributes = {
14
14
  */
15
15
  class CanvasTexture {
16
16
  /**
17
- * @param {number} width the desired width of the canvas
18
- * @param {number} height the desired height of the canvas
19
- * @param {object} attributes The attributes to create both the canvas and context
20
- * @param {boolean} [attributes.context="2d"] the context type to be created ("2d", "webgl", "webgl2")
21
- * @param {boolean} [attributes.offscreenCanvas=false] will create an offscreenCanvas if true instead of a standard canvas
22
- * @param {boolean} [attributes.willReadFrequently=false] Indicates whether or not a lot of read-back operations are planned
23
- * @param {boolean} [attributes.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
17
+ * @param {number} width - the desired width of the canvas
18
+ * @param {number} height - the desired height of the canvas
19
+ * @param {object} attributes - The attributes to create both the canvas and context
20
+ * @param {boolean} [attributes.context="2d"] - the context type to be created ("2d", "webgl", "webgl2")
21
+ * @param {boolean} [attributes.offscreenCanvas=false] - will create an offscreenCanvas if true instead of a standard canvas
22
+ * @param {boolean} [attributes.willReadFrequently=false] - Indicates whether or not a lot of read-back operations are planned
23
+ * @param {boolean} [attributes.antiAlias=false] - Whether to enable anti-aliasing, use false (default) for a pixelated effect.
24
24
  */
25
25
  constructor(width, height, attributes = defaultAttributes) {
26
26
 
@@ -89,8 +89,8 @@ class CanvasTexture {
89
89
 
90
90
  /**
91
91
  * Resizes the canvas texture to the given width and height.
92
- * @param {number} width the desired width
93
- * @param {number} height the desired height
92
+ * @param {number} width - the desired width
93
+ * @param {number} height - the desired height
94
94
  */
95
95
  resize(width, height) {
96
96
  this.canvas.width = Math.round(width);
@@ -194,18 +194,18 @@ export let renderer = null;
194
194
  * - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio
195
195
  * <center><img src="images/scale-stretch.png"/></center><br>
196
196
  * @function video.init
197
- * @param {number} width The width of the canvas viewport
198
- * @param {number} height The height of the canvas viewport
199
- * @param {object} [options] The optional video/renderer parameters.<br> (see Renderer(s) documentation for further specific options)
200
- * @param {string|HTMLElement} [options.parent=document.body] the DOM parent element to hold the canvas in the HTML file
201
- * @param {number} [options.renderer=video.AUTO] renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO)
202
- * @param {number|string} [options.scale=1.0] enable scaling of the canvas ('auto' for automatic scaling)
203
- * @param {string} [options.scaleMethod="fit"] screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
204
- * @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
205
- * @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.
206
- * @param {boolean} [options.transparent=false] whether to allow transparent pixels in the front buffer (screen).
207
- * @param {boolean} [options.antiAlias=false] whether to enable or not video scaling interpolation
208
- * @param {boolean} [options.consoleHeader=true] whether to display melonJS version and basic device information in the console
197
+ * @param {number} width - The width of the canvas viewport
198
+ * @param {number} height - The height of the canvas viewport
199
+ * @param {object} [options] - The optional video/renderer parameters.<br> (see Renderer(s) documentation for further specific options)
200
+ * @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
201
+ * @param {number} [options.renderer=video.AUTO] - renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO)
202
+ * @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
203
+ * @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
204
+ * @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
205
+ * @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.
206
+ * @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
207
+ * @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
208
+ * @param {boolean} [options.consoleHeader=true] - whether to display melonJS version and basic device information in the console
209
209
  * @returns {boolean} false if initialization failed (canvas not supported)
210
210
  * @example
211
211
  * // init the video with a 640x480 canvas
@@ -381,9 +381,9 @@ export function init(width, height, options) {
381
381
  /**
382
382
  * Create and return a new Canvas element
383
383
  * @function video.createCanvas
384
- * @param {number} width width
385
- * @param {number} height height
386
- * @param {boolean} [returnOffscreenCanvas=false] will return an OffscreenCanvas if supported
384
+ * @param {number} width - width
385
+ * @param {number} height - height
386
+ * @param {boolean} [returnOffscreenCanvas=false] - will return an OffscreenCanvas if supported
387
387
  * @returns {HTMLCanvasElement|OffscreenCanvas}
388
388
  */
389
389
  export function createCanvas(width, height, returnOffscreenCanvas = false) {
@@ -425,8 +425,8 @@ export function getParent() {
425
425
  * Only use this if you are not using the automatic scaling feature.
426
426
  * @function video.scale
427
427
  * @see video.init
428
- * @param {number} x x scaling multiplier
429
- * @param {number} y y scaling multiplier
428
+ * @param {number} x - x scaling multiplier
429
+ * @param {number} y - y scaling multiplier
430
430
  */
431
431
  export function scale(x, y) {
432
432
  var canvas = renderer.getCanvas();
@@ -5,7 +5,7 @@
5
5
  * @ignore
6
6
  */
7
7
 
8
- class VertexArrayBuffer {
8
+ export default class VertexArrayBuffer {
9
9
 
10
10
  constructor(vertex_size, vertex_per_quad) {
11
11
  // the size of one vertex in float
@@ -131,4 +131,3 @@ class VertexArrayBuffer {
131
131
  }
132
132
 
133
133
  }
134
- export default VertexArrayBuffer;
@@ -10,12 +10,12 @@ import { minify } from "./utils/string.js";
10
10
  * @classdesc
11
11
  * a base GL Shader object
12
12
  */
13
- class GLShader {
13
+ export default class GLShader {
14
14
  /**
15
- * @param {WebGLRenderingContext} gl the current WebGL rendering context
16
- * @param {string} vertex a string containing the GLSL source code to set
17
- * @param {string} fragment a string containing the GLSL source code to set
18
- * @param {string} [precision=auto detected] float precision ('lowp', 'mediump' or 'highp').
15
+ * @param {WebGLRenderingContext} gl - the current WebGL rendering context
16
+ * @param {string} vertex - a string containing the GLSL source code to set
17
+ * @param {string} fragment - a string containing the GLSL source code to set
18
+ * @param {string} [precision=auto detected] - float precision ('lowp', 'mediump' or 'highp').
19
19
  * @see https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web/GLSL_Shaders
20
20
  * @example
21
21
  * // create a basic shader
@@ -90,7 +90,7 @@ class GLShader {
90
90
 
91
91
  /**
92
92
  * returns the location of an attribute variable in this shader program
93
- * @param {string} name the name of the attribute variable whose location to get.
93
+ * @param {string} name - the name of the attribute variable whose location to get.
94
94
  * @returns {GLint} number indicating the location of the variable name if found. Returns -1 otherwise
95
95
  */
96
96
  getAttribLocation(name) {
@@ -104,8 +104,8 @@ class GLShader {
104
104
 
105
105
  /**
106
106
  * Set the uniform to the given value
107
- * @param {string} name the uniform name
108
- * @param {object|Float32Array} value the value to assign to that uniform
107
+ * @param {string} name - the uniform name
108
+ * @param {object|Float32Array} value - the value to assign to that uniform
109
109
  * @example
110
110
  * myShader.setUniform("uProjectionMatrix", this.projectionMatrix);
111
111
  */
@@ -124,9 +124,9 @@ class GLShader {
124
124
 
125
125
  /**
126
126
  * activate the given vertex attribute for this shader
127
- * @param {WebGLRenderingContext} gl the current WebGL rendering context
128
- * @param {object[]} attributes an array of vertex attributes
129
- * @param {number} vertexByteSize the size of a single vertex in bytes
127
+ * @param {WebGLRenderingContext} gl - the current WebGL rendering context
128
+ * @param {object[]} attributes - an array of vertex attributes
129
+ * @param {number} vertexByteSize - the size of a single vertex in bytes
130
130
  */
131
131
  setVertexAttributes(gl, attributes, vertexByteSize) {
132
132
  // set the vertex attributes
@@ -156,4 +156,4 @@ class GLShader {
156
156
  this.fragment = null;
157
157
  }
158
158
  }
159
- export default GLShader;
159
+
@@ -22,9 +22,9 @@ var V_ARRAY = [
22
22
  * A WebGL Compositor object. This class handles all of the WebGL state<br>
23
23
  * Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU
24
24
  */
25
- class WebGLCompositor {
25
+ export default class WebGLCompositor {
26
26
  /**
27
- * @param {WebGLRenderer} renderer the current WebGL renderer session
27
+ * @param {WebGLRenderer} renderer - the current WebGL renderer session
28
28
  */
29
29
  constructor (renderer) {
30
30
  this.init(renderer);
@@ -147,11 +147,11 @@ class WebGLCompositor {
147
147
 
148
148
  /**
149
149
  * add vertex attribute property definition to the compositor
150
- * @param {string} name name of the attribute in the vertex shader
151
- * @param {number} size number of components per vertex attribute. Must be 1, 2, 3, or 4.
152
- * @param {GLenum} type data type of each component in the array
153
- * @param {boolean} normalized whether integer data values should be normalized into a certain range when being cast to a float
154
- * @param {number} offset offset in bytes of the first component in the vertex attribute array
150
+ * @param {string} name - name of the attribute in the vertex shader
151
+ * @param {number} size - number of components per vertex attribute. Must be 1, 2, 3, or 4.
152
+ * @param {GLenum} type - data type of each component in the array
153
+ * @param {boolean} normalized - whether integer data values should be normalized into a certain range when being cast to a float
154
+ * @param {number} offset - offset in bytes of the first component in the vertex attribute array
155
155
  */
156
156
  addAttribute(name, size, type, normalized, offset) {
157
157
  this.attributes.push({
@@ -192,10 +192,10 @@ class WebGLCompositor {
192
192
 
193
193
  /**
194
194
  * Sets the viewport
195
- * @param {number} x x position of viewport
196
- * @param {number} y y position of viewport
197
- * @param {number} w width of viewport
198
- * @param {number} h height of viewport
195
+ * @param {number} x - x position of viewport
196
+ * @param {number} y - y position of viewport
197
+ * @param {number} w - width of viewport
198
+ * @param {number} h - height of viewport
199
199
  */
200
200
  setViewport(x, y, w, h) {
201
201
  this.gl.viewport(x, y, w, h);
@@ -203,15 +203,15 @@ class WebGLCompositor {
203
203
 
204
204
  /**
205
205
  * Create a WebGL texture from an image
206
- * @param {number} unit Destination texture unit
207
- * @param {Image|HTMLCanvasElement|ImageData|Uint8Array[]|Float32Array[]} image Source image
208
- * @param {number} filter gl.LINEAR or gl.NEAREST
209
- * @param {string} [repeat="no-repeat"] Image repeat behavior (see {@link ImageLayer#repeat})
210
- * @param {number} [w] Source image width (Only use with UInt8Array[] or Float32Array[] source image)
211
- * @param {number} [h] Source image height (Only use with UInt8Array[] or Float32Array[] source image)
212
- * @param {number} [b] Source image border (Only use with UInt8Array[] or Float32Array[] source image)
213
- * @param {boolean} [premultipliedAlpha=true] Multiplies the alpha channel into the other color channels
214
- * @param {boolean} [mipmap=true] Whether mipmap levels should be generated for this texture
206
+ * @param {number} unit - Destination texture unit
207
+ * @param {Image|HTMLCanvasElement|ImageData|Uint8Array[]|Float32Array[]} image - Source image
208
+ * @param {number} filter - gl.LINEAR or gl.NEAREST
209
+ * @param {string} [repeat="no-repeat"] - Image repeat behavior (see {@link ImageLayer#repeat})
210
+ * @param {number} [w] - Source image width (Only use with UInt8Array[] or Float32Array[] source image)
211
+ * @param {number} [h] - Source image height (Only use with UInt8Array[] or Float32Array[] source image)
212
+ * @param {number} [b] - Source image border (Only use with UInt8Array[] or Float32Array[] source image)
213
+ * @param {boolean} [premultipliedAlpha=true] - Multiplies the alpha channel into the other color channels
214
+ * @param {boolean} [mipmap=true] - Whether mipmap levels should be generated for this texture
215
215
  * @returns {WebGLTexture} a WebGL texture
216
216
  */
217
217
  createTexture2D(unit, image, filter, repeat = "no-repeat", w, h, b, premultipliedAlpha = true, mipmap = true) {
@@ -245,8 +245,8 @@ class WebGLCompositor {
245
245
 
246
246
  /**
247
247
  * delete the given WebGL texture
248
- * @param {WebGLTexture} [texture] a WebGL texture to delete
249
- * @param {number} [unit] Texture unit to delete
248
+ * @param {WebGLTexture} [texture] - a WebGL texture to delete
249
+ * @param {number} [unit] - Texture unit to delete
250
250
  */
251
251
  deleteTexture2D(texture) {
252
252
  this.gl.deleteTexture(texture);
@@ -255,7 +255,7 @@ class WebGLCompositor {
255
255
 
256
256
  /**
257
257
  * returns the WebGL texture associated to the given texture unit
258
- * @param {number} unit Texture unit to which a texture is bound
258
+ * @param {number} unit - Texture unit to which a texture is bound
259
259
  * @returns {WebGLTexture} texture a WebGL texture
260
260
  */
261
261
  getTexture2D(unit) {
@@ -264,8 +264,8 @@ class WebGLCompositor {
264
264
 
265
265
  /**
266
266
  * assign the given WebGL texture to the current batch
267
- * @param {WebGLTexture} texture a WebGL texture
268
- * @param {number} unit Texture unit to which the given texture is bound
267
+ * @param {WebGLTexture} texture - a WebGL texture
268
+ * @param {number} unit - Texture unit to which the given texture is bound
269
269
  */
270
270
  bindTexture2D(texture, unit) {
271
271
  var gl = this.gl;
@@ -289,8 +289,8 @@ class WebGLCompositor {
289
289
 
290
290
  /**
291
291
  * unbind the given WebGL texture, forcing it to be reuploaded
292
- * @param {WebGLTexture} [texture] a WebGL texture
293
- * @param {number} [unit] a WebGL texture
292
+ * @param {WebGLTexture} [texture] - a WebGL texture
293
+ * @param {number} [unit] - a WebGL texture
294
294
  * @returns {number} unit the unit number that was associated with the given texture
295
295
  */
296
296
  unbindTexture2D(texture, unit) {
@@ -342,7 +342,7 @@ class WebGLCompositor {
342
342
  /**
343
343
  * Select the shader to use for compositing
344
344
  * @see GLShader
345
- * @param {GLShader} shader a reference to a GLShader instance
345
+ * @param {GLShader} shader - a reference to a GLShader instance
346
346
  */
347
347
  useShader(shader) {
348
348
  if (this.activeShader !== shader) {
@@ -356,16 +356,16 @@ class WebGLCompositor {
356
356
 
357
357
  /**
358
358
  * Add a textured quad
359
- * @param {TextureAtlas} texture Source texture atlas
360
- * @param {number} x Destination x-coordinate
361
- * @param {number} y Destination y-coordinate
362
- * @param {number} w Destination width
363
- * @param {number} h Destination height
364
- * @param {number} u0 Texture UV (u0) value.
365
- * @param {number} v0 Texture UV (v0) value.
366
- * @param {number} u1 Texture UV (u1) value.
367
- * @param {number} v1 Texture UV (v1) value.
368
- * @param {number} tint tint color to be applied to the texture in UINT32 (argb) format
359
+ * @param {TextureAtlas} texture - Source texture atlas
360
+ * @param {number} x - Destination x-coordinate
361
+ * @param {number} y - Destination y-coordinate
362
+ * @param {number} w - Destination width
363
+ * @param {number} h - Destination height
364
+ * @param {number} u0 - Texture UV (u0) value.
365
+ * @param {number} v0 - Texture UV (v0) value.
366
+ * @param {number} u1 - Texture UV (u1) value.
367
+ * @param {number} v1 - Texture UV (v1) value.
368
+ * @param {number} tint - tint color to be applied to the texture in UINT32 (argb) format
369
369
  */
370
370
  addQuad(texture, x, y, w, h, u0, v0, u1, v1, tint) {
371
371
 
@@ -410,7 +410,7 @@ class WebGLCompositor {
410
410
 
411
411
  /**
412
412
  * Flush batched texture operations to the GPU
413
- * @param {number} [mode=gl.TRIANGLES] the GL drawing mode
413
+ * @param {number} [mode=gl.TRIANGLES] - the GL drawing mode
414
414
  */
415
415
  flush(mode = this.mode) {
416
416
  var vertex = this.vertexBuffer;
@@ -436,9 +436,9 @@ class WebGLCompositor {
436
436
 
437
437
  /**
438
438
  * Draw an array of vertices
439
- * @param {GLenum} mode primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
440
- * @param {Vector2d[]} verts vertices
441
- * @param {number} [vertexCount=verts.length] amount of points defined in the points array
439
+ * @param {GLenum} mode - primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
440
+ * @param {Vector2d[]} verts - vertices
441
+ * @param {number} [vertexCount=verts.length] - amount of points defined in the points array
442
442
  */
443
443
  drawVertices(mode, verts, vertexCount = verts.length) {
444
444
  // use the primitive shader
@@ -484,4 +484,3 @@ class WebGLCompositor {
484
484
  gl.clear(gl.COLOR_BUFFER_BIT);
485
485
  }
486
486
  }
487
- export default WebGLCompositor;