melonjs 10.2.0 → 10.3.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 (95) hide show
  1. package/README.md +1 -1
  2. package/dist/melonjs.js +4435 -4283
  3. package/dist/melonjs.min.js +4 -4
  4. package/dist/melonjs.module.d.ts +3348 -3833
  5. package/dist/melonjs.module.js +4025 -3920
  6. package/package.json +13 -14
  7. package/src/audio/audio.js +45 -45
  8. package/src/camera/camera2d.js +78 -101
  9. package/src/entity/draggable.js +21 -29
  10. package/src/entity/droptarget.js +24 -31
  11. package/src/entity/entity.js +34 -38
  12. package/src/game.js +8 -8
  13. package/src/{shapes → geometries}/ellipse.js +46 -46
  14. package/src/{shapes → geometries}/line.js +14 -14
  15. package/src/{shapes → geometries}/poly.js +103 -54
  16. package/src/{shapes → geometries}/rectangle.js +73 -120
  17. package/src/index.js +18 -19
  18. package/src/input/gamepad.js +20 -20
  19. package/src/input/input.js +3 -3
  20. package/src/input/keyboard.js +122 -124
  21. package/src/input/pointer.js +102 -62
  22. package/src/input/pointerevent.js +97 -42
  23. package/src/lang/deprecated.js +29 -18
  24. package/src/level/level.js +34 -26
  25. package/src/level/tiled/TMXGroup.js +12 -13
  26. package/src/level/tiled/TMXLayer.js +41 -42
  27. package/src/level/tiled/TMXObject.js +76 -70
  28. package/src/level/tiled/TMXTile.js +13 -15
  29. package/src/level/tiled/TMXTileMap.js +26 -25
  30. package/src/level/tiled/TMXTileset.js +14 -15
  31. package/src/level/tiled/TMXTilesetGroup.js +5 -6
  32. package/src/level/tiled/TMXUtils.js +13 -11
  33. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
  34. package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
  35. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
  36. package/src/level/tiled/renderer/TMXRenderer.js +18 -19
  37. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
  38. package/src/loader/loader.js +46 -40
  39. package/src/loader/loadingscreen.js +7 -7
  40. package/src/math/color.js +68 -88
  41. package/src/math/math.js +33 -33
  42. package/src/math/matrix2.js +70 -71
  43. package/src/math/matrix3.js +90 -91
  44. package/src/math/observable_vector2.js +91 -92
  45. package/src/math/observable_vector3.js +110 -106
  46. package/src/math/vector2.js +116 -104
  47. package/src/math/vector3.js +129 -110
  48. package/src/particles/emitter.js +116 -126
  49. package/src/particles/particle.js +4 -5
  50. package/src/particles/particlecontainer.js +2 -3
  51. package/src/physics/body.js +82 -83
  52. package/src/physics/bounds.js +64 -66
  53. package/src/physics/collision.js +21 -22
  54. package/src/physics/detector.js +13 -13
  55. package/src/physics/quadtree.js +26 -25
  56. package/src/physics/sat.js +21 -21
  57. package/src/physics/world.js +23 -22
  58. package/src/plugin/plugin.js +12 -13
  59. package/src/renderable/GUI.js +20 -26
  60. package/src/renderable/collectable.js +6 -7
  61. package/src/renderable/colorlayer.js +11 -12
  62. package/src/renderable/container.js +98 -81
  63. package/src/renderable/imagelayer.js +33 -35
  64. package/src/renderable/nineslicesprite.js +15 -16
  65. package/src/renderable/renderable.js +112 -111
  66. package/src/renderable/sprite.js +71 -58
  67. package/src/renderable/trigger.js +17 -19
  68. package/src/state/stage.js +14 -15
  69. package/src/state/state.js +78 -78
  70. package/src/system/device.js +137 -180
  71. package/src/system/event.js +116 -104
  72. package/src/system/pooling.js +15 -15
  73. package/src/system/save.js +9 -6
  74. package/src/system/timer.js +33 -33
  75. package/src/text/bitmaptext.js +39 -46
  76. package/src/text/bitmaptextdata.js +14 -15
  77. package/src/text/text.js +55 -58
  78. package/src/tweens/easing.js +5 -5
  79. package/src/tweens/interpolation.js +5 -5
  80. package/src/tweens/tween.js +49 -40
  81. package/src/utils/agent.js +12 -11
  82. package/src/utils/array.js +8 -8
  83. package/src/utils/file.js +7 -7
  84. package/src/utils/function.js +8 -8
  85. package/src/utils/string.js +19 -19
  86. package/src/utils/utils.js +23 -23
  87. package/src/video/canvas/canvas_renderer.js +127 -128
  88. package/src/video/renderer.js +69 -69
  89. package/src/video/texture.js +80 -82
  90. package/src/video/texture_cache.js +2 -4
  91. package/src/video/video.js +38 -38
  92. package/src/video/webgl/buffer/vertex.js +11 -3
  93. package/src/video/webgl/glshader.js +31 -32
  94. package/src/video/webgl/webgl_compositor.js +145 -127
  95. package/src/video/webgl/webgl_renderer.js +196 -175
