melonjs 20.3.0 → 20.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (454) hide show
  1. package/README.md +19 -19
  2. package/build/application/application.d.ts +0 -17
  3. package/build/application/application.d.ts.map +1 -1
  4. package/build/application/settings.d.ts +3 -0
  5. package/build/application/settings.d.ts.map +1 -1
  6. package/build/audio/audio.d.ts.map +1 -1
  7. package/build/audio/backend/engine.d.ts +0 -19
  8. package/build/audio/backend/engine.d.ts.map +1 -1
  9. package/build/audio/backend/sound.d.ts +1 -51
  10. package/build/audio/backend/sound.d.ts.map +1 -1
  11. package/build/audio/backend/spatial.d.ts.map +1 -1
  12. package/build/audio/backend/types.d.ts +11 -1
  13. package/build/audio/backend/types.d.ts.map +1 -1
  14. package/build/audio/backend/voice.d.ts +0 -25
  15. package/build/audio/backend/voice.d.ts.map +1 -1
  16. package/build/audio/playback.d.ts.map +1 -1
  17. package/build/audio/procedural.d.ts +7 -2
  18. package/build/audio/procedural.d.ts.map +1 -1
  19. package/build/audio/state.d.ts +6 -79
  20. package/build/audio/state.d.ts.map +1 -1
  21. package/build/audio/types.d.ts +22 -0
  22. package/build/audio/types.d.ts.map +1 -1
  23. package/build/camera/camera2d.d.ts +28 -68
  24. package/build/camera/camera2d.d.ts.map +1 -1
  25. package/build/camera/camera3d.d.ts +110 -82
  26. package/build/camera/camera3d.d.ts.map +1 -1
  27. package/build/camera/effects/fade_effect.d.ts +0 -5
  28. package/build/camera/effects/fade_effect.d.ts.map +1 -1
  29. package/build/camera/effects/mask_effect.d.ts +0 -5
  30. package/build/camera/effects/mask_effect.d.ts.map +1 -1
  31. package/build/camera/fog.d.ts +118 -0
  32. package/build/camera/fog.d.ts.map +1 -0
  33. package/build/geometries/box3d.d.ts +0 -28
  34. package/build/geometries/box3d.d.ts.map +1 -1
  35. package/build/geometries/ellipse.d.ts +0 -20
  36. package/build/geometries/ellipse.d.ts.map +1 -1
  37. package/build/geometries/observablePoint.d.ts +0 -3
  38. package/build/geometries/observablePoint.d.ts.map +1 -1
  39. package/build/geometries/path2d.d.ts +0 -19
  40. package/build/geometries/path2d.d.ts.map +1 -1
  41. package/build/geometries/polygon.d.ts +7 -13
  42. package/build/geometries/polygon.d.ts.map +1 -1
  43. package/build/geometries/roundrect.d.ts +0 -18
  44. package/build/geometries/roundrect.d.ts.map +1 -1
  45. package/build/geometries/sphere.d.ts +0 -9
  46. package/build/geometries/sphere.d.ts.map +1 -1
  47. package/build/geometries/toarccanvas.d.ts.map +1 -1
  48. package/build/index.d.ts +5 -0
  49. package/build/index.d.ts.map +1 -1
  50. package/build/index.js +3697 -563
  51. package/build/index.js.map +4 -4
  52. package/build/input/gamepad.d.ts.map +1 -1
  53. package/build/input/pointer.d.ts +0 -4
  54. package/build/input/pointer.d.ts.map +1 -1
  55. package/build/input/pointerevent.d.ts +0 -6
  56. package/build/input/pointerevent.d.ts.map +1 -1
  57. package/build/lang/deprecated.d.ts.map +1 -1
  58. package/build/level/gltf/GLTFModel.d.ts +44 -82
  59. package/build/level/gltf/GLTFModel.d.ts.map +1 -1
  60. package/build/level/gltf/GLTFScene.d.ts +1 -44
  61. package/build/level/gltf/GLTFScene.d.ts.map +1 -1
  62. package/build/level/gltf/gltf_sampler.d.ts +1 -48
  63. package/build/level/gltf/gltf_sampler.d.ts.map +1 -1
  64. package/build/level/level.d.ts +195 -113
  65. package/build/level/level.d.ts.map +1 -1
  66. package/build/level/tiled/TMXGroup.d.ts +1 -65
  67. package/build/level/tiled/TMXGroup.d.ts.map +1 -1
  68. package/build/level/tiled/TMXLayer.d.ts +0 -44
  69. package/build/level/tiled/TMXLayer.d.ts.map +1 -1
  70. package/build/level/tiled/TMXObject.d.ts +1 -136
  71. package/build/level/tiled/TMXObject.d.ts.map +1 -1
  72. package/build/level/tiled/TMXObjectFactory.d.ts +1 -40
  73. package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
  74. package/build/level/tiled/TMXTile.d.ts +1 -30
  75. package/build/level/tiled/TMXTile.d.ts.map +1 -1
  76. package/build/level/tiled/TMXTileMap.d.ts +0 -10
  77. package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
  78. package/build/level/tiled/TMXTileset.d.ts +0 -113
  79. package/build/level/tiled/TMXTileset.d.ts.map +1 -1
  80. package/build/level/tiled/TMXTilesetGroup.d.ts +0 -1
  81. package/build/level/tiled/TMXTilesetGroup.d.ts.map +1 -1
  82. package/build/level/tiled/TMXUtils.d.ts +1 -43
  83. package/build/level/tiled/TMXUtils.d.ts.map +1 -1
  84. package/build/level/tiled/factories/shape.d.ts +1 -7
  85. package/build/level/tiled/factories/shape.d.ts.map +1 -1
  86. package/build/level/tiled/factories/text.d.ts +1 -7
  87. package/build/level/tiled/factories/text.d.ts.map +1 -1
  88. package/build/level/tiled/factories/tile.d.ts +1 -7
  89. package/build/level/tiled/factories/tile.d.ts.map +1 -1
  90. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +0 -60
  91. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
  92. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +0 -42
  93. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
  94. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +0 -5
  95. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
  96. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +0 -31
  97. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
  98. package/build/level/tiled/renderer/TMXRenderer.d.ts +2 -2
  99. package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
  100. package/build/level/tiled/renderer/TMXStaggeredRenderer.d.ts.map +1 -1
  101. package/build/level/tiled/renderer/autodetect.d.ts +1 -6
  102. package/build/level/tiled/renderer/autodetect.d.ts.map +1 -1
  103. package/build/lighting/light2d.d.ts +0 -25
  104. package/build/lighting/light2d.d.ts.map +1 -1
  105. package/build/lighting/light3d.d.ts +20 -63
  106. package/build/lighting/light3d.d.ts.map +1 -1
  107. package/build/loader/loader.d.ts +146 -37
  108. package/build/loader/loader.d.ts.map +1 -1
  109. package/build/loader/loadingscreen.d.ts +0 -33
  110. package/build/loader/loadingscreen.d.ts.map +1 -1
  111. package/build/loader/parsers/aseprite.d.ts +0 -13
  112. package/build/loader/parsers/aseprite.d.ts.map +1 -1
  113. package/build/loader/parsers/audio.d.ts +1 -30
  114. package/build/loader/parsers/audio.d.ts.map +1 -1
  115. package/build/loader/parsers/binary.d.ts +1 -10
  116. package/build/loader/parsers/binary.d.ts.map +1 -1
  117. package/build/loader/parsers/compressed_textures/compressed_image.d.ts.map +1 -1
  118. package/build/loader/parsers/compressed_textures/parseDDS.d.ts +1 -7
  119. package/build/loader/parsers/compressed_textures/parseDDS.d.ts.map +1 -1
  120. package/build/loader/parsers/compressed_textures/parseKTX.d.ts +1 -7
  121. package/build/loader/parsers/compressed_textures/parseKTX.d.ts.map +1 -1
  122. package/build/loader/parsers/compressed_textures/parseKTX2.d.ts +1 -7
  123. package/build/loader/parsers/compressed_textures/parseKTX2.d.ts.map +1 -1
  124. package/build/loader/parsers/compressed_textures/parsePKM.d.ts +1 -7
  125. package/build/loader/parsers/compressed_textures/parsePKM.d.ts.map +1 -1
  126. package/build/loader/parsers/compressed_textures/parsePVR.d.ts +1 -7
  127. package/build/loader/parsers/compressed_textures/parsePVR.d.ts.map +1 -1
  128. package/build/loader/parsers/fontface.d.ts +1 -13
  129. package/build/loader/parsers/fontface.d.ts.map +1 -1
  130. package/build/loader/parsers/gltf.d.ts +1 -70
  131. package/build/loader/parsers/gltf.d.ts.map +1 -1
  132. package/build/loader/parsers/image.d.ts +1 -22
  133. package/build/loader/parsers/image.d.ts.map +1 -1
  134. package/build/loader/parsers/json.d.ts +1 -10
  135. package/build/loader/parsers/json.d.ts.map +1 -1
  136. package/build/loader/parsers/mtl.d.ts +1 -28
  137. package/build/loader/parsers/mtl.d.ts.map +1 -1
  138. package/build/loader/parsers/obj.d.ts +1 -59
  139. package/build/loader/parsers/obj.d.ts.map +1 -1
  140. package/build/loader/parsers/pbr.d.ts +1 -62
  141. package/build/loader/parsers/pbr.d.ts.map +1 -1
  142. package/build/loader/parsers/script.d.ts +1 -10
  143. package/build/loader/parsers/script.d.ts.map +1 -1
  144. package/build/loader/parsers/shader.d.ts +1 -52
  145. package/build/loader/parsers/shader.d.ts.map +1 -1
  146. package/build/loader/parsers/tmx.d.ts +1 -10
  147. package/build/loader/parsers/tmx.d.ts.map +1 -1
  148. package/build/loader/parsers/video.d.ts +1 -10
  149. package/build/loader/parsers/video.d.ts.map +1 -1
  150. package/build/math/color.d.ts.map +1 -1
  151. package/build/math/noise.d.ts +0 -40
  152. package/build/math/noise.d.ts.map +1 -1
  153. package/build/math/observableVector2d.d.ts +0 -3
  154. package/build/math/observableVector2d.d.ts.map +1 -1
  155. package/build/math/observableVector3d.d.ts +0 -3
  156. package/build/math/observableVector3d.d.ts.map +1 -1
  157. package/build/math/vector2d.d.ts +0 -6
  158. package/build/math/vector2d.d.ts.map +1 -1
  159. package/build/math/vertex.d.ts +25 -0
  160. package/build/math/vertex.d.ts.map +1 -1
  161. package/build/particles/emitter.d.ts +0 -65
  162. package/build/particles/emitter.d.ts.map +1 -1
  163. package/build/particles/particle.d.ts +0 -81
  164. package/build/particles/particle.d.ts.map +1 -1
  165. package/build/physics/bounds.d.ts +0 -1
  166. package/build/physics/bounds.d.ts.map +1 -1
  167. package/build/physics/broadphase/broadphase.d.ts +0 -7
  168. package/build/physics/broadphase/broadphase.d.ts.map +1 -1
  169. package/build/physics/broadphase/octree.d.ts +0 -91
  170. package/build/physics/broadphase/octree.d.ts.map +1 -1
  171. package/build/physics/broadphase/quadtree.d.ts +0 -47
  172. package/build/physics/broadphase/quadtree.d.ts.map +1 -1
  173. package/build/physics/builtin/body.d.ts +2 -65
  174. package/build/physics/builtin/body.d.ts.map +1 -1
  175. package/build/physics/builtin/detector.d.ts +0 -312
  176. package/build/physics/builtin/detector.d.ts.map +1 -1
  177. package/build/physics/builtin/sat.d.ts +1 -48
  178. package/build/physics/builtin/sat.d.ts.map +1 -1
  179. package/build/physics/builtin/sat3d.d.ts +1 -56
  180. package/build/physics/builtin/sat3d.d.ts.map +1 -1
  181. package/build/physics/collision.d.ts +0 -2
  182. package/build/physics/collision.d.ts.map +1 -1
  183. package/build/physics/response.d.ts +0 -1
  184. package/build/physics/response.d.ts.map +1 -1
  185. package/build/physics/world.d.ts.map +1 -1
  186. package/build/renderable/anchorPoint.d.ts +1 -73
  187. package/build/renderable/anchorPoint.d.ts.map +1 -1
  188. package/build/renderable/animation.d.ts +21 -13
  189. package/build/renderable/animation.d.ts.map +1 -1
  190. package/build/renderable/colorlayer.d.ts +0 -5
  191. package/build/renderable/colorlayer.d.ts.map +1 -1
  192. package/build/renderable/container.d.ts +27 -60
  193. package/build/renderable/container.d.ts.map +1 -1
  194. package/build/renderable/draggable.d.ts +0 -5
  195. package/build/renderable/draggable.d.ts.map +1 -1
  196. package/build/renderable/dragndrop.d.ts +1 -12
  197. package/build/renderable/dragndrop.d.ts.map +1 -1
  198. package/build/renderable/entity/entity.d.ts +0 -8
  199. package/build/renderable/entity/entity.d.ts.map +1 -1
  200. package/build/renderable/frameAnimation.d.ts +0 -41
  201. package/build/renderable/frameAnimation.d.ts.map +1 -1
  202. package/build/renderable/groundshadow.d.ts +1 -91
  203. package/build/renderable/groundshadow.d.ts.map +1 -1
  204. package/build/renderable/imagelayer.d.ts +0 -29
  205. package/build/renderable/imagelayer.d.ts.map +1 -1
  206. package/build/renderable/instanced_mesh.d.ts +55 -108
  207. package/build/renderable/instanced_mesh.d.ts.map +1 -1
  208. package/build/renderable/mesh.d.ts +257 -231
  209. package/build/renderable/mesh.d.ts.map +1 -1
  210. package/build/renderable/nineslicesprite.d.ts +0 -4
  211. package/build/renderable/nineslicesprite.d.ts.map +1 -1
  212. package/build/renderable/renderable.d.ts +18 -44
  213. package/build/renderable/renderable.d.ts.map +1 -1
  214. package/build/renderable/sprite.d.ts +0 -45
  215. package/build/renderable/sprite.d.ts.map +1 -1
  216. package/build/renderable/sprite3d.d.ts +12 -97
  217. package/build/renderable/sprite3d.d.ts.map +1 -1
  218. package/build/renderable/text/bitmaptext.d.ts +32 -21
  219. package/build/renderable/text/bitmaptext.d.ts.map +1 -1
  220. package/build/renderable/text/bitmaptextdata.d.ts +0 -22
  221. package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
  222. package/build/renderable/text/glyph.d.ts +1 -39
  223. package/build/renderable/text/glyph.d.ts.map +1 -1
  224. package/build/renderable/text/text.d.ts +75 -20
  225. package/build/renderable/text/text.d.ts.map +1 -1
  226. package/build/renderable/text/textmetrics.d.ts +2 -0
  227. package/build/renderable/text/textmetrics.d.ts.map +1 -1
  228. package/build/renderable/text/textstyle.d.ts +1 -5
  229. package/build/renderable/text/textstyle.d.ts.map +1 -1
  230. package/build/renderable/trail.d.ts +0 -29
  231. package/build/renderable/trail.d.ts.map +1 -1
  232. package/build/renderable/trigger.d.ts +0 -6
  233. package/build/renderable/trigger.d.ts.map +1 -1
  234. package/build/renderable/ui/uibaseelement.d.ts +0 -40
  235. package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
  236. package/build/renderable/ui/uispriteelement.d.ts +0 -35
  237. package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
  238. package/build/state/stage.d.ts +5 -50
  239. package/build/state/stage.d.ts.map +1 -1
  240. package/build/state/state.d.ts.map +1 -1
  241. package/build/system/device.d.ts +1 -13
  242. package/build/system/device.d.ts.map +1 -1
  243. package/build/system/dom.d.ts +1 -8
  244. package/build/system/dom.d.ts.map +1 -1
  245. package/build/system/legacy_pool.d.ts +1 -6
  246. package/build/system/legacy_pool.d.ts.map +1 -1
  247. package/build/system/platform.d.ts +0 -1
  248. package/build/system/platform.d.ts.map +1 -1
  249. package/build/system/pool.d.ts +0 -9
  250. package/build/system/pool.d.ts.map +1 -1
  251. package/build/system/save.d.ts +44 -1
  252. package/build/system/save.d.ts.map +1 -1
  253. package/build/system/timer.d.ts +0 -20
  254. package/build/system/timer.d.ts.map +1 -1
  255. package/build/tweens/tween.d.ts +0 -62
  256. package/build/tweens/tween.d.ts.map +1 -1
  257. package/build/utils/array-multimap.d.ts +1 -13
  258. package/build/utils/array-multimap.d.ts.map +1 -1
  259. package/build/utils/decode.d.ts.map +1 -1
  260. package/build/utils/fetchdata.d.ts +1 -31
  261. package/build/utils/fetchdata.d.ts.map +1 -1
  262. package/build/utils/utils.d.ts +0 -13
  263. package/build/utils/utils.d.ts.map +1 -1
  264. package/build/video/blendmodes.d.ts +1 -106
  265. package/build/video/blendmodes.d.ts.map +1 -1
  266. package/build/video/buffer/index.d.ts +1 -39
  267. package/build/video/buffer/index.d.ts.map +1 -1
  268. package/build/video/buffer/vertex.d.ts +1 -82
  269. package/build/video/buffer/vertex.d.ts.map +1 -1
  270. package/build/video/canvas/canvas_renderer.d.ts +2 -23
  271. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  272. package/build/video/canvas_factory.d.ts +1 -24
  273. package/build/video/canvas_factory.d.ts.map +1 -1
  274. package/build/video/effects/blendEffect.d.ts +0 -54
  275. package/build/video/effects/blendEffect.d.ts.map +1 -1
  276. package/build/video/effects/colorMatrix.d.ts +0 -10
  277. package/build/video/effects/colorMatrix.d.ts.map +1 -1
  278. package/build/video/effects/glsl_realization.d.ts +1 -17
  279. package/build/video/effects/glsl_realization.d.ts.map +1 -1
  280. package/build/video/effects/mesh_splice.d.ts +2 -0
  281. package/build/video/effects/mesh_splice.d.ts.map +1 -0
  282. package/build/video/effects/radialGradient.d.ts +0 -1
  283. package/build/video/effects/radialGradient.d.ts.map +1 -1
  284. package/build/video/effects/shadereffect.d.ts +12 -241
  285. package/build/video/effects/shadereffect.d.ts.map +1 -1
  286. package/build/video/effects/wgsl/layout.d.ts +1 -27
  287. package/build/video/effects/wgsl/layout.d.ts.map +1 -1
  288. package/build/video/effects/wgsl/parse.d.ts +1 -8
  289. package/build/video/effects/wgsl/parse.d.ts.map +1 -1
  290. package/build/video/effects/wgsl/scaffold.d.ts +1 -42
  291. package/build/video/effects/wgsl/scaffold.d.ts.map +1 -1
  292. package/build/video/effects/wgsl_realization.d.ts +1 -82
  293. package/build/video/effects/wgsl_realization.d.ts.map +1 -1
  294. package/build/video/gpu/batcher.d.ts +1 -13
  295. package/build/video/gpu/batcher.d.ts.map +1 -1
  296. package/build/video/gpu/instancerecord.d.ts +1 -163
  297. package/build/video/gpu/instancerecord.d.ts.map +1 -1
  298. package/build/video/gpu/meshchunk.d.ts +1 -48
  299. package/build/video/gpu/meshchunk.d.ts.map +1 -1
  300. package/build/video/gpu/meshvertex.d.ts +1 -53
  301. package/build/video/gpu/meshvertex.d.ts.map +1 -1
  302. package/build/video/gpu/primitives.d.ts +1 -59
  303. package/build/video/gpu/primitives.d.ts.map +1 -1
  304. package/build/video/gpu/quadcorners.d.ts +1 -10
  305. package/build/video/gpu/quadcorners.d.ts.map +1 -1
  306. package/build/video/gpu/textureslots.d.ts +1 -121
  307. package/build/video/gpu/textureslots.d.ts.map +1 -1
  308. package/build/video/gpu/texturestore.d.ts +1 -138
  309. package/build/video/gpu/texturestore.d.ts.map +1 -1
  310. package/build/video/gpu/topology.d.ts.map +1 -1
  311. package/build/video/gpu/vertexformat.d.ts +0 -28
  312. package/build/video/gpu/vertexformat.d.ts.map +1 -1
  313. package/build/video/gradient.d.ts +15 -77
  314. package/build/video/gradient.d.ts.map +1 -1
  315. package/build/video/renderer.d.ts +21 -102
  316. package/build/video/renderer.d.ts.map +1 -1
  317. package/build/video/renderstate.d.ts +0 -51
  318. package/build/video/renderstate.d.ts.map +1 -1
  319. package/build/video/rendertarget/canvasrendertarget.d.ts +0 -10
  320. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  321. package/build/video/rendertarget/render_target_pool.d.ts +1 -82
  322. package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
  323. package/build/video/rendertarget/webglrendertarget.d.ts +1 -64
  324. package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
  325. package/build/video/rendertarget/webgpurendertarget.d.ts +0 -8
  326. package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -1
  327. package/build/video/texture/atlas.d.ts +1 -75
  328. package/build/video/texture/atlas.d.ts.map +1 -1
  329. package/build/video/texture/cache.d.ts +0 -136
  330. package/build/video/texture/cache.d.ts.map +1 -1
  331. package/build/video/texture/frametexture.d.ts +1 -71
  332. package/build/video/texture/frametexture.d.ts.map +1 -1
  333. package/build/video/texture/noise_texture2d.d.ts +101 -77
  334. package/build/video/texture/noise_texture2d.d.ts.map +1 -1
  335. package/build/video/texture/parser/aseprite.d.ts +1 -8
  336. package/build/video/texture/parser/aseprite.d.ts.map +1 -1
  337. package/build/video/texture/parser/spritesheet.d.ts +1 -8
  338. package/build/video/texture/parser/spritesheet.d.ts.map +1 -1
  339. package/build/video/texture/parser/texturepacker.d.ts +1 -8
  340. package/build/video/texture/parser/texturepacker.d.ts.map +1 -1
  341. package/build/video/texture/resource.d.ts +0 -9
  342. package/build/video/texture/resource.d.ts.map +1 -1
  343. package/build/video/texture/texture2d.d.ts +0 -11
  344. package/build/video/texture/texture2d.d.ts.map +1 -1
  345. package/build/video/utils/autodetect.d.ts +1 -5
  346. package/build/video/utils/autodetect.d.ts.map +1 -1
  347. package/build/video/webgl/batchers/batcher.d.ts +0 -55
  348. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  349. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +0 -14
  350. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
  351. package/build/video/webgl/batchers/lit_quad_batcher.d.ts +0 -72
  352. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  353. package/build/video/webgl/batchers/material_batcher.d.ts +0 -89
  354. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  355. package/build/video/webgl/batchers/mesh_batcher.d.ts +14 -343
  356. package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
  357. package/build/video/webgl/batchers/primitive_batcher.d.ts +0 -10
  358. package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
  359. package/build/video/webgl/batchers/quad_batcher.d.ts +0 -30
  360. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  361. package/build/video/webgl/buffer/index.d.ts +1 -36
  362. package/build/video/webgl/buffer/index.d.ts.map +1 -1
  363. package/build/video/webgl/buffer/instance_buffer.d.ts +1 -53
  364. package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -1
  365. package/build/video/webgl/buffer/retained_geometry.d.ts +1 -81
  366. package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -1
  367. package/build/video/webgl/buffer/uniformblock.d.ts +1 -80
  368. package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -1
  369. package/build/video/webgl/buffer/vertexstate.d.ts +1 -100
  370. package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -1
  371. package/build/video/webgl/glshader.d.ts +7 -51
  372. package/build/video/webgl/glshader.d.ts.map +1 -1
  373. package/build/video/webgl/lighting/pack3d.d.ts +1 -47
  374. package/build/video/webgl/lighting/pack3d.d.ts.map +1 -1
  375. package/build/video/webgl/lighting/std140.d.ts +1 -109
  376. package/build/video/webgl/lighting/std140.d.ts.map +1 -1
  377. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts +1 -103
  378. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  379. package/build/video/webgl/shaders/multitexture-lit.d.ts +1 -26
  380. package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
  381. package/build/video/webgl/shaders/multitexture.d.ts +1 -9
  382. package/build/video/webgl/shaders/multitexture.d.ts.map +1 -1
  383. package/build/video/webgl/texture/store.d.ts +1 -50
  384. package/build/video/webgl/texture/store.d.ts.map +1 -1
  385. package/build/video/webgl/utils/attributes.d.ts +1 -11
  386. package/build/video/webgl/utils/attributes.d.ts.map +1 -1
  387. package/build/video/webgl/utils/maxtextures.d.ts +1 -36
  388. package/build/video/webgl/utils/maxtextures.d.ts.map +1 -1
  389. package/build/video/webgl/utils/precision.d.ts +1 -14
  390. package/build/video/webgl/utils/precision.d.ts.map +1 -1
  391. package/build/video/webgl/utils/program.d.ts +1 -5
  392. package/build/video/webgl/utils/program.d.ts.map +1 -1
  393. package/build/video/webgl/utils/samplercache.d.ts +1 -68
  394. package/build/video/webgl/utils/samplercache.d.ts.map +1 -1
  395. package/build/video/webgl/utils/string.d.ts +1 -21
  396. package/build/video/webgl/utils/string.d.ts.map +1 -1
  397. package/build/video/webgl/utils/topology.d.ts +1 -23
  398. package/build/video/webgl/utils/topology.d.ts.map +1 -1
  399. package/build/video/webgl/utils/uniforms.d.ts +1 -25
  400. package/build/video/webgl/utils/uniforms.d.ts.map +1 -1
  401. package/build/video/webgl/utils/vertexformat.d.ts +1 -26
  402. package/build/video/webgl/utils/vertexformat.d.ts.map +1 -1
  403. package/build/video/webgl/webgl_renderer.d.ts +22 -285
  404. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  405. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts +0 -6
  406. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -1
  407. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +0 -8
  408. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -1
  409. package/build/video/webgpu/batchers/mesh_batcher.d.ts +7 -231
  410. package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
  411. package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -1
  412. package/build/video/webgpu/batchers/quad_batcher.d.ts +0 -82
  413. package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
  414. package/build/video/webgpu/buffer/arena.d.ts +1 -63
  415. package/build/video/webgpu/buffer/arena.d.ts.map +1 -1
  416. package/build/video/webgpu/buffer/instance_buffer.d.ts +1 -64
  417. package/build/video/webgpu/buffer/instance_buffer.d.ts.map +1 -1
  418. package/build/video/webgpu/buffer/retained_geometry.d.ts +1 -54
  419. package/build/video/webgpu/buffer/retained_geometry.d.ts.map +1 -1
  420. package/build/video/webgpu/buffer/uniformring.d.ts +1 -67
  421. package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -1
  422. package/build/video/webgpu/effect_binding.d.ts +1 -16
  423. package/build/video/webgpu/effect_binding.d.ts.map +1 -1
  424. package/build/video/webgpu/pipeline/bindgroups.d.ts +1 -32
  425. package/build/video/webgpu/pipeline/bindgroups.d.ts.map +1 -1
  426. package/build/video/webgpu/pipeline/cache.d.ts +1 -163
  427. package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
  428. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +1 -87
  429. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  430. package/build/video/webgpu/shaders/mesh-instanced.d.ts +1 -43
  431. package/build/video/webgpu/shaders/mesh-instanced.d.ts.map +1 -1
  432. package/build/video/webgpu/texture/compressed.d.ts +1 -32
  433. package/build/video/webgpu/texture/compressed.d.ts.map +1 -1
  434. package/build/video/webgpu/texture/frametexture.d.ts +1 -62
  435. package/build/video/webgpu/texture/frametexture.d.ts.map +1 -1
  436. package/build/video/webgpu/texture/store.d.ts +1 -147
  437. package/build/video/webgpu/texture/store.d.ts.map +1 -1
  438. package/build/video/webgpu/webgpu_renderer.d.ts +1 -88
  439. package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
  440. package/package.json +5 -4
  441. package/skills/melonjs/SKILL.md +1 -1
  442. package/skills/melonjs-3d/SKILL.md +453 -5
  443. package/skills/melonjs-3d-assets/SKILL.md +164 -6
  444. package/skills/melonjs-audio/SKILL.md +38 -0
  445. package/skills/melonjs-camera-and-drawing/SKILL.md +49 -0
  446. package/skills/melonjs-effects-and-shaders/SKILL.md +95 -2
  447. package/skills/melonjs-loading-assets/SKILL.md +127 -2
  448. package/skills/melonjs-performance/SKILL.md +60 -1
  449. package/skills/melonjs-physics/SKILL.md +78 -0
  450. package/skills/melonjs-renderables/SKILL.md +63 -1
  451. package/skills/melonjs-renderer-backends/SKILL.md +19 -0
  452. package/skills/melonjs-scenes-and-state/SKILL.md +56 -0
  453. package/skills/melonjs-tilemaps/SKILL.md +31 -11
  454. package/skills/melonjs-ui-and-text/SKILL.md +131 -117
