melonjs 20.7.0 → 20.9.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 +7 -3
- package/build/application/application.d.ts +66 -8
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +6 -0
- package/build/application/defaultApplicationSettings.d.ts.map +1 -1
- package/build/application/header.d.ts.map +1 -1
- package/build/application/resize.d.ts +25 -0
- package/build/application/resize.d.ts.map +1 -1
- package/build/application/scaleMethods.d.ts +13 -3
- package/build/application/scaleMethods.d.ts.map +1 -1
- package/build/application/settings.d.ts +144 -5
- package/build/application/settings.d.ts.map +1 -1
- package/build/audio/audio.d.ts +29 -5
- package/build/audio/audio.d.ts.map +1 -1
- package/build/audio/autopause.d.ts +36 -0
- package/build/audio/autopause.d.ts.map +1 -0
- package/build/audio/backend/engine.d.ts +10 -1
- package/build/audio/backend/engine.d.ts.map +1 -1
- package/build/audio/backend/sound.d.ts +0 -1
- package/build/audio/backend/sound.d.ts.map +1 -1
- package/build/audio/backend/spatial.d.ts.map +1 -1
- package/build/audio/context.d.ts +35 -0
- package/build/audio/context.d.ts.map +1 -0
- package/build/audio/playback.d.ts.map +1 -1
- package/build/audio/procedural.d.ts.map +1 -1
- package/build/audio/spatial.d.ts +87 -0
- package/build/audio/spatial.d.ts.map +1 -0
- package/build/audio/state.d.ts +1 -0
- package/build/audio/state.d.ts.map +1 -1
- package/build/audio/types.d.ts +46 -6
- package/build/audio/types.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/camera3d.d.ts +95 -8
- package/build/camera/camera3d.d.ts.map +1 -1
- package/build/camera/effects/fade_effect.d.ts.map +1 -1
- package/build/camera/effects/mask_effect.d.ts.map +1 -1
- package/build/camera/effects/shake_effect.d.ts.map +1 -1
- package/build/geometries/box3d.d.ts +25 -7
- package/build/geometries/box3d.d.ts.map +1 -1
- package/build/geometries/ellipse.d.ts +15 -1
- package/build/geometries/ellipse.d.ts.map +1 -1
- package/build/geometries/line.d.ts +1 -1
- package/build/geometries/line.d.ts.map +1 -1
- package/build/geometries/point.d.ts +1 -1
- package/build/geometries/point.d.ts.map +1 -1
- package/build/geometries/polygon.d.ts +15 -1
- package/build/geometries/polygon.d.ts.map +1 -1
- package/build/geometries/rectangle.d.ts +1 -1
- package/build/geometries/rectangle.d.ts.map +1 -1
- package/build/geometries/roundrect.d.ts +1 -1
- package/build/geometries/roundrect.d.ts.map +1 -1
- package/build/geometries/sphere.d.ts +36 -7
- package/build/geometries/sphere.d.ts.map +1 -1
- package/build/index.d.ts +16 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +38172 -33633
- package/build/index.js.map +4 -4
- package/build/input/gamepad.d.ts +129 -3
- package/build/input/gamepad.d.ts.map +1 -1
- package/build/input/pointerevent.d.ts +8 -0
- package/build/input/pointerevent.d.ts.map +1 -1
- package/build/level/gltf/GLTFModel.d.ts +20 -33
- package/build/level/gltf/GLTFModel.d.ts.map +1 -1
- package/build/level/gltf/GLTFScene.d.ts +40 -1
- package/build/level/gltf/GLTFScene.d.ts.map +1 -1
- package/build/level/level.d.ts +35 -0
- package/build/level/level.d.ts.map +1 -1
- package/build/level/tiled/TMXLayer.d.ts +5 -2
- package/build/level/tiled/TMXLayer.d.ts.map +1 -1
- package/build/level/tiled/TMXObject.d.ts +0 -1
- package/build/level/tiled/TMXObjectFactory.d.ts +3 -2
- package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
- package/build/level/tiled/TMXTile.d.ts +2 -1
- package/build/level/tiled/TMXTile.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts +7 -4
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/level/tiled/TMXTileset.d.ts +1 -1
- package/build/level/tiled/TMXTileset.d.ts.map +1 -1
- package/build/level/tiled/TMXTilesetGroup.d.ts +5 -0
- package/build/level/tiled/TMXTilesetGroup.d.ts.map +1 -1
- package/build/level/tiled/factories/shape.d.ts +0 -1
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +6 -5
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +5 -0
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +5 -7
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +5 -0
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXRenderer.d.ts +19 -4
- package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/autodetect.d.ts +0 -4
- package/build/level/tiled/renderer/autodetect.d.ts.map +1 -1
- package/build/loader/cache.d.ts +220 -0
- package/build/loader/cache.d.ts.map +1 -1
- package/build/loader/loader.d.ts +20 -340
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/loadingscreen.d.ts +1 -2
- package/build/loader/loadingscreen.d.ts.map +1 -1
- package/build/loader/parsers/gltf.d.ts +115 -0
- package/build/loader/parsers/gltf.d.ts.map +1 -1
- package/build/loader/parsers/shader.d.ts +0 -2
- package/build/math/color.d.ts +28 -5
- package/build/math/color.d.ts.map +1 -1
- package/build/math/matrix2d.d.ts +1 -1
- package/build/math/matrix2d.d.ts.map +1 -1
- package/build/math/matrix3d.d.ts +1 -1
- package/build/math/matrix3d.d.ts.map +1 -1
- package/build/math/observableVector2d.d.ts +14 -2
- package/build/math/observableVector2d.d.ts.map +1 -1
- package/build/math/observableVector3d.d.ts +15 -1
- package/build/math/observableVector3d.d.ts.map +1 -1
- package/build/math/vector2d.d.ts +31 -1
- package/build/math/vector2d.d.ts.map +1 -1
- package/build/math/vector3d.d.ts +38 -1
- package/build/math/vector3d.d.ts.map +1 -1
- package/build/math/vertex.d.ts.map +1 -1
- package/build/particles/emitter.d.ts.map +1 -1
- package/build/particles/particle.d.ts +29 -2
- package/build/particles/particle.d.ts.map +1 -1
- package/build/particles/settings.d.ts +104 -0
- package/build/particles/settings.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +9 -1
- package/build/physics/adapter.d.ts.map +1 -1
- package/build/physics/bounds.d.ts +1 -1
- package/build/physics/bounds.d.ts.map +1 -1
- package/build/physics/broadphase/octree.d.ts +24 -0
- package/build/physics/broadphase/octree.d.ts.map +1 -1
- package/build/physics/broadphase/quadtree.d.ts +31 -0
- package/build/physics/broadphase/quadtree.d.ts.map +1 -1
- package/build/physics/builtin/body.d.ts +17 -2
- package/build/physics/builtin/body.d.ts.map +1 -1
- package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
- package/build/physics/builtin/detector.d.ts +0 -1
- package/build/physics/builtin/detector.d.ts.map +1 -1
- package/build/physics/builtin/sat.d.ts +0 -7
- package/build/physics/builtin/sat3d.d.ts +46 -0
- package/build/physics/builtin/sat3d.d.ts.map +1 -1
- package/build/physics/response.d.ts +45 -62
- package/build/physics/response.d.ts.map +1 -1
- package/build/pool.d.ts +4 -0
- package/build/pool.d.ts.map +1 -1
- package/build/renderable/collectable.d.ts +6 -1
- package/build/renderable/collectable.d.ts.map +1 -1
- package/build/renderable/colorlayer.d.ts +17 -4
- package/build/renderable/colorlayer.d.ts.map +1 -1
- package/build/renderable/container.d.ts +23 -17
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/entity/entity.d.ts +12 -16
- package/build/renderable/entity/entity.d.ts.map +1 -1
- package/build/renderable/frameAnimation.d.ts +1 -1
- package/build/renderable/groundshadow.d.ts +1 -0
- package/build/renderable/groundshadow.d.ts.map +1 -1
- package/build/renderable/imagelayer.d.ts +12 -5
- package/build/renderable/imagelayer.d.ts.map +1 -1
- package/build/renderable/instanced_mesh.d.ts +56 -7
- package/build/renderable/instanced_mesh.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +369 -4
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/nineslicesprite.d.ts +3 -13
- package/build/renderable/nineslicesprite.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +129 -28
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +7 -20
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/sprite3d.d.ts +31 -16
- package/build/renderable/sprite3d.d.ts.map +1 -1
- package/build/renderable/text/bitmaptext.d.ts +76 -5
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/bitmaptextdata.d.ts +1 -5
- package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
- package/build/renderable/text/glypheffect.d.ts +44 -0
- package/build/renderable/text/glypheffect.d.ts.map +1 -0
- package/build/renderable/text/text.d.ts +22 -3
- 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/trail.d.ts +0 -1
- package/build/renderable/trail.d.ts.map +1 -1
- package/build/renderable/trail3d.d.ts +174 -0
- package/build/renderable/trail3d.d.ts.map +1 -0
- package/build/renderable/trigger.d.ts +28 -5
- package/build/renderable/trigger.d.ts.map +1 -1
- package/build/renderable/ui/panelpaint.d.ts +5 -0
- package/build/renderable/ui/panelpaint.d.ts.map +1 -0
- package/build/renderable/ui/progressbar.d.ts +192 -0
- package/build/renderable/ui/progressbar.d.ts.map +1 -0
- package/build/renderable/ui/uibaseelement.d.ts +48 -3
- package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
- package/build/renderable/ui/uipanel.d.ts +245 -0
- package/build/renderable/ui/uipanel.d.ts.map +1 -0
- package/build/renderable/ui/uispriteelement.d.ts +19 -3
- package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
- package/build/renderable/ui/uitextbutton.d.ts +30 -1
- package/build/renderable/ui/uitextbutton.d.ts.map +1 -1
- package/build/state/state.d.ts.map +1 -1
- package/build/system/bootstrap.d.ts.map +1 -1
- package/build/system/legacy_pool.d.ts +24 -4
- package/build/system/legacy_pool.d.ts.map +1 -1
- package/build/system/pool.d.ts +15 -8
- package/build/system/pool.d.ts.map +1 -1
- package/build/tweens/tween.d.ts +50 -3
- package/build/tweens/tween.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +34 -23
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/effects/blendEffect.d.ts +0 -1
- package/build/video/effects/bloom.d.ts +72 -0
- package/build/video/effects/bloom.d.ts.map +1 -0
- package/build/video/effects/blur.d.ts +3 -2
- package/build/video/effects/blur.d.ts.map +1 -1
- package/build/video/effects/chromaticAberration.d.ts +3 -2
- package/build/video/effects/chromaticAberration.d.ts.map +1 -1
- package/build/video/effects/colorMatrix.d.ts +3 -2
- package/build/video/effects/colorMatrix.d.ts.map +1 -1
- package/build/video/effects/desaturate.d.ts +10 -2
- package/build/video/effects/desaturate.d.ts.map +1 -1
- package/build/video/effects/dissolve.d.ts +3 -2
- package/build/video/effects/dissolve.d.ts.map +1 -1
- package/build/video/effects/dropShadow.d.ts +3 -2
- package/build/video/effects/dropShadow.d.ts.map +1 -1
- package/build/video/effects/flash.d.ts +3 -2
- package/build/video/effects/flash.d.ts.map +1 -1
- package/build/video/effects/glow.d.ts +3 -2
- package/build/video/effects/glow.d.ts.map +1 -1
- package/build/video/effects/hologram.d.ts +3 -2
- package/build/video/effects/hologram.d.ts.map +1 -1
- package/build/video/effects/invert.d.ts +10 -2
- package/build/video/effects/invert.d.ts.map +1 -1
- package/build/video/effects/outline.d.ts +3 -2
- package/build/video/effects/outline.d.ts.map +1 -1
- package/build/video/effects/pixelate.d.ts +3 -2
- package/build/video/effects/pixelate.d.ts.map +1 -1
- package/build/video/effects/radialGradient.d.ts +8 -3
- package/build/video/effects/radialGradient.d.ts.map +1 -1
- package/build/video/effects/scanline.d.ts +3 -2
- package/build/video/effects/scanline.d.ts.map +1 -1
- package/build/video/effects/sepia.d.ts +10 -2
- package/build/video/effects/sepia.d.ts.map +1 -1
- package/build/video/effects/shadereffect.d.ts +10 -4
- package/build/video/effects/shadereffect.d.ts.map +1 -1
- package/build/video/effects/shine.d.ts +3 -2
- package/build/video/effects/shine.d.ts.map +1 -1
- package/build/video/effects/tintPulse.d.ts +3 -7
- package/build/video/effects/tintPulse.d.ts.map +1 -1
- package/build/video/effects/tonemap.d.ts +121 -0
- package/build/video/effects/tonemap.d.ts.map +1 -0
- package/build/video/effects/vignette.d.ts +3 -2
- package/build/video/effects/vignette.d.ts.map +1 -1
- package/build/video/effects/wave.d.ts +3 -7
- package/build/video/effects/wave.d.ts.map +1 -1
- package/build/video/gpu/batcher.d.ts +8 -2
- package/build/video/gpu/batcher.d.ts.map +1 -1
- package/build/video/gpu/vertexformat.d.ts +26 -0
- package/build/video/gpu/vertexformat.d.ts.map +1 -1
- package/build/video/gradient.d.ts +1 -1
- package/build/video/gradient.d.ts.map +1 -1
- package/build/video/renderer.d.ts +111 -7
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/renderstate.d.ts +2 -0
- package/build/video/renderstate.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts +3 -4
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts +0 -1
- package/build/video/rendertarget/rendertarget.d.ts +12 -5
- package/build/video/rendertarget/rendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/webglrendertarget.d.ts +0 -1
- package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/webgpurendertarget.d.ts +24 -14
- package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -1
- package/build/video/texture/atlas.d.ts +2 -1
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts +1 -3
- package/build/video/texture/frametexture.d.ts +0 -1
- package/build/video/texture/frametexture.d.ts.map +1 -1
- package/build/video/texture/noise_texture2d.d.ts +1 -0
- package/build/video/texture/noise_texture2d.d.ts.map +1 -1
- package/build/video/texture/texture2d.d.ts +6 -0
- package/build/video/texture/texture2d.d.ts.map +1 -1
- package/build/video/utils/autodetect.d.ts +0 -2
- package/build/video/webgl/batchers/batcher.d.ts +0 -9
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +2 -0
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +4 -2
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +0 -3
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts +4 -0
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +0 -1
- package/build/video/webgl/buffer/retained_geometry.d.ts +0 -1
- package/build/video/webgl/glshader.d.ts +5 -3
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts +0 -4
- package/build/video/webgl/texture/store.d.ts +0 -1
- package/build/video/webgl/webgl_renderer.d.ts +63 -24
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/mesh_batcher.d.ts +0 -3
- package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgpu/batchers/quad_batcher.d.ts +0 -2
- package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts +0 -2
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts.map +1 -1
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
- package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +0 -2
- package/build/video/webgpu/texture/frametexture.d.ts +0 -2
- package/build/video/webgpu/texture/frametexture.d.ts.map +1 -1
- package/build/video/webgpu/texture/store.d.ts +0 -1
- package/build/video/webgpu/webgpu_renderer.d.ts +7 -75
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +2 -2
- package/skills/AGENTS.md +1 -1
- package/skills/melonjs/SKILL.md +2 -0
- package/skills/melonjs-3d/SKILL.md +454 -22
- package/skills/melonjs-3d-assets/SKILL.md +111 -10
- package/skills/melonjs-audio/SKILL.md +229 -8
- package/skills/melonjs-camera-and-drawing/SKILL.md +127 -1
- package/skills/melonjs-display-and-scaling/SKILL.md +273 -0
- package/skills/melonjs-effects-and-shaders/SKILL.md +341 -29
- package/skills/melonjs-events/SKILL.md +8 -6
- package/skills/melonjs-input/SKILL.md +147 -7
- package/skills/melonjs-math/SKILL.md +313 -0
- package/skills/melonjs-particles-and-trails/SKILL.md +189 -13
- package/skills/melonjs-performance/SKILL.md +131 -23
- package/skills/melonjs-physics/SKILL.md +103 -28
- package/skills/melonjs-renderables/SKILL.md +8 -2
- package/skills/melonjs-scenes-and-state/SKILL.md +134 -3
- package/skills/melonjs-sprites-and-animation/SKILL.md +9 -4
- package/skills/melonjs-tilemaps/SKILL.md +40 -12
- package/skills/melonjs-ui-and-text/SKILL.md +546 -7
- package/build/level/gltf/srgb.d.ts +0 -20
- package/build/level/gltf/srgb.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -61,14 +61,15 @@ Graphics
|
|
|
61
61
|
- **2D** — `Light2d` as a first-class `Renderable` (multiple dynamic lights, radial-gradient falloff, illumination-only mode, procedural rendering via `drawLight`), plus optional per-pixel normal-map shading on sprites for 3D-looking dynamic lights
|
|
62
62
|
- **3D** — `Light3d` directional, point, spot and ambient lights, added to the world like `Light2d` (half-Lambert diffuse + ambient fill, quadratic falloff and cone angles on the punctual types, runtime-manipulable for day/night), auto-loaded from a glTF scene's authored suns and lamps
|
|
63
63
|
- up to **32 simultaneous lights** on either path, with light data travelling in a uniform buffer — a static light rig costs zero GPU state changes per frame
|
|
64
|
-
- Ground ("blob") shadows for 3D objects — **on by default** — so characters and props read as standing on the floor instead of hovering. An ellipse matching the caster's own footprint and rotation, shrinking and fading with height above the ground; one extra draw per object, and **one for an entire `InstancedMesh` scatter regardless of instance count**. Controllable per object, per glTF scene (`level.load(name, { castGroundShadow })`) or application-wide. Deliberately not shadow mapping: it answers "where is this standing", which is what a 2.5D scene needs
|
|
65
|
-
- Built-in shader effects (Flash, Outline, Glow, Dissolve, CRT, Hologram, etc.) with multi-pass chaining via `addPostEffect()`, plus custom shader support on both GPU backends: `ShaderEffect` for per-sprite fragment effects (GLSL and/or WGSL bodies) and complete custom mesh shader programs via `mesh.shader` (a dual-language `GLShader`: GLSL pair and/or WGSL module)
|
|
64
|
+
- Ground ("blob") shadows for 3D objects — **on by default** — so characters and props read as standing on the floor instead of hovering. An ellipse matching the caster's own footprint and rotation, shrinking and fading with height above the ground; one extra draw per object, and **one for an entire `InstancedMesh` scatter regardless of instance count**. Shaped by the light rather than always straight down: `shadowLight` points a blob at a `Light3d` and is re-read every draw, so a day/night cycle carries every shadow with it, while `shadowOffset` slides it out from the caster's feet, `shadowStretch` lengthens it for a low sun, `shadowScale` sizes it independently of the object, and `shadowGroundNormal` lays it on a floor that is not level. All of them work on an `InstancedMesh` too, as one value for the whole set. Controllable per object, per glTF scene (`level.load(name, { castGroundShadow, shadowLight, … })`) or application-wide. Deliberately not shadow mapping: it answers "where is this standing", which is what a 2.5D scene needs
|
|
65
|
+
- Built-in shader effects (Flash, Outline, Glow, Bloom, ToneMapping, Dissolve, CRT, Hologram, etc.) with multi-pass chaining via `addPostEffect()`, plus custom shader support on both GPU backends: `ShaderEffect` for per-sprite fragment effects (GLSL and/or WGSL bodies) and complete custom mesh shader programs via `mesh.shader` (a dual-language `GLShader`: GLSL pair and/or WGSL module)
|
|
66
|
+
- Optional HDR rendering (`hdr: true`) — the camera's render targets become half-float, so additive light stops saturating on every write and `BloomEffect` thresholds on genuinely over-bright pixels instead of merely bright ones, with `ToneMappingEffect` and a `toneMapping` setting to compress the result back into display range when your art calls for it. Off by default and additive: nothing is inserted into your effect chain, so turning it on does not restyle a game whose look is built on clipped whites. On WebGPU it goes one step further — `hdrOutput: true` presents the frame in the display's own dynamic range rather than clamping it to SDR at the last step
|
|
66
67
|
- Trail renderable for fading, tapering ribbons behind moving objects (speed lines, sword slashes, magic trails)
|
|
67
68
|
- System & Bitmap Text with built-in typewriter effect
|
|
68
69
|
- Video sprite playback
|
|
69
70
|
|
|
70
71
|
Sound
|
|
71
|
-
- Web Audio support with 3D spatial audio and stereo panning
|
|
72
|
+
- Web Audio support with 3D spatial audio and stereo panning, plus a procedural tone/noise API. The playback backend began as [howler.js](https://howlerjs.com) and is now a customized derivative vendored into the engine, so this is **not** a runtime dependency (see `src/audio/backend/LICENSE`)
|
|
72
73
|
- Built-in procedural audio primitives (envelope-shaped oscillators, white/pink/brown noise) for SFX without sample assets
|
|
73
74
|
- Direct `AudioContext` / master-gain accessors for custom WebAudio graphs that mix with the engine's master volume / mute
|
|
74
75
|
|
|
@@ -191,6 +192,9 @@ Examples
|
|
|
191
192
|
* [3D Mesh](https://melonjs.github.io/melonJS/examples/#/mesh-3d) ([source](https://github.com/melonjs/melonJS/tree/master/packages/examples/src/examples/mesh3d))
|
|
192
193
|
* [3D Mesh Material](https://melonjs.github.io/melonJS/examples/#/mesh-3d-material) ([source](https://github.com/melonjs/melonJS/tree/master/packages/examples/src/examples/mesh3dMaterial))
|
|
193
194
|
* [AfterBurner Clone](https://melonjs.github.io/melonJS/examples/#/after-burner) ([source](https://github.com/melonjs/melonJS/tree/master/packages/examples/src/examples/afterBurner)) — `Camera3d` + 3D Mesh arcade shooter
|
|
195
|
+
* [Earth Defender](https://melonjs.github.io/melonJS/examples/#/earth-defender) ([source](https://github.com/melonjs/melonJS/tree/master/packages/examples/src/examples/earthDefender)) — a Stardust tribute: a `Camera3d` posed from the player's own surface point, blob shadows lying on a sphere through `shadowGroundPoint`, mesh-hosted `ShaderEffect` shields, spatial audio and HDR bloom
|
|
196
|
+
* [Ground Shadows](https://melonjs.github.io/melonJS/examples/#/ground-shadows) ([source](https://github.com/melonjs/melonJS/tree/master/packages/examples/src/examples/groundShadows)) — every blob-shadow setting side by side under an orbiting sun, including blobs lying on a slope and a 70-instance scatter that costs one extra draw
|
|
197
|
+
* [Jungle Rabbit](https://melonjs.github.io/melonJS/examples/#/jungle-rabbit) ([source](https://github.com/melonjs/melonJS/tree/master/packages/examples/src/examples/jungleRabbit)) — a low-poly river endless runner: Blender-modelled props through `InstancedMesh`, a rigged paddling boat, a procedural valley and shadows laid on its banks
|
|
194
198
|
* [glTF Scene](https://melonjs.github.io/melonJS/examples/#/gltf) ([source](https://github.com/melonjs/melonJS/tree/master/packages/examples/src/examples/gltf)) — a Blender-authored, lit 3D scene loaded with `level.load`
|
|
195
199
|
* [glTF Animated Model](https://melonjs.github.io/melonJS/examples/#/gltf-character) ([source](https://github.com/melonjs/melonJS/tree/master/packages/examples/src/examples/gltf)) — a rigged character (Kenney Blocky Characters) with node animation, driven by the Sprite-aligned `setCurrentAnimation` / `play` / `pause` / `stop` API
|
|
196
200
|
* [Trail](https://melonjs.github.io/melonJS/examples/#/trail) ([source](https://github.com/melonjs/melonJS/tree/master/packages/examples/src/examples/trail))
|
|
@@ -46,7 +46,39 @@ export default class Application {
|
|
|
46
46
|
*/
|
|
47
47
|
renderer: Renderer;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* The "default" camera of the stage that is currently active.
|
|
50
|
+
*
|
|
51
|
+
* It MIRRORS the active stage, so it changes with every `state.change()`,
|
|
52
|
+
* and its concrete class is whatever that stage resolved to: an explicit
|
|
53
|
+
* `cameras` entry on the stage, then the stage's own `cameraClass`, then
|
|
54
|
+
* the application's `cameraClass`, then a shared {@link Camera2d}.
|
|
55
|
+
*
|
|
56
|
+
* **Typed as the base class on purpose.** A stage overrides the
|
|
57
|
+
* application, and built-in stages do: the loading screen pins a
|
|
58
|
+
* {@link Camera2d} whatever `cameraClass` the application was given. So
|
|
59
|
+
* there is no type this property could carry that a stage could not
|
|
60
|
+
* contradict, and a 3D application would be told it has a
|
|
61
|
+
* {@link Camera3d} here while the loader is up.
|
|
62
|
+
*
|
|
63
|
+
* A 3D game therefore has two sound options, and neither of them is a
|
|
64
|
+
* cast. OWN the camera, which is the better one, because the type is
|
|
65
|
+
* never lost in the first place:
|
|
66
|
+
* @example
|
|
67
|
+
* class GameStage extends Stage {
|
|
68
|
+
* readonly camera: Camera3d;
|
|
69
|
+
*
|
|
70
|
+
* constructor(app) {
|
|
71
|
+
* const camera = new Camera3d(0, 0, app.renderer.width, app.renderer.height);
|
|
72
|
+
* super({ cameras: [camera] });
|
|
73
|
+
* // kept with its real type; nothing downstream has to narrow
|
|
74
|
+
* this.camera = camera;
|
|
75
|
+
* }
|
|
76
|
+
* }
|
|
77
|
+
* @example
|
|
78
|
+
* // or narrow where you read it, which the language already verifies
|
|
79
|
+
* if (app.viewport instanceof Camera3d) {
|
|
80
|
+
* app.viewport.setBasis(right, up, forward);
|
|
81
|
+
* }
|
|
50
82
|
*/
|
|
51
83
|
viewport: Camera2d;
|
|
52
84
|
/**
|
|
@@ -216,21 +248,47 @@ export default class Application {
|
|
|
216
248
|
* into — see {@link Application#getParentElement}), so the canvas and
|
|
217
249
|
* any sibling HUD / overlay markup inside that container go fullscreen
|
|
218
250
|
* together.
|
|
251
|
+
* Must be called from a USER GESTURE, a click or a key press. Browsers
|
|
252
|
+
* refuse it otherwise: the returned promise rejects, this logs the
|
|
253
|
+
* rejection and nothing happens on screen. That is why the example below
|
|
254
|
+
* hangs the call off a key rather than calling it at startup, and why a
|
|
255
|
+
* game offering fullscreen puts it behind a button or a menu entry.
|
|
256
|
+
*
|
|
257
|
+
* Does nothing when the browser has no fullscreen support, or when the
|
|
258
|
+
* application is already fullscreen.
|
|
219
259
|
* @param element - optional element to fullscreen instead of `this.parentElement`
|
|
220
260
|
* @example
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
261
|
+
* import { event, input } from "melonjs";
|
|
262
|
+
*
|
|
263
|
+
* // F toggles fullscreen, from anywhere in the game
|
|
264
|
+
* input.bindKey(input.KEY.F, "fullscreen");
|
|
265
|
+
* event.on(event.KEYDOWN, (action, keyCode, edge) => {
|
|
266
|
+
* // `edge` only: a held key auto-repeats, and a repeat would toggle
|
|
267
|
+
* // straight back out of what it just turned on
|
|
268
|
+
* if (action !== "fullscreen" || !edge) {
|
|
269
|
+
* return;
|
|
270
|
+
* }
|
|
271
|
+
* if (app.isFullscreen()) {
|
|
272
|
+
* app.exitFullscreen();
|
|
273
|
+
* } else {
|
|
274
|
+
* app.requestFullscreen();
|
|
275
|
+
* }
|
|
228
276
|
* });
|
|
229
277
|
* @category Application
|
|
230
278
|
*/
|
|
231
279
|
requestFullscreen(element?: Element): void;
|
|
232
280
|
/**
|
|
233
281
|
* Exit fullscreen mode for this application.
|
|
282
|
+
*
|
|
283
|
+
* Does nothing when the browser has no fullscreen support, or when the
|
|
284
|
+
* application is not fullscreen, so it is safe to call blind. Unlike
|
|
285
|
+
* {@link Application#requestFullscreen} it needs no user gesture: a page
|
|
286
|
+
* is always allowed to give fullscreen back.
|
|
287
|
+
*
|
|
288
|
+
* Note that the user can leave fullscreen without this being called, with
|
|
289
|
+
* Escape or the browser's own control, so a UI showing the current state
|
|
290
|
+
* should read {@link Application#isFullscreen} back rather than remember
|
|
291
|
+
* what it last asked for.
|
|
234
292
|
* @category Application
|
|
235
293
|
*/
|
|
236
294
|
exitFullscreen(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/application/application.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/application/application.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AAGpD,OAAO,KAAK,MAAM,qBAAqB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;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IA+C1B;;OAEG;IACH,IAAI,IAAI,IAAI;CA0CZ;AAED;;;;;GAKG;AACH,eAAO,IAAI,IAAI,EAAE,WAAW,CAAC"}
|
|
@@ -5,6 +5,11 @@ export declare const defaultApplicationSettings: {
|
|
|
5
5
|
powerPreference: "default";
|
|
6
6
|
transparent: false;
|
|
7
7
|
antiAlias: false;
|
|
8
|
+
hdr: false;
|
|
9
|
+
hdrOutput: false;
|
|
10
|
+
toneMapping: "none";
|
|
11
|
+
toneMappingExposure: number;
|
|
12
|
+
toneMappingWhite: number;
|
|
8
13
|
prewarm: true;
|
|
9
14
|
textureFilter: "auto";
|
|
10
15
|
maxTextures: "auto";
|
|
@@ -15,6 +20,7 @@ export declare const defaultApplicationSettings: {
|
|
|
15
20
|
gpuTilemap: true;
|
|
16
21
|
failIfMajorPerformanceCaveat: true;
|
|
17
22
|
highPrecisionShader: true;
|
|
23
|
+
scaleRounding: "fractional";
|
|
18
24
|
subPixel: false;
|
|
19
25
|
verbose: false;
|
|
20
26
|
backgroundColor: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultApplicationSettings.d.ts","sourceRoot":"","sources":["../../src/application/defaultApplicationSettings.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,0BAA0B
|
|
1
|
+
{"version":3,"file":"defaultApplicationSettings.d.ts","sourceRoot":"","sources":["../../src/application/defaultApplicationSettings.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../src/application/header.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../src/application/header.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CA+CpD"}
|
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
import type Application from "./application.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The largest scale at or below `scale` that covers each source pixel with a
|
|
4
|
+
* WHOLE number of device pixels.
|
|
5
|
+
*
|
|
6
|
+
* Rounded down, and rounded in DEVICE pixels rather than CSS ones. That
|
|
7
|
+
* distinction is the whole of it: the canvas is given a CSS size and the
|
|
8
|
+
* browser multiplies by `devicePixelRatio` on the way to real pixels, so
|
|
9
|
+
* flooring the CSS factor lets the fraction come straight back. A factor of
|
|
10
|
+
* 2 at a ratio of 1.25 is 2.5 device pixels per source pixel, which is the
|
|
11
|
+
* unevenness the setting exists to remove.
|
|
12
|
+
*
|
|
13
|
+
* Worked through at a ratio of 2, fitting a 480 wide design into 1280: the
|
|
14
|
+
* raw factor is 2.667 CSS, which is 5.333 device pixels. Flooring here gives
|
|
15
|
+
* 5 device pixels, so a CSS factor of 2.5. Flooring the CSS factor instead
|
|
16
|
+
* would give 2, which is 4 device pixels: also whole, and a whole device
|
|
17
|
+
* pixel smaller than the container could have afforded.
|
|
18
|
+
*
|
|
19
|
+
* Never returns less than one device pixel per source pixel. A container
|
|
20
|
+
* smaller than the design resolution has no whole factor to give, and a
|
|
21
|
+
* scale of zero does not draw at all.
|
|
22
|
+
* @param scale - the unconstrained factor, in CSS pixels
|
|
23
|
+
* @param ratio - `devicePixelRatio`
|
|
24
|
+
* @returns the constrained factor, still in CSS pixels
|
|
25
|
+
*/
|
|
26
|
+
export declare function integerDeviceScale(scale: number, ratio: number): number;
|
|
2
27
|
/**
|
|
3
28
|
* callback for window resize event
|
|
4
29
|
* @param game - the game application instance triggering the resize
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize.d.ts","sourceRoot":"","sources":["../../src/application/resize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAkChD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"resize.d.ts","sourceRoot":"","sources":["../../src/application/resize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAkChD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CA4GhD"}
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
export declare const ScaleMethods: {
|
|
2
2
|
/**
|
|
3
|
-
* Manual; no scaling is performed
|
|
4
|
-
*
|
|
3
|
+
* Manual; no automatic scaling is performed. The canvas keeps the size it
|
|
4
|
+
* was given and nothing is measured.
|
|
5
|
+
*
|
|
6
|
+
* No illustration: there is nothing to show. The one that used to sit
|
|
7
|
+
* here was `Fit`'s.
|
|
5
8
|
*/
|
|
6
9
|
readonly Manual: "manual";
|
|
7
10
|
/**
|
|
8
|
-
* Letterboxed;
|
|
11
|
+
* Letterboxed; the DESIGN RESOLUTION is kept and the whole frame is scaled
|
|
12
|
+
* to the largest factor that fits, leaving the rest as margin.
|
|
13
|
+
*
|
|
14
|
+
* The one mode where the game always sees exactly the world it was
|
|
15
|
+
* authored for: every other mode resizes the renderer, so the viewport
|
|
16
|
+
* grows or shrinks with the window. It is also the only mode
|
|
17
|
+
* `scaleRounding` applies to, since it is the only one with a fixed
|
|
18
|
+
* factor to round.
|
|
9
19
|
* <img src="images/scale-fit.png"/>
|
|
10
20
|
*/
|
|
11
21
|
readonly Fit: "fit";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaleMethods.d.ts","sourceRoot":"","sources":["../../src/application/scaleMethods.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;IACxB
|
|
1
|
+
{"version":3,"file":"scaleMethods.d.ts","sourceRoot":"","sources":["../../src/application/scaleMethods.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;IACxB;;;;;;OAMG;;IAGH;;;;;;;;;;OAUG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;CAEM,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -52,17 +52,51 @@ export type ApplicationSettings = {
|
|
|
52
52
|
*/
|
|
53
53
|
renderer: RendererType | Renderer;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* how the canvas is scaled to the page. A number is a fixed multiplier applied to the design resolution and nothing is measured; `"auto"` scales to the available space every time the window changes, using {@link ApplicationSettings.scaleMethod} to decide how and {@link ApplicationSettings.scaleTarget} to decide what is measured.
|
|
56
|
+
*
|
|
57
|
+
* `scaleMethod`, `scaleTarget` and {@link ApplicationSettings.scaleRounding} apply to `"auto"` only. With a fixed number they are ignored.
|
|
56
58
|
* @default 1
|
|
59
|
+
* @see ApplicationSettings.scaleMethod
|
|
60
|
+
* @see ApplicationSettings.scaleTarget
|
|
61
|
+
* @see ApplicationSettings.scaleRounding
|
|
57
62
|
*/
|
|
58
63
|
scale: number | "auto";
|
|
59
64
|
/**
|
|
60
|
-
*
|
|
65
|
+
* how automatic scaling uses the space available to it. Applies when {@link ApplicationSettings.scale} is `"auto"`.
|
|
66
|
+
*
|
|
67
|
+
* The distinction that decides which to pick is whether the DESIGN RESOLUTION moves. `"fit"` keeps it and scales the whole frame to the largest factor that fits, leaving the rest as margin, so the game always sees exactly the world it was authored for. Every other mode calls `renderer.resize()`, so the design resolution follows the container and the game sees MORE or LESS of the world on a different window: `"fill-min"` / `"fill-max"` keep the aspect ratio while doing so, `"flex"` / `"flex-width"` / `"flex-height"` resize one or both axes, and `"stretch"` scales each axis independently so the aspect ratio is not preserved. `"manual"` does nothing automatic.
|
|
68
|
+
*
|
|
69
|
+
* A game whose layout assumes a known frame wants `"fit"`. A game that should reveal more world on a larger window wants one of the others, and has to cope with a viewport whose size it did not choose.
|
|
61
70
|
* @default "manual"
|
|
71
|
+
* @see ApplicationSettings.scale
|
|
62
72
|
*/
|
|
63
73
|
scaleMethod: ScaleMethod;
|
|
64
74
|
/**
|
|
65
|
-
* the
|
|
75
|
+
* whether the automatically computed scale factor may be fractional, or must be a whole number of device pixels. `"fractional"` (the default) lets the canvas fill its container exactly, at the cost of source pixels landing on uneven numbers of device pixels: at a 2.667 factor some are 3 device pixels wide and some are 2, which browsers resolve differently and which pixel art shows as shimmering or uneven stems. `"integer"` rounds the factor DOWN so every source pixel covers the same whole number of device pixels, and letterboxes with whatever space is left over.
|
|
76
|
+
*
|
|
77
|
+
* Only `scaleMethod: "fit"` is affected: every other method resizes the renderer to the container, so the design resolution changes and there is no fixed factor to round. The rounding is applied in DEVICE pixels, so `devicePixelRatio` cannot reintroduce a fraction.
|
|
78
|
+
*
|
|
79
|
+
* **What it costs depends on the container, and on `devicePixelRatio`, far more than it looks.** A higher ratio has more device pixels to round among, so it lands closer to the factor it wanted. For a 480x270 design, which is exactly a quarter of 1920x1080:
|
|
80
|
+
*
|
|
81
|
+
* | container | ratio | fit | integer | presented | area lost |
|
|
82
|
+
* |---|---|---|---|---|---|
|
|
83
|
+
* | 1920x1080 | 1 or 2 | 4.000 | 4 / 8 | 1920x1080 | none |
|
|
84
|
+
* | 1440x810 | 1 | 3.000 | 3 | 1440x810 | none |
|
|
85
|
+
* | 1280x720 | 2 | 2.667 | 5 | 1200x675 | 12% |
|
|
86
|
+
* | 1280x720 | 1 | 2.667 | 2 | 960x540 | 44% |
|
|
87
|
+
* | 1366x768 | 1 | 2.844 | 2 | 960x540 | 51% |
|
|
88
|
+
*
|
|
89
|
+
* A design resolution that divides the sizes you expect costs nothing at all; one that does not can give up half the screen on a 1x display. Choose the design resolution with this in mind rather than reaching for the setting afterwards.
|
|
90
|
+
* @default "fractional"
|
|
91
|
+
*/
|
|
92
|
+
scaleRounding: "fractional" | "integer";
|
|
93
|
+
/**
|
|
94
|
+
* the element automatic scaling measures to decide how much space it has. By default it is the PARENT of the container the canvas was mounted in, which is one level further out than most callers expect and is the usual cause of a canvas that does not fit its box.
|
|
95
|
+
*
|
|
96
|
+
* The case to watch for: a container that is `position: fixed` or `absolute` contributes no height to its parent, so that parent measures only whatever else it holds. If it measures `<body>`, the window size is used instead, and the canvas comes out larger than the box it lives in, cropped by whatever sits above it, by exactly the height of that other content on every resize.
|
|
97
|
+
*
|
|
98
|
+
* Name the element here when the default does not land on the box you meant, or give the canvas container a parent whose box IS that area.
|
|
99
|
+
* @see ApplicationSettings.scale
|
|
66
100
|
*/
|
|
67
101
|
scaleTarget: HTMLElement;
|
|
68
102
|
/**
|
|
@@ -83,7 +117,9 @@ export type ApplicationSettings = {
|
|
|
83
117
|
*/
|
|
84
118
|
powerPreference: PowerPreference;
|
|
85
119
|
/**
|
|
86
|
-
* whether
|
|
120
|
+
* whether the canvas composites with the page behind it. `false`, the default, makes the front buffer opaque: the clear alpha is 1, WebGPU is configured `alphaMode: "opaque"`, and the canvas renderer clears rather than erases.
|
|
121
|
+
*
|
|
122
|
+
* Turn it on only when the page is meant to show through, since an opaque surface is the cheaper one to composite and is what a game filling its container wants. With it on the clear alpha becomes 0 and WebGPU switches to `"premultiplied"`, so anything drawn at partial alpha blends with the page rather than with a known background.
|
|
87
123
|
* @default false
|
|
88
124
|
*/
|
|
89
125
|
transparent: boolean;
|
|
@@ -100,6 +136,104 @@ export type ApplicationSettings = {
|
|
|
100
136
|
* @default false
|
|
101
137
|
*/
|
|
102
138
|
antiAlias: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Let the post-effect chain carry color values above 1 instead of
|
|
141
|
+
* clamping at every write.
|
|
142
|
+
*
|
|
143
|
+
* Render targets become half-float rather than 8 bits per channel, which
|
|
144
|
+
* is what gives {@link BloomEffect} genuinely over-bright pixels to
|
|
145
|
+
* threshold on and {@link ToneMappingEffect} a range to compress. Off by
|
|
146
|
+
* default, for the same reasons `antiAlias` is: it costs GPU memory, and
|
|
147
|
+
* a game gets a different pipeline depending on the driver underneath.
|
|
148
|
+
*
|
|
149
|
+
* The cost is narrow. Render targets exist only while something is
|
|
150
|
+
* actually running a multi-pass effect chain, and only the CAMERA pair
|
|
151
|
+
* takes the half-float format, at 8 bytes per pixel instead of 4. Sprite
|
|
152
|
+
* chains and the advanced-blend target stay 8-bit whatever this says. A
|
|
153
|
+
* game with no camera post-effects allocates nothing either way.
|
|
154
|
+
*
|
|
155
|
+
* **Not HDR output on its own.** This is headroom THROUGH the chain:
|
|
156
|
+
* the frame is presented in SDR, so anything still above 1 at the end
|
|
157
|
+
* clamps on the blit, exactly as it did before this setting existed. See
|
|
158
|
+
* `hdrOutput` to remove that last clamp as well, on the backends that
|
|
159
|
+
* can. Nothing is added to your effect
|
|
160
|
+
* chain, so turning this on does not restyle your game. Add a
|
|
161
|
+
* `ToneMappingEffect` to the camera if you want a curve rather than that
|
|
162
|
+
* clamp, bearing in mind that every curve maps 1 to less than 1, so a
|
|
163
|
+
* look built on clipped whites will change.
|
|
164
|
+
*
|
|
165
|
+
* Ignored where it cannot be honoured: the Canvas renderer has no render
|
|
166
|
+
* targets, and a WebGL2 driver missing either half-float extension warns
|
|
167
|
+
* once, naming which half, and stays at 8 bits. Read
|
|
168
|
+
* {@link Renderer#supportsHDR} for what you actually got, and branch a
|
|
169
|
+
* grade on that rather than on this, which is only the request.
|
|
170
|
+
* @default false
|
|
171
|
+
*/
|
|
172
|
+
hdr: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Tone curve applied to the camera at the very end of its effect chain,
|
|
175
|
+
* or `"none"` to leave the frame alone.
|
|
176
|
+
*
|
|
177
|
+
* `"none"` by default, and that default is deliberate. Every curve maps 1
|
|
178
|
+
* to less than 1, so a 2D look built on clipped whites and saturated
|
|
179
|
+
* colour goes matte the moment one is applied, at any exposure. Turn it
|
|
180
|
+
* on when your art is authored in linear light and you want the
|
|
181
|
+
* highlights rolled off, not as a companion to `hdr`.
|
|
182
|
+
*
|
|
183
|
+
* Independent of `hdr`: a curve without headroom is a grade on an
|
|
184
|
+
* already-clamped frame, which is a legitimate thing to want, and
|
|
185
|
+
* headroom without a curve is the additive-accumulation win on its own.
|
|
186
|
+
* @default "none"
|
|
187
|
+
*/
|
|
188
|
+
/**
|
|
189
|
+
* Present the frame in the display's full dynamic range, instead of
|
|
190
|
+
* clamping it to SDR on the way to the screen.
|
|
191
|
+
*
|
|
192
|
+
* `hdr` gives the effect chain headroom and then clamps at the very last
|
|
193
|
+
* step, because the surface the browser presents is 8 bits per channel.
|
|
194
|
+
* This changes that surface: values above 1 reach the compositor and, on
|
|
195
|
+
* a display that has the range, are actually shown brighter.
|
|
196
|
+
*
|
|
197
|
+
* **Requires `hdr`, and changes how your game looks on an HDR display.**
|
|
198
|
+
* A 2D look built on clipped whites relies on that final clamp; remove it
|
|
199
|
+
* and everything you drove above 1 gets brighter rather than saturating.
|
|
200
|
+
* That is the point, and it is why this is a separate opt-in rather than
|
|
201
|
+
* part of `hdr`.
|
|
202
|
+
*
|
|
203
|
+
* **WebGPU only.** The WebGL2 equivalent is an unapproved specification
|
|
204
|
+
* change that no browser implements, so that backend reports `false` and
|
|
205
|
+
* presents in SDR as it always has. Query
|
|
206
|
+
* {@link Renderer#supportsHDROutput} for what was granted, and expect it
|
|
207
|
+
* to differ per backend on the same machine.
|
|
208
|
+
* @default false
|
|
209
|
+
*/
|
|
210
|
+
hdrOutput: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* the tone curve applied at the end of the camera's chain, or `"none"` for no curve. `"aces"` is the filmic one, `"reinhard"` the gentlest, `"exponential"` the simplest.
|
|
213
|
+
*
|
|
214
|
+
* **A curve is a look decision, not a companion to {@link ApplicationSettings.hdr}.** Every curve maps 1 to less than 1, so switching one on changes a game whose art was authored against a clamp: the clipped white goes matte and the picture flattens. Turn it on for art authored in linear light, or when a deliberate grade is wanted.
|
|
215
|
+
*
|
|
216
|
+
* Changing the mode rebuilds one shader, since the curve is baked into it; {@link ApplicationSettings.toneMappingExposure} and {@link ApplicationSettings.toneMappingWhite} are uniform writes and can be driven per frame, which is what makes a settings screen or a hit flash cheap. `renderer.setToneMapping()` is the runtime entry point.
|
|
217
|
+
* @default "none"
|
|
218
|
+
* @see ApplicationSettings.toneMappingExposure
|
|
219
|
+
* @see ApplicationSettings.toneMappingWhite
|
|
220
|
+
*/
|
|
221
|
+
toneMapping: "none" | "aces" | "reinhard" | "exponential";
|
|
222
|
+
/**
|
|
223
|
+
* Multiplier applied before the tone curve. Above `1` lifts the image
|
|
224
|
+
* into the curve's shoulder; below `1` pulls it down. Ignored while
|
|
225
|
+
* `toneMapping` is `"none"`.
|
|
226
|
+
* @default 1
|
|
227
|
+
*/
|
|
228
|
+
toneMappingExposure: number;
|
|
229
|
+
/**
|
|
230
|
+
* The post-exposure value the tone curve should map to display white, or
|
|
231
|
+
* `0` to leave the curve its own shoulder. This is what a "brightness" or
|
|
232
|
+
* "peak" slider in a settings screen drives. Ignored while `toneMapping`
|
|
233
|
+
* is `"none"`.
|
|
234
|
+
* @default 0
|
|
235
|
+
*/
|
|
236
|
+
toneMappingWhite: number;
|
|
103
237
|
/**
|
|
104
238
|
* Warm the renderer up during `loader.preload()`, behind the loading
|
|
105
239
|
* screen, instead of paying for it on the frame that first draws (GPU
|
|
@@ -311,8 +445,13 @@ export type ApplicationSettings = {
|
|
|
311
445
|
*/
|
|
312
446
|
highPrecisionShader: boolean;
|
|
313
447
|
/**
|
|
314
|
-
* whether to
|
|
448
|
+
* whether a renderable may sit on a fractional position WITHIN the frame. `false`, the default, snaps each translation to whole pixels, which is what stops a slowly moving or transformed sprite shimmering along its edges.
|
|
449
|
+
*
|
|
450
|
+
* The snap TRUNCATES rather than rounds, and truncates toward zero, so a value that should swing symmetrically about the origin does not: an offset travelling between -3 and +3 lands on -2 and +2, and sits at each extreme a little longer than it should. Something animating over a short distance is where this shows.
|
|
451
|
+
*
|
|
452
|
+
* It says nothing about how the frame reaches the screen. A game that snaps positions here and is then presented at a fractional scale has undone the work at the last step; {@link ApplicationSettings.scaleRounding} is what addresses that half.
|
|
315
453
|
* @default false
|
|
454
|
+
* @see ApplicationSettings.scaleRounding
|
|
316
455
|
*/
|
|
317
456
|
subPixel: boolean;
|
|
318
457
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/application/settings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,KAAK,SAAS,GACX,QAAQ,GACR,UAAU,GACV,SAAS,GACT,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,WAAW,GACX,MAAM,GACN,SAAS,GACT,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,YAAY,CAAC;AAEhB;;;;;;;;GAQG;AACH,KAAK,WAAW,GACb,SAAS,GACT,MAAM,GACN,cAAc,GACd;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC;AAE/B,KAAK,eAAe,GAAG,SAAS,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAEpE,MAAM,MA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OAAO,CAAC;IAElB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;;OAKG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,QAAQ,EAAE,GAAG,KAAK,YAAY,CAAC,GAAG,SAAS,CAAC;IAE/D;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,QAAQ,EAAE,GAAG,KAAK,YAAY,CAAC,GAAG,SAAS,CAAC;IAE5D;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CAAC,EAAE,KACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,KACR,QAAQ,CAAC;CACd,GAAG,CACD;IACA;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC;IAC7B,MAAM,CAAC,EAAE,KAAK,CAAC;CACd,GACD;IACA,MAAM,CAAC,EAAE,KAAK,CAAC;IACf;;;OAGG;IACH,MAAM,EAAE,iBAAiB,CAAC;CACzB,CACH,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,2BAA2B,GAAG,mBAAmB,GAAG;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACd,CAAC"}
|
package/build/audio/audio.d.ts
CHANGED
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
* `pause`, `resume`, `stop`, `fade`, `seek`, `rate`, `stereo`,
|
|
10
10
|
* `position`, `orientation`, `panner`).
|
|
11
11
|
* - {@link ./procedural.ts} — procedural primitives (`tone`, `noise`).
|
|
12
|
+
* - {@link ./spatial.ts} — the world-space layer: a movable listener,
|
|
13
|
+
* sounds that follow a renderable, and the pixel-shaped defaults.
|
|
14
|
+
* - {@link ./autopause.ts} — silencing the mix while the window is away.
|
|
12
15
|
* - {@link ./types.ts} — public TypeScript shapes.
|
|
13
16
|
*
|
|
14
17
|
* This file owns the remaining lifecycle / track / mix / unload
|
|
@@ -16,6 +19,7 @@
|
|
|
16
19
|
*/
|
|
17
20
|
export { duration, fade, load, orientation, panner, pause, play, playing, position, rate, resume, seek, state, stereo, stop, } from "./playback.ts";
|
|
18
21
|
export { noise, tone } from "./procedural.ts";
|
|
22
|
+
export { getSpatialDefaults, listener, listenerOrientation, setListener, setSpatialDefaults, unfollow, } from "./spatial.ts";
|
|
19
23
|
export { getAudioContext, getMasterGain, setStopOnAudioError, stopOnAudioError, } from "./state.ts";
|
|
20
24
|
export type { LoadSettings, NoiseFilter, NoiseOptions, PannerAttributes, SoundAsset, ToneOptions, } from "./types.ts";
|
|
21
25
|
/**
|
|
@@ -65,20 +69,40 @@ export declare function enable(): void;
|
|
|
65
69
|
*/
|
|
66
70
|
export declare function disable(): void;
|
|
67
71
|
/**
|
|
68
|
-
* Play the specified audio track
|
|
69
|
-
*
|
|
70
|
-
*
|
|
72
|
+
* Play the specified audio track, **replacing** whatever track was playing.
|
|
73
|
+
*
|
|
74
|
+
* The clip loops, and its name becomes the current track for
|
|
75
|
+
* {@link stopTrack} / {@link pauseTrack} / {@link resumeTrack} /
|
|
76
|
+
* {@link getCurrentTrack}. The previous track is stopped first, so only one
|
|
77
|
+
* track is ever playing: there is a single current-track slot, and a track
|
|
78
|
+
* left running after the slot had moved on could no longer be reached by any
|
|
79
|
+
* of those four.
|
|
80
|
+
*
|
|
81
|
+
* Calling it with the name already playing restarts that track from the
|
|
82
|
+
* beginning, the same as {@link play} on any other clip. Scene code that
|
|
83
|
+
* wants the bed to carry on across a screen change should not call this
|
|
84
|
+
* again, rather than rely on it doing nothing.
|
|
85
|
+
*
|
|
86
|
+
* Use {@link play} for sound effects: they are meant to overlap, and nothing
|
|
87
|
+
* here applies to them.
|
|
71
88
|
* @param sound_name - Audio track name (case-sensitive).
|
|
72
89
|
* @param volume - Playback volume, `0.0..1.0`. Defaults to the current
|
|
73
90
|
* global volume.
|
|
74
91
|
* @returns The sound instance ID.
|
|
92
|
+
* @throws {Error} when no clip of that name is loaded, raised before anything
|
|
93
|
+
* is stopped, so a mistyped name cannot silence the music already playing.
|
|
75
94
|
* @example
|
|
76
|
-
* me.audio.playTrack("
|
|
95
|
+
* me.audio.playTrack("menu_theme");
|
|
96
|
+
* me.audio.playTrack("battle_theme"); // the menu theme stops
|
|
77
97
|
* @category Audio
|
|
78
98
|
*/
|
|
79
99
|
export declare function playTrack(sound_name: string, volume?: number): number;
|
|
80
100
|
/**
|
|
81
|
-
* Stop the current audio track.
|
|
101
|
+
* Stop the current audio track, and leave no current track behind.
|
|
102
|
+
*
|
|
103
|
+
* Only needed where nothing else follows, since {@link playTrack} stops the
|
|
104
|
+
* track it replaces: a scene whose successor has no music of its own, or a
|
|
105
|
+
* game going quiet. A no-op when no track is playing.
|
|
82
106
|
* @see {@link playTrack}
|
|
83
107
|
* @example
|
|
84
108
|
* me.audio.playTrack("awesome_music");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audio.d.ts","sourceRoot":"","sources":["../../src/audio/audio.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"audio.d.ts","sourceRoot":"","sources":["../../src/audio/audio.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAeH,OAAO,EACN,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,MAAM,EACN,KAAK,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,MAAM,EACN,IAAI,GACJ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EACN,kBAAkB,EAClB,QAAQ,EACR,mBAAmB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;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED;;;GAGG;AACH,wBAAgB,OAAO,IAAI,IAAI,CAE9B;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAEhC;AAED;;;;GAIG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAE/B;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAsBlD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAOhC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Silence the game's sound effects while the window does not have focus.
|
|
3
|
+
*
|
|
4
|
+
* `Application` pauses the game on blur and resumes it on focus (its
|
|
5
|
+
* `pauseOnBlur` / `resumeOnFocus` settings, both on by default), and
|
|
6
|
+
* `state.pause()` already pauses the MUSIC TRACK. Nothing ever silenced the
|
|
7
|
+
* sound effects, so a looping one — an engine hum, an alarm, ambience — kept
|
|
8
|
+
* playing over whatever the player switched to.
|
|
9
|
+
*
|
|
10
|
+
* Driven from `Application#_onBlur` / `_onFocus` rather than from
|
|
11
|
+
* `STATE_PAUSE`, deliberately. A state pause is not always a focus loss:
|
|
12
|
+
* `state.freeze()` forwards its `music` flag into `state.pause()` for a
|
|
13
|
+
* hit-stop measured in tens of milliseconds, and muting there would punch a
|
|
14
|
+
* hole in the very impact sound the freeze exists to emphasise. A game's own
|
|
15
|
+
* pause menu is the same story, and would lose its UI clicks. Focus loss is
|
|
16
|
+
* the case where silence is unambiguously right.
|
|
17
|
+
*
|
|
18
|
+
* Driving it from the application also means the existing `stopOnBlur` /
|
|
19
|
+
* `pauseOnBlur` / `resumeOnFocus` settings gate it, instead of a fourth
|
|
20
|
+
* setting that says almost the same thing. A game that opted out of pausing
|
|
21
|
+
* in the background is a game that wants to keep running there, audio
|
|
22
|
+
* included.
|
|
23
|
+
*
|
|
24
|
+
* MUTED rather than stopped or paused:
|
|
25
|
+
*
|
|
26
|
+
* - stopping discards playback ids, and an id is the handle a game holds to
|
|
27
|
+
* reposition or fade a sound, so a loop could never be resumed in place;
|
|
28
|
+
* - per-voice pausing would have to be taught about every source in turn, and
|
|
29
|
+
* would miss the procedural `tone` / `noise` primitives and anything a game
|
|
30
|
+
* hangs off `getMasterGain()`;
|
|
31
|
+
* - muting zeroes the master gain, which everything routes through, and it
|
|
32
|
+
* lets a short one-shot finish silently instead of queueing up to fire the
|
|
33
|
+
* moment the player comes back.
|
|
34
|
+
*/
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=autopause.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autopause.d.ts","sourceRoot":"","sources":["../../src/audio/autopause.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { AudioContextOwner } from "../context.ts";
|
|
1
2
|
import type { Sound } from "./sound.ts";
|
|
2
|
-
import { type HTMLAudioElementWithUnlocked } from "./types.ts";
|
|
3
3
|
export declare class AudioEngine {
|
|
4
4
|
html5PoolSize: number;
|
|
5
5
|
sounds: Sound[];
|
|
@@ -10,6 +10,15 @@ export declare class AudioEngine {
|
|
|
10
10
|
ctx: AudioContext | null;
|
|
11
11
|
autoUnlock: boolean;
|
|
12
12
|
state: string;
|
|
13
|
+
/**
|
|
14
|
+
* The single owner of the context: see `../context.ts`.
|
|
15
|
+
*
|
|
16
|
+
* The engine no longer creates listeners for keeping the context alive,
|
|
17
|
+
* nor decides when a stop should be reverted. It answers the owner's two
|
|
18
|
+
* questions and does the reviving, which is the part only it can do
|
|
19
|
+
* because only it has the voices waiting on the result.
|
|
20
|
+
*/
|
|
21
|
+
readonly contextOwner: AudioContextOwner;
|
|
13
22
|
constructor();
|
|
14
23
|
volume(vol?: number): number | this;
|
|
15
24
|
mute(muted: boolean): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/audio/backend/engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EACN,KAAK,4BAA4B,EAGjC,MAAM,YAAY,CAAC;AAEpB,qBAAa,WAAW;IAWvB,aAAa,EAAE,MAAM,CAAM;IAM3B,MAAM,EAAE,KAAK,EAAE,CAAM;IAqBrB,UAAU,EAAE,QAAQ,GAAG,IAAI,CAAQ;IACnC,OAAO,EAAE,OAAO,CAAS;IACzB,aAAa,EAAE,OAAO,CAAQ;IAC9B,WAAW,EAAE,OAAO,CAAQ;IAC5B,GAAG,EAAE,YAAY,GAAG,IAAI,CAAQ;IAChC,UAAU,EAAE,OAAO,CAAQ;IAC3B,KAAK,EAAE,MAAM,CAAe;;
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/audio/backend/engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EACN,KAAK,4BAA4B,EAGjC,MAAM,YAAY,CAAC;AAEpB,qBAAa,WAAW;IAWvB,aAAa,EAAE,MAAM,CAAM;IAM3B,MAAM,EAAE,KAAK,EAAE,CAAM;IAqBrB,UAAU,EAAE,QAAQ,GAAG,IAAI,CAAQ;IACnC,OAAO,EAAE,OAAO,CAAS;IACzB,aAAa,EAAE,OAAO,CAAQ;IAC9B,WAAW,EAAE,OAAO,CAAQ;IAC5B,GAAG,EAAE,YAAY,GAAG,IAAI,CAAQ;IAChC,UAAU,EAAE,OAAO,CAAQ;IAC3B,KAAK,EAAE,MAAM,CAAe;IAM5B;;;;;;;OAOG;IACH,QAAQ,CAAC,YAAY,EAAE,i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