melonjs 17.1.0 → 17.2.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 (246) hide show
  1. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  2. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  3. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/index.js +1 -1
  5. package/dist/melonjs.mjs/_virtual/re.js +1 -1
  6. package/dist/melonjs.mjs/application/application.js +2 -2
  7. package/dist/melonjs.mjs/application/header.js +2 -2
  8. package/dist/melonjs.mjs/application/resize.js +1 -1
  9. package/dist/melonjs.mjs/application/settings.js +1 -1
  10. package/dist/melonjs.mjs/audio/audio.js +13 -9
  11. package/dist/melonjs.mjs/camera/camera2d.js +1 -1
  12. package/dist/melonjs.mjs/const.js +1 -1
  13. package/dist/melonjs.mjs/geometries/ellipse.js +1 -1
  14. package/dist/melonjs.mjs/geometries/line.js +1 -1
  15. package/dist/melonjs.mjs/geometries/path2d.js +17 -17
  16. package/dist/melonjs.mjs/geometries/point.js +1 -1
  17. package/dist/melonjs.mjs/geometries/poly.js +1 -1
  18. package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
  19. package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
  20. package/dist/melonjs.mjs/geometries/toarccanvas.js +4 -6
  21. package/dist/melonjs.mjs/index.js +4 -4
  22. package/dist/melonjs.mjs/input/gamepad.js +1 -1
  23. package/dist/melonjs.mjs/input/input.js +1 -1
  24. package/dist/melonjs.mjs/input/keyboard.js +1 -1
  25. package/dist/melonjs.mjs/input/pointer.js +1 -1
  26. package/dist/melonjs.mjs/input/pointerevent.js +1 -1
  27. package/dist/melonjs.mjs/lang/console.js +1 -1
  28. package/dist/melonjs.mjs/lang/deprecated.js +1 -1
  29. package/dist/melonjs.mjs/level/level.js +1 -1
  30. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
  31. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +1 -1
  32. package/dist/melonjs.mjs/level/tiled/TMXObject.js +2 -2
  33. package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
  34. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +2 -2
  35. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +1 -1
  36. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
  37. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +3 -3
  38. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  39. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +5 -5
  40. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  41. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +3 -3
  42. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
  43. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  44. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  45. package/dist/melonjs.mjs/loader/cache.js +5 -2
  46. package/dist/melonjs.mjs/loader/loader.js +34 -5
  47. package/dist/melonjs.mjs/loader/loadingscreen.js +2 -4
  48. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  49. package/dist/melonjs.mjs/loader/parsers/binary.js +1 -1
  50. package/dist/melonjs.mjs/loader/parsers/compressed_textures/compressed_image.js +1 -1
  51. package/dist/melonjs.mjs/loader/parsers/compressed_textures/parseDDS.js +1 -1
  52. package/dist/melonjs.mjs/loader/parsers/compressed_textures/parseKTX.js +1 -1
  53. package/dist/melonjs.mjs/loader/parsers/compressed_textures/parseKTX2.js +1 -1
  54. package/dist/melonjs.mjs/loader/parsers/compressed_textures/parsePKM.js +1 -1
  55. package/dist/melonjs.mjs/loader/parsers/compressed_textures/parsePVR.js +1 -1
  56. package/dist/melonjs.mjs/loader/parsers/fetchdata.js +1 -1
  57. package/dist/melonjs.mjs/loader/parsers/fontface.js +25 -15
  58. package/dist/melonjs.mjs/loader/parsers/image.js +3 -3
  59. package/dist/melonjs.mjs/loader/parsers/json.js +1 -1
  60. package/dist/melonjs.mjs/loader/parsers/script.js +1 -1
  61. package/dist/melonjs.mjs/loader/parsers/tmx.js +1 -1
  62. package/dist/melonjs.mjs/loader/parsers/video.js +1 -1
  63. package/dist/melonjs.mjs/math/color.js +6 -6
  64. package/dist/melonjs.mjs/math/math.js +1 -1
  65. package/dist/melonjs.mjs/math/matrix2.js +7 -7
  66. package/dist/melonjs.mjs/math/matrix3.js +2 -2
  67. package/dist/melonjs.mjs/math/observable_vector2.js +3 -3
  68. package/dist/melonjs.mjs/math/observable_vector3.js +4 -4
  69. package/dist/melonjs.mjs/math/vector2.js +3 -3
  70. package/dist/melonjs.mjs/math/vector3.js +4 -4
  71. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
  72. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
  73. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  74. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
  75. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  76. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  77. package/dist/melonjs.mjs/node_modules/semver/classes/comparator.js +1 -1
  78. package/dist/melonjs.mjs/node_modules/semver/classes/range.js +1 -1
  79. package/dist/melonjs.mjs/node_modules/semver/classes/semver.js +1 -1
  80. package/dist/melonjs.mjs/node_modules/semver/functions/clean.js +1 -1
  81. package/dist/melonjs.mjs/node_modules/semver/functions/cmp.js +1 -1
  82. package/dist/melonjs.mjs/node_modules/semver/functions/coerce.js +1 -1
  83. package/dist/melonjs.mjs/node_modules/semver/functions/compare-build.js +1 -1
  84. package/dist/melonjs.mjs/node_modules/semver/functions/compare-loose.js +1 -1
  85. package/dist/melonjs.mjs/node_modules/semver/functions/compare.js +1 -1
  86. package/dist/melonjs.mjs/node_modules/semver/functions/diff.js +1 -1
  87. package/dist/melonjs.mjs/node_modules/semver/functions/eq.js +1 -1
  88. package/dist/melonjs.mjs/node_modules/semver/functions/gt.js +1 -1
  89. package/dist/melonjs.mjs/node_modules/semver/functions/gte.js +1 -1
  90. package/dist/melonjs.mjs/node_modules/semver/functions/inc.js +1 -1
  91. package/dist/melonjs.mjs/node_modules/semver/functions/lt.js +1 -1
  92. package/dist/melonjs.mjs/node_modules/semver/functions/lte.js +1 -1
  93. package/dist/melonjs.mjs/node_modules/semver/functions/major.js +1 -1
  94. package/dist/melonjs.mjs/node_modules/semver/functions/minor.js +1 -1
  95. package/dist/melonjs.mjs/node_modules/semver/functions/neq.js +1 -1
  96. package/dist/melonjs.mjs/node_modules/semver/functions/parse.js +1 -1
  97. package/dist/melonjs.mjs/node_modules/semver/functions/patch.js +1 -1
  98. package/dist/melonjs.mjs/node_modules/semver/functions/prerelease.js +1 -1
  99. package/dist/melonjs.mjs/node_modules/semver/functions/rcompare.js +1 -1
  100. package/dist/melonjs.mjs/node_modules/semver/functions/rsort.js +1 -1
  101. package/dist/melonjs.mjs/node_modules/semver/functions/satisfies.js +1 -1
  102. package/dist/melonjs.mjs/node_modules/semver/functions/sort.js +1 -1
  103. package/dist/melonjs.mjs/node_modules/semver/functions/valid.js +1 -1
  104. package/dist/melonjs.mjs/node_modules/semver/index.js +1 -1
  105. package/dist/melonjs.mjs/node_modules/semver/internal/constants.js +1 -1
  106. package/dist/melonjs.mjs/node_modules/semver/internal/debug.js +1 -1
  107. package/dist/melonjs.mjs/node_modules/semver/internal/identifiers.js +1 -1
  108. package/dist/melonjs.mjs/node_modules/semver/internal/parse-options.js +1 -1
  109. package/dist/melonjs.mjs/node_modules/semver/internal/re.js +1 -1
  110. package/dist/melonjs.mjs/node_modules/semver/node_modules/lru-cache/index.js +1 -1
  111. package/dist/melonjs.mjs/node_modules/semver/node_modules/yallist/iterator.js +1 -1
  112. package/dist/melonjs.mjs/node_modules/semver/node_modules/yallist/yallist.js +1 -1
  113. package/dist/melonjs.mjs/node_modules/semver/ranges/gtr.js +1 -1
  114. package/dist/melonjs.mjs/node_modules/semver/ranges/intersects.js +1 -1
  115. package/dist/melonjs.mjs/node_modules/semver/ranges/ltr.js +1 -1
  116. package/dist/melonjs.mjs/node_modules/semver/ranges/max-satisfying.js +1 -1
  117. package/dist/melonjs.mjs/node_modules/semver/ranges/min-satisfying.js +1 -1
  118. package/dist/melonjs.mjs/node_modules/semver/ranges/min-version.js +1 -1
  119. package/dist/melonjs.mjs/node_modules/semver/ranges/outside.js +1 -1
  120. package/dist/melonjs.mjs/node_modules/semver/ranges/simplify.js +1 -1
  121. package/dist/melonjs.mjs/node_modules/semver/ranges/subset.js +1 -1
  122. package/dist/melonjs.mjs/node_modules/semver/ranges/to-comparators.js +1 -1
  123. package/dist/melonjs.mjs/node_modules/semver/ranges/valid.js +1 -1
  124. package/dist/melonjs.mjs/particles/emitter.js +1 -1
  125. package/dist/melonjs.mjs/particles/particle.js +1 -1
  126. package/dist/melonjs.mjs/particles/settings.js +1 -1
  127. package/dist/melonjs.mjs/physics/body.js +4 -4
  128. package/dist/melonjs.mjs/physics/bounds.js +1 -1
  129. package/dist/melonjs.mjs/physics/collision.js +1 -1
  130. package/dist/melonjs.mjs/physics/detector.js +2 -2
  131. package/dist/melonjs.mjs/physics/quadtree.js +1 -1
  132. package/dist/melonjs.mjs/physics/response.js +1 -1
  133. package/dist/melonjs.mjs/physics/sat.js +1 -1
  134. package/dist/melonjs.mjs/physics/world.js +1 -1
  135. package/dist/melonjs.mjs/plugin/plugin.js +3 -3
  136. package/dist/melonjs.mjs/renderable/collectable.js +1 -1
  137. package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
  138. package/dist/melonjs.mjs/renderable/container.js +2 -2
  139. package/dist/melonjs.mjs/renderable/draggable.js +1 -1
  140. package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
  141. package/dist/melonjs.mjs/renderable/entity/entity.js +1 -1
  142. package/dist/melonjs.mjs/renderable/imagelayer.js +1 -1
  143. package/dist/melonjs.mjs/renderable/light2d.js +7 -7
  144. package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
  145. package/dist/melonjs.mjs/renderable/renderable.js +1 -1
  146. package/dist/melonjs.mjs/renderable/sprite.js +1 -1
  147. package/dist/melonjs.mjs/renderable/text/bitmaptext.js +1 -1
  148. package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +1 -1
  149. package/dist/melonjs.mjs/renderable/text/glyph.js +1 -1
  150. package/dist/melonjs.mjs/renderable/text/text.js +1 -1
  151. package/dist/melonjs.mjs/renderable/text/textmetrics.js +1 -1
  152. package/dist/melonjs.mjs/renderable/text/textstyle.js +1 -1
  153. package/dist/melonjs.mjs/renderable/trigger.js +1 -1
  154. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
  155. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
  156. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
  157. package/dist/melonjs.mjs/state/stage.js +1 -1
  158. package/dist/melonjs.mjs/state/state.js +5 -5
  159. package/dist/melonjs.mjs/system/device.js +6 -6
  160. package/dist/melonjs.mjs/system/dom.js +1 -1
  161. package/dist/melonjs.mjs/system/event.js +1 -1
  162. package/dist/melonjs.mjs/system/platform.js +4 -2
  163. package/dist/melonjs.mjs/system/pooling.js +2 -2
  164. package/dist/melonjs.mjs/system/save.js +2 -2
  165. package/dist/melonjs.mjs/system/timer.js +2 -2
  166. package/dist/melonjs.mjs/tweens/easing.js +68 -70
  167. package/dist/melonjs.mjs/tweens/interpolation.js +29 -29
  168. package/dist/melonjs.mjs/tweens/tween.js +43 -43
  169. package/dist/melonjs.mjs/utils/agent.js +1 -1
  170. package/dist/melonjs.mjs/utils/array.js +1 -1
  171. package/dist/melonjs.mjs/utils/file.js +1 -1
  172. package/dist/melonjs.mjs/utils/function.js +1 -1
  173. package/dist/melonjs.mjs/utils/string.js +1 -1
  174. package/dist/melonjs.mjs/utils/utils.js +1 -1
  175. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +6 -5
  176. package/dist/melonjs.mjs/video/renderer.js +17 -69
  177. package/dist/melonjs.mjs/video/rendertarget/canvasrendertarget.js +12 -6
  178. package/dist/melonjs.mjs/video/texture/atlas.js +1 -1
  179. package/dist/melonjs.mjs/video/texture/cache.js +1 -1
  180. package/dist/melonjs.mjs/video/texture/parser/aseprite.js +1 -1
  181. package/dist/melonjs.mjs/video/texture/parser/spritesheet.js +1 -1
  182. package/dist/melonjs.mjs/video/texture/parser/texturepacker.js +1 -1
  183. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  184. package/dist/melonjs.mjs/video/video.js +1 -1
  185. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
  186. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +1 -1
  187. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +1 -1
  188. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +1 -1
  189. package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
  190. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  191. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
  192. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  193. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
  194. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
  195. package/dist/melonjs.mjs/video/webgl/utils/precision.js +5 -5
  196. package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
  197. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  198. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
  199. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +8 -7
  200. package/dist/melonjs.module.js +358 -369
  201. package/dist/types/audio/audio.d.ts +8 -4
  202. package/dist/types/loader/cache.d.ts +1 -0
  203. package/dist/types/loader/loader.d.ts +7 -0
  204. package/dist/types/system/platform.d.ts +2 -0
  205. package/dist/types/video/renderer.d.ts +5 -15
  206. package/dist/types/video/rendertarget/canvasrendertarget.d.ts +6 -9
  207. package/package.json +13 -13
  208. package/src/application/application.js +1 -1
  209. package/src/application/header.js +1 -1
  210. package/src/audio/audio.js +12 -8
  211. package/src/geometries/path2d.js +16 -16
  212. package/src/index.js +2 -2
  213. package/src/level/tiled/TMXObject.js +1 -1
  214. package/src/level/tiled/TMXTileMap.js +1 -1
  215. package/src/level/tiled/TMXUtils.js +2 -2
  216. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +4 -4
  217. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
  218. package/src/loader/cache.js +3 -0
  219. package/src/loader/loader.js +33 -3
  220. package/src/loader/parsers/fontface.js +24 -14
  221. package/src/loader/parsers/image.js +2 -2
  222. package/src/math/color.js +5 -5
  223. package/src/math/matrix2.js +6 -6
  224. package/src/math/matrix3.js +1 -1
  225. package/src/math/observable_vector2.js +2 -2
  226. package/src/math/observable_vector3.js +3 -3
  227. package/src/math/vector2.js +2 -2
  228. package/src/math/vector3.js +3 -3
  229. package/src/physics/body.js +3 -3
  230. package/src/physics/detector.js +1 -1
  231. package/src/renderable/container.js +1 -1
  232. package/src/renderable/light2d.js +6 -6
  233. package/src/state/state.js +4 -4
  234. package/src/system/device.js +5 -5
  235. package/src/system/platform.js +2 -0
  236. package/src/system/pooling.js +1 -1
  237. package/src/system/save.js +1 -1
  238. package/src/system/timer.js +1 -1
  239. package/src/tweens/easing.js +67 -69
  240. package/src/tweens/interpolation.js +28 -28
  241. package/src/tweens/tween.js +42 -42
  242. package/src/video/canvas/canvas_renderer.js +5 -4
  243. package/src/video/renderer.js +16 -68
  244. package/src/video/rendertarget/canvasrendertarget.js +11 -5
  245. package/src/video/webgl/utils/precision.js +4 -4
  246. package/src/video/webgl/webgl_renderer.js +7 -6
