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,160 @@
1
+ ---
2
+ name: melonjs-20-migration
3
+ description: "Use this skill when writing melonJS code that may be based on pre-20.x knowledge, when migrating a game from melonJS 19.x or earlier, or when an API you expected does not exist. Covers the mandatory async Application.init(), the WebGL 2 baseline and WebGPU backend, renderable post effects replacing the shader property, and the deprecated exports still present. Triggers on: migration, upgrade, melonJS 19, me.game, me.video.init, renderable.shader, Compositor, CanvasTexture, me.Math, deprecated."
4
+ license: MIT
5
+ ---
6
+
7
+ # Migrating to melonJS 20.x
8
+
9
+ > What changed in melonJS 20.x, and which older APIs are gone, deprecated, or
10
+ > renamed. Read this before writing melonJS code from memory — much of what is
11
+ > published about melonJS predates 20.0.
12
+
13
+ **Why this skill exists:** most melonJS material in circulation describes 19.x or
14
+ earlier. Code written from that knowledge looks correct and fails at runtime.
15
+ The items below are ordered by how likely they are to be reproduced from memory.
16
+
17
+ ## 1. `Application.init()` is mandatory and asynchronous
18
+
19
+ Since 20.0, constructing an `Application` no longer initialises it.
20
+
21
+ ```js
22
+ // ✗ pre-20.x — the constructor called init(width, height, options) for you
23
+ const app = new Application(800, 600, { parent: "screen" });
24
+ app.world.addChild(sprite); // added, but nothing ever renders
25
+
26
+ // ✓ 20.x
27
+ const app = new Application(800, 600, { parent: "screen" });
28
+ await app.init(); // REQUIRED
29
+ app.world.addChild(sprite);
30
+ ```
31
+
32
+ `init()` is async because acquiring a WebGPU device is async. There is no
33
+ synchronous alternative, and no automatic fallback that papers over the missing
34
+ call. Nothing that then breaks names it: the constructor still builds
35
+ `app.world`, so children can be added and simply never draw — no canvas is
36
+ appended, the app never subscribes to the frame tick, and `app.renderer` /
37
+ `app.viewport` stay `undefined` — while constructing a `Sprite` or `Text` first
38
+ throws a `TypeError` on the unset global `game` instead.
39
+
40
+ The signature changed too: 19.x took `init(width, height, options)`, 20.x takes
41
+ none, and anything passed is ignored (settings come from the constructor).
42
+
43
+ **`video.init(...)` no longer exists.** The `video` module now exports only the
44
+ four renderer constants (`AUTO`, `CANVAS`, `WEBGL`, `WEBGPU`) — there is no
45
+ `init` on it to call. Any code shaped like `me.video.init(800, 600, {...})` is
46
+ from a removed API. Build an `Application` and await `init()`.
47
+
48
+ Note that `import * as me from "melonjs"` still works, so `me.Sprite` style is
49
+ fine. It is the *globals bootstrap* that is gone, not the namespace import.
50
+
51
+ ## 2. Post effects replaced the `shader` property
52
+
53
+ `renderable.shader = …` is **deprecated since 19.2.0**. Use the post-effect API:
54
+
55
+ ```js
56
+ // ✗ deprecated
57
+ mySprite.shader = new ShaderEffect(app.renderer, glslBody);
58
+
59
+ // ✓
60
+ mySprite.addPostEffect(new ShaderEffect(app.renderer, glslBody));
61
+ ```
62
+
63
+ Related trap: **`removePostEffect()` destroys the effect** — and so does
64
+ assigning `renderable.shader`, which destroys whatever it replaces. Only an
65
+ effect carrying `shared = true` is spared. To turn one off temporarily, toggle
66
+ `effect.enabled` instead: remove-and-re-add hands you back an object whose GPU
67
+ resources have already been freed.
68
+
69
+ ## 3. WebGL 2 is the baseline; WebGPU is the default attempt
70
+
71
+ `video.AUTO` now tries **WebGPU → WebGL 2 → Canvas**. WebGL 1 is gone.
72
+
73
+ Consequences:
74
+
75
+ - Which backend runs is a runtime fact. Do not write code that assumes WebGL.
76
+ - Custom shaders can carry both GLSL and WGSL in one asset, so one effect runs
77
+ on either GPU backend.
78
+ - Features needing a programmable pipeline are inert on Canvas and warn once
79
+ rather than throwing.
80
+
81
+ ## 4. Deprecated exports still present
82
+
83
+ These resolve but should not be used in new code:
84
+
85
+ | deprecated | since | use instead |
86
+ |---|---|---|
87
+ | `CanvasTexture` | 17.1.0 | `CanvasRenderTarget` |
88
+ | `Compositor` | 18.1.0 | `WebGLBatcher` |
89
+ | `PrimitiveCompositor` | 18.1.0 | `PrimitiveBatcher` |
90
+ | `QuadCompositor` | 18.1.0 | `QuadBatcher` |
91
+ | `Math` (capitalised) | 18.0.0 | `math` (lowercase) |
92
+ | `device.requestFullscreen` / `exitFullscreen` | 19.7.0 | `app.requestFullscreen()` / `app.exitFullscreen()` |
93
+ | `renderable.shader = …` | 19.2.0 | `addPostEffect()` |
94
+ | `Entity` | 18.1.0 | `Sprite` / `Renderable` + a `Body` |
95
+ | `loader.onload` / `onProgress` / `onError` | 18.2.0, **removed 20.3** | the `LOADER_*` events, or `preload(assets, onloadcb)` |
96
+ | `response.overlap` / `overlapN` / `overlapV` | — | `response.depth` / `response.normal` |
97
+ | `setLineWidth()` | 17.3.0 | the `lineWidth` property |
98
+
99
+ Two of these deserve emphasis:
100
+
101
+ - **`Entity`** is still exported, so code using it compiles and runs while being
102
+ the wrong shape for 20.x. Compose a `Sprite`/`Renderable` with a `Body`
103
+ instead.
104
+ - **The capitalised `Math`** shadows the global `Math` if imported carelessly.
105
+ `me.Math.random()` from older docs resolves to the deprecated re-export.
106
+
107
+ ## 5. The global `game` is not the modern shape
108
+
109
+ `game` is still exported, but since 20.0 it names the most recently
110
+ **initialized** `Application` and is `undefined` until the first `init()`
111
+ resolves — so anything reading it at module scope gets `undefined`. Take the
112
+ `Application` instance as a parameter instead: `Stage#onResetEvent` and
113
+ `onDestroyEvent` are handed it, and any renderable can reach it through
114
+ `parentApp`.
115
+
116
+ ## 6. Node and SSR
117
+
118
+ melonJS imports cleanly under Node — useful for isomorphic apps and for tooling.
119
+ It has **no runtime dependencies** as of 20.3. Do not add polyfills for
120
+ `globalThis`, `String.trimStart` or `String.trimEnd`: the published bundle
121
+ targets ES2022, so every environment that can parse it already has them.
122
+
123
+ ## 7. Browser support
124
+
125
+ The published bundle targets **ES2022** and uses private class members. A browser
126
+ that predates that cannot parse the file at all — it fails at load, not when a
127
+ feature is used. Transpile if you need older browsers, and note that transpiling
128
+ handles *syntax* only: built-in methods need separate polyfills, which a
129
+ bundler's `target` setting will never add.
130
+
131
+ ## The shipped examples are not all current
132
+
133
+ The examples in this repository are the best reference for how melonJS is
134
+ assembled, but a few contain stale comments or legacy calls. Do not learn these
135
+ from them:
136
+
137
+ - `webgpu/` has a comment claiming *"`video.AUTO` never selects the WebGPU
138
+ backend"*. That is pre-20 leftover — AUTO tries WebGPU **first**. The code is
139
+ right; the comment is wrong.
140
+ - Several examples assign `viewport.shader = …` / `sprite.shader = …`, which is
141
+ deprecated. `addPostEffect()` is current.
142
+ - Five files set `this.z = Number.POSITIVE_INFINITY` on a HUD. That property
143
+ does not exist; those HUDs draw on top only because they are added last.
144
+ - `platformer/entities/player.ts` reads `response.overlapV`, the deprecated
145
+ field. Use `response.depth` / `response.normal`.
146
+ - Particle speeds tuned before 20.2 look wrong now: the particle transform fix
147
+ changed how far a burst travels, and emitters were retuned upward to match.
148
+
149
+ ## Checklist when code "should work" but doesn't
150
+
151
+ 1. Is `await app.init()` there?
152
+ 2. Is the code assuming WebGL when it might be running on Canvas or WebGPU?
153
+ 3. Is it using `renderable.shader =` instead of `addPostEffect()`?
154
+ 4. Is it importing a deprecated symbol from the table above?
155
+ 5. Is it referencing a global `game`?
156
+
157
+ ## Related skills
158
+
159
+ - `melonjs-getting-started` — the correct 20.x bootstrap in full
160
+ - `melonjs-renderables` — post effects, pointer events and custom draw code
@@ -0,0 +1,525 @@
1
+ ---
2
+ name: melonjs-3d
3
+ description: "Use this skill for anything 3D or 2.5D in melonJS — Camera3d, Mesh, InstancedMesh, Sprite3d billboards, Light3d, ground shadows, glTF/GLB scenes, and depth sorting. Covers the Y-down/+Z-forward convention that is the inverse of OpenGL, the cameraClass opt-in, clip planes, and what does not work on the Canvas fallback. Triggers on: Camera3d, Mesh, InstancedMesh, Sprite3d, Light3d, billboard, glTF, glb, 3D, 2.5D, depth, cameraClass, fov, setClipPlanes, setFog, fog, distance fog, height fog, heightFalloff, transparent, transparency, alpha, blendMode, fade, castGroundShadow, lit."
4
+ license: MIT
5
+ ---
6
+
7
+ # 3D and 2.5D in melonJS
8
+
9
+ > melonJS is a 2D engine that grew a real 3D tier: perspective cameras, meshes,
10
+ > instancing, glTF scenes and 3D lights. Most of what a model "knows" about 3D
11
+ > graphics comes from the OpenGL convention, and **melonJS's is the inverse**.
12
+ > Read the conventions section before writing any 3D code.
13
+
14
+ ## Coordinate conventions — the inverse of OpenGL
15
+
16
+ This is the single most important thing on this page.
17
+
18
+ | | melonJS | OpenGL convention |
19
+ |---|---|---|
20
+ | vertical | **Y-down** — higher `y` is *lower* on screen | Y-up |
21
+ | depth | **+Z forward** — higher `z` is *farther* away | −Z forward |
22
+
23
+ Rotations are extrinsic XYZ. `Camera3d` exposes two of the three: `camera.pitch`
24
+ (X, look up/down) and `camera.yaw` (Y, look left/right). **There is no `roll`**;
25
+ neither camera applies a Z-axis bank to the view, so assigning one does nothing.
26
+
27
+ The payoff is that 2D code translates directly — anywhere you used `pos.x` /
28
+ `pos.y`, add `pos.z` and the maths still holds. The cost is that every
29
+ OpenGL-shaped instinct is backwards.
30
+
31
+ **Consequence that bites immediately:** "behind everything" is the *largest*
32
+ depth when the camera looks along +Z. Put a backdrop on the wrong side and it
33
+ either paints over the whole scene (it is nearer than everything else) or
34
+ disappears without trace (it falls in front of the near plane and the GPU clips
35
+ it). Which sign means "far" depends on which side the camera sits, so check the
36
+ camera before picking a backdrop depth.
37
+
38
+ glTF assets are authored Y-up right-handed. `level.load` converts them by
39
+ rotation (`rightHanded: true` is its default), so you do not apply a flip
40
+ yourself. The **`Mesh` constructor defaults `rightHanded` to `false`**, which
41
+ bridges by mirroring instead — geometry you hand to a `Mesh` directly comes in
42
+ flipped left/right unless you pass `rightHanded: true`. See
43
+ `melonjs-3d-assets`.
44
+
45
+ ## Opting in
46
+
47
+ 3D starts with the camera class, and nothing else has to change. Set it once on
48
+ the `Application`:
49
+
50
+ ```js
51
+ import { Application, Camera3d } from "melonjs";
52
+
53
+ const app = new Application(1024, 768, {
54
+ parent: "screen",
55
+ cameraClass: Camera3d, // ← the opt-in
56
+ });
57
+ await app.init();
58
+ ```
59
+
60
+ That flips the world's sort to `"depth"`, switches the broadphase to a 3D index,
61
+ and renders sprites and meshes with perspective projection. `Camera3d` extends
62
+ `Camera2d`, so follow, fade, shake and post effects all still work.
63
+
64
+ Per-stage opt-in also works, which is useful when the loading screen is 2D:
65
+
66
+ ```js
67
+ class GameStage extends Stage {
68
+ constructor() {
69
+ super({ cameras: [new Camera3d(0, 0, 1024, 768, { fov: Math.PI / 3 })] });
70
+ }
71
+ }
72
+ ```
73
+
74
+ ## Camera traps
75
+
76
+ - **There is no sky.** The frame clears to `renderer.backgroundColor` (opaque
77
+ black unless the renderer was created transparent), and `world.backgroundColor`
78
+ clears over it when you set one — both are flat colours. Anything more is a
79
+ backdrop renderable, screen-fixed or placed at a far depth.
80
+ - **Set the clip planes for your scene scale.** Defaults are near 0.1 / far 1000.
81
+ Objects beyond the far plane clip or project with bad w-divides; a `near` that
82
+ is too small wastes depth precision and distant props z-fight. Use
83
+ `camera.setClipPlanes(near, far)`.
84
+ - **`camera.pos.set(x, y)` is 2-argument and zeroes z.** Use `camera.depth` —
85
+ the documented z accessor — or assign `pos.x`/`pos.y` individually.
86
+
87
+ ## Depth sorting
88
+
89
+ Under `Camera3d` the world sorts on `"depth"` **every frame** (recursively), so
90
+ unlike 2D you *can* assign `depth` after `addChild` and it will reorder. That is
91
+ the one place where the usual z-ordering rule is relaxed — see
92
+ `melonjs-renderables` for the 2D rules, which still apply everywhere else.
93
+
94
+ You will often *have* to. A `Container` has `autoDepth: true` by default, so
95
+ `addChild(child)` with no explicit z **overwrites `pos.z` with the child's
96
+ index** — a real world depth in a 3D scene, and never the one you wanted. Pass
97
+ it (`world.addChild(mesh, z)`), or set `mesh.depth` afterwards. The glTF
98
+ importer turns `autoDepth` off on the container it loads into for this reason.
99
+
100
+ **`floating` does not opt out of this sort.** It skips the camera *transform*,
101
+ not the depth *order*. A floating child is ordered by `|pos.z|` alone — its
102
+ `pos.x/y` are screen pixels, and the camera does not move relative to it — so
103
+ the magnitude is the distance and the sign is ignored:
104
+
105
+ ```js
106
+ world.addChild(hud, -150); // small -> nearer than anything -> on top
107
+ world.addChild(skybox, -10000); // large -> farther -> behind everything
108
+ world.addChild(skybox, 100000); // equally far: sign does not matter
109
+ ```
110
+
111
+ Both hold at any camera position. A HUD given the huge z that would put it on
112
+ top in 2D lands at the far end of the level instead, with the scenery drawing
113
+ over it.
114
+
115
+ ## Transparency
116
+
117
+ A mesh fades by setting its opacity — there is nothing else to switch on:
118
+
119
+ ```js
120
+ ghost.setOpacity(0.4);
121
+ ```
122
+
123
+ Meshes render in two phases. The **opaque pass** writes depth in sort order; the
124
+ **transparent pass** replays afterwards, back-to-front, blending and writing no
125
+ depth. A draw lands in the second whenever its alpha is fractional.
126
+
127
+ That default matters because the opaque path writes premultiplied colour with
128
+ blending off, so before this a faded mesh came out **darkened toward black**
129
+ rather than see-through — the background contributed nothing.
130
+
131
+ **`transparent: true`** when the transparency is in the TEXTURE rather than the
132
+ opacity — a soft-edged glow, smoke, a glTF material with `alphaMode: "BLEND"`.
133
+ The automatic check reads the draw's alpha and cannot see into a texture. Watch
134
+ `alphaCutoff` here: it discards texels *before* blending sees them, so a soft
135
+ edge needs a low cutoff (`Sprite3d` drops its own default to `1/255` when you
136
+ set `transparent: true`). The cutoff thresholds the MATERIAL's alpha, not the
137
+ drawn alpha, so a fading cutout mesh keeps its shape instead of disappearing at
138
+ its own threshold.
139
+
140
+ The glTF loader does **not** set this for you: one loaded mesh can merge several
141
+ materials and the flag routes the whole mesh, so a `"BLEND"` material sharing
142
+ geometry with an opaque one would drag the opaque half into the transparent pass.
143
+
144
+ **`transparent: false`** pins a mesh to the opaque pass however it is faded.
145
+
146
+ Blending uses the renderable's existing `blendMode`, so a glow is one property.
147
+ The advanced modes (`"overlay"`, `"difference"`, and the rest that need a
148
+ compositing pass) fall back to `"normal"` here, on both backends:
149
+
150
+ ```js
151
+ const glow = new Mesh(0, 0, {
152
+ ...quad, texture: glowTexture,
153
+ transparent: true, blendMode: "additive", alphaCutoff: 0,
154
+ });
155
+ ```
156
+
157
+ | | |
158
+ | --- | --- |
159
+ | sorting | **per object**, by distance from the camera |
160
+ | intersecting transparent meshes | may pop as the camera moves — split them, or accept it |
161
+ | `InstancedMesh` | sorts as **one** object; instances draw in buffer order |
162
+ | needs | a GPU backend and a `Camera3d` |
163
+
164
+ Ground shadows ride the same pass — a blob is a decal, and decals are its first
165
+ client rather than a feature of their own.
166
+
167
+ ## Distance fog
168
+
169
+ Off until you ask for it, and one call on the camera:
170
+
171
+ ```js
172
+ camera.setFog({ near: 2000, far: 7000 }); // linear: name the two distances
173
+ camera.setFog({ mode: "exp2", density: 4e-4 }); // or one density
174
+ camera.setFog(null); // off
175
+ ```
176
+
177
+ It is the cheapest thing that stops a 3D scene reading as flat cut-outs, and it
178
+ lets props arrive at the far plane without a visible edge.
179
+
180
+ **Every parameter is optional, and the omitted ones track live.** Distances
181
+ default to the camera's own clip planes, so fog cannot silently disagree with
182
+ them after a later `setClipPlanes`. The colour defaults to
183
+ `renderer.backgroundColor` and follows it, so geometry dissolves into whatever
184
+ sky you already set — including through a day/night fade. Pass `color` only
185
+ when the fog should deliberately differ from the backdrop:
186
+
187
+ ```js
188
+ camera.setFog({ far: 5000, color: "#8899aa" });
189
+ ```
190
+
191
+ A `Color` is held by reference, so mutating it animates the fog.
192
+
193
+ **Height falloff** makes mist pool in low ground instead of hanging at every
194
+ altitude equally — the difference between fog reading as weather and as a global
195
+ desaturation:
196
+
197
+ ```js
198
+ camera.setFog({ near: 1200, far: 7000, fogHeight: 0, heightFalloff: 0.0015 });
199
+ ```
200
+
201
+ `heightFalloff` defaults to **0**, which is uniform fog — not a special case,
202
+ the same integral with the dial at zero, so leaving it out changes nothing.
203
+ Render space is **Y-down**, so `fogHeight` is the floor and density rises
204
+ *below* it; every published form of this formula assumes Y-up and has the
205
+ opposite sign.
206
+
207
+ Fog is measured **radially** from the camera and applied **per fragment**, so
208
+ it does not slide as the camera turns and does not band across large triangles.
209
+ It lives on the camera, so a split-screen or minimap view fogs independently —
210
+ and a `Camera2d` never fogs at all.
211
+
212
+ **Per object:** `fog: false` exempts a mesh however far away it is — for a
213
+ waypoint or objective marker that has to stay readable. It exempts the mesh and
214
+ not the ground shadow it casts: a blob is a mark on the floor and fogs with the
215
+ floor. Emissive surfaces fog
216
+ like everything else (light travelling through fog is attenuated too), so a
217
+ neon sign that should punch through wants `fog: false`, not a brighter
218
+ emissive.
219
+
220
+ Only meshes fog. 2D content, HUDs and `floating` renderables never reach the
221
+ mesh shaders, so a screen-space overlay stays clean with no work.
222
+
223
+ **A custom mesh shader is not fogged unless it asks to be.** Fog is compiled
224
+ into the engine's own mesh programs — `#define FOG` on WebGL, an `enable_fog`
225
+ overridable constant on WebGPU — and a shader you supply is yours: the engine
226
+ binds it as written and never substitutes a fogged variant. So a mesh carrying a
227
+ `ShaderEffect` keeps full contrast while the scene around it recedes. It is safe
228
+ — nothing throws, and the camera's fog is simply not applied — but it is usually
229
+ surprising.
230
+
231
+ To opt in, declare the same uniforms and the engine will feed them, because the
232
+ fog values are pushed to any mesh program that declares them rather than only to
233
+ the built-in ones:
234
+
235
+ ```glsl
236
+ uniform vec3 uFogColor; // straight (unpremultiplied) fog colour
237
+ uniform vec4 uFogParams; // x = mode (0 off / 1 linear / 2 exp2),
238
+ // y = near, z = 1/(far - near), w = density
239
+ ```
240
+
241
+ Your vertex stage computes the distance itself — `length((uViewMatrix *
242
+ uModelMatrix * vec4(aVertex, 1.0)).xyz)`, radially so it does not swim as the
243
+ camera turns — and the blend must scale the fog colour by the fragment's own
244
+ alpha, `mix(uFogColor * a, rgb, f)`, because `vColor` arrives premultiplied.
245
+ Mixing toward the unscaled colour haloes every alpha-cutout edge.
246
+
247
+ The flip side is the reason fog costs nothing when unused: with no camera fog,
248
+ the mesh programs are compiled without any of it, on both backends. It is not a
249
+ branch that is skipped at runtime — the code is not there.
250
+
251
+ ## Meshes
252
+
253
+ ```js
254
+ const cube = new Mesh(x, y, {
255
+ model: "cube", // a preloaded OBJ name — no built-in primitives
256
+ texture: atlas, // TextureAtlas, image, or a preloaded image name
257
+ width: 64, height: 64,
258
+ cullBackFaces: true, // the default
259
+ lit: true,
260
+ });
261
+ ```
262
+
263
+ **A mesh pivots about its model origin `(0, 0, 0)`, not an anchor point.** Under
264
+ `Camera3d` it opts out of the anchor offset entirely, so `anchorPoint` is inert
265
+ there — place the origin where you want the pivot at authoring time, or nest the
266
+ mesh under a transformed parent. The anchor is only honoured on the legacy
267
+ 2D-camera path.
268
+
269
+ ### InstancedMesh, and when it is the wrong tool
270
+
271
+ **`InstancedMesh`** draws one mesh many times in a single draw call — the
272
+ difference between a hundred trees and a hundred thousand. glTF scenes using
273
+ `EXT_mesh_gpu_instancing` load as one automatically; by hand it is a `Mesh`
274
+ with a count:
275
+
276
+ ```js
277
+ const trees = new InstancedMesh(0, 0, { ...treeGeometry, instanceCount: 400 });
278
+ const at = new Matrix3d(); // one scratch, reused
279
+ for (let i = 0; i < trees.instanceCount; i++) {
280
+ at.identity().translate(x, y, z);
281
+ trees.setInstance(i, at);
282
+ }
283
+ world.addChild(trees, 0);
284
+
285
+ trees.visibleInstanceCount = 120; // draw fewer, without re-uploading
286
+ ```
287
+
288
+ It is not a free upgrade. One `InstancedMesh` is **one geometry and one
289
+ material**, and four things move from per-object to per-group:
290
+
291
+ | | with `Mesh` | with `InstancedMesh` |
292
+ | --- | --- | --- |
293
+ | depth sort | each object sorts on its own `pos` | the whole set has **one** sort key |
294
+ | ground shadow | one blob per object | one instanced draw for the set |
295
+ | removal | `removeChild`, indices unaffected | `removeInstance(i)` swaps the **last** instance into the hole, so any index you were holding is now wrong |
296
+ | colour | `tint` per object | needs `instanceColors: true` and `setInstanceColor(i, …)` |
297
+
298
+ So the question is not "how many are there" but **"does the game address them
299
+ individually"**:
300
+
301
+ - **Scenery — instance it.** Trees, rocks, grass, debris: the game never asks
302
+ about one of them.
303
+ - **Collision-tested props — still fine.** You test against positions you
304
+ already own; instancing only changes how they are *drawn*.
305
+ - **Collectibles and enemies — usually not.** Anything removed one at a time
306
+ makes `removeInstance`'s swap your problem: you have to keep an index↔object
307
+ map and repair it on every removal. At small counts a pooled `Mesh` each is
308
+ less code and no slower.
309
+
310
+ Under a few hundred objects the draw-call saving is not what limits you
311
+ anyway — reach for it when the count is in the thousands, or when the objects
312
+ are pure scenery and it costs nothing to.
313
+
314
+ ## Normals are generated for you
315
+
316
+ A `lit` mesh needs per-vertex normals for the shader to light with. Supply them
317
+ if you have them; **omit them and the engine computes them from the geometry**:
318
+
319
+ ```js
320
+ const mesh = new Mesh(x, y, { vertices, uvs, indices, lit: true });
321
+ // normals derived from the triangles — nothing else to do
322
+ ```
323
+
324
+ You do not choose flat or smooth, because the geometry already decides. Face
325
+ normals accumulate into their vertices weighted by area, so where faces **share**
326
+ a vertex they average and the surface shades smoothly, and where every triangle
327
+ carries its **own** three vertices — a triangle soup, which is how most
328
+ hand-built geometry comes out — each vertex belongs to one face and the result
329
+ is that face's normal, so it shades flat. Want faceted edges: duplicate the
330
+ vertices. Want smooth: share them.
331
+
332
+ An explicit `settings.normals` always wins, and an unlit mesh gets none — there
333
+ would be nothing to read them.
334
+
335
+ **A lit mesh with no normals used to render fullbright**, which looks like the
336
+ lighting is broken rather than absent. If an older scene suddenly picks up
337
+ shading, that is why.
338
+
339
+ ## Colouring a mesh
340
+
341
+ There are four levels, and picking the wrong one is the usual reason a colour
342
+ "does not apply". They all multiply together.
343
+
344
+ | level | how | use for |
345
+ |---|---|---|
346
+ | whole object | `mesh.tint.setColor(r, g, b)` | flash on hit, team colour, fading one object |
347
+ | per vertex | `settings.vertexColors`, or `mesh.setVertexColor(i, color)` | a gradient *within* one mesh — distance haze, a darker crease |
348
+ | per material | `textureGroups`, from a multi-material OBJ + MTL | a model whose parts differ, in one draw call |
349
+ | per instance | `new InstancedMesh(…, { instanceColors: true })` then `setInstanceColor(i, color)` | a thousand copies that differ |
350
+
351
+ **`tint` is per object.** That is the trap: build a terrain as one big mesh and
352
+ you can tint the whole valley or none of it. Anything that varies *across* a
353
+ single mesh is per-vertex.
354
+
355
+ ```js
356
+ // fade a procedural terrain toward the sky the further out it goes
357
+ const ground = new Color(217, 230, 244);
358
+ const sky = new Color(207, 230, 247);
359
+ const haze = new Color();
360
+ for (let i = 0; i < mesh.vertexCount; i++) {
361
+ const t = Math.min(1, mesh.originalVertices[i * 3 + 2] / 6000);
362
+ mesh.setVertexColor(i, haze.copy(ground).lerp(sky, t));
363
+ }
364
+ ```
365
+
366
+ Supply the whole array at construction when you already have it —
367
+ `vertexColors` takes a packed `Uint32Array` (the form the batchers read, so no
368
+ conversion) or one `Color` per vertex. A length that does not match
369
+ `vertexCount` **throws**; it is not padded, because a short array would leave
370
+ the tail of the mesh mis-coloured and that reads as a lighting bug.
371
+
372
+ Mutating the array directly is fine, but say so afterwards:
373
+
374
+ ```js
375
+ mesh.vertexColors[i] = color.toUint32(color.alpha);
376
+ mesh.needsUpdate = true; // the retained Camera3d path uploads once
377
+ ```
378
+
379
+ `setVertexColor` does that for you. Skip it and the colour applies under a 2D
380
+ camera and silently does not under `Camera3d`.
381
+
382
+ On a lit mesh the colour multiplies the **lit** result, so it behaves as albedo
383
+ rather than as an emissive override — a vertex colour will not make an unlit
384
+ face bright.
385
+
386
+ `alpha` hides a mesh as it hides anything else: at 0 the draw is skipped. There
387
+ is no *partial* mesh transparency though — the mesh path renders opaque, so a
388
+ mesh at `alpha = 0.5` draws fully opaque rather than half see-through. Fade a
389
+ mesh out and it will stay solid until it vanishes.
390
+
391
+ ## Sprite3d and billboards
392
+
393
+ `Sprite3d` is the 2.5D workhorse: a flat sprite living at a real depth, with
394
+ `billboard` controlling how it faces the camera.
395
+
396
+ | `billboard` | behaviour |
397
+ |---|---|
398
+ | `false` (default) / `"none"` | no rotation — a flat plane in the world |
399
+ | `true` / `"cylindrical"` | yaws to face the camera, stays upright (characters, trees) |
400
+ | `"spherical"` | always fully faces the camera (particles, impostors) |
401
+
402
+ `"cylindrical"` is what you want for paper-thin characters in a 2.5D game.
403
+ Billboarding needs a `Camera3d` drawing the frame; under a 2D camera the quad
404
+ renders fixed-orientation. **Any other string falls through to the spherical
405
+ branch**, so a guessed value like `"upright"` silently gives you spherical.
406
+
407
+ ## Lighting
408
+
409
+ `Light3d` takes **one argument — the options object** (it has no `x, y, z`
410
+ pair; a light carries its own `position`). Types are `"directional"` (the
411
+ default), `"ambient"`, `"point"` and `"spot"`.
412
+
413
+ ```js
414
+ world.addChild(new Light3d({ type: "directional", direction: [0.3, 1, 0.2] }));
415
+ world.addChild(new Light3d({ type: "ambient", intensity: 0.3 }));
416
+ ```
417
+
418
+ Use **both halves**: with a key light but no ambient, the shadow side of a mesh
419
+ goes black. With no `Light3d` in the world at all, a `lit: true` mesh falls back
420
+ to a white ambient and renders fullbright — indistinguishable from unlit, which
421
+ is why "I added `lit: true` and nothing changed" is the usual first report.
422
+
423
+ Other defaults worth knowing: `intensity` 1, `color` white, `range` 1000 (point
424
+ and spot, a stylised quadratic falloff, not inverse-square),
425
+ `innerConeAngle` 0 and `outerConeAngle` π/4 (spot).
426
+
427
+ **`Light2d` is 2D-only** and produces visible artifacts under perspective
428
+ projection. Do not combine it with `Camera3d`.
429
+
430
+ Ground shadows are **on by default** (the `castGroundShadow` application
431
+ setting), and need a GPU backend and a `Camera3d`. As a blanket default they
432
+ skip geometry with no vertical extent — a ground plane. Per object,
433
+ `castGroundShadow: true`/`false` overrides the app setting and is obeyed as
434
+ given, safeguard included; `shadowGroundY` names the floor the blob lands on.
435
+
436
+ The blob is an ellipse sized to the caster's own footprint and placed at the
437
+ caster's x/z — it is **never offset by light direction**. So a tall or narrow
438
+ object (a character, a tree, a pickup) shows its shadow clearly, while a wide,
439
+ flat-bottomed one resting on the floor covers its own completely from a camera
440
+ looking down at it. That is the shadow behaving correctly, not a bug.
441
+
442
+ **Do not chase it by raising `shadowGroundY`.** Lifting the plane does not slide
443
+ the blob out from under the object, it floats the blob *up* — and past a few
444
+ units it projects over the top of the caster as a dark halo ringing it. If an
445
+ object needs a visible shadow, give it a smaller footprint relative to its
446
+ height, or accept that a boulder bedded in the ground has none.
447
+
448
+ ## glTF / GLB scenes
449
+
450
+ Loaded through the same level director as everything else:
451
+
452
+ ```js
453
+ await loader.preload([{ name: "diorama", type: "glb", src: "data/diorama.glb" }]);
454
+ level.load("diorama", { scale, castGroundShadow, shadowGroundY, onLoaded });
455
+ ```
456
+
457
+ `.obj` / `.mtl` are also supported loader types.
458
+
459
+ `melonjs-3d-assets` covers the rest: every `level.load` option, which material
460
+ features are imported, imported lights and their intensity units, node-TRS
461
+ animation (and the skinning that is out of scope), and OBJ/MTL.
462
+
463
+ ## Requires a GPU backend
464
+
465
+ The whole 3D tier needs WebGPU or WebGL 2. The Canvas renderer has no depth
466
+ buffer, no perspective path and no `drawMesh`, so a `Camera3d` scene does not
467
+ render correctly there — usually a black canvas. `Light3d` and shader effects
468
+ are inert too. A `Mesh` under a *2D* camera still renders, CPU-projected by
469
+ painter's algorithm and unlit.
470
+
471
+ `Application` does warn: constructing with a `cameraClass` whose
472
+ `defaultSortOn` is `"depth"` on a renderer with no depth buffer logs a
473
+ `console.warn`. But `video.AUTO` falls back silently to Canvas, so the strong
474
+ gate is to ask for a GPU backend by name — `renderer: video.WEBGL` (or
475
+ `video.WEBGPU`) makes `await app.init()` reject instead of misrendering:
476
+
477
+ ```js
478
+ const app = new Application(1024, 768, {
479
+ parent: "screen",
480
+ renderer: video.WEBGL, // init() rejects if WebGL 2 is unavailable
481
+ cameraClass: Camera3d,
482
+ });
483
+ await app.init();
484
+ ```
485
+
486
+ To branch rather than fail, read `app.renderer.supportsDepthBuffer` after
487
+ `init()`.
488
+
489
+ ## Symptom → cause
490
+
491
+ | symptom | cause |
492
+ |---|---|
493
+ | a `lit` mesh renders fullbright | it had no normals — supply them, or let the engine generate them |
494
+ | a gradient across one mesh is impossible | `tint` is per object — use `vertexColors` / `setVertexColor` |
495
+ | a mesh stays solid as you fade it out | meshes render opaque; only `alpha` 0 (hidden) and 1 differ |
496
+ | vertex colour applies under a 2D camera but not `Camera3d` | wrote the array directly without setting `needsUpdate` |
497
+ | `Mesh: vertexColors has N entries, expected M` | one colour per *vertex*, not per triangle or per index |
498
+ | nothing renders, or a backdrop covers everything | wrong depth sign — "far" is *larger* z when looking along +Z |
499
+ | distant objects vanish or warp | scene exceeds the default far plane; `setClipPlanes` |
500
+ | distant surfaces z-fight | `near` too small for the scene scale |
501
+ | black canvas under `Camera3d` | Canvas renderer (no depth buffer) — check the `console.warn` |
502
+ | everything flat and unlit | `lit: true` with no `Light3d` in the world (falls back to fullbright), or a mesh under a 2D camera |
503
+ | a faded mesh goes dark instead of see-through | `transparent: false` on it, or a 2D camera — the transparent pass needs a `Camera3d` |
504
+ | a soft-edged glow has hard edges | `alphaCutoff` discarded the soft texels; lower it |
505
+ | a glTF `alphaMode: "BLEND"` material draws opaque | the loader does not set `transparent` — one mesh can merge several materials, so set it yourself |
506
+ | two transparent objects pop as the camera moves | per-object sorting cannot order intersecting geometry |
507
+ | a `floating` HUD draws behind the scenery | a large \|z\| is *far* under `Camera3d` — use a small depth |
508
+ | fog hangs in the sky as thickly as in the valley | uniform fog — add `heightFalloff` so it pools low |
509
+ | mist sits on the ridges instead of the valley floor | the `fogHeight` sign — Y is DOWN here, density rises below it |
510
+ | distant geometry pops in against the sky | no fog — `camera.setFog({})` picks up the clip planes and background colour |
511
+ | fog does not match the sky after a background fade | an explicit `color` was passed; omit it to track `renderer.backgroundColor` |
512
+ | geometry clips before it has finished fading | fog `far` beyond the clip far — omit the distances and they default to the clip planes |
513
+ | one marker must stay readable in fog | `fog: false` on that mesh |
514
+ | an object casts no visible shadow | wide and flat-bottomed — its own blob is underneath it; raising `shadowGroundY` haloes it instead of revealing it |
515
+ | a dark ring around the top of an object | `shadowGroundY` lifted too far, floating the blob up into the caster |
516
+ | a mesh sits at the wrong depth after being added | `autoDepth` overwrote `pos.z` with the child index — pass `addChild(mesh, z)` |
517
+ | a mesh sits half its size off | `anchorPoint` — only on the 2D-camera path; a `Camera3d` mesh pivots on its model origin |
518
+ | a billboard tips over when the camera looks down | `"spherical"`, or a mistyped mode string falling through to it — use `true` / `"cylindrical"` |
519
+ | an object jumps to the camera plane | `Vector3d.set(x, y)` / `camera.pos.set(x, y)` zeroed its z |
520
+ | lighting looks wrong under a 3D camera | `Light2d` used instead of `Light3d` |
521
+
522
+ ## Related skills
523
+
524
+ - `melonjs-renderables` — the 2D z-ordering rules, anchors, custom draw
525
+ - `melonjs-getting-started` — Application settings and the renderer fallback