melonjs 20.3.0 → 20.5.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 (454) hide show
  1. package/README.md +19 -19
  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 +3 -0
  5. package/build/application/settings.d.ts.map +1 -1
  6. package/build/audio/audio.d.ts.map +1 -1
  7. package/build/audio/backend/engine.d.ts +0 -19
  8. package/build/audio/backend/engine.d.ts.map +1 -1
  9. package/build/audio/backend/sound.d.ts +1 -51
  10. package/build/audio/backend/sound.d.ts.map +1 -1
  11. package/build/audio/backend/spatial.d.ts.map +1 -1
  12. package/build/audio/backend/types.d.ts +11 -1
  13. package/build/audio/backend/types.d.ts.map +1 -1
  14. package/build/audio/backend/voice.d.ts +0 -25
  15. package/build/audio/backend/voice.d.ts.map +1 -1
  16. package/build/audio/playback.d.ts.map +1 -1
  17. package/build/audio/procedural.d.ts +7 -2
  18. package/build/audio/procedural.d.ts.map +1 -1
  19. package/build/audio/state.d.ts +6 -79
  20. package/build/audio/state.d.ts.map +1 -1
  21. package/build/audio/types.d.ts +22 -0
  22. package/build/audio/types.d.ts.map +1 -1
  23. package/build/camera/camera2d.d.ts +28 -68
  24. package/build/camera/camera2d.d.ts.map +1 -1
  25. package/build/camera/camera3d.d.ts +110 -82
  26. package/build/camera/camera3d.d.ts.map +1 -1
  27. package/build/camera/effects/fade_effect.d.ts +0 -5
  28. package/build/camera/effects/fade_effect.d.ts.map +1 -1
  29. package/build/camera/effects/mask_effect.d.ts +0 -5
  30. package/build/camera/effects/mask_effect.d.ts.map +1 -1
  31. package/build/camera/fog.d.ts +118 -0
  32. package/build/camera/fog.d.ts.map +1 -0
  33. package/build/geometries/box3d.d.ts +0 -28
  34. package/build/geometries/box3d.d.ts.map +1 -1
  35. package/build/geometries/ellipse.d.ts +0 -20
  36. package/build/geometries/ellipse.d.ts.map +1 -1
  37. package/build/geometries/observablePoint.d.ts +0 -3
  38. package/build/geometries/observablePoint.d.ts.map +1 -1
  39. package/build/geometries/path2d.d.ts +0 -19
  40. package/build/geometries/path2d.d.ts.map +1 -1
  41. package/build/geometries/polygon.d.ts +7 -13
  42. package/build/geometries/polygon.d.ts.map +1 -1
  43. package/build/geometries/roundrect.d.ts +0 -18
  44. package/build/geometries/roundrect.d.ts.map +1 -1
  45. package/build/geometries/sphere.d.ts +0 -9
  46. package/build/geometries/sphere.d.ts.map +1 -1
  47. package/build/geometries/toarccanvas.d.ts.map +1 -1
  48. package/build/index.d.ts +5 -0
  49. package/build/index.d.ts.map +1 -1
  50. package/build/index.js +3697 -563
  51. package/build/index.js.map +4 -4
  52. package/build/input/gamepad.d.ts.map +1 -1
  53. package/build/input/pointer.d.ts +0 -4
  54. package/build/input/pointer.d.ts.map +1 -1
  55. package/build/input/pointerevent.d.ts +0 -6
  56. package/build/input/pointerevent.d.ts.map +1 -1
  57. package/build/lang/deprecated.d.ts.map +1 -1
  58. package/build/level/gltf/GLTFModel.d.ts +44 -82
  59. package/build/level/gltf/GLTFModel.d.ts.map +1 -1
  60. package/build/level/gltf/GLTFScene.d.ts +1 -44
  61. package/build/level/gltf/GLTFScene.d.ts.map +1 -1
  62. package/build/level/gltf/gltf_sampler.d.ts +1 -48
  63. package/build/level/gltf/gltf_sampler.d.ts.map +1 -1
  64. package/build/level/level.d.ts +195 -113
  65. package/build/level/level.d.ts.map +1 -1
  66. package/build/level/tiled/TMXGroup.d.ts +1 -65
  67. package/build/level/tiled/TMXGroup.d.ts.map +1 -1
  68. package/build/level/tiled/TMXLayer.d.ts +0 -44
  69. package/build/level/tiled/TMXLayer.d.ts.map +1 -1
  70. package/build/level/tiled/TMXObject.d.ts +1 -136
  71. package/build/level/tiled/TMXObject.d.ts.map +1 -1
  72. package/build/level/tiled/TMXObjectFactory.d.ts +1 -40
  73. package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
  74. package/build/level/tiled/TMXTile.d.ts +1 -30
  75. package/build/level/tiled/TMXTile.d.ts.map +1 -1
  76. package/build/level/tiled/TMXTileMap.d.ts +0 -10
  77. package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
  78. package/build/level/tiled/TMXTileset.d.ts +0 -113
  79. package/build/level/tiled/TMXTileset.d.ts.map +1 -1
  80. package/build/level/tiled/TMXTilesetGroup.d.ts +0 -1
  81. package/build/level/tiled/TMXTilesetGroup.d.ts.map +1 -1
  82. package/build/level/tiled/TMXUtils.d.ts +1 -43
  83. package/build/level/tiled/TMXUtils.d.ts.map +1 -1
  84. package/build/level/tiled/factories/shape.d.ts +1 -7
  85. package/build/level/tiled/factories/shape.d.ts.map +1 -1
  86. package/build/level/tiled/factories/text.d.ts +1 -7
  87. package/build/level/tiled/factories/text.d.ts.map +1 -1
  88. package/build/level/tiled/factories/tile.d.ts +1 -7
  89. package/build/level/tiled/factories/tile.d.ts.map +1 -1
  90. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +0 -60
  91. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
  92. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +0 -42
  93. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
  94. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +0 -5
  95. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
  96. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +0 -31
  97. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
  98. package/build/level/tiled/renderer/TMXRenderer.d.ts +2 -2
  99. package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
  100. package/build/level/tiled/renderer/TMXStaggeredRenderer.d.ts.map +1 -1
  101. package/build/level/tiled/renderer/autodetect.d.ts +1 -6
  102. package/build/level/tiled/renderer/autodetect.d.ts.map +1 -1
  103. package/build/lighting/light2d.d.ts +0 -25
  104. package/build/lighting/light2d.d.ts.map +1 -1
  105. package/build/lighting/light3d.d.ts +20 -63
  106. package/build/lighting/light3d.d.ts.map +1 -1
  107. package/build/loader/loader.d.ts +146 -37
  108. package/build/loader/loader.d.ts.map +1 -1
  109. package/build/loader/loadingscreen.d.ts +0 -33
  110. package/build/loader/loadingscreen.d.ts.map +1 -1
  111. package/build/loader/parsers/aseprite.d.ts +0 -13
  112. package/build/loader/parsers/aseprite.d.ts.map +1 -1
  113. package/build/loader/parsers/audio.d.ts +1 -30
  114. package/build/loader/parsers/audio.d.ts.map +1 -1
  115. package/build/loader/parsers/binary.d.ts +1 -10
  116. package/build/loader/parsers/binary.d.ts.map +1 -1
  117. package/build/loader/parsers/compressed_textures/compressed_image.d.ts.map +1 -1
  118. package/build/loader/parsers/compressed_textures/parseDDS.d.ts +1 -7
  119. package/build/loader/parsers/compressed_textures/parseDDS.d.ts.map +1 -1
  120. package/build/loader/parsers/compressed_textures/parseKTX.d.ts +1 -7
  121. package/build/loader/parsers/compressed_textures/parseKTX.d.ts.map +1 -1
  122. package/build/loader/parsers/compressed_textures/parseKTX2.d.ts +1 -7
  123. package/build/loader/parsers/compressed_textures/parseKTX2.d.ts.map +1 -1
  124. package/build/loader/parsers/compressed_textures/parsePKM.d.ts +1 -7
  125. package/build/loader/parsers/compressed_textures/parsePKM.d.ts.map +1 -1
  126. package/build/loader/parsers/compressed_textures/parsePVR.d.ts +1 -7
  127. package/build/loader/parsers/compressed_textures/parsePVR.d.ts.map +1 -1
  128. package/build/loader/parsers/fontface.d.ts +1 -13
  129. package/build/loader/parsers/fontface.d.ts.map +1 -1
  130. package/build/loader/parsers/gltf.d.ts +1 -70
  131. package/build/loader/parsers/gltf.d.ts.map +1 -1
  132. package/build/loader/parsers/image.d.ts +1 -22
  133. package/build/loader/parsers/image.d.ts.map +1 -1
  134. package/build/loader/parsers/json.d.ts +1 -10
  135. package/build/loader/parsers/json.d.ts.map +1 -1
  136. package/build/loader/parsers/mtl.d.ts +1 -28
  137. package/build/loader/parsers/mtl.d.ts.map +1 -1
  138. package/build/loader/parsers/obj.d.ts +1 -59
  139. package/build/loader/parsers/obj.d.ts.map +1 -1
  140. package/build/loader/parsers/pbr.d.ts +1 -62
  141. package/build/loader/parsers/pbr.d.ts.map +1 -1
  142. package/build/loader/parsers/script.d.ts +1 -10
  143. package/build/loader/parsers/script.d.ts.map +1 -1
  144. package/build/loader/parsers/shader.d.ts +1 -52
  145. package/build/loader/parsers/shader.d.ts.map +1 -1
  146. package/build/loader/parsers/tmx.d.ts +1 -10
  147. package/build/loader/parsers/tmx.d.ts.map +1 -1
  148. package/build/loader/parsers/video.d.ts +1 -10
  149. package/build/loader/parsers/video.d.ts.map +1 -1
  150. package/build/math/color.d.ts.map +1 -1
  151. package/build/math/noise.d.ts +0 -40
  152. package/build/math/noise.d.ts.map +1 -1
  153. package/build/math/observableVector2d.d.ts +0 -3
  154. package/build/math/observableVector2d.d.ts.map +1 -1
  155. package/build/math/observableVector3d.d.ts +0 -3
  156. package/build/math/observableVector3d.d.ts.map +1 -1
  157. package/build/math/vector2d.d.ts +0 -6
  158. package/build/math/vector2d.d.ts.map +1 -1
  159. package/build/math/vertex.d.ts +25 -0
  160. package/build/math/vertex.d.ts.map +1 -1
  161. package/build/particles/emitter.d.ts +0 -65
  162. package/build/particles/emitter.d.ts.map +1 -1
  163. package/build/particles/particle.d.ts +0 -81
  164. package/build/particles/particle.d.ts.map +1 -1
  165. package/build/physics/bounds.d.ts +0 -1
  166. package/build/physics/bounds.d.ts.map +1 -1
  167. package/build/physics/broadphase/broadphase.d.ts +0 -7
  168. package/build/physics/broadphase/broadphase.d.ts.map +1 -1
  169. package/build/physics/broadphase/octree.d.ts +0 -91
  170. package/build/physics/broadphase/octree.d.ts.map +1 -1
  171. package/build/physics/broadphase/quadtree.d.ts +0 -47
  172. package/build/physics/broadphase/quadtree.d.ts.map +1 -1
  173. package/build/physics/builtin/body.d.ts +2 -65
  174. package/build/physics/builtin/body.d.ts.map +1 -1
  175. package/build/physics/builtin/detector.d.ts +0 -312
  176. package/build/physics/builtin/detector.d.ts.map +1 -1
  177. package/build/physics/builtin/sat.d.ts +1 -48
  178. package/build/physics/builtin/sat.d.ts.map +1 -1
  179. package/build/physics/builtin/sat3d.d.ts +1 -56
  180. package/build/physics/builtin/sat3d.d.ts.map +1 -1
  181. package/build/physics/collision.d.ts +0 -2
  182. package/build/physics/collision.d.ts.map +1 -1
  183. package/build/physics/response.d.ts +0 -1
  184. package/build/physics/response.d.ts.map +1 -1
  185. package/build/physics/world.d.ts.map +1 -1
  186. package/build/renderable/anchorPoint.d.ts +1 -73
  187. package/build/renderable/anchorPoint.d.ts.map +1 -1
  188. package/build/renderable/animation.d.ts +21 -13
  189. package/build/renderable/animation.d.ts.map +1 -1
  190. package/build/renderable/colorlayer.d.ts +0 -5
  191. package/build/renderable/colorlayer.d.ts.map +1 -1
  192. package/build/renderable/container.d.ts +27 -60
  193. package/build/renderable/container.d.ts.map +1 -1
  194. package/build/renderable/draggable.d.ts +0 -5
  195. package/build/renderable/draggable.d.ts.map +1 -1
  196. package/build/renderable/dragndrop.d.ts +1 -12
  197. package/build/renderable/dragndrop.d.ts.map +1 -1
  198. package/build/renderable/entity/entity.d.ts +0 -8
  199. package/build/renderable/entity/entity.d.ts.map +1 -1
  200. package/build/renderable/frameAnimation.d.ts +0 -41
  201. package/build/renderable/frameAnimation.d.ts.map +1 -1
  202. package/build/renderable/groundshadow.d.ts +1 -91
  203. package/build/renderable/groundshadow.d.ts.map +1 -1
  204. package/build/renderable/imagelayer.d.ts +0 -29
  205. package/build/renderable/imagelayer.d.ts.map +1 -1
  206. package/build/renderable/instanced_mesh.d.ts +55 -108
  207. package/build/renderable/instanced_mesh.d.ts.map +1 -1
  208. package/build/renderable/mesh.d.ts +257 -231
  209. package/build/renderable/mesh.d.ts.map +1 -1
  210. package/build/renderable/nineslicesprite.d.ts +0 -4
  211. package/build/renderable/nineslicesprite.d.ts.map +1 -1
  212. package/build/renderable/renderable.d.ts +18 -44
  213. package/build/renderable/renderable.d.ts.map +1 -1
  214. package/build/renderable/sprite.d.ts +0 -45
  215. package/build/renderable/sprite.d.ts.map +1 -1
  216. package/build/renderable/sprite3d.d.ts +12 -97
  217. package/build/renderable/sprite3d.d.ts.map +1 -1
  218. package/build/renderable/text/bitmaptext.d.ts +32 -21
  219. package/build/renderable/text/bitmaptext.d.ts.map +1 -1
  220. package/build/renderable/text/bitmaptextdata.d.ts +0 -22
  221. package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
  222. package/build/renderable/text/glyph.d.ts +1 -39
  223. package/build/renderable/text/glyph.d.ts.map +1 -1
  224. package/build/renderable/text/text.d.ts +75 -20
  225. package/build/renderable/text/text.d.ts.map +1 -1
  226. package/build/renderable/text/textmetrics.d.ts +2 -0
  227. package/build/renderable/text/textmetrics.d.ts.map +1 -1
  228. package/build/renderable/text/textstyle.d.ts +1 -5
  229. package/build/renderable/text/textstyle.d.ts.map +1 -1
  230. package/build/renderable/trail.d.ts +0 -29
  231. package/build/renderable/trail.d.ts.map +1 -1
  232. package/build/renderable/trigger.d.ts +0 -6
  233. package/build/renderable/trigger.d.ts.map +1 -1
  234. package/build/renderable/ui/uibaseelement.d.ts +0 -40
  235. package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
  236. package/build/renderable/ui/uispriteelement.d.ts +0 -35
  237. package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
  238. package/build/state/stage.d.ts +5 -50
  239. package/build/state/stage.d.ts.map +1 -1
  240. package/build/state/state.d.ts.map +1 -1
  241. package/build/system/device.d.ts +1 -13
  242. package/build/system/device.d.ts.map +1 -1
  243. package/build/system/dom.d.ts +1 -8
  244. package/build/system/dom.d.ts.map +1 -1
  245. package/build/system/legacy_pool.d.ts +1 -6
  246. package/build/system/legacy_pool.d.ts.map +1 -1
  247. package/build/system/platform.d.ts +0 -1
  248. package/build/system/platform.d.ts.map +1 -1
  249. package/build/system/pool.d.ts +0 -9
  250. package/build/system/pool.d.ts.map +1 -1
  251. package/build/system/save.d.ts +44 -1
  252. package/build/system/save.d.ts.map +1 -1
  253. package/build/system/timer.d.ts +0 -20
  254. package/build/system/timer.d.ts.map +1 -1
  255. package/build/tweens/tween.d.ts +0 -62
  256. package/build/tweens/tween.d.ts.map +1 -1
  257. package/build/utils/array-multimap.d.ts +1 -13
  258. package/build/utils/array-multimap.d.ts.map +1 -1
  259. package/build/utils/decode.d.ts.map +1 -1
  260. package/build/utils/fetchdata.d.ts +1 -31
  261. package/build/utils/fetchdata.d.ts.map +1 -1
  262. package/build/utils/utils.d.ts +0 -13
  263. package/build/utils/utils.d.ts.map +1 -1
  264. package/build/video/blendmodes.d.ts +1 -106
  265. package/build/video/blendmodes.d.ts.map +1 -1
  266. package/build/video/buffer/index.d.ts +1 -39
  267. package/build/video/buffer/index.d.ts.map +1 -1
  268. package/build/video/buffer/vertex.d.ts +1 -82
  269. package/build/video/buffer/vertex.d.ts.map +1 -1
  270. package/build/video/canvas/canvas_renderer.d.ts +2 -23
  271. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  272. package/build/video/canvas_factory.d.ts +1 -24
  273. package/build/video/canvas_factory.d.ts.map +1 -1
  274. package/build/video/effects/blendEffect.d.ts +0 -54
  275. package/build/video/effects/blendEffect.d.ts.map +1 -1
  276. package/build/video/effects/colorMatrix.d.ts +0 -10
  277. package/build/video/effects/colorMatrix.d.ts.map +1 -1
  278. package/build/video/effects/glsl_realization.d.ts +1 -17
  279. package/build/video/effects/glsl_realization.d.ts.map +1 -1
  280. package/build/video/effects/mesh_splice.d.ts +2 -0
  281. package/build/video/effects/mesh_splice.d.ts.map +1 -0
  282. package/build/video/effects/radialGradient.d.ts +0 -1
  283. package/build/video/effects/radialGradient.d.ts.map +1 -1
  284. package/build/video/effects/shadereffect.d.ts +12 -241
  285. package/build/video/effects/shadereffect.d.ts.map +1 -1
  286. package/build/video/effects/wgsl/layout.d.ts +1 -27
  287. package/build/video/effects/wgsl/layout.d.ts.map +1 -1
  288. package/build/video/effects/wgsl/parse.d.ts +1 -8
  289. package/build/video/effects/wgsl/parse.d.ts.map +1 -1
  290. package/build/video/effects/wgsl/scaffold.d.ts +1 -42
  291. package/build/video/effects/wgsl/scaffold.d.ts.map +1 -1
  292. package/build/video/effects/wgsl_realization.d.ts +1 -82
  293. package/build/video/effects/wgsl_realization.d.ts.map +1 -1
  294. package/build/video/gpu/batcher.d.ts +1 -13
  295. package/build/video/gpu/batcher.d.ts.map +1 -1
  296. package/build/video/gpu/instancerecord.d.ts +1 -163
  297. package/build/video/gpu/instancerecord.d.ts.map +1 -1
  298. package/build/video/gpu/meshchunk.d.ts +1 -48
  299. package/build/video/gpu/meshchunk.d.ts.map +1 -1
  300. package/build/video/gpu/meshvertex.d.ts +1 -53
  301. package/build/video/gpu/meshvertex.d.ts.map +1 -1
  302. package/build/video/gpu/primitives.d.ts +1 -59
  303. package/build/video/gpu/primitives.d.ts.map +1 -1
  304. package/build/video/gpu/quadcorners.d.ts +1 -10
  305. package/build/video/gpu/quadcorners.d.ts.map +1 -1
  306. package/build/video/gpu/textureslots.d.ts +1 -121
  307. package/build/video/gpu/textureslots.d.ts.map +1 -1
  308. package/build/video/gpu/texturestore.d.ts +1 -138
  309. package/build/video/gpu/texturestore.d.ts.map +1 -1
  310. package/build/video/gpu/topology.d.ts.map +1 -1
  311. package/build/video/gpu/vertexformat.d.ts +0 -28
  312. package/build/video/gpu/vertexformat.d.ts.map +1 -1
  313. package/build/video/gradient.d.ts +15 -77
  314. package/build/video/gradient.d.ts.map +1 -1
  315. package/build/video/renderer.d.ts +21 -102
  316. package/build/video/renderer.d.ts.map +1 -1
  317. package/build/video/renderstate.d.ts +0 -51
  318. package/build/video/renderstate.d.ts.map +1 -1
  319. package/build/video/rendertarget/canvasrendertarget.d.ts +0 -10
  320. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  321. package/build/video/rendertarget/render_target_pool.d.ts +1 -82
  322. package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
  323. package/build/video/rendertarget/webglrendertarget.d.ts +1 -64
  324. package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
  325. package/build/video/rendertarget/webgpurendertarget.d.ts +0 -8
  326. package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -1
  327. package/build/video/texture/atlas.d.ts +1 -75
  328. package/build/video/texture/atlas.d.ts.map +1 -1
  329. package/build/video/texture/cache.d.ts +0 -136
  330. package/build/video/texture/cache.d.ts.map +1 -1
  331. package/build/video/texture/frametexture.d.ts +1 -71
  332. package/build/video/texture/frametexture.d.ts.map +1 -1
  333. package/build/video/texture/noise_texture2d.d.ts +101 -77
  334. package/build/video/texture/noise_texture2d.d.ts.map +1 -1
  335. package/build/video/texture/parser/aseprite.d.ts +1 -8
  336. package/build/video/texture/parser/aseprite.d.ts.map +1 -1
  337. package/build/video/texture/parser/spritesheet.d.ts +1 -8
  338. package/build/video/texture/parser/spritesheet.d.ts.map +1 -1
  339. package/build/video/texture/parser/texturepacker.d.ts +1 -8
  340. package/build/video/texture/parser/texturepacker.d.ts.map +1 -1
  341. package/build/video/texture/resource.d.ts +0 -9
  342. package/build/video/texture/resource.d.ts.map +1 -1
  343. package/build/video/texture/texture2d.d.ts +0 -11
  344. package/build/video/texture/texture2d.d.ts.map +1 -1
  345. package/build/video/utils/autodetect.d.ts +1 -5
  346. package/build/video/utils/autodetect.d.ts.map +1 -1
  347. package/build/video/webgl/batchers/batcher.d.ts +0 -55
  348. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  349. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +0 -14
  350. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
  351. package/build/video/webgl/batchers/lit_quad_batcher.d.ts +0 -72
  352. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  353. package/build/video/webgl/batchers/material_batcher.d.ts +0 -89
  354. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  355. package/build/video/webgl/batchers/mesh_batcher.d.ts +14 -343
  356. package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
  357. package/build/video/webgl/batchers/primitive_batcher.d.ts +0 -10
  358. package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
  359. package/build/video/webgl/batchers/quad_batcher.d.ts +0 -30
  360. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  361. package/build/video/webgl/buffer/index.d.ts +1 -36
  362. package/build/video/webgl/buffer/index.d.ts.map +1 -1
  363. package/build/video/webgl/buffer/instance_buffer.d.ts +1 -53
  364. package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -1
  365. package/build/video/webgl/buffer/retained_geometry.d.ts +1 -81
  366. package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -1
  367. package/build/video/webgl/buffer/uniformblock.d.ts +1 -80
  368. package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -1
  369. package/build/video/webgl/buffer/vertexstate.d.ts +1 -100
  370. package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -1
  371. package/build/video/webgl/glshader.d.ts +7 -51
  372. package/build/video/webgl/glshader.d.ts.map +1 -1
  373. package/build/video/webgl/lighting/pack3d.d.ts +1 -47
  374. package/build/video/webgl/lighting/pack3d.d.ts.map +1 -1
  375. package/build/video/webgl/lighting/std140.d.ts +1 -109
  376. package/build/video/webgl/lighting/std140.d.ts.map +1 -1
  377. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts +1 -103
  378. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  379. package/build/video/webgl/shaders/multitexture-lit.d.ts +1 -26
  380. package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
  381. package/build/video/webgl/shaders/multitexture.d.ts +1 -9
  382. package/build/video/webgl/shaders/multitexture.d.ts.map +1 -1
  383. package/build/video/webgl/texture/store.d.ts +1 -50
  384. package/build/video/webgl/texture/store.d.ts.map +1 -1
  385. package/build/video/webgl/utils/attributes.d.ts +1 -11
  386. package/build/video/webgl/utils/attributes.d.ts.map +1 -1
  387. package/build/video/webgl/utils/maxtextures.d.ts +1 -36
  388. package/build/video/webgl/utils/maxtextures.d.ts.map +1 -1
  389. package/build/video/webgl/utils/precision.d.ts +1 -14
  390. package/build/video/webgl/utils/precision.d.ts.map +1 -1
  391. package/build/video/webgl/utils/program.d.ts +1 -5
  392. package/build/video/webgl/utils/program.d.ts.map +1 -1
  393. package/build/video/webgl/utils/samplercache.d.ts +1 -68
  394. package/build/video/webgl/utils/samplercache.d.ts.map +1 -1
  395. package/build/video/webgl/utils/string.d.ts +1 -21
  396. package/build/video/webgl/utils/string.d.ts.map +1 -1
  397. package/build/video/webgl/utils/topology.d.ts +1 -23
  398. package/build/video/webgl/utils/topology.d.ts.map +1 -1
  399. package/build/video/webgl/utils/uniforms.d.ts +1 -25
  400. package/build/video/webgl/utils/uniforms.d.ts.map +1 -1
  401. package/build/video/webgl/utils/vertexformat.d.ts +1 -26
  402. package/build/video/webgl/utils/vertexformat.d.ts.map +1 -1
  403. package/build/video/webgl/webgl_renderer.d.ts +22 -285
  404. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  405. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts +0 -6
  406. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -1
  407. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +0 -8
  408. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -1
  409. package/build/video/webgpu/batchers/mesh_batcher.d.ts +7 -231
  410. package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
  411. package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -1
  412. package/build/video/webgpu/batchers/quad_batcher.d.ts +0 -82
  413. package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
  414. package/build/video/webgpu/buffer/arena.d.ts +1 -63
  415. package/build/video/webgpu/buffer/arena.d.ts.map +1 -1
  416. package/build/video/webgpu/buffer/instance_buffer.d.ts +1 -64
  417. package/build/video/webgpu/buffer/instance_buffer.d.ts.map +1 -1
  418. package/build/video/webgpu/buffer/retained_geometry.d.ts +1 -54
  419. package/build/video/webgpu/buffer/retained_geometry.d.ts.map +1 -1
  420. package/build/video/webgpu/buffer/uniformring.d.ts +1 -67
  421. package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -1
  422. package/build/video/webgpu/effect_binding.d.ts +1 -16
  423. package/build/video/webgpu/effect_binding.d.ts.map +1 -1
  424. package/build/video/webgpu/pipeline/bindgroups.d.ts +1 -32
  425. package/build/video/webgpu/pipeline/bindgroups.d.ts.map +1 -1
  426. package/build/video/webgpu/pipeline/cache.d.ts +1 -163
  427. package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
  428. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +1 -87
  429. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  430. package/build/video/webgpu/shaders/mesh-instanced.d.ts +1 -43
  431. package/build/video/webgpu/shaders/mesh-instanced.d.ts.map +1 -1
  432. package/build/video/webgpu/texture/compressed.d.ts +1 -32
  433. package/build/video/webgpu/texture/compressed.d.ts.map +1 -1
  434. package/build/video/webgpu/texture/frametexture.d.ts +1 -62
  435. package/build/video/webgpu/texture/frametexture.d.ts.map +1 -1
  436. package/build/video/webgpu/texture/store.d.ts +1 -147
  437. package/build/video/webgpu/texture/store.d.ts.map +1 -1
  438. package/build/video/webgpu/webgpu_renderer.d.ts +1 -88
  439. package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
  440. package/package.json +5 -4
  441. package/skills/melonjs/SKILL.md +1 -1
  442. package/skills/melonjs-3d/SKILL.md +453 -5
  443. package/skills/melonjs-3d-assets/SKILL.md +164 -6
  444. package/skills/melonjs-audio/SKILL.md +38 -0
  445. package/skills/melonjs-camera-and-drawing/SKILL.md +49 -0
  446. package/skills/melonjs-effects-and-shaders/SKILL.md +95 -2
  447. package/skills/melonjs-loading-assets/SKILL.md +127 -2
  448. package/skills/melonjs-performance/SKILL.md +60 -1
  449. package/skills/melonjs-physics/SKILL.md +78 -0
  450. package/skills/melonjs-renderables/SKILL.md +63 -1
  451. package/skills/melonjs-renderer-backends/SKILL.md +19 -0
  452. package/skills/melonjs-scenes-and-state/SKILL.md +56 -0
  453. package/skills/melonjs-tilemaps/SKILL.md +31 -11
  454. package/skills/melonjs-ui-and-text/SKILL.md +131 -117
