melonjs 10.1.1 → 10.2.3

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 (92) hide show
  1. package/README.md +6 -10
  2. package/dist/melonjs.js +3114 -2866
  3. package/dist/melonjs.min.js +3 -3
  4. package/dist/melonjs.module.d.ts +2588 -2498
  5. package/dist/melonjs.module.js +2694 -2479
  6. package/package.json +10 -11
  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 +3 -3
  13. package/src/index.js +15 -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 +25 -33
  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 +31 -27
  33. package/src/loader/loadingscreen.js +44 -75
  34. package/src/math/color.js +45 -64
  35. package/src/math/math.js +17 -17
  36. package/src/math/matrix2.js +46 -46
  37. package/src/math/matrix3.js +64 -64
  38. package/src/math/observable_vector2.js +45 -57
  39. package/src/math/observable_vector3.js +56 -70
  40. package/src/math/vector2.js +60 -59
  41. package/src/math/vector3.js +65 -64
  42. package/src/particles/emitter.js +53 -55
  43. package/src/particles/particle.js +1 -1
  44. package/src/physics/body.js +45 -51
  45. package/src/physics/bounds.js +36 -36
  46. package/src/physics/collision.js +15 -16
  47. package/src/physics/detector.js +10 -11
  48. package/src/physics/quadtree.js +18 -16
  49. package/src/physics/sat.js +17 -17
  50. package/src/physics/world.js +12 -10
  51. package/src/plugin/plugin.js +6 -6
  52. package/src/renderable/GUI.js +13 -18
  53. package/src/renderable/collectable.js +3 -3
  54. package/src/renderable/colorlayer.js +4 -4
  55. package/src/renderable/container.js +64 -46
  56. package/src/renderable/imagelayer.js +30 -31
  57. package/src/renderable/nineslicesprite.js +158 -69
  58. package/src/renderable/renderable.js +68 -67
  59. package/src/renderable/sprite.js +57 -43
  60. package/src/renderable/trigger.js +14 -15
  61. package/src/shapes/ellipse.js +27 -26
  62. package/src/shapes/line.js +8 -7
  63. package/src/shapes/poly.js +33 -31
  64. package/src/shapes/rectangle.js +50 -96
  65. package/src/state/stage.js +8 -8
  66. package/src/state/state.js +56 -56
  67. package/src/system/device.js +97 -84
  68. package/src/system/event.js +72 -72
  69. package/src/system/pooling.js +14 -14
  70. package/src/system/save.js +6 -3
  71. package/src/system/timer.js +20 -20
  72. package/src/text/bitmaptext.js +27 -33
  73. package/src/text/bitmaptextdata.js +9 -9
  74. package/src/text/text.js +118 -59
  75. package/src/tweens/easing.js +4 -4
  76. package/src/tweens/interpolation.js +4 -4
  77. package/src/tweens/tween.js +37 -27
  78. package/src/utils/agent.js +9 -8
  79. package/src/utils/array.js +4 -4
  80. package/src/utils/file.js +4 -4
  81. package/src/utils/function.js +5 -5
  82. package/src/utils/string.js +12 -12
  83. package/src/utils/utils.js +19 -19
  84. package/src/video/canvas/canvas_renderer.js +90 -90
  85. package/src/video/renderer.js +40 -39
  86. package/src/video/texture.js +85 -76
  87. package/src/video/texture_cache.js +11 -0
  88. package/src/video/video.js +31 -31
  89. package/src/video/webgl/buffer/vertex.js +9 -1
  90. package/src/video/webgl/glshader.js +20 -20
  91. package/src/video/webgl/webgl_compositor.js +47 -46
  92. package/src/video/webgl/webgl_renderer.js +104 -104
@@ -7,9 +7,9 @@ import pool from "./../system/pooling.js";
7
7
  * @class Vector3d
8
8
  * @memberOf me
9
9
  * @constructor
10
- * @param {Number} [x=0] x value of the vector
11
- * @param {Number} [y=0] y value of the vector
12
- * @param {Number} [z=0] z value of the vector
10
+ * @param {number} [x=0] x value of the vector
11
+ * @param {number} [y=0] y value of the vector
12
+ * @param {number} [z=0] z value of the vector
13
13
  */
14
14
 
