melonjs 14.4.0 → 15.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 (245) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +13 -57
  3. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/arraymultimap.js +1 -1
  5. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  6. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  7. package/dist/melonjs.mjs/_virtual/index.js +1 -1
  8. package/dist/melonjs.mjs/_virtual/index2.js +1 -1
  9. package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
  10. package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
  11. package/dist/melonjs.mjs/application/application.js +1 -1
  12. package/dist/melonjs.mjs/application/header.js +1 -1
  13. package/dist/melonjs.mjs/application/resize.js +1 -1
  14. package/dist/melonjs.mjs/application/settings.js +1 -1
  15. package/dist/melonjs.mjs/audio/audio.js +5 -7
  16. package/dist/melonjs.mjs/camera/camera2d.js +1 -1
  17. package/dist/melonjs.mjs/const.js +1 -1
  18. package/dist/melonjs.mjs/entity/entity.js +43 -9
  19. package/dist/melonjs.mjs/geometries/ellipse.js +2 -3
  20. package/dist/melonjs.mjs/geometries/line.js +1 -1
  21. package/dist/melonjs.mjs/geometries/path2d.js +20 -44
  22. package/dist/melonjs.mjs/geometries/point.js +1 -6
  23. package/dist/melonjs.mjs/geometries/poly.js +2 -5
  24. package/dist/melonjs.mjs/geometries/rectangle.js +13 -9
  25. package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
  26. package/dist/melonjs.mjs/index.js +10 -6
  27. package/dist/melonjs.mjs/input/gamepad.js +10 -16
  28. package/dist/melonjs.mjs/input/input.js +1 -1
  29. package/dist/melonjs.mjs/input/keyboard.js +1 -1
  30. package/dist/melonjs.mjs/input/pointer.js +1 -1
  31. package/dist/melonjs.mjs/input/pointerevent.js +3 -17
  32. package/dist/melonjs.mjs/lang/console.js +1 -1
  33. package/dist/melonjs.mjs/lang/deprecated.js +1 -1
  34. package/dist/melonjs.mjs/level/level.js +3 -3
  35. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
  36. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +1 -8
  37. package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
  38. package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
  39. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +8 -4
  40. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +5 -5
  41. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
  42. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +1 -1
  43. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  44. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  45. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  46. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  47. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
  48. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  49. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  50. package/dist/melonjs.mjs/loader/cache.js +24 -0
  51. package/dist/melonjs.mjs/loader/loader.js +331 -716
  52. package/dist/melonjs.mjs/loader/loadingscreen.js +4 -4
  53. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  54. package/dist/melonjs.mjs/loader/parser.js +281 -0
  55. package/dist/melonjs.mjs/loader/settings.js +91 -0
  56. package/dist/melonjs.mjs/math/color.js +9 -8
  57. package/dist/melonjs.mjs/math/math.js +1 -1
  58. package/dist/melonjs.mjs/math/matrix2.js +7 -9
  59. package/dist/melonjs.mjs/math/matrix3.js +18 -21
  60. package/dist/melonjs.mjs/math/observable_vector2.js +3 -3
  61. package/dist/melonjs.mjs/math/observable_vector3.js +3 -4
  62. package/dist/melonjs.mjs/math/vector2.js +3 -3
  63. package/dist/melonjs.mjs/math/vector3.js +3 -4
  64. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +1 -1
  65. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
  66. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +1 -1
  67. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +1 -1
  68. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  69. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
  70. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  71. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  72. package/dist/melonjs.mjs/particles/emitter.js +3 -3
  73. package/dist/melonjs.mjs/particles/particle.js +1 -1
  74. package/dist/melonjs.mjs/particles/settings.js +1 -1
  75. package/dist/melonjs.mjs/physics/body.js +18 -14
  76. package/dist/melonjs.mjs/physics/bounds.js +18 -70
  77. package/dist/melonjs.mjs/physics/collision.js +1 -1
  78. package/dist/melonjs.mjs/physics/detector.js +1 -1
  79. package/dist/melonjs.mjs/physics/quadtree.js +1 -1
  80. package/dist/melonjs.mjs/physics/response.js +1 -1
  81. package/dist/melonjs.mjs/physics/sat.js +1 -1
  82. package/dist/melonjs.mjs/physics/world.js +1 -1
  83. package/dist/melonjs.mjs/plugin/plugin.js +3 -3
  84. package/dist/melonjs.mjs/renderable/collectable.js +1 -1
  85. package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
  86. package/dist/melonjs.mjs/renderable/container.js +25 -19
  87. package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
  88. package/dist/melonjs.mjs/renderable/imagelayer.js +7 -1
  89. package/dist/melonjs.mjs/renderable/light2d.js +1 -1
  90. package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
  91. package/dist/melonjs.mjs/renderable/renderable.js +148 -105
  92. package/dist/melonjs.mjs/renderable/sprite.js +33 -54
  93. package/dist/melonjs.mjs/renderable/trigger.js +1 -1
  94. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
  95. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
  96. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -3
  97. package/dist/melonjs.mjs/state/stage.js +1 -1
  98. package/dist/melonjs.mjs/state/state.js +2 -2
  99. package/dist/melonjs.mjs/system/device.js +2 -2
  100. package/dist/melonjs.mjs/system/dom.js +1 -1
  101. package/dist/melonjs.mjs/system/event.js +1 -1
  102. package/dist/melonjs.mjs/system/platform.js +1 -1
  103. package/dist/melonjs.mjs/system/pooling.js +8 -18
  104. package/dist/melonjs.mjs/system/save.js +1 -1
  105. package/dist/melonjs.mjs/system/timer.js +1 -1
  106. package/dist/melonjs.mjs/text/bitmaptext.js +66 -8
  107. package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
  108. package/dist/melonjs.mjs/text/glyph.js +1 -1
  109. package/dist/melonjs.mjs/text/text.js +56 -86
  110. package/dist/melonjs.mjs/text/textmetrics.js +1 -1
  111. package/dist/melonjs.mjs/text/textstyle.js +4 -6
  112. package/dist/melonjs.mjs/tweens/easing.js +1 -1
  113. package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
  114. package/dist/melonjs.mjs/tweens/tween.js +1 -1
  115. package/dist/melonjs.mjs/utils/agent.js +1 -1
  116. package/dist/melonjs.mjs/utils/array.js +1 -1
  117. package/dist/melonjs.mjs/utils/file.js +1 -1
  118. package/dist/melonjs.mjs/utils/function.js +1 -1
  119. package/dist/melonjs.mjs/utils/string.js +2 -2
  120. package/dist/melonjs.mjs/utils/utils.js +2 -4
  121. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +7 -11
  122. package/dist/melonjs.mjs/video/renderer.js +2 -13
  123. package/dist/melonjs.mjs/video/texture/atlas.js +12 -17
  124. package/dist/melonjs.mjs/video/texture/cache.js +3 -3
  125. package/dist/melonjs.mjs/video/texture/canvas_texture.js +1 -1
  126. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  127. package/dist/melonjs.mjs/video/video.js +2 -2
  128. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +21 -17
  129. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +235 -0
  130. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +77 -0
  131. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +249 -0
  132. package/dist/melonjs.mjs/video/webgl/{webgl_compositor.js → compositors/webgl_compositor.js} +20 -205
  133. package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
  134. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  135. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +2 -2
  136. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  137. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +2 -2
  138. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
  139. package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
  140. package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
  141. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  142. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
  143. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +139 -149
  144. package/dist/melonjs.module.js +26320 -26376
  145. package/dist/types/entity/entity.d.ts +3 -3
  146. package/dist/types/geometries/path2d.d.ts +5 -31
  147. package/dist/types/geometries/point.d.ts +2 -7
  148. package/dist/types/geometries/poly.d.ts +0 -1
  149. package/dist/types/index.d.ts +5 -3
  150. package/dist/types/loader/cache.d.ts +7 -0
  151. package/dist/types/loader/loader.d.ts +166 -181
  152. package/dist/types/loader/parser.d.ts +41 -0
  153. package/dist/types/loader/settings.d.ts +57 -0
  154. package/dist/types/particles/emitter.d.ts +4 -4
  155. package/dist/types/physics/bounds.d.ts +29 -84
  156. package/dist/types/renderable/container.d.ts +0 -11
  157. package/dist/types/renderable/renderable.d.ts +43 -31
  158. package/dist/types/renderable/sprite.d.ts +3 -3
  159. package/dist/types/renderable/ui/uitextbutton.d.ts +0 -1
  160. package/dist/types/state/state.d.ts +1 -1
  161. package/dist/types/system/pooling.d.ts +2 -2
  162. package/dist/types/text/text.d.ts +6 -20
  163. package/dist/types/text/textstyle.d.ts +1 -1
  164. package/dist/types/video/canvas/canvas_renderer.d.ts +0 -5
  165. package/dist/types/video/renderer.d.ts +1 -5
  166. package/dist/types/video/webgl/buffer/vertex.d.ts +3 -3
  167. package/dist/types/video/webgl/compositors/compositor.d.ts +107 -0
  168. package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +22 -0
  169. package/dist/types/video/webgl/compositors/quad_compositor.d.ts +72 -0
  170. package/dist/types/video/webgl/compositors/webgl_compositor.d.ts +86 -0
  171. package/dist/types/video/webgl/webgl_compositor.d.ts +2 -3
  172. package/dist/types/video/webgl/webgl_renderer.d.ts +34 -28
  173. package/package.json +18 -18
  174. package/src/audio/audio.js +4 -6
  175. package/src/entity/entity.js +42 -8
  176. package/src/geometries/ellipse.js +1 -2
  177. package/src/geometries/path2d.js +19 -43
  178. package/src/geometries/point.js +0 -5
  179. package/src/geometries/poly.js +1 -4
  180. package/src/geometries/rectangle.js +12 -8
  181. package/src/index.js +7 -3
  182. package/src/input/gamepad.js +9 -15
  183. package/src/input/pointerevent.js +1 -15
  184. package/src/level/level.js +2 -2
  185. package/src/level/tiled/TMXLayer.js +0 -7
  186. package/src/level/tiled/TMXTileMap.js +7 -3
  187. package/src/level/tiled/TMXTileset.js +4 -4
  188. package/src/loader/cache.js +16 -0
  189. package/src/loader/loader.js +339 -711
  190. package/src/loader/loadingscreen.js +3 -3
  191. package/src/loader/parser.js +279 -0
  192. package/src/loader/settings.js +85 -0
  193. package/src/math/color.js +8 -7
  194. package/src/math/matrix2.js +6 -8
  195. package/src/math/matrix3.js +17 -20
  196. package/src/math/observable_vector2.js +2 -2
  197. package/src/math/observable_vector3.js +2 -3
  198. package/src/math/vector2.js +2 -2
  199. package/src/math/vector3.js +2 -3
  200. package/src/particles/emitter.js +2 -2
  201. package/src/physics/body.js +17 -13
  202. package/src/physics/bounds.js +17 -69
  203. package/src/polyfill/index.js +0 -2
  204. package/src/renderable/container.js +24 -18
  205. package/src/renderable/imagelayer.js +6 -0
  206. package/src/renderable/renderable.js +147 -104
  207. package/src/renderable/sprite.js +32 -53
  208. package/src/renderable/ui/uitextbutton.js +0 -2
  209. package/src/state/state.js +1 -1
  210. package/src/system/device.js +1 -1
  211. package/src/system/pooling.js +7 -17
  212. package/src/text/bitmaptext.js +65 -7
  213. package/src/text/text.js +55 -85
  214. package/src/text/textstyle.js +3 -5
  215. package/src/utils/string.js +1 -1
  216. package/src/utils/utils.js +1 -3
  217. package/src/video/canvas/canvas_renderer.js +5 -9
  218. package/src/video/renderer.js +0 -11
  219. package/src/video/texture/atlas.js +11 -16
  220. package/src/video/texture/cache.js +2 -2
  221. package/src/video/video.js +1 -1
  222. package/src/video/webgl/buffer/vertex.js +20 -16
  223. package/src/video/webgl/compositors/compositor.js +226 -0
  224. package/src/video/webgl/compositors/primitive_compositor.js +68 -0
  225. package/src/video/webgl/compositors/quad_compositor.js +240 -0
  226. package/src/video/webgl/shaders/primitive.vert +2 -5
  227. package/src/video/webgl/shaders/quad.vert +3 -1
  228. package/src/video/webgl/webgl_renderer.js +137 -147
  229. package/dist/melonjs.mjs/_virtual/make-built-in.js +0 -10
  230. package/dist/melonjs.mjs/_virtual/object-define-property.js +0 -10
  231. package/dist/melonjs.mjs/_virtual/object-get-own-property-descriptor.js +0 -10
  232. package/dist/melonjs.mjs/_virtual/object-get-own-property-names.js +0 -10
  233. package/dist/melonjs.mjs/_virtual/object-get-own-property-symbols.js +0 -10
  234. package/dist/melonjs.mjs/_virtual/object-property-is-enumerable.js +0 -10
  235. package/dist/melonjs.mjs/_virtual/shared.js +0 -10
  236. package/dist/melonjs.mjs/game.js +0 -29
  237. package/dist/melonjs.mjs/polyfill/console.js +0 -18
  238. package/dist/melonjs.mjs/polyfill/performance.js +0 -27
  239. package/dist/melonjs.mjs/polyfill/requestAnimationFrame.js +0 -46
  240. package/dist/melonjs.mjs/polyfill/roundrect.js +0 -242
  241. package/dist/melonjs.mjs/renderable/re_container.js +0 -1016
  242. package/dist/melonjs.mjs/video/utils/resize.js +0 -116
  243. package/src/polyfill/performance.js +0 -20
  244. package/src/polyfill/requestAnimationFrame.js +0 -39
  245. package/src/video/webgl/webgl_compositor.js +0 -486
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -107,7 +107,7 @@ const pointerEvent = !!globalThis.PointerEvent;
107
107
  * @readonly