@@ -81,7 +81,16 @@ Two rules that cause subtle bugs when missed:
81
81
  successfully recycled object never sees it. Pair event subscriptions with
82
82
  `onActivateEvent` / `onDeactivateEvent` instead, or you leak handlers.
83
83
 
84
- Engine classes are poolable too: `pool.pull("me.Tween", target)`.
84
+ Engine classes are poolable too: `pool.pull("Tween", target)`. The canonical
85
+ names are unprefixed — `Entity`, `Collectable`, `Trigger`, `Light2d`,
86
+ `Particle`, `Sprite`, `NineSliceSprite`, `Renderable`, `Text`, `BitmapText`,
87
+ `ImageLayer`, `Tween`, `ColorLayer`.
88
+
89
+ `pool.register` additionally aliases every name under an `me.` prefix, pointing
90
+ at the same entry, so `pool.pull("me.Tween")` resolves identically — and the
91
+ same alias is registered with the Tiled object factory, which is why a map
92
+ authored against melonJS 1.x still finds its classes. Prefer the unprefixed
93
+ name in new code; do not "correct" an `me.`-prefixed one, it is not broken.
85
94
 
86
95
  ## `scale()` is multiplicative
87
96
 
@@ -126,6 +135,11 @@ collapse to one.
126
135
  between a hundred trees and a hundred thousand. glTF scenes using