15
15
  class Vector3d {
@@ -30,7 +30,8 @@ class Vector3d {
30
30
  }
31
31
 
32
32
  /**
33
- * @ignore */
33
+ * @ignore
34
+ */
34
35
  _set(x, y, z = 0) {
35
36
  this.x = x;
36
37
  this.y = y;
@@ -43,10 +44,10 @@ class Vector3d {
43
44
  * @name set
44
45
  * @memberOf me.Vector3d
45
46
  * @function
46
- * @param {Number} x
47
- * @param {Number} y
48
- * @param {Number} [z=0]
49
- * @return {me.Vector3d} Reference to this object for method chaining
47
+ * @param {number} x
48
+ * @param {number} y
49
+ * @param {number} [z=0]
50
+ * @returns {me.Vector3d} Reference to this object for method chaining
50
51
  */
51
52
  set(x, y, z) {
52
53
  if (x !== +x || y !== +y || (typeof z !== "undefined" && z !== +z)) {
@@ -58,7 +59,7 @@ class Vector3d {
58
59
  /**
59
60
  * x value of the vector
60
61
  * @public
61
- * @type Number
62
+ * @type {number}
62
63
  * @name x
63
64
  * @memberOf me.Vector3d
64
65
  */
@@ -67,7 +68,7 @@ class Vector3d {
67
68
  /**
68
69
  * y value of the vector
69
70
  * @public
70
- * @type Number
71
+ * @type {number}
71
72
  * @name y
72
73
  * @memberOf me.Vector3d
73
74
  */
@@ -76,7 +77,7 @@ class Vector3d {
76
77
  /**
77
78
  * z value of the vector
78
79
  * @public
79
- * @type Number
80
+ * @type {number}
80
81
  * @name z
81
82
  * @memberOf me.Vector3d
82
83
  */
@@ -90,7 +91,7 @@ class Vector3d {
90
91
  * @name setZero
91
92
  * @memberOf me.Vector3d
92
93
  * @function
93
- * @return {me.Vector3d} Reference to this object for method chaining
94
+ * @returns {me.Vector3d} Reference to this object for method chaining
94
95
  */
95
96
  setZero() {
96
97
  return this.set(0, 0, 0);
@@ -102,7 +103,7 @@ class Vector3d {
102
103
  * @memberOf me.Vector3d
103
104
  * @function
104
105
  * @param {me.Vector2d|me.Vector3d} v
105
- * @return {me.Vector3d} Reference to this object for method chaining
106
+ * @returns {me.Vector3d} Reference to this object for method chaining
106
107
  */
107
108
  setV(v) {
108
109
  return this._set(v.x, v.y, v.z);
@@ -114,7 +115,7 @@ class Vector3d {
114
115
  * @memberOf me.Vector3d
115
116
  * @function
116
117
  * @param {me.Vector2d|me.Vector3d} v
117
- * @return {me.Vector3d} Reference to this object for method chaining
118
+ * @returns {me.Vector3d} Reference to this object for method chaining
118
119
  */
119
120
  add(v) {
120
121
  return this._set(this.x + v.x, this.y + v.y, this.z + (v.z || 0));
@@ -126,7 +127,7 @@ class Vector3d {
126
127
  * @memberOf me.Vector3d
127
128
  * @function
128
129
  * @param {me.Vector2d|me.Vector3d} v
129
- * @return {me.Vector3d} Reference to this object for method chaining
130
+ * @returns {me.Vector3d} Reference to this object for method chaining
130
131
  */
131
132
  sub(v) {
132
133
  return this._set(this.x - v.x, this.y - v.y, this.z - (v.z || 0));
@@ -137,10 +138,10 @@ class Vector3d {
137
138
  * @name scale
138
139
  * @memberOf me.Vector3d
139
140
  * @function
140
- * @param {Number} x
141
- * @param {Number} [y=x]
142
- * @param {Number} [z=1]
143
- * @return {me.Vector3d} Reference to this object for method chaining
141
+ * @param {number} x
142
+ * @param {number} [y=x]
143
+ * @param {number} [z=1]
144
+ * @returns {me.Vector3d} Reference to this object for method chaining
144
145
  */
145
146
  scale(x, y, z) {
146
147
  y = (typeof (y) !== "undefined" ? y : x);
@@ -153,7 +154,7 @@ class Vector3d {
153
154
  * @memberOf me.Vector3d
154
155
  * @function
155
156
  * @param {me.Vector2d|me.Vector3d} v
156
- * @return {me.Vector3d} Reference to this object for method chaining
157
+ * @returns {me.Vector3d} Reference to this object for method chaining
157
158
  */
158
159
  scaleV(v) {
159
160
  return this.scale(v.x, v.y, v.z);
@@ -164,7 +165,7 @@ class Vector3d {
164
165
  * @name toIso
165
166
  * @memberOf me.Vector3d
166
167
  * @function
167
- * @return {me.Vector3d} Reference to this object for method chaining
168
+ * @returns {me.Vector3d} Reference to this object for method chaining
168
169
  */
169
170
  toIso() {
170
171
  return this._set(this.x - this.y, (this.x + this.y) * 0.5, this.z);
@@ -175,7 +176,7 @@ class Vector3d {
175
176
  * @name to2d
176
177
  * @memberOf me.Vector3d
177
178
  * @function
178
- * @return {me.Vector3d} Reference to this object for method chaining
179
+ * @returns {me.Vector3d} Reference to this object for method chaining
179
180
  */
180
181
  to2d() {
181
182
  return this._set(this.y + this.x / 2, this.y - this.x / 2, this.z);
@@ -186,8 +187,8 @@ class Vector3d {
186
187
  * @name div
187
188
  * @memberOf me.Vector3d
188
189
  * @function
189
- * @param {Number} value
190
- * @return {me.Vector3d} Reference to this object for method chaining
190
+ * @param {number} n the value to divide the vector by
191
+ * @returns {me.Vector3d} Reference to this object for method chaining
191
192
  */
192
193
  div(n) {
193
194
  return this._set(this.x / n, this.y / n, this.z / n);
@@ -198,7 +199,7 @@ class Vector3d {
198
199
  * @name abs
199
200
  * @memberOf me.Vector3d
200
201
  * @function
201
- * @return {me.Vector3d} Reference to this object for method chaining
202
+ * @returns {me.Vector3d} Reference to this object for method chaining
202
203
  */
203
204
  abs() {
204
205
  return this._set((this.x < 0) ? -this.x : this.x, (this.y < 0) ? -this.y : this.y, (this.z < 0) ? -this.z : this.z);
@@ -209,9 +210,9 @@ class Vector3d {
209
210
  * @name clamp
210
211
  * @memberOf me.Vector3d
211
212
  * @function
212
- * @param {Number} low
213
- * @param {Number} high
214
- * @return {me.Vector3d} new me.Vector3d
213
+ * @param {number} low
214
+ * @param {number} high
215
+ * @returns {me.Vector3d} new me.Vector3d
215
216
  */
216
217
  clamp(low, high) {
217
218
  return new Vector3d(clamp(this.x, low, high), clamp(this.y, low, high), clamp(this.z, low, high));
@@ -222,9 +223,9 @@ class Vector3d {
222
223
  * @name clampSelf
223
224
  * @memberOf me.Vector3d
224
225
  * @function
225
- * @param {Number} low
226
- * @param {Number} high
227
- * @return {me.Vector3d} Reference to this object for method chaining
226
+ * @param {number} low
227
+ * @param {number} high
228
+ * @returns {me.Vector3d} Reference to this object for method chaining
228
229
  */
229
230
  clampSelf(low, high) {
230
231
  return this._set(clamp(this.x, low, high), clamp(this.y, low, high), clamp(this.z, low, high));
@@ -236,7 +237,7 @@ class Vector3d {
236
237
  * @memberOf me.Vector3d
237
238
  * @function
238
239
  * @param {me.Vector2d|me.Vector3d} v
239
- * @return {me.Vector3d} Reference to this object for method chaining
240
+ * @returns {me.Vector3d} Reference to this object for method chaining
240
241
  */
241
242
  minV(v) {
242
243
  var _vz = v.z || 0;
@@ -249,7 +250,7 @@ class Vector3d {
249
250
  * @memberOf me.Vector3d
250
251
  * @function
251
252
  * @param {me.Vector2d|me.Vector3d} v
252
- * @return {me.Vector3d} Reference to this object for method chaining
253
+ * @returns {me.Vector3d} Reference to this object for method chaining
253
254
  */
254
255
  maxV(v) {
255
256
  var _vz = v.z || 0;
@@ -261,7 +262,7 @@ class Vector3d {
261
262
  * @name floor
262
263
  * @memberOf me.Vector3d
263
264
  * @function
264
- * @return {me.Vector3d} new me.Vector3d
265
+ * @returns {me.Vector3d} new me.Vector3d
265
266
  */
266
267
  floor() {
267
268
  return new Vector3d(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
@@ -272,7 +273,7 @@ class Vector3d {
272
273
  * @name floorSelf
273
274
  * @memberOf me.Vector3d
274
275
  * @function
275
- * @return {me.Vector3d} Reference to this object for method chaining
276
+ * @returns {me.Vector3d} Reference to this object for method chaining
276
277
  */
277
278
  floorSelf() {
278
279
  return this._set(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
@@ -283,7 +284,7 @@ class Vector3d {
283
284
  * @name ceil
284
285
  * @memberOf me.Vector3d
285
286
  * @function
286
- * @return {me.Vector3d} new me.Vector3d
287
+ * @returns {me.Vector3d} new me.Vector3d
287
288
  */
288
289
  ceil() {
289
290
  return new Vector3d(Math.ceil(this.x), Math.ceil(this.y), Math.ceil(this.z));
@@ -294,7 +295,7 @@ class Vector3d {
294
295
  * @name ceilSelf
295
296
  * @memberOf me.Vector3d
296
297
  * @function
297
- * @return {me.Vector3d} Reference to this object for method chaining
298
+ * @returns {me.Vector3d} Reference to this object for method chaining
298
299
  */
299
300
  ceilSelf() {
300
301
  return this._set(Math.ceil(this.x), Math.ceil(this.y), Math.ceil(this.z));
@@ -305,7 +306,7 @@ class Vector3d {
305
306
  * @name negate
306
307
  * @memberOf me.Vector3d
307
308
  * @function
308
- * @return {me.Vector3d} new me.Vector3d
309
+ * @returns {me.Vector3d} new me.Vector3d
309
310
  */
310
311
  negate() {
311
312
  return new Vector3d(-this.x, -this.y, -this.z);
@@ -316,7 +317,7 @@ class Vector3d {
316
317
  * @name negateSelf
317
318
  * @memberOf me.Vector3d
318
319
  * @function
319
- * @return {me.Vector3d} Reference to this object for method chaining
320
+ * @returns {me.Vector3d} Reference to this object for method chaining
320
321
  */
321
322
  negateSelf() {
322
323
  return this._set(-this.x, -this.y, -this.z);
@@ -328,7 +329,7 @@ class Vector3d {
328
329
  * @memberOf me.Vector3d
329
330
  * @function
330
331
  * @param {me.Vector2d|me.Vector3d} v
331
- * @return {me.Vector3d} Reference to this object for method chaining
332
+ * @returns {me.Vector3d} Reference to this object for method chaining
332
333
  */
333
334
  copy(v) {
334
335
  return this._set(v.x, v.y, v.z || 0);
@@ -340,17 +341,17 @@ class Vector3d {
340
341
  * @memberOf me.Vector3d
341
342
  * @function
342
343
  * @param {me.Vector2d|me.Vector3d} v
343
- * @return {Boolean}
344
+ * @returns {boolean}
344
345
  */
345
346
  /**
346
347
  * return true if this vector is equal to the given values
347
348
  * @name equals
348
349
  * @memberOf me.Vector3d
349
350
  * @function
350
- * @param {Number} x
351
- * @param {Number} y
352
- * @param {Number} [z]
353
- * @return {Boolean}
351
+ * @param {number} x
352
+ * @param {number} y
353
+ * @param {number} [z]
354
+ * @returns {boolean}
354
355
  */
355
356
  equals() {
356
357
  var _x, _y, _z;
@@ -378,7 +379,7 @@ class Vector3d {
378
379
  * @name normalize
379
380
  * @memberOf me.Vector3d
380
381
  * @function
381
- * @return {me.Vector3d} Reference to this object for method chaining
382
+ * @returns {me.Vector3d} Reference to this object for method chaining
382
383
  */
383
384
  normalize() {
384
385
  return this.div(this.length() || 1);
@@ -390,7 +391,7 @@ class Vector3d {
390
391
  * @name perp
391
392
  * @memberOf me.Vector3d
392
393
  * @function
393
- * @return {me.Vector3d} Reference to this object for method chaining
394
+ * @returns {me.Vector3d} Reference to this object for method chaining
394
395
  */
395
396
  perp() {
396
397
  return this._set(this.y, -this.x, this.z);
@@ -403,7 +404,7 @@ class Vector3d {
403
404
  * @function
404
405
  * @param {number} angle The angle to rotate (in radians)
405
406
  * @param {me.Vector2d|me.ObservableVector2d} [v] an optional point to rotate around (on the same z axis)
406
- * @return {me.Vector3d} Reference to this object for method chaining
407
+ * @returns {me.Vector3d} Reference to this object for method chaining
407
408
  */
408
409
  rotate(angle, v) {
409
410
  var cx = 0;
@@ -430,19 +431,19 @@ class Vector3d {
430
431
  * @memberOf me.Vector3d
431
432
  * @function
432
433
  * @param {me.Vector2d|me.Vector3d} v
433
- * @return {Number} The dot product.
434
+ * @returns {number} The dot product.
434
435
  */
435
436
  dotProduct(v) {
436
437
  return this.x * v.x + this.y * v.y + this.z * (typeof(v.z) !== "undefined" ? v.z : this.z);
437
438
  }
438
439
 
439
440
  /**
440
- * return the square length of this vector
441
- * @name length2
442
- * @memberOf me.Vector3d
443
- * @function
444
- * @return {Number} The length^2 of this vector.
445
- */
441
+ * return the square length of this vector
442
+ * @name length2
443
+ * @memberOf me.Vector3d
444
+ * @function
445
+ * @returns {number} The length^2 of this vector.
446
+ */
446
447
  length2() {
447
448
  return this.dotProduct(this);
448
449
  }
@@ -452,7 +453,7 @@ class Vector3d {
452
453
  * @name length
453
454
  * @memberOf me.Vector3d
454
455
  * @function
455
- * @return {Number} the length of this vector
456
+ * @returns {number} the length of this vector
456
457
  */
457
458
  length() {
458
459
  return Math.sqrt(this.length2());
@@ -464,8 +465,8 @@ class Vector3d {
464
465
  * @memberOf me.Vector3d
465
466
  * @function
466
467
  * @param {me.Vector3d} v
467
- * @param {Number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
468
- * @return {me.Vector3d} Reference to this object for method chaining
468
+ * @param {number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
469
+ * @returns {me.Vector3d} Reference to this object for method chaining
469
470
  */
470
471
  lerp(v, alpha) {
471
472
  this.x += ( v.x - this.x ) * alpha;
@@ -480,7 +481,7 @@ class Vector3d {
480
481
  * @memberOf me.Vector3d
481
482
  * @function
482
483
  * @param {me.Vector2d|me.Vector3d} v
483
- * @return {Number}
484
+ * @returns {number}
484
485
  */
485
486
  distance(v) {
486
487
  var dx = this.x - v.x;
@@ -495,7 +496,7 @@ class Vector3d {
495
496
  * @memberOf me.Vector3d
496
497
  * @function
497
498
  * @param {me.Vector2d|me.Vector3d} v
498
- * @return {Number} angle in radians
499
+ * @returns {number} angle in radians
499
500
  */
500
501
  angle(v) {
501
502
  return Math.acos(clamp(this.dotProduct(v) / (this.length() * v.length()), -1, 1));
@@ -507,7 +508,7 @@ class Vector3d {
507
508
  * @memberOf me.Vector3d
508
509
  * @function
509
510
  * @param {me.Vector2d|me.Vector3d} v The vector to project onto.
510
- * @return {me.Vector3d} Reference to this object for method chaining
511
+ * @returns {me.Vector3d} Reference to this object for method chaining
511
512
  */
512
513
  project(v) {
513
514
  var ratio = this.dotProduct(v) / v.length2();
@@ -521,7 +522,7 @@ class Vector3d {
521
522
  * @memberOf me.Vector3d
522
523
  * @function
523
524
  * @param {me.Vector2d|me.Vector3d} v The unit vector to project onto.
524
- * @return {me.Vector3d} Reference to this object for method chaining
525
+ * @returns {me.Vector3d} Reference to this object for method chaining
525
526
  */
526
527
  projectN(v) {
527
528
  var ratio = this.dotProduct(v) / v.length2();
@@ -533,7 +534,7 @@ class Vector3d {
533
534
  * @name clone
534
535
  * @memberOf me.Vector3d
535
536
  * @function
536
- * @return {me.Vector3d} new me.Vector3d
537
+ * @returns {me.Vector3d} new me.Vector3d
537
538
  */
538
539
  clone() {
539
540
  return pool.pull("Vector3d", this.x, this.y, this.z);
@@ -544,7 +545,7 @@ class Vector3d {
544
545
  * @name toString
545
546
  * @memberOf me.Vector3d
546
547
  * @function
547
- * @return {String}
548
+ * @returns {string}
548
549
  */
549
550
  toString() {
550
551
  return "x:" + this.x + ",y:" + this.y + ",z:" + this.z;