@@ -113,11 +113,12 @@ export function rate(sound_name: string, ...args: any[]): number;
113
113
  * @memberof audio
114
114
  * @param {string} sound_name - audio clip name - case sensitive
115
115
  * @param {number} [pan] - the panning value - A value of -1.0 is all the way left and 1.0 is all the way right.
116
+ * @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will be changed.
116
117
  * @return {number} the current panning value
117
118
  * @example
118
119
  * me.audio.stereo("cling", -1);
119
120
  */
120
- export function stereo(sound_name: string, pan?: number | undefined): number;
121
+ export function stereo(sound_name: string, pan?: number | undefined, id?: number | undefined): number;
121
122
  /**
122
123
  * get or set the 3D spatial position for the specified sound.
123
124
  * @memberof audio
@@ -125,9 +126,10 @@ export function stereo(sound_name: string, pan?: number | undefined): number;
125
126
  * @param {Number} x - the x-position of the audio source.
126
127
  * @param {Number} y - the y-position of the audio source.
127
128
  * @param {Number} z - the z-position of the audio source.
129
+ * @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will be changed.
128
130
  * @return {Array} the current 3D spatial position: [x, y, z]
129
131
  */
130
- export function position(sound_name: string, x: number, y: number, z: number): any[];
132
+ export function position(sound_name: string, x: number, y: number, z: number, id?: number | undefined): any[];
131
133
  /**
132
134
  * Get/set the direction the audio source is pointing in the 3D cartesian coordinate space.
133
135
  * Depending on how direction the sound is, based on the `cone` attributes, a sound pointing away from the listener can be quiet or silent.
@@ -136,9 +138,10 @@ export function position(sound_name: string, x: number, y: number, z: number): a
136
138
  * @param {Number} x - the x-orientation of the audio source.
137
139
  * @param {Number} y - the y-orientation of the audio source.
138
140
  * @param {Number} z - the z-orientation of the audio source.
141
+ * @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will be changed.
139
142
  * @return {Array} the current 3D spatial orientation: [x, y, z]
140
143
  */
