melonjs 20.3.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 (442) 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.map +1 -1
  18. package/build/audio/state.d.ts +6 -79
  19. package/build/audio/state.d.ts.map +1 -1
  20. package/build/camera/camera2d.d.ts +0 -68
  21. package/build/camera/camera2d.d.ts.map +1 -1
  22. package/build/camera/camera3d.d.ts +86 -79
  23. package/build/camera/camera3d.d.ts.map +1 -1
  24. package/build/camera/effects/fade_effect.d.ts +0 -5
  25. package/build/camera/effects/fade_effect.d.ts.map +1 -1
  26. package/build/camera/effects/mask_effect.d.ts +0 -5
  27. package/build/camera/effects/mask_effect.d.ts.map +1 -1
  28. package/build/camera/fog.d.ts +118 -0
  29. package/build/camera/fog.d.ts.map +1 -0
  30. package/build/geometries/box3d.d.ts +0 -28
  31. package/build/geometries/box3d.d.ts.map +1 -1
  32. package/build/geometries/ellipse.d.ts +0 -20
  33. package/build/geometries/ellipse.d.ts.map +1 -1
  34. package/build/geometries/observablePoint.d.ts +0 -3
  35. package/build/geometries/observablePoint.d.ts.map +1 -1
  36. package/build/geometries/path2d.d.ts +0 -19
  37. package/build/geometries/path2d.d.ts.map +1 -1
  38. package/build/geometries/polygon.d.ts +0 -12
  39. package/build/geometries/polygon.d.ts.map +1 -1
  40. package/build/geometries/roundrect.d.ts +0 -18
  41. package/build/geometries/roundrect.d.ts.map +1 -1
  42. package/build/geometries/sphere.d.ts +0 -9
  43. package/build/geometries/sphere.d.ts.map +1 -1
  44. package/build/geometries/toarccanvas.d.ts.map +1 -1
  45. package/build/index.d.ts +1 -0
  46. package/build/index.d.ts.map +1 -1
  47. package/build/index.js +2652 -413
  48. package/build/index.js.map +3 -3
  49. package/build/input/gamepad.d.ts.map +1 -1
  50. package/build/input/pointer.d.ts +0 -4
  51. package/build/input/pointer.d.ts.map +1 -1
  52. package/build/input/pointerevent.d.ts +0 -6
  53. package/build/input/pointerevent.d.ts.map +1 -1
  54. package/build/lang/deprecated.d.ts.map +1 -1
  55. package/build/level/gltf/GLTFModel.d.ts +0 -81
  56. package/build/level/gltf/GLTFModel.d.ts.map +1 -1
  57. package/build/level/gltf/GLTFScene.d.ts +1 -44
  58. package/build/level/gltf/GLTFScene.d.ts.map +1 -1
  59. package/build/level/gltf/gltf_sampler.d.ts +1 -48
  60. package/build/level/gltf/gltf_sampler.d.ts.map +1 -1
  61. package/build/level/level.d.ts +195 -113
  62. package/build/level/level.d.ts.map +1 -1
  63. package/build/level/tiled/TMXGroup.d.ts +1 -65
  64. package/build/level/tiled/TMXGroup.d.ts.map +1 -1
  65. package/build/level/tiled/TMXLayer.d.ts +0 -44
  66. package/build/level/tiled/TMXLayer.d.ts.map +1 -1
  67. package/build/level/tiled/TMXObject.d.ts +1 -136
  68. package/build/level/tiled/TMXObject.d.ts.map +1 -1
  69. package/build/level/tiled/TMXObjectFactory.d.ts +1 -40
  70. package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
  71. package/build/level/tiled/TMXTile.d.ts +1 -30
  72. package/build/level/tiled/TMXTile.d.ts.map +1 -1
  73. package/build/level/tiled/TMXTileMap.d.ts +0 -10
  74. package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
  75. package/build/level/tiled/TMXTileset.d.ts +0 -113
  76. package/build/level/tiled/TMXTileset.d.ts.map +1 -1
  77. package/build/level/tiled/TMXTilesetGroup.d.ts +0 -1
  78. package/build/level/tiled/TMXTilesetGroup.d.ts.map +1 -1
  79. package/build/level/tiled/TMXUtils.d.ts +1 -43
  80. package/build/level/tiled/TMXUtils.d.ts.map +1 -1
  81. package/build/level/tiled/factories/shape.d.ts +1 -7
  82. package/build/level/tiled/factories/shape.d.ts.map +1 -1
  83. package/build/level/tiled/factories/text.d.ts +1 -7
  84. package/build/level/tiled/factories/text.d.ts.map +1 -1
  85. package/build/level/tiled/factories/tile.d.ts +1 -7
  86. package/build/level/tiled/factories/tile.d.ts.map +1 -1
  87. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +0 -60
  88. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
  89. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +0 -42
  90. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
  91. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +0 -5
  92. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
  93. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +0 -31
  94. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
  95. package/build/level/tiled/renderer/TMXRenderer.d.ts +2 -2
  96. package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
  97. package/build/level/tiled/renderer/TMXStaggeredRenderer.d.ts.map +1 -1
  98. package/build/level/tiled/renderer/autodetect.d.ts +1 -6
  99. package/build/level/tiled/renderer/autodetect.d.ts.map +1 -1
  100. package/build/lighting/light2d.d.ts +0 -25
  101. package/build/lighting/light2d.d.ts.map +1 -1
  102. package/build/lighting/light3d.d.ts +0 -16
  103. package/build/lighting/light3d.d.ts.map +1 -1
  104. package/build/loader/loader.d.ts +42 -33
  105. package/build/loader/loader.d.ts.map +1 -1
  106. package/build/loader/loadingscreen.d.ts +0 -33
  107. package/build/loader/loadingscreen.d.ts.map +1 -1
  108. package/build/loader/parsers/aseprite.d.ts +0 -13
  109. package/build/loader/parsers/aseprite.d.ts.map +1 -1
  110. package/build/loader/parsers/audio.d.ts +1 -30
  111. package/build/loader/parsers/audio.d.ts.map +1 -1
  112. package/build/loader/parsers/binary.d.ts +1 -10
  113. package/build/loader/parsers/binary.d.ts.map +1 -1
  114. package/build/loader/parsers/compressed_textures/compressed_image.d.ts.map +1 -1
  115. package/build/loader/parsers/compressed_textures/parseDDS.d.ts +1 -7
  116. package/build/loader/parsers/compressed_textures/parseDDS.d.ts.map +1 -1
  117. package/build/loader/parsers/compressed_textures/parseKTX.d.ts +1 -7
  118. package/build/loader/parsers/compressed_textures/parseKTX.d.ts.map +1 -1
  119. package/build/loader/parsers/compressed_textures/parseKTX2.d.ts +1 -7
  120. package/build/loader/parsers/compressed_textures/parseKTX2.d.ts.map +1 -1
  121. package/build/loader/parsers/compressed_textures/parsePKM.d.ts +1 -7
  122. package/build/loader/parsers/compressed_textures/parsePKM.d.ts.map +1 -1
  123. package/build/loader/parsers/compressed_textures/parsePVR.d.ts +1 -7
  124. package/build/loader/parsers/compressed_textures/parsePVR.d.ts.map +1 -1
  125. package/build/loader/parsers/fontface.d.ts +1 -13
  126. package/build/loader/parsers/fontface.d.ts.map +1 -1
  127. package/build/loader/parsers/gltf.d.ts +1 -70
  128. package/build/loader/parsers/gltf.d.ts.map +1 -1
  129. package/build/loader/parsers/image.d.ts +1 -22
  130. package/build/loader/parsers/image.d.ts.map +1 -1
  131. package/build/loader/parsers/json.d.ts +1 -10
  132. package/build/loader/parsers/json.d.ts.map +1 -1
  133. package/build/loader/parsers/mtl.d.ts +1 -28
  134. package/build/loader/parsers/mtl.d.ts.map +1 -1
  135. package/build/loader/parsers/obj.d.ts +1 -59
  136. package/build/loader/parsers/obj.d.ts.map +1 -1
  137. package/build/loader/parsers/pbr.d.ts +1 -62
  138. package/build/loader/parsers/pbr.d.ts.map +1 -1
  139. package/build/loader/parsers/script.d.ts +1 -10
  140. package/build/loader/parsers/script.d.ts.map +1 -1
  141. package/build/loader/parsers/shader.d.ts +1 -52
  142. package/build/loader/parsers/shader.d.ts.map +1 -1
  143. package/build/loader/parsers/tmx.d.ts +1 -10
  144. package/build/loader/parsers/tmx.d.ts.map +1 -1
  145. package/build/loader/parsers/video.d.ts +1 -10
  146. package/build/loader/parsers/video.d.ts.map +1 -1
  147. package/build/math/color.d.ts.map +1 -1
  148. package/build/math/noise.d.ts +0 -40
  149. package/build/math/noise.d.ts.map +1 -1
  150. package/build/math/observableVector2d.d.ts +0 -3
  151. package/build/math/observableVector2d.d.ts.map +1 -1
  152. package/build/math/observableVector3d.d.ts +0 -3
  153. package/build/math/observableVector3d.d.ts.map +1 -1
  154. package/build/math/vector2d.d.ts +0 -6
  155. package/build/math/vector2d.d.ts.map +1 -1
  156. package/build/math/vertex.d.ts +25 -0
  157. package/build/math/vertex.d.ts.map +1 -1
  158. package/build/particles/emitter.d.ts +0 -65
  159. package/build/particles/emitter.d.ts.map +1 -1
  160. package/build/particles/particle.d.ts +0 -81
  161. package/build/particles/particle.d.ts.map +1 -1
  162. package/build/physics/bounds.d.ts +0 -1
  163. package/build/physics/bounds.d.ts.map +1 -1
  164. package/build/physics/broadphase/broadphase.d.ts +0 -7
  165. package/build/physics/broadphase/broadphase.d.ts.map +1 -1
  166. package/build/physics/broadphase/octree.d.ts +0 -91
  167. package/build/physics/broadphase/octree.d.ts.map +1 -1
  168. package/build/physics/broadphase/quadtree.d.ts +0 -47
  169. package/build/physics/broadphase/quadtree.d.ts.map +1 -1
  170. package/build/physics/builtin/body.d.ts +2 -65
  171. package/build/physics/builtin/body.d.ts.map +1 -1
  172. package/build/physics/builtin/detector.d.ts +0 -312
  173. package/build/physics/builtin/detector.d.ts.map +1 -1
  174. package/build/physics/builtin/sat.d.ts +1 -48
  175. package/build/physics/builtin/sat.d.ts.map +1 -1
  176. package/build/physics/builtin/sat3d.d.ts +1 -56
  177. package/build/physics/builtin/sat3d.d.ts.map +1 -1
  178. package/build/physics/collision.d.ts +0 -2
  179. package/build/physics/collision.d.ts.map +1 -1
  180. package/build/physics/response.d.ts +0 -1
  181. package/build/physics/response.d.ts.map +1 -1
  182. package/build/physics/world.d.ts.map +1 -1
  183. package/build/renderable/anchorPoint.d.ts +1 -73
  184. package/build/renderable/anchorPoint.d.ts.map +1 -1
  185. package/build/renderable/animation.d.ts +0 -7
  186. package/build/renderable/animation.d.ts.map +1 -1
  187. package/build/renderable/colorlayer.d.ts +0 -5
  188. package/build/renderable/colorlayer.d.ts.map +1 -1
  189. package/build/renderable/container.d.ts +0 -55
  190. package/build/renderable/container.d.ts.map +1 -1
  191. package/build/renderable/draggable.d.ts +0 -5
  192. package/build/renderable/draggable.d.ts.map +1 -1
  193. package/build/renderable/dragndrop.d.ts +1 -12
  194. package/build/renderable/dragndrop.d.ts.map +1 -1
  195. package/build/renderable/entity/entity.d.ts +0 -8
  196. package/build/renderable/entity/entity.d.ts.map +1 -1
  197. package/build/renderable/frameAnimation.d.ts +0 -41
  198. package/build/renderable/frameAnimation.d.ts.map +1 -1
  199. package/build/renderable/groundshadow.d.ts +1 -91
  200. package/build/renderable/groundshadow.d.ts.map +1 -1
  201. package/build/renderable/imagelayer.d.ts +0 -29
  202. package/build/renderable/imagelayer.d.ts.map +1 -1
  203. package/build/renderable/instanced_mesh.d.ts +26 -104
  204. package/build/renderable/instanced_mesh.d.ts.map +1 -1
  205. package/build/renderable/mesh.d.ts +130 -141
  206. package/build/renderable/mesh.d.ts.map +1 -1
  207. package/build/renderable/nineslicesprite.d.ts +0 -4
  208. package/build/renderable/nineslicesprite.d.ts.map +1 -1
  209. package/build/renderable/renderable.d.ts +1 -44
  210. package/build/renderable/renderable.d.ts.map +1 -1
  211. package/build/renderable/sprite.d.ts +0 -45
  212. package/build/renderable/sprite.d.ts.map +1 -1
  213. package/build/renderable/sprite3d.d.ts +0 -95
  214. package/build/renderable/sprite3d.d.ts.map +1 -1
  215. package/build/renderable/text/bitmaptext.d.ts +0 -14
  216. package/build/renderable/text/bitmaptext.d.ts.map +1 -1
  217. package/build/renderable/text/bitmaptextdata.d.ts +0 -22
  218. package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
  219. package/build/renderable/text/glyph.d.ts +1 -39
  220. package/build/renderable/text/glyph.d.ts.map +1 -1
  221. package/build/renderable/text/text.d.ts +0 -20
  222. package/build/renderable/text/text.d.ts.map +1 -1
  223. package/build/renderable/text/textstyle.d.ts +1 -5
  224. package/build/renderable/text/textstyle.d.ts.map +1 -1
  225. package/build/renderable/trail.d.ts +0 -29
  226. package/build/renderable/trail.d.ts.map +1 -1
  227. package/build/renderable/trigger.d.ts +0 -6
  228. package/build/renderable/trigger.d.ts.map +1 -1
  229. package/build/renderable/ui/uibaseelement.d.ts +0 -40
  230. package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
  231. package/build/renderable/ui/uispriteelement.d.ts +0 -35
  232. package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
  233. package/build/state/stage.d.ts +0 -66
  234. package/build/state/stage.d.ts.map +1 -1
  235. package/build/state/state.d.ts.map +1 -1
  236. package/build/system/device.d.ts +0 -12
  237. package/build/system/device.d.ts.map +1 -1
  238. package/build/system/dom.d.ts +1 -8
  239. package/build/system/dom.d.ts.map +1 -1
  240. package/build/system/legacy_pool.d.ts +1 -6
  241. package/build/system/legacy_pool.d.ts.map +1 -1
  242. package/build/system/platform.d.ts +0 -1
  243. package/build/system/platform.d.ts.map +1 -1
  244. package/build/system/pool.d.ts +0 -9
  245. package/build/system/pool.d.ts.map +1 -1
  246. package/build/system/save.d.ts.map +1 -1
  247. package/build/system/timer.d.ts +0 -20
  248. package/build/system/timer.d.ts.map +1 -1
  249. package/build/tweens/tween.d.ts +0 -62
  250. package/build/tweens/tween.d.ts.map +1 -1
  251. package/build/utils/array-multimap.d.ts +1 -13
  252. package/build/utils/array-multimap.d.ts.map +1 -1
  253. package/build/utils/decode.d.ts.map +1 -1
  254. package/build/utils/fetchdata.d.ts +1 -31
  255. package/build/utils/fetchdata.d.ts.map +1 -1
  256. package/build/utils/utils.d.ts +0 -13
  257. package/build/utils/utils.d.ts.map +1 -1
  258. package/build/video/blendmodes.d.ts +1 -106
  259. package/build/video/blendmodes.d.ts.map +1 -1
  260. package/build/video/buffer/index.d.ts +1 -39
  261. package/build/video/buffer/index.d.ts.map +1 -1
  262. package/build/video/buffer/vertex.d.ts +1 -82
  263. package/build/video/buffer/vertex.d.ts.map +1 -1
  264. package/build/video/canvas/canvas_renderer.d.ts +2 -23
  265. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  266. package/build/video/canvas_factory.d.ts +1 -24
  267. package/build/video/canvas_factory.d.ts.map +1 -1
  268. package/build/video/effects/blendEffect.d.ts +0 -54
  269. package/build/video/effects/blendEffect.d.ts.map +1 -1
  270. package/build/video/effects/colorMatrix.d.ts +0 -10
  271. package/build/video/effects/colorMatrix.d.ts.map +1 -1
  272. package/build/video/effects/glsl_realization.d.ts +1 -17
  273. package/build/video/effects/glsl_realization.d.ts.map +1 -1
  274. package/build/video/effects/radialGradient.d.ts +0 -1
  275. package/build/video/effects/radialGradient.d.ts.map +1 -1
  276. package/build/video/effects/shadereffect.d.ts +0 -113
  277. package/build/video/effects/shadereffect.d.ts.map +1 -1
  278. package/build/video/effects/wgsl/layout.d.ts +1 -27
  279. package/build/video/effects/wgsl/layout.d.ts.map +1 -1
  280. package/build/video/effects/wgsl/parse.d.ts +1 -8
  281. package/build/video/effects/wgsl/parse.d.ts.map +1 -1
  282. package/build/video/effects/wgsl/scaffold.d.ts +1 -42
  283. package/build/video/effects/wgsl/scaffold.d.ts.map +1 -1
  284. package/build/video/effects/wgsl_realization.d.ts +1 -82
  285. package/build/video/effects/wgsl_realization.d.ts.map +1 -1
  286. package/build/video/gpu/batcher.d.ts +1 -13
  287. package/build/video/gpu/batcher.d.ts.map +1 -1
  288. package/build/video/gpu/instancerecord.d.ts +1 -163
  289. package/build/video/gpu/instancerecord.d.ts.map +1 -1
  290. package/build/video/gpu/meshchunk.d.ts +1 -48
  291. package/build/video/gpu/meshchunk.d.ts.map +1 -1
  292. package/build/video/gpu/meshvertex.d.ts +1 -53
  293. package/build/video/gpu/meshvertex.d.ts.map +1 -1
  294. package/build/video/gpu/primitives.d.ts +1 -59
  295. package/build/video/gpu/primitives.d.ts.map +1 -1
  296. package/build/video/gpu/quadcorners.d.ts +1 -10
  297. package/build/video/gpu/quadcorners.d.ts.map +1 -1
  298. package/build/video/gpu/textureslots.d.ts +1 -121
  299. package/build/video/gpu/textureslots.d.ts.map +1 -1
  300. package/build/video/gpu/texturestore.d.ts +1 -138
  301. package/build/video/gpu/texturestore.d.ts.map +1 -1
  302. package/build/video/gpu/topology.d.ts.map +1 -1
  303. package/build/video/gpu/vertexformat.d.ts +0 -28
  304. package/build/video/gpu/vertexformat.d.ts.map +1 -1
  305. package/build/video/gradient.d.ts +0 -81
  306. package/build/video/gradient.d.ts.map +1 -1
  307. package/build/video/renderer.d.ts +21 -102
  308. package/build/video/renderer.d.ts.map +1 -1
  309. package/build/video/renderstate.d.ts +0 -51
  310. package/build/video/renderstate.d.ts.map +1 -1
  311. package/build/video/rendertarget/canvasrendertarget.d.ts +0 -10
  312. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  313. package/build/video/rendertarget/render_target_pool.d.ts +1 -82
  314. package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
  315. package/build/video/rendertarget/webglrendertarget.d.ts +1 -64
  316. package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
  317. package/build/video/rendertarget/webgpurendertarget.d.ts +0 -8
  318. package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -1
  319. package/build/video/texture/atlas.d.ts +1 -75
  320. package/build/video/texture/atlas.d.ts.map +1 -1
  321. package/build/video/texture/cache.d.ts +0 -136
  322. package/build/video/texture/cache.d.ts.map +1 -1
  323. package/build/video/texture/frametexture.d.ts +1 -71
  324. package/build/video/texture/frametexture.d.ts.map +1 -1
  325. package/build/video/texture/noise_texture2d.d.ts +0 -43
  326. package/build/video/texture/noise_texture2d.d.ts.map +1 -1
  327. package/build/video/texture/parser/aseprite.d.ts +1 -8
  328. package/build/video/texture/parser/aseprite.d.ts.map +1 -1
  329. package/build/video/texture/parser/spritesheet.d.ts +1 -8
  330. package/build/video/texture/parser/spritesheet.d.ts.map +1 -1
  331. package/build/video/texture/parser/texturepacker.d.ts +1 -8
  332. package/build/video/texture/parser/texturepacker.d.ts.map +1 -1
  333. package/build/video/texture/resource.d.ts +0 -9
  334. package/build/video/texture/resource.d.ts.map +1 -1
  335. package/build/video/texture/texture2d.d.ts +0 -11
  336. package/build/video/texture/texture2d.d.ts.map +1 -1
  337. package/build/video/utils/autodetect.d.ts +1 -5
  338. package/build/video/utils/autodetect.d.ts.map +1 -1
  339. package/build/video/webgl/batchers/batcher.d.ts +0 -55
  340. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  341. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +0 -14
  342. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
  343. package/build/video/webgl/batchers/lit_quad_batcher.d.ts +0 -72
  344. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  345. package/build/video/webgl/batchers/material_batcher.d.ts +0 -89
  346. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  347. package/build/video/webgl/batchers/mesh_batcher.d.ts +14 -343
  348. package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
  349. package/build/video/webgl/batchers/primitive_batcher.d.ts +0 -10
  350. package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
  351. package/build/video/webgl/batchers/quad_batcher.d.ts +0 -30
  352. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  353. package/build/video/webgl/buffer/index.d.ts +1 -36
  354. package/build/video/webgl/buffer/index.d.ts.map +1 -1
  355. package/build/video/webgl/buffer/instance_buffer.d.ts +1 -53
  356. package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -1
  357. package/build/video/webgl/buffer/retained_geometry.d.ts +1 -81
  358. package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -1
  359. package/build/video/webgl/buffer/uniformblock.d.ts +1 -80
  360. package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -1
  361. package/build/video/webgl/buffer/vertexstate.d.ts +1 -100
  362. package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -1
  363. package/build/video/webgl/glshader.d.ts +0 -49
  364. package/build/video/webgl/glshader.d.ts.map +1 -1
  365. package/build/video/webgl/lighting/pack3d.d.ts +1 -47
  366. package/build/video/webgl/lighting/pack3d.d.ts.map +1 -1
  367. package/build/video/webgl/lighting/std140.d.ts +1 -109
  368. package/build/video/webgl/lighting/std140.d.ts.map +1 -1
  369. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts +1 -103
  370. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  371. package/build/video/webgl/shaders/multitexture-lit.d.ts +1 -26
  372. package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
  373. package/build/video/webgl/shaders/multitexture.d.ts +1 -9
  374. package/build/video/webgl/shaders/multitexture.d.ts.map +1 -1
  375. package/build/video/webgl/texture/store.d.ts +1 -50
  376. package/build/video/webgl/texture/store.d.ts.map +1 -1
  377. package/build/video/webgl/utils/attributes.d.ts +1 -11
  378. package/build/video/webgl/utils/attributes.d.ts.map +1 -1
  379. package/build/video/webgl/utils/maxtextures.d.ts +1 -36
  380. package/build/video/webgl/utils/maxtextures.d.ts.map +1 -1
  381. package/build/video/webgl/utils/precision.d.ts +1 -14
  382. package/build/video/webgl/utils/precision.d.ts.map +1 -1
  383. package/build/video/webgl/utils/program.d.ts +1 -5
  384. package/build/video/webgl/utils/program.d.ts.map +1 -1
  385. package/build/video/webgl/utils/samplercache.d.ts +1 -68
  386. package/build/video/webgl/utils/samplercache.d.ts.map +1 -1
  387. package/build/video/webgl/utils/string.d.ts +1 -21
  388. package/build/video/webgl/utils/string.d.ts.map +1 -1
  389. package/build/video/webgl/utils/topology.d.ts +1 -23
  390. package/build/video/webgl/utils/topology.d.ts.map +1 -1
  391. package/build/video/webgl/utils/uniforms.d.ts +1 -25
  392. package/build/video/webgl/utils/uniforms.d.ts.map +1 -1
  393. package/build/video/webgl/utils/vertexformat.d.ts +1 -26
  394. package/build/video/webgl/utils/vertexformat.d.ts.map +1 -1
  395. package/build/video/webgl/webgl_renderer.d.ts +22 -285
  396. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  397. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts +0 -6
  398. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -1
  399. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +0 -8
  400. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -1
  401. package/build/video/webgpu/batchers/mesh_batcher.d.ts +1 -230
  402. package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
  403. package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -1
  404. package/build/video/webgpu/batchers/quad_batcher.d.ts +0 -82
  405. package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
  406. package/build/video/webgpu/buffer/arena.d.ts +1 -63
  407. package/build/video/webgpu/buffer/arena.d.ts.map +1 -1
  408. package/build/video/webgpu/buffer/instance_buffer.d.ts +1 -64
  409. package/build/video/webgpu/buffer/instance_buffer.d.ts.map +1 -1
  410. package/build/video/webgpu/buffer/retained_geometry.d.ts +1 -54
  411. package/build/video/webgpu/buffer/retained_geometry.d.ts.map +1 -1
  412. package/build/video/webgpu/buffer/uniformring.d.ts +1 -67
  413. package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -1
  414. package/build/video/webgpu/effect_binding.d.ts +1 -16
  415. package/build/video/webgpu/effect_binding.d.ts.map +1 -1
  416. package/build/video/webgpu/pipeline/bindgroups.d.ts +1 -32
  417. package/build/video/webgpu/pipeline/bindgroups.d.ts.map +1 -1
  418. package/build/video/webgpu/pipeline/cache.d.ts +1 -163
  419. package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
  420. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +1 -87
  421. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  422. package/build/video/webgpu/shaders/mesh-instanced.d.ts +1 -43
  423. package/build/video/webgpu/shaders/mesh-instanced.d.ts.map +1 -1
  424. package/build/video/webgpu/texture/compressed.d.ts +1 -32
  425. package/build/video/webgpu/texture/compressed.d.ts.map +1 -1
  426. package/build/video/webgpu/texture/frametexture.d.ts +1 -62
  427. package/build/video/webgpu/texture/frametexture.d.ts.map +1 -1
  428. package/build/video/webgpu/texture/store.d.ts +1 -147
  429. package/build/video/webgpu/texture/store.d.ts.map +1 -1
  430. package/build/video/webgpu/webgpu_renderer.d.ts +0 -88
  431. package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
  432. package/package.json +5 -4
  433. package/skills/melonjs/SKILL.md +1 -1
  434. package/skills/melonjs-3d/SKILL.md +301 -2
  435. package/skills/melonjs-3d-assets/SKILL.md +25 -6
  436. package/skills/melonjs-audio/SKILL.md +21 -0
  437. package/skills/melonjs-camera-and-drawing/SKILL.md +4 -0
  438. package/skills/melonjs-effects-and-shaders/SKILL.md +2 -1
  439. package/skills/melonjs-loading-assets/SKILL.md +30 -1
  440. package/skills/melonjs-performance/SKILL.md +5 -0
  441. package/skills/melonjs-tilemaps/SKILL.md +31 -11
  442. package/skills/melonjs-ui-and-text/SKILL.md +17 -127
