melonjs 14.1.2 → 14.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 (381) hide show
  1. package/README.md +3 -4
  2. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  3. package/dist/melonjs.mjs/_virtual/arraymultimap.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/earcut.js +7 -3
  5. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  6. package/dist/melonjs.mjs/_virtual/index.js +1 -1
  7. package/dist/melonjs.mjs/_virtual/index2.js +7 -3
  8. package/dist/melonjs.mjs/_virtual/make-built-in.js +10 -0
  9. package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
  10. package/dist/melonjs.mjs/_virtual/object-define-property.js +10 -0
  11. package/dist/melonjs.mjs/_virtual/object-get-own-property-descriptor.js +10 -0
  12. package/dist/melonjs.mjs/_virtual/object-get-own-property-names.js +10 -0
  13. package/dist/melonjs.mjs/_virtual/object-get-own-property-symbols.js +10 -0
  14. package/dist/melonjs.mjs/_virtual/object-property-is-enumerable.js +10 -0
  15. package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
  16. package/dist/melonjs.mjs/_virtual/shared.js +10 -0
  17. package/dist/melonjs.mjs/application/application.js +173 -22
  18. package/dist/melonjs.mjs/application/header.js +34 -0
  19. package/dist/melonjs.mjs/application/resize.js +119 -0
  20. package/dist/melonjs.mjs/application/settings.js +28 -0
  21. package/dist/melonjs.mjs/audio/audio.js +1 -1
  22. package/dist/melonjs.mjs/camera/camera2d.js +2 -2
  23. package/dist/melonjs.mjs/entity/entity.js +1 -1
  24. package/dist/melonjs.mjs/game.js +1 -1
  25. package/dist/melonjs.mjs/geometries/ellipse.js +1 -1
  26. package/dist/melonjs.mjs/geometries/line.js +1 -1
  27. package/dist/melonjs.mjs/geometries/path2d.js +3 -3
  28. package/dist/melonjs.mjs/geometries/point.js +1 -1
  29. package/dist/melonjs.mjs/geometries/poly.js +3 -3
  30. package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
  31. package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
  32. package/dist/melonjs.mjs/index.js +41 -61
  33. package/dist/melonjs.mjs/input/gamepad.js +1 -1
  34. package/dist/melonjs.mjs/input/input.js +1 -1
  35. package/dist/melonjs.mjs/input/keyboard.js +1 -1
  36. package/dist/melonjs.mjs/input/pointer.js +2 -2
  37. package/dist/melonjs.mjs/input/pointerevent.js +7 -8
  38. package/dist/melonjs.mjs/lang/deprecated.js +1 -1
  39. package/dist/melonjs.mjs/level/level.js +2 -2
  40. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
  41. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +2 -2
  42. package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
  43. package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
  44. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +2 -2
  45. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +1 -1
  46. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
  47. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +1 -1
  48. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  49. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  50. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  51. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
  52. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  53. package/dist/melonjs.mjs/loader/loader.js +1 -1
  54. package/dist/melonjs.mjs/loader/loadingscreen.js +2 -2
  55. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  56. package/dist/melonjs.mjs/math/color.js +1 -1
  57. package/dist/melonjs.mjs/math/math.js +1 -1
  58. package/dist/melonjs.mjs/math/matrix2.js +1 -1
  59. package/dist/melonjs.mjs/math/matrix3.js +1 -1
  60. package/dist/melonjs.mjs/math/observable_vector2.js +1 -1
  61. package/dist/melonjs.mjs/math/observable_vector3.js +1 -1
  62. package/dist/melonjs.mjs/math/vector2.js +1 -1
  63. package/dist/melonjs.mjs/math/vector3.js +1 -1
  64. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +3 -2
  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 +3 -2
  67. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +3 -2
  68. package/dist/melonjs.mjs/node_modules/core-js/es/string/trim-end.js +13 -0
  69. package/dist/melonjs.mjs/node_modules/core-js/es/string/trim-start.js +13 -0
  70. package/dist/melonjs.mjs/node_modules/core-js/internals/a-callable.js +22 -0
  71. package/dist/melonjs.mjs/node_modules/core-js/internals/an-object.js +21 -0
  72. package/dist/melonjs.mjs/node_modules/core-js/internals/array-includes.js +45 -0
  73. package/dist/melonjs.mjs/node_modules/core-js/internals/classof-raw.js +19 -0
  74. package/dist/melonjs.mjs/node_modules/core-js/internals/classof.js +43 -0
  75. package/dist/melonjs.mjs/node_modules/core-js/internals/copy-constructor-properties.js +32 -0
  76. package/dist/melonjs.mjs/node_modules/core-js/internals/create-non-enumerable-property.js +24 -0
  77. package/dist/melonjs.mjs/node_modules/core-js/internals/create-property-descriptor.js +17 -0
  78. package/dist/melonjs.mjs/node_modules/core-js/internals/define-built-in.js +43 -0
  79. package/dist/melonjs.mjs/node_modules/core-js/internals/define-global-property.js +23 -0
  80. package/dist/melonjs.mjs/node_modules/core-js/internals/descriptors.js +18 -0
  81. package/dist/melonjs.mjs/node_modules/core-js/internals/document-all.js +18 -0
  82. package/dist/melonjs.mjs/node_modules/core-js/internals/document-create-element.js +22 -0
  83. package/dist/melonjs.mjs/node_modules/core-js/internals/engine-user-agent.js +14 -0
  84. package/dist/melonjs.mjs/node_modules/core-js/internals/engine-v8-version.js +39 -0
  85. package/dist/melonjs.mjs/node_modules/core-js/internals/entry-unbind.js +18 -0
  86. package/dist/melonjs.mjs/node_modules/core-js/internals/enum-bug-keys.js +19 -0
  87. package/dist/melonjs.mjs/node_modules/core-js/internals/export.js +72 -0
  88. package/dist/melonjs.mjs/node_modules/core-js/internals/fails.js +16 -0
  89. package/dist/melonjs.mjs/node_modules/core-js/internals/function-bind-native.js +19 -0
  90. package/dist/melonjs.mjs/node_modules/core-js/internals/function-call.js +18 -0
  91. package/dist/melonjs.mjs/node_modules/core-js/internals/function-name.js +29 -0
  92. package/dist/melonjs.mjs/node_modules/core-js/internals/function-uncurry-this.js +22 -0
  93. package/dist/melonjs.mjs/node_modules/core-js/internals/get-built-in.js +22 -0
  94. package/dist/melonjs.mjs/node_modules/core-js/internals/get-method.js +21 -0
  95. package/dist/melonjs.mjs/node_modules/core-js/internals/global.js +25 -0
  96. package/dist/melonjs.mjs/node_modules/core-js/internals/has-own-property.js +23 -0
  97. package/dist/melonjs.mjs/node_modules/core-js/internals/hidden-keys.js +10 -0
  98. package/dist/melonjs.mjs/node_modules/core-js/internals/ie8-dom-define.js +24 -0
  99. package/dist/melonjs.mjs/node_modules/core-js/internals/indexed-object.js +28 -0
  100. package/dist/melonjs.mjs/node_modules/core-js/internals/inspect-source.js +27 -0
  101. package/dist/melonjs.mjs/node_modules/core-js/internals/internal-state.js +88 -0
  102. package/dist/melonjs.mjs/node_modules/core-js/internals/is-callable.js +22 -0
  103. package/dist/melonjs.mjs/node_modules/core-js/internals/is-forced.js +34 -0
  104. package/dist/melonjs.mjs/node_modules/core-js/internals/is-null-or-undefined.js +14 -0
  105. package/dist/melonjs.mjs/node_modules/core-js/internals/is-object.js +22 -0
  106. package/dist/melonjs.mjs/node_modules/core-js/internals/is-symbol.js +27 -0
  107. package/dist/melonjs.mjs/node_modules/core-js/internals/length-of-array-like.js +18 -0
  108. package/dist/melonjs.mjs/node_modules/core-js/internals/make-built-in.js +68 -0
  109. package/dist/melonjs.mjs/node_modules/core-js/internals/math-trunc.js +19 -0
  110. package/dist/melonjs.mjs/node_modules/core-js/internals/object-define-property.js +58 -0
  111. package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-descriptor.js +41 -0
  112. package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-names.js +23 -0
  113. package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-symbols.js +12 -0
  114. package/dist/melonjs.mjs/node_modules/core-js/internals/object-is-prototype-of.js +14 -0
  115. package/dist/melonjs.mjs/node_modules/core-js/internals/object-keys-internal.js +35 -0
  116. package/dist/melonjs.mjs/node_modules/core-js/internals/object-property-is-enumerable.js +23 -0
  117. package/dist/melonjs.mjs/node_modules/core-js/internals/ordinary-to-primitive.js +28 -0
  118. package/dist/melonjs.mjs/node_modules/core-js/internals/own-keys.js +31 -0
  119. package/dist/melonjs.mjs/node_modules/core-js/internals/require-object-coercible.js +21 -0
  120. package/dist/melonjs.mjs/node_modules/core-js/internals/shared-key.js +21 -0
  121. package/dist/melonjs.mjs/node_modules/core-js/internals/shared-store.js +19 -0
  122. package/dist/melonjs.mjs/node_modules/core-js/internals/shared.js +24 -0
  123. package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-end.js +22 -0
  124. package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-forced.js +28 -0
  125. package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-start.js +22 -0
  126. package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim.js +45 -0
  127. package/dist/melonjs.mjs/node_modules/core-js/internals/symbol-constructor-detection.js +26 -0
  128. package/dist/melonjs.mjs/node_modules/core-js/internals/to-absolute-index.js +23 -0
  129. package/dist/melonjs.mjs/node_modules/core-js/internals/to-indexed-object.js +19 -0
  130. package/dist/melonjs.mjs/node_modules/core-js/internals/to-integer-or-infinity.js +20 -0
  131. package/dist/melonjs.mjs/node_modules/core-js/internals/to-length.js +20 -0
  132. package/dist/melonjs.mjs/node_modules/core-js/internals/to-object.js +20 -0
  133. package/dist/melonjs.mjs/node_modules/core-js/internals/to-primitive.js +41 -0
  134. package/dist/melonjs.mjs/node_modules/core-js/internals/to-property-key.js +21 -0
  135. package/dist/melonjs.mjs/node_modules/core-js/internals/to-string-tag-support.js +19 -0
  136. package/dist/melonjs.mjs/node_modules/core-js/internals/to-string.js +19 -0
  137. package/dist/melonjs.mjs/node_modules/core-js/internals/try-to-string.js +18 -0
  138. package/dist/melonjs.mjs/node_modules/core-js/internals/uid.js +20 -0
  139. package/dist/melonjs.mjs/node_modules/core-js/internals/use-symbol-as-uid.js +18 -0
  140. package/dist/melonjs.mjs/node_modules/core-js/internals/v8-prototype-define-bug.js +24 -0
  141. package/dist/melonjs.mjs/node_modules/core-js/internals/weak-map-basic-detection.js +18 -0
  142. package/dist/melonjs.mjs/node_modules/core-js/internals/well-known-symbol.js +41 -0
  143. package/dist/melonjs.mjs/node_modules/core-js/internals/whitespaces.js +12 -0
  144. package/dist/melonjs.mjs/node_modules/core-js/modules/es.global-this.js +18 -0
  145. package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-end.js +22 -0
  146. package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-left.js +19 -0
  147. package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-right.js +19 -0
  148. package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-start.js +22 -0
  149. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +4 -5
  150. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +3 -3
  151. package/dist/melonjs.mjs/node_modules/eventemitter3/index.mjs.js +9 -0
  152. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +5 -2
  153. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +3 -2
  154. package/dist/melonjs.mjs/particles/emitter.js +1 -1
  155. package/dist/melonjs.mjs/particles/particle.js +1 -1
  156. package/dist/melonjs.mjs/particles/settings.js +1 -1
  157. package/dist/melonjs.mjs/physics/body.js +1 -1
  158. package/dist/melonjs.mjs/physics/bounds.js +1 -1
  159. package/dist/melonjs.mjs/physics/collision.js +3 -3
  160. package/dist/melonjs.mjs/physics/detector.js +174 -146
  161. package/dist/melonjs.mjs/physics/quadtree.js +1 -1
  162. package/dist/melonjs.mjs/physics/response.js +1 -1
  163. package/dist/melonjs.mjs/physics/sat.js +1 -1
  164. package/dist/melonjs.mjs/physics/world.js +10 -30
  165. package/dist/melonjs.mjs/plugin/plugin.js +4 -4
  166. package/dist/melonjs.mjs/polyfill/console.js +18 -0
  167. package/dist/melonjs.mjs/polyfill/performance.js +27 -0
  168. package/dist/melonjs.mjs/polyfill/requestAnimationFrame.js +46 -0
  169. package/dist/melonjs.mjs/polyfill/roundrect.js +242 -0
  170. package/dist/melonjs.mjs/renderable/collectable.js +1 -1
  171. package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
  172. package/dist/melonjs.mjs/renderable/container.js +3 -87
  173. package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
  174. package/dist/melonjs.mjs/renderable/imagelayer.js +2 -2
  175. package/dist/melonjs.mjs/renderable/light2d.js +1 -1
  176. package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
  177. package/dist/melonjs.mjs/renderable/re_container.js +1016 -0
  178. package/dist/melonjs.mjs/renderable/renderable.js +1 -1
  179. package/dist/melonjs.mjs/renderable/sprite.js +1 -1
  180. package/dist/melonjs.mjs/renderable/trigger.js +2 -2
  181. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
  182. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
  183. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
  184. package/dist/melonjs.mjs/state/stage.js +2 -2
  185. package/dist/melonjs.mjs/state/state.js +2 -2
  186. package/dist/melonjs.mjs/system/device.js +9 -29
  187. package/dist/melonjs.mjs/system/dom.js +3 -2
  188. package/dist/melonjs.mjs/system/event.js +1 -1
  189. package/dist/melonjs.mjs/system/platform.js +1 -1
  190. package/dist/melonjs.mjs/system/pooling.js +1 -1
  191. package/dist/melonjs.mjs/system/save.js +1 -1
  192. package/dist/melonjs.mjs/system/timer.js +1 -1
  193. package/dist/melonjs.mjs/text/bitmaptext.js +1 -1
  194. package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
  195. package/dist/melonjs.mjs/text/glyph.js +1 -1
  196. package/dist/melonjs.mjs/text/text.js +1 -1
  197. package/dist/melonjs.mjs/text/textmetrics.js +1 -1
  198. package/dist/melonjs.mjs/text/textstyle.js +1 -1
  199. package/dist/melonjs.mjs/tweens/easing.js +1 -1
  200. package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
  201. package/dist/melonjs.mjs/tweens/tween.js +2 -2
  202. package/dist/melonjs.mjs/utils/agent.js +1 -1
  203. package/dist/melonjs.mjs/utils/array.js +1 -1
  204. package/dist/melonjs.mjs/utils/file.js +1 -1
  205. package/dist/melonjs.mjs/utils/function.js +1 -1
  206. package/dist/melonjs.mjs/utils/string.js +1 -1
  207. package/dist/melonjs.mjs/utils/utils.js +4 -29
  208. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +4 -1
  209. package/dist/melonjs.mjs/video/renderer.js +26 -6
  210. package/dist/melonjs.mjs/video/texture/atlas.js +1 -1
  211. package/dist/melonjs.mjs/video/texture/cache.js +1 -1
  212. package/dist/melonjs.mjs/video/texture/canvas_texture.js +21 -1
  213. package/dist/melonjs.mjs/video/utils/autodetect.js +27 -0
  214. package/dist/melonjs.mjs/video/utils/resize.js +116 -0
  215. package/dist/melonjs.mjs/video/video.js +20 -294
  216. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
  217. package/dist/melonjs.mjs/video/webgl/glshader.js +2 -3
  218. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  219. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
  220. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  221. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
  222. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
  223. package/dist/melonjs.mjs/video/webgl/utils/precision.js +20 -2
  224. package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
  225. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  226. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
  227. package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +1 -1
  228. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +4 -1
  229. package/dist/melonjs.module.js +28551 -26959
  230. package/dist/types/application/application.d.ts +144 -0
  231. package/dist/types/application/header.d.ts +5 -0
  232. package/dist/types/application/resize.d.ts +5 -0
  233. package/dist/types/application/settings.d.ts +18 -0
  234. package/dist/types/audio/audio.d.ts +267 -0
  235. package/dist/types/camera/camera2d.d.ts +289 -0
  236. package/dist/types/entity/entity.d.ts +98 -0
  237. package/{src/game.js → dist/types/game.d.ts} +3 -14
  238. package/dist/types/geometries/ellipse.d.ts +154 -0
  239. package/dist/types/geometries/line.d.ts +11 -0
  240. package/dist/types/geometries/path2d.d.ts +121 -0
  241. package/dist/types/geometries/point.d.ts +53 -0
  242. package/dist/types/geometries/poly.d.ts +222 -0
  243. package/dist/types/geometries/rectangle.d.ts +176 -0
  244. package/dist/types/geometries/roundrect.d.ts +52 -0
  245. package/dist/types/index.d.ts +3 -2
  246. package/dist/types/input/gamepad.d.ts +95 -0
  247. package/dist/types/input/input.d.ts +15 -0
  248. package/dist/types/input/keyboard.d.ts +205 -0
  249. package/dist/types/input/pointer.d.ts +270 -0
  250. package/dist/types/input/pointerevent.d.ts +181 -0
  251. package/dist/types/lang/deprecated.d.ts +53 -0
  252. package/dist/types/level/level.d.ts +134 -0
  253. package/dist/types/level/tiled/TMXGroup.d.ts +82 -0
  254. package/dist/types/level/tiled/TMXLayer.d.ts +180 -0
  255. package/dist/types/level/tiled/TMXObject.d.ts +195 -0
  256. package/dist/types/level/tiled/TMXTile.d.ts +78 -0
  257. package/dist/types/level/tiled/TMXTileMap.d.ts +180 -0
  258. package/dist/types/level/tiled/TMXTileset.d.ts +94 -0
  259. package/dist/types/level/tiled/TMXTilesetGroup.d.ts +32 -0
  260. package/dist/types/level/tiled/TMXUtils.d.ts +47 -0
  261. package/dist/types/level/tiled/renderer/TMXHexagonalRenderer.d.ts +87 -0
  262. package/dist/types/level/tiled/renderer/TMXIsometricRenderer.d.ts +55 -0
  263. package/dist/types/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +43 -0
  264. package/dist/types/level/tiled/renderer/TMXRenderer.d.ts +75 -0
  265. package/dist/types/level/tiled/renderer/TMXStaggeredRenderer.d.ts +8 -0
  266. package/dist/types/loader/loader.d.ts +181 -0
  267. package/dist/types/loader/loadingscreen.d.ts +18 -0
  268. package/dist/types/math/color.d.ts +170 -0
  269. package/dist/types/math/math.d.ts +165 -0
  270. package/dist/types/math/matrix2.d.ts +209 -0
  271. package/dist/types/math/matrix3.d.ts +236 -0
  272. package/dist/types/math/observable_vector2.d.ts +278 -0
  273. package/dist/types/math/observable_vector3.d.ts +277 -0
  274. package/dist/types/math/vector2.d.ts +327 -0
  275. package/dist/types/math/vector3.d.ts +332 -0
  276. package/dist/types/particles/emitter.d.ts +188 -0
  277. package/dist/types/particles/particle.d.ts +32 -0
  278. package/dist/types/particles/settings.d.ts +32 -0
  279. package/dist/types/physics/body.d.ts +330 -0
  280. package/dist/types/physics/bounds.d.ts +250 -0
  281. package/dist/types/physics/collision.d.ts +44 -0
  282. package/dist/types/physics/detector.d.ts +64 -0
  283. package/dist/types/physics/quadtree.d.ts +79 -0
  284. package/dist/types/physics/response.d.ts +37 -0
  285. package/dist/types/physics/sat.d.ts +48 -0
  286. package/dist/types/physics/world.d.ts +83 -0
  287. package/dist/types/plugin/plugin.d.ts +10 -0
  288. package/dist/types/polyfill/console.d.ts +0 -0
  289. package/dist/types/polyfill/index.d.ts +1 -0
  290. package/dist/types/polyfill/performance.d.ts +0 -0
  291. package/dist/types/polyfill/requestAnimationFrame.d.ts +1 -0
  292. package/dist/types/polyfill/roundrect.d.ts +0 -0
  293. package/dist/types/renderable/collectable.d.ts +19 -0
  294. package/dist/types/renderable/colorlayer.d.ts +28 -0
  295. package/dist/types/renderable/container.d.ts +302 -0
  296. package/dist/types/renderable/dragndrop.d.ts +118 -0
  297. package/dist/types/renderable/imagelayer.d.ts +106 -0
  298. package/dist/types/renderable/light2d.d.ts +58 -0
  299. package/dist/types/renderable/nineslicesprite.d.ts +59 -0
  300. package/dist/types/renderable/renderable.d.ts +402 -0
  301. package/dist/types/renderable/sprite.d.ts +268 -0
  302. package/dist/types/renderable/trigger.d.ts +61 -0
  303. package/dist/types/renderable/ui/uibaseelement.d.ts +95 -0
  304. package/dist/types/renderable/ui/uispriteelement.d.ts +127 -0
  305. package/dist/types/renderable/ui/uitextbutton.d.ts +54 -0
  306. package/dist/types/state/stage.d.ts +116 -0
  307. package/dist/types/state/state.d.ts +170 -0
  308. package/dist/types/system/device.d.ts +579 -0
  309. package/dist/types/system/dom.d.ts +1 -0
  310. package/dist/types/system/event.d.ts +473 -0
  311. package/dist/types/system/platform.d.ts +31 -0
  312. package/dist/types/system/pooling.d.ts +101 -0
  313. package/dist/types/system/save.d.ts +25 -0
  314. package/dist/types/system/timer.d.ts +126 -0
  315. package/dist/types/text/bitmaptext.d.ts +151 -0
  316. package/dist/types/text/bitmaptextdata.d.ts +35 -0
  317. package/dist/types/text/glyph.d.ts +28 -0
  318. package/dist/types/text/text.d.ts +173 -0
  319. package/dist/types/text/textmetrics.d.ts +47 -0
  320. package/dist/types/text/textstyle.d.ts +5 -0
  321. package/dist/types/tweens/easing.d.ts +46 -0
  322. package/dist/types/tweens/interpolation.d.ts +18 -0
  323. package/dist/types/tweens/tween.d.ts +195 -0
  324. package/dist/types/utils/agent.d.ts +21 -0
  325. package/dist/types/utils/array.d.ts +39 -0
  326. package/dist/types/utils/file.d.ts +18 -0
  327. package/dist/types/utils/function.d.ts +32 -0
  328. package/dist/types/utils/string.d.ts +50 -0
  329. package/dist/types/utils/utils.d.ts +17 -0
  330. package/dist/types/video/canvas/canvas_renderer.d.ts +380 -0
  331. package/dist/types/video/renderer.d.ts +222 -0
  332. package/dist/types/video/texture/atlas.d.ts +201 -0
  333. package/dist/types/video/texture/cache.d.ts +45 -0
  334. package/dist/types/video/texture/canvas_texture.d.ts +78 -0
  335. package/dist/types/video/utils/autodetect.d.ts +7 -0
  336. package/dist/types/video/utils/resize.d.ts +4 -0
  337. package/dist/types/video/video.d.ts +92 -0
  338. package/dist/types/video/webgl/buffer/vertex.d.ts +56 -0
  339. package/dist/types/video/webgl/glshader.d.ts +93 -0
  340. package/dist/types/video/webgl/utils/attributes.d.ts +4 -0
  341. package/dist/types/video/webgl/utils/precision.d.ts +13 -0
  342. package/dist/types/video/webgl/utils/program.d.ts +5 -0
  343. package/dist/types/video/webgl/utils/string.d.ts +5 -0
  344. package/dist/types/video/webgl/utils/uniforms.d.ts +4 -0
  345. package/dist/types/video/webgl/webgl_compositor.d.ts +174 -0
  346. package/dist/types/video/webgl/webgl_renderer.d.ts +429 -0
  347. package/package.json +14 -14
  348. package/src/application/application.js +171 -20
  349. package/src/application/header.js +25 -0
  350. package/src/application/resize.js +110 -0
  351. package/src/application/settings.js +19 -0
  352. package/src/camera/camera2d.js +1 -1
  353. package/src/index.js +34 -23
  354. package/src/input/pointer.js +1 -1
  355. package/src/input/pointerevent.js +6 -7
  356. package/src/level/level.js +1 -1
  357. package/src/level/tiled/TMXLayer.js +1 -1
  358. package/src/level/tiled/TMXTileMap.js +2 -2
  359. package/src/loader/loadingscreen.js +1 -1
  360. package/src/physics/collision.js +2 -2
  361. package/src/physics/detector.js +172 -145
  362. package/src/physics/world.js +10 -30
  363. package/src/plugin/plugin.js +1 -1
  364. package/src/renderable/container.js +7 -91
  365. package/src/renderable/imagelayer.js +1 -1
  366. package/src/renderable/trigger.js +1 -1
  367. package/src/renderable/ui/uibaseelement.js +1 -1
  368. package/src/state/stage.js +1 -1
  369. package/src/state/state.js +1 -1
  370. package/src/system/device.js +7 -27
  371. package/src/system/dom.js +2 -1
  372. package/src/tweens/tween.js +1 -1
  373. package/src/utils/utils.js +3 -28
  374. package/src/video/canvas/canvas_renderer.js +3 -0
  375. package/src/video/renderer.js +27 -7
  376. package/src/video/texture/canvas_texture.js +20 -0
  377. package/src/video/utils/autodetect.js +18 -0
  378. package/src/video/video.js +17 -291
  379. package/src/video/webgl/glshader.js +3 -4
  380. package/src/video/webgl/utils/precision.js +18 -0
  381. package/src/video/webgl/webgl_renderer.js +3 -0