141
- export function orientation(sound_name: string, x: number, y: number, z: number): any[];
144
+ export function orientation(sound_name: string, x: number, y: number, z: number, id?: number | undefined): any[];
142
145
  /**
143
146
  * get or set the panner node's attributes for a sound or group of sounds.
144
147
  * See {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Web_audio_spatialization_basics#creating_a_panner_node}
@@ -153,6 +156,7 @@ export function orientation(sound_name: string, x: number, y: number, z: number)
153
156
  * @param {string} [settings.refDistance=1] - A reference distance for reducing volume as source moves further from the listener. This is simply a variable of the distance model and has a different effect depending on which model is used and the scale of your coordinates. Generally, volume will be equal to 1 at this distance.
154
157
  * @param {string} [settings.rolloffFactor=1] - How quickly the volume reduces as source moves from listener. This is simply a variable of the distance model and can be in the range of `[0, 1]` with `linear` and `[0, ∞]` with `inverse` and `exponential`.
155
158
  * @param {string} [settings.panningModel="HRTF"] - Determines which spatialization algorithm is used to position audio. Can be `HRTF` or `equalpower`.
159
+ * @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will be changed.
156
160
  * @return {Object} current panner attributes.
157
161
  * @example
158
162
  * me.audio.panner("cling", {
@@ -162,7 +166,7 @@ export function orientation(sound_name: string, x: number, y: number, z: number)
162
166
  * distanceModel: 'exponential'
163
167
  * });
164
168
  */