@@ -5,10 +5,9 @@ import { EPSILON } from "./math.js";
5
5
  * @classdesc
6
6
  * a 4x4 Matrix3d Object<br>
7
7
  * @class Matrix3d
8
- * @memberOf me
9
- * @constructor
8
+ * @memberof me
10
9
  * @param {me.Matrix3d} [mat3d] An instance of me.Matrix3d to copy from
11
- * @param {Number[]} [arguments...] Matrix elements. See {@link me.Matrix3d.setTransform}
10
+ * @param {number[]} [arguments...] Matrix elements. See {@link me.Matrix3d.setTransform}
12
11
  */
13
12
 
14
13
  class Matrix3d {
@@ -39,10 +38,10 @@ class Matrix3d {
39
38
  /**
40
39
  * tx component of the matrix
41
40
  * @public
42
- * @type {Number}
41
+ * @type {number}
43
42
  * @readonly
44
43
  * @name tx
45
- * @memberOf me.Matrix3d
44
+ * @memberof me.Matrix3d
46
45
  */
47
46
  get tx() {
48
47
  return this.val[12];
@@ -51,10 +50,10 @@ class Matrix3d {
51
50
  /**
52
51
  * ty component of the matrix
53
52
  * @public
54
- * @type {Number}
53
+ * @type {number}
55
54
  * @readonly
56
55
  * @name ty
57
- * @memberOf me.Matrix3d
56
+ * @memberof me.Matrix3d
58
57
  */
59
58
  get ty() {
60
59
  return this.val[13];
@@ -63,10 +62,10 @@ class Matrix3d {
63
62
  /**
64
63
  * ty component of the matrix
65
64
  * @public
66
- * @type {Number}
65
+ * @type {number}
67
66
  * @readonly
68
67
  * @name tz
69
- * @memberOf me.Matrix3d
68
+ * @memberof me.Matrix3d
70
69
  */
71
70
  get tz() {
72
71
  return this.val[14];
@@ -77,9 +76,9 @@ class Matrix3d {
77
76
  * the identity matrix and parameters position : <br>
78
77
  * <img src="images/identity-matrix_2x.png"/>
79
78
  * @name identity
80
- * @memberOf me.Matrix3d
79
+ * @memberof me.Matrix3d
81
80
  * @function
82
- * @return {me.Matrix3d} Reference to this object for method chaining
81
+ * @returns {me.Matrix3d} Reference to this object for method chaining
83
82
  */
84
83
  identity() {
85
84
  return this.setTransform(
@@ -93,25 +92,25 @@ class Matrix3d {
93
92
  /**
94
93
  * set the matrix to the specified value
95
94
  * @name setTransform
96
- * @memberOf me.Matrix3d
95
+ * @memberof me.Matrix3d
97
96
  * @function
98
- * @param {Number} m00
99
- * @param {Number} m01
100
- * @param {Number} m02
101
- * @param {Number} m03
102
- * @param {Number} m10
103
- * @param {Number} m11
104
- * @param {Number} m12
105
- * @param {Number} m13
106
- * @param {Number} m20
107
- * @param {Number} m21
108
- * @param {Number} m22
109
- * @param {Number} m23
110
- * @param {Number} m30
111
- * @param {Number} m31
112
- * @param {Number} m32
113
- * @param {Number} m33
114
- * @return {me.Matrix3d} Reference to this object for method chaining
97
+ * @param {number} m00
98
+ * @param {number} m01
99
+ * @param {number} m02
100
+ * @param {number} m03
101
+ * @param {number} m10
102
+ * @param {number} m11
103
+ * @param {number} m12
104
+ * @param {number} m13
105
+ * @param {number} m20
106
+ * @param {number} m21
107
+ * @param {number} m22
108
+ * @param {number} m23
109
+ * @param {number} m30
110
+ * @param {number} m31
111
+ * @param {number} m32
112
+ * @param {number} m33
113
+ * @returns {me.Matrix3d} Reference to this object for method chaining
115
114
  */
116
115
  setTransform(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
117
116
  var a = this.val;
@@ -139,23 +138,23 @@ class Matrix3d {
139
138
  /**
140
139
  * Copies over the values from another me.Matrix3d.
141
140
  * @name copy
142
- * @memberOf me.Matrix3d
141
+ * @memberof me.Matrix3d
143
142
  * @function
144
143
  * @param {me.Matrix3d} m the matrix object to copy from
145
- * @return {me.Matrix3d} Reference to this object for method chaining
144
+ * @returns {me.Matrix3d} Reference to this object for method chaining
146
145
  */
147
- copy(b) {
148
- this.val.set(b.val);
146
+ copy(m) {
147
+ this.val.set(m.val);
149
148
  return this;
150
149
  }
151
150
 
152
151
  /**
153
152
  * Copies over the upper-left 2x2 values from the given me.Matrix2d
154
153
  * @name fromMat2d
155
- * @memberOf me.Matrix3d
154
+ * @memberof me.Matrix3d
156
155
  * @function
157
156
  * @param {me.Matrix2d} m the matrix object to copy from
158
- * @return {me.Matrix2d} Reference to this object for method chaining
157
+ * @returns {me.Matrix2d} Reference to this object for method chaining
159
158
  */
160
159
  fromMat2d(m) {
161
160
  var b = m.val;
@@ -171,10 +170,10 @@ class Matrix3d {
171
170
  /**
172
171
  * multiply both matrix
173
172
  * @name multiply
174
- * @memberOf me.Matrix3d
173
+ * @memberof me.Matrix3d
175
174
  * @function
176
175
  * @param {me.Matrix3d} m Other matrix
177
- * @return {me.Matrix3d} Reference to this object for method chaining
176
+ * @returns {me.Matrix3d} Reference to this object for method chaining
178
177
  */
179
178
  multiply(m) {
180
179
  var a = this.val;
@@ -227,9 +226,9 @@ class Matrix3d {
227
226
  /**
228
227
  * Transpose the value of this matrix.
229
228
  * @name transpose
230
- * @memberOf me.Matrix3d
229
+ * @memberof me.Matrix3d
231
230
  * @function
232
- * @return {me.Matrix3d} Reference to this object for method chaining
231
+ * @returns {me.Matrix3d} Reference to this object for method chaining
233
232
  */
234
233
  transpose() {
235
234
  var a = this.val,
@@ -259,9 +258,9 @@ class Matrix3d {
259
258
  /**
260
259
  * invert this matrix, causing it to apply the opposite transformation.
261
260
  * @name invert
262
- * @memberOf me.Matrix3d
261
+ * @memberof me.Matrix3d
263
262
  * @function
264
- * @return {me.Matrix3d} Reference to this object for method chaining
263
+ * @returns {me.Matrix3d} Reference to this object for method chaining
265
264
  */
266
265
  invert() {
267
266
  var a = this.val;
@@ -319,10 +318,10 @@ class Matrix3d {
319
318
  /**
320
319
  * apply the current transform to the given 2d or 3d vector
321
320
  * @name apply
322
- * @memberOf me.Matrix3d
321
+ * @memberof me.Matrix3d
323
322
  * @function
324
- * @param {me.Vector2d|me.Vector3d} vector the vector object to be transformed
325
- * @return {me.Vector2d|me.Vector3d} result vector object.
323
+ * @param {me.Vector2d|me.Vector3d} v the vector object to be transformed
324
+ * @returns {me.Vector2d|me.Vector3d} result vector object.
326
325
  */
327
326
  apply(v) {
328
327
  var a = this.val,
@@ -345,10 +344,10 @@ class Matrix3d {
345
344
  /**
346
345
  * apply the inverted current transform to the given 2d or 3d vector
347
346
  * @name applyInverse
348
- * @memberOf me.Matrix3d
347
+ * @memberof me.Matrix3d
349
348
  * @function
350
- * @param {me.Vector2d|me.Vector3d} vector the vector object to be transformed
351
- * @return {me.Vector2d|me.Vector3d} result vector object.
349
+ * @param {me.Vector2d|me.Vector3d} v the vector object to be transformed
350
+ * @returns {me.Vector2d|me.Vector3d} result vector object.
352
351
  */
353
352
  applyInverse(v) {
354
353
  // invert the current matrix
@@ -366,15 +365,15 @@ class Matrix3d {
366
365
  * generate an orthogonal projection matrix, with the result replacing the current matrix
367
366
  * <img src="images/glOrtho.gif"/><br>
368
367
  * @name ortho
369
- * @memberOf me.Matrix3d
368
+ * @memberof me.Matrix3d
370
369
  * @function
371
- * @param {Number} left farthest left on the x-axis
372
- * @param {Number} right farthest right on the x-axis
373
- * @param {Number} bottom farthest down on the y-axis
374
- * @param {Number} top farthest up on the y-axis
375
- * @param {Number} near distance to the near clipping plane along the -Z axis
376
- * @param {Number} far distance to the far clipping plane along the -Z axis
377
- * @return {me.Matrix3d} Reference to this object for method chaining
370
+ * @param {number} left farthest left on the x-axis
371
+ * @param {number} right farthest right on the x-axis
372
+ * @param {number} bottom farthest down on the y-axis
373
+ * @param {number} top farthest up on the y-axis
374
+ * @param {number} near distance to the near clipping plane along the -Z axis
375
+ * @param {number} far distance to the far clipping plane along the -Z axis
376
+ * @returns {me.Matrix3d} Reference to this object for method chaining
378
377
  */
379
378
  ortho(left, right, bottom, top, near, far) {
380
379
  var a = this.val;
@@ -405,12 +404,12 @@ class Matrix3d {
405
404
  /**
406
405
  * scale the matrix
407
406
  * @name scale
408
- * @memberOf me.Matrix3d
407
+ * @memberof me.Matrix3d
409
408
  * @function
410
- * @param {Number} x a number representing the abscissa of the scaling vector.
411
- * @param {Number} [y=x] a number representing the ordinate of the scaling vector.
412
- * @param {Number} [z=0] a number representing the depth vector
413
- * @return {me.Matrix3d} Reference to this object for method chaining
409
+ * @param {number} x a number representing the abscissa of the scaling vector.
410
+ * @param {number} [y=x] a number representing the ordinate of the scaling vector.
411
+ * @param {number} [z=0] a number representing the depth vector
412
+ * @returns {me.Matrix3d} Reference to this object for method chaining
414
413
  */
415
414
  scale(x, y, z) {
416
415
  var a = this.val,
@@ -439,10 +438,10 @@ class Matrix3d {
439
438
  /**
440
439
  * adds a 2D scaling transformation.
441
440
  * @name scaleV
442
- * @memberOf me.Matrix3d
441
+ * @memberof me.Matrix3d
443
442
  * @function
444
- * @param {me.Vector2d|me.Vector3d} vector scaling vector
445
- * @return {me.Matrix3d} Reference to this object for method chaining
443
+ * @param {me.Vector2d|me.Vector3d} v scaling vector
444
+ * @returns {me.Matrix3d} Reference to this object for method chaining
446
445
  */
447
446
  scaleV(v) {
448
447
  return this.scale(v.x, v.y, v.z);
@@ -451,10 +450,10 @@ class Matrix3d {
451
450
  /**
452
451
  * specifies a 2D scale operation using the [sx, 1] scaling vector
453
452
  * @name scaleX
454
- * @memberOf me.Matrix3d
453
+ * @memberof me.Matrix3d
455
454
  * @function
456
- * @param {Number} x x scaling vector
457
- * @return {me.Matrix3d} Reference to this object for method chaining
455
+ * @param {number} x x scaling vector
456
+ * @returns {me.Matrix3d} Reference to this object for method chaining
458
457
  */
459
458
  scaleX(x) {
460
459
  return this.scale(x, 1);
@@ -463,10 +462,10 @@ class Matrix3d {
463
462
  /**
464
463
  * specifies a 2D scale operation using the [1,sy] scaling vector
465
464
  * @name scaleY
466
- * @memberOf me.Matrix3d
465
+ * @memberof me.Matrix3d
467
466
  * @function
468
- * @param {Number} y y scaling vector
469
- * @return {me.Matrix3d} Reference to this object for method chaining
467
+ * @param {number} y y scaling vector
468
+ * @returns {me.Matrix3d} Reference to this object for method chaining
470
469
  */
471
470
  scaleY(y) {
472
471
  return this.scale(1, y);
@@ -475,11 +474,11 @@ class Matrix3d {
475
474
  /**
476
475
  * rotate this matrix (counter-clockwise) by the specified angle (in radians).
477
476
  * @name rotate
478
- * @memberOf me.Matrix3d
477
+ * @memberof me.Matrix3d
479
478
  * @function
480
- * @param {Number} angle Rotation angle in radians.
481
- * @param {me.Vector3d} axis the axis to rotate around
482
- * @return {me.Matrix3d} Reference to this object for method chaining
479
+ * @param {number} angle Rotation angle in radians.
480
+ * @param {me.Vector3d} v the axis to rotate around
481
+ * @returns {me.Matrix3d} Reference to this object for method chaining
483
482
  */
484
483
  rotate(angle, v) {
485
484
  var a = this.val,
@@ -554,20 +553,20 @@ class Matrix3d {
554
553
  /**
555
554
  * translate the matrix position using the given vector
556
555
  * @name translate
557
- * @memberOf me.Matrix3d
556
+ * @memberof me.Matrix3d
558
557
  * @function
559
- * @param {Number} x a number representing the abscissa of the vector.
560
- * @param {Number} [y=x] a number representing the ordinate of the vector.
561
- * @param {Number} [z=0] a number representing the depth of the vector
562
- * @return {me.Matrix3d} Reference to this object for method chaining
558
+ * @param {number} x a number representing the abscissa of the vector.
559
+ * @param {number} [y=x] a number representing the ordinate of the vector.
560
+ * @param {number} [z=0] a number representing the depth of the vector
561
+ * @returns {me.Matrix3d} Reference to this object for method chaining
563
562
  */
564
563
  /**
565
564
  * translate the matrix by a vector on the horizontal and vertical axis
566
565
  * @name translateV
567
- * @memberOf me.Matrix3d
566
+ * @memberof me.Matrix3d
568
567
  * @function
569
568
  * @param {me.Vector2d|me.Vector3d} v the vector to translate the matrix by
570
- * @return {me.Matrix3d} Reference to this object for method chaining
569
+ * @returns {me.Matrix3d} Reference to this object for method chaining
571
570
  */
572
571
  translate() {
573
572
  var a = this.val;
@@ -596,10 +595,10 @@ class Matrix3d {
596
595
  /**
597
596
  * returns true if the matrix is an identity matrix.
598
597
  * @name isIdentity
599
- * @memberOf me.Matrix3d
598
+ * @memberof me.Matrix3d
600
599
  * @function
601
- * @return {Boolean}
602
- **/
600
+ * @returns {boolean}
601
+ */
603
602
  isIdentity() {
604
603
  var a = this.val;
605
604
 
@@ -626,10 +625,10 @@ class Matrix3d {
626
625
  /**
627
626
  * return true if the two matrices are identical
628
627
  * @name equals
629
- * @memberOf me.Matrix3d
628
+ * @memberof me.Matrix3d
630
629
  * @function
631
630
  * @param {me.Matrix3d} m the other matrix
632
- * @return {Boolean} true if both are equals
631
+ * @returns {boolean} true if both are equals
633
632
  */
634
633
  equals(m) {
635
634
  var b = m.val;
@@ -658,9 +657,9 @@ class Matrix3d {
658
657
  /**
659
658
  * Clone the Matrix
660
659
  * @name clone
661
- * @memberOf me.Matrix3d
660
+ * @memberof me.Matrix3d
662
661
  * @function
663
- * @return {me.Matrix3d}
662
+ * @returns {me.Matrix3d}
664
663
  */
665
664
  clone() {
666
665
  return pool.pull("Matrix3d", this);
@@ -669,9 +668,9 @@ class Matrix3d {
669
668
  /**
670
669
  * return an array representation of this Matrix
671
670
  * @name toArray
672
- * @memberOf me.Matrix3d
671
+ * @memberof me.Matrix3d
673
672
  * @function
674
- * @return {Float32Array}
673
+ * @returns {Float32Array}
675
674
  */
676
675
  toArray() {
677
676
  return this.val;
@@ -680,9 +679,9 @@ class Matrix3d {
680
679
  /**
681
680
  * convert the object to a string representation
682
681
  * @name toString
683
- * @memberOf me.Matrix3d
682
+ * @memberof me.Matrix3d
684
683
  * @function
685
- * @return {String}
684
+ * @returns {string}
686
685
  */
687
686
  toString() {
688
687
  var a = this.val;