@@ -1,10 +1,10 @@
1
- import utils from "./../utils/utils.js";
2
- import game from "./../game.js";
3
- import * as event from "./../system/event.js";
4
- import pool from "./../system/pooling.js";
5
- import state from "./../state/state.js";
6
- import Renderable from "./renderable.js";
7
- import Body from "./../physics/body.js";
1
+ import Renderable from "./renderable";
2
+ import utils from "../utils/utils.js";
3
+ import { game } from "../index.js";
4
+ import * as event from "../system/event.js";
5
+ import pool from "../system/pooling.js";
6
+ import state from "../state/state.js";
7
+ import Body from "../physics/body.js";
8
8
 
9
9
  /**
10
10
  * Private function to re-use for object removal in a defer
@@ -45,11 +45,8 @@ let globalFloatingCounter = 0;
45
45
 
46
46
  /**
47
47
  * whether the container is the root of the scene
48
- * @public
49
48
  * @type {boolean}
50
49
  * @default false
51
- * @name root
52
- * @memberof Container
53
50
  */
54
51
  this.root = root;
55
52
 
@@ -62,48 +59,34 @@ let globalFloatingCounter = 0;
62
59
  /**
63
60
  * The property of the child object that should be used to sort on <br>
64
61
  * value : "x", "y", "z"
65
- * @public
66
62
  * @type {string}
67
63
  * @default me.game.sortOn
68
- * @name sortOn
69
- * @memberof Container
70
64
  */
