melonjs 20.2.0 → 20.4.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 (515) hide show
  1. package/README.md +86 -8
  2. package/build/application/application.d.ts +0 -17
  3. package/build/application/application.d.ts.map +1 -1
  4. package/build/application/settings.d.ts +6 -2
  5. package/build/application/settings.d.ts.map +1 -1
  6. package/build/audio/audio.d.ts +2 -2
  7. package/build/audio/audio.d.ts.map +1 -1
  8. package/build/audio/backend/buffer.d.ts +26 -0
  9. package/build/audio/backend/buffer.d.ts.map +1 -0
  10. package/build/audio/backend/cache.d.ts +2 -0
  11. package/build/audio/backend/cache.d.ts.map +1 -0
  12. package/build/audio/backend/core.d.ts +24 -0
  13. package/build/audio/backend/core.d.ts.map +1 -0
  14. package/build/audio/backend/engine.d.ts +35 -0
  15. package/build/audio/backend/engine.d.ts.map +1 -0
  16. package/build/audio/backend/sound.d.ts +29 -0
  17. package/build/audio/backend/sound.d.ts.map +1 -0
  18. package/build/audio/backend/spatial.d.ts +191 -0
  19. package/build/audio/backend/spatial.d.ts.map +1 -0
  20. package/build/audio/backend/types.d.ts +107 -0
  21. package/build/audio/backend/types.d.ts.map +1 -0
  22. package/build/audio/backend/voice.d.ts +8 -0
  23. package/build/audio/backend/voice.d.ts.map +1 -0
  24. package/build/audio/playback.d.ts +49 -4
  25. package/build/audio/playback.d.ts.map +1 -1
  26. package/build/audio/procedural.d.ts.map +1 -1
  27. package/build/audio/state.d.ts +69 -0
  28. package/build/audio/state.d.ts.map +1 -0
  29. package/build/audio/types.d.ts +93 -1
  30. package/build/audio/types.d.ts.map +1 -1
  31. package/build/camera/camera2d.d.ts +0 -68
  32. package/build/camera/camera2d.d.ts.map +1 -1
  33. package/build/camera/camera3d.d.ts +91 -84
  34. package/build/camera/camera3d.d.ts.map +1 -1
  35. package/build/camera/effects/fade_effect.d.ts +0 -5
  36. package/build/camera/effects/fade_effect.d.ts.map +1 -1
  37. package/build/camera/effects/mask_effect.d.ts +0 -5
  38. package/build/camera/effects/mask_effect.d.ts.map +1 -1
  39. package/build/camera/fog.d.ts +118 -0
  40. package/build/camera/fog.d.ts.map +1 -0
  41. package/build/const.d.ts +2 -2
  42. package/build/geometries/box3d.d.ts +0 -28
  43. package/build/geometries/box3d.d.ts.map +1 -1
  44. package/build/geometries/ellipse.d.ts +0 -20
  45. package/build/geometries/ellipse.d.ts.map +1 -1
  46. package/build/geometries/observablePoint.d.ts +0 -3
  47. package/build/geometries/observablePoint.d.ts.map +1 -1
  48. package/build/geometries/path2d.d.ts +0 -19
  49. package/build/geometries/path2d.d.ts.map +1 -1
  50. package/build/geometries/polygon.d.ts +0 -12
  51. package/build/geometries/polygon.d.ts.map +1 -1
  52. package/build/geometries/roundrect.d.ts +0 -18
  53. package/build/geometries/roundrect.d.ts.map +1 -1
  54. package/build/geometries/sphere.d.ts +0 -9
  55. package/build/geometries/sphere.d.ts.map +1 -1
  56. package/build/geometries/toarccanvas.d.ts.map +1 -1
  57. package/build/index.d.ts +1 -0
  58. package/build/index.d.ts.map +1 -1
  59. package/build/index.js +12150 -11289
  60. package/build/index.js.map +4 -4
  61. package/build/input/gamepad.d.ts.map +1 -1
  62. package/build/input/input.d.ts +19 -0
  63. package/build/input/input.d.ts.map +1 -1
  64. package/build/input/pointer.d.ts +0 -4
  65. package/build/input/pointer.d.ts.map +1 -1
  66. package/build/input/pointerevent.d.ts +0 -6
  67. package/build/input/pointerevent.d.ts.map +1 -1
  68. package/build/lang/deprecated.d.ts +4 -2
  69. package/build/lang/deprecated.d.ts.map +1 -1
  70. package/build/level/gltf/GLTFModel.d.ts +0 -81
  71. package/build/level/gltf/GLTFModel.d.ts.map +1 -1
  72. package/build/level/gltf/GLTFScene.d.ts +13 -44
  73. package/build/level/gltf/GLTFScene.d.ts.map +1 -1
  74. package/build/level/gltf/gltf_sampler.d.ts +1 -48
  75. package/build/level/gltf/gltf_sampler.d.ts.map +1 -1
  76. package/build/level/level.d.ts +195 -113
  77. package/build/level/level.d.ts.map +1 -1
  78. package/build/level/tiled/TMXGroup.d.ts +1 -65
  79. package/build/level/tiled/TMXGroup.d.ts.map +1 -1
  80. package/build/level/tiled/TMXLayer.d.ts +0 -44
  81. package/build/level/tiled/TMXLayer.d.ts.map +1 -1
  82. package/build/level/tiled/TMXObject.d.ts +1 -136
  83. package/build/level/tiled/TMXObject.d.ts.map +1 -1
  84. package/build/level/tiled/TMXObjectFactory.d.ts +1 -40
  85. package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
  86. package/build/level/tiled/TMXTile.d.ts +1 -30
  87. package/build/level/tiled/TMXTile.d.ts.map +1 -1
  88. package/build/level/tiled/TMXTileMap.d.ts +0 -10
  89. package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
  90. package/build/level/tiled/TMXTileset.d.ts +0 -113
  91. package/build/level/tiled/TMXTileset.d.ts.map +1 -1
  92. package/build/level/tiled/TMXTilesetGroup.d.ts +0 -1
  93. package/build/level/tiled/TMXTilesetGroup.d.ts.map +1 -1
  94. package/build/level/tiled/TMXUtils.d.ts +1 -43
  95. package/build/level/tiled/TMXUtils.d.ts.map +1 -1
  96. package/build/level/tiled/factories/shape.d.ts +1 -7
  97. package/build/level/tiled/factories/shape.d.ts.map +1 -1
  98. package/build/level/tiled/factories/text.d.ts +1 -7
  99. package/build/level/tiled/factories/text.d.ts.map +1 -1
  100. package/build/level/tiled/factories/tile.d.ts +1 -7
  101. package/build/level/tiled/factories/tile.d.ts.map +1 -1
  102. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +0 -60
  103. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
  104. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +0 -42
  105. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
  106. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +0 -5
  107. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
  108. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +0 -31
  109. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
  110. package/build/level/tiled/renderer/TMXRenderer.d.ts +2 -2
  111. package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
  112. package/build/level/tiled/renderer/TMXStaggeredRenderer.d.ts.map +1 -1
  113. package/build/level/tiled/renderer/autodetect.d.ts +1 -6
  114. package/build/level/tiled/renderer/autodetect.d.ts.map +1 -1
  115. package/build/lighting/light2d.d.ts +0 -25
  116. package/build/lighting/light2d.d.ts.map +1 -1
  117. package/build/lighting/light3d.d.ts +0 -16
  118. package/build/lighting/light3d.d.ts.map +1 -1
  119. package/build/loader/loader.d.ts +46 -73
  120. package/build/loader/loader.d.ts.map +1 -1
  121. package/build/loader/loadingscreen.d.ts +0 -33
  122. package/build/loader/loadingscreen.d.ts.map +1 -1
  123. package/build/loader/parsers/aseprite.d.ts +0 -13
  124. package/build/loader/parsers/aseprite.d.ts.map +1 -1
  125. package/build/loader/parsers/audio.d.ts +2 -0
  126. package/build/loader/parsers/audio.d.ts.map +1 -0
  127. package/build/loader/parsers/binary.d.ts +1 -10
  128. package/build/loader/parsers/binary.d.ts.map +1 -1
  129. package/build/loader/parsers/compressed_textures/compressed_image.d.ts.map +1 -1
  130. package/build/loader/parsers/compressed_textures/parseDDS.d.ts +1 -7
  131. package/build/loader/parsers/compressed_textures/parseDDS.d.ts.map +1 -1
  132. package/build/loader/parsers/compressed_textures/parseKTX.d.ts +1 -7
  133. package/build/loader/parsers/compressed_textures/parseKTX.d.ts.map +1 -1
  134. package/build/loader/parsers/compressed_textures/parseKTX2.d.ts +1 -7
  135. package/build/loader/parsers/compressed_textures/parseKTX2.d.ts.map +1 -1
  136. package/build/loader/parsers/compressed_textures/parsePKM.d.ts +1 -7
  137. package/build/loader/parsers/compressed_textures/parsePKM.d.ts.map +1 -1
  138. package/build/loader/parsers/compressed_textures/parsePVR.d.ts +1 -7
  139. package/build/loader/parsers/compressed_textures/parsePVR.d.ts.map +1 -1
  140. package/build/loader/parsers/fontface.d.ts +1 -13
  141. package/build/loader/parsers/fontface.d.ts.map +1 -1
  142. package/build/loader/parsers/gltf.d.ts +1 -70
  143. package/build/loader/parsers/gltf.d.ts.map +1 -1
  144. package/build/loader/parsers/image.d.ts +1 -22
  145. package/build/loader/parsers/image.d.ts.map +1 -1
  146. package/build/loader/parsers/json.d.ts +1 -10
  147. package/build/loader/parsers/json.d.ts.map +1 -1
  148. package/build/loader/parsers/mtl.d.ts +1 -28
  149. package/build/loader/parsers/mtl.d.ts.map +1 -1
  150. package/build/loader/parsers/obj.d.ts +1 -59
  151. package/build/loader/parsers/obj.d.ts.map +1 -1
  152. package/build/loader/parsers/pbr.d.ts +1 -62
  153. package/build/loader/parsers/pbr.d.ts.map +1 -1
  154. package/build/loader/parsers/script.d.ts +1 -10
  155. package/build/loader/parsers/script.d.ts.map +1 -1
  156. package/build/loader/parsers/shader.d.ts +1 -52
  157. package/build/loader/parsers/shader.d.ts.map +1 -1
  158. package/build/loader/parsers/tmx.d.ts +1 -10
  159. package/build/loader/parsers/tmx.d.ts.map +1 -1
  160. package/build/loader/parsers/video.d.ts +1 -10
  161. package/build/loader/parsers/video.d.ts.map +1 -1
  162. package/build/math/color.d.ts.map +1 -1
  163. package/build/math/noise.d.ts +0 -40
  164. package/build/math/noise.d.ts.map +1 -1
  165. package/build/math/observableVector2d.d.ts +0 -3
  166. package/build/math/observableVector2d.d.ts.map +1 -1
  167. package/build/math/observableVector3d.d.ts +0 -3
  168. package/build/math/observableVector3d.d.ts.map +1 -1
  169. package/build/math/vector2d.d.ts +0 -6
  170. package/build/math/vector2d.d.ts.map +1 -1
  171. package/build/math/vertex.d.ts +25 -0
  172. package/build/math/vertex.d.ts.map +1 -1
  173. package/build/particles/emitter.d.ts +0 -65
  174. package/build/particles/emitter.d.ts.map +1 -1
  175. package/build/particles/particle.d.ts +0 -81
  176. package/build/particles/particle.d.ts.map +1 -1
  177. package/build/physics/adapter.d.ts +3 -3
  178. package/build/physics/bounds.d.ts +0 -1
  179. package/build/physics/bounds.d.ts.map +1 -1
  180. package/build/physics/broadphase/broadphase.d.ts +0 -7
  181. package/build/physics/broadphase/broadphase.d.ts.map +1 -1
  182. package/build/physics/broadphase/octree.d.ts +0 -91
  183. package/build/physics/broadphase/octree.d.ts.map +1 -1
  184. package/build/physics/broadphase/quadtree.d.ts +0 -47
  185. package/build/physics/broadphase/quadtree.d.ts.map +1 -1
  186. package/build/physics/builtin/body.d.ts +5 -69
  187. package/build/physics/builtin/body.d.ts.map +1 -1
  188. package/build/physics/builtin/detector.d.ts +0 -312
  189. package/build/physics/builtin/detector.d.ts.map +1 -1
  190. package/build/physics/builtin/sat.d.ts +1 -48
  191. package/build/physics/builtin/sat.d.ts.map +1 -1
  192. package/build/physics/builtin/sat3d.d.ts +1 -56
  193. package/build/physics/builtin/sat3d.d.ts.map +1 -1
  194. package/build/physics/collision.d.ts +0 -2
  195. package/build/physics/collision.d.ts.map +1 -1
  196. package/build/physics/response.d.ts +0 -1
  197. package/build/physics/response.d.ts.map +1 -1
  198. package/build/physics/world.d.ts.map +1 -1
  199. package/build/plugin/plugin.d.ts +9 -1
  200. package/build/plugin/plugin.d.ts.map +1 -1
  201. package/build/polyfill/index.d.ts +1 -4
  202. package/build/polyfill/index.d.ts.map +1 -1
  203. package/build/renderable/anchorPoint.d.ts +1 -73
  204. package/build/renderable/anchorPoint.d.ts.map +1 -1
  205. package/build/renderable/animation.d.ts +0 -7
  206. package/build/renderable/animation.d.ts.map +1 -1
  207. package/build/renderable/colorlayer.d.ts +0 -5
  208. package/build/renderable/colorlayer.d.ts.map +1 -1
  209. package/build/renderable/container.d.ts +0 -55
  210. package/build/renderable/container.d.ts.map +1 -1
  211. package/build/renderable/draggable.d.ts +0 -5
  212. package/build/renderable/draggable.d.ts.map +1 -1
  213. package/build/renderable/dragndrop.d.ts +1 -12
  214. package/build/renderable/dragndrop.d.ts.map +1 -1
  215. package/build/renderable/entity/entity.d.ts +0 -8
  216. package/build/renderable/entity/entity.d.ts.map +1 -1
  217. package/build/renderable/frameAnimation.d.ts +0 -41
  218. package/build/renderable/frameAnimation.d.ts.map +1 -1
  219. package/build/renderable/groundshadow.d.ts +1 -91
  220. package/build/renderable/groundshadow.d.ts.map +1 -1
  221. package/build/renderable/imagelayer.d.ts +0 -29
  222. package/build/renderable/imagelayer.d.ts.map +1 -1
  223. package/build/renderable/instanced_mesh.d.ts +26 -104
  224. package/build/renderable/instanced_mesh.d.ts.map +1 -1
  225. package/build/renderable/mesh.d.ts +145 -140
  226. package/build/renderable/mesh.d.ts.map +1 -1
  227. package/build/renderable/nineslicesprite.d.ts +0 -4
  228. package/build/renderable/nineslicesprite.d.ts.map +1 -1
  229. package/build/renderable/renderable.d.ts +17 -54
  230. package/build/renderable/renderable.d.ts.map +1 -1
  231. package/build/renderable/sprite.d.ts +7 -52
  232. package/build/renderable/sprite.d.ts.map +1 -1
  233. package/build/renderable/sprite3d.d.ts +0 -95
  234. package/build/renderable/sprite3d.d.ts.map +1 -1
  235. package/build/renderable/text/bitmaptext.d.ts +0 -14
  236. package/build/renderable/text/bitmaptext.d.ts.map +1 -1
  237. package/build/renderable/text/bitmaptextdata.d.ts +0 -22
  238. package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
  239. package/build/renderable/text/glyph.d.ts +1 -39
  240. package/build/renderable/text/glyph.d.ts.map +1 -1
  241. package/build/renderable/text/text.d.ts +0 -20
  242. package/build/renderable/text/text.d.ts.map +1 -1
  243. package/build/renderable/text/textstyle.d.ts +1 -5
  244. package/build/renderable/text/textstyle.d.ts.map +1 -1
  245. package/build/renderable/trail.d.ts +0 -29
  246. package/build/renderable/trail.d.ts.map +1 -1
  247. package/build/renderable/trigger.d.ts +0 -6
  248. package/build/renderable/trigger.d.ts.map +1 -1
  249. package/build/renderable/ui/uibaseelement.d.ts +0 -40
  250. package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
  251. package/build/renderable/ui/uispriteelement.d.ts +0 -35
  252. package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
  253. package/build/state/stage.d.ts +4 -68
  254. package/build/state/stage.d.ts.map +1 -1
  255. package/build/state/state.d.ts.map +1 -1
  256. package/build/system/device.d.ts +0 -12
  257. package/build/system/device.d.ts.map +1 -1
  258. package/build/system/dom.d.ts +1 -8
  259. package/build/system/dom.d.ts.map +1 -1
  260. package/build/system/event.d.ts +1 -1
  261. package/build/system/legacy_pool.d.ts +1 -6
  262. package/build/system/legacy_pool.d.ts.map +1 -1
  263. package/build/system/platform.d.ts +21 -2
  264. package/build/system/platform.d.ts.map +1 -1
  265. package/build/system/pool.d.ts +0 -9
  266. package/build/system/pool.d.ts.map +1 -1
  267. package/build/system/save.d.ts.map +1 -1
  268. package/build/system/timer.d.ts +0 -20
  269. package/build/system/timer.d.ts.map +1 -1
  270. package/build/tweens/tween.d.ts +0 -62
  271. package/build/tweens/tween.d.ts.map +1 -1
  272. package/build/utils/array-multimap.d.ts +1 -13
  273. package/build/utils/array-multimap.d.ts.map +1 -1
  274. package/build/utils/decode.d.ts.map +1 -1
  275. package/build/utils/fetchdata.d.ts +2 -0
  276. package/build/utils/fetchdata.d.ts.map +1 -0
  277. package/build/utils/utils.d.ts +0 -13
  278. package/build/utils/utils.d.ts.map +1 -1
  279. package/build/video/blendmodes.d.ts +1 -106
  280. package/build/video/blendmodes.d.ts.map +1 -1
  281. package/build/video/buffer/index.d.ts +1 -39
  282. package/build/video/buffer/index.d.ts.map +1 -1
  283. package/build/video/buffer/vertex.d.ts +1 -82
  284. package/build/video/buffer/vertex.d.ts.map +1 -1
  285. package/build/video/canvas/canvas_renderer.d.ts +7 -25
  286. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  287. package/build/video/canvas_factory.d.ts +1 -24
  288. package/build/video/canvas_factory.d.ts.map +1 -1
  289. package/build/video/effects/blendEffect.d.ts +0 -54
  290. package/build/video/effects/blendEffect.d.ts.map +1 -1
  291. package/build/video/effects/blur.d.ts +4 -4
  292. package/build/video/effects/blur.d.ts.map +1 -1
  293. package/build/video/effects/chromaticAberration.d.ts +5 -5
  294. package/build/video/effects/chromaticAberration.d.ts.map +1 -1
  295. package/build/video/effects/colorMatrix.d.ts +5 -15
  296. package/build/video/effects/colorMatrix.d.ts.map +1 -1
  297. package/build/video/effects/desaturate.d.ts +5 -5
  298. package/build/video/effects/desaturate.d.ts.map +1 -1
  299. package/build/video/effects/dissolve.d.ts +4 -4
  300. package/build/video/effects/dissolve.d.ts.map +1 -1
  301. package/build/video/effects/dropShadow.d.ts +5 -5
  302. package/build/video/effects/dropShadow.d.ts.map +1 -1
  303. package/build/video/effects/flash.d.ts +4 -4
  304. package/build/video/effects/flash.d.ts.map +1 -1
  305. package/build/video/effects/glow.d.ts +5 -5
  306. package/build/video/effects/glow.d.ts.map +1 -1
  307. package/build/video/effects/glsl_realization.d.ts +1 -17
  308. package/build/video/effects/glsl_realization.d.ts.map +1 -1
  309. package/build/video/effects/hologram.d.ts +4 -4
  310. package/build/video/effects/hologram.d.ts.map +1 -1
  311. package/build/video/effects/invert.d.ts +5 -5
  312. package/build/video/effects/invert.d.ts.map +1 -1
  313. package/build/video/effects/outline.d.ts +6 -6
  314. package/build/video/effects/outline.d.ts.map +1 -1
  315. package/build/video/effects/pixelate.d.ts +4 -4
  316. package/build/video/effects/pixelate.d.ts.map +1 -1
  317. package/build/video/effects/radialGradient.d.ts +2 -3
  318. package/build/video/effects/radialGradient.d.ts.map +1 -1
  319. package/build/video/effects/scanline.d.ts +6 -6
  320. package/build/video/effects/scanline.d.ts.map +1 -1
  321. package/build/video/effects/sepia.d.ts +5 -5
  322. package/build/video/effects/sepia.d.ts.map +1 -1
  323. package/build/video/effects/shadereffect.d.ts +12 -123
  324. package/build/video/effects/shadereffect.d.ts.map +1 -1
  325. package/build/video/effects/shine.d.ts +3 -3
  326. package/build/video/effects/shine.d.ts.map +1 -1
  327. package/build/video/effects/tintPulse.d.ts +4 -4
  328. package/build/video/effects/tintPulse.d.ts.map +1 -1
  329. package/build/video/effects/vignette.d.ts +6 -6
  330. package/build/video/effects/vignette.d.ts.map +1 -1
  331. package/build/video/effects/wave.d.ts +4 -4
  332. package/build/video/effects/wave.d.ts.map +1 -1
  333. package/build/video/effects/wgsl/layout.d.ts +1 -27
  334. package/build/video/effects/wgsl/layout.d.ts.map +1 -1
  335. package/build/video/effects/wgsl/parse.d.ts +1 -8
  336. package/build/video/effects/wgsl/parse.d.ts.map +1 -1
  337. package/build/video/effects/wgsl/scaffold.d.ts +1 -42
  338. package/build/video/effects/wgsl/scaffold.d.ts.map +1 -1
  339. package/build/video/effects/wgsl_realization.d.ts +1 -82
  340. package/build/video/effects/wgsl_realization.d.ts.map +1 -1
  341. package/build/video/gpu/batcher.d.ts +1 -13
  342. package/build/video/gpu/batcher.d.ts.map +1 -1
  343. package/build/video/gpu/instancerecord.d.ts +1 -163
  344. package/build/video/gpu/instancerecord.d.ts.map +1 -1
  345. package/build/video/gpu/meshchunk.d.ts +1 -48
  346. package/build/video/gpu/meshchunk.d.ts.map +1 -1
  347. package/build/video/gpu/meshvertex.d.ts +1 -53
  348. package/build/video/gpu/meshvertex.d.ts.map +1 -1
  349. package/build/video/gpu/primitives.d.ts +1 -59
  350. package/build/video/gpu/primitives.d.ts.map +1 -1
  351. package/build/video/gpu/quadcorners.d.ts +1 -10
  352. package/build/video/gpu/quadcorners.d.ts.map +1 -1
  353. package/build/video/gpu/textureslots.d.ts +1 -121
  354. package/build/video/gpu/textureslots.d.ts.map +1 -1
  355. package/build/video/gpu/texturestore.d.ts +1 -138
  356. package/build/video/gpu/texturestore.d.ts.map +1 -1
  357. package/build/video/gpu/topology.d.ts.map +1 -1
  358. package/build/video/gpu/vertexformat.d.ts +0 -28
  359. package/build/video/gpu/vertexformat.d.ts.map +1 -1
  360. package/build/video/gradient.d.ts +0 -81
  361. package/build/video/gradient.d.ts.map +1 -1
  362. package/build/video/renderer.d.ts +21 -102
  363. package/build/video/renderer.d.ts.map +1 -1
  364. package/build/video/renderstate.d.ts +0 -51
  365. package/build/video/renderstate.d.ts.map +1 -1
  366. package/build/video/rendertarget/canvasrendertarget.d.ts +0 -10
  367. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  368. package/build/video/rendertarget/render_target_pool.d.ts +1 -82
  369. package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
  370. package/build/video/rendertarget/webglrendertarget.d.ts +1 -64
  371. package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
  372. package/build/video/rendertarget/webgpurendertarget.d.ts +0 -8
  373. package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -1
  374. package/build/video/texture/atlas.d.ts +2 -76
  375. package/build/video/texture/atlas.d.ts.map +1 -1
  376. package/build/video/texture/cache.d.ts +0 -136
  377. package/build/video/texture/cache.d.ts.map +1 -1
  378. package/build/video/texture/frametexture.d.ts +1 -71
  379. package/build/video/texture/frametexture.d.ts.map +1 -1
  380. package/build/video/texture/noise_texture2d.d.ts +0 -43
  381. package/build/video/texture/noise_texture2d.d.ts.map +1 -1
  382. package/build/video/texture/parser/aseprite.d.ts +1 -8
  383. package/build/video/texture/parser/aseprite.d.ts.map +1 -1
  384. package/build/video/texture/parser/spritesheet.d.ts +1 -8
  385. package/build/video/texture/parser/spritesheet.d.ts.map +1 -1
  386. package/build/video/texture/parser/texturepacker.d.ts +1 -8
  387. package/build/video/texture/parser/texturepacker.d.ts.map +1 -1
  388. package/build/video/texture/resource.d.ts +0 -9
  389. package/build/video/texture/resource.d.ts.map +1 -1
  390. package/build/video/texture/texture2d.d.ts +0 -11
  391. package/build/video/texture/texture2d.d.ts.map +1 -1
  392. package/build/video/utils/autodetect.d.ts +1 -5
  393. package/build/video/utils/autodetect.d.ts.map +1 -1
  394. package/build/video/webgl/batchers/batcher.d.ts +0 -55
  395. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  396. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +0 -14
  397. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
  398. package/build/video/webgl/batchers/lit_quad_batcher.d.ts +0 -72
  399. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  400. package/build/video/webgl/batchers/material_batcher.d.ts +0 -89
  401. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  402. package/build/video/webgl/batchers/mesh_batcher.d.ts +14 -343
  403. package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
  404. package/build/video/webgl/batchers/primitive_batcher.d.ts +0 -10
  405. package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
  406. package/build/video/webgl/batchers/quad_batcher.d.ts +0 -30
  407. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  408. package/build/video/webgl/buffer/index.d.ts +1 -36
  409. package/build/video/webgl/buffer/index.d.ts.map +1 -1
  410. package/build/video/webgl/buffer/instance_buffer.d.ts +1 -53
  411. package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -1
  412. package/build/video/webgl/buffer/retained_geometry.d.ts +1 -81
  413. package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -1
  414. package/build/video/webgl/buffer/uniformblock.d.ts +1 -80
  415. package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -1
  416. package/build/video/webgl/buffer/vertexstate.d.ts +1 -100
  417. package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -1
  418. package/build/video/webgl/glshader.d.ts +2 -51
  419. package/build/video/webgl/glshader.d.ts.map +1 -1
  420. package/build/video/webgl/lighting/pack3d.d.ts +1 -47
  421. package/build/video/webgl/lighting/pack3d.d.ts.map +1 -1
  422. package/build/video/webgl/lighting/std140.d.ts +1 -109
  423. package/build/video/webgl/lighting/std140.d.ts.map +1 -1
  424. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts +1 -103
  425. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  426. package/build/video/webgl/shaders/multitexture-lit.d.ts +1 -26
  427. package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
  428. package/build/video/webgl/shaders/multitexture.d.ts +1 -9
  429. package/build/video/webgl/shaders/multitexture.d.ts.map +1 -1
  430. package/build/video/webgl/texture/store.d.ts +1 -50
  431. package/build/video/webgl/texture/store.d.ts.map +1 -1
  432. package/build/video/webgl/utils/attributes.d.ts +1 -11
  433. package/build/video/webgl/utils/attributes.d.ts.map +1 -1
  434. package/build/video/webgl/utils/maxtextures.d.ts +1 -36
  435. package/build/video/webgl/utils/maxtextures.d.ts.map +1 -1
  436. package/build/video/webgl/utils/precision.d.ts +1 -14
  437. package/build/video/webgl/utils/precision.d.ts.map +1 -1
  438. package/build/video/webgl/utils/program.d.ts +1 -5
  439. package/build/video/webgl/utils/program.d.ts.map +1 -1
  440. package/build/video/webgl/utils/samplercache.d.ts +1 -68
  441. package/build/video/webgl/utils/samplercache.d.ts.map +1 -1
  442. package/build/video/webgl/utils/string.d.ts +1 -21
  443. package/build/video/webgl/utils/string.d.ts.map +1 -1
  444. package/build/video/webgl/utils/topology.d.ts +1 -23
  445. package/build/video/webgl/utils/topology.d.ts.map +1 -1
  446. package/build/video/webgl/utils/uniforms.d.ts +1 -25
  447. package/build/video/webgl/utils/uniforms.d.ts.map +1 -1
  448. package/build/video/webgl/utils/vertexformat.d.ts +1 -26
  449. package/build/video/webgl/utils/vertexformat.d.ts.map +1 -1
  450. package/build/video/webgl/webgl_renderer.d.ts +24 -286
  451. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  452. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts +0 -6
  453. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -1
  454. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +0 -8
  455. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -1
  456. package/build/video/webgpu/batchers/mesh_batcher.d.ts +1 -230
  457. package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
  458. package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -1
  459. package/build/video/webgpu/batchers/quad_batcher.d.ts +0 -82
  460. package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
  461. package/build/video/webgpu/buffer/arena.d.ts +1 -63
  462. package/build/video/webgpu/buffer/arena.d.ts.map +1 -1
  463. package/build/video/webgpu/buffer/instance_buffer.d.ts +1 -64
  464. package/build/video/webgpu/buffer/instance_buffer.d.ts.map +1 -1
  465. package/build/video/webgpu/buffer/retained_geometry.d.ts +1 -54
  466. package/build/video/webgpu/buffer/retained_geometry.d.ts.map +1 -1
  467. package/build/video/webgpu/buffer/uniformring.d.ts +1 -67
  468. package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -1
  469. package/build/video/webgpu/effect_binding.d.ts +1 -16
  470. package/build/video/webgpu/effect_binding.d.ts.map +1 -1
  471. package/build/video/webgpu/pipeline/bindgroups.d.ts +1 -32
  472. package/build/video/webgpu/pipeline/bindgroups.d.ts.map +1 -1
  473. package/build/video/webgpu/pipeline/cache.d.ts +1 -163
  474. package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
  475. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +1 -87
  476. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  477. package/build/video/webgpu/shaders/mesh-instanced.d.ts +1 -43
  478. package/build/video/webgpu/shaders/mesh-instanced.d.ts.map +1 -1
  479. package/build/video/webgpu/texture/compressed.d.ts +1 -32
  480. package/build/video/webgpu/texture/compressed.d.ts.map +1 -1
  481. package/build/video/webgpu/texture/frametexture.d.ts +1 -62
  482. package/build/video/webgpu/texture/frametexture.d.ts.map +1 -1
  483. package/build/video/webgpu/texture/store.d.ts +1 -147
  484. package/build/video/webgpu/texture/store.d.ts.map +1 -1
  485. package/build/video/webgpu/webgpu_renderer.d.ts +2 -89
  486. package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
  487. package/package.json +8 -11
  488. package/skills/AGENTS.md +67 -0
  489. package/skills/melonjs/SKILL.md +156 -0
  490. package/skills/melonjs-20-migration/SKILL.md +160 -0
  491. package/skills/melonjs-3d/SKILL.md +525 -0
  492. package/skills/melonjs-3d-assets/SKILL.md +258 -0
  493. package/skills/melonjs-audio/SKILL.md +236 -0
  494. package/skills/melonjs-camera-and-drawing/SKILL.md +175 -0
  495. package/skills/melonjs-deployment/SKILL.md +113 -0
  496. package/skills/melonjs-effects-and-shaders/SKILL.md +178 -0
  497. package/skills/melonjs-events/SKILL.md +159 -0
  498. package/skills/melonjs-getting-started/SKILL.md +183 -0
  499. package/skills/melonjs-input/SKILL.md +166 -0
  500. package/skills/melonjs-lighting/SKILL.md +139 -0
  501. package/skills/melonjs-loading-assets/SKILL.md +186 -0
  502. package/skills/melonjs-particles-and-trails/SKILL.md +136 -0
  503. package/skills/melonjs-performance/SKILL.md +183 -0
  504. package/skills/melonjs-physics/SKILL.md +321 -0
  505. package/skills/melonjs-plugins/SKILL.md +191 -0
  506. package/skills/melonjs-renderables/SKILL.md +214 -0
  507. package/skills/melonjs-renderer-backends/SKILL.md +173 -0
  508. package/skills/melonjs-scenes-and-state/SKILL.md +180 -0
  509. package/skills/melonjs-sprites-and-animation/SKILL.md +173 -0
  510. package/skills/melonjs-tilemaps/SKILL.md +213 -0
  511. package/skills/melonjs-ui-and-text/SKILL.md +65 -0
  512. package/build/audio/backend.d.ts +0 -140
  513. package/build/audio/backend.d.ts.map +0 -1
  514. package/build/loader/parsers/fetchdata.d.ts +0 -32
  515. package/build/loader/parsers/fetchdata.d.ts.map +0 -1
