melonjs 10.2.1 → 10.2.2

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 (90) hide show
  1. package/README.md +1 -1
  2. package/dist/melonjs.js +2735 -2760
  3. package/dist/melonjs.min.js +3 -3
  4. package/dist/melonjs.module.d.ts +2186 -2162
  5. package/dist/melonjs.module.js +2323 -2362
  6. package/package.json +8 -9
  7. package/src/audio/audio.js +43 -43
  8. package/src/camera/camera2d.js +52 -74
  9. package/src/entity/draggable.js +18 -17
  10. package/src/entity/droptarget.js +19 -18
  11. package/src/entity/entity.js +22 -26
  12. package/src/game.js +2 -2
  13. package/src/index.js +11 -11
  14. package/src/input/gamepad.js +13 -13
  15. package/src/input/input.js +1 -1
  16. package/src/input/keyboard.js +14 -16
  17. package/src/input/pointer.js +42 -35
  18. package/src/input/pointerevent.js +18 -26
  19. package/src/lang/deprecated.js +3 -3
  20. package/src/level/level.js +24 -16
  21. package/src/level/tiled/TMXGroup.js +6 -6
  22. package/src/level/tiled/TMXLayer.js +31 -31
  23. package/src/level/tiled/TMXObject.js +19 -19
  24. package/src/level/tiled/TMXTile.js +11 -12
  25. package/src/level/tiled/TMXTileMap.js +23 -21
  26. package/src/level/tiled/TMXTileset.js +13 -13
  27. package/src/level/tiled/TMXTilesetGroup.js +4 -4
  28. package/src/level/tiled/TMXUtils.js +13 -11
  29. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  30. package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  31. package/src/level/tiled/renderer/TMXRenderer.js +17 -17
  32. package/src/loader/loader.js +29 -25
  33. package/src/math/color.js +45 -64
  34. package/src/math/math.js +17 -17
  35. package/src/math/matrix2.js +46 -46
  36. package/src/math/matrix3.js +64 -64
  37. package/src/math/observable_vector2.js +45 -57
  38. package/src/math/observable_vector3.js +56 -70
  39. package/src/math/vector2.js +60 -59
  40. package/src/math/vector3.js +65 -64
  41. package/src/particles/emitter.js +53 -55
  42. package/src/particles/particle.js +1 -1
  43. package/src/physics/body.js +44 -44
  44. package/src/physics/bounds.js +34 -34
  45. package/src/physics/collision.js +15 -16
  46. package/src/physics/detector.js +10 -10
  47. package/src/physics/quadtree.js +19 -17
  48. package/src/physics/sat.js +17 -17
  49. package/src/physics/world.js +12 -10
  50. package/src/plugin/plugin.js +6 -6
  51. package/src/renderable/GUI.js +13 -18
  52. package/src/renderable/collectable.js +3 -3
  53. package/src/renderable/colorlayer.js +4 -4
  54. package/src/renderable/container.js +64 -46
  55. package/src/renderable/imagelayer.js +30 -31
  56. package/src/renderable/nineslicesprite.js +13 -13
  57. package/src/renderable/renderable.js +68 -66
  58. package/src/renderable/sprite.js +57 -43
  59. package/src/renderable/trigger.js +14 -15
  60. package/src/shapes/ellipse.js +27 -26
  61. package/src/shapes/line.js +8 -7
  62. package/src/shapes/poly.js +33 -31
  63. package/src/shapes/rectangle.js +50 -96
  64. package/src/state/stage.js +6 -6
  65. package/src/state/state.js +54 -54
  66. package/src/system/device.js +97 -84
  67. package/src/system/event.js +72 -72
  68. package/src/system/pooling.js +14 -14
  69. package/src/system/save.js +6 -3
  70. package/src/system/timer.js +20 -20
  71. package/src/text/bitmaptext.js +27 -33
  72. package/src/text/bitmaptextdata.js +9 -9
  73. package/src/text/text.js +39 -41
  74. package/src/tweens/easing.js +4 -4
  75. package/src/tweens/interpolation.js +4 -4
  76. package/src/tweens/tween.js +37 -27
  77. package/src/utils/agent.js +9 -8
  78. package/src/utils/array.js +4 -4
  79. package/src/utils/file.js +4 -4
  80. package/src/utils/function.js +5 -5
  81. package/src/utils/string.js +12 -12
  82. package/src/utils/utils.js +19 -19
  83. package/src/video/canvas/canvas_renderer.js +90 -90
  84. package/src/video/renderer.js +40 -39
  85. package/src/video/texture.js +74 -75
  86. package/src/video/video.js +30 -30
  87. package/src/video/webgl/buffer/vertex.js +9 -1
  88. package/src/video/webgl/glshader.js +20 -20
  89. package/src/video/webgl/webgl_compositor.js +33 -34
  90. package/src/video/webgl/webgl_renderer.js +104 -104