@@ -1,6 +1,6 @@
1
1
  ---
2
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, castGroundShadow, lit."
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
4
  license: MIT
5
5
  ---
6
6
 
@@ -97,6 +97,157 @@ index** — a real world depth in a 3D scene, and never the one you wanted. Pass
97
97
  it (`world.addChild(mesh, z)`), or set `mesh.depth` afterwards. The glTF
98
98
  importer turns `autoDepth` off on the container it loads into for this reason.
99
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
+
100
251
  ## Meshes
101
252
 
102
253
  ```js
@@ -115,9 +266,127 @@ there — place the origin where you want the pivot at authoring time, or nest t
115
266
  mesh under a transformed parent. The anchor is only honoured on the legacy
116
267
  2D-camera path.
117
268
 
269
+ ### InstancedMesh, and when it is the wrong tool
270
+
118
271
  **`InstancedMesh`** draws one mesh many times in a single draw call — the
119
272
  difference between a hundred trees and a hundred thousand. glTF scenes using
120
- `EXT_mesh_gpu_instancing` load as an `InstancedMesh` automatically.
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.
121
390
 
122
391
  ## Sprite3d and billboards
123
392
 
@@ -164,6 +433,18 @@ skip geometry with no vertical extent — a ground plane. Per object,
164
433
  `castGroundShadow: true`/`false` overrides the app setting and is obeyed as
165
434
  given, safeguard included; `shadowGroundY` names the floor the blob lands on.
166
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
+
167
448
  ## glTF / GLB scenes
168
449
 
169
450
  Loaded through the same level director as everything else:
@@ -209,11 +490,29 @@ To branch rather than fail, read `app.renderer.supportsDepthBuffer` after
209
490
 
210
491
  | symptom | cause |
211
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 |
212
498
  | nothing renders, or a backdrop covers everything | wrong depth sign — "far" is *larger* z when looking along +Z |
213
499
  | distant objects vanish or warp | scene exceeds the default far plane; `setClipPlanes` |
214
500
  | distant surfaces z-fight | `near` too small for the scene scale |
215
501
  | black canvas under `Camera3d` | Canvas renderer (no depth buffer) — check the `console.warn` |
216
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 |
217
516
  | a mesh sits at the wrong depth after being added | `autoDepth` overwrote `pos.z` with the child index — pass `addChild(mesh, z)` |
218
517
  | a mesh sits half its size off | `anchorPoint` — only on the 2D-camera path; a `Camera3d` mesh pivots on its model origin |
219
518
  | a billboard tips over when the camera looks down | `"spherical"`, or a mistyped mode string falling through to it — use `true` / `"cylindrical"` |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: melonjs-3d-assets
3
- description: "Use this skill when loading 3D models into melonJS — glTF and GLB scenes, OBJ/MTL models, materials, imported lights, node animation, ground shadows and GPU instancing. Covers level.load options, the rightHanded conversion, and exactly what the loader does and does not support. Triggers on: glTF, gltf, glb, OBJ, MTL, 3D model, getGLTF, getOBJ, getMTL, GLTFModel, GLTFScene, level.load glb, rightHanded, lightIntensityScale, castGroundShadow, shadowGroundY, EXT_mesh_gpu_instancing, KHR_lights_punctual, skinning, Blender export, 3D asset."
3
+ description: "Use this skill when loading 3D models into melonJS — glTF and GLB scenes, OBJ/MTL models, materials, imported lights, node animation, ground shadows and GPU instancing. Covers level.load options including the async flag, the rightHanded conversion, and exactly what the loader does and does not support. Triggers on: glTF, gltf, glb, OBJ, MTL, 3D model, getGLTF, getOBJ, getMTL, GLTFModel, GLTFScene, level.load glb, rightHanded, lightIntensityScale, castGroundShadow, shadowGroundY, EXT_mesh_gpu_instancing, KHR_lights_punctual, skinning, Blender export, 3D asset."
4
4
  license: MIT
5
5
  ---
6
6
 
@@ -34,6 +34,7 @@ or it renders flat. See `melonjs-3d` for the camera.
34
34
  | `scale` | `1` | pixels per glTF unit, applied to the whole scene. Blender's metre-scale export usually needs 20–100. |
35
35
  | `container` | `game.world` | where the nodes are added |
36
36
  | `onLoaded` | `app.onLevelLoaded` | called with the **level id**, not the scene |
37
+ | `async` | `false` | return a promise that settles once the scene is in the world, instead of a boolean |
37
38
  | `rightHanded` | `true` | see below |
38
39
  | `lights` | `true` | instantiate authored `KHR_lights_punctual` lights as `Light3d` world children |
39
40
  | `lightIntensityScale` | — | keep authored intensity ratios instead of normalising every light to 1 |
@@ -41,10 +42,19 @@ or it renders flat. See `melonjs-3d` for the camera.
41
42
  | `shadowGroundY` | each object's own base | world Y of the floor the blobs land on |
42
43
 
43
44
  `onLoaded` receives the level id — it is a "done" signal, not a handle on the
44
- scene. You need it: with the game loop running, `level.load` stops the loop and
45
- defers the actual load to the next tick, so it returns *before* anything is in
46
- the world. To get at what was loaded, load into a container you own, or look the
47
- nodes up by their authored names:
45
+ scene. You need it, or `async`: with the game loop running, `level.load` stops
46
+ the loop and defers the actual load to a timer, so by default it returns
47
+ *before* anything is in the world.
48
+
49
+ ```js
50
+ await level.load("diorama", { scale: 50, async: true });
51
+ // the scene is in the world here
52
+ ```
53
+
54
+ Note `await level.load("diorama")` without the flag does not await the load — the
55
+ call returns a boolean, and `await true` resolves immediately. To get at what was
56
+ loaded, load into a container you own, or look the nodes up by their authored
57
+ names:
48
58
 
49
59
  ```js
