melonjs 10.10.0 → 11.0.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 +4 -3
  2. package/dist/melonjs.js +1071 -2102
  3. package/dist/melonjs.min.js +4 -4
  4. package/dist/melonjs.module.d.ts +600 -1351
  5. package/dist/melonjs.module.js +996 -2029
  6. package/package.json +16 -19
  7. package/src/audio/audio.js +0 -1
  8. package/src/camera/camera2d.js +1 -16
  9. package/src/entity/entity.js +6 -11
  10. package/src/geometries/ellipse.js +3 -12
  11. package/src/geometries/line.js +1 -4
  12. package/src/geometries/path2d.js +4 -14
  13. package/src/geometries/poly.js +6 -24
  14. package/src/geometries/rectangle.js +3 -15
  15. package/src/geometries/roundrect.js +2 -6
  16. package/src/index.js +0 -1
  17. package/src/input/gamepad.js +3 -14
  18. package/src/input/keyboard.js +1 -9
  19. package/src/input/pointer.js +0 -1
  20. package/src/input/pointerevent.js +14 -23
  21. package/src/lang/deprecated.js +4 -3
  22. package/src/level/level.js +0 -9
  23. package/src/level/tiled/TMXGroup.js +0 -4
  24. package/src/level/tiled/TMXLayer.js +0 -8
  25. package/src/level/tiled/TMXObject.js +0 -3
  26. package/src/level/tiled/TMXTile.js +4 -5
  27. package/src/level/tiled/TMXTileMap.js +1 -7
  28. package/src/level/tiled/TMXTileset.js +0 -5
  29. package/src/level/tiled/TMXTilesetGroup.js +1 -4
  30. package/src/level/tiled/TMXUtils.js +0 -3
  31. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -3
  32. package/src/level/tiled/renderer/TMXIsometricRenderer.js +0 -1
  33. package/src/level/tiled/renderer/TMXRenderer.js +1 -7
  34. package/src/loader/loader.js +0 -11
  35. package/src/loader/loadingscreen.js +1 -1
  36. package/src/math/color.js +5 -26
  37. package/src/math/math.js +0 -10
  38. package/src/math/matrix2.js +12 -27
  39. package/src/math/matrix3.js +1 -22
  40. package/src/math/observable_vector2.js +0 -29
  41. package/src/math/observable_vector3.js +0 -29
  42. package/src/math/vector2.js +3 -40
  43. package/src/math/vector3.js +4 -41
  44. package/src/particles/emitter.js +1 -1
  45. package/src/physics/body.js +4 -5
  46. package/src/physics/bounds.js +5 -19
  47. package/src/physics/collision.js +1 -13
  48. package/src/physics/detector.js +6 -56
  49. package/src/physics/quadtree.js +0 -7
  50. package/src/physics/response.js +48 -0
  51. package/src/physics/sat.js +4 -4
  52. package/src/physics/world.js +0 -4
  53. package/src/plugin/plugin.js +0 -2
  54. package/src/polyfill/roundrect.js +4 -2
  55. package/src/renderable/GUI.js +6 -9
  56. package/src/renderable/collectable.js +1 -0
  57. package/src/renderable/colorlayer.js +9 -7
  58. package/src/renderable/container.js +12 -38
  59. package/src/renderable/dragndrop.js +1 -10
  60. package/src/renderable/imagelayer.js +6 -10
  61. package/src/renderable/light2d.js +48 -16
  62. package/src/renderable/renderable.js +6 -28
  63. package/src/renderable/sprite.js +4 -16
  64. package/src/renderable/trigger.js +10 -3
  65. package/src/state/stage.js +0 -4
  66. package/src/state/state.js +22 -23
  67. package/src/system/device.js +16 -119
  68. package/src/system/dom.js +69 -0
  69. package/src/system/event.js +22 -0
  70. package/src/system/pooling.js +20 -9
  71. package/src/system/save.js +9 -11
  72. package/src/system/timer.js +239 -218
  73. package/src/text/bitmaptextdata.js +1 -4
  74. package/src/text/glyph.js +2 -2
  75. package/src/text/text.js +13 -8
  76. package/src/text/textmetrics.js +0 -2
  77. package/src/tweens/easing.js +1 -1
  78. package/src/tweens/interpolation.js +2 -2
  79. package/src/tweens/tween.js +1 -13
  80. package/src/utils/agent.js +1 -3
  81. package/src/utils/array.js +0 -3
  82. package/src/utils/file.js +0 -2
  83. package/src/utils/function.js +0 -2
  84. package/src/utils/string.js +0 -6
  85. package/src/utils/utils.js +0 -3
  86. package/src/video/canvas/canvas_renderer.js +4 -39
  87. package/src/video/renderer.js +1 -23
  88. package/src/video/texture/atlas.js +2 -0
  89. package/src/video/texture/cache.js +0 -1
  90. package/src/video/texture/canvas_texture.js +16 -4
  91. package/src/video/video.js +3 -3
  92. package/src/video/webgl/glshader.js +0 -5
  93. package/src/video/webgl/utils/uniforms.js +3 -6
  94. package/src/video/webgl/webgl_compositor.js +0 -14
  95. package/src/video/webgl/webgl_renderer.js +0 -42