165
- export function panner(sound_name: string, attributes: any): Object;
169
+ export function panner(sound_name: string, attributes: any, id?: number | undefined): Object;
166
170
  /**
167
171
  * stop the specified sound on all channels
168
172
  * @memberof audio
@@ -6,3 +6,4 @@ export let tmxList: {};
6
6
  export let binList: {};
7
7
  export let jsonList: {};
8
8
  export let videoList: {};
9
+ export let fontList: {};
@@ -242,6 +242,13 @@ export function getJSON(elt: string): JSON;
242
242
  * @returns {HTMLVideoElement}
243
243
  */
244
244
  export function getVideo(elt: string): HTMLVideoElement;
245
+ /**
246
+ * return the specified FontFace Object
247
+ * @memberof loader
248
+ * @param {string} elt - name of the font file
249
+ * @returns {FontFace}
250
+ */
251
+ export function getFont(elt: string): FontFace;
245
252
  /**
246
253
  * a small class to manage loading of stuff and manage resources
247
254
  * @namespace loader
@@ -15,6 +15,7 @@
15
15
  * @property {boolean} isWeixin `true` if running under Wechat
16
16
  * @property {boolean} nodeJS `true` if running under node.js
17
17
  * @property {boolean} isMobile `true` if a mobile device
18
+ * @property {boolean} webApp `true` if running as a standalone web app
18
19
  */
19
20
  export const ua: string;
20
21
  export const iOS: boolean;
@@ -29,3 +30,4 @@ export const ejecta: boolean;
29
30
  export const isWeixin: boolean;
30
31
  export const nodeJS: boolean;
31
32
  export const isMobile: boolean;