50
60
  level.load("diorama", { scale: 50, onLoaded: () => {
@@ -166,6 +176,12 @@ Omit `shadowGroundY` and each blob sits at its own object's base at full
166
176
  strength, which is right for props already resting on the ground. Set it when
167
177
  things jump or fly, so the shadow stays on the floor and shrinks with height.
168
178
 
179
+ A blob is centred on its caster's x/z and is never offset by light direction, so
180
+ a wide flat-bottomed prop hides its own shadow under itself. Raising
181
+ `shadowGroundY` to force one into view floats the blob up over the object as a
182
+ dark ring rather than sliding it clear — the setting is for things that leave
183
+ the ground, not a visibility knob.
184
+
169
185
  ## OBJ/MTL
170
186
 
171
187
  A different shape entirely: OBJ produces raw geometry you hand to a `Mesh`,
@@ -227,13 +243,16 @@ need a prefix.
227
243
  | a character does not deform | vertex skinning is out of scope; rig hierarchically or billboard |
228
244
  | animation names come back empty | the asset has no node-TRS channels (skin-only rig) |
229
245
  | a hundred copies tank the frame rate | exported without `EXT_mesh_gpu_instancing` |
246
+ | a prop casts no visible shadow | wide and flat-bottomed — the blob is under it; `shadowGroundY` haloes it rather than revealing it |
230
247
  | a shadow smeared across the whole floor | a ground plane cast its own blob — use the scene-wide opt-in |
231
248
  | `onLoaded` gets a string, not the scene | it is called with the level id; load into your own container instead |
232
249
  | scene renders flat and unlit | no `Camera3d` — the 2D-camera path is CPU-projected and unlit (with a `Camera3d` on Canvas you get a black canvas instead) |
233
250
 
234
251
  ## Related skills
235
252
 
236
- - `melonjs-3d` — conventions, `Camera3d`, meshes, `Light3d`, instancing
253
+ - `melonjs-3d` — conventions, `Camera3d`, meshes, `Light3d`, instancing, and
254
+ `camera.setFog` (an outdoor scene almost always wants it; it is set on the
255
+ camera, so a loaded scene needs no per-node work)
237
256
  - `melonjs-lighting` — how `Light3d` behaves once imported
238
257
  - `melonjs-loading-assets` — the loader, asset types and base URLs
239
258
  - `melonjs-plugins` — the Spine plugin, for skeletal characters
@@ -195,6 +195,25 @@ same switch under its backend name.) `on` accepts the full lifecycle set:
195
195
  Re-preloading a manifest that already contains a loaded clip is a no-op —
196
196
  `audio.unload(name)` first if you genuinely want to reload it.
197
197
 
198
+ **Credentials use the same global switch as every other asset type** —
199
+ `loader.setOptions({ withCredentials: true })`, not an audio-specific option.
200
+ Buffered audio fetches through the shared loader path, so it honours it exactly
201
+ as an image or a JSON file does. A `stream: true` clip does not: it plays
202
+ through an `<audio>` element, which needs a `crossorigin` attribute rather than
203
+ fetch credentials. Preload a clip buffered if it sits behind a login.
204
+
205
+ **Failing clips and `setStopOnAudioError(false)`.** The default is to fail the
206
+ preload when a clip cannot be loaded after its retries: the error reaches the
207
+ loader, so `await loader.preload(...)` rejects and your `catch` runs, and the
208
+ reason is logged. Turn the flag off and the engine mutes audio, warns
209
+ (`failed loading <name>, disabling audio`) and lets the load *continue* — the
210
+ preload finishes and the game reaches the next scene without sound.
211
+
212
+ Before 20.4 both halves were broken: with the flag off it disabled audio and
213
+ failed the preload anyway, and a clip whose bytes arrived but would not decode
214
+ (a missing file served as HTML by an SPA rewrite, say) reported nothing at all
215
+ either way — blank screen, empty console.
216
+
198
217
  ## Symptom → cause
199
218
 
200
219
  | symptom | cause |
@@ -207,6 +226,8 @@ Re-preloading a manifest that already contains a loaded clip is a no-op —
207
226
  | music keeps playing after leaving a scene | used `play` instead of `playTrack`, or no `stopTrack` in teardown |
208
227
  | `stereo` / `position` do nothing | the clip was loaded with `stream: true` — spatial is WebAudio-only |
209
228
  | one format works, another does not | that codec is not in the `audio.init()` list |
229
+ | audio behind a login fails, or the preload hangs | `loader.setOptions({ withCredentials: true })` — the same switch every asset type uses |
230
+ | a streamed clip ignores `withCredentials` | `stream: true` plays through an `<audio>` element; preload it buffered instead |
210
231
  | `audio.tone(440, {...})` does nothing / errors | `tone` takes a single options object with a required `duration` |
211
232
  | `tone` / `noise` are silent with no error | no WebAudio context — `getAudioContext()` returned `null` |
212
233
 
@@ -87,6 +87,10 @@ and an overridden `postDraw`:
87
87
  this.cameras.set("minimap", new MinimapCamera());
88
88
  ```
89
89
 
90
+ View state is per camera, not per scene: a `Camera3d` carries its own distance
91
+ fog (`setFog`), so a minimap or split-screen view fogs independently of the main
92
+ one — and a `Camera2d` never fogs. See `melonjs-3d`.
93
+
90
94
  ## Immediate-mode drawing
91
95
 
92
96
  Inside a custom `draw(renderer)` you can draw shapes directly. Remember the two
@@ -174,4 +174,5 @@ same question after construction.
174
174
  ## Related skills
175
175
 
176
176
  - `melonjs-renderables` — where post effects attach, and the destroy trap
177
- - `melonjs-3d` — custom mesh shaders and the GPU-backend requirement
177
+ - `melonjs-3d` — the GPU-backend requirement, and why a custom mesh shader is
178
+ not affected by the camera's distance fog
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: melonjs-loading-assets
3
- description: "Use this skill for loading and managing game assets in melonJS — the resource descriptor format, the full asset type list, preload versus load, retrieving loaded assets, base URLs and cross-origin settings, and the loading screen. Triggers on: loader, loader.preload, loader.load, resources, getImage, getJSON, getTMX, getGLTF, getVideo, getFont, setBaseURL, setOptions, crossOrigin, asset, preload, LOADER_COMPLETE, loading screen, unload."
3
+ description: "Use this skill for loading and managing game assets in melonJS — the resource descriptor format, the full asset type list, preload versus load, retrieving loaded assets, base URLs and cross-origin settings, and the loading screen. Triggers on: loader, loader.preload, loader.load, resources, getImage, getJSON, getTMX, getGLTF, getVideo, getFont, setBaseURL, setOptions, crossOrigin, withCredentials, credentials, cookies, authenticated assets, CORS, asset, preload, LOADER_COMPLETE, loading screen, unload."
4
4
  license: MIT
5
5
  ---
6
6
 
@@ -138,6 +138,32 @@ If you preload without a loading stage and then change state immediately, pass
138
138
  state.change(state.PLAY, true);
139
139
  ```
140
140
 
141
+ ## Cross-origin and authenticated assets
142
+
143
+ Two settings, both global and both applying to **every** asset type — there is
144
+ no per-asset or per-type spelling to remember:
145
+
146
+ ```js
147
+ loader.setOptions({
148
+ crossOrigin: "anonymous", // CORS mode for remote assets
149
+ withCredentials: true, // send cookies / auth with the request
150
+ });
151
+ ```
152
+
153
+ `withCredentials` is what an asset behind a session cookie or an
154
+ `Authorization`-style login needs. Every fetched asset — image, json, binary,
155
+ tmx, tsx, shader, gltf/glb, obj, mtl, aseprite, video — carries it, and so does
156
+ buffered audio.
157
+
158
+ **Set them through `setOptions`.** `loader.crossOrigin` and
159
+ `loader.withCredentials` are read-only module bindings; assigning to them
160
+ throws, the same trap as the removed `loader.onload` / `onProgress`.
161
+
162
+ | | |
163
+ | --- | --- |
164
+ | one streamed clip (`stream: true` / `html5: true`) ignores `withCredentials` | it plays through an `<audio>` element, which needs a `crossorigin` attribute rather than fetch credentials. Preload it buffered if it is behind auth |
165
+ | credentials silently dropped for audio before 20.4 | the loader forwarded them under a pre-20.3 name the backend never read — a hung preload rather than an error |
166
+
141
167
  ## Symptom → cause
142
168
 
143
169
  | symptom | cause |
@@ -146,6 +172,9 @@ state.change(state.PLAY, true);
146
172
  | audio fails, `preload()` rejects with "Failed loading resource" | `audio.init()` not called before preloading — the real message is replaced by the loader's |
147
173
  | blank level, missing tiles | `.tsx` or tileset image not listed in the resources |
148
174
  | cross-origin textures fail | missing `loader.setOptions({ crossOrigin: "anonymous" })` |
175
+ | assets behind a login 401 / audio preload hangs | missing `loader.setOptions({ withCredentials: true })` — one switch, all asset types |
176
+ | `TypeError` assigning `loader.withCredentials` / `crossOrigin` | read-only module bindings; use `loader.setOptions({ … })` |
177
+ | preload never finishes, blank screen, no error | a failing sound with `audio.setStopOnAudioError(false)` before 20.4 — it disabled audio *and* failed the preload |
149
178
  | text renders in a fallback font | web font not preloaded as `"fontface"` |
150
179
  | `BitmapText` renders nothing | the `.fnt` (as `"binary"`) or its image is missing |
151
180
  | `TypeError` assigning `loader.onProgress` / `onload` | removed in 20.3; they were never writable — use the `LOADER_*` events |
@@ -126,6 +126,11 @@ collapse to one.
126
126
  between a hundred trees and a hundred thousand. glTF scenes using
127
127
  `EXT_mesh_gpu_instancing` load as an `InstancedMesh` automatically.
128
128
 
129
+ It trades per-object control for the draw call: the set gets ONE depth sort key
130
+ and ONE ground shadow, and `removeInstance` swaps the last instance into the
131
+ hole so held indices go stale. Scenery yes; anything the game removes or
132
+ queries one at a time, usually not. See `melonjs-3d` for the decision table.
133
+
129
134
  ## Update loops
130
135
 
131
136
  - `update(dt)` should **return `true` only when something changed**. Returning
@@ -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`) |