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