71
65
  this.sortOn = game.sortOn;
72
66
 
73
67
  /**
74
68
  * Specify if the children list should be automatically sorted when adding a new child
75
- * @public
76
69
  * @type {boolean}
77
70
  * @default true
78
- * @name autoSort
79
- * @memberof Container
80
71
  */
81
72
  this.autoSort = true;
82
73
 
83
74
  /**
84
75
  * Specify if the children z index should automatically be managed by the parent container
85
- * @public
86
76
  * @type {boolean}
87
77
  * @default true
88
- * @name autoDepth
89
- * @memberof Container
90
78
  */
91
79
  this.autoDepth = true;
92
80
 
93
81
  /**
94
82
  * Specify if the container draw operation should clip his children to its own bounds
95
- * @public
96
83
  * @type {boolean}
97
84
  * @default false
98
- * @name clipping
99
- * @memberof Container
100
85
  */
101
86
  this.clipping = false;
102
87
 
103
88
  /**
104
89
  * a callback to be extended, triggered after a child has been added or removed
105
- * @name onChildChange
106
- * @memberof Container#
107
90
  * @param {number} index - added or removed child index
108
91
  */
109
92
  this.onChildChange = function (index) { // eslint-disable-line no-unused-vars
@@ -114,21 +97,15 @@ let globalFloatingCounter = 0;
114
97
  * Specify if the container bounds should automatically take in account
115
98
  * all child bounds when updated (this is expensive and disabled by default,
116
99
  * only enable if necessary)
117
- * @public
118
100
  * @type {boolean}
119
101
  * @default false
120
- * @name enableChildBoundsUpdate
121
- * @memberof Container
122
102
  */
123
103
  this.enableChildBoundsUpdate = false;
124
104
 
125
105
  /**
126
106
  * define a background color for this container
127
- * @public
128
107
  * @type {Color}
129
- * @name backgroundColor
130
108
  * @default (0, 0, 0, 0.0)
131
- * @memberof Container
132
109
  * @example
133
110
  * // add a red background color to this container
134
111
  * this.backgroundColor.setColor(255, 0, 0);
@@ -158,8 +135,6 @@ let globalFloatingCounter = 0;
158
135
 
159
136
  /**
160
137
  * reset the container, removing all childrens, and reseting transforms.
161
- * @name reset
162
- * @memberof Container
163
138
  */
164
139
  reset() {
165
140
  // cancel any sort operation
@@ -195,8 +170,6 @@ let globalFloatingCounter = 0;
195
170
  * will not be in any container. <br>
196
171
  * if the given child implements a onActivateEvent method, that method will be called
197
172
  * once the child is added to this container.
198
- * @name addChild
199
- * @memberof Container
200
173
  * @param {Renderable} child
201
174
  * @param {number} [z] - forces the z index of the child to the specified value
202
175
  * @returns {Renderable} the added child
@@ -258,8 +231,6 @@ let globalFloatingCounter = 0;
258
231
  /**
259
232
  * Add a child to the container at the specified index<br>
260
233
  * (the list won't be sorted after insertion)
261
- * @name addChildAt
262
- * @memberof Container
263
234
  * @param {Renderable} child
264
235
  * @param {number} index
265
236
  * @returns {Renderable} the added child
@@ -316,8 +287,6 @@ let globalFloatingCounter = 0;
316
287
  * - The current element being processed in the array <br>
317
288
  * - The index of element in the array. <br>
318
289
  * - The array forEach() was called upon. <br>
319
- * @name forEach
320
- * @memberof Container
321
290
  * @param {Function} callback - fnction to execute on each element
322
291
  * @param {object} [thisArg] - value to use as this(i.e reference Object) when executing callback.
323
292
  * @example
@@ -352,8 +321,6 @@ let globalFloatingCounter = 0;
352
321
 
353
322
  /**
354
323
  * Swaps the position (z-index) of 2 children
355
- * @name swapChildren
356
- * @memberof Container
357
324
  * @param {Renderable} child
358
325
  * @param {Renderable} child2
359
326
  */
@@ -379,8 +346,6 @@ let globalFloatingCounter = 0;
379
346
 
380
347
  /**
381
348
  * Returns the Child at the specified index
382
- * @name getChildAt
383
- * @memberof Container
384
349
  * @param {number} index
385
350
  * @returns {Renderable} the child at the specified index
386
351
  */
@@ -395,8 +360,6 @@ let globalFloatingCounter = 0;
395
360
 
396
361
  /**
397
362
  * Returns the index of the given Child
398
- * @name getChildIndex
399
- * @memberof Container
400
363
  * @param {Renderable} child
401
364
  * @returns {number} index
402
365
  */
@@ -406,8 +369,6 @@ let globalFloatingCounter = 0;
406
369
 
407
370
  /**
408
371
  * Returns the next child within the container or undefined if none
409
- * @name getNextChild
410
- * @memberof Container
411
372
  * @param {Renderable} child
412
373
  * @returns {Renderable} child
413
374
  */
@@ -421,8 +382,6 @@ let globalFloatingCounter = 0;
421
382
 
422
383
  /**
423
384
  * Returns true if contains the specified Child
424
- * @name hasChild
425
- * @memberof Container
426
385
  * @param {Renderable} child
427
386
  * @returns {boolean}
428
387
  */
@@ -434,9 +393,6 @@ let globalFloatingCounter = 0;
434
393
  * return the child corresponding to the given property and value.<br>
435
394
  * note : avoid calling this function every frame since
436
395
  * it parses the whole object tree each time
437
- * @name getChildByProp
438
- * @memberof Container
439
- * @public
440
396
  * @param {string} prop - Property name
441
397
  * @param {string|RegExp|number|boolean} value - Value of the property
442
398
  * @returns {Renderable[]} Array of childs
@@ -485,9 +441,6 @@ let globalFloatingCounter = 0;
485
441
 
486
442
  /**
487
443
  * returns the list of childs with the specified class type
488
- * @name getChildByType
489
- * @memberof Container
490
- * @public
491
444
  * @param {object} classType
492
445
  * @returns {Renderable[]} Array of children
493
446
  */
@@ -511,9 +464,6 @@ let globalFloatingCounter = 0;
511
464
  * as defined in Tiled (Name field of the Object Properties)<br>
512
465
  * note : avoid calling this function every frame since
513
466
  * it parses the whole object list each time
514
- * @name getChildByName
515
- * @memberof Container
516
- * @public
517
467
  * @param {string|RegExp|number|boolean} name - child name
518
468
  * @returns {Renderable[]} Array of children
519
469
  */
@@ -525,9 +475,6 @@ let globalFloatingCounter = 0;
525
475
  * return the child corresponding to the specified GUID<br>
526
476
  * note : avoid calling this function every frame since
527
477
  * it parses the whole object list each time
528
- * @name getChildByGUID
529
- * @memberof Container
530
- * @public
531
478
  * @param {string|RegExp|number|boolean} guid - child GUID
532
479
  * @returns {Renderable} corresponding child or null
533
480
  */
@@ -538,9 +485,6 @@ let globalFloatingCounter = 0;
538
485
 
539
486
  /**
540
487
  * return all child in this container
541
- * @name getChildren
542
- * @memberof Container
543
- * @public
544
488
  * @returns {Renderable[]} an array of renderable object
545
489
  */
546
490
  getChildren() {
@@ -553,8 +497,6 @@ let globalFloatingCounter = 0;
553
497
  /**
554
498
  * update the bounding box for this shape.
555
499
  * @ignore
556
- * @name updateBounds
557
- * @memberof Renderable
558
500
  * @returns {Bounds} this shape bounding box Rectangle object
559
501
  */
560
502
  updateBounds(forceUpdateChildBounds = false) {
@@ -581,8 +523,6 @@ let globalFloatingCounter = 0;
581
523
  /**
582
524
  * Checks if this container is root or if it's attached to the root container.
583
525
  * @private
584
- * @name isAttachedToRoot
585
- * @memberof Container
586
526
  * @returns {boolean}
587
527
  */
588
528
  isAttachedToRoot() {
@@ -603,8 +543,6 @@ let globalFloatingCounter = 0;
603
543
  /**
604
544
  * update the cointainer's bounding rect (private)
605
545
  * @ignore
606
- * @name updateBoundsPos
607
- * @memberof Container
608
546
  */
609
547
  updateBoundsPos(newX, newY) {
610
548
  // call the parent method
@@ -638,9 +576,6 @@ let globalFloatingCounter = 0;
638
576
  /**
639
577
  * Invokes the removeChildNow in a defer, to ensure the child is removed safely after the update & draw stack has completed. <br>
640
578
  * if the given child implements a onDeactivateEvent() method, that method will be called once the child is removed from this container.
641
- * @name removeChild
642
- * @memberof Container
643
- * @public
644
579
  * @param {Renderable} child
645
580
  * @param {boolean} [keepalive=false] - true to prevent calling child.destroy()
646
581
  */
@@ -657,8 +592,6 @@ let globalFloatingCounter = 0;
657
592
  * Removes (and optionally destroys) a child from the container.<br>
658
593
  * (removal is immediate and unconditional)<br>
659
594
  * Never use keepalive=true with objects from {@link pool}. Doing so will create a memory leak.
660
- * @name removeChildNow
661
- * @memberof Container
662
595
  * @param {Renderable} child
663
596
  * @param {boolean} [keepalive=False] - True to prevent calling child.destroy()
664
597
  */
@@ -709,8 +642,6 @@ let globalFloatingCounter = 0;
709
642
 
710
643
  /**
711
644
  * Automatically set the specified property of all childs to the given value
712
- * @name setChildsProperty
713
- * @memberof Container
714
645
  * @param {string} prop - property name
715
646
  * @param {object} value - property value
716
647
  * @param {boolean} [recursive=false] - recursively apply the value to child containers if true
@@ -726,8 +657,6 @@ let globalFloatingCounter = 0;
726
657
 
727
658
  /**
728
659
  * Move the child in the group one step forward (z depth).
729
- * @name moveUp
730
- * @memberof Container
731
660
  * @param {Renderable} child
732
661
  */
733
662
  moveUp(child) {
@@ -742,8 +671,6 @@ let globalFloatingCounter = 0;
742
671
 
743
672
  /**
744
673
  * Move the child in the group one step backward (z depth).
745
- * @name moveDown
746
- * @memberof Container
747
674
  * @param {Renderable} child
748
675
  */
749
676
  moveDown(child) {
@@ -758,8 +685,6 @@ let globalFloatingCounter = 0;
758
685
 
759
686
  /**
760
687
  * Move the specified child to the top(z depth).
761
- * @name moveToTop
762
- * @memberof Container
763
688
  * @param {Renderable} child
764
689
  */
765
690
  moveToTop(child) {
@@ -777,8 +702,6 @@ let globalFloatingCounter = 0;
777
702
 
778
703
  /**
779
704
  * Move the specified child the bottom (z depth).
780
- * @name moveToBottom
781
- * @memberof Container
782
705
  * @param {Renderable} child
783
706
  */
784
707
  moveToBottom(child) {
@@ -796,9 +719,6 @@ let globalFloatingCounter = 0;
796
719
 
797
720
  /**
798
721
  * Manually trigger the sort of all the childs in the container</p>
799
- * @name sort
800
- * @memberof Container
801
- * @public
802
722
  * @param {boolean} [recursive=false] - recursively sort all containers if true
803
723
  */
804
724
  sort(recursive) {
@@ -890,8 +810,6 @@ let globalFloatingCounter = 0;
890
810
  /**
891
811
  * container update function. <br>
892
812
  * automatically called by the game manager {@link game}
893
- * @name update
894
- * @memberof Container
895
813
  * @protected
896
814
  * @param {number} dt - time since the last update in milliseconds.
897
815
  * @returns {boolean} true if the Container is dirty
@@ -941,8 +859,6 @@ let globalFloatingCounter = 0;
941
859
 
942
860
  /**
943
861
  * draw this renderable (automatically called by melonJS)
944
- * @name draw
945
- * @memberof Container
946
862
  * @protected
947
863
  * @param {CanvasRenderer|WebGLRenderer} renderer - a renderer instance
948
864
  * @param {Camera2d} [viewport] - the viewport to (re)draw
@@ -1,7 +1,7 @@
1
1
  import { renderer } from "./../video/video.js";
2
2
  import * as event from "./../system/event.js";
3
3
  import pool from "./../system/pooling.js";
4
- import game from "./../game.js";
4
+ import { game } from "../index.js";
5
5
  import Sprite from "./sprite.js";
6
6
  import * as stringUtil from "./../utils/string.js";
7
7
 
@@ -2,7 +2,7 @@ import Renderable from "./renderable.js";
2
2
  import collision from "./../physics/collision.js";
3
3
  import Body from "./../physics/body.js";
4
4
  import level from "./../level/level.js";
5
- import game from "./../game.js";
5
+ import { game } from "../index.js";
6
6
  import pool from "./../system/pooling.js";
7
7
 
8
8
  /**
@@ -1,4 +1,4 @@
1
- import Container from "./../container.js";
1
+ import Container from "../container.js";
2
2
  import timer from "../../system/timer.js";
3
3
  import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js";
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { renderer } from "./../video/video.js";
2
- import game from "./../game.js";
2
+ import { game } from "../index.js";
3
3
  import Camera2d from "./../camera/camera2d.js";
4
4
  import Color from "./../math/color.js";
5
5
 
@@ -1,7 +1,7 @@
1
1
  import { pauseTrack, resumeTrack } from "./../audio/audio.js";
2
2
  import * as fctUtil from "./../utils/function.js";
3
3
  import * as event from "./../system/event.js";
4
- import game from "./../game.js";
4
+ import { game } from "../index.js";
5
5
  import * as device from "./../system/device.js";
6
6
  import Stage from "./../state/stage.js";
7
7
  import DefaultLoadingScreen from "./../loader/loadingscreen.js";
@@ -462,7 +462,7 @@ export function enableSwipe(enable) {
462
462
  */
463
463
  export function isFullscreen() {
464
464
  if (hasFullscreenSupport) {
465
- return !!(prefixed("fullscreenElement", document) || document.mozFullScreenElement);
465
+ return !!(prefixed("fullscreenElement", globalThis.document) || globalThis.document.mozFullScreenElement);
466
466
  } else {
467
467
  return false;
468
468
  }
@@ -473,7 +473,7 @@ export function isFullscreen() {
473
473
  * @function requestFullscreen
474
474
  * @memberof device
475
475
  * @public
476
- * @param {object} [element=default canvas object] - the element to be set in full-screen mode.
476
+ * @param {Element} [element] - the element to be set in full-screen mode.
477
477
  * @example
478
478
  * // add a keyboard shortcut to toggle Fullscreen mode on/off
479
479
  * me.input.bindKey(me.input.KEY.F, "toggleFullscreen");
@@ -502,7 +502,7 @@ export function requestFullscreen(element) {
502
502
  */
503
503
  export function exitFullscreen() {
504
504
  if (hasFullscreenSupport && isFullscreen()) {
505
- document.exitFullscreen();
505
+ globalThis.document.exitFullscreen();
506
506
  }
507
507
  }
508
508
 
@@ -655,7 +655,7 @@ export function getElement(element) {
655
655
 
656
656
  if (element !== "undefined") {
657
657
  if (typeof element === "string") {
658
- target = document.getElementById(element);
658
+ target = globalThis.document.getElementById(element);
659
659
  } else if (typeof element === "object" && element.nodeType === Node.ELEMENT_NODE) {
660
660
  target = element;
661
661
  }
@@ -664,7 +664,7 @@ export function getElement(element) {
664
664
  // fallback, if invalid target or non HTMLElement object
665
665
  if (!target) {
666
666
  //default to document.body
667
- target = document.body;
667
+ target = globalThis.document.body;
668
668
  }
669
669
 
670
670
  return target;
@@ -681,7 +681,7 @@ export function getElement(element) {
681
681
  * @returns {DOMRect} the size and position of the element relatively to the viewport
682
682
  */
683
683
  export function getElementBounds(element) {
684
- if (typeof element === "object" && element !== document.body && typeof element.getBoundingClientRect !== "undefined") {
684
+ if (typeof element === "object" && element !== globalThis.document.body && typeof element.getBoundingClientRect !== "undefined") {
685
685
  return element.getBoundingClientRect();
686
686
  } else {
687
687
  domRect.width = domRect.right = globalThis.innerWidth;
@@ -716,7 +716,7 @@ export function getParentBounds(element) {
716
716
  export function isWebGLSupported(options) {
717
717
  let _supported = false;
718
718
  try {
719
- let canvas = document.createElement("canvas");
719
+ let canvas = globalThis.document.createElement("canvas");
720
720
  let ctxOptions = {
721
721
  stencil: true,
722
722
  failIfMajorPerformanceCaveat: options.failIfMajorPerformanceCaveat
@@ -729,26 +729,6 @@ export function isWebGLSupported(options) {
729
729
  return _supported;
730
730
  }
731
731
 
732
- /**
733
- * return the highest precision format supported by this device for GL Shaders
734
- * @function getMaxShaderPrecision
735
- * @memberof device
736
- * @public
737
- * @param {WebGLRenderingContext} gl
738
- * @returns {boolean} "lowp", "mediump", or "highp"
739
- */
740
- export function getMaxShaderPrecision(gl) {
741
- if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&
742
- gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0) {
743
- return "highp";
744
- }
745
- if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 &&
746
- gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0) {
747
- return "mediump";
748
- }
749
- return "lowp";
750
- }
751
-
752
732
  /**
753
733
  * Makes a request to bring this device window to the front.
754
734
  * @function focus
package/src/system/dom.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as event from "./event.js";
2
+ import { nodeJS } from "./platform.js";
2
3
 
3
4
  // track if DOMContentLoaded was called already
4
5
  let readyBound = false;
@@ -51,7 +52,7 @@ export function DOMContentLoaded(fn) {
51
52
  // bind dom load event if not done yet
52
53
  if (!readyBound) {
53
54
  // directly call domReady if document is already "ready"
54
- if (((typeof process !== "undefined") && (process.release.name === "node")) || (typeof globalThis.document !== "undefined" && globalThis.document.readyState === "complete")) {
55
+ if (nodeJS === true || (typeof globalThis.document !== "undefined" && globalThis.document.readyState === "complete")) {
55
56
  // defer the fn call to ensure our script is fully loaded
56
57
  globalThis.setTimeout(_domReady, 0);
57
58
  }
@@ -1,6 +1,6 @@
1
1
  import timer from "./../system/timer.js";
2
2
  import * as event from "./../system/event.js";
3
- import game from "./../game.js";
3
+ import { game } from "../index.js";
4
4
  import { Easing } from "./easing.js";
5
5
  import { Interpolation } from "./interpolation.js";
6
6
 
@@ -3,9 +3,6 @@ import * as arrayUtils from "./array.js";
3
3
  import * as fileUtils from "./file.js";
4
4
  import * as stringUtils from "./string.js";
5
5
  import * as fnUtils from "./function.js";
6
- import { createCanvas } from "./../video/video.js";
7
- import CanvasRenderer from "./../video/canvas/canvas_renderer.js";
8
- import { version } from "./../index.js";
9
6
 
10
7
  /**
11
8
  * a collection of utility functions
@@ -24,35 +21,13 @@ var utils = {
24
21
  string : stringUtils,
25
22
  function : fnUtils,
26
23
 
27
- /**
28
- * Get image pixels
29
- * @public
30
- * @memberof utils
31
- * @name getPixels
32
- * @param {HTMLImageElement|HTMLCanvasElement} image - Image to read
33
- * @returns {ImageData} ImageData object
34
- */
35
- getPixels : function (image) {
36
- if (image instanceof HTMLImageElement) {
37
- var _context = CanvasRenderer.getContext2d(
38
- createCanvas(image.width, image.height)
39
- );
40
- _context.drawImage(image, 0, 0);
41
- return _context.getImageData(0, 0, image.width, image.height);
42
- }
43
- else {
44
- // canvas !
45
- return image.getContext("2d").getImageData(0, 0, image.width, image.height);
46
- }
47
- },
48
-
49
24
  /**
50
25
  * Compare two version strings
51
26
  * @public
52
27
  * @memberof utils
53
28
  * @name checkVersion
54
- * @param {string} first - First version string to compare
55
- * @param {string} [second=version] - Second version string to compare
29
+ * @param {string} first - Ffrst version string to compare
30
+ * @param {string} second - second version string to compare
56
31
  * @returns {number} comparison result <br>&lt; 0 : first &lt; second<br>
57
32
  * 0 : first == second<br>
58
33
  * &gt; 0 : first &gt; second
@@ -63,7 +38,7 @@ var utils = {
63
38
  * );
64
39
  * }
65
40
  */
66
- checkVersion : function (first, second = version) {
41
+ checkVersion : function (first, second) {
67
42
  var a = first.split(".");
68
43
  var b = second.split(".");
69
44
  var len = Math.min(a.length, b.length);
@@ -45,6 +45,9 @@ import * as event from "./../../system/event.js";
45
45
  this.uvOffset = 1;
46
46
  }
47
47
 
48
+ // set the renderer type
49
+ this.type = "CANVAS";
50
+
48
51
  // context lost & restore event for canvas
49
52
  this.getCanvas().addEventListener("contextlost", (e) => {
50
53
  e.preventDefault();
@@ -1,8 +1,8 @@
1
1
  import Color from "./../math/color.js";
2
2
  import Matrix3d from "./../math/matrix3.js";
3
- import { createCanvas, renderer } from "./video.js";
3
+ import { createCanvas } from "./video.js";
4
4
  import * as event from "./../system/event.js";
5
- import * as device from "./../system/device.js";
5
+ import { platform } from "../system/device.js";
6
6
  import { setPrefixed } from "./../utils/agent.js";
7
7
  import Rect from "./../geometries/rectangle.js";
8
8
  import RoundRect from "./../geometries/roundrect.js";
@@ -11,6 +11,7 @@ import Polygon from "./../geometries/poly.js";
11
11
  import Line from "./../geometries/line.js";
12
12
  import Bounds from "./../physics/bounds.js";
13
13
  import Path2D from "./../geometries/path2d.js";
14
+ import Vector2d from "../math/vector2.js";
14
15
  import Point from "../geometries/point.js";
15
16
 
16
17
  /**
@@ -41,6 +42,20 @@ import Point from "../geometries/point.js";
41
42
  */
42
43
  this.settings = options;
43
44
 
45
+ /**
46
+ * the requested video size ratio
47
+ * @public
48
+ * @type {Number}
49
+ */
50
+ this.designRatio = this.settings.width / this.settings.height;
51
+
52
+ /**
53
+ * the scaling ratio to be applied to the main canvas
54
+ * @type {Vector2d}
55
+ * @default <1,1>
56
+ */
57
+ this.scaleRatio = new Vector2d(this.settings.scale, this.settings.scale);
58
+
44
59
  /**
45
60
  * true if the current rendering context is valid
46
61
  * @default true
@@ -54,6 +69,13 @@ import Point from "../geometries/point.js";
54
69
  */
55
70
  this.path2D = new Path2D();
56
71
 
72
+ /**
73
+ * The renderer type : Canvas, WebGL, etc...
74
+ * (override this property with a specific value when implementing a custom renderer)
75
+ * @type {string}
76
+ */
77
+ this.type = "Generic";
78
+
57
79
  /**
58
80
  * @ignore
59
81
  */
@@ -70,7 +92,7 @@ import Point from "../geometries/point.js";
70
92
  this.currentBlendMode = "none";
71
93
 
72
94
  // create the main screen canvas
73
- if (device.platform.ejecta === true) {
95
+ if (platform.ejecta === true) {
74
96
  // a main canvas is already automatically created by Ejecta
75
97
  this.canvas = document.getElementById("canvas");
76
98
  } else if (typeof globalThis.canvas !== "undefined") {
@@ -94,9 +116,9 @@ import Point from "../geometries/point.js";
94
116
  // default uvOffset
95
117
  this.uvOffset = 0;
96
118
 
97
- // reset the instantiated renderer on game reset
119
+ // reset the renderer on game reset
98
120
  event.on(event.GAME_RESET, () => {
99
- renderer.reset();
121
+ this.reset();
100
122
  });
101
123
  }
102
124
 
@@ -323,8 +345,6 @@ import Point from "../geometries/point.js";
323
345
 
324
346
  /**
325
347
  * fill the given shape
326
- * @name fill
327
- * @memberof Renderer
328
348
  * @param {Rect|RoundRect|Polygon|Line|Ellipse} shape - a shape object to fill
329
349
  */
330
350
  fill(shape) {
@@ -1,5 +1,6 @@
1
1
  import { createCanvas } from "./../video.js";
2
2
  import { setPrefixed } from "./../../utils/agent.js";
3
+ import { clamp } from "../../math/math.js";
3
4
 
4
5
  // default canvas settings
5
6
  var defaultAttributes = {
@@ -97,6 +98,25 @@ class CanvasTexture {
97
98
  this.canvas.height = Math.round(height);
98
99
  }
99
100
 
101
+ /**
102
+ * Returns an ImageData object representing the underlying pixel data for a specified portion of this canvas texture.
103
+ * (Note: when using getImageData(), it is highly recommended to use the `willReadFrequently` attribute when creatimg the corresponding canvas texture)
104
+ * @param {number} x - The x-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
105
+ * @param {number} y - The y-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
106
+ * @param {number} width - The width of the rectangle from which the ImageData will be extracted. Positive values are to the right, and negative to the left
107
+ * @param {number} height - The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up
108
+ * @return {ImageData} The ImageData extracted from this CanvasTexture.
109
+ */
110
+ getImageData(x, y, width, height) {
111
+ // clamp values
112
+ x = clamp(Math.floor(x), 0, this.canvas.width - 1);
113
+ y = clamp(Math.floor(y), 0, this.canvas.height - 1);
114
+ width = clamp(width, 1, this.canvas.width - x);
115
+ height = clamp(height, 1, this.canvas.height - y);
116
+ // return imageData
117
+ return this.context.getImageData(x, y, width, height);
118
+ }
119
+
100
120
  /**
101
121
  * @ignore
102
122
  */