127
136
  `EXT_mesh_gpu_instancing` load as an `InstancedMesh` automatically.
128
137
 
138
+ It trades per-object control for the draw call: the set gets ONE depth sort key
139
+ and ONE ground shadow, and `removeInstance` swaps the last instance into the
140
+ hole so held indices go stale. Scenery yes; anything the game removes or
141
+ queries one at a time, usually not. See `melonjs-3d` for the decision table.
142
+
129
143
  ## Update loops
130
144
 
131
145
  - `update(dt)` should **return `true` only when something changed**. Returning
@@ -146,6 +160,49 @@ between a hundred trees and a hundred thousand. glTF scenes using
146
160
  GPU release. Images, by contrast, only lose their loader-side reference; the
147
161
  renderer's texture cache is not purged by unloading.
148
162
 
163
+ ## The first frame of a scene is not like the others
164
+
165
+ A freeze the first time a level appears, and never again, is almost always
166
+ **shader linking**, not your scene build. Measure before assuming: procedural
167
+ geometry is usually trivial next to it.
168
+
169
+ Programs are created lazily. The mesh batcher keys a variant on the feature
170
+ combination it is asked for (lit, instanced, instance colours, instance data,
171
+ fog) and links it on the first draw that needs it — and `compileProgram` calls
172
+ `getProgramParameter(LINK_STATUS)` right after `linkProgram`, which blocks until
173
+ the driver finishes. That whole cost lands inside one frame.
174
+
175
+ How to tell them apart, all from the page:
176
+
177
+ ```js
178
+ // 1. is it the build, or the draw? time your own setup
179
+ const t0 = performance.now(); buildLevel(); console.log(performance.now() - t0);
180
+
181
+ // 2. how long is the bad frame? rAF deltas, not averages
182
+ let last = performance.now();
183
+ const tick = () => { const n = performance.now();
184
+ if (n - last > 40) console.log("long frame", (n - last).toFixed(0));
185
+ last = n; requestAnimationFrame(tick); };
186
+
187
+ // 3. is it programs? count them, and when
188
+ const gl = WebGL2RenderingContext.prototype, link = gl.linkProgram;
189
+ gl.linkProgram = function (p) { console.count("linkProgram"); return link.call(this, p); };
190
+ ```
191
+
192
+ The tell is that the second entry into the same scene is cheap: one measured
193
+ case went 852ms of stall (worst frame 479ms) on first entry to 277ms (worst
194
+ 102ms) on the second, because the programs were already cached.
195
+
196
+ Two things follow. Cut the number of programs — identical `ShaderEffect`s each
197
+ link their own, so preload one as a `"shader"` asset and share it. And pay what
198
+ remains behind the loading screen by drawing the scene once there and discarding
199
+ it (see `melonjs-loading-assets`).
200
+
201
+ Do not profile this on a software rasterizer — headless Chromium falls back to
202
+ SwiftShader, where the absolute numbers are wildly pessimistic and the JS
203
+ profile shows the time as `(program)`, outside JS entirely. Ratios transfer;
204
+ milliseconds do not.
205
+
149
206
  ## Where the costs actually are