@@ -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
 
@@ -20,9 +20,15 @@ This is the single most important thing on this page.
20
20
  | vertical | **Y-down** — higher `y` is *lower* on screen | Y-up |
21
21
  | depth | **+Z forward** — higher `z` is *farther* away | −Z forward |
22
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.
23
+ Rotations are extrinsic XYZ, and `Camera3d` exposes all three: `camera.pitch`
24
+ (X, look up/down), `camera.yaw` (Y, look left/right) and `camera.roll` (Z, bank
25
+ the horizon). The view is `R(yaw) ∘ R(pitch) ∘ R(roll)` inverted, and the frustum
26
+ planes come off that same matrix — so culling follows a banked view.
27
+
28
+ `camera.rotate()` is NOT the way to bank a 3D camera. It writes the inherited
29
+ `currentTransform`, which a 3D view never reads, so the call is silently inert.
30
+ Set `roll`. (On a `Camera2d` it is the other way round: roll IS that transform's
31
+ rotation, which is why `worldToLocal` / `localToWorld` compensate for it.)
26
32
 
27
33
  The payoff is that 2D code translates directly — anywhere you used `pos.x` /
28
34
  `pos.y`, add `pos.z` and the maths still holds. The cost is that every
@@ -83,6 +89,10 @@ class GameStage extends Stage {
83
89
  `camera.setClipPlanes(near, far)`.
84
90
  - **`camera.pos.set(x, y)` is 2-argument and zeroes z.** Use `camera.depth` —
85
91
  the documented z accessor — or assign `pos.x`/`pos.y` individually.
92
+ - **`worldToLocal` does not project.** It is a 2D camera's offset subtraction.
93
+ To pin a label or marker to a point in the scene use
94
+ `camera.worldToScreen(x, y, z)`, which applies the projection and returns
95
+ `null` behind the camera. See `melonjs-camera-and-drawing`.
86
96
 
87
97
  ## Depth sorting
88
98
 
@@ -97,6 +107,157 @@ index** — a real world depth in a 3D scene, and never the one you wanted. Pass
97
107
  it (`world.addChild(mesh, z)`), or set `mesh.depth` afterwards. The glTF
98
108
  importer turns `autoDepth` off on the container it loads into for this reason.
99
109
 
110
+ **`floating` does not opt out of this sort.** It skips the camera *transform*,
111
+ not the depth *order*. A floating child is ordered by `|pos.z|` alone — its
112
+ `pos.x/y` are screen pixels, and the camera does not move relative to it — so
113
+ the magnitude is the distance and the sign is ignored:
114
+
115
+ ```js
116
+ world.addChild(hud, -150); // small -> nearer than anything -> on top
117
+ world.addChild(skybox, -10000); // large -> farther -> behind everything
118
+ world.addChild(skybox, 100000); // equally far: sign does not matter
119
+ ```
120
+
121
+ Both hold at any camera position. A HUD given the huge z that would put it on
122
+ top in 2D lands at the far end of the level instead, with the scenery drawing
123
+ over it.
124
+
125
+ ## Transparency
126
+
127
+ A mesh fades by setting its opacity — there is nothing else to switch on:
128
+
129
+ ```js
130
+ ghost.setOpacity(0.4);
131
+ ```
132
+
133
+ Meshes render in two phases. The **opaque pass** writes depth in sort order; the
134
+ **transparent pass** replays afterwards, back-to-front, blending and writing no
135
+ depth. A draw lands in the second whenever its alpha is fractional.
136
+
137
+ That default matters because the opaque path writes premultiplied colour with
138
+ blending off, so before this a faded mesh came out **darkened toward black**
139
+ rather than see-through — the background contributed nothing.
140
+
141
+ **`transparent: true`** when the transparency is in the TEXTURE rather than the
142
+ opacity — a soft-edged glow, smoke, a glTF material with `alphaMode: "BLEND"`.
143
+ The automatic check reads the draw's alpha and cannot see into a texture. Watch
144
+ `alphaCutoff` here: it discards texels *before* blending sees them, so a soft
145
+ edge needs a low cutoff (`Sprite3d` drops its own default to `1/255` when you
146
+ set `transparent: true`). The cutoff thresholds the MATERIAL's alpha, not the
147
+ drawn alpha, so a fading cutout mesh keeps its shape instead of disappearing at
148
+ its own threshold.
149
+
150
+ The glTF loader does **not** set this for you: one loaded mesh can merge several
151
+ materials and the flag routes the whole mesh, so a `"BLEND"` material sharing
152
+ geometry with an opaque one would drag the opaque half into the transparent pass.
153
+
154
+ **`transparent: false`** pins a mesh to the opaque pass however it is faded.
155
+
156
+ Blending uses the renderable's existing `blendMode`, so a glow is one property.
157
+ The advanced modes (`"overlay"`, `"difference"`, and the rest that need a
158
+ compositing pass) fall back to `"normal"` here, on both backends:
159
+
160
+ ```js
161
+ const glow = new Mesh(0, 0, {
162
+ ...quad, texture: glowTexture,
163
+ transparent: true, blendMode: "additive", alphaCutoff: 0,
164
+ });
165
+ ```
166
+
167
+ | | |
168
+ | --- | --- |
169
+ | sorting | **per object**, by distance from the camera |
170
+ | intersecting transparent meshes | may pop as the camera moves — split them, or accept it |
171
+ | `InstancedMesh` | sorts as **one** object; instances draw in buffer order |
172
+ | needs | a GPU backend and a `Camera3d` |
173
+
174
+ Ground shadows ride the same pass — a blob is a decal, and decals are its first
175
+ client rather than a feature of their own.
176
+
177
+ ## Distance fog
178
+
179
+ Off until you ask for it, and one call on the camera:
180
+
181
+ ```js
182
+ camera.setFog({ near: 2000, far: 7000 }); // linear: name the two distances
183
+ camera.setFog({ mode: "exp2", density: 4e-4 }); // or one density
184
+ camera.setFog(null); // off
185
+ ```
186
+
187
+ It is the cheapest thing that stops a 3D scene reading as flat cut-outs, and it
188
+ lets props arrive at the far plane without a visible edge.
189
+
190
+ **Every parameter is optional, and the omitted ones track live.** Distances
191
+ default to the camera's own clip planes, so fog cannot silently disagree with
192
+ them after a later `setClipPlanes`. The colour defaults to
193
+ `renderer.backgroundColor` and follows it, so geometry dissolves into whatever
194
+ sky you already set — including through a day/night fade. Pass `color` only
195
+ when the fog should deliberately differ from the backdrop:
196
+
197
+ ```js
198
+ camera.setFog({ far: 5000, color: "#8899aa" });
199
+ ```
200
+
201
+ A `Color` is held by reference, so mutating it animates the fog.
202
+
203
+ **Height falloff** makes mist pool in low ground instead of hanging at every
204
+ altitude equally — the difference between fog reading as weather and as a global
205
+ desaturation:
206
+
207
+ ```js
208
+ camera.setFog({ near: 1200, far: 7000, fogHeight: 0, heightFalloff: 0.0015 });
209
+ ```
210
+
211
+ `heightFalloff` defaults to **0**, which is uniform fog — not a special case,
212
+ the same integral with the dial at zero, so leaving it out changes nothing.
213
+ Render space is **Y-down**, so `fogHeight` is the floor and density rises
214
+ *below* it; every published form of this formula assumes Y-up and has the
215
+ opposite sign.
216
+
217
+ Fog is measured **radially** from the camera and applied **per fragment**, so
218
+ it does not slide as the camera turns and does not band across large triangles.
219
+ It lives on the camera, so a split-screen or minimap view fogs independently —
220
+ and a `Camera2d` never fogs at all.
221
+
222
+ **Per object:** `fog: false` exempts a mesh however far away it is — for a
223
+ waypoint or objective marker that has to stay readable. It exempts the mesh and
224
+ not the ground shadow it casts: a blob is a mark on the floor and fogs with the
225
+ floor. Emissive surfaces fog
226
+ like everything else (light travelling through fog is attenuated too), so a
227
+ neon sign that should punch through wants `fog: false`, not a brighter
228
+ emissive.
229
+
230
+ Only meshes fog. 2D content, HUDs and `floating` renderables never reach the
231
+ mesh shaders, so a screen-space overlay stays clean with no work.
232
+
233
+ **A custom mesh shader is not fogged unless it asks to be.** Fog is compiled
234
+ into the engine's own mesh programs — `#define FOG` on WebGL, an `enable_fog`
235
+ overridable constant on WebGPU — and a shader you supply is yours: the engine
236
+ binds it as written and never substitutes a fogged variant. So a mesh carrying a
237
+ `ShaderEffect` keeps full contrast while the scene around it recedes. It is safe
238
+ — nothing throws, and the camera's fog is simply not applied — but it is usually
239
+ surprising.
240
+
241
+ To opt in, declare the same uniforms and the engine will feed them, because the
242
+ fog values are pushed to any mesh program that declares them rather than only to
243
+ the built-in ones:
244
+
245
+ ```glsl
246
+ uniform vec3 uFogColor; // straight (unpremultiplied) fog colour
247
+ uniform vec4 uFogParams; // x = mode (0 off / 1 linear / 2 exp2),
248
+ // y = near, z = 1/(far - near), w = density
249
+ ```
250
+
251
+ Your vertex stage computes the distance itself — `length((uViewMatrix *
252
+ uModelMatrix * vec4(aVertex, 1.0)).xyz)`, radially so it does not swim as the
253
+ camera turns — and the blend must scale the fog colour by the fragment's own
254
+ alpha, `mix(uFogColor * a, rgb, f)`, because `vColor` arrives premultiplied.
255
+ Mixing toward the unscaled colour haloes every alpha-cutout edge.
256
+
257
+ The flip side is the reason fog costs nothing when unused: with no camera fog,
258
+ the mesh programs are compiled without any of it, on both backends. It is not a
259
+ branch that is skipped at runtime — the code is not there.
260
+
100
261
  ## Meshes
101
262
 
102
263
  ```js
@@ -115,9 +276,188 @@ there — place the origin where you want the pivot at authoring time, or nest t
115
276
  mesh under a transformed parent. The anchor is only honoured on the legacy
116
277
  2D-camera path.
117
278
 
279
+ ### InstancedMesh, and when it is the wrong tool
280
+
118
281
  **`InstancedMesh`** draws one mesh many times in a single draw call — the
119
282
  difference between a hundred trees and a hundred thousand. glTF scenes using
120
- `EXT_mesh_gpu_instancing` load as an `InstancedMesh` automatically.
283
+ `EXT_mesh_gpu_instancing` load as one automatically; by hand it is a `Mesh`
284
+ with a count:
285
+
286
+ ```js
287
+ const trees = new InstancedMesh(0, 0, { ...treeGeometry, instanceCount: 400 });
288
+ const at = new Matrix3d(); // one scratch, reused
289
+ for (let i = 0; i < trees.instanceCount; i++) {
290
+ at.identity().translate(x, y, z);
291
+ trees.setInstance(i, at);
292
+ }
293
+ world.addChild(trees, 0);
294
+
295
+ trees.visibleInstanceCount = 120; // draw fewer, without re-uploading
296
+ ```
297
+
298
+ It is not a free upgrade. One `InstancedMesh` is **one geometry and one
299
+ material**, and four things move from per-object to per-group:
300
+
301
+ | | with `Mesh` | with `InstancedMesh` |
302
+ | --- | --- | --- |
303
+ | depth sort | each object sorts on its own `pos` | the whole set has **one** sort key |
304
+ | ground shadow | one blob per object | one instanced draw for the set |
305
+ | removal | `removeChild`, indices unaffected | `removeInstance(i)` swaps the **last** instance into the hole, so any index you were holding is now wrong |
306
+ | colour | `tint` per object | needs `instanceColors: true` and `setInstanceColor(i, …)` |
307
+
308
+ So the question is not "how many are there" but **"does the game address them
309
+ individually"**:
310
+
311
+ - **Scenery — instance it.** Trees, rocks, grass, debris: the game never asks
312
+ about one of them.
313
+ - **Collision-tested props — still fine.** You test against positions you
314
+ already own; instancing only changes how they are *drawn*.
315
+ - **Collectibles and enemies — usually not.** Anything removed one at a time
316
+ makes `removeInstance`'s swap your problem: you have to keep an index↔object
317
+ map and repair it on every removal. At small counts a pooled `Mesh` each is
318
+ less code and no slower.
319
+
320
+ Under a few hundred objects the draw-call saving is not what limits you
321
+ anyway — reach for it when the count is in the thousands, or when the objects
322
+ are pure scenery and it costs nothing to.
323
+
324
+ ## Normals are generated for you
325
+
326
+ A `lit` mesh needs per-vertex normals for the shader to light with. Supply them
327
+ if you have them; **omit them and the engine computes them from the geometry**:
328
+
329
+ ```js
330
+ const mesh = new Mesh(x, y, { vertices, uvs, indices, lit: true });
331
+ // normals derived from the triangles — nothing else to do
332
+ ```
333
+
334
+ You do not choose flat or smooth, because the geometry already decides. Face
335
+ normals accumulate into their vertices weighted by area, so where faces **share**
336
+ a vertex they average and the surface shades smoothly, and where every triangle
337
+ carries its **own** three vertices — a triangle soup, which is how most
338
+ hand-built geometry comes out — each vertex belongs to one face and the result
339
+ is that face's normal, so it shades flat. Want faceted edges: duplicate the
340
+ vertices. Want smooth: share them.
341
+
342
+ An explicit `settings.normals` always wins, and an unlit mesh gets none — there
343
+ would be nothing to read them.
344
+
345
+ **A lit mesh with no normals used to render fullbright**, which looks like the
346
+ lighting is broken rather than absent. If an older scene suddenly picks up
347
+ shading, that is why.
348
+
349
+ ## Colouring a mesh
350
+
351
+ There are four levels, and picking the wrong one is the usual reason a colour
352
+ "does not apply". They all multiply together.
353
+
354
+ | level | how | use for |
355
+ |---|---|---|
356
+ | whole object | `mesh.tint.setColor(r, g, b)` | flash on hit, team colour, fading one object |
357
+ | per vertex | `settings.vertexColors`, or `mesh.setVertexColor(i, color)` | a gradient *within* one mesh — distance haze, a darker crease |
358
+ | per material | `textureGroups`, from a multi-material OBJ + MTL | a model whose parts differ, in one draw call |
359
+ | per instance | `new InstancedMesh(…, { instanceColors: true })` then `setInstanceColor(i, color)` | a thousand copies that differ |
360
+
361
+ **`tint` is per object.** That is the trap: build a terrain as one big mesh and
362
+ you can tint the whole valley or none of it. Anything that varies *across* a
363
+ single mesh is per-vertex.
364
+
365
+ ```js
366
+ // fade a procedural terrain toward the sky the further out it goes
367
+ const ground = new Color(217, 230, 244);
368
+ const sky = new Color(207, 230, 247);
369
+ const haze = new Color();
370
+ for (let i = 0; i < mesh.vertexCount; i++) {
371
+ const t = Math.min(1, mesh.originalVertices[i * 3 + 2] / 6000);
372
+ mesh.setVertexColor(i, haze.copy(ground).lerp(sky, t));
373
+ }
374
+ ```
375
+
376
+ Supply the whole array at construction when you already have it —
377
+ `vertexColors` takes a packed `Uint32Array` (the form the batchers read, so no
378
+ conversion) or one `Color` per vertex. A length that does not match
379
+ `vertexCount` **throws**; it is not padded, because a short array would leave
380
+ the tail of the mesh mis-coloured and that reads as a lighting bug.
381
+
382
+ Mutating the array directly is fine, but say so afterwards:
383
+
384
+ ```js
385
+ mesh.vertexColors[i] = color.toUint32(color.alpha);
386
+ mesh.needsUpdate = true; // the retained Camera3d path uploads once
387
+ ```
388
+
389
+ `setVertexColor` does that for you. Skip it and the colour applies under a 2D
390
+ camera and silently does not under `Camera3d`.
391
+
392
+ On a lit mesh the colour multiplies the **lit** result, so it behaves as albedo
393
+ rather than as an emissive override — a vertex colour will not make an unlit
394
+ face bright.
395
+
396
+ `alpha` hides a mesh as it hides anything else: at 0 the draw is skipped. There
397
+ is no *partial* mesh transparency though — the mesh path renders opaque, so a
398
+ mesh at `alpha = 0.5` draws fully opaque rather than half see-through. Fade a
399
+ mesh out and it will stay solid until it vanishes.
400
+
401
+ ## Moving a mesh in 3D
402
+
403
+ `Mesh` and `Sprite3d` inherit the ordinary `Renderable` transform helpers, and
404
+ both are already 3D:
405
+
406
+ ```js
407
+ mesh.rotate(Math.PI / 2, new Vector3d(1, 0, 0)); // axis overload
408
+ mesh.scale(2, 1, 0.5); // z is a real argument
409
+ ```
410
+
411
+ `rotate(angle)` alone is the 2D case (about Z); pass a `Vector3d` and it
412
+ rotates about that axis. Both write to `currentTransform`, a **`Matrix3d`**,
413
+ which `Mesh` folds into its model matrix — so orienting a mesh costs a matrix
414
+ update, not new geometry.
415
+
416
+ This matters most for the case it is least obvious for: a horizontal plane.
417
+ `Sprite3d` with `billboard: false` is a quad in the sprite plane — upright —
418
+ and the way to lay one flat (water, a road, a shadow decal) is to rotate it a
419
+ quarter turn about X, **not** to hand-build vertices. The one reason to build
420
+ geometry instead is tiling: a `Sprite3d` bakes its UVs 0..1 from its atlas
421
+ frame, so a surface that needs `textureRepeat` across many world units still
422
+ wants an explicit `vertices`/`uvs` mesh.
423
+
424
+ ## The mesh pass is opaque
425
+
426
+ Worth stating plainly, because the symptom does not look like a blending
427
+ problem: **the mesh pass disables blending**. A soft-edged texture — a glow, a
428
+ sun, a halo, anything with a gradient alpha — composites as a hard-edged disc
429
+ with a grey rim, which reads as a broken texture rather than as a missing
430
+ feature.
431
+
432
+ `transparent: true` routes it through the transparent pass, and `blendMode:
433
+ "additive"` on top of that makes a light source add to the sky instead of
434
+ sitting on it. This is the same feature a translucent water surface needs.
435
+
436
+ ## Textures under a perspective camera
437
+
438
+ A tiling texture on a large ground plane is seen at a grazing angle, and that
439
+ changes which detail survives:
440
+
441
+ - **Nothing straight and parallel to the direction of travel.** Every such run
442
+ converges on the vanishing point, so a few current bands on a river become a
443
+ fan of rays radiating out of the horizon. Narrowing them and tiling more
444
+ often only multiplies the rays. Short, scattered, direction-free detail
445
+ minifies into an even shimmer instead.
446
+ - **`textureFilter: "linear"`** for a floor — `"nearest"` opts out of mipmaps
447
+ and anisotropy, and detail aliases into a wash exactly where the camera looks
448
+ most.
449
+
450
+ ## Ground must outlast the props standing on it
451
+
452
+ Scenery scattered up a slope is placed by its own rule, and terrain is built by
453
+ another. When the planting reaches further than the mesh does, a low camera
454
+ sees trees standing over open sky at the corners of the frame. Build the ground
455
+ wider than the widest thing planted on it — past the profile's clamp it is a
456
+ flat plateau, so the extra columns cost two triangles and no silhouette.
457
+
458
+ Recycling has the same trap in Z: an endless runner that recycles tiles a fixed
459
+ distance behind the *player* forgets that the camera trails further back still,
460
+ and the bottom of the frame falls off the world.
121
461
 
122
462
  ## Sprite3d and billboards
123
463
 
@@ -144,8 +484,37 @@ default), `"ambient"`, `"point"` and `"spot"`.
144
484
  ```js
145
485
  world.addChild(new Light3d({ type: "directional", direction: [0.3, 1, 0.2] }));
146
486
  world.addChild(new Light3d({ type: "ambient", intensity: 0.3 }));
487
+ // a Vector3d works too, wherever the game already has one
488
+ world.addChild(new Light3d({ type: "spot", position: torch.pos, range: 400 }));
147
489
  ```
148
490
 
491
+ `direction` and `position` take an `[x, y, z]` array **or** a `Vector3d`, and
492
+ `color` takes a `Color`, a CSS string or an `[r, g, b]` array — so a value the
493
+ game already holds can go straight in. Each is read, not retained: move your
494
+ vector afterwards and the light stays where it was.
495
+
496
+ Two things still bite, both silently:
497
+
498
+ - `new Light3d(0, 0, {…})` — the constructor takes **options alone**. JavaScript
499
+ drops the extra arguments, so `options` becomes the number `0` and every
500
+ setting in your literal is discarded. The light still appears, on pure
501
+ defaults: a `type: "ambient"` written this way is a second DIRECTIONAL light,
502
+ and the scene looks plausible enough that nobody checks. TypeScript stops
503
+ checking a literal once the argument count is wrong, so nothing inside it is
504
+ verified either.
505
+ - **`direction` is where the light GOES, and this is a Y-down space** — so a sun
506
+ overhead travels *downward* and its Y is **positive**. Get the sign wrong and
507
+ the scene is lit from underneath: faces that should be in shade are bright,
508
+ the ground glows and the sky-facing surfaces go dark.
509
+
510
+ ```js
511
+ direction: [-0.35, 0.8, 0.45] // sun overhead, late afternoon
512
+ direction: [-0.35, -0.8, 0.45] // lit from below — almost never what you want
513
+ ```
514
+
515
+ `position` follows the same convention: a lamp above the floor has a
516
+ **smaller** y than the floor.
517
+
149
518
  Use **both halves**: with a key light but no ambient, the shadow side of a mesh
150
519
  goes black. With no `Light3d` in the world at all, a `lit: true` mesh falls back
151
520
  to a white ambient and renders fullbright — indistinguishable from unlit, which
@@ -164,6 +533,49 @@ skip geometry with no vertical extent — a ground plane. Per object,
164
533
  `castGroundShadow: true`/`false` overrides the app setting and is obeyed as
165
534
  given, safeguard included; `shadowGroundY` names the floor the blob lands on.
166
535
 
536
+ The blob is an ellipse sized to the caster's own footprint and placed at the
537
+ caster's x/z — it is **never offset by light direction**. So a tall or narrow
538
+ object (a character, a tree, a pickup) shows its shadow clearly, while a wide,
539
+ flat-bottomed one resting on the floor covers its own completely from a camera
540
+ looking down at it. That is the shadow behaving correctly, not a bug.
541
+
542
+ **Do not chase it by raising `shadowGroundY`.** Lifting the plane does not slide
543
+ the blob out from under the object, it floats the blob *up* — and past a few
544
+ units it projects over the top of the caster as a dark halo ringing it. If an
545
+ object needs a visible shadow, give it a smaller footprint relative to its
546
+ height, or accept that a boulder bedded in the ground has none.
547
+
548
+ ### Get the sign right: the floor is a GREATER y
549
+
550
+ Render space is **Y-down**, so the floor an object stands on is a *larger* y
551
+ than the object itself. Nudging a shadow plane below a surface is therefore a
552
+ **plus**:
553
+
554
+ ```js
555
+ mesh.shadowGroundY = WATER_LEVEL + 8; // just under the surface — correct
556
+ mesh.shadowGroundY = mesh.pos.y - 8; // eight units ABOVE its own base — wrong
557
+ ```
558
+
559
+ Get it backwards and the blob becomes a horizontal quad slicing through the
560
+ caster's own body. It is still drawn at full strength — the height fade sees a
561
+ *negative* height and clamps to 1, so nothing warns you — but the depth test
562
+ hides every part of it that falls inside the caster's silhouette. What survives
563
+ is a thin ring, only as wide as the blob overhangs the object.
564
+
565
+ The symptom is distinctive and easy to misread: **shadows appear to switch on as
566
+ casters approach the camera.** That ring is a few pixels on the nearest object
567
+ and sub-pixel further out, so a scene reads as "only nearby things have
568
+ shadows" — which looks like culling, an LOD stage or a fog problem, none of
569
+ which it is. Before chasing any of those, dump `shadowGroundY` against the
570
+ caster's own y and check which one is larger.
571
+
572
+ ## Collision in 3D
573
+
574
+ Use `Box3d` bodies, not a hand-rolled distance check. `Box3d`-vs-`Box3d` is
575
+ the engine's 3D narrowphase and the only contact that pushes back along Z; the
576
+ response carries `overlapNZ` / `overlapZ` for the depth axis. See the physics
577
+ skill for the contract and the mixed-pair caveat.
578
+
167
579
  ## glTF / GLB scenes
168
580
 
169
581
  Loaded through the same level director as everything else:
@@ -175,6 +587,23 @@ level.load("diorama", { scale, castGroundShadow, shadowGroundY, onLoaded });
175
587
 
176
588
  `.obj` / `.mtl` are also supported loader types.
177
589
 
590
+ An **animated** asset instantiates as a `GLTFModel`, which is a game object as
591
+ much as a scene: construct it straight from the parsed descriptor, and place it
592
+ with `pos` / `depth` / `rotate` / `scale` like any other renderable — the
593
+ placement drives the whole rig and composes with the playing clip.
594
+
595
+ ```js
596
+ const model = new GLTFModel(loader.getGLTF("boat"), { scale: 40, lit: false });
597
+ model.setCurrentAnimation("paddle", { loop: true });
598
+ model.pos.set(x, y);
599
+ model.depth = z;
600
+ ```
601
+
602
+ To scatter an authored mesh yourself, read the geometry off the descriptor and
603
+ hand it to an `InstancedMesh` — `loader.getGLTF(name).nodes[0]` carries
604
+ `vertices` / `uvs` / `normals` / `indices`. That wants a single merged
605
+ primitive exported at the origin; see `melonjs-3d-assets`.
606
+
178
607
  `melonjs-3d-assets` covers the rest: every `level.load` option, which material
179
608
  features are imported, imported lights and their intensity units, node-TRS
180
609
  animation (and the skinning that is out of scope), and OBJ/MTL.
@@ -209,11 +638,30 @@ To branch rather than fail, read `app.renderer.supportsDepthBuffer` after
209
638
 
210
639
  | symptom | cause |
211
640
  |---|---|
641
+ | scene lit from underneath | `direction` Y sign — this is Y-down, so a sun overhead is **+Y** |
642
+ | a `lit` mesh renders fullbright | it had no normals — supply them, or let the engine generate them |
643
+ | a gradient across one mesh is impossible | `tint` is per object — use `vertexColors` / `setVertexColor` |
644
+ | a mesh stays solid as you fade it out | meshes render opaque; only `alpha` 0 (hidden) and 1 differ |
645
+ | vertex colour applies under a 2D camera but not `Camera3d` | wrote the array directly without setting `needsUpdate` |
646
+ | `Mesh: vertexColors has N entries, expected M` | one colour per *vertex*, not per triangle or per index |
212
647
  | nothing renders, or a backdrop covers everything | wrong depth sign — "far" is *larger* z when looking along +Z |
213
648
  | distant objects vanish or warp | scene exceeds the default far plane; `setClipPlanes` |
214
649
  | distant surfaces z-fight | `near` too small for the scene scale |
215
650
  | black canvas under `Camera3d` | Canvas renderer (no depth buffer) — check the `console.warn` |
216
651
  | everything flat and unlit | `lit: true` with no `Light3d` in the world (falls back to fullbright), or a mesh under a 2D camera |
652
+ | a faded mesh goes dark instead of see-through | `transparent: false` on it, or a 2D camera — the transparent pass needs a `Camera3d` |
653
+ | a soft-edged glow has hard edges | `alphaCutoff` discarded the soft texels; lower it |
654
+ | a glTF `alphaMode: "BLEND"` material draws opaque | the loader does not set `transparent` — one mesh can merge several materials, so set it yourself |
655
+ | two transparent objects pop as the camera moves | per-object sorting cannot order intersecting geometry |
656
+ | a `floating` HUD draws behind the scenery | a large \|z\| is *far* under `Camera3d` — use a small depth |
657
+ | fog hangs in the sky as thickly as in the valley | uniform fog — add `heightFalloff` so it pools low |
658
+ | mist sits on the ridges instead of the valley floor | the `fogHeight` sign — Y is DOWN here, density rises below it |
659
+ | distant geometry pops in against the sky | no fog — `camera.setFog({})` picks up the clip planes and background colour |
660
+ | fog does not match the sky after a background fade | an explicit `color` was passed; omit it to track `renderer.backgroundColor` |
661
+ | geometry clips before it has finished fading | fog `far` beyond the clip far — omit the distances and they default to the clip planes |
662
+ | one marker must stay readable in fog | `fog: false` on that mesh |
663
+ | an object casts no visible shadow | wide and flat-bottomed — its own blob is underneath it; raising `shadowGroundY` haloes it instead of revealing it |
664
+ | a dark ring around the top of an object | `shadowGroundY` lifted too far, floating the blob up into the caster |
217
665
  | a mesh sits at the wrong depth after being added | `autoDepth` overwrote `pos.z` with the child index — pass `addChild(mesh, z)` |
218
666
  | a mesh sits half its size off | `anchorPoint` — only on the 2D-camera path; a `Camera3d` mesh pivots on its model origin |
219
667
  | a billboard tips over when the camera looks down | `"spherical"`, or a mistyped mode string falling through to it — use `true` / `"cylindrical"` |