melonjs 20.1.1 → 20.2.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 +2 -2
- package/build/application/settings.d.ts +3 -2
- package/build/application/settings.d.ts.map +1 -1
- package/build/index.js +1304 -219
- package/build/index.js.map +4 -4
- package/build/input/pointerevent.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/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/renderable.d.ts +106 -22
- package/build/renderable/renderable.d.ts.map +1 -1
- 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 +28 -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/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/webgl/batchers/batcher.d.ts.map +1 -1
- 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 +116 -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 +100 -6
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -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 six 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
|
+
* Every renderer supports the full set: <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,30 @@ 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 <br>
|
|
59
|
+
* A few draw types cannot honour every mode — 3D meshes, and fills using
|
|
60
|
+
* a {@link Gradient} — and fall back to "normal" with a one-time console
|
|
61
|
+
* warning. `setBlendMode` returns what it actually applied, so comparing
|
|
62
|
+
* the result against your request detects that case.
|
|
59
63
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
60
64
|
* @param {string} [mode="normal"] - blend mode
|
|
61
65
|
* @returns {string} the blend mode actually applied (may differ if the requested mode is unsupported)
|
|
@@ -301,24 +305,24 @@ export default class CanvasRenderer extends Renderer {
|
|
|
301
305
|
* Reset (overrides) the renderer transformation matrix to the
|
|
302
306
|
* identity one, and then apply the given transformation matrix.
|
|
303
307
|
* @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
|
|
308
|
+
* @param {number} [b] - the b component to multiply the current matrix by; omitted when `a` is a matrix
|
|
309
|
+
* @param {number} [c] - the c component to multiply the current matrix by; omitted when `a` is a matrix
|
|
310
|
+
* @param {number} [d] - the d component to multiply the current matrix by; omitted when `a` is a matrix
|
|
311
|
+
* @param {number} [e] - the e component to multiply the current matrix by; omitted when `a` is a matrix
|
|
312
|
+
* @param {number} [f] - the f component to multiply the current matrix by; omitted when `a` is a matrix
|
|
309
313
|
*/
|
|
310
|
-
setTransform(a: Matrix2d | Matrix3d | number, b
|
|
314
|
+
setTransform(a: Matrix2d | Matrix3d | number, b?: number, c?: number, d?: number, e?: number, f?: number): void;
|
|
311
315
|
/**
|
|
312
316
|
* Multiply given matrix into the renderer tranformation matrix
|
|
313
317
|
* @see {@link CanvasRenderer.setTransform} which will reset the current transform matrix prior to performing the new transformation
|
|
314
318
|
* @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
|
|
319
|
+
* @param {number} [b] - the b component to multiply the current matrix by; omitted when `a` is a matrix
|
|
320
|
+
* @param {number} [c] - the c component to multiply the current matrix by; omitted when `a` is a matrix
|
|
321
|
+
* @param {number} [d] - the d component to multiply the current matrix by; omitted when `a` is a matrix
|
|
322
|
+
* @param {number} [e] - the e component to multiply the current matrix by; omitted when `a` is a matrix
|
|
323
|
+
* @param {number} [f] - the f component to multiply the current matrix by; omitted when `a` is a matrix
|
|
320
324
|
*/
|
|
321
|
-
transform(a: Matrix2d | Matrix3d | number, b
|
|
325
|
+
transform(a: Matrix2d | Matrix3d | number, b?: number, c?: number, d?: number, e?: number, f?: number): void;
|
|
322
326
|
/**
|
|
323
327
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
324
328
|
* 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":"AAcA;;;;;;;;;;GAUG;AAEH;;;GAGG;AACH;IAiBE,oBAAmC;IAiCnC,wBAEC;IAyBD,8CAA4B;IAyE1B,mBAA0B;IA6B7B;;;;;OAKG;IACH,sBAFW,QAAQ,QAclB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,oBAHW,MAAM,GACJ,MAAM,CAqClB;IAWD;;;;OAIG;IACH,mBAHW,KAAK,GAAC,M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BAChC,4BAA4B;6BACzB,+BAA+B;4BAEhC,yBAAyB;8BADvB,wBAAwB"}
|
|
@@ -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"}
|
|
@@ -447,11 +447,10 @@ declare class Renderer {
|
|
|
447
447
|
*/
|
|
448
448
|
getBlendMode(): string;
|
|
449
449
|
/**
|
|
450
|
-
* set the current blend mode.
|
|
451
|
-
*
|
|
452
|
-
* lands) implement the actual backend logic.
|
|
450
|
+
* set the current blend mode. Every renderer supports the same set —
|
|
451
|
+
* see {@link CanvasRenderer#setBlendMode} for the list and what each does.
|
|
453
452
|
* @param {string} [mode="normal"] - blend mode
|
|
454
|
-
* @param {boolean} [premultipliedAlpha=true] - whether textures use premultiplied alpha
|
|
453
|
+
* @param {boolean} [premultipliedAlpha=true] - whether textures use premultiplied alpha
|
|
455
454
|
*/
|
|
456
455
|
setBlendMode(mode?: string): void;
|
|
457
456
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/video/renderer.js"],"names":[],"mappings":"AAUA;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;;GAGG;AACH;IA2dC;;;;;;;;;;;;OAYG;IACH,2BANW,MAAM,UACN,MAAM,0BACN,OAAO,GAEL,iBAAiB,GAAC,eAAe,CAI7C;IAED;;;;;;;;;;;;OAYG;IACH,wBAFa,iBAAiB,GAAC,eAAe,CAgB7C;IAtgBD;;OAEG;IACH,sBAFW,mBAAmB,EA4N7B;IAzNA;;;;OAIG;IACH,cAFU,kBAAkB,CAS3B;IAED;;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yB;6BACtB,4BAA4B;0CAEf,wBAAwB"}
|
|
@@ -82,6 +82,7 @@ declare class CanvasRenderTarget extends RenderTarget {
|
|
|
82
82
|
* @ignore
|
|
83
83
|
*/
|
|
84
84
|
destroy(renderer?: CanvasRenderer | WebGLRenderer): void;
|
|
85
|
+
#private;
|
|
85
86
|
}
|
|
86
87
|
import RenderTarget from "./rendertarget.ts";
|
|
87
88
|
import type CanvasRenderer from "./../canvas/canvas_renderer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvasrendertarget.d.ts","sourceRoot":"","sources":["../../../src/video/rendertarget/canvasrendertarget.js"],"names":[],"mappings":";AA6EA;;;;;;GAMG;AACH;IACC;;;;;;;;;OASG;IACH,mBATW,MAAM,UACN,MAAM,eAEd;QAA4B,OAAO;QACN,WAAW;QACX,eAAe;QACf,kBAAkB;QAClB,SAAS;KACxC,EAoCA;IAhCA;;;;;;;;;;;;;;;;;MAAkE;IASjE,YAA+B;IAUhC,aAA0D;IAGzD;;;;OAIG;IACH,cAHU,MAAM,CAGK;IAOvB;;OAEG;IACH,4CAGC;IAUD;;;OAGG;IACH,sBAFW,OAAO,QAwBjB;IAYD;;;;;;;;OAQG;IACH,gBANW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,GACJ,SAAS,CAUrB;IAoDD;;;;OAIG;IACH,qBAFW,cAAc,GAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"canvasrendertarget.d.ts","sourceRoot":"","sources":["../../../src/video/rendertarget/canvasrendertarget.js"],"names":[],"mappings":";AA6EA;;;;;;GAMG;AACH;IACC;;;;;;;;;OASG;IACH,mBATW,MAAM,UACN,MAAM,eAEd;QAA4B,OAAO;QACN,WAAW;QACX,eAAe;QACf,kBAAkB;QAClB,SAAS;KACxC,EAoCA;IAhCA;;;;;;;;;;;;;;;;;MAAkE;IASjE,YAA+B;IAUhC,aAA0D;IAGzD;;;;OAIG;IACH,cAHU,MAAM,CAGK;IAOvB;;OAEG;IACH,4CAGC;IAUD;;;OAGG;IACH,sBAFW,OAAO,QAwBjB;IAYD;;;;;;;;OAQG;IACH,gBANW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,GACJ,SAAS,CAUrB;IAoDD;;;;OAIG;IACH,qBAFW,cAAc,GAAC,aAAa,QAsBtC;IAWC,mBAEC;IAeH;;;;OAIG;IACH,mBAHW,cAAc,GAAC,aAAa,QAyCtC;;CA2BD;yBAvXwB,mBAAmB;gCAIb,gCAAgC;+BACjC,8BAA8B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/batcher.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH;IAgBC;;;OAGG;IACH,sBAHW,aAAa,YACb,MAAM,EAKhB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,eAfW,aAAa,YAErB;QAA2B,UAAU,EACrC;YAAoC,IAAI,EAAhC,MAAM;YACsB,IAAI,EAAhC,MAAM;YACsB,IAAI,EAAhC,MAAM;YACuB,UAAU,EAAvC,OAAO;YACqB,MAAM,EAAlC,MAAM;SACd;QAAyB,MAAM,EAC/B;YAAgC,MAAM,EAA9B,MAAM;YACkB,QAAQ,EAAhC,MAAM;SACd;QAA0B,WAAW;QACV,OAAO;QACR,iBAAiB;KAC7C,QA+IA;IAzIA,QAAqB;IAGrB,iCAA2C;IAE3C;;;OAGG;IACH,oCAA8B;IAE9B;;;OAGG;IACH,oCAA8B;
|
|
1
|
+
{"version":3,"file":"batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/batcher.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH;IAgBC;;;OAGG;IACH,sBAHW,aAAa,YACb,MAAM,EAKhB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,eAfW,aAAa,YAErB;QAA2B,UAAU,EACrC;YAAoC,IAAI,EAAhC,M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,oBAFW,MAAM,EAAE,QAOlB;IAED;;;OAGG;IACH,aAFW,MAAM,QAqEhB;;CACD;;wBAhxB6C,sBAAsB;+BAUtC,wBAAwB;8BAC3B,2BAA2B;qBAPjC,gBAAgB;8BASV,uBAAuB;6BAVrB,0BAA0B;8BAJzB,wBAAwB;6BAGzB,oBAAoB;kCAUlB,2BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glshader.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/glshader.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,iBAtCW,qBAAqB,UAGrB,MAAM,GAAC,MAAM,aAGb,MAAM,cACN,MAAM,EAiKhB;IArHA;;;OAGG;IACH,IAFU,qBAAqB,CAEnB;IAEZ;;;;;OAKG;IACH,kBAHU,OAAO,CAIwD;IAEzE;;;;;OAKG;IACH,mBAHU,OAAO,CAGuB;IAExC;;;OAGG;IACH,MAFU,MAAM,GAAC,SAAS,CAEV;IAEhB;;;;OAIG;IACH,OAFU,MAAM,GAAC,SAAS,CAER;IAIlB,mBAAqB;IAKrB;;;MAAwD;IAWxD;;;;;;;OAOG;IACH,oBAHU,OAAO,CAGK;IAEtB;;;;;;;;;OASG;IACH,QAHU,OAAO,CAGE;IAEnB;;;;;;;;;;OAUG;IACH,oBAHU,OAAO,CAGK;IAGtB,+BAA2B;IAC3B,oCAA+B;IAC/B,+BAA2B;IAG3B,mBAAwC;IAMtC,sBAAmB;IACnB,iBAAoB;IACpB,qBAAsB;IAgBzB;;;;;;OAMG;IACH,iBA0CC;IAzCA,YAGC;IACD,cAGC;IAoCF;;;;;OAKG;IACH,uBAgBC;IAED;;;;;OAKG;IACH,2BAMC;IAED;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"glshader.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/glshader.js"],"names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KG;IACH,gBAkCC;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/utils/program.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/utils/program.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH,0FA8CC"}
|
|
@@ -24,6 +24,34 @@ export default class WebGLRenderer extends Renderer {
|
|
|
24
24
|
*/
|
|
25
25
|
_effectProjectionStack: Matrix3d;
|
|
26
26
|
_effectPassDepth: number;
|
|
27
|
+
/**
|
|
28
|
+
* Advanced-blend state. The six CSS modes fixed-function cannot
|
|
29
|
+
* express are composited by capturing the destination, rendering the
|
|
30
|
+
* draw to an offscreen target, and blitting that through
|
|
31
|
+
* {@link BlendEffect}. All of it is created lazily — a game that
|
|
32
|
+
* never asks for an advanced mode pays nothing.
|
|
33
|
+
*
|
|
34
|
+
* `_advancedBlendBusy` is a DEPTH, not a flag: the bracket nests
|
|
35
|
+
* inside itself (the composite blit re-enters `setBatcher`, and
|
|
36
|
+
* `toFrameTexture` does too), so a boolean would be cleared by the
|
|
37
|
+
* inner scope while the outer one is still running.
|
|
38
|
+
* @ignore
|
|
39
|
+
*/
|
|
40
|
+
_advancedBlendEffect: BlendEffect | undefined;
|
|
41
|
+
/** @ignore */
|
|
42
|
+
_advancedBlendCapture: any;
|
|
43
|
+
/** @ignore */
|
|
44
|
+
_advancedBlendTarget: WebGLRenderTarget | undefined;
|
|
45
|
+
/** @ignore */
|
|
46
|
+
_advancedBlendOpen: boolean;
|
|
47
|
+
/** @ignore */
|
|
48
|
+
_advancedBlendBusy: number;
|
|
49
|
+
/** @ignore */
|
|
50
|
+
_advancedBlendParent: import("../rendertarget/rendertarget.ts").default | null | undefined;
|
|
51
|
+
/** @ignore */
|
|
52
|
+
_advancedBlendStencil: boolean;
|
|
53
|
+
/** @ignore */
|
|
54
|
+
_advancedBlendWarned: Set<any>;
|
|
27
55
|
/**
|
|
28
56
|
* sets or returns the shape used to join two line segments where they meet.
|
|
29
57
|
* Out of the three possible values for this property: "round", "bevel", and "miter", only "round" is supported for now in WebGL
|
|
@@ -105,11 +133,26 @@ export default class WebGLRenderer extends Renderer {
|
|
|
105
133
|
* @type {WebGLBatcher}
|
|
106
134
|
*/
|
|
107
135
|
currentBatcher: WebGLBatcher;
|
|
136
|
+
set currentProgram(value: WebGLProgram | undefined);
|
|
108
137
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
138
|
+
* Returns the WebGLContext instance for the renderer
|
|
139
|
+
* return a reference to the system 2d Context
|
|
140
|
+
* @returns {WebGLRenderingContext} the current WebGL context
|
|
111
141
|
*/
|
|
112
|
-
|
|
142
|
+
/**
|
|
143
|
+
* The shader program the GL context actually has bound.
|
|
144
|
+
*
|
|
145
|
+
* Backed by the CONTEXT rather than by a field on this renderer, because
|
|
146
|
+
* `GLShader` binds programs too — writing a uniform calls `useProgram`,
|
|
147
|
+
* and a freshly linked program is left bound — and it is constructed with
|
|
148
|
+
* a bare `gl`, so it cannot reach a renderer-owned cache. A field here
|
|
149
|
+
* would silently drift out of step with GL, and every batcher that
|
|
150
|
+
* compares against it (`syncProgram`, the mesh and primitive paths) would
|
|
151
|
+
* skip a rebind it actually needed, drawing a pending batch through the
|
|
152
|
+
* wrong program.
|
|
153
|
+
* @type {WebGLProgram|undefined}
|
|
154
|
+
*/
|
|
155
|
+
get currentProgram(): WebGLProgram | undefined;
|
|
113
156
|
/**
|
|
114
157
|
* the GL texture unit currently active (`gl.activeTexture`) — global
|
|
115
158
|
* GL state, so tracked once per renderer and shared by every batcher
|
|
@@ -163,7 +206,7 @@ export default class WebGLRenderer extends Renderer {
|
|
|
163
206
|
deleteMeshGeometry(mesh: object): void;
|
|
164
207
|
_lightShader: RadialGradientEffect | undefined;
|
|
165
208
|
_lightAtlas: TextureAtlas | undefined;
|
|
166
|
-
_frameTexture:
|
|
209
|
+
_frameTexture: any;
|
|
167
210
|
_orthogonalTMXGPURenderer: OrthogonalTMXLayerGPURenderer | null | undefined;
|
|
168
211
|
/**
|
|
169
212
|
* Draw a TMX tile layer through whichever path the layer's `renderMode`
|
|
@@ -255,6 +298,8 @@ export default class WebGLRenderer extends Renderer {
|
|
|
255
298
|
* @ignore
|
|
256
299
|
*/
|
|
257
300
|
_getLightAtlas(): TextureAtlas;
|
|
301
|
+
/** @ignore */
|
|
302
|
+
_toFrameTexture(options?: {}): any;
|
|
258
303
|
/**
|
|
259
304
|
* The renderer-owned shared frame-capture slot, minted lazily so it has a
|
|
260
305
|
* stable identity from the moment an effect is constructed — before the
|
|
@@ -283,6 +328,37 @@ export default class WebGLRenderer extends Renderer {
|
|
|
283
328
|
invalidateTextureUnit(unit: number, except?: WebGLBatcher): void;
|
|
284
329
|
/** @ignore */
|
|
285
330
|
endPostEffect(renderable: any): void;
|
|
331
|
+
/**
|
|
332
|
+
* Say once, per excluded path and mode, that an advanced blend mode is
|
|
333
|
+
* falling back to `"normal"`. A silent data-dependent fallback is exactly
|
|
334
|
+
* what the advanced-blend work exists to remove, so the exclusions are
|
|
335
|
+
* loud.
|
|
336
|
+
* @param {string} what - the excluded path, named for the message
|
|
337
|
+
* @ignore
|
|
338
|
+
*/
|
|
339
|
+
_warnAdvancedBlendFallback(what: string): void;
|
|
340
|
+
/**
|
|
341
|
+
* Close a pending advanced-blend bracket, if one is open and we are not
|
|
342
|
+
* already inside the bracket machinery. The safe form to call from any
|
|
343
|
+
* path that is about to disturb the destination.
|
|
344
|
+
* @ignore
|
|
345
|
+
*/
|
|
346
|
+
_drainAdvancedBlend(): void;
|
|
347
|
+
/**
|
|
348
|
+
* Open an advanced-blend bracket: capture the destination, then redirect
|
|
349
|
+
* this draw into an offscreen target. Closed by {@link _closeAdvancedBlend}
|
|
350
|
+
* at the next draw, flush or clear.
|
|
351
|
+
* @returns {boolean} false when the effect could not be realized, in which
|
|
352
|
+
* case the draw proceeds unbracketed (plain source-over)
|
|
353
|
+
* @ignore
|
|
354
|
+
*/
|
|
355
|
+
_openAdvancedBlend(): boolean;
|
|
356
|
+
/**
|
|
357
|
+
* Close an advanced-blend bracket: drain the offscreen, return to the
|
|
358
|
+
* parent target, and composite through {@link BlendEffect}.
|
|
359
|
+
* @ignore
|
|
360
|
+
*/
|
|
361
|
+
_closeAdvancedBlend(): void;
|
|
286
362
|
/**
|
|
287
363
|
* Clears the gl context with the given color.
|
|
288
364
|
* @param {Color|string} [color="#000000"] - CSS color.
|
|
@@ -448,15 +524,10 @@ export default class WebGLRenderer extends Renderer {
|
|
|
448
524
|
* add a straight line from the current point to the start of the current sub-path. If the shape has already been closed or has only one point, this function does nothing
|
|
449
525
|
*/
|
|
450
526
|
closePath(): void;
|
|
451
|
-
/**
|
|
452
|
-
* Returns the WebGLContext instance for the renderer
|
|
453
|
-
* return a reference to the system 2d Context
|
|
454
|
-
* @returns {WebGLRenderingContext} the current WebGL context
|
|
455
|
-
*/
|
|
456
527
|
getContext(): WebGLRenderingContext;
|
|
457
528
|
/**
|
|
458
529
|
* set the current blend mode for this renderer. <br>
|
|
459
|
-
*
|
|
530
|
+
* Every renderer supports the full set: <br>
|
|
460
531
|
* - "normal" : draws new content on top of the existing content <br>
|
|
461
532
|
* <img src="../images/normal-blendmode.png" width="180"/> <br>
|
|
462
533
|
* - "add", "additive", or "lighter" : color values are added together <br>
|
|
@@ -465,19 +536,33 @@ export default class WebGLRenderer extends Renderer {
|
|
|
465
536
|
* <img src="../images/multiply-blendmode.png" width="180"/> <br>
|
|
466
537
|
* - "screen" : pixels are inverted, multiplied, and inverted again (opposite of multiply) <br>
|
|
467
538
|
* <img src="../images/screen-blendmode.png" width="180"/> <br>
|
|
468
|
-
* WebGL2 additionally supports: <br>
|
|
469
539
|
* - "darken" : retains the darkest pixels of both layers <br>
|
|
470
540
|
* <img src="../images/darken-blendmode.png" width="180"/> <br>
|
|
471
541
|
* - "lighten" : retains the lightest pixels of both layers <br>
|
|
472
542
|
* <img src="../images/lighten-blendmode.png" width="180"/> <br>
|
|
543
|
+
* - "overlay" : multiplies or screens, depending on the backdrop <br>
|
|
544
|
+
* <img src="../images/overlay-blendmode.png" width="180"/> <br>
|
|
545
|
+
* - "hard-light" : overlay with the layers swapped — a harsh spotlight <br>
|
|
546
|
+
* <img src="../images/hard-light-blendmode.png" width="180"/> <br>
|
|
547
|
+
* - "soft-light" : a diffused spotlight, gentler than hard-light <br>
|
|
548
|
+
* <img src="../images/soft-light-blendmode.png" width="180"/> <br>
|
|
549
|
+
* - "color-dodge" : brightens the backdrop to reflect the source <br>
|
|
550
|
+
* <img src="../images/color-dodge-blendmode.png" width="180"/> <br>
|
|
551
|
+
* - "color-burn" : darkens the backdrop to reflect the source <br>
|
|
552
|
+
* <img src="../images/color-burn-blendmode.png" width="180"/> <br>
|
|
553
|
+
* - "difference" : the absolute difference of the two layers <br>
|
|
554
|
+
* <img src="../images/difference-blendmode.png" width="180"/> <br>
|
|
555
|
+
* - "exclusion" : like difference, but lower in contrast <br>
|
|
556
|
+
* <img src="../images/exclusion-blendmode.png" width="180"/> <br>
|
|
473
557
|
* - "none" : blending disabled — the source replaces the destination
|
|
474
|
-
* outright, alpha included
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
558
|
+
* outright, alpha included <br>
|
|
559
|
+
* A few draw types cannot honour every mode — 3D meshes, and fills using
|
|
560
|
+
* a {@link Gradient} — and fall back to "normal" with a one-time console
|
|
561
|
+
* warning. `setBlendMode` returns what it actually applied, so comparing
|
|
562
|
+
* the result against your request detects that case.
|
|
478
563
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
479
564
|
* @param {string} [mode="normal"] - blend mode
|
|
480
|
-
* @param {boolean} [premultipliedAlpha=true] - whether textures use premultiplied alpha (affects source blend factor)
|
|
565
|
+
* @param {boolean} [premultipliedAlpha=true] - whether textures use premultiplied alpha (affects the source blend factor)
|
|
481
566
|
* @returns {string} the blend mode actually applied (may differ if the requested mode is unsupported)
|
|
482
567
|
*/
|
|
483
568
|
setBlendMode(mode?: string, premultipliedAlpha?: boolean): string;
|
|
@@ -580,24 +665,24 @@ export default class WebGLRenderer extends Renderer {
|
|
|
580
665
|
* Reset (overrides) the renderer transformation matrix to the
|
|
581
666
|
* identity one, and then apply the given transformation matrix.
|
|
582
667
|
* @param {Matrix2d|Matrix3d|number} a - a matrix to transform by, or the a component to multiply the current matrix by
|
|
583
|
-
* @param {number} b - the b component to multiply the current matrix by
|
|
584
|
-
* @param {number} c - the c component to multiply the current matrix by
|
|
585
|
-
* @param {number} d - the d component to multiply the current matrix by
|
|
586
|
-
* @param {number} e - the e component to multiply the current matrix by
|
|
587
|
-
* @param {number} f - the f component to multiply the current matrix by
|
|
668
|
+
* @param {number} [b] - the b component to multiply the current matrix by; omitted when `a` is a matrix
|
|
669
|
+
* @param {number} [c] - the c component to multiply the current matrix by; omitted when `a` is a matrix
|
|
670
|
+
* @param {number} [d] - the d component to multiply the current matrix by; omitted when `a` is a matrix
|
|
671
|
+
* @param {number} [e] - the e component to multiply the current matrix by; omitted when `a` is a matrix
|
|
672
|
+
* @param {number} [f] - the f component to multiply the current matrix by; omitted when `a` is a matrix
|
|
588
673
|
*/
|
|
589
|
-
setTransform(a: Matrix2d | Matrix3d | number, b
|
|
674
|
+
setTransform(a: Matrix2d | Matrix3d | number, b?: number, c?: number, d?: number, e?: number, f?: number): void;
|
|
590
675
|
/**
|
|
591
676
|
* Multiply given matrix into the renderer tranformation matrix
|
|
592
677
|
* @see {@link WebGLRenderer.setTransform} which will reset the current transform matrix prior to performing the new transformation
|
|
593
678
|
* @param {Matrix2d|Matrix3d|number} a - a matrix to transform by, or the a component to multiply the current matrix by
|
|
594
|
-
* @param {number} b - the b component to multiply the current matrix by
|
|
595
|
-
* @param {number} c - the c component to multiply the current matrix by
|
|
596
|
-
* @param {number} d - the d component to multiply the current matrix by
|
|
597
|
-
* @param {number} e - the e component to multiply the current matrix by
|
|
598
|
-
* @param {number} f - the f component to multiply the current matrix by
|
|
679
|
+
* @param {number} [b] - the b component to multiply the current matrix by; omitted when `a` is a matrix
|
|
680
|
+
* @param {number} [c] - the c component to multiply the current matrix by; omitted when `a` is a matrix
|
|
681
|
+
* @param {number} [d] - the d component to multiply the current matrix by; omitted when `a` is a matrix
|
|
682
|
+
* @param {number} [e] - the e component to multiply the current matrix by; omitted when `a` is a matrix
|
|
683
|
+
* @param {number} [f] - the f component to multiply the current matrix by; omitted when `a` is a matrix
|
|
599
684
|
*/
|
|
600
|
-
transform(a: Matrix2d | Matrix3d | number, b
|
|
685
|
+
transform(a: Matrix2d | Matrix3d | number, b?: number, c?: number, d?: number, e?: number, f?: number): void;
|
|
601
686
|
/**
|
|
602
687
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
603
688
|
* If the drawing or rendering area is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
@@ -613,14 +698,16 @@ export default class WebGLRenderer extends Renderer {
|
|
|
613
698
|
import Renderer from "./../renderer.js";
|
|
614
699
|
import RenderTargetPool from "../rendertarget/render_target_pool.js";
|
|
615
700
|
import { Matrix3d } from "../../math/matrix3d.ts";
|
|
701
|
+
import BlendEffect from "../effects/blendEffect.js";
|
|
702
|
+
import WebGLRenderTarget from "../rendertarget/webglrendertarget.js";
|
|
616
703
|
import { GLSamplerCache } from "./utils/samplercache.js";
|
|
617
704
|
import { Bounds } from "../../physics/bounds.ts";
|
|
618
705
|
import { WebGLBatcher } from "./batchers/batcher.js";
|
|
619
706
|
import TextureCache from "./../texture/cache.js";
|
|
620
707
|
import RadialGradientEffect from "../effects/radialGradient.js";
|
|
621
708
|
import { TextureAtlas } from "./../texture/atlas.js";
|
|
622
|
-
import { FrameTexture } from "./../texture/frametexture.js";
|
|
623
709
|
import OrthogonalTMXLayerGPURenderer from "./renderers/tmxlayer/orthogonal.js";
|
|
710
|
+
import { FrameTexture } from "./../texture/frametexture.js";
|
|
624
711
|
import { Color } from "./../../math/color.ts";
|
|
625
712
|
import type { Rect } from "./../../geometries/rectangle.ts";
|
|
626
713
|
import type { RoundRect } from "./../../geometries/roundrect.ts";
|