@@ -0,0 +1,113 @@
1
+ ---
2
+ name: melonjs-deployment
3
+ description: "Use this skill when packaging, shipping or scaffolding a melonJS game — starting a project with create-melonjs, building for the web, wrapping as a native app with Capacitor or Cordova, publishing to WeChat Mini Games or Facebook Instant Games, browser support and transpiling. Triggers on: create-melonjs, scaffold, new project, build, deploy, publish, Capacitor, Cordova, native app, iOS, Android, WeChat, Instant Games, browser support, transpile, ES2022, bundle size, tree-shaking."
4
+ license: MIT
5
+ ---
6
+
7
+ # Starting and shipping a project
8
+
9
+ ## Scaffolding
10
+
11
+ Start from the template rather than assembling a build by hand:
12
+
13
+ ```bash
14
+ npm create melonjs@latest my-game
15
+ ```
16
+
17
+ The project name is required — without it the command prints its usage and
18
+ exits. It downloads the melonJS TypeScript boilerplate (Vite, TypeScript and the
19
+ debug plugin already wired in), which saves you the top-level-await and
20
+ asset-path issues that a hand-rolled config usually hits first.
21
+
22
+ ## Adding melonJS to an existing project
23
+
24
+ ```bash
25
+ npm install melonjs
26
+ ```
27
+
28
+ ```js
29
+ import { Application, Sprite, loader } from "melonjs";
30
+ ```
31
+
32
+ The package is a tree-shakeable ES module with TypeScript declarations included
33
+ and **no runtime dependencies**.
34
+
35
+ A CDN build exists for quick experiments, but not for production:
36
+
37
+ ```html
38
+ <script type="module">
39
+ import { Application } from "https://cdn.jsdelivr.net/npm/melonjs@20/+esm";
40
+ </script>
41
+ ```
42
+
43
+ ## Browser support and transpiling
44
+
45
+ The published bundle targets **ES2022** and uses private class members. A browser
46
+ that predates that **cannot parse the file at all** — it fails at load, not when
47
+ a feature is used, so the symptom is a blank page with a syntax error.
48
+
49
+ To support older browsers, transpile melonJS **together with your own code**.
50
+ The usual trap is that build setups skip `node_modules` by default, leaving
51
+ melonJS untouched however low you set your target:
52
+
53
+ ```js
54
+ // vite.config.js — esbuild downlevels dependencies too
55
+ export default { build: { target: "es2020" } };
56
+ ```
57
+
58
+ ```js
59
+ // webpack: the default `exclude: /node_modules/` would skip melonjs
60
+ { test: /\.js$/, exclude: /node_modules\/(?!melonjs)/, use: "babel-loader" }
61
+ ```
62
+
63
+ Two caveats worth knowing:
64
+
65
+ - **Transpiling handles syntax only.** Built-in methods need separate polyfills;
66
+ a bundler's `target` setting will never add them.
67
+ - Downlevelled private class members become `WeakMap` lookups, and melonJS uses
68
+ them in the renderer's hot paths. This is a real trade, not a free switch.
69
+
70
+ ## Native apps
71
+
72
+ **Capacitor** is the current recommendation for iOS and Android — see
73
+ `@melonjs/capacitor-plugin`. **Cordova** also works and is documented, but is the
74
+ older route.
75
+
76
+ The thing that breaks first in both is asset loading: the app is served from
77
+ `file://`, where `fetch()` cannot read local files. melonJS's loader falls back
78
+ to XHR for that scheme, so engine-loaded assets work — but any `fetch()` in
79
+ *your* game code will fail there.
80
+
81
+ ## Mini-game platforms
82
+
83
+ **WeChat Mini Games** and **Facebook Instant Games** are both documented in the
84
+ wiki. Note that `device.platform.isWeixin` detects WeChat's **in-app browser**,
85
+ which is a normal WebView. WeChat *Mini Games* are a different runtime with no
86
+ DOM, and need platform-specific adaptation rather than just detection — the one
87
+ hook the engine offers is that the renderer adopts a `globalThis.canvas` when
88
+ the runtime's adapter provides one, instead of creating its own.
89
+
90
+ ## Size
91
+
92
+ The whole engine is roughly **250 KB minzipped**. Tree-shaking helps less than
93
+ you might expect — the engine's subsystems reach each other, so a game importing
94
+ a handful of symbols still pulls most of it. Budget for the full figure.
95
+
96
+ Practical wins are in assets, not the engine: pack sprites into atlases, prefer
97
+ one tileset over several, and use `stream: true` for long music tracks so they
98
+ are not decoded into memory.
99
+
100
+ ## Symptom → cause
101
+
102
+ | symptom | cause |
103
+ |---|---|
104
+ | blank page, syntax error in the console | browser older than the ES2022 target |
105
+ | transpiling changes nothing | build config excludes `node_modules` |
106
+ | assets 404 in a packaged native app | `fetch()` in game code — `file://` needs XHR |
107
+ | a built-in method is missing after transpiling | transpiling is syntax-only; polyfills are separate |
108
+ | bundle much larger than expected | tree-shaking recovers little — subsystems are interconnected |
109
+
110
+ ## Related skills
111
+
112
+ - `melonjs` — the companion packages, including the Capacitor plugin
113
+ - `melonjs-getting-started` — the Application bootstrap the template produces
@@ -0,0 +1,178 @@
1
+ ---
2
+ name: melonjs-effects-and-shaders
3
+ description: "Use this skill for post-processing effects, custom shaders, blend modes and colour grading in melonJS. Covers the built-in ShaderEffect presets, addPostEffect on renderables and cameras, writing a custom dual-language GLSL/WGSL effect, the screen_texture builtins, and why effects silently do nothing on the Canvas fallback. Triggers on: ShaderEffect, addPostEffect, removePostEffect, getPostEffect, VignetteEffect, GlowEffect, BlurEffect, PixelateEffect, ScanlineEffect, shader, GLSL, WGSL, uniform, setUniform, setTexture, setTime, blendMode, colorMatrix, screen_texture, toFrameTexture, post effect, filter."
4
+ license: MIT
5
+ ---
6
+
7
+ # Post effects and custom shaders
8
+
9
+ > melonJS ships a catalogue of post effects and a dual-language shader system.
10
+ > The recurring trap is that every shader path needs a GPU backend and
11
+ > **degrades to nothing** on Canvas rather than erroring. Blend modes are the
12
+ > exception — those work on all three renderers.
13
+
14
+ ## Applying an effect
15
+
16
+ Effects attach to a renderable **or** to a camera (for full-screen grading):
17
+
18
+ ```js
19
+ import { VignetteEffect, GlowEffect } from "melonjs";
20
+
21
+ sprite.addPostEffect(new GlowEffect(app.renderer));
22
+ app.viewport.addPostEffect(new VignetteEffect(app.renderer));
23
+ ```
24
+
25
+ `renderable.shader = …` is **deprecated since 19.2.0**, and its setter destroys
26
+ whatever it replaces. Use `addPostEffect` / `getPostEffect` / `removePostEffect`.
27
+
28
+ ## Toggle with `enabled`, do not remove
29
+
30
+ **`removePostEffect()` destroys the effect** — it calls `effect.destroy()` and
31
+ frees GPU resources, so the instance cannot be re-added. Same for
32
+ `clearPostEffects()` and for reassigning the deprecated `.shader`.
33
+
34
+ ```js
35
+ // ✗ destroys it; re-adding later fails or forces a recompile
36
+ sprite.removePostEffect(effect);
37
+
38
+ // ✓
39
+ effect.enabled = false;
40
+ ```
41
+
42
+ An effect with `effect.shared === true` opts out of auto-destroy because it is
43
+ reused across renderables.
44
+
45
+ ## Built-in effects
46
+
47
+ Eighteen presets, every one constructed as `new XEffect(renderer, options)` and
48
+ every one shipping both a GLSL and a WGSL body, so they all run on either GPU
49
+ backend: `VignetteEffect`, `ScanlineEffect` (optional CRT curvature),
50
+ `GlowEffect`, `BlurEffect`, `PixelateEffect`, `ChromaticAberrationEffect`,
51
+ `DropShadowEffect`, `FlashEffect`, `OutlineEffect`, `ColorMatrixEffect`,
52
+ `DesaturateEffect`, `DissolveEffect`, `TintPulseEffect`, `WaveEffect`,
53
+ `InvertEffect`, `SepiaEffect`, `HologramEffect`, `ShineEffect`.
54
+
55
+ For grading without writing a shader yourself, the camera has a colour matrix:
56
+
57
+ ```js
58
+ app.viewport.colorMatrix.contrast(1.1).saturate(1.1);
59
+ ```
60
+
61
+ It is still *implemented* as one: a non-identity matrix makes the camera append
62
+ an internal `ColorMatrixEffect` to its post-effect chain for that frame, so it
63
+ needs a GPU backend like everything else here.
64
+
65
+ ## Custom effects are dual-language
66
+
67
+ A custom `ShaderEffect` supplies a fragment **body**, not a whole program. To run
68
+ on both GPU backends it needs GLSL *and* WGSL — a GLSL-only effect silently does
69
+ nothing when `video.AUTO` lands on WebGPU.
70
+
71
+ ```js
72
+ const effect = new ShaderEffect(app.renderer, { glsl, wgsl });
73
+ effect.setUniform("uStrength", 0.5);
74
+ effect.setTexture("uScene", tex);
75
+ effect.setTime(timer.getTime() / 1000); // setTime takes SECONDS; getTime is ms
76
+ ```
77
+
78
+ Uniform names are shared across the two bodies — in WGSL they are the members of
79
+ one `@group(3) @binding(0) var<uniform>` struct — so a single `setUniform` call
80
+ feeds whichever backend is live. `setTime` is a convenience for a `uTime`
81
+ uniform and silently does nothing if the shader does not declare one.
82
+
83
+ Shaders can also be preloaded as assets with loader type `"shader"`.
84
+
85
+ ### Screen-reading builtins
86
+
87
+ For refraction, distortion and anything that samples what is already drawn:
88
+
89
+ - **`screen_texture`** — a sampler kept filled with everything drawn so far
90
+ (GLSL: annotate the sampler `uniform sampler2D tex : screen_texture;`)
91
+ - **`screen_uv`** — this fragment's 0..1 position in that capture
92
+ - **`noise_uv`** — 0..1 across the sprite regardless of its atlas frame
93
+
94
+ In WGSL the capture is sampled through `screen_sampler` (clamped) or
95
+ `screen_sampler_repeat` (wrapping) instead of GLSL's `: screen_texture`
96
+ annotation. `screen_uv` is y-**up** in GLSL and y-**down** in WGSL, which exactly
97
+ matches each backend's own capture orientation — so a body that samples
98
+ `screen_texture` at `screen_uv` needs no flip in *either* language.
99
+
100
+ Two places where a straight port really does differ:
101
+
102
+ - **A capture you bind yourself.** `renderer.toFrameTexture()` grabs the frame
103
+ into a `Texture2d` you hand to `setTexture` — the supported replacement for
104
+ `readPixels` tricks. The GL capture is bottom-up (GLSL bodies sample it with
105
+ `1.0 - uv.y`) and opaque RGB; the WebGPU capture is top-down (the WGSL twin
106
+ must *not* flip) and preserves alpha.
107
+ - **Vertical UV offsets** — a drop shadow, a directional smear. The WebGL pooled
108
+ multi-effect path composites through bottom-up FBOs, so declare a `uUVYDir`
109
+ uniform (initialise it to `1.0`) and multiply vertical offsets by it; the
110
+ renderer feeds `-1` on that path and `+1` everywhere else.
111
+
112
+ ## Blend modes
113
+
114
+ Fourteen modes; thirteen of them are honoured by all three renderers:
115
+
116
+ ```js
117
+ sprite.blendMode = "additive"; // or "multiply", "screen", "overlay", …
118
+ ```
119
+
120
+ Six ride fixed-function blend state and cost nothing extra: `normal`,
121
+ `additive` (spelled `add` or `lighter` too), `multiply`, `screen`, `exclusion`,
122
+ and `none` (blending off — the source replaces the destination, alpha included).
123
+ `none` is the one mode the Canvas backend does not implement; it reports
124
+ `"normal"` instead.
125
+
126
+ The other eight cannot be expressed as a multiply-add on the destination, so the
127
+ GPU backends capture the destination and composite through `BlendEffect` — one
128
+ capture plus one composite **per draw**: `difference`, `overlay`, `hard-light`,
129
+ `color-dodge`, `color-burn`, `soft-light`, `darken`, `lighten`. Right for
130
+ accents; expensive for hundreds of objects. The Canvas renderer reaches all
131
+ eight through `globalCompositeOperation` instead, at no extra cost.
132
+
133
+ Anything else collapses to `"normal"`, and so do 3D meshes and `Gradient` fills
134
+ whatever you ask for — the latter with a one-time console warning.
135
+ `renderer.setBlendMode(mode)` returns the mode it actually applied, so comparing
136
+ that against your request detects the fallback.
137
+
138
+ ## The Canvas fallback
139
+
140
+ `ShaderEffect` on a Canvas renderer logs a warning, leaves `enabled = false`, and
141
+ turns every method into a no-op. Nothing throws. The same happens on a GPU
142
+ backend when no body matches its language — a GLSL-only effect under WebGPU.
143
+
144
+ That is fine for decoration. It is **not** fine when the shader draws your
145
+ content — the carrier renderable then shows through raw. A 1×1 white texture
146
+ stretched to 280×156 renders as a white box where the effect should be.
147
+
148
+ Guard when the effect is load-bearing:
149
+
150
+ ```js
151
+ if (app.renderer.shaderLanguage === null) {
152
+ // no programmable pipeline — skip the carrier draw entirely
153
+ }
154
+ ```
155
+
156
+ `shaderLanguage` (`"glsl"`, `"wgsl"`, or `null`) is the flag to test here rather
157
+ than a backend name or `supportsDepthBuffer`: it answers "can this renderer
158
+ compile what I am about to hand it". Per-effect, `effect.enabled` answers the
159
+ same question after construction.
160
+
161
+ ## Symptom → cause
162
+
163
+ | symptom | cause |
164
+ |---|---|
165
+ | effect does nothing, warning in console | Canvas fallback — no programmable pipeline |
166
+ | effect does nothing on some machines only | GLSL-only shader, `video.AUTO` chose WebGPU |
167
+ | a white or solid box where the effect should be | carrier renderable drawn while the effect is disabled |
168
+ | effect cannot be re-enabled | `removePostEffect()` destroyed it — use `enabled` |
169
+ | ported shader renders upside down | a hand-bound `toFrameTexture()` capture — GL is bottom-up, WebGPU top-down |
170
+ | shadow/smear offset flips on some draws | vertical UV offset not multiplied by `uUVYDir` |
171
+ | frame rate collapses with many blended sprites | an *advanced* mode (overlay, darken, …) — each draw is a capture plus a composite |
172
+ | animated shader never moves | `setTime` fed milliseconds, or the shader declares no `uTime` |
173
+
174
+ ## Related skills
175
+
176
+ - `melonjs-renderables` — where post effects attach, and the destroy trap
177
+ - `melonjs-3d` — the GPU-backend requirement, and why a custom mesh shader is
178
+ not affected by the camera's distance fog
@@ -0,0 +1,159 @@
1
+ ---
2
+ name: melonjs-events
3
+ description: "Use this skill for the melonJS event bus and lifecycle hooks — subscribing to engine events, the per-frame and per-state event names, renderable lifecycle callbacks, and how to unsubscribe without leaking. Triggers on: event.on, event.off, event.once, event.emit, GAME_UPDATE, GAME_BEFORE_DRAW, LEVEL_LOADED, LOADER_COMPLETE, STATE_CHANGE, CANVAS_ONRESIZE, POINTERMOVE, WORLD_STEP, onActivateEvent, onDeactivateEvent, onDestroyEvent, lifecycle, subscribe, listener."
4
+ license: MIT
5
+ ---
6
+
7
+ # Events and lifecycle
8
+
9
+ ## The bus
10
+
11
+ ```js
12
+ import { event } from "melonjs";
13
+
14
+ const onUpdate = () => { /* … */ };
15
+ const unsubscribe = event.on(event.GAME_UPDATE, onUpdate); // on() returns its own off()
16
+ event.once(event.LEVEL_LOADED, () => { /* … */ });
17
+
18
+ // two ways to undo it — the same reference, or the returned function
19
+ event.off(event.GAME_UPDATE, onUpdate);
20
+ unsubscribe();
21
+ ```
22
+
23
+ `event.on`/`once`/`off`/`has` all take an optional third `context` argument,
24
+ invoked as the handler's `this`. **`off` matches on the pair — handler identity
25
+ AND context identity.** `on(EVT, fn, this)` followed by `off(EVT, fn)` removes
26
+ nothing, silently.
27
+
28
+ **Store the handler reference, or use the context argument.** An inline arrow or
29
+ a fresh `.bind(this)` in the `on` call can never be removed — that is the
30
+ standard way to leak listeners in melonJS.
31
+
32
+ ```js
33
+ // ✗ unremovable
34
+ event.on(event.GAME_UPDATE, this.tick.bind(this));
35
+
36
+ // ✓ keep the bound reference
37
+ this._tick = this.tick.bind(this);
38
+ event.on(event.GAME_UPDATE, this._tick);
39
+ // later: event.off(event.GAME_UPDATE, this._tick);
40
+
41
+ // ✓ or skip the bind entirely — the context is part of the identity
42
+ event.on(event.GAME_UPDATE, this.tick, this);
43
+ // later: event.off(event.GAME_UPDATE, this.tick, this);
44
+ ```
45
+
46
+ Custom event names work at runtime (`event.emit("my.custom.event", payload)`),
47
+ but `on`/`emit` are typed against a closed map of the engine's own events, so in
48
+ TypeScript a name outside that map is a compile error. Use your own emitter for
49
+ game events in a `.ts` project.
50
+
51
+ ## The events worth knowing
52
+
53
+ **Per frame**
54
+
55
+ | event | when |
56
+ |---|---|
57
+ | `GAME_BEFORE_UPDATE` / `GAME_UPDATE` / `GAME_AFTER_UPDATE` | around the world update — `GAME_UPDATE` is **not** emitted while paused |
58
+ | `GAME_BEFORE_DRAW` / `GAME_AFTER_DRAW` | around the draw pass |
59
+ | `WORLD_STEP` | after the physics step |
60
+ | `TICK` | the raw engine tick |
61
+
62
+ **Lifecycle**
63
+
64
+ | event | when |
65
+ |---|---|
66
+ | `BOOT`, `GAME_INIT`, `VIDEO_INIT` | engine start-up |
67
+ | `STATE_CHANGE`, `STATE_PAUSE`, `STATE_RESUME`, `STATE_STOP` | state machine |
68
+ | `STAGE_RESET` | a stage was reset |
69
+ | `LEVEL_LOADED` | a Tiled level finished loading |
70
+ | `LOADER_PROGRESS`, `LOADER_COMPLETE`, `LOADER_ERROR` | asset loading |
71
+ | `BLUR` / `FOCUS` | the page lost or regained focus |
72
+ | `CANVAS_ONRESIZE`, `VIEWPORT_ONRESIZE` | relayout hooks |
73
+ | `POINTERMOVE` | global pointer movement |
74
+
75
+ Use `LOADER_PROGRESS` / `LOADER_COMPLETE`. The `loader.onProgress` /
76
+ `loader.onload` / `loader.onError` properties were deprecated in 18.2.0 and
77
+ removed in 20.3: they were module-level `let` bindings on an ES module
78
+ namespace, so `loader.onProgress = fn` threw and the documented migration path
79
+ never worked. For completion, `loader.preload(assets, onloadcb)` also takes the
80
+ callback directly.
81
+
82
+ ## Renderable lifecycle callbacks
83
+
84
+ Prefer these over bus subscriptions where they fit — the engine calls them at the
85
+ right times and there is nothing to unsubscribe:
86
+
87
+ | callback | when |
88
+ |---|---|
89
+ | `onActivateEvent()` | `addChild`-ed into a container that is already attached to the world root (a `Container` forwards it to its children) |
90
+ | `onDeactivateEvent()` | removed from its container — including the automatic world clear on a state change |
91
+ | `onDestroyEvent()` | `destroy()` ran; called with no arguments from the container-removal path |
92
+ | `onCollisionStart` / `onCollisionActive` / `onCollisionEnd` | contacts |
93
+
94
+ Note the activate gate: adding a child to a *detached* container fires nothing.
95
+ The callback arrives later, when that container itself is added to the world.
96
+ And an `isPersistent` renderable survives the world clear between stages, so it
97
+ gets no fresh `onActivateEvent` on the next state.
98
+
99
+ **Pair subscriptions with activate/deactivate, not the constructor.** This is
100
+ the rule that keeps pooled objects working:
101
+
102
+ ```js
103
+ onActivateEvent() {
104
+ this._tick = this.update.bind(this);
105
+ event.on(event.GAME_UPDATE, this._tick);
106
+ input.registerPointerEvent("pointerdown", this, this._onDown);
107
+ }
108
+ onDeactivateEvent() {
109
+ event.off(event.GAME_UPDATE, this._tick);
110
+ input.releasePointerEvent("pointerdown", this);
111
+ }
112
+ ```
113
+
114
+ **Pool-recycled objects never fire `onDestroyEvent` on removal** — `removeChildNow`
115
+ tries `pool.push(child)` first and only calls `destroy()` if that fails, so a
116
+ class registered with `pool.register(name, Class, true)` goes back to the pool
117
+ instead. Anything you clean up there will not run. `destroy()` is also what calls
118
+ `releaseAllPointerEvents(this)`, which is why a pooled object must release its
119
+ own pointer registrations in `onDeactivateEvent`.
120
+
121
+ ## Guard callbacks that can fire during teardown
122
+
123
+ Events can arrive while a stage is being dismantled, when the current state is
124
+ already something else:
125
+
126
+ ```js
127
+ if (!state.isCurrent(state.PLAY)) return;
128
+ ```
129
+
130
+ Without this, a "children emptied" handler can reset the wrong stage.
131
+
132
+ ## Removing objects from a collision callback
133
+
134
+ Contact callbacks fire inline inside the physics step, mid-iteration over the
135
+ detector's pair list. `container.removeChild()` is safe there — it defers the
136
+ actual removal to the next tick, which is exactly why it defers. The immediate
137
+ forms are the dangerous ones: `removeChildNow()` and `destroy()` tear the object
138
+ down under the iteration (`destroy()` nulls `pos` and `body`). The builtin
139
+ detector guards the pair it is currently resolving, but nothing guarantees that
140
+ for the rest of the step or for another adapter.
141
+
142
+ Use `removeChild()`, or flag the work and drain it from `Stage.update`.
143
+
144
+ ## Symptom → cause
145
+
146
+ | symptom | cause |
147
+ |---|---|
148
+ | handler still fires after removing the object | `event.off` given a different function reference, or a different `context` than `on` got |
149
+ | handlers accumulate on pooled objects | subscribed in the constructor rather than `onActivateEvent` |
150
+ | cleanup never runs on a pooled object | pooled removal does not fire `onDestroyEvent` |
151
+ | crash during a stage switch | callback ran mid-teardown — guard with `state.isCurrent` |
152
+ | crash after a collision | `removeChildNow()` / `destroy()` inside a contact callback — use `removeChild()` |
153
+ | progress callbacks never fire | assigned `loader.onProgress` (removed in 20.3) instead of subscribing to `LOADER_PROGRESS` |
154
+ | `onActivateEvent` never runs | the child was added to a container not yet attached to the world |
155
+
156
+ ## Related skills
157
+
158
+ - `melonjs-scenes-and-state` — the state machine and stage lifecycle
159
+ - `melonjs-performance` — pooling, and why activate/deactivate pairing matters
@@ -0,0 +1,183 @@
1
+ ---
2
+ name: melonjs-getting-started
3
+ description: "Use this skill when starting or bootstrapping a melonJS game, creating the Application, choosing a renderer, or setting up the first scene. Covers the mandatory async init, the world container, adding renderables, and the WebGPU/WebGL 2/Canvas fallback. Triggers on: melonjs, new Application, app.init, app.world, video.AUTO, video.WEBGL, video.CANVAS, Stage, state.change, getting started, bootstrap."
4
+ license: MIT
5
+ ---
6
+
7
+ # Getting started with melonJS
8
+
9
+ > Bootstrapping a melonJS 20.x game: the `Application` lifecycle, the mandatory
10
+ > `await app.init()`, the world container, and what the renderer fallback means
11
+ > for feature availability.
12
+
13
+ **Applies to:** melonJS 20.x. Older major versions differ — see the
14
+ `melonjs-20-migration` skill.
15
+
16
+ ## The bootstrap
17
+
18
+ `Application` construction is synchronous but **initialisation is not**. `init()`
19
+ returns a promise and must be awaited before building any renderable, loading
20
+ assets, or entering a scene.
21
+
22
+ ```js
23
+ import { Application, Text } from "melonjs";
24
+
25
+ const app = new Application(1218, 562, {
26
+ parent: "screen", // id of the DOM element to mount into
27
+ scale: "auto",
28
+ backgroundColor: "#202020",
29
+ });
30
+ await app.init(); // ← REQUIRED. Nothing below works without it.
31
+
32
+ app.world.addChild(
33
+ new Text(609, 281, {
34
+ font: "Arial",
35
+ size: 160,
36
+ fillStyle: "#FFFFFF",
37
+ textAlign: "center",
38
+ textBaseline: "middle",
39
+ text: "Hello World !",
40
+ }),
41
+ );
42
+ ```
43
+
44
+ **This is the single most common thing to get wrong.** On 19.x the constructor
45
+ called `init(width, height, options)` for you; on 20.x `init()` takes no
46
+ arguments and calling — and awaiting — it is your job. Nothing that follows
47
+ names the missing call. The constructor does build `app.world`, so adding a
48
+ plain renderable succeeds and simply never draws — no canvas is appended and the
49
+ app never subscribes to the frame tick — while constructing a `Sprite` or a
50
+ `Text` throws `Cannot read properties of undefined (reading 'renderer')`,
51
+ because the global `game` those two fall back on is only set once the first
52
+ `init()` resolves. Either way `app.renderer` and `app.viewport` stay `undefined`
53
+ and the page stays blank.
54
+
55
+ `init()` is asynchronous because acquiring a WebGPU device is asynchronous. There
56
+ is no synchronous alternative.
57
+
58
+ ## Top-level await
59
+
60
+ The bootstrap needs `await` at module scope. In an ES module that is fine. If the
61
+ surrounding tooling does not allow it, wrap it:
62
+
63
+ ```js
64
+ async function main() {
65
+ const app = new Application(800, 600, { parent: "screen" });
66
+ await app.init();
67
+ // …
68
+ }
69
+ void main();
70
+ ```
71
+
72
+ ## Choosing a renderer
73
+
74
+ `video.AUTO` (the default) tries **WebGPU → WebGL 2 → Canvas** and uses the first
75
+ that works.
76
+
77
+ ```js
78
+ import { video } from "melonjs";
79
+
80
+ const app = new Application(800, 600, {
81
+ parent: "screen",
82
+ renderer: video.AUTO, // default; or video.WEBGPU / video.WEBGL / video.CANVAS
83
+ });
84
+ ```
85
+
86
+ Two consequences worth knowing before writing rendering code:
87
+
88
+ - **Which backend you get is a runtime fact, not a build-time one.** The same
89
+ code runs on a different renderer depending on the machine. Do not assume
90
+ WebGL.
91
+ - **Not every feature exists on every backend.** Shader effects and post effects
92
+ need a programmable pipeline and are inert on Canvas. Where a feature degrades,
93
+ the engine warns once rather than throwing — so a missing effect is a console
94
+ warning, not a crash.
95
+
96
+ Pin the renderer explicitly (`video.WEBGL`) only when you have a reason to. It
97
+ costs you the WebGPU path and the Canvas fallback.
98
+
99
+ ## The scene graph
100
+
101
+ `app.world` is the root `Container`. Everything drawn is a descendant of it.
102
+
103
+ ```js
104
+ app.world.addChild(sprite, 10); // 10 is the z / draw order
105
+ ```
106
+
107
+ **Pass the z-order as the second argument to `addChild`** — it is the only form
108
+ that works. `renderable.z` does not exist as a property, setting `depth` before
109
+ `addChild` is overwritten by `autoDepth`, and setting it afterwards does not
110
+ resort. See the `melonjs-renderables` skill for the full explanation.
111
+
112
+ ## Scenes
113
+
114
+ For anything beyond a single screen, use `Stage` subclasses and the `state`
115
+ manager rather than mutating `app.world` directly:
116
+
117
+ ```js
118
+ import { Stage, state } from "melonjs";
119
+
120
+ class PlayScreen extends Stage {
121
+ onResetEvent() { /* build the scene */ }
122
+ onDestroyEvent() { /* tear it down */ }
123
+ }
124
+
125
+ state.set(state.PLAY, new PlayScreen());
126
+ state.change(state.PLAY);
127
+ ```
128
+
129
+ `onResetEvent` runs every time the state is entered, not once — build scene
130
+ content there, not in the constructor.
131
+
132
+ ## Loading assets
133
+
134
+ Assets are declared and preloaded through `loader`; audio needs `audio.init()`
135
+ with the formats you ship before any audio asset is preloaded.
136
+
137
+ ```js
138
+ import { audio, loader } from "melonjs";
139
+
140
+ loader.setOptions({ crossOrigin: "anonymous" }); // needed for remote assets
141
+ audio.init("mp3,ogg"); // BEFORE preloading audio
142
+ await loader.preload([
143
+ { name: "tileset", type: "image", src: "data/img/tileset.png" },
144
+ { name: "jump", type: "audio", src: "data/sfx/" }, // directory, not file
145
+ ]);
146
+ ```
147
+
148
+ Two ordering rules that produce confusing failures when missed:
149
+
150
+ - **`audio.init()` must run before any audio asset is preloaded**, and names the
151
+ formats you actually ship. Preloading first throws *"target audio extension(s)
152
+ should be set through me.audio.init() before calling the preloader"*.
153
+ - The audio `src` is a **directory**, not a file. The loader appends the asset
154
+ `name` plus each configured extension, so a full filename gives you a 404.
155
+
156
+ ## `anchorPoint` defaults to the centre
157
+
158
+ `Renderable.anchorPoint` is `(0.5, 0.5)`, so `pos` is an object's **centre**, not
159
+ its top-left. `Container` forces `(0, 0)` instead.
160
+
161
+ Writing top-left math against a centred anchor puts everything half a sprite off
162
+ with no error — it is the most common source of "close but subtly wrong"
163
+ placement.
164
+
165
+ ## Common mistakes
166
+
167
+ | symptom | cause |
168
+ |---|---|
169
+ | blank page, nothing drawn, or a `TypeError` reading `renderer` from `new Sprite` / `new Text` | missing `await app.init()` |
170
+ | objects draw in the wrong order | `.z`/`depth` set instead of `addChild(child, z)` — `.z` is not even a real property |
171
+ | shader/post effect does nothing, warning in console | running on the Canvas renderer |
172
+ | audio 404s | audio asset `src` given as a file rather than a directory |
173
+ | scene content appears once and never resets | scene built in the constructor instead of `onResetEvent` |
174
+ | everything offset by half a sprite | top-left math against the centred `anchorPoint` default |
175
+ | a `Tween` or `ParticleEmitter` does nothing | `.start()` / `streamParticles()` never called |
176
+ | cross-origin textures fail to load | missing `loader.setOptions({ crossOrigin: "anonymous" })` |
177
+
178
+ ## Related skills
179
+
180
+ - `melonjs-20-migration` — what changed in 20.x that older code and older
181
+ training data get wrong
182
+ - `melonjs-renderables` — custom `Renderable` subclasses, pointer events, post
183
+ effects and the traps in each