33
+ export const webApp: boolean;
@@ -66,7 +66,6 @@ export default class Renderer {
66
66
  * @ignore
67
67
  */
68
68
  currentBlendMode: string;
69
- canvas: any;
70
69
  currentColor: Color;
71
70
  currentTint: Color;
72
71
  projectionMatrix: Matrix3d;
@@ -96,12 +95,12 @@ export default class Renderer {
96
95
  */
97
96
  reset(): void;
98
97
  /**
99
- * return a reference to the canvas which this renderer draws to
98
+ * return a reference to the current render target corresponding canvas which this renderer draws to
100
99
  * @returns {HTMLCanvasElement}
101
100
  */
102
101
  getCanvas(): HTMLCanvasElement;
103
102
  /**
104
- * return a reference to this renderer canvas corresponding Context
103
+ * return a reference to the current render target corresponding Context
105
104
  * @returns {CanvasRenderingContext2D|WebGLRenderingContext}
106
105
  */
107
106
  getContext(): CanvasRenderingContext2D | WebGLRenderingContext;
@@ -110,14 +109,6 @@ export default class Renderer {
110
109
  * @returns {string} blend mode
111
110
  */
112
111
  getBlendMode(): string;
113
- /**
114
- * Returns the 2D Context object of the given Canvas<br>
115
- * Also configures anti-aliasing and blend modes based on constructor options.
116
- * @param {HTMLCanvasElement} canvas
117
- * @param {boolean} [transparent=true] - use false to disable transparency
118
- * @returns {CanvasRenderingContext2D}
119
- */
120
- getContext2d(canvas: HTMLCanvasElement, transparent?: boolean | undefined): CanvasRenderingContext2D;
121
112
  /**
122
113
  * get the current fill & stroke style color.
123
114
  * @returns {Color} current global color
@@ -141,11 +132,10 @@ export default class Renderer {
141
132
  */
142
133
  resize(width: number, height: number): void;
143
134
  /**
144
- * enable/disable image smoothing (scaling interpolation) for the given context
145
- * @param {CanvasRenderingContext2D} context
135
+ * enable/disable image smoothing (scaling interpolation) for the current render target
146
136
  * @param {boolean} [enable=false]
147
137
  */
148
- setAntiAlias(context: CanvasRenderingContext2D, enable?: boolean | undefined): void;
138
+ setAntiAlias(enable?: boolean | undefined): void;
149
139
  /**
150
140
  * set/change the current projection matrix (WebGL only)
151
141
  * @param {Matrix3d} matrix
@@ -167,7 +157,7 @@ export default class Renderer {
167
157
  * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} src - the source image to be tinted
168
158
  * @param {Color|string} color - the color that will be used to tint the image
169
159
  * @param {string} [mode="multiply"] - the composition mode used to tint the image
170
- * @returns {HTMLCanvasElement|OffscreenCanvas} a new canvas element representing the tinted image
160
+ * @returns {HTMLCanvasElement|OffscreenCanvas} a new canvas or offscreencanvas (if supported) element representing the tinted image
171
161
  */
172
162
  tint(src: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas, color: Color | string, mode?: string | undefined): HTMLCanvasElement | OffscreenCanvas;
173
163
  /**
@@ -6,18 +6,15 @@ declare class CanvasRenderTarget {
6
6
  /**
7
7
  * @param {number} width - the desired width of the canvas
8
8
  * @param {number} height - the desired height of the canvas
9
- * @param {object} attributes - The attributes to create both the canvas and context
10
- * @param {boolean} [attributes.context="2d"] - the context type to be created ("2d", "webgl", "webgl2")
9
+ * @param {Settings} attributes - The attributes to create both the canvas and context
10
+ * @param {boolean} [attributes.context="2d"] - the context type to be created ("2d", "webgl")
11
+ * @param {boolean} [attributes.preferWebGL1=false] - set to true for force using WebGL1 instead of WebGL2 (if supported)
12
+ * @param {boolean} [attributes.transparent=false] - specify if the canvas contains an alpha channel
11
13
  * @param {boolean} [attributes.offscreenCanvas=false] - will create an offscreenCanvas if true instead of a standard canvas
12
14
  * @param {boolean} [attributes.willReadFrequently=false] - Indicates whether or not a lot of read-back operations are planned
13
15
  * @param {boolean} [attributes.antiAlias=false] - Whether to enable anti-aliasing, use false (default) for a pixelated effect.
14
16
  */
15
- constructor(width: number, height: number, attributes?: {
16
- context?: boolean | undefined;
17
- offscreenCanvas?: boolean | undefined;
18
- willReadFrequently?: boolean | undefined;
19
- antiAlias?: boolean | undefined;
20
- });
17
+ constructor(width: number, height: number, attributes?: Settings);
21
18
  /**
22
19
  * the canvas created for this CanvasRenderTarget
23
20
  * @type {HTMLCanvasElement|OffscreenCanvas}
@@ -28,7 +25,7 @@ declare class CanvasRenderTarget {
28
25
  * @type {CanvasRenderingContext2D|WebGLRenderingContext}
29
26
  */
30
27
  context: CanvasRenderingContext2D | WebGLRenderingContext;
31
- attributes: never;
28
+ attributes: any;
32
29
  WebGLVersion: any;
33
30
  /**
34
31
  * @ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "melonjs",
3
- "version": "17.1.0",
3
+ "version": "17.2.0",
4
4
  "description": "melonJS Game Engine",
5
5
  "homepage": "http://www.melonjs.org/",
6
6
  "type": "module",
@@ -53,45 +53,45 @@
53
53
  ],
54
54
  "dependencies": {
55
55
  "@teppeis/multimaps": "^3.0.0",
56
- "core-js": "^3.36.1",
56
+ "core-js": "^3.37.0",
57
57
  "earcut": "2.2.4",
58
58
  "eventemitter3": "^5.0.1",
59
59
  "howler": "2.2.4",
60
+ "save-dev": "^0.0.1-security",
60
61
  "semver": "^7.6.0",
61
62
  "whatwg-fetch": "^3.6.20"
62
63
  },
63
64
  "devDependencies": {
64
- "@babel/eslint-parser": "^7.24.1",
65
- "@babel/plugin-syntax-import-assertions": "^7.24.1",
66
- "@fastify/static": "^7.0.1",
65
+ "@fastify/static": "^7.0.3",
67
66
  "@melonjs/webdoc-theme": "^1.1.1",
68
67
  "@rollup/plugin-commonjs": "^25.0.7",
69
68
  "@rollup/plugin-image": "^3.0.3",
69
+ "@rollup/plugin-json": "^6.1.0",
70
70
  "@rollup/plugin-node-resolve": "^15.2.3",
71
71
  "@rollup/plugin-replace": "^5.0.5",
72
72
  "@webdoc/cli": "^2.2.0",
73
- "chromedriver": "^123.0.1",
73
+ "chromedriver": "^123.0.4",
74
74
  "cross-env": "^7.0.3",
75
75
  "del-cli": "^5.1.0",
76
- "eslint": "^8.57.0",
77
- "eslint-plugin-jsdoc": "^48.2.2",
76
+ "eslint": "^9.1.0",
77
+ "eslint-plugin-jsdoc": "^48.2.3",
78
78
  "expect": "^29.7.0",
79
79
  "expect-mocha-image-snapshot": "^3.0.16",
80
80
  "fastify": "^4.26.2",
81
81
  "mocha": "^10.4.0",
82
82
  "npm-self-link": "^1.1.7",
83
- "puppeteer": "^22.6.1",
84
- "rollup": "^4.13.2",
83
+ "puppeteer": "^22.6.5",
84
+ "rollup": "^4.16.1",
85
85
  "rollup-plugin-bundle-size": "^1.0.3",
86
86
  "rollup-plugin-string": "^3.0.0",
87
- "terser": "^5.30.0",
88
- "typescript": "^5.4.3"
87
+ "terser": "^5.30.3",
88
+ "typescript": "^5.4.5"
89
89
  },
90
90
  "scripts": {
91
91
  "build": "npm run lint && rollup -c --silent",
92
92
  "build:cd": "npm run lint && rollup -c --failAfterWarnings",
93
93
  "dist": " npm run clean && npm run build && mkdirp dist && cp -fR build/*.* dist/ && npm run types && npm run doc",
94
- "lint": "eslint src/** rollup.config.mjs",
94
+ "lint": "eslint",
95
95
  "pretest": "mkdirp tests/browser/public/lib && cp -f build/melonjs.module.js tests/browser/public/lib",
96
96
  "test": "npm run test-node && mocha ./tests/browser/spec/*.js --reporter spec --bail --timeout 10000",
97
97
  "test-node": "node build/melonjs.module.js",
@@ -180,7 +180,7 @@ export default class Application {
180
180
 
181
181
  // identify parent element and/or the html target for resizing
182
182
  this.parentElement = device.getElement(this.settings.parent);
183
- if (typeof this.settings.scaleTarget !== "undefined" ) {
183
+ if (typeof this.settings.scaleTarget !== "undefined") {
184
184
  this.settings.scaleTarget = device.getElement(this.settings.scaleTarget);
185
185
  }
186
186
 
@@ -20,7 +20,7 @@ export function consoleHeader(app) {
20
20
  device.language
21
21
  );
22
22
 
23
- console.log( "resolution: " + "requested " + app.settings.width + "x" + app.settings.height +
23
+ console.log("resolution: " + "requested " + app.settings.width + "x" + app.settings.height +
24
24
  ", got " + app.renderer.width + "x" + app.renderer.height
25
25
  );
26
26
  }
@@ -284,14 +284,15 @@ export function rate(sound_name, ...args) {
284
284
  * @memberof audio
285
285
  * @param {string} sound_name - audio clip name - case sensitive
286
286
  * @param {number} [pan] - the panning value - A value of -1.0 is all the way left and 1.0 is all the way right.
287
+ * @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will be changed.
287
288
  * @return {number} the current panning value
288
289
  * @example
289
290
  * me.audio.stereo("cling", -1);
290
291
  */
291
- export function stereo(sound_name, pan) {
292
+ export function stereo(sound_name, pan, id) {
292
293
  let sound = audioTracks[sound_name];
293
294
  if (sound && typeof sound !== "undefined") {
294
- return sound.stereo(pan);
295
+ return sound.stereo(pan, id);
295
296
  } else {
296
297
  throw new Error("audio clip " + sound_name + " does not exist");
297
298
  }
@@ -304,12 +305,13 @@ export function stereo(sound_name, pan) {
304
305
  * @param {Number} x - the x-position of the audio source.
305
306
  * @param {Number} y - the y-position of the audio source.
306
307
  * @param {Number} z - the z-position of the audio source.
308
+ * @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will be changed.
307
309
  * @return {Array} the current 3D spatial position: [x, y, z]
308
310
  */
309
- export function position(sound_name, x, y, z) {
311
+ export function position(sound_name, x, y, z, id) {
310
312
  let sound = audioTracks[sound_name];
311
313
  if (sound && typeof sound !== "undefined") {
312
- return sound.pos(x, y, z);
314
+ return sound.pos(x, y, z, id);
313
315
  } else {
314
316
  throw new Error("audio clip " + sound_name + " does not exist");
315
317
  }
@@ -323,12 +325,13 @@ export function position(sound_name, x, y, z) {
323
325
  * @param {Number} x - the x-orientation of the audio source.
324
326
  * @param {Number} y - the y-orientation of the audio source.
325
327
  * @param {Number} z - the z-orientation of the audio source.
328
+ * @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will be changed.
326
329
  * @return {Array} the current 3D spatial orientation: [x, y, z]
327
330
  */
328
- export function orientation(sound_name, x, y, z) {
331
+ export function orientation(sound_name, x, y, z, id) {
329
332
  let sound = audioTracks[sound_name];
330
333
  if (sound && typeof sound !== "undefined") {
331
- return sound.orientation(x, y, z);
334
+ return sound.orientation(x, y, z, id);
332
335
  } else {
333
336
  throw new Error("audio clip " + sound_name + " does not exist");
334
337
  }
@@ -348,6 +351,7 @@ export function orientation(sound_name, x, y, z) {
348
351
  * @param {string} [settings.refDistance=1] - A reference distance for reducing volume as source moves further from the listener. This is simply a variable of the distance model and has a different effect depending on which model is used and the scale of your coordinates. Generally, volume will be equal to 1 at this distance.
349
352
  * @param {string} [settings.rolloffFactor=1] - How quickly the volume reduces as source moves from listener. This is simply a variable of the distance model and can be in the range of `[0, 1]` with `linear` and `[0, ∞]` with `inverse` and `exponential`.
350
353
  * @param {string} [settings.panningModel="HRTF"] - Determines which spatialization algorithm is used to position audio. Can be `HRTF` or `equalpower`.
354
+ * @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will be changed.
351
355
  * @return {Object} current panner attributes.
352
356
  * @example
353
357
  * me.audio.panner("cling", {
@@ -357,10 +361,10 @@ export function orientation(sound_name, x, y, z) {
357
361
  * distanceModel: 'exponential'
358
362
  * });
359
363
  */
360
- export function panner(sound_name, attributes) {
364
+ export function panner(sound_name, attributes, id) {
361
365
  let sound = audioTracks[sound_name];
362
366
  if (sound && typeof sound !== "undefined") {
363
- return sound.pannerAttr(attributes);
367
+ return sound.pannerAttr(attributes, id);
364
368
  } else {
365
369
  throw new Error("audio clip " + sound_name + " does not exist");
366
370
  }
@@ -63,12 +63,12 @@ export default class Path2D {
63
63
  break;
64
64
  case "H":
65
65
  // H take 1 coordinate
66
- lastPoint = points.length === 0 ? startPoint : points[points.length-1];
66
+ lastPoint = points.length === 0 ? startPoint : points[points.length - 1];
67
67
  this.lineTo(lastPoint.x + coordinates[0], lastPoint.y);
68
68
  break;
69
69
  case "V":
70
70
  // V take 1 coordinate
71
- lastPoint = points.length === 0 ? startPoint : points[points.length-1];
71
+ lastPoint = points.length === 0 ? startPoint : points[points.length - 1];
72
72
  this.lineTo(lastPoint.x, lastPoint.y + coordinates[0]);
73
73
  break;
74
74
  case "M":
@@ -120,7 +120,7 @@ export default class Path2D {
120
120
  let points = this.points;
121
121
  if (points.length > 0) {
122
122
  let firstPoint = points[0];
123
- if (!firstPoint.equals(points[points.length-1])) {
123
+ if (!firstPoint.equals(points[points.length - 1])) {
124
124
  this.lineTo(firstPoint.x, firstPoint.y);
125
125
  }
126
126
  this.isDirty = true;
@@ -145,14 +145,14 @@ export default class Path2D {
145
145
  }
146
146
 
147
147
  // calculate all vertices
148
- for (let i = 0; i < indicesLength; i++ ) {
148
+ for (let i = 0; i < indicesLength; i++) {
149
149
  let point = points[indices[i]];
150
150
  vertices[i].set(point.x, point.y);
151
151
  }
152
152
 
153
153
  // recycle overhead from a previous triangulation
154
154
  while (vertices.length > indicesLength) {
155
- pool.push(vertices[vertices.length-1]);
155
+ pool.push(vertices[vertices.length - 1]);
156
156
  vertices.length -= 1;
157
157
  }
158
158
  this.isDirty = false;
@@ -179,7 +179,7 @@ export default class Path2D {
179
179
  lineTo(x, y) {
180
180
  let points = this.points;
181
181
  let startPoint = this.startPoint;
182
- let lastPoint = points.length === 0 ? startPoint : points[points.length-1];
182
+ let lastPoint = points.length === 0 ? startPoint : points[points.length - 1];
183
183
 
184
184
  if (!startPoint.equals(lastPoint)) {
185
185
  points.push(pool.pull("Point", startPoint.x, startPoint.y));
@@ -208,7 +208,7 @@ export default class Path2D {
208
208
  // based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
209
209
  //bring angles all in [0, 2*PI] range
210
210
  if (startAngle === endAngle) return;
211
- const fullCircle = anticlockwise ? Math.abs(startAngle-endAngle) >= (TAU) : Math.abs(endAngle-startAngle) >= (TAU);
211
+ const fullCircle = anticlockwise ? Math.abs(startAngle - endAngle) >= (TAU) : Math.abs(endAngle - startAngle) >= (TAU);
212
212
 
213
213
  startAngle = startAngle % (TAU);
214
214
  endAngle = endAngle % (TAU);
@@ -217,7 +217,7 @@ export default class Path2D {
217
217
  if (endAngle < 0) endAngle += TAU;
218
218
 
219
219
  if (startAngle >= endAngle) {
220
- endAngle+= TAU;
220
+ endAngle += TAU;
221
221
  }
222
222
 
223
223
  let diff = endAngle - startAngle;
@@ -258,7 +258,7 @@ export default class Path2D {
258
258
  arcTo(x1, y1, x2, y2, radius) {
259
259
  let points = this.points;
260
260
  let startPoint = this.startPoint;
261
- let lastPoint = points.length === 0 ? startPoint : points[points.length-1];
261
+ let lastPoint = points.length === 0 ? startPoint : points[points.length - 1];
262
262
 
263
263
  // based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
264
264
  let x0 = lastPoint.x, y0 = lastPoint.y;
@@ -273,8 +273,8 @@ export default class Path2D {
273
273
  let angle = Math.atan2(a1, a0) - Math.atan2(b1, b0);
274
274
 
275
275
  //work out tangent points using tan(θ) = opposite / adjacent; angle/2 because hypotenuse is the bisection of a,b
276
- let tan_angle_div2 = Math.tan(angle/2);
277
- let adj_l = (radius/tan_angle_div2);
276
+ let tan_angle_div2 = Math.tan(angle / 2);
277
+ let adj_l = (radius / tan_angle_div2);
278
278
 
279
279
  let tangent1_pointx = x1 + a0 * adj_l, tangent1_pointy = y1 + a1 * adj_l;
280
280
  let tangent2_pointx = x1 + b0 * adj_l, tangent2_pointy = y1 + b1 * adj_l;
@@ -309,7 +309,7 @@ export default class Path2D {
309
309
  ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise = false) {
310
310
  // based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
311
311
  if (startAngle === endAngle) return;
312
- let fullCircle = anticlockwise ? Math.abs(startAngle-endAngle) >= (TAU) : Math.abs(endAngle-startAngle) >= (TAU);
312
+ let fullCircle = anticlockwise ? Math.abs(startAngle - endAngle) >= (TAU) : Math.abs(endAngle - startAngle) >= (TAU);
313
313
 
314
314
  //bring angles all in [0, 2*PI] range
315
315
  startAngle = startAngle % (TAU);
@@ -317,7 +317,7 @@ export default class Path2D {
317
317
  if (startAngle < 0) startAngle += TAU;
318
318
  if (endAngle < 0) endAngle += TAU;
319
319
 
320
- if (startAngle>=endAngle) {
320
+ if (startAngle >= endAngle) {
321
321
  endAngle += TAU;
322
322
  }
323
323
 
@@ -347,7 +347,7 @@ export default class Path2D {
347
347
  const _y1 = radiusY * Math.sin(angle);
348
348
  const _x2 = x + _x1 * cos_rotation - _y1 * sin_rotation;
349
349
  const _y2 = y + _x1 * sin_rotation + _y1 * cos_rotation;
350
- this.lineTo( _x2, _y2);
350
+ this.lineTo(_x2, _y2);
351
351
  angle += angleStep;
352
352
  }
353
353
  // close the ellipse
@@ -365,7 +365,7 @@ export default class Path2D {
365
365
  quadraticCurveTo(cpX, cpY, x, y) {
366
366
  const points = this.points;
367
367
  const startPoint = this.startPoint;
368
- const lastPoint = points.length === 0 ? startPoint : points[points.length-1];
368
+ const lastPoint = points.length === 0 ? startPoint : points[points.length - 1];
369
369
  const endPoint = pool.pull("Point").set(x, y);
370
370
  const controlPoint = pool.pull("Point").set(cpX, cpY);
371
371
  const resolution = this.arcResolution;
@@ -393,7 +393,7 @@ export default class Path2D {
393
393
  bezierCurveTo(cp1X, cp1Y, cp2X, cp2Y, x, y) {
394
394
  const points = this.points;
395
395
  const startPoint = this.startPoint;
396
- const lastPoint = points.length === 0 ? startPoint : points[points.length-1];
396
+ const lastPoint = points.length === 0 ? startPoint : points[points.length - 1];
397
397
  const endPoint = pool.pull("Point").set(x, y);
398
398
  const controlPoint1 = pool.pull("Point").set(cp1X, cp1Y);
399
399
  const controlPoint2 = pool.pull("Point").set(cp2X, cp2Y);
package/src/index.js CHANGED
@@ -226,7 +226,7 @@ export function boot() {
226
226
  }
227
227
 
228
228
  // output melonJS version in the console
229
- console.log("melonJS 2 (v" + version + ") | http://melonjs.org" );
229
+ console.log("melonJS 2 (v" + version + ") | http://melonjs.org");
230
230
 
231
231
  // register all built-ins objects into the object pool
232
232
  pool.register("me.Entity", Entity);
@@ -293,7 +293,7 @@ export function boot() {
293
293
  event.emit(event.BOOT);
294
294
 
295
295
  // enable/disable the cache
296
- loader.setNocache( utils.getUriFragment().nocache || false );
296
+ loader.setNocache(utils.getUriFragment().nocache || false);
297
297
 
298
298
  // automatically enable keyboard events
299
299
  input.initKeyboardEvent();
@@ -228,7 +228,7 @@ export default class TMXObject {
228
228
  let _polygon = pool.pull("Polygon", 0, 0, this.points);
229
229
  let isConvex = _polygon.isConvex();
230
230
  // make sure it's a convex polygon
231
- if (isConvex === false ) {
231
+ if (isConvex === false) {
232
232
  throw new Error("collision polygones in Tiled should be defined as Convex");
233
233
  } else if (isConvex === null) {
234
234
  throw new Error("invalid polygone");
@@ -199,7 +199,7 @@ export default class TMXTileMap {
199
199
  if (this.version !== "undefined" && this.version !== "") {
200
200
  // deprecation warning if map tiled version is older than 1.5
201
201
  if (checkVersion(this.version, "1.5") < 0) {
202
- warning("("+this.name+") Tiled Map format version 1.4 and below", "format 1.5 or higher", "10.4.4");
202
+ warning("(" + this.name + ") Tiled Map format version 1.4 and below", "format 1.5 or higher", "10.4.4");
203
203
  }
204
204
  }
205
205
 
@@ -45,7 +45,7 @@ function setTMXValue(name, type, value) {
45
45
  try {
46
46
  value = JSON.parse(match);
47
47
  }
48
- catch (e) {
48
+ catch {
49
49
  throw new Error("Unable to parse JSON: " + match);
50
50
  }
51
51
  }
@@ -56,7 +56,7 @@ function setTMXValue(name, type, value) {
56
56
  // eslint-disable-next-line
57
57
  value = Function("'use strict';return (" + match + ")")();
58
58
  }
59
- catch (e) {
59
+ catch {
60
60
  throw new Error("Unable to evaluate: " + match);
61
61
  }
62
62
  }
@@ -185,10 +185,10 @@ export default class TMXHexagonalRenderer extends TMXRenderer {
185
185
  }
186
186
  } else {
187
187
  if ((x & 1) ^ this.staggerEven) {
188
- ret.set(x -1, y + 1);
188
+ ret.set(x - 1, y + 1);
189
189
  }
190
190
  else {
191
- ret.set(x -1, y);
191
+ ret.set(x - 1, y);
192
192
  }
193
193
  }
194
194
  return ret;
@@ -422,11 +422,11 @@ export default class TMXHexagonalRenderer extends TMXRenderer {
422
422
  let staggeredRow = this.doStaggerX(startTile.x + layer.pos.x);
423
423
 
424
424
  // main drawing loop
425
- for (; startPos.y < rect.bottom && startTile.y < endY; ) {
425
+ for (; startPos.y < rect.bottom && startTile.y < endY;) {
426
426
  rowTile.setV(startTile);
427
427
  rowPos.setV(startPos);
428
428
 
429
- for (; rowPos.x < rect.right && rowTile.x < endX; rowTile.x+=2) {
429
+ for (; rowPos.x < rect.right && rowTile.x < endX; rowTile.x += 2) {
430
430
  tile = layer.cellAt(rowTile.x, rowTile.y, false);
431
431
  if (tile) {
432
432
  // draw the tile
@@ -133,8 +133,8 @@ export default class TMXOrthogonalRenderer extends TMXRenderer {
133
133
  }
134
134
 
135
135
  // main drawing loop
136
- for (let y = start.y; y !== end.y; y+= incY) {
137
- for (let x = start.x; x !== end.x; x+= incX) {
136
+ for (let y = start.y; y !== end.y; y += incY) {
137
+ for (let x = start.x; x !== end.x; x += incX) {
138
138
  let tmxTile = layer.cellAt(x, y, false);
139
139
  if (tmxTile) {
140
140
  this.drawTile(renderer, x, y, tmxTile);
@@ -17,3 +17,6 @@ export let jsonList = {};
17
17
 
18
18
  // contains all the video files
19
19
  export let videoList = {};
20
+
21
+ // contains all the font files
22
+ export let fontList = {};
@@ -2,7 +2,7 @@ import * as fileUtil from "./../utils/file.js";
2
2
  import * as event from "./../system/event.js";
3
3
  import * as audio from "./../audio/audio.js";
4
4
  import state from "./../state/state.js";
5
- import { imgList, tmxList, binList, jsonList, videoList } from "./cache.js";
5
+ import { imgList, tmxList, binList, jsonList, videoList, fontList } from "./cache.js";
6
6
  import { preloadImage } from "./parsers/image.js";
7
7
  import { preloadFontFace } from "./parsers/fontface.js";
8
8
  import { preloadTMX } from "./parsers/tmx.js";
@@ -529,8 +529,12 @@ export function unload(asset) {
529
529
  return true;
530
530
 
531
531
  case "fontface":
532
- // ??
533
- return true;
532
+ if (typeof typeof globalThis.document !== "undefined" && typeof globalThis.document.fonts !== "undefined") {
533
+ globalThis.document.fonts.delete(fontList[asset.name]);
534
+ delete fontList[asset.name];
535
+ return true;
536
+ }
537
+ return false;
534
538
 
535
539
  case "tmx":
536
540
  case "tsx":
@@ -615,6 +619,16 @@ export function unloadAll() {
615
619
  }
616
620
  }
617
621
 
622
+ // unload all video resources
623
+ for (name in fontList) {
624
+ if (fontList.hasOwnProperty(name)) {
625
+ unload({
626
+ "name" : name,
627
+ "type" : "font"
628
+ });
629
+ }
630
+ }
631
+
618
632
  // unload all audio resources
619
633
  audio.unloadAll();
620
634
  }
@@ -695,3 +709,19 @@ export function getVideo(elt) {
695
709
  return null;
696
710
  }
697
711
 
712
+ /**
713
+ * return the specified FontFace Object
714
+ * @memberof loader
715
+ * @param {string} elt - name of the font file
716
+ * @returns {FontFace}
717
+ */
718
+ export function getFont(elt) {
719
+ // force as string
720
+ elt = "" + elt;
721
+ if (elt in fontList) {
722
+ return fontList[elt];
723
+ }
724
+ return null;
725
+ }
726
+
727
+