@@ -9,7 +9,6 @@ import * as event from "./../../system/event.js";
9
9
  import pool from "./../../system/pooling.js";
10
10
  import { isPowerOfTwo, nextPowerOfTwo } from "./../../math/math.js";
11
11
 
12
-
13
12
  /**
14
13
  * @classdesc
15
14
  * a WebGL renderer object
@@ -172,7 +171,6 @@ class WebGLRenderer extends Renderer {
172
171
  * Reset context state
173
172
  * @name reset
174
173
  * @memberof WebGLRenderer
175
- * @function
176
174
  */
177
175
  reset() {
178
176
  super.reset();
@@ -196,10 +194,8 @@ class WebGLRenderer extends Renderer {
196
194
  /**
197
195
  * set the active compositor for this renderer
198
196
  * @name setCompositor
199
- * @function
200
197
  * @param {WebGLCompositor|string} compositor a compositor name or instance
201
198
  * @memberof WebGLRenderer
202
- * @function
203
199
  */
204
200
  setCompositor(compositor = "default") {
205
201
 
@@ -225,7 +221,6 @@ class WebGLRenderer extends Renderer {
225
221
  * Reset the gl transform to identity
226
222
  * @name resetTransform
227
223
  * @memberof WebGLRenderer
228
- * @function
229
224
  */
230
225
  resetTransform() {
231
226
  this.currentTransform.identity();
@@ -272,7 +267,6 @@ class WebGLRenderer extends Renderer {
272
267
  * Create a pattern with the specified repetition
273
268
  * @name createPattern
274
269
  * @memberof WebGLRenderer
275
- * @function
276
270
  * @param {Image} image Source image
277
271
  * @param {string} repeat Define how the pattern should be repeated
278
272
  * @returns {TextureAtlas}
@@ -305,7 +299,6 @@ class WebGLRenderer extends Renderer {
305
299
  * Flush the compositor to the frame buffer
306
300
  * @name flush
307
301
  * @memberof WebGLRenderer
308
- * @function
309
302
  */
310
303
  flush() {
311
304
  this.currentCompositor.flush();
@@ -315,7 +308,6 @@ class WebGLRenderer extends Renderer {
315
308
  * set/change the current projection matrix (WebGL only)
316
309
  * @name setProjection
317
310
  * @memberof WebGLRenderer
318
- * @function
319
311
  * @param {Matrix3d} matrix
320
312
  */
321
313
  setProjection(matrix) {
@@ -327,7 +319,6 @@ class WebGLRenderer extends Renderer {
327
319
  * Clears the gl context with the given color.
328
320
  * @name clearColor
329
321
  * @memberof WebGLRenderer
330
- * @function
331
322
  * @param {Color|string} [color="#000000"] CSS color.
332
323
  * @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
333
324
  */
@@ -355,7 +346,6 @@ class WebGLRenderer extends Renderer {
355
346
  * Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
356
347
  * @name clearRect
357
348
  * @memberof WebGLRenderer
358
- * @function
359
349
  * @param {number} x x axis of the coordinate for the rectangle starting point.
360
350
  * @param {number} y y axis of the coordinate for the rectangle starting point.
361
351
  * @param {number} width The rectangle's width.
@@ -405,7 +395,6 @@ class WebGLRenderer extends Renderer {
405
395
  * Draw an image to the gl context
406
396
  * @name drawImage
407
397
  * @memberof WebGLRenderer
408
- * @function
409
398
  * @param {Image} image An element to draw into the context. The specification permits any canvas image source (CanvasImageSource), specifically, a CSSImageValue, an HTMLImageElement, an SVGImageElement, an HTMLVideoElement, an HTMLCanvasElement, an ImageBitmap, or an OffscreenCanvas.
410
399
  * @param {number} sx The X coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.
411
400
  * @param {number} sy The Y coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.
@@ -458,7 +447,6 @@ class WebGLRenderer extends Renderer {
458
447
  * Draw a pattern within the given rectangle.
459
448
  * @name drawPattern
460
449
  * @memberof WebGLRenderer
461
- * @function
462
450
  * @param {TextureAtlas} pattern Pattern object
463
451
  * @param {number} x
464
452
  * @param {number} y
@@ -476,7 +464,6 @@ class WebGLRenderer extends Renderer {
476
464
  * return a reference to the screen canvas corresponding WebGL Context
477
465
  * @name getScreenContext
478
466
  * @memberof WebGLRenderer
479
- * @function
480
467
  * @returns {WebGLRenderingContext}
481
468
  */
482
469
  getScreenContext() {
@@ -487,7 +474,6 @@ class WebGLRenderer extends Renderer {
487
474
  * Returns the WebGL Context object of the given Canvas
488
475
  * @name getContextGL
489
476
  * @memberof WebGLRenderer
490
- * @function
491
477
  * @param {HTMLCanvasElement} canvas
492
478
  * @param {boolean} [transparent=true] use false to disable transparency
493
479
  * @returns {WebGLRenderingContext}
@@ -545,7 +531,6 @@ class WebGLRenderer extends Renderer {
545
531
  * return a reference to the system 2d Context
546
532
  * @name getContext
547
533
  * @memberof WebGLRenderer
548
- * @function
549
534
  * @returns {WebGLRenderingContext}
550
535
  */
551
536
  getContext() {
@@ -566,7 +551,6 @@ class WebGLRenderer extends Renderer {
566
551
  * @name setBlendMode
567
552
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
568
553
  * @memberof WebGLRenderer
569
- * @function
570
554
  * @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter", "additive", "screen"
571
555
  * @param {WebGLRenderingContext} [gl]
572
556
  */
@@ -617,7 +601,6 @@ class WebGLRenderer extends Renderer {
617
601
  * restores the canvas context
618
602
  * @name restore
619
603
  * @memberof WebGLRenderer
620
- * @function
621
604
  */
622
605
  restore() {
623
606
  // do nothing if there is no saved states
@@ -653,7 +636,6 @@ class WebGLRenderer extends Renderer {
653
636
  * saves the canvas context
654
637
  * @name save
655
638
  * @memberof WebGLRenderer
656
- * @function
657
639
  */
658
640
  save() {
659
641
  this._colorStack.push(this.currentColor.clone());
@@ -671,7 +653,6 @@ class WebGLRenderer extends Renderer {
671
653
  * rotates the uniform matrix
672
654
  * @name rotate
673
655
  * @memberof WebGLRenderer
674
- * @function
675
656
  * @param {number} angle in radians
676
657
  */
677
658
  rotate(angle) {
@@ -682,7 +663,6 @@ class WebGLRenderer extends Renderer {
682
663
  * scales the uniform matrix
683
664
  * @name scale
684
665
  * @memberof WebGLRenderer
685
- * @function
686
666
  * @param {number} x
687
667
  * @param {number} y
688
668
  */
@@ -703,7 +683,6 @@ class WebGLRenderer extends Renderer {
703
683
  * Set the global alpha
704
684
  * @name setGlobalAlpha
705
685
  * @memberof WebGLRenderer
706
- * @function
707
686
  * @param {number} alpha 0.0 to 1.0 values accepted.
708
687
  */
709
688
  setGlobalAlpha(alpha) {
@@ -714,7 +693,6 @@ class WebGLRenderer extends Renderer {
714
693
  * Return the global alpha
715
694
  * @name getGlobalAlpha
716
695
  * @memberof WebGLRenderer
717
- * @function
718
696
  * @returns {number} global alpha value
719
697
  */
720
698
  getGlobalAlpha() {
@@ -726,7 +704,6 @@ class WebGLRenderer extends Renderer {
726
704
  * By default, or upon reset, the value is set to #000000.
727
705
  * @name setColor
728
706
  * @memberof WebGLRenderer
729
- * @function
730
707
  * @param {Color|string} color css color string.
731
708
  */
732
709
  setColor(color) {
@@ -739,7 +716,6 @@ class WebGLRenderer extends Renderer {
739
716
  * Set the line width
740
717
  * @name setLineWidth
741
718
  * @memberof WebGLRenderer
742
- * @function
743
719
  * @param {number} width Line width
744
720
  */
745
721
  setLineWidth(width) {
@@ -750,7 +726,6 @@ class WebGLRenderer extends Renderer {
750
726
  * Stroke an arc at the specified coordinates with given radius, start and end points
751
727
  * @name strokeArc
752
728
  * @memberof WebGLRenderer
753
- * @function
754
729
  * @param {number} x arc center point x-axis
755
730
  * @param {number} y arc center point y-axis
756
731
  * @param {number} radius
@@ -778,7 +753,6 @@ class WebGLRenderer extends Renderer {
778
753
  * Fill an arc at the specified coordinates with given radius, start and end points
779
754
  * @name fillArc
780
755
  * @memberof WebGLRenderer
781
- * @function
782
756
  * @param {number} x arc center point x-axis
783
757
  * @param {number} y arc center point y-axis
784
758
  * @param {number} radius
@@ -794,7 +768,6 @@ class WebGLRenderer extends Renderer {
794
768
  * Stroke an ellipse at the specified coordinates with given radius
795
769
  * @name strokeEllipse
796
770
  * @memberof WebGLRenderer
797
- * @function
798
771
  * @param {number} x ellipse center point x-axis
799
772
  * @param {number} y ellipse center point y-axis
800
773
  * @param {number} w horizontal radius of the ellipse
@@ -820,7 +793,6 @@ class WebGLRenderer extends Renderer {
820
793
  * Fill an ellipse at the specified coordinates with given radius
821
794
  * @name fillEllipse
822
795
  * @memberof WebGLRenderer
823
- * @function
824
796
  * @param {number} x ellipse center point x-axis
825
797
  * @param {number} y ellipse center point y-axis
826
798
  * @param {number} w horizontal radius of the ellipse
@@ -834,7 +806,6 @@ class WebGLRenderer extends Renderer {
834
806
  * Stroke a line of the given two points
835
807
  * @name strokeLine
836
808
  * @memberof WebGLRenderer
837
- * @function
838
809
  * @param {number} startX the start x coordinate
839
810
  * @param {number} startY the start y coordinate
840
811
  * @param {number} endX the end x coordinate
@@ -856,7 +827,6 @@ class WebGLRenderer extends Renderer {
856
827
  * Fill a line of the given two points
857
828
  * @name fillLine
858
829
  * @memberof WebGLRenderer
859
- * @function
860
830
  * @param {number} startX the start x coordinate
861
831
  * @param {number} startY the start y coordinate
862
832
  * @param {number} endX the end x coordinate
@@ -870,7 +840,6 @@ class WebGLRenderer extends Renderer {
870
840
  * Stroke a me.Polygon on the screen with a specified color
871
841
  * @name strokePolygon
872
842
  * @memberof WebGLRenderer
873
- * @function
874
843
  * @param {Polygon} poly the shape to draw
875
844
  * @param {boolean} [fill=false] also fill the shape with the current color if true
876
845
  */
@@ -902,7 +871,6 @@ class WebGLRenderer extends Renderer {
902
871
  * Fill a me.Polygon on the screen
903
872
  * @name fillPolygon
904
873
  * @memberof WebGLRenderer
905
- * @function
906
874
  * @param {Polygon} poly the shape to draw
907
875
  */
908
876
  fillPolygon(poly) {
@@ -913,7 +881,6 @@ class WebGLRenderer extends Renderer {
913
881
  * Draw a stroke rectangle at the specified coordinates
914
882
  * @name strokeRect
915
883
  * @memberof WebGLRenderer
916
- * @function
917
884
  * @param {number} x
918
885
  * @param {number} y
919
886
  * @param {number} width
@@ -938,7 +905,6 @@ class WebGLRenderer extends Renderer {
938
905
  * Draw a filled rectangle at the specified coordinates
939
906
  * @name fillRect
940
907
  * @memberof WebGLRenderer
941
- * @function
942
908
  * @param {number} x
943
909
  * @param {number} y
944
910
  * @param {number} width
@@ -952,7 +918,6 @@ class WebGLRenderer extends Renderer {
952
918
  * Stroke a rounded rectangle at the specified coordinates
953
919
  * @name strokeRoundRect
954
920
  * @memberof WebGLRenderer
955
- * @function
956
921
  * @param {number} x
957
922
  * @param {number} y
958
923
  * @param {number} width
@@ -979,7 +944,6 @@ class WebGLRenderer extends Renderer {
979
944
  * Draw a rounded filled rectangle at the specified coordinates
980
945
  * @name fillRoundRect
981
946
  * @memberof WebGLRenderer
982
- * @function
983
947
  * @param {number} x
984
948
  * @param {number} y
985
949
  * @param {number} width
@@ -995,7 +959,6 @@ class WebGLRenderer extends Renderer {
995
959
  * identity one, and then apply the given transformation matrix.
996
960
  * @name setTransform
997
961
  * @memberof WebGLRenderer
998
- * @function
999
962
  * @param {Matrix2d} mat2d Matrix to transform by
1000
963
  */
1001
964
  setTransform(mat2d) {
@@ -1007,7 +970,6 @@ class WebGLRenderer extends Renderer {
1007
970
  * Multiply given matrix into the renderer tranformation matrix
1008
971
  * @name transform
1009
972
  * @memberof WebGLRenderer
1010
- * @function
1011
973
  * @param {Matrix2d} mat2d Matrix to transform by
1012
974
  */
1013
975
  transform(mat2d) {
@@ -1025,7 +987,6 @@ class WebGLRenderer extends Renderer {
1025
987
  * Translates the uniform matrix by the given coordinates
1026
988
  * @name translate
1027
989
  * @memberof WebGLRenderer
1028
- * @function
1029
990
  * @param {number} x
1030
991
  * @param {number} y
1031
992
  */
@@ -1048,7 +1009,6 @@ class WebGLRenderer extends Renderer {
1048
1009
  * (<u>this is an experimental feature !</u>)
1049
1010
  * @name clipRect
1050
1011
  * @memberof WebGLRenderer
1051
- * @function
1052
1012
  * @param {number} x
1053
1013
  * @param {number} y
1054
1014
  * @param {number} width
@@ -1096,7 +1056,6 @@ class WebGLRenderer extends Renderer {
1096
1056
  * Mask are not preserved through renderer context save and restore.
1097
1057
  * @name setMask
1098
1058
  * @memberof WebGLRenderer
1099
- * @function
1100
1059
  * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] a shape defining the mask to be applied
1101
1060
  * @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
1102
1061
  */
@@ -1143,7 +1102,6 @@ class WebGLRenderer extends Renderer {
1143
1102
  * @name clearMask
1144
1103
  * @see WebGLRenderer#setMask
1145
1104
  * @memberof WebGLRenderer
1146
- * @function
1147
1105
  */
1148
1106
  clearMask() {
1149
1107
  if (this.maskLevel > 0) {