150
207
 
151
208
  In rough order for a typical 2D game:
@@ -170,6 +227,8 @@ In rough order for a typical 2D game:
170
227
  | everything updates even when idle | `update()` returning `true` unconditionally |
171
228
  | memory grows with long music | missing `stream: true` |
172
229
  | slow only on some machines | Canvas fallback — no GPU tilemap path |
230
+ | a freeze the first time a level shows, never again | shader variants linking on first draw — warm them behind the loading screen |
231
+ | the same scene stutters once per entry | a derived texture rebuilt per stage: the texture cache keys on the image object, so each rebuild is a new upload |
173
232
 
174
233
  ## Related skills
175
234
 
@@ -120,6 +120,19 @@ this.body.setVelocity(vx, vy);
120
120
  this.body.force.x = this.body.maxVel.x;
121
121
  ```
122
122
 
123
+ `maxVel` is what turns a force into a speed, so the two are set together. Use
124
+ the setters rather than writing the vectors — both take an optional THIRD
125
+ argument for the depth axis, left unchanged when omitted, so a 2D call keeps
126
+ its behaviour:
127
+
128
+ ```js
129
+ this.body.setMaxVelocity(3, 15); // walk speed, jump speed
130
+ this.body.setFriction(0.4, 0); // ground drag, none vertically
131
+ ```
132
+
133
+ `friction` here is per-axis per-step velocity damping, not a surface
134
+ coefficient — see the built-in quirks below.
135
+
123
136
  Under matter and planck, `syncFromPhysics()` copies the engine body's position
124
137
  back onto `renderable.pos` after every step, so a direct write is simply erased
125
138
  — no error. The built-in world integrates `pos` in place instead, so a write
@@ -227,6 +240,69 @@ Two prerequisites that produce empty results rather than errors:
227
240
  - On the **built-in** adapter, the broadphase is cleared and rebuilt inside
228
241
  `world.update()`, so querying before the first update returns nothing.
229
242
 
243
+ ## 3D collision: `Box3d` and the Z pushback
244
+
245
+ The narrowphase is not 2D-only. `Box3d` is the one shape with a depth extent,
246
+ and a `Box3d`-vs-`Box3d` contact is resolved in three dimensions — it is the
247
+ only pair in the engine that can push back along **Z**.
248
+
249
+ ```js
250
+ import { Box3d } from "melonjs";
251
+
252
+ // centre offset from the body, then half-extents on each axis
253
+ rock.body.addShape(new Box3d(0, 0, 0, 40, 60, 40));
254
+ boat.body.addShape(new Box3d(0, 0, 0, 30, 40, 60));
255
+ ```
256
+
257
+ Reach for this for anything moving in the XZ plane under a `Camera3d` — a
258
+ runner dodging obstacles, a 2.5D platformer, pickups on a course. Hand-rolling
259
+ a distance check there is the usual mistake, and it throws away the
260
+ penetration vector the response already carries.
261
+
262
+ **Read the Z axis off the response, not `overlapN`.** The MTV is a single
263
+ axis, so exactly one of `overlapN.x`, `overlapN.y` and `overlapNZ` is
264
+ non-zero:
265
+
266
+ ```js
267
+ onCollision(response, other) {
268
+ if (response.overlapNZ !== 0) {
269
+ // a depth-only contact: overlapN / overlapV are BOTH zero here
270
+ this.pos.z -= response.overlapZ;
271
+ }
272
+ return true;
273
+ }
274
+ ```
275
+
276
+ That is deliberate: a collision resolved along Z leaves the 2D fields at zero,
277
+ so an existing 2D `onCollision` applies no push rather than a wrong one.
278
+
279
+ **Mixed pairs degrade to 2D.** `Box3d` against a `Polygon`, `Rectangle`,
280
+ `RoundRect` or `Ellipse` tests the box's XY footprint and treats the planar
281
+ shape as unbounded along Z. Only `Box3d`-vs-`Box3d` gives a depth result, so
282
+ give BOTH sides a `Box3d` when you want one.
283
+
284
+ This is the narrowphase and is independent of the 3D broadphase queries above
285
+ — `querySphere` / `raycast3d` need `world.sortOn === "depth"`; `Box3d` shapes
286
+ do not.
287
+
288
+ **Bounds are what the broadphase sorts by, and they come from the SHAPE.**
289
+ Every item is filed by its renderable's 2D `getBounds()`, so an object with no
290
+ extent cannot be placed and silently collides with nothing. A `Mesh` takes its
291
+ extent from its geometry and a `GLTFModel` from its part meshes, so both report
292
+ where they are without being told. A body's shapes do **not** contribute, so a
293
+ custom collidable built on a bare `Container` has no extent until you give it
294
+ one:
295
+
296
+ ```js
297
+ // a container reports an EMPTY bounds until it has a size of its own
298
+ group.resize(width, height);
299
+ ```
300
+
301
+ `enableChildBoundsUpdate` also gives it one, but it re-measures the whole child
302
+ list on every update — reach for it only when the extent genuinely IS the
303
+ members' union and moves with them (a flock, a squad), not to give a fixed
304
+ group a size.
305
+
230
306
  ## Built-in world quirks
231
307
 
232
308
  These are specific to the default world and surprise people arriving from a
@@ -308,6 +384,8 @@ use them. `adapter.capabilities` (`constraints`,
308
384
  | crash or a null body when spawning from `onCollisionStart` | world mutated during contact dispatch (locked world under planck) |
309
385
  | `raycast` / `queryAABB` finds nothing | `isKinematic` still `true`, or no `world.update` yet (built-in) |
310
386
  | `querySphere` / `raycast3d` is not a function | 2D adapter, or built-in without a 3D broadphase (`sortOn !== "depth"`) |
387
+ | a 3D contact reports no overlap to push against | read `overlapNZ` / `overlapZ` — a Z-axis MTV leaves `overlapN` / `overlapV` at zero |
388
+ | two 3D objects never separate in depth | one of them carries a planar shape; a mixed pair is tested as the box's XY footprint, unbounded along Z |
311
389
  | `response.depth` / `response.normal` are `undefined` | reading a legacy `onCollision` response — it carries `overlap` / `overlapN` |
312
390
  | `onCollisionEnd` handler throws on `response` | built-in dispatches it with `undefined` |
313
391
  | off-screen bodies stop simulating | built-in gating on `inViewport`; set `alwaysUpdate` |
@@ -145,7 +145,36 @@ at `enabled === false` and no-ops every method rather than throwing — and
145
145
  backend at runtime, an effect that works on your machine may do nothing on
146
146
  another.
147
147
 
148
- ## 5. `Vector3d.set(x, y)` silently zeroes `z`
148
+ ## 5. Opacity cascades; `setChildsProperty` assigns
149
+
150
+ `alpha` composes down the tree. Fading a container fades everything inside
151
+ it, and the values multiply — a child at `0.5` inside a parent at `0.5` draws
152
+ at `0.25`. Each renderable keeps its own value; the composition happens at
153
+ draw time and is undone when the renderable is finished.
154
+
155
+ ```js
156
+ model.alpha = 0.3; // fades the whole rig
157
+ container.setChildsProperty("alpha", 0.3, true); // REWRITES each child's alpha
158
+ ```
159
+
160
+ The two are not interchangeable. `setChildsProperty` is a bulk assignment: it
161
+ changes what the children *are*, so their own `alpha` now reads `0.3` and
162
+ stays that way after the container goes back to full. Reach for it when you
163
+ mean to change the children, and for `alpha` when you mean to fade a subtree.
164
+
165
+ Do not assign alpha down a hierarchy by hand. The renderer composes it as it
166
+ walks the tree, so setting it at more than one level multiplies: in a rig
167
+ nested three deep, `0.3` applied at every level lands parts on `0.3`, `0.09`
168
+ and `0.027` depending where they sit. The symptom does not look like an
169
+ opacity problem — a model whose parts hold *different* opacities, and which
170
+ appears to change opacity as it turns, because turning changes which parts
171
+ face the camera.
172
+
173
+ A useful consequence: a `GLTFModel` is a `Container`, so `model.alpha` fades
174
+ every part of a loaded rig — which is what you want for a ghost, a fade-in,
175
+ or a reflection.
176
+
177
+ ## 6. `Vector3d.set(x, y)` silently zeroes `z`
149
178
 
150
179
  ```js
