melonjs 20.1.1 → 20.3.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 +88 -10
- package/build/application/settings.d.ts +4 -2
- package/build/application/settings.d.ts.map +1 -1
- package/build/audio/audio.d.ts +2 -2
- package/build/audio/audio.d.ts.map +1 -1
- package/build/audio/backend/buffer.d.ts +26 -0
- package/build/audio/backend/buffer.d.ts.map +1 -0
- package/build/audio/backend/cache.d.ts +2 -0
- package/build/audio/backend/cache.d.ts.map +1 -0
- package/build/audio/backend/core.d.ts +24 -0
- package/build/audio/backend/core.d.ts.map +1 -0
- package/build/audio/backend/engine.d.ts +54 -0
- package/build/audio/backend/engine.d.ts.map +1 -0
- package/build/audio/backend/sound.d.ts +79 -0
- package/build/audio/backend/sound.d.ts.map +1 -0
- package/build/audio/backend/spatial.d.ts +191 -0
- package/build/audio/backend/spatial.d.ts.map +1 -0
- package/build/audio/backend/types.d.ts +97 -0
- package/build/audio/backend/types.d.ts.map +1 -0
- package/build/audio/backend/voice.d.ts +33 -0
- package/build/audio/backend/voice.d.ts.map +1 -0
- package/build/audio/playback.d.ts +49 -4
- package/build/audio/playback.d.ts.map +1 -1
- package/build/audio/{backend.d.ts → state.d.ts} +13 -11
- package/build/audio/state.d.ts.map +1 -0
- package/build/audio/types.d.ts +93 -1
- package/build/audio/types.d.ts.map +1 -1
- package/build/camera/camera3d.d.ts +5 -5
- package/build/const.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +10048 -10341
- package/build/index.js.map +4 -4
- package/build/input/input.d.ts +19 -0
- package/build/input/input.d.ts.map +1 -1
- package/build/input/pointerevent.d.ts.map +1 -1
- package/build/lang/deprecated.d.ts +4 -2
- package/build/lang/deprecated.d.ts.map +1 -1
- package/build/level/gltf/GLTFScene.d.ts +12 -0
- package/build/level/gltf/GLTFScene.d.ts.map +1 -1
- package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
- package/build/loader/loader.d.ts +4 -40
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/parsers/audio.d.ts +31 -0
- package/build/loader/parsers/audio.d.ts.map +1 -0
- package/build/loader/parsers/shader.d.ts.map +1 -1
- package/build/particles/emitter.d.ts +81 -3
- package/build/particles/emitter.d.ts.map +1 -1
- package/build/particles/particle.d.ts +62 -1
- package/build/particles/particle.d.ts.map +1 -1
- package/build/particles/settings.d.ts +50 -7
- package/build/particles/settings.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +3 -3
- package/build/physics/builtin/body.d.ts +23 -24
- package/build/physics/builtin/body.d.ts.map +1 -1
- package/build/physics/builtin/detector.d.ts +1 -1
- package/build/plugin/plugin.d.ts +9 -1
- package/build/plugin/plugin.d.ts.map +1 -1
- package/build/polyfill/index.d.ts +1 -4
- package/build/polyfill/index.d.ts.map +1 -1
- package/build/renderable/container.d.ts +10 -0
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/entity/entity.d.ts +10 -0
- package/build/renderable/entity/entity.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +16 -0
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +122 -32
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +7 -7
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/state/stage.d.ts +4 -2
- package/build/state/stage.d.ts.map +1 -1
- package/build/system/event.d.ts +1 -1
- package/build/system/platform.d.ts +21 -1
- package/build/system/platform.d.ts.map +1 -1
- package/build/utils/fetchdata.d.ts.map +1 -0
- package/build/video/blendmodes.d.ts +107 -0
- package/build/video/blendmodes.d.ts.map +1 -0
- package/build/video/canvas/canvas_renderer.d.ts +31 -24
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/effects/blendEffect.d.ts +57 -0
- package/build/video/effects/blendEffect.d.ts.map +1 -0
- package/build/video/effects/blur.d.ts +4 -4
- package/build/video/effects/blur.d.ts.map +1 -1
- package/build/video/effects/chromaticAberration.d.ts +5 -5
- package/build/video/effects/chromaticAberration.d.ts.map +1 -1
- package/build/video/effects/colorMatrix.d.ts +5 -5
- package/build/video/effects/colorMatrix.d.ts.map +1 -1
- package/build/video/effects/desaturate.d.ts +5 -5
- package/build/video/effects/desaturate.d.ts.map +1 -1
- package/build/video/effects/dissolve.d.ts +4 -4
- package/build/video/effects/dissolve.d.ts.map +1 -1
- package/build/video/effects/dropShadow.d.ts +5 -5
- package/build/video/effects/dropShadow.d.ts.map +1 -1
- package/build/video/effects/flash.d.ts +4 -4
- package/build/video/effects/flash.d.ts.map +1 -1
- package/build/video/effects/glow.d.ts +5 -5
- package/build/video/effects/glow.d.ts.map +1 -1
- package/build/video/effects/hologram.d.ts +4 -4
- package/build/video/effects/hologram.d.ts.map +1 -1
- package/build/video/effects/invert.d.ts +5 -5
- package/build/video/effects/invert.d.ts.map +1 -1
- package/build/video/effects/outline.d.ts +6 -6
- package/build/video/effects/outline.d.ts.map +1 -1
- package/build/video/effects/pixelate.d.ts +4 -4
- package/build/video/effects/pixelate.d.ts.map +1 -1
- package/build/video/effects/radialGradient.d.ts +2 -2
- package/build/video/effects/scanline.d.ts +6 -6
- package/build/video/effects/scanline.d.ts.map +1 -1
- package/build/video/effects/sepia.d.ts +5 -5
- package/build/video/effects/sepia.d.ts.map +1 -1
- package/build/video/effects/shadereffect.d.ts +12 -10
- package/build/video/effects/shadereffect.d.ts.map +1 -1
- package/build/video/effects/shine.d.ts +3 -3
- package/build/video/effects/shine.d.ts.map +1 -1
- package/build/video/effects/tintPulse.d.ts +4 -4
- package/build/video/effects/tintPulse.d.ts.map +1 -1
- package/build/video/effects/vignette.d.ts +6 -6
- package/build/video/effects/vignette.d.ts.map +1 -1
- package/build/video/effects/wave.d.ts +4 -4
- package/build/video/effects/wave.d.ts.map +1 -1
- package/build/video/renderer.d.ts +3 -4
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts +1 -0
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/texture/atlas.d.ts +1 -1
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/glshader.d.ts +2 -2
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/utils/program.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts +117 -29
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/quad_batcher.d.ts +7 -0
- package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgpu/pipeline/cache.d.ts +0 -9
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
- package/build/video/webgpu/webgpu_renderer.d.ts +101 -6
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +6 -10
- package/skills/AGENTS.md +67 -0
- package/skills/melonjs/SKILL.md +156 -0
- package/skills/melonjs-20-migration/SKILL.md +160 -0
- package/skills/melonjs-3d/SKILL.md +226 -0
- package/skills/melonjs-3d-assets/SKILL.md +239 -0
- package/skills/melonjs-audio/SKILL.md +215 -0
- package/skills/melonjs-camera-and-drawing/SKILL.md +171 -0
- package/skills/melonjs-deployment/SKILL.md +113 -0
- package/skills/melonjs-effects-and-shaders/SKILL.md +177 -0
- package/skills/melonjs-events/SKILL.md +159 -0
- package/skills/melonjs-getting-started/SKILL.md +183 -0
- package/skills/melonjs-input/SKILL.md +166 -0
- package/skills/melonjs-lighting/SKILL.md +139 -0
- package/skills/melonjs-loading-assets/SKILL.md +157 -0
- package/skills/melonjs-particles-and-trails/SKILL.md +136 -0
- package/skills/melonjs-performance/SKILL.md +178 -0
- package/skills/melonjs-physics/SKILL.md +321 -0
- package/skills/melonjs-plugins/SKILL.md +191 -0
- package/skills/melonjs-renderables/SKILL.md +214 -0
- package/skills/melonjs-renderer-backends/SKILL.md +173 -0
- package/skills/melonjs-scenes-and-state/SKILL.md +180 -0
- package/skills/melonjs-sprites-and-animation/SKILL.md +173 -0
- package/skills/melonjs-tilemaps/SKILL.md +193 -0
- package/skills/melonjs-ui-and-text/SKILL.md +175 -0
- package/build/audio/backend.d.ts.map +0 -1
- package/build/loader/parsers/fetchdata.d.ts.map +0 -1
- /package/build/{loader/parsers → utils}/fetchdata.d.ts +0 -0
package/build/input/input.d.ts
CHANGED
|
@@ -3,9 +3,28 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* specify if melonJS should prevent all default browser action on registered events.
|
|
6
|
+
*
|
|
7
|
+
* Read-only: this is a module binding, so `input.preventDefault = false` cannot
|
|
8
|
+
* work — assigning to a module namespace property throws. Use
|
|
9
|
+
* {@link input.setPreventDefault} instead.
|
|
6
10
|
* @default true
|
|
11
|
+
* @see input.setPreventDefault
|
|
7
12
|
*/
|
|
8
13
|
export declare let preventDefault: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* set whether melonJS should prevent the default browser action on registered
|
|
16
|
+
* events. This is the global default; {@link input.bindKey}'s `preventDefault`
|
|
17
|
+
* argument overrides it per binding.
|
|
18
|
+
*
|
|
19
|
+
* Pointer listeners read it when they are registered, so call this before
|
|
20
|
+
* creating the {@link Application} for it to apply to the engine's own
|
|
21
|
+
* listeners.
|
|
22
|
+
* @param value - true to prevent default browser actions (the default)
|
|
23
|
+
* @example
|
|
24
|
+
* // let the browser handle scrolling, zooming and context menus itself
|
|
25
|
+
* me.input.setPreventDefault(false);
|
|
26
|
+
*/
|
|
27
|
+
export declare function setPreventDefault(value: boolean): void;
|
|
9
28
|
export * from "./gamepad.ts";
|
|
10
29
|
export * from "./key.ts";
|
|
11
30
|
export * from "./keyboard.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/input/input.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/input/input.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;GAQG;AACH,eAAO,IAAI,cAAc,EAAE,OAAc,CAAC;AAE1C;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,QAE/C;AAED,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointerevent.d.ts","sourceRoot":"","sources":["../../src/input/pointerevent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAepD,OAAO,OAAO,MAAM,cAAc,CAAC;AAoBnC;;;GAGG;AACH,eAAO,IAAI,IAAI,EAAE,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"pointerevent.d.ts","sourceRoot":"","sources":["../../src/input/pointerevent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAepD,OAAO,OAAO,MAAM,cAAc,CAAC;AAoBnC;;;GAGG;AACH,eAAO,IAAI,IAAI,EAAE,WAAW,CAAC;AAqiB7B;;GAEG;AACH,eAAO,IAAI,kBAAkB,EAAE,WAAW,GAAG,IAAW,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,OAAiC,CAAC;AAExD;;GAEG;AACH,eAAO,IAAI,MAAM,EAAE,OAAe,CAAC;AAEnC;;;;GAIG;AACH,eAAO,IAAI,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;AAElD;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAY1E;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC7B,OAAO,EAAE,iBAAiB,EAC1B,KAAK,CAAC,EAAE,MAAM,GACZ,IAAI,CAEN;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAanD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAGnD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,oBAAoB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,GAAG,EACX,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAG,IAAI,GAC5C,IAAI,CAsCN;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,GAAG,EACX,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAG,IAAI,GAC7C,IAAI,CAiCN;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAMzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAO5C;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAMzC"}
|
|
@@ -25,13 +25,15 @@ export class CanvasTexture extends CanvasRenderTarget {
|
|
|
25
25
|
* @param {number} width - the desired width of the canvas
|
|
26
26
|
* @param {number} height - the desired height of the canvas
|
|
27
27
|
* @param {object} attributes - The attributes to create both the canvas and context
|
|
28
|
-
* @param {
|
|
28
|
+
* @param {string} [attributes.context="2d"] - the context type to be created ("2d", "webgl" — creates a WebGL 2 context, or "webgpu")
|
|
29
|
+
* @param {boolean} [attributes.transparent=false] - whether to enable transparency on the canvas
|
|
29
30
|
* @param {boolean} [attributes.offscreenCanvas=false] - will create an offscreenCanvas if true instead of a standard canvas
|
|
30
31
|
* @param {boolean} [attributes.willReadFrequently=false] - Indicates whether or not a lot of read-back operations are planned
|
|
31
32
|
* @param {boolean} [attributes.antiAlias=false] - Whether to enable anti-aliasing, use false (default) for a pixelated effect.
|
|
32
33
|
*/
|
|
33
34
|
constructor(width: number, height: number, attributes: {
|
|
34
|
-
context?:
|
|
35
|
+
context?: string | undefined;
|
|
36
|
+
transparent?: boolean | undefined;
|
|
35
37
|
offscreenCanvas?: boolean | undefined;
|
|
36
38
|
willReadFrequently?: boolean | undefined;
|
|
37
39
|
antiAlias?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecated.d.ts","sourceRoot":"","sources":["../../src/lang/deprecated.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deprecated.d.ts","sourceRoot":"","sources":["../../src/lang/deprecated.js"],"names":[],"mappings":"AA0JA;;;;;;;;GAQG;AACH,4CAHW,OAAO,QAsBjB;AAED;;;;;;GAMG;AACH,uCAeC;AAhMD;;;GAGG;AACH;IACC;;;;;;;;;OASG;IACH,mBATW,MAAM,UACN,MAAM,cAEd;QAA4B,OAAO;QACN,WAAW;QACX,eAAe;QACf,kBAAkB;QAClB,SAAS;KACxC,EAIA;CACD;AA8BD;;;GAGG;AACH;IACC,0BAA0B;IAC1B,qBADY,GAAG,EAAE,EAIhB;CACD;AAED;;;GAGG;AACH;IACC,0BAA0B;IAC1B,qBADY,GAAG,EAAE,EAIhB;CACD;AAED;;;GAGG;AACH;IACC,0BAA0B;IAC1B,qBADY,GAAG,EAAE,EAIhB;CACD;;+BA9F8B,6CAA6C;6BAC/C,oCAAoC;6BACpC,8CAA8C;wBACnD,yCAAyC"}
|
|
@@ -87,12 +87,24 @@ export default class GLTFScene {
|
|
|
87
87
|
* at unit intensity and lets the app tune. With this option the
|
|
88
88
|
* authored ratios survive: e.g. `0.001` maps a 1000-lux sun to 1 while
|
|
89
89
|
* a half-strength 500-lux fill lands at 0.5.
|
|
90
|
+
* @param {boolean} [options.castGroundShadow] - give this scene's meshes a
|
|
91
|
+
* ground shadow ({@link Mesh#castGroundShadow}), overriding the
|
|
92
|
+
* application's setting for this scene in both directions; omit it to
|
|
93
|
+
* inherit. As a scene-wide opt-in it skips nodes with no vertical extent —
|
|
94
|
+
* a scene's ground plane is exactly that, and shadowing it with itself
|
|
95
|
+
* smears a blob across the whole floor.
|
|
96
|
+
* @param {number} [options.shadowGroundY] - world Y of the floor those
|
|
97
|
+
* shadows land on ({@link Mesh#shadowGroundY}); omit it and each blob sits
|
|
98
|
+
* at its own object's base at full strength, which is right for a scene
|
|
99
|
+
* whose props already rest on the ground.
|
|
90
100
|
*/
|
|
91
101
|
addTo(container: Container, options?: {
|
|
92
102
|
scale?: number | undefined;
|
|
93
103
|
rightHanded?: boolean | undefined;
|
|
94
104
|
lights?: boolean | undefined;
|
|
95
105
|
lightIntensityScale?: number | undefined;
|
|
106
|
+
castGroundShadow?: boolean | undefined;
|
|
107
|
+
shadowGroundY?: number | undefined;
|
|
96
108
|
}): void;
|
|
97
109
|
/**
|
|
98
110
|
* Add the scene's authored lights — directional, point and spot — (plus a soft ambient fill) to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLTFScene.d.ts","sourceRoot":"","sources":["../../../src/level/gltf/GLTFScene.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GLTFScene.d.ts","sourceRoot":"","sources":["../../../src/level/gltf/GLTFScene.js"],"names":[],"mappings":"AAuWA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,oCAJW,aAAa,aACb,MAAM,QAwChB;AAvZD;;;;;;;;;;GAUG;AACH;IACC;;OAEG;IACH,qBAFW,MAAM,EAkBhB;IAfA;;;OAGG;IACH,MAFU,MAAM,CAEG;IACnB;;;OAGG;IACH,QAFU,MAAM,CAEI;IACpB;;;OAGG;IACH,MAFU,MAAM,CAEY;IAG7B;;;;OAIG;IACH,cAFa,MAAM,GAAC,SAAS,CAI5B;IAED;;;;OAIG;IACH,qBAEC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,iBAhCW,SAAS,YAEjB;QAAyB,KAAK;QACJ,WAAW;QAEX,MAAM;QAQP,mBAAmB;QAQlB,gBAAgB;QAMjB,aAAa;KAIxC,QA4KA;IAED;;;;;;;;;;;;OAYG;IACH,sBANW,SAAS,SACT,MAAM,SACN,MAAM,WACN,MAAM,QAqEhB;IAED;;;;;OAKG;IACH,gBAAY;CACZ;0BAjWyB,oCAAoC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TMXObjectFactory.d.ts","sourceRoot":"","sources":["../../../src/level/tiled/TMXObjectFactory.js"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AACH,0CAJW,MAAM,GACJ,OAAO,GAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"TMXObjectFactory.d.ts","sourceRoot":"","sources":["../../../src/level/tiled/TMXObjectFactory.js"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AACH,0CAJW,MAAM,GACJ,OAAO,GAAC,MAAM,EAAE,CAgB5B;AAED;;;;;;;;;;;;GAYG;AACH,2CAJW,MAAM,GACJ,MAAM,CAsBlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,iDApBW,MAAM,2BAgChB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,+CAZW,MAAM,+BA6BhB;AAQD;;;;;;;GAOG;AACH,gDAJW,MAAM,+BAWhB;AAoCD;;;;;;;GAOG;AACH,0CALW,MAAM,OACN,UAAU,GACR,UAAU,CAqBtB"}
|
package/build/loader/loader.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export function setBaseURL(type: string, url?: string): void;
|
|
|
47
47
|
* @typedef {object} Asset
|
|
48
48
|
* @memberof loader
|
|
49
49
|
* @property {string} name - name of the asset
|
|
50
|
-
* @property {string} type - the type of the asset ("audio"|"binary"|"image"|"json"|"js"|"tmx"|"
|
|
50
|
+
* @property {string} type - the type of the asset ("audio"|"binary"|"image"|"json"|"js"|"tmx"|"tsx"|"fontface"|"video"|"aseprite"|"shader"|"obj"|"mtl"|"gltf"|"glb"). JSON-serialised Tiled maps and tilesets (`.tmj` / `.tsj`) load under `"tmx"` / `"tsx"` — those are file extensions, not asset types.
|
|
51
51
|
* @property {string|string[]} [src] - path and/or file name of the resource (for audio assets only the path is required).
|
|
52
52
|
* For image assets, an array of sources can be provided as a fallback chain (e.g. compressed texture formats by priority, with a PNG fallback).
|
|
53
53
|
* The loader will try each source in order and use the first one that loads successfully.
|
|
@@ -410,11 +410,11 @@ export function getGLTF(elt: string): GLTFData | null;
|
|
|
410
410
|
* } },
|
|
411
411
|
* ], () => {
|
|
412
412
|
* // one shared program — same uniform state for every user
|
|
413
|
-
* mySprite.
|
|
413
|
+
* mySprite.addPostEffect(me.loader.getShader("waterRipple"));
|
|
414
414
|
* // private copy with its own uniforms (caller-owned, shared = false)
|
|
415
|
-
* boss.
|
|
415
|
+
* boss.addPostEffect(me.loader.getShader("flash").clone());
|
|
416
416
|
* // a complete program hosts on a mesh, replacing the built-in shading
|
|
417
|
-
* myMesh.
|
|
417
|
+
* myMesh.addPostEffect(me.loader.getShader("toonMesh"));
|
|
418
418
|
* });
|
|
419
419
|
*/
|
|
420
420
|
export function getShader(elt: string): ShaderEffect | GLShader | null;
|
|
@@ -513,42 +513,6 @@ export let crossOrigin: string;
|
|
|
513
513
|
* me.loader.preload(game.resources, () => this.loaded());
|
|
514
514
|
*/
|
|
515
515
|
export let withCredentials: boolean;
|
|
516
|
-
/**
|
|
517
|
-
* onload callback
|
|
518
|
-
* @default undefined
|
|
519
|
-
* @memberof loader
|
|
520
|
-
* @type {function}
|
|
521
|
-
* @deprecated since 18.2.0 - Use the {@link event.LOADER_COMPLETE} event or the `onloadcb` parameter of {@link loader.preload} instead.
|
|
522
|
-
* @example
|
|
523
|
-
* // use the LOADER_COMPLETE event instead
|
|
524
|
-
* me.event.on(me.event.LOADER_COMPLETE, this.loaded.bind(this));
|
|
525
|
-
*/
|
|
526
|
-
export let onload: Function;
|
|
527
|
-
/**
|
|
528
|
-
* onProgress callback<br>
|
|
529
|
-
* each time a resource is loaded, the loader will fire the specified function,
|
|
530
|
-
* giving the actual progress [0 ... 1], as argument, and an object describing the resource loaded
|
|
531
|
-
* @default undefined
|
|
532
|
-
* @memberof loader
|
|
533
|
-
* @type {function}
|
|
534
|
-
* @deprecated since 18.2.0 - Use the {@link event.LOADER_PROGRESS} event instead.
|
|
535
|
-
* @example
|
|
536
|
-
* // use the LOADER_PROGRESS event instead
|
|
537
|
-
* me.event.on(me.event.LOADER_PROGRESS, (progress, resource) => this.updateProgress(progress, resource));
|
|
538
|
-
*/
|
|
539
|
-
export let onProgress: Function;
|
|
540
|
-
/**
|
|
541
|
-
* onError callback<br>
|
|
542
|
-
* each time a resource loading is failed, the loader will fire the specified function giving the actual asset as argument.
|
|
543
|
-
* @default undefined
|
|
544
|
-
* @memberof loader
|
|
545
|
-
* @type {function}
|
|
546
|
-
* @deprecated since 18.2.0 - Use the {@link event.LOADER_ERROR} event instead.
|
|
547
|
-
* @example
|
|
548
|
-
* // use the LOADER_ERROR event instead
|
|
549
|
-
* me.event.on(me.event.LOADER_ERROR, (resource) => this.loaderError(resource));
|
|
550
|
-
*/
|
|
551
|
-
export let onError: Function;
|
|
552
516
|
/**
|
|
553
517
|
* an asset definition to be used with the loader
|
|
554
518
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/loader/loader.js"],"names":[],"mappings":"AAuFA;;;GAGG;AACH,mDAEC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,oCAdG;IAAyB,WAAW;IACV,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/preload an Audio file
|
|
3
|
+
*
|
|
4
|
+
* Unlike the other parsers this one delegates rather than doing the work
|
|
5
|
+
* itself: audio assets are owned by the audio module, which decodes them
|
|
6
|
+
* through its own backend and tracks them for playback. Keeping that
|
|
7
|
+
* delegation here means every asset type is registered the same way — from a
|
|
8
|
+
* parser of the same shape in this directory — and the loader never reaches
|
|
9
|
+
* into the audio module directly, so replacing the audio backend cannot ripple
|
|
10
|
+
* into the loader.
|
|
11
|
+
* @param {loader.Asset} data - asset data
|
|
12
|
+
* @param {Function} [onload] - function to be called when the resource is loaded
|
|
13
|
+
* @param {Function} [onerror] - function to be called in case of error
|
|
14
|
+
* @param {Object} [settings] - Additional settings to be passed when loading the asset
|
|
15
|
+
* @returns {number} the amount of corresponding resource parsed/preloaded
|
|
16
|
+
* @ignore
|
|
17
|
+
*/
|
|
18
|
+
export function preloadAudio(data: loader.Asset, onload?: Function, onerror?: Function, settings?: Object): number;
|
|
19
|
+
/**
|
|
20
|
+
* unload the given audio asset
|
|
21
|
+
* @param {string} name - asset name
|
|
22
|
+
* @returns {boolean} true if unloaded
|
|
23
|
+
* @ignore
|
|
24
|
+
*/
|
|
25
|
+
export function unloadAudio(name: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* unload all audio assets
|
|
28
|
+
* @ignore
|
|
29
|
+
*/
|
|
30
|
+
export function unloadAllAudio(): void;
|
|
31
|
+
//# sourceMappingURL=audio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio.d.ts","sourceRoot":"","sources":["../../../src/loader/parsers/audio.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,mCAPW,MAAM,CAAC,KAAK,oDAGZ,MAAM,GACJ,MAAM,CAKlB;AAED;;;;;GAKG;AACH,kCAJW,MAAM,GACJ,OAAO,CAKnB;AAED;;;GAGG;AACH,uCAEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader.d.ts","sourceRoot":"","sources":["../../../src/loader/parsers/shader.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;GAeG;AACH,2CANW,MAAM,GAAC,MAAM,GAEX,YAAY,GAAC,QAAQ,CAqDjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,oCAPW,MAAM,CAAC,KAAK,oDAGZ,MAAM,GACJ,MAAM,CAgHlB;
|
|
1
|
+
{"version":3,"file":"shader.d.ts","sourceRoot":"","sources":["../../../src/loader/parsers/shader.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;GAeG;AACH,2CANW,MAAM,GAAC,MAAM,GAEX,YAAY,GAAC,QAAQ,CAqDjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,oCAPW,MAAM,CAAC,KAAK,oDAGZ,MAAM,GACJ,MAAM,CAgHlB;yBA7OwB,qCAAqC;qBACzC,+BAA+B"}
|
|
@@ -1,11 +1,56 @@
|
|
|
1
|
+
import { Matrix3d } from "../math/matrix3d.ts";
|
|
1
2
|
import Container from "./../renderable/container.js";
|
|
3
|
+
import type CanvasRenderer from "../video/canvas/canvas_renderer.js";
|
|
2
4
|
import CanvasRenderTarget from "../video/rendertarget/canvasrendertarget.js";
|
|
5
|
+
import type WebGLRenderer from "../video/webgl/webgl_renderer.js";
|
|
3
6
|
import { type ParticleEmitterSettings } from "./settings.ts";
|
|
4
7
|
/**
|
|
5
8
|
* Particle Emitter Object.
|
|
9
|
+
*
|
|
10
|
+
* ### Blend modes
|
|
11
|
+
*
|
|
12
|
+
* An emitter draws no pixels of its own: every {@link Particle} is a
|
|
13
|
+
* renderable in its own right and carries its own blend mode. Assigning
|
|
14
|
+
* `emitter.blendMode` applies the mode to the particles — both the ones
|
|
15
|
+
* already alive and, through {@link ParticleEmitterSettings.blendMode}, the
|
|
16
|
+
* ones emitted afterwards. The change is picked up on the emitter's next
|
|
17
|
+
* `update`, so within the same frame.
|
|
18
|
+
*
|
|
19
|
+
* ```js
|
|
20
|
+
* emitter.blendMode = "overlay"; // live particles AND future ones
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* ### Reference space
|
|
24
|
+
*
|
|
25
|
+
* A particle stores a position, and
|
|
26
|
+
* {@link ParticleEmitterSettings.referenceSpace} decides what that position is
|
|
27
|
+
* measured against. By default it is the emitter, so a moving emitter carries
|
|
28
|
+
* its whole cloud along — right for a flame or an aura, wrong for anything
|
|
29
|
+
* emitted and then abandoned. Set it to `"world"` and the position names a
|
|
30
|
+
* place in the level instead, so the emitter moves away and leaves the
|
|
31
|
+
* particles behind; that is a trail. Pass a {@link Container} to measure from
|
|
32
|
+
* something else entirely.
|
|
33
|
+
*
|
|
34
|
+
* Changing it at runtime — by assigning the property or through
|
|
35
|
+
* {@link ParticleEmitter#reset} — re-bases the particles already alive, so the
|
|
36
|
+
* cloud does not jump; only its subsequent motion changes.
|
|
37
|
+
*
|
|
38
|
+
* Two things are worth knowing before reaching for a non-local space. The
|
|
39
|
+
* emitter is treated as always visible while it has live particles, because
|
|
40
|
+
* otherwise a trail would vanish the moment the emitter that made it scrolled
|
|
41
|
+
* off-screen (the particles themselves are still culled individually). And
|
|
42
|
+
* `clipping` or a `backgroundColor` on the emitter would be applied in the
|
|
43
|
+
* emitter's own frame rather than the particles', so neither composes with
|
|
44
|
+
* this.
|
|
45
|
+
*
|
|
46
|
+
* ```js
|
|
47
|
+
* // exhaust that stays where it was emitted
|
|
48
|
+
* const emitter = new ParticleEmitter(x, y, { referenceSpace: "world" });
|
|
49
|
+
* ```
|
|
6
50
|
* @category Particles
|
|
7
51
|
*/
|
|
8
52
|
export default class ParticleEmitter extends Container {
|
|
53
|
+
#private;
|
|
9
54
|
/**
|
|
10
55
|
* the current (active) emitter settings (with defaults merged in)
|
|
11
56
|
*/
|
|
@@ -37,6 +82,19 @@ export default class ParticleEmitter extends Container {
|
|
|
37
82
|
* @ignore
|
|
38
83
|
*/
|
|
39
84
|
_deltaInv: number;
|
|
85
|
+
/**
|
|
86
|
+
* Maps an emitter-local spawn point into the reference frame the particles
|
|
87
|
+
* live in, so a particle is BORN where the emitter is even though its
|
|
88
|
+
* position is thereafter measured from somewhere else. `undefined` in
|
|
89
|
+
* local mode, where the two frames coincide and no mapping is needed.
|
|
90
|
+
*
|
|
91
|
+
* Held per emitter (not a module scratch) because particles read it during
|
|
92
|
+
* their own reset, after `addParticles` has computed it. One matrix per
|
|
93
|
+
* emitter that actually uses a non-local space — emitters are few, unlike
|
|
94
|
+
* particles, which allocate nothing.
|
|
95
|
+
* @ignore
|
|
96
|
+
*/
|
|
97
|
+
_spawnMap: Matrix3d | undefined;
|
|
40
98
|
/**
|
|
41
99
|
* @param x - x position of the particle emitter
|
|
42
100
|
* @param y - y position of the particle emitter
|
|
@@ -68,11 +126,21 @@ export default class ParticleEmitter extends Container {
|
|
|
68
126
|
* app.world.removeChild(emitter);
|
|
69
127
|
*/
|
|
70
128
|
constructor(x: number, y: number, settings?: Partial<ParticleEmitterSettings>);
|
|
129
|
+
reset(settings?: Partial<ParticleEmitterSettings>): void;
|
|
71
130
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
131
|
+
* What a particle's position is measured against — see
|
|
132
|
+
* {@link ParticleEmitterSettings.referenceSpace}.
|
|
133
|
+
*
|
|
134
|
+
* Assigning this re-bases every particle already alive into the new frame,
|
|
135
|
+
* so nothing jumps: the cloud stays exactly where it is on screen and only
|
|
136
|
+
* its subsequent motion differs. Passing it through
|
|
137
|
+
* {@link ParticleEmitter#reset} does the same.
|
|
138
|
+
* @default "local"
|
|
139
|
+
* @example
|
|
140
|
+
* emitter.referenceSpace = "world"; // start leaving a trail
|
|
74
141
|
*/
|
|
75
|
-
|
|
142
|
+
get referenceSpace(): "local" | "world" | Container;
|
|
143
|
+
set referenceSpace(space: "local" | "world" | Container);
|
|
76
144
|
/**
|
|
77
145
|
* returns a random point on the x axis within the bounds of this emitter
|
|
78
146
|
* @returns a random x position within the emitter bounds
|
|
@@ -83,6 +151,16 @@ export default class ParticleEmitter extends Container {
|
|
|
83
151
|
* @returns a random y position within the emitter bounds
|
|
84
152
|
*/
|
|
85
153
|
getRandomPointY(): number;
|
|
154
|
+
/**
|
|
155
|
+
* Draw the particles in their reference frame rather than the emitter's.
|
|
156
|
+
*
|
|
157
|
+
* The correction goes in before `super.draw()` because that is where the
|
|
158
|
+
* child walk happens; translations and the correction compose, and in
|
|
159
|
+
* local mode there is no correction and this is the inherited path
|
|
160
|
+
* untouched.
|
|
161
|
+
* @ignore
|
|
162
|
+
*/
|
|
163
|
+
draw(renderer: CanvasRenderer | WebGLRenderer, viewport?: Parameters<Container["draw"]>[1]): void;
|
|
86
164
|
/** @ignore */
|
|
87
165
|
addParticles(count: number): void;
|
|
88
166
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/particles/emitter.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,8BAA8B,CAAC;AAErD,OAAO,kBAAkB,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/particles/emitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,SAAS,MAAM,8BAA8B,CAAC;AAErD,OAAO,KAAK,cAAc,MAAM,oCAAoC,CAAC;AACrE,OAAO,kBAAkB,MAAM,6CAA6C,CAAC;AAC7E,OAAO,KAAK,aAAa,MAAM,kCAAkC,CAAC;AAElE,OAA+B,EAC9B,KAAK,uBAAuB,EAC5B,MAAM,eAAe,CAAC;AAmDvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,SAAS;;IACrD;;OAEG;IACH,QAAQ,EAAE,uBAAuB,CAAC;IAElC,cAAc;IACd,OAAO,EAAE,OAAO,CAAC;IA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I,IAAI;IAIlB;;;OAGG;IACH,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IASpC;;OAEG;IACM,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAiHpC;;;OAGG;IACM,OAAO,IAAI,IAAI;CAmBxB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Matrix3d } from "../math/matrix3d.ts";
|
|
1
2
|
import { Vector2d } from "../math/vector2d.ts";
|
|
2
3
|
import Renderable from "../renderable/renderable.js";
|
|
3
4
|
import CanvasRenderer from "../video/canvas/canvas_renderer.js";
|
|
@@ -8,6 +9,7 @@ import ParticleEmitter from "./emitter.ts";
|
|
|
8
9
|
* @category Particles
|
|
9
10
|
*/
|
|
10
11
|
export default class Particle extends Renderable {
|
|
12
|
+
#private;
|
|
11
13
|
vel: Vector2d;
|
|
12
14
|
image: HTMLCanvasElement | HTMLImageElement;
|
|
13
15
|
life: number;
|
|
@@ -18,7 +20,6 @@ export default class Particle extends Renderable {
|
|
|
18
20
|
wind: number;
|
|
19
21
|
followTrajectory: boolean;
|
|
20
22
|
onlyInViewport: boolean;
|
|
21
|
-
accurateBounds: boolean;
|
|
22
23
|
_deltaInv: number;
|
|
23
24
|
_halfW: number;
|
|
24
25
|
_halfH: number;
|
|
@@ -28,6 +29,26 @@ export default class Particle extends Renderable {
|
|
|
28
29
|
* @param emitter - the particle emitter
|
|
29
30
|
*/
|
|
30
31
|
constructor(emitter: ParticleEmitter);
|
|
32
|
+
/**
|
|
33
|
+
* Whether the bounds need recomputing before anyone reads them.
|
|
34
|
+
*
|
|
35
|
+
* A `Renderable` refreshes its bounds eagerly, from a callback fired on
|
|
36
|
+
* every `pos` assignment. That is the right trade for a scene object, and
|
|
37
|
+
* the wrong one for a particle: `update()` writes `pos.x` and `pos.y`
|
|
38
|
+
* separately, so the callback fires TWICE per particle per frame, and both
|
|
39
|
+
* runs happen before `currentTransform` is rebuilt — deriving bounds from
|
|
40
|
+
* the previous frame's matrix and then throwing that away. Measured, the
|
|
41
|
+
* redundant pass was about two thirds of the whole particle update loop.
|
|
42
|
+
*
|
|
43
|
+
* So a particle invalidates instead of recomputing, and pays once, on
|
|
44
|
+
* read, for particles something actually looks at.
|
|
45
|
+
*
|
|
46
|
+
* Deliberately not a `#private` field: `updateBounds()` is reached from the
|
|
47
|
+
* base constructor chain (`Polygon.setVertices`) before a subclass's field
|
|
48
|
+
* initializers have run, and writing an undeclared private field throws.
|
|
49
|
+
* @ignore
|
|
50
|
+
*/
|
|
51
|
+
_boundsDirty: boolean;
|
|
31
52
|
/**
|
|
32
53
|
* @ignore
|
|
33
54
|
*/
|
|
@@ -39,6 +60,46 @@ export default class Particle extends Renderable {
|
|
|
39
60
|
* @param dt - time since the last update in milliseconds
|
|
40
61
|
*/
|
|
41
62
|
update(dt: number): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* `autoTransform` is off (see `onResetEvent`), so the base `preDraw` will
|
|
65
|
+
* not apply the matrix — append it here instead, unconjugated. Appending
|
|
66
|
+
* after `super` rather than splicing into it is order-equivalent for a
|
|
67
|
+
* particle specifically: no flip, no mask, and the anchor is zeroed, so
|
|
68
|
+
* nothing the base method emits interacts with this.
|
|
69
|
+
* @ignore
|
|
70
|
+
*/
|
|
71
|
+
preDraw(renderer: CanvasRenderer | WebGLRenderer): void;
|
|
72
|
+
/**
|
|
73
|
+
* `currentTransform` already places the particle, so the frame it
|
|
74
|
+
* produces is positioned — only the ancestors' contribution is still
|
|
75
|
+
* missing. The base implementation would add this particle's own `pos` on
|
|
76
|
+
* top of a matrix that already contains it, counting it twice.
|
|
77
|
+
* @ignore
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* Bounds are recomputed here rather than when `pos` moves, so a particle
|
|
81
|
+
* nothing looks at this frame pays nothing at all.
|
|
82
|
+
*
|
|
83
|
+
* `updateBounds()` deliberately keeps its eager contract — a caller that
|
|
84
|
+
* asks for a recompute, such as {@link Container} aggregating child bounds
|
|
85
|
+
* under `enableChildBoundsUpdate`, still gets fresh values back.
|
|
86
|
+
* @ignore
|
|
87
|
+
*/
|
|
88
|
+
getBounds(): Bounds;
|
|
89
|
+
updateBounds(absolute?: boolean): any;
|
|
90
|
+
/**
|
|
91
|
+
* A particle is positioned within its reference frame, which is not
|
|
92
|
+
* necessarily its parent — so summing up the ancestor chain, as the base
|
|
93
|
+
* implementation does, would measure from the wrong place.
|
|
94
|
+
* @ignore
|
|
95
|
+
*/
|
|
96
|
+
getAbsolutePosition(): any;
|
|
97
|
+
/**
|
|
98
|
+
* With the placement in `currentTransform` and `autoTransform` off, the
|
|
99
|
+
* base composition would describe a transform this class never applies.
|
|
100
|
+
* @ignore
|
|
101
|
+
*/
|
|
102
|
+
getLocalTransform(out: Matrix3d): Matrix3d;
|
|
42
103
|
/**
|
|
43
104
|
* @ignore
|
|
44
105
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particle.d.ts","sourceRoot":"","sources":["../../src/particles/particle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAgB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"particle.d.ts","sourceRoot":"","sources":["../../src/particles/particle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAgB,MAAM,qBAAqB,CAAC;AAK7D,OAAO,UAAU,MAAM,6BAA6B,CAAC;AAErD,OAAO,cAAc,MAAM,oCAAoC,CAAC;AAChE,OAAO,aAAa,MAAM,kCAAkC,CAAC;AAC7D,OAAO,eAAe,MAAM,cAAc,CAAC;AAS3C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,UAAU;;IAC/C,GAAG,EAAE,QAAQ,CAAC;IACd,KAAK,EAAE,iBAAiB,GAAG,gBAAgB,CAAC;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;gBACS,OAAO,EAAE,eAAe;IAiBpC;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,UAAQ;IAEpB;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,WAAW,GAAE,OAAe;IA2HnE;;;;;OAKG;IACM,MAAM,CAAC,EAAE,EAAE,MAAM;IA0G1B;;;;;;;OAOG;IACM,OAAO,CAAC,QAAQ,EAAE,cAAc,GAAG,aAAa;IAOzD;;;;;;OAMG;IACH;;;;;;;;OAQG;IACM,SAAS;IAQT,YAAY,CAAC,QAAQ,UAAO;IAkDrC;;;;;OAKG;IACM,mBAAmB;IAiB5B;;;;OAIG;IACM,iBAAiB,CAAC,GAAG,EAAE,QAAQ;IAIxC;;OAEG;IACM,IAAI,CAAC,QAAQ,EAAE,cAAc,GAAG,aAAa;CAMtD;AAED,eAAO,MAAM,YAAY,wEAWxB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type Container from "../renderable/container.js";
|
|
1
2
|
import type ParticleEmitter from "./emitter.ts";
|
|
2
3
|
/**
|
|
3
4
|
* Configuration shape for {@link ParticleEmitter}.
|
|
@@ -129,9 +130,13 @@ export interface ParticleEmitterSettings {
|
|
|
129
130
|
/**
|
|
130
131
|
* Blend mode applied when rendering particles. If different than "normal",
|
|
131
132
|
* supersedes the `textureAdditive` setting.
|
|
133
|
+
*
|
|
134
|
+
* Each particle copies this when it is BORN, so changing it here affects
|
|
135
|
+
* particles emitted from that point on. To change the mode of particles
|
|
136
|
+
* already alive as well, assign {@link ParticleEmitter#blendMode} instead —
|
|
137
|
+
* it updates this setting and every live particle together.
|
|
132
138
|
* @default "normal"
|
|
133
|
-
* @see {@link CanvasRenderer#setBlendMode}
|
|
134
|
-
* @see {@link WebGLRenderer#setBlendMode}
|
|
139
|
+
* @see {@link CanvasRenderer#setBlendMode} for the full list of modes
|
|
135
140
|
*/
|
|
136
141
|
blendMode: string;
|
|
137
142
|
/**
|
|
@@ -146,6 +151,40 @@ export interface ParticleEmitterSettings {
|
|
|
146
151
|
* @default false
|
|
147
152
|
*/
|
|
148
153
|
floating: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* What a particle's position is measured against.
|
|
156
|
+
*
|
|
157
|
+
* A particle stores a position, and this decides what that position is
|
|
158
|
+
* relative to. The difference is whether an effect is *attached* to the
|
|
159
|
+
* emitter or *emitted and abandoned* by it.
|
|
160
|
+
*
|
|
161
|
+
* | value | measured from | use |
|
|
162
|
+
* | --- | --- | --- |
|
|
163
|
+
* | `"local"` | the emitter | a flame, an aura, anything welded on |
|
|
164
|
+
* | `"world"` | the container the emitter sits in | trails, smoke, exhaust, dust |
|
|
165
|
+
* | a {@link Container} | that container | a moving frame of reference |
|
|
166
|
+
*
|
|
167
|
+
* With `"local"` a moving emitter drags its whole cloud along, because a
|
|
168
|
+
* particle's stored position never named a place in the level — it meant
|
|
169
|
+
* "this far from my emitter". With `"world"` the position is a place, so
|
|
170
|
+
* the emitter moves away and leaves the particles behind; only newly
|
|
171
|
+
* emitted ones appear at the new location. Passing a `Container` measures
|
|
172
|
+
* from that instead, for the case where the right frame is neither: snow
|
|
173
|
+
* drifting inside a moving carriage travels with the carriage without
|
|
174
|
+
* being welded to the vent that emits it.
|
|
175
|
+
*
|
|
176
|
+
* `"world"` resolves to the emitter's parent container rather than the
|
|
177
|
+
* root, so a level that moves carries its own trails with it. Pass the
|
|
178
|
+
* container explicitly if you want a different one.
|
|
179
|
+
*
|
|
180
|
+
* Changing this at runtime re-bases the particles already alive, so
|
|
181
|
+
* nothing jumps — only their subsequent motion differs.
|
|
182
|
+
* @default "local"
|
|
183
|
+
* @example
|
|
184
|
+
* // exhaust that stays where it was emitted
|
|
185
|
+
* const emitter = new ParticleEmitter(x, y, { referenceSpace: "world" });
|
|
186
|
+
*/
|
|
187
|
+
referenceSpace: "local" | "world" | Container;
|
|
149
188
|
/**
|
|
150
189
|
* Maximum number of particles launched each tick (stream mode only).
|
|
151
190
|
* @default 10
|
|
@@ -169,12 +208,16 @@ export interface ParticleEmitterSettings {
|
|
|
169
208
|
*/
|
|
170
209
|
framesToSkip: number;
|
|
171
210
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
211
|
+
* No longer has any effect, and kept only so existing configurations keep
|
|
212
|
+
* working.
|
|
213
|
+
*
|
|
214
|
+
* It used to trade hitbox accuracy for speed, because bounds were
|
|
215
|
+
* recomputed eagerly on every position write — twice per particle per
|
|
216
|
+
* frame, from a transform that had not been rebuilt yet. Particles now
|
|
217
|
+
* invalidate on write and recompute once on read, so the bounds a reader
|
|
218
|
+
* gets are always current.
|
|
177
219
|
* @default false
|
|
220
|
+
* @deprecated since 20.2.0 — bounds are always up to date; remove it
|
|
178
221
|
*/
|
|
179
222
|
accurateBounds: boolean;
|
|
180
223
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/particles/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,cAAc,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACvC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,KAAK,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,SAAS,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C;IAEjB;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;;;;;OAMG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAE/B;;;;;;;OAOG;IACH,UAAU,EAAE,CAAC,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAC1D;AAED;;;GAGG;AACH,QAAA,MAAM,8BAA8B,EAAE,uBAkCrC,CAAC;AAEF,eAAe,8BAA8B,CAAC"}
|
|
@@ -158,13 +158,13 @@ export interface CollisionResponse {
|
|
|
158
158
|
*/
|
|
159
159
|
pair?: unknown;
|
|
160
160
|
/**
|
|
161
|
-
* @deprecated Use `depth`. Built-in SAT legacy field; kept on modern
|
|
161
|
+
* @deprecated since 19.5.0 - Use `depth`. Built-in SAT legacy field; kept on modern
|
|
162
162
|
* handler dispatches for migration. `undefined` under
|
|
163
163
|
* `@melonjs/matter-adapter`.
|
|
164
164
|
*/
|
|
165
165
|
overlap?: number;
|
|
166
166
|
/**
|
|
167
|
-
* @deprecated Use `normal`. Built-in SAT legacy field; flipped per
|
|
167
|
+
* @deprecated since 19.5.0 - Use `normal`. Built-in SAT legacy field; flipped per
|
|
168
168
|
* receiver so the sign convention aligns with `normal` on the modern
|
|
169
169
|
* dispatch. `undefined` under `@melonjs/matter-adapter`.
|
|
170
170
|
*/
|
|
@@ -173,7 +173,7 @@ export interface CollisionResponse {
|
|
|
173
173
|
y: number;
|
|
174
174
|
};
|
|
175
175
|
/**
|
|
176
|
-
* @deprecated Built-in SAT legacy field, equal to `normal × depth`.
|
|
176
|
+
* @deprecated since 19.5.0 - Built-in SAT legacy field, equal to `normal × depth`.
|
|
177
177
|
* Flipped per receiver. `undefined` under `@melonjs/matter-adapter`.
|
|
178
178
|
*/
|
|
179
179
|
overlapV?: {
|