108
108
  * @public
109
109
  */
110
- const touch = touchEvent || pointerEvent;
110
+ const touch = touchEvent || (pointerEvent && globalThis.navigator.maxTouchPoints > 0);
111
111
 
112
112
  /**
113
113
  * the maximum number of simultaneous touch contact points are supported by the current device.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -35,14 +35,14 @@ class ObjectPool {
35
35
  * @param {boolean} [recycling=false] - enables object recycling for the specified class
36
36
  * @example
37
37
  * // implement CherryEntity
38
- * class CherryEntity extends Spritesheet {
38
+ * class Cherry extends Sprite {
39
39
  * onResetEvent() {
40
40
  * // reset object mutable properties
41
41
  * this.lifeBar = 100;
42
42
  * }
43
43
  * };
44
44
  * // add our users defined entities in the object pool and enable object recycling
45
- * me.pool.register("cherryentity", CherryEntity, true);
45
+ * me.pool.register("cherrysprite", Cherry, true);
46
46
  */
47
47
  register(className, classObj, recycling = false) {
48
48
  if (typeof (classObj) !== "undefined") {
@@ -76,11 +76,7 @@ class ObjectPool {
76
76
  * me.game.world.removeChild(enemy);
77
77
  * me.game.world.removeChild(bullet);
78
78
  */
79
- pull(name) {
80
- var args = new Array(arguments.length);
81
- for (var i = 0; i < arguments.length; i++) {
82
- args[i] = arguments[i];
83
- }
79
+ pull(name, ...args) {
84
80
  var className = this.objectClass[name];
85
81
  if (className) {
86
82
  var proto = className["class"],
@@ -88,18 +84,12 @@ class ObjectPool {
88
84
  obj;
89
85
 
90
86
  if (poolArray && ((obj = poolArray.pop()))) {
91
- // pull an existing instance from the pool
92
- args.shift();
93
- // call the object onResetEvent function if defined
94
- if (typeof(obj.onResetEvent) === "function") {
95
- obj.onResetEvent.apply(obj, args);
96
- }
87
+ // poolable object must implement a `onResetEvent` method
88
+ obj.onResetEvent.apply(obj, args);
97
89
  this.instance_counter--;
98
- }
99
- else {
90
+ } else {
100
91
  // create a new instance
101
- args[0] = proto;
102
- obj = new (proto.bind.apply(proto, args))();
92
+ obj = new (proto.bind.apply(proto, [ proto, ...args ]))();
103
93
  if (poolArray) {
104
94
  obj.className = name;
105
95
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import Color from '../math/color.js';
9
9
  import pool from '../system/pooling.js';
10
- import loader from '../loader/loader.js';
10
+ import { getImage, getBinary } from '../loader/loader.js';
11
11
  import Renderable from '../renderable/renderable.js';
12
12
  import TextMetrics from './textmetrics.js';
13
13
 
@@ -102,7 +102,7 @@ import TextMetrics from './textmetrics.js';
102
102
  * font image
103
103
  * @private
104
104
  */
105
- this.fontImage = (typeof settings.font === "object") ? settings.font : loader.getImage(settings.font);
105
+ this.fontImage = (typeof settings.font === "object") ? settings.font : getImage(settings.font);
106
106
 
107
107
  if (typeof settings.fontData !== "string") {
108
108
  /**
@@ -110,11 +110,11 @@ import TextMetrics from './textmetrics.js';
110
110
  * @private
111
111
  */
112
112
  // use settings.font to retreive the data from the loader
113
- this.fontData = pool.pull("BitmapTextData", loader.getBinary(settings.font));
113
+ this.fontData = pool.pull("BitmapTextData", getBinary(settings.font));
114
114
  } else {
115
115
  this.fontData = pool.pull("BitmapTextData",
116
116
  // if starting/includes "info face" the whole data string was passed as parameter
117
- (settings.fontData.includes("info face")) ? settings.fontData : loader.getBinary(settings.fontData)
117
+ (settings.fontData.includes("info face")) ? settings.fontData : getBinary(settings.fontData)
118
118
  );
119
119
  }
120
120
 
@@ -183,11 +183,70 @@ import TextMetrics from './textmetrics.js';
183
183
  this._text = this.metrics.wordWrap(this._text, this.wordWrapWidth);
184
184
  }
185
185
 
186
- this.getBounds().addBounds(this.metrics.measureText(this._text), true);
186
+ this.updateBounds();
187
187
 
188
188
  return this;
189
189
  }
190
190
 
191
+ /**
192
+ * update the bounding box for this Bitmap Text.
193
+ * @param {boolean} [absolute=true] - update the bounds size and position in (world) absolute coordinates
194
+ * @returns {Bounds} this Bitmap Text bounding box Rectangle object
195
+ */
196
+ updateBounds(absolute = true) {
197
+ var bounds = this.getBounds();
198
+
199
+ bounds.clear();
200
+
201
+ if (typeof this.metrics !== "undefined") {
202
+ var ax, ay;
203
+
204
+ bounds.addBounds(this.metrics.measureText(this._text));
205
+
206
+ switch (this.textAlign) {
207
+ case "right":
208
+ ax = this.metrics.width * 1.0;
209
+ break;
210
+
211
+ case "center":
212
+ ax = this.metrics.width * 0.5;
213
+ break;
214
+
215
+ default :
216
+ ax = this.metrics.width * 0.0;
217
+ break;
218
+ }
219
+
220
+ // adjust y pos based on alignment value
221
+ switch (this.textBaseline) {
222
+ case "middle":
223
+ ay = this.metrics.height * 0.5;
224
+ break;
225
+
226
+ case "ideographic":
227
+ case "alphabetic":
228
+ case "bottom":
229
+ ay = this.metrics.height * 1.0;
230
+ break;
231
+
232
+ default :
233
+ ay = this.metrics.height * 0.0;
234
+ break;
235
+ }
236
+
237
+ // translate the bounds accordingly
238
+ bounds.translate(ax, ay);
239
+ }
240
+
241
+ if (absolute === true) {
242
+ if (typeof this.ancestor !== "undefined" && typeof this.ancestor.addChild === "function" && this.floating !== true) {
243
+ bounds.translate(this.ancestor.getAbsolutePosition());
244
+ }
245
+ }
246
+
247
+ return bounds;
248
+ }
249
+
191
250
  /**
192
251
  * defines the color used to tint the bitmap text
193
252
  * @public
@@ -214,9 +273,8 @@ import TextMetrics from './textmetrics.js';
214
273
  resize(scale) {
215
274
  this.fontScale.set(scale, scale);
216
275
 
217
- this.getBounds().addBounds(this.metrics.measureText(this._text), true);
276
+ this.updateBounds();
218
277
 
219
- // clear the cache text to recalculate bounds
220
278
  this.isDirty = true;
221
279
 
222
280
  return this;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,12 +1,11 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
6
6
  * @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
7
7
  */
8
8
  import Color from '../math/color.js';
9
- import WebGLRenderer from '../video/webgl/webgl_renderer.js';
10
9
  import { renderer } from '../video/video.js';
11
10
  import pool from '../system/pooling.js';
12
11
  import Renderable from '../renderable/renderable.js';
@@ -26,18 +25,6 @@ import TextMetrics from './textmetrics.js';
26
25
  const runits = ["ex", "em", "pt", "px"];
27
26
  const toPX = [12, 24, 0.75, 1];
28
27
 
29
- // return a valid 2d context for Text rendering/styling
30
- var getContext2d = function (renderer$1, text) {
31
- if (text.offScreenCanvas === true) {
32
- return text.canvasTexture.context;
33
- } else {
34
- if (typeof renderer$1 === "undefined") {
35
- renderer$1 = renderer;
36
- }
37
- return renderer$1.getFontContext();
38
- }
39
- };
40
-
41
28
  /**
42
29
  * @classdesc
43
30
  * a generic system font object.
@@ -52,12 +39,11 @@ var getContext2d = function (renderer$1, text) {
52
39
  * @param {number|string} settings.size - size, or size + suffix (px, em, pt)
53
40
  * @param {Color|string} [settings.fillStyle="#000000"] - a CSS color value
54
41
  * @param {Color|string} [settings.strokeStyle="#000000"] - a CSS color value
55
- * @param {number} [settings.lineWidth=1] - line width, in pixels, when drawing stroke
42
+ * @param {number} [settings.lineWidth=0] - line width, in pixels, when drawing stroke
56
43
  * @param {string} [settings.textAlign="left"] - horizontal text alignment
57
44
  * @param {string} [settings.textBaseline="top"] - the text baseline
58
45
  * @param {number} [settings.lineHeight=1.0] - line spacing height
59
46
  * @param {Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] - anchor point to draw the text at
60
- * @param {boolean} [settings.offScreenCanvas=false] - whether to draw the font to an individual "cache" texture first
61
47
  * @param {number} [settings.wordWrapWidth] - the maximum length in CSS pixel for a single segment of text
62
48
  * @param {(string|string[])} [settings.text=""] - a string, or an array of strings
63
49
  * @example
@@ -112,9 +98,9 @@ var getContext2d = function (renderer$1, text) {
112
98
  * sets the current line width, in pixels, when drawing stroke
113
99
  * @public
114
100
  * @type {number}
115
- * @default 1
101
+ * @default 0
116
102
  */
117
- this.lineWidth = settings.lineWidth || 1;
103
+ this.lineWidth = settings.lineWidth || 0;
118
104
 
119
105
  /**
120
106
  * Set the default text alignment (or justification),<br>
@@ -143,16 +129,6 @@ var getContext2d = function (renderer$1, text) {
143
129
  */
144
130
  this.lineHeight = settings.lineHeight || 1.0;
145
131
 
146
- /**
147
- * whether to draw the font to a indidividual offscreen canvas texture first <br>
148
- * Note: this will improve performances when using WebGL, but will impact
149
- * memory consumption as every text element will have its own canvas texture
150
- * @public
151
- * @type {boolean}
152
- * @default false
153
- */
154
- this.offScreenCanvas = false;
155
-
156
132
  /**
157
133
  * the maximum length in CSS pixel for a single segment of text.
158
134
  * (use -1 to disable word wrapping)
@@ -199,10 +175,8 @@ var getContext2d = function (renderer$1, text) {
199
175
  this.italic();
200
176
  }
201
177
 
202
- if (settings.offScreenCanvas === true) {
203
- this.offScreenCanvas = true;
204
- this.canvasTexture = pool.pull("CanvasTexture", 2, 2, { offscreenCanvas: true });
205
- }
178
+ // the canvas Texture used to render this text
179
+ this.canvasTexture = pool.pull("CanvasTexture", 2, 2, { offscreenCanvas: true });
206
180
 
207
181
  // instance to text metrics functions
208
182
  this.metrics = new TextMetrics(this);
@@ -291,38 +265,38 @@ var getContext2d = function (renderer$1, text) {
291
265
 
292
266
  // word wrap if necessary
293
267
  if (this._text.length > 0 && this.wordWrapWidth > 0) {
294
- this._text = this.metrics.wordWrap(this._text, this.wordWrapWidth, getContext2d(renderer, this));
268
+ this._text = this.metrics.wordWrap(this._text, this.wordWrapWidth, this.canvasTexture.context);
295
269
  }
296
270
 
297
271
  // calculcate the text size and update the bounds accordingly
298
- bounds.addBounds(this.metrics.measureText(this._text, getContext2d(renderer, this)), true);
272
+ bounds.addBounds(this.metrics.measureText(this._text, this.canvasTexture.context), true);
299
273
 
300
274
  // update the offScreenCanvas texture if required
301
- if (this.offScreenCanvas === true) {
302
- var width = Math.ceil(this.metrics.width),
303
- height = Math.ceil(this.metrics.height);
304
-
305
- if (renderer instanceof WebGLRenderer) {
306
- // invalidate the previous corresponding texture so that it can reuploaded once changed
307
- this.glTextureUnit = renderer.cache.getUnit(renderer.cache.get(this.canvasTexture.canvas));
308
- renderer.currentCompositor.unbindTexture2D(null, this.glTextureUnit);
309
-
310
- if (renderer.WebGLVersion === 1) {
311
- // round size to next Pow2
312
- width = nextPowerOfTwo(this.metrics.width);
313
- height = nextPowerOfTwo(this.metrics.height);
314
- }
315
- }
316
-
317
- // resize the cache canvas if necessary
318
- if (this.canvasTexture.width < width || this.canvasTexture.height < height) {
319
- this.canvasTexture.resize(width, height);
275
+ var width = Math.ceil(this.metrics.width),
276
+ height = Math.ceil(this.metrics.height);
277
+
278
+ if (typeof renderer.gl !== "undefined") {
279
+ // make sure the right compositor is active
280
+ renderer.setCompositor("quad");
281
+ // invalidate the previous corresponding texture so that it can reuploaded once changed
282
+ this.glTextureUnit = renderer.cache.getUnit(renderer.cache.get(this.canvasTexture.canvas));
283
+ renderer.currentCompositor.unbindTexture2D(null, this.glTextureUnit);
284
+
285
+ if (renderer.WebGLVersion === 1) {
286
+ // round size to next Pow2
287
+ width = nextPowerOfTwo(this.metrics.width);
288
+ height = nextPowerOfTwo(this.metrics.height);
320
289
  }
290
+ }
321
291
 
322
- this.canvasTexture.clear();
323
- this._drawFont(this.canvasTexture.context, this._text, this.pos.x - this.metrics.x, this.pos.y - this.metrics.y, false);
292
+ // resize the cache canvas if necessary
293
+ if (this.canvasTexture.width < width || this.canvasTexture.height < height) {
294
+ this.canvasTexture.resize(width, height);
324
295
  }
325
296
 
297
+ this.canvasTexture.clear();
298
+ this._drawFont(this.canvasTexture.context, this._text, this.pos.x - this.metrics.x, this.pos.y - this.metrics.y);
299
+
326
300
  this.isDirty = true;
327
301
 
328
302
  return this;
@@ -335,7 +309,7 @@ var getContext2d = function (renderer$1, text) {
335
309
  * @returns {TextMetrics} a TextMetrics object defining the dimensions of the given piece of text
336
310
  */
337
311
  measureText(renderer, text = this._text) {
338
- return this.metrics.measureText(text, getContext2d(renderer, this));
312
+ return this.metrics.measureText(text, this.canvasTexture.context);
339
313
  }
340
314
 
341
315
 
@@ -345,9 +319,8 @@ var getContext2d = function (renderer$1, text) {
345
319
  * @param {string} [text]
346
320
  * @param {number} [x]
347
321
  * @param {number} [y]
348
- * @param {boolean} [stroke=false] - draw stroke the the text if true
349
322
  */
350
- draw(renderer, text, x = this.pos.x, y = this.pos.y, stroke = false) {
323
+ draw(renderer, text, x = this.pos.x, y = this.pos.y) {
351
324
  // "hacky patch" for backward compatibilty
352
325
  if (typeof this.ancestor === "undefined") {
353
326
 
@@ -361,21 +334,18 @@ var getContext2d = function (renderer$1, text) {
361
334
  // update text cache
362
335
  this.setText(text);
363
336
 
364
- x = this.metrics.x;
365
- y = this.metrics.y;
366
-
367
337
  // save the previous context
368
338
  renderer.save();
369
339
 
370
340
  // apply the defined alpha value
371
341
  renderer.setGlobalAlpha(renderer.globalAlpha() * this.getOpacity());
372
342
 
373
- } else {
374
- // added directly to an object container
375
- x = this.pos.x;
376
- y = this.pos.y;
377
343
  }
378
344
 
345
+ // adjust x,y position based on the bounding box
346
+ x = this.metrics.x;
347
+ y = this.metrics.y;
348
+
379
349
  // clamp to pixel grid if required
380
350
  if (renderer.settings.subPixel === false) {
381
351
  x = ~~x;
@@ -383,12 +353,7 @@ var getContext2d = function (renderer$1, text) {
383
353
  }
384
354
 
385
355
  // draw the text
386
- if (this.offScreenCanvas === true) {
387
- renderer.drawImage(this.canvasTexture.canvas, x, y);
388
- } else {
389
- renderer.drawFont(this._drawFont(renderer.getFontContext(), this._text, x, y, stroke));
390
- }
391
-
356
+ renderer.drawImage(this.canvasTexture.canvas, x, y);
392
357
 
393
358
  // for backward compatibilty
394
359
  if (typeof this.ancestor === "undefined") {
@@ -398,28 +363,33 @@ var getContext2d = function (renderer$1, text) {
398
363
  }
399
364
 
400
365
  /**
401
- * draw a stroke text at the specified coord, as defined <br>
402
- * by the `lineWidth` and `fillStroke` properties. <br>
403
- * Note : using drawStroke is not recommended for performance reasons
366
+ * draw a stroke text at the specified coord, as defined by the `lineWidth` and `fillStroke` properties.
367
+ * @deprecated since 15.0.0
404
368
  * @param {CanvasRenderer|WebGLRenderer} renderer - Reference to the destination renderer instance
405
369
  * @param {string} text
406
370
  * @param {number} x
407
371
  * @param {number} y
408
372
  */
409
373
  drawStroke(renderer, text, x, y) {
410
- this.draw(renderer, text, x, y, true);
374
+ this.draw(renderer, text, x, y);
411
375
  }
412
376
 
413
377
  /**
414
378
  * @ignore
415
379
  */
416
- _drawFont(context, text, x, y, stroke = false) {
417
- setContextStyle(context, this, stroke);
380
+ _drawFont(context, text, x, y) {
381
+ setContextStyle(context, this);
418
382
 
419
383
  for (var i = 0; i < text.length; i++) {
420
384
  var string = text[i].trimEnd();
421
385
  // draw the string
422
- context[stroke ? "strokeText" : "fillText"](string, x, y);
386
+ if (this.fillStyle.alpha > 0) {
387
+ context.fillText(string, x, y);
388
+ }
389
+ // stroke the text
390
+ if (this.lineWidth > 0 && this.strokeStyle.alpha > 0) {
391
+ context.strokeText(string, x, y);
392
+ }
423
393
  // add leading space
424
394
  y += this.metrics.lineHeight();
425
395
  }
@@ -431,15 +401,15 @@ var getContext2d = function (renderer$1, text) {
431
401
  * @ignore
432
402
  */
433
403
  destroy() {
434
- if (this.offScreenCanvas === true) {
435
- if (renderer instanceof WebGLRenderer) {
436
- renderer.currentCompositor.deleteTexture2D(renderer.currentCompositor.getTexture2D(this.glTextureUnit));
437
- this.glTextureUnit = undefined;
438
- }
439
- renderer.cache.delete(this.canvasTexture.canvas);
440
- pool.push(this.canvasTexture);
441
- this.canvasTexture = undefined;
404
+ if (typeof renderer.gl !== "undefined") {
405
+ // make sure the right compositor is active
406
+ renderer.setCompositor("quad");
407
+ renderer.currentCompositor.deleteTexture2D(renderer.currentCompositor.getTexture2D(this.glTextureUnit));
408
+ this.glTextureUnit = undefined;
442
409
  }
410
+ renderer.cache.delete(this.canvasTexture.canvas);
411
+ pool.push(this.canvasTexture);
412
+ this.canvasTexture = undefined;
443
413
  pool.push(this.fillStyle);
444
414
  pool.push(this.strokeStyle);
445
415
  this.fillStyle = this.strokeStyle = undefined;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -9,13 +9,11 @@
9
9
  * apply the current text style to the given context
10
10
  * @ignore
11
11
  */
12
- function setContextStyle(context, style, stroke = false) {
12
+ function setContextStyle(context, style) {
13
13
  context.font = style.font;
14
14
  context.fillStyle = style.fillStyle.toRGBA();
15
- if (stroke === true) {
16
- context.strokeStyle = style.strokeStyle.toRGBA();
17
- context.lineWidth = style.lineWidth;
18
- }
15
+ context.strokeStyle = style.strokeStyle.toRGBA();
16
+ context.lineWidth = style.lineWidth;
19
17
  context.textAlign = style.textAlign;
20
18
  context.textBaseline = style.textBaseline;
21
19
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -34,7 +34,7 @@ function isNumeric(str) {
34
34
  if (typeof str === "string") {
35
35
  str = str.trim();
36
36
  }
37
- return !isNaN(str) && /[+-]?([0-9]*[.])?[0-9]+/.test(str);
37
+ return !isNaN(str) && /^[+-]?(\d+(\.\d+)?|\.\d+)$/.test(str);
38
38
  }
39
39
 
40
40
  /**
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.4.0
2
+ * melonJS Game Engine - v15.0.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -107,9 +107,7 @@ var utils = {
107
107
  }
108
108
 
109
109
  // parse the url
110
- url.slice(1).split("&").filter((value) => {
111
- return (value !== "");
112
- }).forEach((value) => {
110
+ url.slice(1).split("&").filter((value) => value !== "").forEach((value) => {
113
111
  var kv = value.split("=");
114
112
  var k = kv.shift();
115
113
  var v = kv.join("=");