151
180
  v.set(10, 20); // z becomes 0, not "unchanged"
@@ -155,6 +184,37 @@ v.set(10, 20, v.z); // keep it
155
184
  `pos` is an `ObservableVector3d`, whose `set(x = 0, y = 0, z = 0)` does the same
156
185
  — so `this.pos.set(x, y)` wipes the object's depth.
157
186
 
187
+ ## 7. A settings key the class never reads is silently ignored
188
+
189
+ A settings object is a plain literal: nothing rejects a key, so a name that
190
+ belongs somewhere else does nothing at all and says nothing about it.
191
+
192
+ ```js
193
+ // WRONG — only the RENDERER reads a `blendMode` setting, never a renderable
194
+ const glow = new Sprite3d(x, y, { image: "sun", blendMode: "additive" });
195
+
196
+ // right: it is a property
197
+ glow.blendMode = "additive";
198
+ ```
199
+
200
+ The same shape catches `transparent` on a `GLTFModel` (its parts carry it —
201
+ `model.setChildsProperty("transparent", true, true)`) and any `Mesh` setting
202
+ handed to a class that forwards only a curated subset. If a visual option
203
+ appears to do nothing, check whether the class actually reads it before
204
+ tuning the value.
205
+
206
+ ## 8. `isRenderable` does not hide anything
207
+
208
+ It gates `updateBounds`, not drawing. Setting it `false` leaves the object on
209
+ screen and merely stops its bounds tracking, which is worse than doing nothing.
210
+
211
+ ```js
212
+ sprite.isRenderable = false; // WRONG — still drawn, bounds now stale
213
+ sprite.alpha = 0; // hides it
214
+ ```
215
+
216
+ Use `alpha` for a blink, or remove the child for a long absence.
217
+
158
218
  ## Update and draw
