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
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* android2 `true` if the device is an Android 2.x platform (deprecated)
|
|
9
9
|
* linux `true` if the device is a Linux platform
|
|
10
10
|
* chromeOS `true` if the device is running on ChromeOS.
|
|
11
|
+
* appleVendor `true` if the browser reports an Apple vendor (Safari)
|
|
11
12
|
* wp `true` if the device is a Windows Phone platform (deprecated)
|
|
12
13
|
* BlackBerry `true` if the device is a BlackBerry platform (deprecated)
|
|
13
14
|
* Kindle `true` if the device is a Kindle platform (deprecated)
|
|
@@ -19,6 +20,13 @@
|
|
|
19
20
|
*/
|
|
20
21
|
export declare const ua: string;
|
|
21
22
|
export declare const iOS: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* `true` when the browser reports an Apple vendor string — Safari on
|
|
25
|
+
* macOS or iOS. Distinct from {@link iOS}: a Mac running Safari is
|
|
26
|
+
* `appleVendor` but not `iOS`, and Chrome on iOS is `iOS` but not
|
|
27
|
+
* `appleVendor`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const appleVendor: boolean;
|
|
22
30
|
export declare const android: boolean;
|
|
23
31
|
/**
|
|
24
32
|
* @deprecated since 19.7.0 — Android 2.x predates 2012. Will be removed in 20.x.
|
|
@@ -35,7 +43,19 @@ export declare const wp: boolean;
|
|
|
35
43
|
*/
|
|
36
44
|
export declare const BlackBerry: boolean;
|
|
37
45
|
/**
|
|
38
|
-
*
|
|
46
|
+
* `true` on Amazon devices — Fire tablets (which report the Silk browser) and
|
|
47
|
+
* legacy Kindle e-readers.
|
|
48
|
+
*
|
|
49
|
+
* The previous pattern required `Silk` followed by `Mobile Safari`, which no
|
|
50
|
+
* current Fire tablet sends: Chromium-based Silk ends its user agent with
|
|
51
|
+
* `Safari/537.36`, so every modern Fire tablet went undetected. Silk is
|
|
52
|
+
* Amazon-only, so matching the `Silk/` token directly is both narrower and
|
|
53
|
+
* correct.
|
|
54
|
+
*
|
|
55
|
+
* Note these devices are ordinary Android: {@link android} is `true` for all of
|
|
56
|
+
* them, and nothing in the engine branches on this constant.
|
|
57
|
+
* @deprecated since 19.7.0 — Kindle behaves like Android and {@link android}
|
|
58
|
+
* already covers it. Will be removed in a future release.
|
|
39
59
|
*/
|
|
40
60
|
export declare const Kindle: boolean;
|
|
41
61
|
export declare const ejecta: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/system/platform.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/system/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,EAAE,QAGT,CAAC;AA0DP,eAAO,MAAM,GAAG,SAAsD,CAAC;AACvE;;;;;GAKG;AACH,eAAO,MAAM,WAAW,SAAyB,CAAC;AAClD,eAAO,MAAM,OAAO,SAAsB,CAAC;AAC3C;;GAEG;AACH,eAAO,MAAM,QAAQ,SAAwB,CAAC;AAC9C,eAAO,MAAM,KAAK,SAAoB,CAAC;AACvC,eAAO,MAAM,QAAQ,SAAkB,CAAC;AACxC;;GAEG;AACH,eAAO,MAAM,EAAE,SAA4B,CAAC;AAC5C;;GAEG;AACH,eAAO,MAAM,UAAU,SAAyB,CAAC;AACjD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,MAAM,SAA4B,CAAC;AAChD,eAAO,MAAM,MAAM,SAAyB,CAAC;AAC7C,eAAO,MAAM,QAAQ,SAA6B,CAAC;AAOnD,eAAO,MAAM,MAAM,SAGW,CAAC;AAO/B,eAAO,MAAM,QAAQ,SAAqC,CAAC;AAC3D,eAAO,MAAM,MAAM,SAK2C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchdata.d.ts","sourceRoot":"","sources":["../../src/utils/fetchdata.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,oCALW,MAAM,aACN,MAAM,GACJ,OAAO,CAKnB;AA2DD;;;;;;;;;;;;;;;GAeG;AACH,+BAdW,MAAM,gBACN,MAAM,aACN,MAAM,gBAkDhB"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a blend mode needs the shader path rather than fixed-function state.
|
|
3
|
+
* @param {string} mode - the blend mode to test
|
|
4
|
+
* @returns {boolean} true when the mode needs the shader path
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
7
|
+
export function isAdvancedBlendMode(mode: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The `uBlendMode` uniform value for an advanced blend mode.
|
|
10
|
+
* @param {string} mode - the blend mode
|
|
11
|
+
* @returns {number} the shader's mode index, or -1 when not an advanced mode
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
export function advancedBlendModeIndex(mode: string): number;
|
|
15
|
+
/**
|
|
16
|
+
* Normalize a user-facing blend-mode string to its canonical token: `add` and
|
|
17
|
+
* `lighter` are spellings of `additive`, and anything unrecognized collapses
|
|
18
|
+
* to `normal`.
|
|
19
|
+
*
|
|
20
|
+
* The advanced modes normalize to `"normal"` on purpose — that is their
|
|
21
|
+
* PIPELINE state, since the geometry really does rasterize under ordinary
|
|
22
|
+
* source-over before the shader composites it. Use {@link isAdvancedBlendMode}
|
|
23
|
+
* to ask the other question, and {@link reportedBlendMode} for what
|
|
24
|
+
* `setBlendMode` should tell the caller.
|
|
25
|
+
* @param {string} mode - blend mode as set through `setBlendMode`
|
|
26
|
+
* @returns {string} the canonical token
|
|
27
|
+
* @ignore
|
|
28
|
+
*/
|
|
29
|
+
export function normalizeBlendMode(mode: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the engine can honour this blend mode at all, by either route.
|
|
32
|
+
* @param {string} mode - the blend mode to test
|
|
33
|
+
* @returns {boolean} false only for a mode no backend implements
|
|
34
|
+
* @ignore
|
|
35
|
+
*/
|
|
36
|
+
export function isSupportedBlendMode(mode: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* What `setBlendMode` reports back as applied.
|
|
39
|
+
*
|
|
40
|
+
* The return value is a capability probe: callers compare it against their
|
|
41
|
+
* request, and a mismatch means the renderer could not honour the mode. So a
|
|
42
|
+
* mode that WAS honoured must report itself verbatim — including an alias
|
|
43
|
+
* like `add`, which shares a pipeline with `additive` but must not come back
|
|
44
|
+
* under that name — while anything unimplemented reports `"normal"`.
|
|
45
|
+
* @param {string} mode - the requested blend mode
|
|
46
|
+
* @returns {string} the mode actually applied
|
|
47
|
+
* @ignore
|
|
48
|
+
*/
|
|
49
|
+
export function reportedBlendMode(mode: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* The blend state for a mode, in WebGPU's vocabulary — the neutral form each
|
|
52
|
+
* backend translates from.
|
|
53
|
+
*
|
|
54
|
+
* `srcFactor` depends on whether sources carry premultiplied alpha: a
|
|
55
|
+
* premultiplied source has already been scaled, so it takes `one` where a
|
|
56
|
+
* straight one takes `src-alpha`.
|
|
57
|
+
*
|
|
58
|
+
* Every mode here is EXACT for a translucent source as well as an opaque one
|
|
59
|
+
* — `multiply`, `screen` and `exclusion` were long commented as
|
|
60
|
+
* "approximate", but the algebra works out and measurement agrees. The two
|
|
61
|
+
* that genuinely could not be expressed this way, `darken` and `lighten`,
|
|
62
|
+
* moved to the shader path instead of staying approximate.
|
|
63
|
+
* @param {string} mode - a canonical mode from {@link normalizeBlendMode}
|
|
64
|
+
* @param {boolean} premultipliedAlpha - whether sources are premultiplied
|
|
65
|
+
* @returns {{operation: string, srcFactor: string, dstFactor: string}|undefined} the
|
|
66
|
+
* blend state, or `undefined` for `"none"`, which means replace (no blending)
|
|
67
|
+
* @ignore
|
|
68
|
+
*/
|
|
69
|
+
export function blendStateFor(mode: string, premultipliedAlpha: boolean): {
|
|
70
|
+
operation: string;
|
|
71
|
+
srcFactor: string;
|
|
72
|
+
dstFactor: string;
|
|
73
|
+
} | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* The engine's blend-mode registry — one definition of every mode, shared by
|
|
76
|
+
* all three renderers.
|
|
77
|
+
*
|
|
78
|
+
* Blending is described here in **backend-neutral** terms and translated by
|
|
79
|
+
* each backend: WebGPU consumes these tokens directly (they are its own
|
|
80
|
+
* vocabulary), WebGL maps them onto `gl.*` enums, and Canvas ignores them
|
|
81
|
+
* entirely in favour of `globalCompositeOperation`.
|
|
82
|
+
*
|
|
83
|
+
* Keeping the table in one place is not tidiness. The two GPU backends
|
|
84
|
+
* previously each carried their own copy — a `switch` of `blendEquation` /
|
|
85
|
+
* `blendFunc` calls on one side and a `GPUBlendState` table on the other —
|
|
86
|
+
* which meant a mode added, removed or corrected on one backend could
|
|
87
|
+
* silently disagree with the other, and `video.AUTO` would then render the
|
|
88
|
+
* same scene differently depending on which backend it happened to pick.
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* The CSS blend modes that cannot be expressed as `src * sfactor + dst * dfactor`.
|
|
92
|
+
*
|
|
93
|
+
* Fixed-function blending computes one multiply-add per channel, which covers
|
|
94
|
+
* `multiply`, `screen`, `additive` and `exclusion` — exactly, translucent
|
|
95
|
+
* sources included. The modes below cannot be reached that way: most need a
|
|
96
|
+
* per-pixel branch, a division or a `sqrt` on the DESTINATION, and `darken` /
|
|
97
|
+
* `lighten` need a term the `min` / `max` operations leave no room for.
|
|
98
|
+
* Neither GPU backend can read the destination in a fragment shader, so all of
|
|
99
|
+
* them are implemented by capturing the destination to a texture and
|
|
100
|
+
* compositing in `BlendEffect`.
|
|
101
|
+
*
|
|
102
|
+
* The array ORDER is the wire format: the index is the `uBlendMode` uniform
|
|
103
|
+
* value the shader branches on, so reordering it silently remaps every mode.
|
|
104
|
+
* @ignore
|
|
105
|
+
*/
|
|
106
|
+
export const ADVANCED_BLEND_MODES: string[];
|
|
107
|
+
//# sourceMappingURL=blendmodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blendmodes.d.ts","sourceRoot":"","sources":["../../src/video/blendmodes.js"],"names":[],"mappings":"AAkDA;;;;;GAKG;AACH,0CAJW,MAAM,GACJ,OAAO,CAKnB;AAED;;;;;GAKG;AACH,6CAJW,MAAM,GACJ,MAAM,CAKlB;AAED;;;;;;;;;;;;;GAaG;AACH,yCAJW,MAAM,GACJ,MAAM,CAkBlB;AAED;;;;;GAKG;AACH,2CAJW,MAAM,GACJ,OAAO,CASnB;AAED;;;;;;;;;;;GAWG;AACH,wCAJW,MAAM,GACJ,MAAM,CAKlB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,oCANW,MAAM,sBACN,OAAO,GACL;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAC,GAAC,SAAS,CAwC/E;AA1LD;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,4CAeE"}
|
|
@@ -27,7 +27,7 @@ export default class CanvasRenderer extends Renderer {
|
|
|
27
27
|
setProjection(matrix: Matrix3d): void;
|
|
28
28
|
/**
|
|
29
29
|
* set the current blend mode for this renderer. <br>
|
|
30
|
-
*
|
|
30
|
+
* This renderer supports every mode below except `"none"`: <br>
|
|
31
31
|
* - "normal" : draws new content on top of the existing content <br>
|
|
32
32
|
* <img src="../images/normal-blendmode.png" width="180"/> <br>
|
|
33
33
|
* - "add", "additive", or "lighter" : color values are added together <br>
|
|
@@ -36,26 +36,33 @@ export default class CanvasRenderer extends Renderer {
|
|
|
36
36
|
* <img src="../images/multiply-blendmode.png" width="180"/> <br>
|
|
37
37
|
* - "screen" : pixels are inverted, multiplied, and inverted again (opposite of multiply) <br>
|
|
38
38
|
* <img src="../images/screen-blendmode.png" width="180"/> <br>
|
|
39
|
-
* Canvas (browser-dependent) and WebGL2: <br>
|
|
40
39
|
* - "darken" : retains the darkest pixels of both layers <br>
|
|
41
40
|
* <img src="../images/darken-blendmode.png" width="180"/> <br>
|
|
42
41
|
* - "lighten" : retains the lightest pixels of both layers <br>
|
|
43
42
|
* <img src="../images/lighten-blendmode.png" width="180"/> <br>
|
|
44
|
-
*
|
|
45
|
-
* - "overlay" <br>
|
|
43
|
+
* - "overlay" : multiplies or screens, depending on the backdrop <br>
|
|
46
44
|
* <img src="../images/overlay-blendmode.png" width="180"/> <br>
|
|
47
|
-
* - "
|
|
48
|
-
* <img src="../images/color-dodge-blendmode.png" width="180"/> <br>
|
|
49
|
-
* - "color-burn" <br>
|
|
50
|
-
* <img src="../images/color-burn-blendmode.png" width="180"/> <br>
|
|
51
|
-
* - "hard-light" <br>
|
|
45
|
+
* - "hard-light" : overlay with the layers swapped — a harsh spotlight <br>
|
|
52
46
|
* <img src="../images/hard-light-blendmode.png" width="180"/> <br>
|
|
53
|
-
* - "soft-light" <br>
|
|
47
|
+
* - "soft-light" : a diffused spotlight, gentler than hard-light <br>
|
|
54
48
|
* <img src="../images/soft-light-blendmode.png" width="180"/> <br>
|
|
55
|
-
* - "
|
|
49
|
+
* - "color-dodge" : brightens the backdrop to reflect the source <br>
|
|
50
|
+
* <img src="../images/color-dodge-blendmode.png" width="180"/> <br>
|
|
51
|
+
* - "color-burn" : darkens the backdrop to reflect the source <br>
|
|
52
|
+
* <img src="../images/color-burn-blendmode.png" width="180"/> <br>
|
|
53
|
+
* - "difference" : the absolute difference of the two layers <br>
|
|
56
54
|
* <img src="../images/difference-blendmode.png" width="180"/> <br>
|
|
57
|
-
* - "exclusion" <br>
|
|
55
|
+
* - "exclusion" : like difference, but lower in contrast <br>
|
|
58
56
|
* <img src="../images/exclusion-blendmode.png" width="180"/> <br>
|
|
57
|
+
* - "none" : blending disabled — the source replaces the destination
|
|
58
|
+
* outright, alpha included. **GPU backends only**: there is no
|
|
59
|
+
* `globalCompositeOperation` that disables blending for the drawn area
|
|
60
|
+
* alone (`"copy"` clears the rest of the surface), so this renderer falls
|
|
61
|
+
* back to "normal" and reports it <br>
|
|
62
|
+
* A few draw types cannot honour every mode — 3D meshes, and fills using
|
|
63
|
+
* a {@link Gradient} — and fall back to "normal" with a one-time console
|
|
64
|
+
* warning. `setBlendMode` returns what it actually applied, so comparing
|
|
65
|
+
* the result against your request detects that case.
|
|
59
66
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
60
67
|
* @param {string} [mode="normal"] - blend mode
|
|
61
68
|
* @returns {string} the blend mode actually applied (may differ if the requested mode is unsupported)
|
|
@@ -301,24 +308,24 @@ export default class CanvasRenderer extends Renderer {
|
|
|
301
308
|
* Reset (overrides) the renderer transformation matrix to the
|
|
302
309
|
* identity one, and then apply the given transformation matrix.
|
|
303
310
|
* @param {Matrix2d|Matrix3d|number} a - a matrix to transform by, or the a component to multiply the current matrix by
|
|
304
|
-
* @param {number} b - the b component to multiply the current matrix by
|
|
305
|
-
* @param {number} c - the c component to multiply the current matrix by
|
|
306
|
-
* @param {number} d - the d component to multiply the current matrix by
|
|
307
|
-
* @param {number} e - the e component to multiply the current matrix by
|
|
308
|
-
* @param {number} f - the f component to multiply the current matrix by
|
|
311
|
+
* @param {number} [b] - the b component to multiply the current matrix by; omitted when `a` is a matrix
|
|
312
|
+
* @param {number} [c] - the c component to multiply the current matrix by; omitted when `a` is a matrix
|
|
313
|
+
* @param {number} [d] - the d component to multiply the current matrix by; omitted when `a` is a matrix
|
|
314
|
+
* @param {number} [e] - the e component to multiply the current matrix by; omitted when `a` is a matrix
|
|
315
|
+
* @param {number} [f] - the f component to multiply the current matrix by; omitted when `a` is a matrix
|
|
309
316
|
*/
|
|
310
|
-
setTransform(a: Matrix2d | Matrix3d | number, b
|
|
317
|
+
setTransform(a: Matrix2d | Matrix3d | number, b?: number, c?: number, d?: number, e?: number, f?: number): void;
|
|
311
318
|
/**
|
|
312
319
|
* Multiply given matrix into the renderer tranformation matrix
|
|
313
320
|
* @see {@link CanvasRenderer.setTransform} which will reset the current transform matrix prior to performing the new transformation
|
|
314
321
|
* @param {Matrix2d|Matrix3d|number} a - a matrix to transform by, or the a component to multiply the current matrix by
|
|
315
|
-
* @param {number} b - the b component to multiply the current matrix by
|
|
316
|
-
* @param {number} c - the c component to multiply the current matrix by
|
|
317
|
-
* @param {number} d - the d component to multiply the current matrix by
|
|
318
|
-
* @param {number} e - the e component to multiply the current matrix by
|
|
319
|
-
* @param {number} f - the f component to multiply the current matrix by
|
|
322
|
+
* @param {number} [b] - the b component to multiply the current matrix by; omitted when `a` is a matrix
|
|
323
|
+
* @param {number} [c] - the c component to multiply the current matrix by; omitted when `a` is a matrix
|
|
324
|
+
* @param {number} [d] - the d component to multiply the current matrix by; omitted when `a` is a matrix
|
|
325
|
+
* @param {number} [e] - the e component to multiply the current matrix by; omitted when `a` is a matrix
|
|
326
|
+
* @param {number} [f] - the f component to multiply the current matrix by; omitted when `a` is a matrix
|
|
320
327
|
*/
|
|
321
|
-
transform(a: Matrix2d | Matrix3d | number, b
|
|
328
|
+
transform(a: Matrix2d | Matrix3d | number, b?: number, c?: number, d?: number, e?: number, f?: number): void;
|
|
322
329
|
/**
|
|
323
330
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
324
331
|
* If the drawing or rendering area is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/canvas/canvas_renderer.js"],"names":[],"mappings":"AAcA;;;;;;;;;;GAUG;AAEH;;;GAGG;AACH;IAiBE,oBAAmC;IAiCnC,wBAEC;IAyBD,8CAA4B;IAyE1B,mBAA0B;IA6B7B;;;;;OAKG;IACH,sBAFW,QAAQ,QAclB;IAED
|
|
1
|
+
{"version":3,"file":"canvas_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/canvas/canvas_renderer.js"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export const wgslFragment: "\nstruct BlendUniforms {\n\tuBlendMode : f32,\n};\n@group(3) @binding(0) var<uniform> fx : BlendUniforms;\n@group(3) @binding(1) var backdrop : texture_2d<f32>;\n@group(3) @binding(2) var backdrop_sampler : sampler;\n\n// HardLight(Cb, Cs) \u2014 also the kernel for Overlay, which the W3C spec\n// defines as HardLight with the arguments swapped\nfn ME_hardLight(b : vec3f, s : vec3f) -> vec3f {\n\tlet lo = 2.0 * b * s;\n\tlet hi = 1.0 - 2.0 * (1.0 - b) * (1.0 - s);\n\treturn mix(lo, hi, step(vec3f(0.5), s));\n}\n\nfn ME_softLight(b : vec3f, s : vec3f) -> vec3f {\n\tlet d = mix(((16.0 * b - 12.0) * b + 4.0) * b, sqrt(b), step(vec3f(0.25), b));\n\tlet lo = b - (1.0 - 2.0 * s) * b * (1.0 - b);\n\tlet hi = b + (2.0 * s - 1.0) * (d - b);\n\treturn mix(lo, hi, step(vec3f(0.5), s));\n}\n\n// Cb == 0 wins over Cs == 1, so it is applied last\nfn ME_colorDodge(b : vec3f, s : vec3f) -> vec3f {\n\tvar r = min(vec3f(1.0), b / max(1.0 - s, vec3f(1e-4)));\n\tr = mix(r, vec3f(1.0), step(vec3f(1.0), s));\n\treturn mix(r, vec3f(0.0), step(b, vec3f(0.0)));\n}\n\n// Cb == 1 wins over Cs == 0, so it is applied last\nfn ME_colorBurn(b : vec3f, s : vec3f) -> vec3f {\n\tvar r = 1.0 - min(vec3f(1.0), (1.0 - b) / max(s, vec3f(1e-4)));\n\tr = mix(r, vec3f(0.0), step(s, vec3f(0.0)));\n\treturn mix(r, vec3f(1.0), step(vec3f(1.0), b));\n}\n\nfn ME_blend(b : vec3f, s : vec3f) -> vec3f {\n\tif (fx.uBlendMode < 0.5) { return abs(b - s); }\n\tif (fx.uBlendMode < 1.5) { return ME_hardLight(s, b); }\n\tif (fx.uBlendMode < 2.5) { return ME_hardLight(b, s); }\n\tif (fx.uBlendMode < 3.5) { return ME_colorDodge(b, s); }\n\tif (fx.uBlendMode < 4.5) { return ME_colorBurn(b, s); }\n\tif (fx.uBlendMode < 5.5) { return ME_softLight(b, s); }\n\tif (fx.uBlendMode < 6.5) { return min(b, s); }\n\treturn max(b, s);\n}\n\nfn apply(color : vec4f, uv : vec2f) -> vec4f {\n\t// sampled BEFORE any branch, so plain textureSampleLevel is safe here\n\tlet Cb = textureSampleLevel(backdrop, backdrop_sampler, screen_uv, 0.0).rgb;\n\tlet a = color.a;\n\tlet Cs = color.rgb / max(a, 1e-4);\n\tlet B = clamp(ME_blend(Cb, Cs), vec3f(0.0), vec3f(1.0));\n\treturn vec4f(a * B, a);\n}\n";
|
|
2
|
+
/**
|
|
3
|
+
* The compositing shader behind the six CSS blend modes that fixed-function
|
|
4
|
+
* blending cannot express: `overlay`, `hard-light`, `color-dodge`,
|
|
5
|
+
* `color-burn`, `soft-light` and `difference`.
|
|
6
|
+
*
|
|
7
|
+
* Internal — owned by the renderer, one instance per renderer, never
|
|
8
|
+
* constructed or configured by user code. A game selects a mode the ordinary
|
|
9
|
+
* way (`sprite.blendMode = "overlay"`, or `renderer.setBlendMode("overlay")`)
|
|
10
|
+
* and the renderer drives this effect from there.
|
|
11
|
+
*
|
|
12
|
+
* ### How it composites
|
|
13
|
+
*
|
|
14
|
+
* The renderer captures the destination, renders the draw to an offscreen
|
|
15
|
+
* target, then blits that target through this effect. Everything arriving in
|
|
16
|
+
* `color` is PREMULTIPLIED (the offscreen was drawn source-over into a
|
|
17
|
+
* transparent clear), while the W3C formulas are defined on straight colour —
|
|
18
|
+
* so the body un-premultiplies, blends, and re-premultiplies.
|
|
19
|
+
*
|
|
20
|
+
* Emitting premultiplied and letting ordinary source-over run the composite
|
|
21
|
+
* yields `as*B + (1-as)*Cb` and a correct output alpha for free. It also keeps
|
|
22
|
+
* the premultiplied invariant `rgb <= a` — a texel with `rgb > a` is undefined
|
|
23
|
+
* and diverges across browsers — which is why `B` is clamped even though all
|
|
24
|
+
* six formulas land in `[0,1]` analytically.
|
|
25
|
+
*
|
|
26
|
+
* The backdrop is treated as opaque (`ab = 1`). The GL capture is an RGB
|
|
27
|
+
* texture so that is true by construction there; the WebGPU capture preserves
|
|
28
|
+
* alpha and is deliberately ignored, so the two backends agree.
|
|
29
|
+
*
|
|
30
|
+
* ### Why not the `: screen_texture` builtin
|
|
31
|
+
*
|
|
32
|
+
* That annotation wires the sampler to the renderer's SHARED capture slot,
|
|
33
|
+
* which `drawImage` already refreshes on behalf of any custom shader that
|
|
34
|
+
* samples the screen. A renderable carrying an advanced blend mode AND a
|
|
35
|
+
* screen-sampling {@link ShaderEffect} would then have the two fighting over
|
|
36
|
+
* one texture. This declares a plain sampler instead and the renderer binds
|
|
37
|
+
* its own capture, so the two are independent. Referencing `screen_uv` still
|
|
38
|
+
* activates that varying on its own.
|
|
39
|
+
* @see {@link https://www.w3.org/TR/compositing-1/#blending}
|
|
40
|
+
* @ignore
|
|
41
|
+
*/
|
|
42
|
+
export default class BlendEffect extends ShaderEffect {
|
|
43
|
+
/**
|
|
44
|
+
* @param {import("../webgl/webgl_renderer.js").default|import("../webgpu/webgpu_renderer.js").default} renderer - the renderer that owns this effect
|
|
45
|
+
*/
|
|
46
|
+
constructor(renderer: import("../webgl/webgl_renderer.js").default | import("../webgpu/webgpu_renderer.js").default);
|
|
47
|
+
/**
|
|
48
|
+
* Select which of the six formulas the shader evaluates.
|
|
49
|
+
* @param {string} mode - one of the modes in {@link ADVANCED_BLEND_MODES}
|
|
50
|
+
* @returns {boolean} false when the mode is not an advanced blend mode, in
|
|
51
|
+
* which case the uniform is left untouched
|
|
52
|
+
* @ignore
|
|
53
|
+
*/
|
|
54
|
+
setBlendMode(mode: string): boolean;
|
|
55
|
+
}
|
|
56
|
+
import ShaderEffect from "./shadereffect.js";
|
|
57
|
+
//# sourceMappingURL=blendEffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blendEffect.d.ts","sourceRoot":"","sources":["../../../src/video/effects/blendEffect.js"],"names":[],"mappings":"AAgBA,soEAwDE;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH;IACC;;OAEG;IACH,sBAFW,OAAO,4BAA4B,EAAE,OAAO,GAAC,OAAO,8BAA8B,EAAE,OAAO,EA4DrG;IAED;;;;;;OAMG;IACH,mBALW,MAAM,GACJ,OAAO,CAWnB;CACD;yBAhMwB,mBAAmB"}
|
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
* Commonly used for background defocus, depth-of-field simulation,
|
|
4
4
|
* or UI backdrop blur.
|
|
5
5
|
* @category Effects
|
|
6
|
-
* @see {@link Renderable
|
|
6
|
+
* @see {@link Renderable#addPostEffect} for usage
|
|
7
7
|
* @example
|
|
8
8
|
* // moderate blur
|
|
9
|
-
* mySprite.
|
|
9
|
+
* mySprite.addPostEffect(new BlurEffect(renderer, { strength: 2.0 }));
|
|
10
10
|
*/
|
|
11
11
|
export default class BlurEffect extends ShaderEffect {
|
|
12
12
|
/**
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {WebGLRenderer|WebGPURenderer|CanvasRenderer} renderer - the current renderer instance
|
|
14
14
|
* @param {object} [options] - effect options
|
|
15
15
|
* @param {number} [options.strength=1.0] - blur strength in texels
|
|
16
16
|
* @param {number[]} [options.textureSize=[256, 256]] - texture dimensions [width, height]
|
|
17
17
|
*/
|
|
18
|
-
constructor(renderer:
|
|
18
|
+
constructor(renderer: WebGLRenderer | WebGPURenderer | CanvasRenderer, options?: {
|
|
19
19
|
strength?: number | undefined;
|
|
20
20
|
textureSize?: number[] | undefined;
|
|
21
21
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blur.d.ts","sourceRoot":"","sources":["../../../src/video/effects/blur.js"],"names":[],"mappings":"AA4BA;;;;;;;;;GASG;AACH;IACC;;;;;OAKG;IACH,
|
|
1
|
+
{"version":3,"file":"blur.d.ts","sourceRoot":"","sources":["../../../src/video/effects/blur.js"],"names":[],"mappings":"AA4BA;;;;;;;;;GASG;AACH;IACC;;;;;OAKG;IACH,sBALW,aAAa,GAAC,cAAc,GAAC,cAAc,YAEnD;QAAyB,QAAQ;QACN,WAAW;KACxC,EA8BA;IALA,iBAAuC;IAOxC;;;OAGG;IACH,sBAFW,MAAM,QAKhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;CACD;yBA7FwB,mBAAmB"}
|
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
* chromatic aberration (color fringe) effect. Commonly used for
|
|
4
4
|
* impact feedback, glitch effects, or damage indicators.
|
|
5
5
|
* @category Effects
|
|
6
|
-
* @see {@link Renderable
|
|
6
|
+
* @see {@link Renderable#addPostEffect} for usage
|
|
7
7
|
* @example
|
|
8
8
|
* // subtle chromatic aberration
|
|
9
|
-
* mySprite.
|
|
9
|
+
* mySprite.addPostEffect(new ChromaticAberrationEffect(renderer, { offset: 2.0 }));
|
|
10
10
|
* @example
|
|
11
11
|
* // strong glitch effect
|
|
12
|
-
* mySprite.
|
|
12
|
+
* mySprite.addPostEffect(new ChromaticAberrationEffect(renderer, { offset: 5.0 }));
|
|
13
13
|
*/
|
|
14
14
|
export default class ChromaticAberrationEffect extends ShaderEffect {
|
|
15
15
|
/**
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {WebGLRenderer|WebGPURenderer|CanvasRenderer} renderer - the current renderer instance
|
|
17
17
|
* @param {object} [options] - effect options
|
|
18
18
|
* @param {number} [options.offset=3.0] - channel offset in texels
|
|
19
19
|
* @param {number[]} [options.textureSize=[256, 256]] - texture dimensions [width, height]
|
|
20
20
|
*/
|
|
21
|
-
constructor(renderer:
|
|
21
|
+
constructor(renderer: WebGLRenderer | WebGPURenderer | CanvasRenderer, options?: {
|
|
22
22
|
offset?: number | undefined;
|
|
23
23
|
textureSize?: number[] | undefined;
|
|
24
24
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chromaticAberration.d.ts","sourceRoot":"","sources":["../../../src/video/effects/chromaticAberration.js"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;GAYG;AACH;IACC;;;;;OAKG;IACH,
|
|
1
|
+
{"version":3,"file":"chromaticAberration.d.ts","sourceRoot":"","sources":["../../../src/video/effects/chromaticAberration.js"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;GAYG;AACH;IACC;;;;;OAKG;IACH,sBALW,aAAa,GAAC,cAAc,GAAC,cAAc,YAEnD;QAAyB,MAAM;QACJ,WAAW;KACxC,EAuBA;IALA,eAAmC;IAOpC;;;OAGG;IACH,kBAFW,MAAM,QAKhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;CACD;yBAlFwB,mBAAmB"}
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
* A shader effect that applies a 4x4 color transformation matrix.
|
|
3
3
|
* Provides chainable color adjustment methods that automatically update the GPU uniform.
|
|
4
4
|
* @category Effects
|
|
5
|
-
* @see {@link Renderable
|
|
5
|
+
* @see {@link Renderable#addPostEffect} for usage
|
|
6
6
|
* @example
|
|
7
7
|
* // desaturate a sprite
|
|
8
|
-
* mySprite.
|
|
8
|
+
* mySprite.addPostEffect(new ColorMatrixEffect(renderer).saturate(0.0));
|
|
9
9
|
* @example
|
|
10
10
|
* // combine brightness + contrast on a camera
|
|
11
|
-
* camera.
|
|
11
|
+
* camera.addPostEffect(new ColorMatrixEffect(renderer).brightness(1.3).contrast(1.5));
|
|
12
12
|
* @example
|
|
13
13
|
* // update dynamically
|
|
14
14
|
* effect.reset().brightness(1.5).saturate(0.5);
|
|
15
15
|
*/
|
|
16
16
|
export default class ColorMatrixEffect extends ShaderEffect {
|
|
17
17
|
/**
|
|
18
|
-
* @param {
|
|
18
|
+
* @param {WebGLRenderer|WebGPURenderer|CanvasRenderer} renderer - the current renderer instance
|
|
19
19
|
* @param {object} [options] - effect options
|
|
20
20
|
* @param {ColorMatrix} [options.matrix] - an initial color matrix. Defaults to identity.
|
|
21
21
|
*/
|
|
22
|
-
constructor(renderer:
|
|
22
|
+
constructor(renderer: WebGLRenderer | WebGPURenderer | CanvasRenderer, options?: {
|
|
23
23
|
matrix?: ColorMatrix | undefined;
|
|
24
24
|
});
|
|
25
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorMatrix.d.ts","sourceRoot":"","sources":["../../../src/video/effects/colorMatrix.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;;OAIG;IACH,
|
|
1
|
+
{"version":3,"file":"colorMatrix.d.ts","sourceRoot":"","sources":["../../../src/video/effects/colorMatrix.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;;OAIG;IACH,sBAJW,aAAa,GAAC,cAAc,GAAC,cAAc,YAEnD;QAA8B,MAAM;KACtC,EAkBA;IANA;;;OAGG;IACH,qBAAkD;IAInD;;;OAGG;IACH,qBAEC;IAED;;;OAGG;IACH,SAFa,IAAI,CAMhB;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,IAAI,CAMhB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,IAAI,CAMhB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,IAAI,CAMhB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,IAAI,CAMhB;IAED;;;;OAIG;IACH,eAHW,MAAM,GACJ,IAAI,CAMhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,GACJ,IAAI,CAMhB;IAED;;;;OAIG;IACH,iBAHW,WAAW,GACT,IAAI,CAMhB;IAED;;;;;OAKG;IACH,mBAHc,MAAM,EAAA,GACP,IAAI,CAMhB;CACD;yBAjKwB,mBAAmB;4BADhB,4BAA4B"}
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
* A shader effect that desaturates (grayscales) the sprite.
|
|
3
3
|
* Commonly used for disabled states, death effects, or petrification.
|
|
4
4
|
* @category Effects
|
|
5
|
-
* @see {@link Renderable
|
|
5
|
+
* @see {@link Renderable#addPostEffect} for usage
|
|
6
6
|
* @example
|
|
7
7
|
* // full grayscale
|
|
8
|
-
* mySprite.
|
|
8
|
+
* mySprite.addPostEffect(new DesaturateEffect(renderer));
|
|
9
9
|
* @example
|
|
10
10
|
* // partial desaturation (50%)
|
|
11
|
-
* mySprite.
|
|
11
|
+
* mySprite.addPostEffect(new DesaturateEffect(renderer, { intensity: 0.5 }));
|
|
12
12
|
*/
|
|
13
13
|
export default class DesaturateEffect extends ColorMatrixEffect {
|
|
14
14
|
/**
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {WebGLRenderer|WebGPURenderer|CanvasRenderer} renderer - the current renderer instance
|
|
16
16
|
* @param {object} [options] - effect options
|
|
17
17
|
* @param {number} [options.intensity=1.0] - desaturation intensity (0.0 = full color, 1.0 = grayscale)
|
|
18
18
|
*/
|
|
19
|
-
constructor(renderer:
|
|
19
|
+
constructor(renderer: WebGLRenderer | WebGPURenderer | CanvasRenderer, options?: {
|
|
20
20
|
intensity?: number | undefined;
|
|
21
21
|
});
|
|
22
22
|
intensity: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desaturate.d.ts","sourceRoot":"","sources":["../../../src/video/effects/desaturate.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH;IACC;;;;OAIG;IACH,
|
|
1
|
+
{"version":3,"file":"desaturate.d.ts","sourceRoot":"","sources":["../../../src/video/effects/desaturate.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH;IACC;;;;OAIG;IACH,sBAJW,aAAa,GAAC,cAAc,GAAC,cAAc,YAEnD;QAAyB,SAAS;KACpC,EAMA;IAHA,kBACgE;IAIjE;;;OAGG;IACH,oBAFW,MAAM,QAKhB;CACD;8BAnC6B,kBAAkB"}
|
|
@@ -4,24 +4,24 @@
|
|
|
4
4
|
* `progress` value increases from 0 to 1.
|
|
5
5
|
* Commonly used for death, spawn, or teleport effects.
|
|
6
6
|
* @category Effects
|
|
7
|
-
* @see {@link Renderable
|
|
7
|
+
* @see {@link Renderable#addPostEffect} for usage
|
|
8
8
|
* @example
|
|
9
9
|
* // create a dissolve effect
|
|
10
10
|
* const dissolve = new DissolveEffect(renderer);
|
|
11
|
-
* mySprite.
|
|
11
|
+
* mySprite.addPostEffect(dissolve);
|
|
12
12
|
*
|
|
13
13
|
* // animate the dissolve (0 = fully visible, 1 = fully dissolved)
|
|
14
14
|
* dissolve.setProgress(0.5);
|
|
15
15
|
*/
|
|
16
16
|
export default class DissolveEffect extends ShaderEffect {
|
|
17
17
|
/**
|
|
18
|
-
* @param {
|
|
18
|
+
* @param {WebGLRenderer|WebGPURenderer|CanvasRenderer} renderer - the current renderer instance
|
|
19
19
|
* @param {object} [options] - effect options
|
|
20
20
|
* @param {number} [options.progress=0.0] - dissolve progress (0.0 = visible, 1.0 = dissolved)
|
|
21
21
|
* @param {number[]} [options.edgeColor=[1.0, 0.5, 0.0]] - color of the dissolve edge
|
|
22
22
|
* @param {number} [options.edgeWidth=0.1] - width of the colored edge (0.0–1.0)
|
|
23
23
|
*/
|
|
24
|
-
constructor(renderer:
|
|
24
|
+
constructor(renderer: WebGLRenderer | WebGPURenderer | CanvasRenderer, options?: {
|
|
25
25
|
progress?: number | undefined;
|
|
26
26
|
edgeColor?: number[] | undefined;
|
|
27
27
|
edgeWidth?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dissolve.d.ts","sourceRoot":"","sources":["../../../src/video/effects/dissolve.js"],"names":[],"mappings":"AA8DA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;;;;OAMG;IACH,
|
|
1
|
+
{"version":3,"file":"dissolve.d.ts","sourceRoot":"","sources":["../../../src/video/effects/dissolve.js"],"names":[],"mappings":"AA8DA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;;;;OAMG;IACH,sBANW,aAAa,GAAC,cAAc,GAAC,cAAc,YAEnD;QAAyB,QAAQ;QACN,SAAS;QACX,SAAS;KACpC,EA0DA;IAPA,iBAAuC;IASxC;;;OAGG;IACH,mBAFW,MAAM,QAKhB;IAED;;;OAGG;IACH,oBAFW,MAAM,EAAE,QAIlB;CACD;yBAhKwB,mBAAmB"}
|
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
* Works by sampling the texture at an offset — if the offset position
|
|
4
4
|
* has an opaque pixel but the current position doesn't, the shadow is drawn.
|
|
5
5
|
* @category Effects
|
|
6
|
-
* @see {@link Renderable
|
|
6
|
+
* @see {@link Renderable#addPostEffect} for usage
|
|
7
7
|
* @example
|
|
8
8
|
* // dark shadow offset to the bottom-right
|
|
9
|
-
* mySprite.
|
|
9
|
+
* mySprite.addPostEffect(new DropShadowEffect(renderer, {
|
|
10
10
|
* offsetX: 3.0,
|
|
11
11
|
* offsetY: 3.0,
|
|
12
12
|
* color: [0.0, 0.0, 0.0],
|
|
13
13
|
* opacity: 0.5,
|
|
14
|
-
* });
|
|
14
|
+
* }));
|
|
15
15
|
*/
|
|
16
16
|
export default class DropShadowEffect extends ShaderEffect {
|
|
17
17
|
/**
|
|
18
|
-
* @param {
|
|
18
|
+
* @param {WebGLRenderer|WebGPURenderer|CanvasRenderer} renderer - the current renderer instance
|
|
19
19
|
* @param {object} [options] - effect options
|
|
20
20
|
* @param {number} [options.offsetX=2.0] - shadow x offset in texels
|
|
21
21
|
* @param {number} [options.offsetY=2.0] - shadow y offset in texels
|
|
@@ -23,7 +23,7 @@ export default class DropShadowEffect extends ShaderEffect {
|
|
|
23
23
|
* @param {number} [options.opacity=0.5] - shadow opacity (0.0–1.0)
|
|
24
24
|
* @param {number[]} [options.textureSize=[256, 256]] - texture dimensions [width, height]
|
|
25
25
|
*/
|
|
26
|
-
constructor(renderer:
|
|
26
|
+
constructor(renderer: WebGLRenderer | WebGPURenderer | CanvasRenderer, options?: {
|
|
27
27
|
offsetX?: number | undefined;
|
|
28
28
|
offsetY?: number | undefined;
|
|
29
29
|
color?: number[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropShadow.d.ts","sourceRoot":"","sources":["../../../src/video/effects/dropShadow.js"],"names":[],"mappings":"AAkCA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;;;;;;OAQG;IACH,
|
|
1
|
+
{"version":3,"file":"dropShadow.d.ts","sourceRoot":"","sources":["../../../src/video/effects/dropShadow.js"],"names":[],"mappings":"AAkCA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;;;;;;OAQG;IACH,sBARW,aAAa,GAAC,cAAc,GAAC,cAAc,YAEnD;QAAyB,OAAO;QACP,OAAO;QACL,KAAK;QACP,OAAO;QACL,WAAW;KACxC,EA0CA;IAED;;;;OAIG;IACH,aAHW,MAAM,KACN,MAAM,QAIhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;CACD;yBAvHwB,mBAAmB"}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* The `intensity` uniform controls how much of the flash color is mixed in
|
|
5
5
|
* (0.0 = original sprite, 1.0 = fully colored).
|
|
6
6
|
* @category Effects
|
|
7
|
-
* @see {@link Renderable
|
|
7
|
+
* @see {@link Renderable#addPostEffect} for usage
|
|
8
8
|
* @example
|
|
9
9
|
* // create a white flash effect
|
|
10
10
|
* const flash = new FlashEffect(renderer);
|
|
11
|
-
* mySprite.
|
|
11
|
+
* mySprite.addPostEffect(flash);
|
|
12
12
|
*
|
|
13
13
|
* // trigger the flash (e.g. on hit)
|
|
14
14
|
* flash.setIntensity(1.0);
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
*/
|
|
22
22
|
export default class FlashEffect extends ShaderEffect {
|
|
23
23
|
/**
|
|
24
|
-
* @param {
|
|
24
|
+
* @param {WebGLRenderer|WebGPURenderer|CanvasRenderer} renderer - the current renderer instance
|
|
25
25
|
* @param {object} [options] - effect options
|
|
26
26
|
* @param {number[]} [options.color=[1.0, 1.0, 1.0]] - flash color as [r, g, b] (0.0–1.0)
|
|
27
27
|
* @param {number} [options.intensity=0.0] - initial flash intensity (0.0–1.0)
|
|
28
28
|
*/
|
|
29
|
-
constructor(renderer:
|
|
29
|
+
constructor(renderer: WebGLRenderer | WebGPURenderer | CanvasRenderer, options?: {
|
|
30
30
|
color?: number[] | undefined;
|
|
31
31
|
intensity?: number | undefined;
|
|
32
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flash.d.ts","sourceRoot":"","sources":["../../../src/video/effects/flash.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IACC;;;;;OAKG;IACH,
|
|
1
|
+
{"version":3,"file":"flash.d.ts","sourceRoot":"","sources":["../../../src/video/effects/flash.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IACC;;;;;OAKG;IACH,sBALW,aAAa,GAAC,cAAc,GAAC,cAAc,YAEnD;QAA2B,KAAK;QACP,SAAS;KACpC,EAkBA;IAJA,kBAAyC;IAM1C;;;OAGG;IACH,oBAFW,MAAM,QAKhB;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;CACD;yBA/EwB,mBAAmB"}
|
|
@@ -3,24 +3,24 @@
|
|
|
3
3
|
* Similar to OutlineEffect but with a soft, blurred edge instead of a hard line.
|
|
4
4
|
* Commonly used for power-ups, magic items, or selection highlights.
|
|
5
5
|
* @category Effects
|
|
6
|
-
* @see {@link Renderable
|
|
6
|
+
* @see {@link Renderable#addPostEffect} for usage
|
|
7
7
|
* @example
|
|
8
8
|
* // blue glow for a magic item
|
|
9
|
-
* mySprite.
|
|
9
|
+
* mySprite.addPostEffect(new GlowEffect(renderer, {
|
|
10
10
|
* color: [0.2, 0.5, 1.0],
|
|
11
11
|
* intensity: 1.5,
|
|
12
|
-
* });
|
|
12
|
+
* }));
|
|
13
13
|
*/
|
|
14
14
|
export default class GlowEffect extends ShaderEffect {
|
|
15
15
|
/**
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {WebGLRenderer|WebGPURenderer|CanvasRenderer} renderer - the current renderer instance
|
|
17
17
|
* @param {object} [options] - effect options
|
|
18
18
|
* @param {number[]} [options.color=[1.0, 1.0, 1.0]] - glow color as [r, g, b] (0.0–1.0)
|
|
19
19
|
* @param {number} [options.width=3.0] - glow spread in pixels
|
|
20
20
|
* @param {number} [options.intensity=1.0] - glow brightness multiplier
|
|
21
21
|
* @param {number[]} [options.textureSize=[256, 256]] - texture dimensions [width, height]
|
|
22
22
|
*/
|
|
23
|
-
constructor(renderer:
|
|
23
|
+
constructor(renderer: WebGLRenderer | WebGPURenderer | CanvasRenderer, options?: {
|
|
24
24
|
color?: number[] | undefined;
|
|
25
25
|
width?: number | undefined;
|
|
26
26
|
intensity?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glow.d.ts","sourceRoot":"","sources":["../../../src/video/effects/glow.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;GAYG;AACH;IACC;;;;;;;OAOG;IACH,
|
|
1
|
+
{"version":3,"file":"glow.d.ts","sourceRoot":"","sources":["../../../src/video/effects/glow.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;GAYG;AACH;IACC;;;;;;;OAOG;IACH,sBAPW,aAAa,GAAC,cAAc,GAAC,cAAc,YAEnD;QAA2B,KAAK;QACP,KAAK;QACL,SAAS;QACP,WAAW;KACxC,EAsCA;IANA,kBAAyC;IAQ1C;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;IAED;;;OAGG;IACH,oBAFW,MAAM,QAKhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;CACD;yBAtHwB,mBAAmB"}
|