@@ -2,7 +2,7 @@ import * as event from "./../../system/event.js";
2
2
  import device from "./../../system/device.js";
3
3
 
4
4
  /**
5
- * @private
5
+ * @ignore
6
6
  */
7
7
  function extractUniforms(gl, shader) {
8
8
  var uniforms = {},
@@ -46,9 +46,9 @@ function extractUniforms(gl, shader) {
46
46
  }
47
47
  else {
48
48
  /**
49
- * A generic setter for uniform vectors
50
- * @ignore
51
- */
49
+ * A generic setter for uniform vectors
50
+ * @ignore
51
+ */
52
52
  return function (val) {
53
53
  var fnv = fn;
54
54
  if (val.length && fn.substr(-1) !== "v") {
@@ -66,7 +66,7 @@ function extractUniforms(gl, shader) {
66
66
  };
67
67
 
68
68
  /**
69
- * @private
69
+ * @ignore
70
70
  */
71
71
  function extractAttributes(gl, shader) {
72
72
  var attributes = {},
@@ -83,7 +83,7 @@ function extractAttributes(gl, shader) {
83
83
  };
84
84
 
85
85
  /**
86
- * @private
86
+ * @ignore
87
87
  */
88
88
  function compileShader(gl, type, source) {
89
89
  var shader = gl.createShader(type);
@@ -99,7 +99,7 @@ function compileShader(gl, type, source) {
99
99
 
100
100
  /**
101
101
  * Compile GLSL into a shader object
102
- * @private
102
+ * @ignore
103
103
  */
104
104
  function compileProgram(gl, vertex, fragment, attributes) {
105
105
  var vertShader = compileShader(gl, gl.VERTEX_SHADER, vertex);
@@ -144,7 +144,7 @@ function compileProgram(gl, vertex, fragment, attributes) {
144
144
 
145
145
  /**
146
146
  * Hash map of GLSL data types to WebGL Uniform methods
147
- * @private
147
+ * @ignore
148
148
  */
149
149
  var fnHash = {
150
150
  "bool" : "1i",
@@ -168,7 +168,7 @@ var fnHash = {
168
168
  /**
169
169
  * set precision for the fiven shader source
170
170
  * won't do anything if the precision is already specified
171
- * @private
171
+ * @ignore
172
172
  */
173
173
  function setPrecision(src, precision) {
174
174
  if (src.substring(0, 9) !== "precision") {
@@ -179,7 +179,7 @@ function setPrecision(src, precision) {
179
179
 
180
180
  /**
181
181
  * clean the given source from space, comments, etc...
182
- * @private
182
+ * @ignore
183
183
  */
184
184
  function minify(src) {
185
185
  // remove comments
@@ -200,9 +200,9 @@ function minify(src) {
200
200
  * @class GLShader
201
201
  * @memberOf me
202
202
  * @param {WebGLRenderingContext} gl the current WebGL rendering context
203
- * @param {String} vertex a string containing the GLSL source code to set
204
- * @param {String} fragment a string containing the GLSL source code to set
205
- * @param {String} [precision=auto detected] float precision ('lowp', 'mediump' or 'highp').
203
+ * @param {string} vertex a string containing the GLSL source code to set
204
+ * @param {string} fragment a string containing the GLSL source code to set
205
+ * @param {string} [precision=auto detected] float precision ('lowp', 'mediump' or 'highp').
206
206
  * @constructor
207
207
  * @see https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web/GLSL_Shaders
208
208
  * @example
@@ -242,7 +242,7 @@ class GLShader {
242
242
  /**
243
243
  * the vertex shader source code
244
244
  * @public
245
- * @type {String}
245
+ * @type {string}
246
246
  * @name vertex
247
247
  * @memberOf me.GLShader
248
248
  */
@@ -251,7 +251,7 @@ class GLShader {
251
251
  /**
252
252
  * the fragment shader source code
253
253
  * @public
254
- * @type {String}
254
+ * @type {string}
255
255
  * @name vertex
256
256
  * @memberOf me.GLShader
257
257
  */
@@ -279,7 +279,7 @@ class GLShader {
279
279
  /**
280
280
  * the uniforms of the shader
281
281
  * @public
282
- * @type {Object}
282
+ * @type {object}
283
283
  * @name uniforms
284
284
  * @memberOf me.GLShader
285
285
  */
@@ -306,8 +306,8 @@ class GLShader {
306
306
  * @name getAttribLocation
307
307
  * @memberOf me.GLShader
308
308
  * @function
309
- * @param {String} name the name of the attribute variable whose location to get.
310
- * @return {GLint} number indicating the location of the variable name if found. Returns -1 otherwise
309
+ * @param {string} name the name of the attribute variable whose location to get.
310
+ * @returns {GLint} number indicating the location of the variable name if found. Returns -1 otherwise
311
311
  */
312
312
  getAttribLocation(name) {
313
313
  var attr = this.attributes[name];
@@ -323,8 +323,8 @@ class GLShader {
323
323
  * @name setUniform
324
324
  * @memberOf me.GLShader
325
325
  * @function
326
- * @param {String} name the uniform name
327
- * @param {Object|Float32Array} value the value to assign to that uniform
326
+ * @param {string} name the uniform name
327
+ * @param {object|Float32Array} value the value to assign to that uniform
328
328
  * @example
329
329
  * myShader.setUniform("uProjectionMatrix", this.projectionMatrix);
330
330
  */
@@ -79,7 +79,7 @@ class WebGLCompositor {
79
79
  * The number of quads held in the batch
80
80
  * @name length
81
81
  * @memberOf me.WebGLCompositor
82
- * @type Number
82
+ * @type {number}
83
83
  * @readonly
84
84
  */
85
85
  //this.length = 0;
@@ -196,11 +196,11 @@ class WebGLCompositor {
196
196
  * @name addAttribute
197
197
  * @memberOf me.WebGLCompositor
198
198
  * @function
199
- * @param {String} name name of the attribute in the vertex shader
200
- * @param {Number} size number of components per vertex attribute. Must be 1, 2, 3, or 4.
199
+ * @param {string} name name of the attribute in the vertex shader
200
+ * @param {number} size number of components per vertex attribute. Must be 1, 2, 3, or 4.
201
201
  * @param {GLenum} type data type of each component in the array
202
- * @param {Boolean} normalized whether integer data values should be normalized into a certain range when being cast to a float
203
- * @param {Number} offset offset in bytes of the first component in the vertex attribute array
202
+ * @param {boolean} normalized whether integer data values should be normalized into a certain range when being cast to a float
203
+ * @param {number} offset offset in bytes of the first component in the vertex attribute array
204
204
  */
205
205
  addAttribute(name, size, type, normalized, offset) {
206
206
  this.attributes.push({
@@ -217,10 +217,10 @@ class WebGLCompositor {
217
217
  * @name setViewport
218
218
  * @memberOf me.WebGLCompositor
219
219
  * @function
220
- * @param {Number} x x position of viewport
221
- * @param {Number} y y position of viewport
222
- * @param {Number} width width of viewport
223
- * @param {Number} height height of viewport
220
+ * @param {number} x x position of viewport
221
+ * @param {number} y y position of viewport
222
+ * @param {number} w width of viewport
223
+ * @param {number} h height of viewport
224
224
  */
225
225
  setViewport(x, y, w, h) {
226
226
  this.gl.viewport(x, y, w, h);
@@ -231,17 +231,16 @@ class WebGLCompositor {
231
231
  * @name createTexture2D
232
232
  * @memberOf me.WebGLCompositor
233
233
  * @function
234
- * @param {Number} unit Destination texture unit
235
- * @param {Image|Canvas|ImageData|UInt8Array[]|Float32Array[]} image Source image
236
- * @param {Number} filter gl.LINEAR or gl.NEAREST
237
- * @param {String} [repeat="no-repeat"] Image repeat behavior (see {@link me.ImageLayer#repeat})
238
- * @param {Number} [w] Source image width (Only use with UInt8Array[] or Float32Array[] source image)
239
- * @param {Number} [h] Source image height (Only use with UInt8Array[] or Float32Array[] source image)
240
- * @param {Number} [b] Source image border (Only use with UInt8Array[] or Float32Array[] source image)
241
- * @param {Number} [b] Source image border (Only use with UInt8Array[] or Float32Array[] source image)
242
- * @param {Boolean} [premultipliedAlpha=true] Multiplies the alpha channel into the other color channels
243
- * @param {Boolean} [mipmap=true] Whether mipmap levels should be generated for this texture
244
- * @return {WebGLTexture} a WebGL texture
234
+ * @param {number} unit Destination texture unit
235
+ * @param {Image|HTMLCanvasElement|ImageData|Uint8Array[]|Float32Array[]} image Source image
236
+ * @param {number} filter gl.LINEAR or gl.NEAREST
237
+ * @param {string} [repeat="no-repeat"] Image repeat behavior (see {@link me.ImageLayer#repeat})
238
+ * @param {number} [w] Source image width (Only use with UInt8Array[] or Float32Array[] source image)
239
+ * @param {number} [h] Source image height (Only use with UInt8Array[] or Float32Array[] source image)
240
+ * @param {number} [b] Source image border (Only use with UInt8Array[] or Float32Array[] source image)
241
+ * @param {boolean} [premultipliedAlpha=true] Multiplies the alpha channel into the other color channels
242
+ * @param {boolean} [mipmap=true] Whether mipmap levels should be generated for this texture
243
+ * @returns {WebGLTexture} a WebGL texture
245
244
  */
246
245
  createTexture2D(unit, image, filter, repeat = "no-repeat", w, h, b, premultipliedAlpha = true, mipmap = true) {
247
246
  var gl = this.gl;
@@ -277,8 +276,8 @@ class WebGLCompositor {
277
276
  * @name bindTexture2D
278
277
  * @memberOf me.WebGLCompositor
279
278
  * @function
280
- * @param {WebGLTexture} a WebGL texture
281
- * @param {Number} unit Texture unit to which the given texture is bound
279
+ * @param {WebGLTexture} texture a WebGL texture
280
+ * @param {number} unit Texture unit to which the given texture is bound
282
281
  */
283
282
  bindTexture2D(texture, unit) {
284
283
  var gl = this.gl;
@@ -305,7 +304,7 @@ class WebGLCompositor {
305
304
  * @name unbindTexture2D
306
305
  * @memberOf me.WebGLCompositor
307
306
  * @function
308
- * @param {WebGLTexture} a WebGL texture
307
+ * @param {WebGLTexture} texture a WebGL texture
309
308
  */
310
309
  unbindTexture2D(texture) {
311
310
  var unit = this.renderer.cache.getUnit(texture);
@@ -374,10 +373,10 @@ class WebGLCompositor {
374
373
  * @memberOf me.WebGLCompositor
375
374
  * @function
376
375
  * @param {me.Renderer.Texture} texture Source texture
377
- * @param {Number} x Destination x-coordinate
378
- * @param {Number} y Destination y-coordinate
379
- * @param {Number} w Destination width
380
- * @param {Number} h Destination height
376
+ * @param {number} x Destination x-coordinate
377
+ * @param {number} y Destination y-coordinate
378
+ * @param {number} w Destination width
379
+ * @param {number} h Destination height
381
380
  * @param {number} u0 Texture UV (u0) value.
382
381
  * @param {number} v0 Texture UV (v0) value.
383
382
  * @param {number} u1 Texture UV (u1) value.
@@ -425,7 +424,7 @@ class WebGLCompositor {
425
424
 
426
425
  /**
427
426
  * Flush batched texture operations to the GPU
428
- * @param
427
+ * @param {number} [mode=gl.TRIANGLES] the GL drawing mode
429
428
  * @memberOf me.WebGLCompositor
430
429
  * @function
431
430
  */
@@ -463,9 +462,9 @@ class WebGLCompositor {
463
462
  * @name drawVertices
464
463
  * @memberOf me.WebGLCompositor
465
464
  * @function
466
- * @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)
465
+ * @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)
467
466
  * @param {me.Vector2d[]} verts vertices
468
- * @param {Number} [vertexCount=verts.length] amount of points defined in the points array
467
+ * @param {number} [vertexCount=verts.length] amount of points defined in the points array
469
468
  */
470
469
  drawVertices(mode, verts, vertexCount = verts.length) {
471
470
  // use the primitive shader
@@ -493,10 +492,10 @@ class WebGLCompositor {
493
492
  * @name clearColor
494
493
  * @memberOf me.WebGLCompositor
495
494
  * @function
496
- * @param {Number} r - the red color value used when the color buffers are cleared
497
- * @param {Number} g - the green color value used when the color buffers are cleared
498
- * @param {Number} b - the blue color value used when the color buffers are cleared
499
- * @param {Number} a - the alpha color value used when the color buffers are cleared
495
+ * @param {number} r - the red color value used when the color buffers are cleared
496
+ * @param {number} g - the green color value used when the color buffers are cleared
497
+ * @param {number} b - the blue color value used when the color buffers are cleared
498
+ * @param {number} a - the alpha color value used when the color buffers are cleared
500
499
  */
501
500
  clearColor(r, g, b, a) {
502
501
  this.gl.clearColor(r, g, b, a);