159
219
 
160
220
  ```js
@@ -207,6 +267,8 @@ Hand-rolled equivalents miss the batching and the multi-backend support.
207
267
  | custom draw offset by half the size | centred `anchorPoint` default not zeroed |
208
268
  | spatial query never finds an object | `isKinematic` left `true` — not in the broadphase |
209
269
  | `z` unexpectedly 0 after a `set` | `Vector3d.set(x, y)` defaults `z` to 0 |
270
+ | a settings option appears to do nothing | the class never reads that key — see section 7 |
271
+ | `isRenderable = false` did not hide the object | it gates bounds, not drawing — use `alpha` |
210
272
 
211
273
  ## Related skills
212
274
 
@@ -132,6 +132,14 @@ event.on(event.ONCONTEXT_RESTORED, (renderer) => {
132
132
  });
133
133
  ```
134
134
 
135
+ ## Test on the backend your users get, not the one your harness picks
136
+
137
+ `video.AUTO` prefers WebGPU where it exists. Headless Chromium usually has no
138
+ GPU adapter and falls back to WebGL, so an automated suite can pass every run
139
+ while the WebGPU path is broken — the two differ in real, throwing ways (see
140
+ below). Pin the backend explicitly when it matters: `renderer: video.WEBGPU`,
141
+ or the `#webgpu` / `#webgl` URI fragment on a page you can open by hand.
142
+
135
143
  ## Practical differences
136
144
 
137
145
  - **Frame capture orientation differs**: row 0 of a `toFrameTexture()` capture is
@@ -147,6 +155,15 @@ event.on(event.ONCONTEXT_RESTORED, (renderer) => {
147
155
  accents, ruinous for hundreds of objects. `normal`, `additive`, `multiply`,
148
156
  `screen` and `exclusion` are ordinary fixed-function state and cost nothing
149
157
  extra.
158
+ - **WebGPU rejects a zero-sized image source; WebGL shrugs at it.** Uploading a
159
+ 0-width or 0-height canvas throws
160
+ `OperationError: GPUQueue.copyExternalImageToTexture: External image state is
161
+ not valid`, from a stack that reads `drawImage → addQuad → getBinding`. WebGL
162
+ uploads the same source without complaint, so this is a class of bug that
163
+ cannot appear on one backend and stops the game dead on the other. The usual
164
+ source is a `Text` whose string is empty or whitespace-only — it measures to
165
+ nothing, so its glyph canvas has no width. Give a placeholder label a real
166
+ glyph and hide it with `alpha`/position instead of blanking its text.
150
167
  - **3D meshes do not honour blend modes.** The mesh pass draws with its own
151
168
  depth/blend state; asking for one of the advanced modes logs a one-time
152
169
  `blend mode "…" is not supported for 3D meshes` warning and falls back to
@@ -163,6 +180,8 @@ event.on(event.ONCONTEXT_RESTORED, (renderer) => {
163
180
  | a solid box where an effect should be | carrier drawn while the effect is disabled |
164
181
  | nothing renders at all on an old device | `video.WEBGL` pinned; WebGL 1 is rejected, not downgraded |
165
182
  | ported shader is vertically flipped | the WebGL capture is bottom-up, the WebGPU one top-down |
183
+ | `copyExternalImageToTexture: External image state is not valid` | a zero-sized upload source — most often a `Text` with an empty or whitespace-only string |
184
+ | runs on the test machine, dies on the dev's | the harness fell back to WebGL and never exercised WebGPU |
166
185
  | a blended mode is ignored on a mesh | meshes fall back to `"normal"`; look for the one-time warning |
167
186
  | textures vanish after the tab is restored | cached raw GPU handles not re-acquired on context restore |
168
187
 
@@ -74,6 +74,45 @@ app.freeze(150); // brief hit-stop (proxies state.fr
74
74
  `state.change`. The `"mask"` form needs its fourth argument, an `Ellipse` or
75
75
  `Polygon`; without one it warns and falls back to a direct switch.
76
76
 
77
+ ### A Stage's own `update()` is NOT paused
78
+
79
+ This one is easy to get wrong and hard to see. `Application.update` calls both
80
+ of these **unconditionally**:
81
+
82
+ ```js
83
+ this.isDirty = this.world.update(this.updateDelta);
84
+ this.isDirty = state.current().update(this.updateDelta) || this.isDirty;
85
+ ```
86
+
87
+ Only `Container.update` consults the pause — it reads `state.isPaused()` and
88
+ skips every child that is not `updateWhenPaused`. So world children (entities,
89
+ sprites, meshes, a `GLTFModel`) freeze correctly, while **the Stage subclass's
90
+ own `update()` keeps running**.
91
+
92
+ A game that keeps its logic in entities pauses for free and never notices. A
93
+ game that drives the simulation from `Stage.update` — common for an endless
94
+ runner, where one object moves and the world scrolls past it — keeps simulating
95
+ through `pauseOnBlur` with its world frozen. The signature is bizarre and very
96
+ misleading: the scenery scrolls on, the player character stands still in world
97
+ space and slides off the screen, and it all snaps back on focus. It reads as a
98
+ culling or animation bug, not a pause bug.
99
+
100
+ Guard it explicitly:
101
+
102
+ ```js
103
+ update(dt) {
104
+ super.update(dt);
105
+ if (state.isPaused()) {
106
+ return true; // world children are already frozen for you
107
+ }
108
+ // …simulation…
109
+ }
110
+ ```
111
+
112
+ Worth knowing that `pauseOnBlur` (default `true`) fires on a window `blur`, not
113
+ only on tab `visibilitychange` — so clicking another window on the same screen
114
+ triggers it while the canvas is still fully visible.
115
+
77
116
  ## The update loop
78
117
 
79
118
  There is no loop you own. Logic goes in `update(dt)` overrides, or a
@@ -160,6 +199,21 @@ save.add({ hiscore: 0 }); // once; idempotent, loads any stored value
160
199
  save.hiscore = 1200; // plain assignment writes to localStorage
161
200
  ```
162
201
 
202
+ **In TypeScript, keep what `add()` returns.** The namespace carries a
203
+ `[key: string]: unknown` index for keys registered anywhere, so reading
204
+ `save.hiscore` off it gives you `unknown`. `add()` hands back the same
205
+ namespace typed with the keys you just registered, which is the handle to
206
+ keep:
207
+
208
+ ```ts
209
+ const store = save.add({ hiscore: 0, lives: 3 });
210
+ store.hiscore = 1200; // number, no cast
211
+ if (score > store.hiscore) { /* ... */ }
212
+ ```
213
+
214
+ Chained calls accumulate, so `save.add({ a: 0 }).add({ b: "" })` is typed with
215
+ both.
216
+
163
217
  ## Symptom → cause
164
218
 
165
219
  | symptom | cause |
@@ -169,6 +223,8 @@ save.hiscore = 1200; // plain assignment writes to localStorage
169
223
  | a tween finishes in 1000 ms whatever you pass | `to()` takes `{ duration }`, not a number |
170
224
  | object frozen while its state updates | `update()` not returning `true` |
171
225
  | timers fire behind a pause menu | `window.setTimeout` instead of `timer.setTimeout` |
226
+ | the world freezes on blur but the game keeps advancing | simulation lives in `Stage.update`, which the pause does not gate — only `Container.update` checks `state.isPaused()` |
227
+ | the player character is left behind and scrolls off after a lost window | same cause: the stage advanced the camera while its world children were paused |
172
228
  | a tween does nothing | `.start()` never called |
173
229
  | effect stops during a hit-stop | tween needs `updateWhenPaused = true` |
174
230
  | crash after a stage switch | callback ran during teardown — guard with `state.isCurrent` |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: melonjs-tilemaps
3
- description: "Use this skill for Tiled maps in melonJS — loading TMX/TSX levels, spawning entities from Tiled objects, collision shapes authored in Tiled, isometric and hexagonal maps, and image layers. Covers the pool.register name contract, camera bounds, compressed maps needing the inflate plugin, and the level director API. Triggers on: Tiled, TMX, TSX, tilemap, level.load, tileset, ImageLayer, isometric, hexagonal, staggered, pool.register, Collectable, Trigger, object layer, collision layer, parallax."
3
+ description: "Use this skill for Tiled maps in melonJS — loading TMX/TSX levels, spawning entities from Tiled objects, collision shapes authored in Tiled, isometric and hexagonal maps, and image layers. Covers the pool.register name contract, camera bounds, compressed maps needing the inflate plugin, and the level director API. Triggers on: Tiled, TMX, TSX, tilemap, level.load, level.load async, await level.load, tileset, ImageLayer, isometric, hexagonal, staggered, pool.register, Collectable, Trigger, object layer, collision layer, parallax."
4
4
  license: MIT
5
5
  ---
6
6
 
@@ -33,18 +33,37 @@ also skip `src` and pass the map inline via `data` (with `format: "json"` or
33
33
  `"xml"`).
34
34
 
35
35
  `level.load(levelId, options)` accepts `container` (default `game.world`),
36
- `onLoaded` (default `game.onLevelLoaded`), `flatten` (default `game.mergeGroup`)
37
- and `setViewportBounds` (default **`true`**). It throws `level <id> not found`
38
- for an unknown id.
36
+ `onLoaded` (default `game.onLevelLoaded`), `flatten` (default `game.mergeGroup`),
37
+ `setViewportBounds` (default **`true`**) and `async` (default `false`). It throws
38
+ `level <id> not found` for an unknown id — synchronously, in both forms, because
39
+ that is a typo rather than a load failure.
39
40
 
40
41
  **`level.load` is deferred while the game loop is running.** It calls
41
- `state.stop()` and finishes the load in a `setTimeout`, so it returns `true`
42
- before anything is in the world. Do follow-up work from the `onLoaded` callback
43
- or an `event.LEVEL_LOADED` listener, not on the next line.
42
+ `state.stop()` and finishes the load on a timer, after the current frame, so by
43
+ default it returns `true` before anything is in the world. Two ways to sequence
44
+ work after it:
44
45
 
45
- `level.reload()`, `level.next()`, `level.previous()`, `level.getCurrentLevelId()`
46
- and `level.levelCount()` round out the namespace. `flatten: false` wraps each
47
- Tiled object group in its own `Container` named after the group.
46
+ ```js
47
+ // await it
48
+ await level.load("map1", { async: true });
49
+ // the world is populated here
50
+
51
+ // ...or use the callback / event, which fire in both forms
52
+ level.load("map1", { onLoaded: () => this.spawnPlayer() });
53
+ ```
54
+
55
+ `async: true` is the only thing that changes the return value — everything else
56
+ behaves identically, `onLoaded` included. Without it the call returns a boolean,
57
+ so `await level.load("map1")` is not an error and does not await the load:
58
+ `await true` resolves immediately, while the load is still sitting on a timer.
59
+ Pass the flag when you mean to await.
60
+
61
+ `level.reload()`, `level.next()` and `level.previous()` take the same `async`
62
+ option and resolve the same value they return — so `if (level.next())` becomes
63
+ `if (await level.next({ async: true }))`. Running out of levels reports `false`
64
+ either way rather than throwing. `level.getCurrentLevelId()` and
65
+ `level.levelCount()` round out the namespace. `flatten: false` wraps each Tiled
66
+ object group in its own `Container` named after the group.
48
67
 
49
68
  ## Spawning entities from Tiled objects
50
69
 
@@ -177,7 +196,8 @@ unanimated layer into the offscreen-bake path instead.
177
196
  | symptom | cause |
178
197
  |---|---|
179
198
  | a Tiled object becomes a plain shape with no behaviour | its class/name does not match any registered factory, or it was registered after `level.load` |
180
- | the world is still empty right after `level.load` | the load is deferred via `setTimeout` while the loop runs — use `onLoaded` / `LEVEL_LOADED` |
199
+ | the world is still empty right after `level.load` | the load is deferred to a timer while the loop runs — `await level.load(id, { async: true })`, or use `onLoaded` / `LEVEL_LOADED` |
200
+ | `await level.load(id)` returned `true` rather than a promise | without `async: true` the call returns a boolean; `await true` resolves immediately and the load has not run yet — pass the flag when you mean to await |
181
201
  | `level <id> not found` | the map was never preloaded, or the asset `name` differs from the id passed to `load` |
182
202
  | `unknown or invalid resource type` | asset `type` set to `"tmj"` / `"tsj"` — use `"tmx"` / `"tsx"` with the `.tmj` / `.tsj` file |
183
203
  | camera will not scroll | `setViewportBounds: false`, or the map was added with `addTo()` (which defaults to `false`) |