melonjs 19.1.0 → 19.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 +19 -15
- package/build/application/application.d.ts +33 -0
- package/build/application/application.d.ts.map +1 -1
- package/build/application/settings.d.ts +1 -0
- package/build/application/settings.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +45 -22
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/effects/camera_effect.d.ts +45 -0
- package/build/camera/effects/camera_effect.d.ts.map +1 -0
- package/build/camera/effects/fade_effect.d.ts +60 -0
- package/build/camera/effects/fade_effect.d.ts.map +1 -0
- package/build/camera/effects/mask_effect.d.ts +88 -0
- package/build/camera/effects/mask_effect.d.ts.map +1 -0
- package/build/camera/effects/shake_effect.d.ts +47 -0
- package/build/camera/effects/shake_effect.d.ts.map +1 -0
- package/build/index.d.ts +10 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4283 -1315
- package/build/index.js.map +4 -4
- package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
- package/build/math/color_matrix.d.ts +51 -0
- package/build/math/color_matrix.d.ts.map +1 -0
- package/build/math/matrix2d.d.ts +6 -6
- package/build/math/matrix3d.d.ts +17 -0
- package/build/math/matrix3d.d.ts.map +1 -1
- package/build/particles/emitter.d.ts +19 -5
- package/build/particles/emitter.d.ts.map +1 -1
- package/build/particles/particle.d.ts +4 -1
- package/build/particles/particle.d.ts.map +1 -1
- package/build/particles/settings.d.ts +200 -31
- package/build/particles/settings.d.ts.map +1 -1
- package/build/physics/bounds.d.ts +5 -2
- package/build/physics/bounds.d.ts.map +1 -1
- package/build/physics/quadtree.d.ts.map +1 -1
- package/build/renderable/container.d.ts +1 -1
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/imagelayer.d.ts +13 -2
- package/build/renderable/imagelayer.d.ts.map +1 -1
- package/build/renderable/light2d.d.ts +128 -18
- package/build/renderable/light2d.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +54 -35
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +38 -6
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/text/bitmaptext.d.ts +33 -5
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts +27 -1
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/renderable/trigger.d.ts +44 -19
- package/build/renderable/trigger.d.ts.map +1 -1
- package/build/state/stage.d.ts +65 -9
- package/build/state/stage.d.ts.map +1 -1
- package/build/state/state.d.ts +44 -2
- package/build/state/state.d.ts.map +1 -1
- package/build/tweens/tween.d.ts +9 -0
- package/build/tweens/tween.d.ts.map +1 -1
- package/build/video/buffer/index.d.ts +40 -0
- package/build/video/buffer/index.d.ts.map +1 -0
- package/build/video/{webgl/buffer → buffer}/vertex.d.ts +5 -3
- package/build/video/buffer/vertex.d.ts.map +1 -0
- package/build/video/canvas/canvas_renderer.d.ts +2 -0
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/renderer.d.ts +141 -0
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/renderstate.d.ts +27 -0
- package/build/video/renderstate.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts +26 -63
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts +73 -0
- package/build/video/rendertarget/render_target_pool.d.ts.map +1 -0
- package/build/video/rendertarget/rendertarget.d.ts +77 -0
- package/build/video/rendertarget/rendertarget.d.ts.map +1 -0
- package/build/video/rendertarget/webglrendertarget.d.ts +30 -0
- package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -0
- package/build/video/texture/atlas.d.ts +26 -2
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/webgl/batchers/batcher.d.ts +10 -4
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +109 -0
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -0
- package/build/video/webgl/batchers/quad_batcher.d.ts +34 -3
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +5 -34
- package/build/video/webgl/buffer/index.d.ts.map +1 -1
- package/build/video/webgl/effects/colorMatrix.d.ts +92 -0
- package/build/video/webgl/effects/colorMatrix.d.ts.map +1 -0
- package/build/video/webgl/effects/desaturate.d.ts +2 -4
- package/build/video/webgl/effects/desaturate.d.ts.map +1 -1
- package/build/video/webgl/effects/invert.d.ts +2 -2
- package/build/video/webgl/effects/invert.d.ts.map +1 -1
- package/build/video/webgl/effects/radialGradient.d.ts +105 -0
- package/build/video/webgl/effects/radialGradient.d.ts.map +1 -0
- package/build/video/webgl/effects/sepia.d.ts +2 -2
- package/build/video/webgl/effects/sepia.d.ts.map +1 -1
- package/build/video/webgl/effects/vignette.d.ts +42 -0
- package/build/video/webgl/effects/vignette.d.ts.map +1 -0
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/lighting/constants.d.ts +13 -0
- package/build/video/webgl/lighting/constants.d.ts.map +1 -0
- package/build/video/webgl/lighting/pack.d.ts +76 -0
- package/build/video/webgl/lighting/pack.d.ts.map +1 -0
- package/build/video/webgl/shaders/multitexture-lit.d.ts +23 -0
- package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -0
- package/build/video/webgl/webgl_renderer.d.ts +24 -7
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/build/video/webgl/buffer/vertex.d.ts.map +0 -1
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export default CanvasRenderTarget;
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* A 2D canvas render target for offscreen texture generation.
|
|
4
|
+
* Used by Text, Gradient, Light2d and Particle systems to render into
|
|
5
|
+
* a canvas that is then uploaded as a WebGL texture.
|
|
6
|
+
* @augments RenderTarget
|
|
4
7
|
* @category Rendering
|
|
5
8
|
*/
|
|
6
|
-
declare class CanvasRenderTarget {
|
|
9
|
+
declare class CanvasRenderTarget extends RenderTarget {
|
|
7
10
|
/**
|
|
8
11
|
* @param {number} width - the desired width of the canvas
|
|
9
12
|
* @param {number} height - the desired height of the canvas
|
|
@@ -23,15 +26,26 @@ declare class CanvasRenderTarget {
|
|
|
23
26
|
willReadFrequently?: boolean | undefined;
|
|
24
27
|
antiAlias?: boolean | undefined;
|
|
25
28
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
attributes: {
|
|
30
|
+
offscreenCanvas: boolean;
|
|
31
|
+
willReadFrequently: boolean;
|
|
32
|
+
antiAlias: boolean;
|
|
33
|
+
context: string;
|
|
34
|
+
transparent: boolean;
|
|
35
|
+
premultipliedAlpha: boolean;
|
|
36
|
+
stencil: boolean;
|
|
37
|
+
blendMode: string;
|
|
38
|
+
failIfMajorPerformanceCaveat: boolean;
|
|
39
|
+
preferWebGL1: boolean;
|
|
40
|
+
powerPreference: string;
|
|
41
|
+
} & {
|
|
42
|
+
context?: string | undefined;
|
|
43
|
+
preferWebGL1?: boolean | undefined;
|
|
44
|
+
transparent?: boolean | undefined;
|
|
45
|
+
offscreenCanvas?: boolean | undefined;
|
|
46
|
+
willReadFrequently?: boolean | undefined;
|
|
47
|
+
antiAlias?: boolean | undefined;
|
|
48
|
+
};
|
|
35
49
|
canvas: any;
|
|
36
50
|
context: any;
|
|
37
51
|
WebGLVersion: any;
|
|
@@ -39,21 +53,11 @@ declare class CanvasRenderTarget {
|
|
|
39
53
|
* @ignore
|
|
40
54
|
*/
|
|
41
55
|
onResetEvent(width: any, height: any): void;
|
|
42
|
-
/**
|
|
43
|
-
* Clears the content of the canvas texture
|
|
44
|
-
*/
|
|
45
|
-
clear(): void;
|
|
46
56
|
/**
|
|
47
57
|
* enable/disable image smoothing (scaling interpolation)
|
|
48
58
|
* @param {boolean} [enable=false] - whether to enable or not image smoothing (scaling interpolation)
|
|
49
59
|
*/
|
|
50
60
|
setAntiAlias(enable?: boolean): void;
|
|
51
|
-
/**
|
|
52
|
-
* Resizes the canvas texture to the given width and height.
|
|
53
|
-
* @param {number} width - the desired width
|
|
54
|
-
* @param {number} height - the desired height
|
|
55
|
-
*/
|
|
56
|
-
resize(width: number, height: number): void;
|
|
57
61
|
/**
|
|
58
62
|
* Returns an ImageData object representing the underlying pixel data for a specified portion of this canvas texture.
|
|
59
63
|
* (Note: when using getImageData(), it is highly recommended to use the `willReadFrequently` attribute when creatimg the corresponding canvas texture)
|
|
@@ -64,34 +68,6 @@ declare class CanvasRenderTarget {
|
|
|
64
68
|
* @returns {ImageData} The ImageData extracted from this CanvasRenderTarget.
|
|
65
69
|
*/
|
|
66
70
|
getImageData(x: number, y: number, width: number, height: number): ImageData;
|
|
67
|
-
/**
|
|
68
|
-
* creates a Blob object representing the image contained in this canvas texture
|
|
69
|
-
* @param {string} [type="image/png"] - A string indicating the image format
|
|
70
|
-
* @param {number} [quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
71
|
-
* @returns {Promise} A Promise returning a Blob object representing the image contained in this canvas texture
|
|
72
|
-
* @example
|
|
73
|
-
* renderTarget.convertToBlob().then((blob) => console.log(blob));
|
|
74
|
-
*/
|
|
75
|
-
toBlob(type?: string, quality?: number): Promise<any>;
|
|
76
|
-
/**
|
|
77
|
-
* creates an ImageBitmap object from the most recently rendered image of this canvas texture
|
|
78
|
-
* @param {string} [type="image/png"] - A string indicating the image format
|
|
79
|
-
* @param {number} [quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
80
|
-
* @returns {Promise} A Promise returning an ImageBitmap.
|
|
81
|
-
* @example
|
|
82
|
-
* renderTarget.transferToImageBitmap().then((bitmap) => console.log(bitmap));
|
|
83
|
-
*/
|
|
84
|
-
toImageBitmap(type?: string, quality?: number): Promise<any>;
|
|
85
|
-
/**
|
|
86
|
-
* returns a data URL containing a representation of the most recently rendered image of this canvas texture
|
|
87
|
-
* (not supported by OffscreenCanvas)
|
|
88
|
-
* @param {string} [type="image/png"] - A string indicating the image format
|
|
89
|
-
* @param {number} [quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
90
|
-
* @returns {Promise} A Promise returning a string containing the requested data URL.
|
|
91
|
-
* @example
|
|
92
|
-
* renderer.toDataURL().then((dataURL) => console.log(dataURL));
|
|
93
|
-
*/
|
|
94
|
-
toDataURL(type?: string, quality?: number): Promise<any>;
|
|
95
71
|
/**
|
|
96
72
|
* invalidate the current CanvasRenderTarget, and force a reupload of the corresponding texture
|
|
97
73
|
* (call this if you modify the canvas content between two draw calls)
|
|
@@ -105,21 +81,8 @@ declare class CanvasRenderTarget {
|
|
|
105
81
|
* @ignore
|
|
106
82
|
*/
|
|
107
83
|
destroy(renderer?: CanvasRenderer | WebGLRenderer): void;
|
|
108
|
-
public set width(val: number);
|
|
109
|
-
/**
|
|
110
|
-
* The width of this canvas texture in pixels
|
|
111
|
-
* @public
|
|
112
|
-
* @type {number}
|
|
113
|
-
*/
|
|
114
|
-
public get width(): number;
|
|
115
|
-
public set height(val: number);
|
|
116
|
-
/**
|
|
117
|
-
* The height of this canvas texture in pixels
|
|
118
|
-
* @public
|
|
119
|
-
* @type {number}
|
|
120
|
-
*/
|
|
121
|
-
public get height(): number;
|
|
122
84
|
}
|
|
85
|
+
import RenderTarget from "./rendertarget.ts";
|
|
123
86
|
import type CanvasRenderer from "./../canvas/canvas_renderer.js";
|
|
124
87
|
import type WebGLRenderer from "./../webgl/webgl_renderer.js";
|
|
125
88
|
//# sourceMappingURL=canvasrendertarget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvasrendertarget.d.ts","sourceRoot":"","sources":["../../../src/video/rendertarget/canvasrendertarget.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"canvasrendertarget.d.ts","sourceRoot":"","sources":["../../../src/video/rendertarget/canvasrendertarget.js"],"names":[],"mappings":";AA+EA;;;;;;GAMG;AACH;IACC;;;;;;;;;;OAUG;IACH,mBAVW,MAAM,UACN,MAAM,eAEd;QAA4B,OAAO;QACN,YAAY;QACZ,WAAW;QACX,eAAe;QACf,kBAAkB;QAClB,SAAS;KACxC,EA6BA;IAzBA;;;;;;;;;;;;;;;;;;;MAAkE;IASjE,YAA+B;IAUhC,aAA0D;IAE1D,kBAAgC;IAMjC;;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,QAatC;IALC,mBAEC;IAKH;;;;OAIG;IACH,mBAHW,cAAc,GAAC,aAAa,QAoBtC;CA2BD;yBA3TwB,mBAAmB;gCAIb,gCAAgC;+BACjC,8BAA8B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import RenderTarget from "./rendertarget.ts";
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Manages a pool of {@link RenderTarget} instances for post-effect processing.
|
|
6
|
+
* Renderer-agnostic — the actual RenderTarget creation is delegated to a
|
|
7
|
+
* factory function provided by the renderer (WebGL, WebGPU, etc.).
|
|
8
|
+
*
|
|
9
|
+
* Camera effects use pool indices 0 and 1 (capture + ping-pong),
|
|
10
|
+
* sprite effects use indices 2 and 3.
|
|
11
|
+
* Render targets are lazily created and resized to match the required dimensions.
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
export default class RenderTargetPool {
|
|
15
|
+
/**
|
|
16
|
+
* @param {function(number, number): RenderTarget} factory - creates a RenderTarget with the given width and height
|
|
17
|
+
*/
|
|
18
|
+
constructor(factory: (arg0: number, arg1: number) => RenderTarget);
|
|
19
|
+
/** @type {function(number, number): RenderTarget} */
|
|
20
|
+
_factory: (arg0: number, arg1: number) => RenderTarget;
|
|
21
|
+
/** @type {RenderTarget[]} */
|
|
22
|
+
_pool: RenderTarget[];
|
|
23
|
+
/** @type {number} */
|
|
24
|
+
_activeBase: number;
|
|
25
|
+
/** @type {number} */
|
|
26
|
+
_previousBase: number;
|
|
27
|
+
/**
|
|
28
|
+
* Get or create a render target at the given pool index, resized to the given dimensions.
|
|
29
|
+
* @param {number} index - pool index
|
|
30
|
+
* @param {number} width - desired width in pixels
|
|
31
|
+
* @param {number} height - desired height in pixels
|
|
32
|
+
* @returns {RenderTarget} the render target
|
|
33
|
+
*/
|
|
34
|
+
get(index: number, width: number, height: number): RenderTarget;
|
|
35
|
+
/**
|
|
36
|
+
* Prepare render targets for a post-effect pass.
|
|
37
|
+
* Allocates/resizes the capture target and optionally the ping-pong target.
|
|
38
|
+
* @param {boolean} isCamera - true for camera effects (indices 0+1), false for sprite (indices 2+3)
|
|
39
|
+
* @param {number} effectCount - number of enabled effects
|
|
40
|
+
* @param {number} width - target width in pixels
|
|
41
|
+
* @param {number} height - target height in pixels
|
|
42
|
+
* @returns {RenderTarget} the capture target (ready to bind)
|
|
43
|
+
*/
|
|
44
|
+
begin(isCamera: boolean, effectCount: number, width: number, height: number): RenderTarget;
|
|
45
|
+
/**
|
|
46
|
+
* Get the capture render target for the current active pass.
|
|
47
|
+
* @returns {RenderTarget|undefined} the capture target, or undefined if no active pass
|
|
48
|
+
*/
|
|
49
|
+
getCaptureTarget(): RenderTarget | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Get the ping-pong render target for the current active pass.
|
|
52
|
+
* @returns {RenderTarget|undefined} the ping-pong target, or undefined if no active pass
|
|
53
|
+
*/
|
|
54
|
+
getPingPongTarget(): RenderTarget | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* End the current pass and restore the previous active base.
|
|
57
|
+
* Returns the parent render target to rebind (or null for screen).
|
|
58
|
+
* @returns {RenderTarget|null} the parent target, or null if returning to screen
|
|
59
|
+
*/
|
|
60
|
+
end(): RenderTarget | null;
|
|
61
|
+
/**
|
|
62
|
+
* Resize all existing render targets in the pool to the given dimensions.
|
|
63
|
+
* @param {number} width - new width in pixels
|
|
64
|
+
* @param {number} height - new height in pixels
|
|
65
|
+
*/
|
|
66
|
+
resizeAll(width: number, height: number): void;
|
|
67
|
+
/**
|
|
68
|
+
* Destroy all render targets and clear the pool.
|
|
69
|
+
*/
|
|
70
|
+
destroy(): void;
|
|
71
|
+
}
|
|
72
|
+
import type RenderTarget from "./rendertarget.ts";
|
|
73
|
+
//# sourceMappingURL=render_target_pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render_target_pool.d.ts","sourceRoot":"","sources":["../../../src/video/rendertarget/render_target_pool.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;GASG;AACH;IACC;;OAEG;IACH,qBAFW,CAAS,IAAM,EAAN,MAAM,EAAE,IAAM,EAAN,MAAM,KAAG,YAAY,EAWhD;IARA,qDAAqD;IACrD,UADW,CAAS,IAAM,EAAN,MAAM,EAAE,IAAM,EAAN,MAAM,KAAG,YAAY,CAC1B;IACvB,6BAA6B;IAC7B,OADW,YAAY,EAAE,CACV;IACf,qBAAqB;IACrB,aADW,MAAM,CACI;IACrB,qBAAqB;IACrB,eADW,MAAM,CACM;IAGxB;;;;;;OAMG;IACH,WALW,MAAM,SACN,MAAM,UACN,MAAM,GACJ,YAAY,CASxB;IAED;;;;;;;;OAQG;IACH,gBANW,OAAO,eACP,MAAM,SACN,MAAM,UACN,MAAM,GACJ,YAAY,CAexB;IAED;;;OAGG;IACH,oBAFa,YAAY,GAAC,SAAS,CAOlC;IAED;;;OAGG;IACH,qBAFa,YAAY,GAAC,SAAS,CAOlC;IAED;;;;OAIG;IACH,OAFa,YAAY,GAAC,IAAI,CAS7B;IAED;;;;OAIG;IACH,iBAHW,MAAM,UACN,MAAM,QAQhB;IAED;;OAEG;IACH,gBASC;CACD;8BAlI4B,mBAAmB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base class for offscreen render targets.
|
|
3
|
+
* Provides a renderer-agnostic interface for binding, clearing, resizing,
|
|
4
|
+
* and reading back pixel data from an offscreen surface.
|
|
5
|
+
* Concrete implementations:
|
|
6
|
+
* - {@link WebGLRenderTarget} — WebGL framebuffer object (FBO) for post-processing
|
|
7
|
+
* - {@link CanvasRenderTarget} — 2D canvas surface for texture generation
|
|
8
|
+
*
|
|
9
|
+
* A future WebGPU implementation would extend this class with
|
|
10
|
+
* GPUTexture / GPURenderPassDescriptor management.
|
|
11
|
+
* @category Rendering
|
|
12
|
+
*/
|
|
13
|
+
export default abstract class RenderTarget {
|
|
14
|
+
/**
|
|
15
|
+
* The width of this render target in pixels.
|
|
16
|
+
*/
|
|
17
|
+
width: number;
|
|
18
|
+
/**
|
|
19
|
+
* The height of this render target in pixels.
|
|
20
|
+
*/
|
|
21
|
+
height: number;
|
|
22
|
+
/**
|
|
23
|
+
* Bind this render target as the active draw destination.
|
|
24
|
+
* All subsequent draw calls will render into this target until {@link unbind} is called.
|
|
25
|
+
* No-op by default — subclasses override for GPU render targets (e.g. WebGL FBOs).
|
|
26
|
+
*/
|
|
27
|
+
bind(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Unbind this render target, restoring the default (screen) output.
|
|
30
|
+
* No-op by default — subclasses override for GPU render targets.
|
|
31
|
+
*/
|
|
32
|
+
unbind(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Resize the render target's backing storage to the given dimensions.
|
|
35
|
+
* @param width - new width in pixels
|
|
36
|
+
* @param height - new height in pixels
|
|
37
|
+
*/
|
|
38
|
+
abstract resize(width: number, height: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Clear the render target contents.
|
|
41
|
+
*/
|
|
42
|
+
abstract clear(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Release all resources held by this render target.
|
|
45
|
+
* The target must not be used after calling destroy.
|
|
46
|
+
*/
|
|
47
|
+
abstract destroy(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Read back pixel data from this render target.
|
|
50
|
+
* @param x - x coordinate of the top-left corner (default 0)
|
|
51
|
+
* @param y - y coordinate of the top-left corner (default 0)
|
|
52
|
+
* @param width - width of the area to read (default full width)
|
|
53
|
+
* @param height - height of the area to read (default full height)
|
|
54
|
+
* @returns an ImageData object containing the pixel data
|
|
55
|
+
*/
|
|
56
|
+
abstract getImageData(x?: number, y?: number, width?: number, height?: number): ImageData;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a Blob object representing the image contained in this render target.
|
|
59
|
+
* @param type - a string indicating the image format (default "image/png")
|
|
60
|
+
* @param quality - a number between 0 and 1 for lossy formats (e.g. image/jpeg)
|
|
61
|
+
* @returns a Promise resolving to a Blob
|
|
62
|
+
*/
|
|
63
|
+
toBlob(type?: string, quality?: number): Promise<Blob>;
|
|
64
|
+
/**
|
|
65
|
+
* Creates an ImageBitmap object from the current contents of this render target.
|
|
66
|
+
* @returns a Promise resolving to an ImageBitmap
|
|
67
|
+
*/
|
|
68
|
+
toImageBitmap(): Promise<ImageBitmap>;
|
|
69
|
+
/**
|
|
70
|
+
* Returns a data URL containing a representation of the current contents.
|
|
71
|
+
* @param type - a string indicating the image format (default "image/png")
|
|
72
|
+
* @param quality - a number between 0 and 1 for lossy formats (e.g. image/jpeg)
|
|
73
|
+
* @returns a Promise resolving to a data URL string
|
|
74
|
+
*/
|
|
75
|
+
toDataURL(type?: string, quality?: number): Promise<string>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=rendertarget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rendertarget.d.ts","sourceRoot":"","sources":["../../../src/video/rendertarget/rendertarget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,YAAY;IACzC;;OAEG;IACK,KAAK,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACK,MAAM,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,IAAI,IAAI,IAAI;IAEZ;;;OAGG;IACH,MAAM,IAAI,IAAI;IAEd;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAEpD;;OAEG;IACH,QAAQ,CAAC,KAAK,IAAI,IAAI;IAEtB;;;OAGG;IACH,QAAQ,CAAC,OAAO,IAAI,IAAI;IAExB;;;;;;;OAOG;IACH,QAAQ,CAAC,YAAY,CACpB,CAAC,CAAC,EAAE,MAAM,EACV,CAAC,CAAC,EAAE,MAAM,EACV,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GACb,SAAS;IAEZ;;;;;OAKG;IACH,MAAM,CAAC,IAAI,SAAc,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsC3D;;;OAGG;IACH,aAAa,IAAI,OAAO,CAAC,WAAW,CAAC;IAKrC;;;;;OAKG;IACH,SAAS,CAAC,IAAI,SAAc,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAiBhE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A WebGL Framebuffer Object (FBO) render target for offscreen rendering.
|
|
3
|
+
* Used by the post-processing pipeline to render a camera's output to a texture,
|
|
4
|
+
* which can then be drawn to the screen through a post-process shader.
|
|
5
|
+
* @augments RenderTarget
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
export default class WebGLRenderTarget extends RenderTarget {
|
|
9
|
+
/**
|
|
10
|
+
* @param {WebGLRenderingContext|WebGL2RenderingContext} gl - the WebGL context
|
|
11
|
+
* @param {number} width - initial width in pixels
|
|
12
|
+
* @param {number} height - initial height in pixels
|
|
13
|
+
*/
|
|
14
|
+
constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, width: number, height: number);
|
|
15
|
+
gl: WebGLRenderingContext | WebGL2RenderingContext;
|
|
16
|
+
framebuffer: WebGLFramebuffer;
|
|
17
|
+
texture: WebGLTexture;
|
|
18
|
+
depthStencilBuffer: WebGLRenderbuffer;
|
|
19
|
+
/**
|
|
20
|
+
* (Re)attach the depth/stencil renderbuffer at the given size and
|
|
21
|
+
* update `_hasStencil` based on the resulting framebuffer status.
|
|
22
|
+
* Falls back to depth-only when packed depth+stencil fails; warns
|
|
23
|
+
* once if even depth-only is incomplete.
|
|
24
|
+
* @ignore
|
|
25
|
+
*/
|
|
26
|
+
_applyDepthStencil(width: any, height: any): void;
|
|
27
|
+
_hasStencil: boolean | undefined;
|
|
28
|
+
}
|
|
29
|
+
import RenderTarget from "./rendertarget.ts";
|
|
30
|
+
//# sourceMappingURL=webglrendertarget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webglrendertarget.d.ts","sourceRoot":"","sources":["../../../src/video/rendertarget/webglrendertarget.js"],"names":[],"mappings":"AA8DA;;;;;;GAMG;AACH;IACC;;;;OAIG;IACH,gBAJW,qBAAqB,GAAC,sBAAsB,SAC5C,MAAM,UACN,MAAM,EAqDhB;IAjDA,mDAAY;IAKZ,8BAAyC;IAMzC,sBAAiC;IAoBjC,sCAAiD;IAoBlD;;;;;;OAMG;IACH,kDAkBC;IAVA,iCAAoC;CAmIrC;yBAlRwB,mBAAmB"}
|
|
@@ -46,7 +46,7 @@ export class TextureAtlas {
|
|
|
46
46
|
/**
|
|
47
47
|
* @param {object|object[]} atlases - atlas information. See {@link loader.getJSON}
|
|
48
48
|
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|CompressedImage|string|OffscreenCanvas[]|HTMLImageElement[]|HTMLCanvasElement[]|string[]} [src=atlas.meta.image] - Image source
|
|
49
|
-
* @param {boolean} [cache
|
|
49
|
+
* @param {boolean|object} [options] - either a boolean (legacy `cache` flag — `false` disables `TextureCache` registration; default behavior is to cache) or an options object `{ cache?: boolean, normalMap?: HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|string }`. When `normalMap` is provided, the atlas exposes a paired normal-map texture sharing the same UVs as the color texture (used by the WebGL renderer's lit pipeline). `HTMLVideoElement` is intentionally not supported as a normal map (would freeze on frame 0 due to per-image GL texture caching).
|
|
50
50
|
* @example
|
|
51
51
|
* // create a texture atlas from a JSON Object
|
|
52
52
|
* game.texture = new me.TextureAtlas(
|
|
@@ -68,8 +68,16 @@ export class TextureAtlas {
|
|
|
68
68
|
* anchorPoint : new me.Vector2d(0.5, 0.5)
|
|
69
69
|
* },
|
|
70
70
|
* me.loader.getImage("spritesheet")
|
|
71
|
+
* );
|
|
72
|
+
*
|
|
73
|
+
* // SpriteIlluminator workflow: pair the color atlas with its normal map
|
|
74
|
+
* game.texture = new me.TextureAtlas(
|
|
75
|
+
* me.loader.getJSON("scene"),
|
|
76
|
+
* me.loader.getImage("scene"),
|
|
77
|
+
* { normalMap: me.loader.getImage("scene_n") }
|
|
78
|
+
* );
|
|
71
79
|
*/
|
|
72
|
-
constructor(atlases: object | object[], src?: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | CompressedImage | string | OffscreenCanvas[] | HTMLImageElement[] | HTMLCanvasElement[] | string[],
|
|
80
|
+
constructor(atlases: object | object[], src?: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | CompressedImage | string | OffscreenCanvas[] | HTMLImageElement[] | HTMLCanvasElement[] | string[], options?: boolean | object);
|
|
73
81
|
/**
|
|
74
82
|
* to identify the atlas format (e.g. texture packer)
|
|
75
83
|
* @ignore
|
|
@@ -81,6 +89,14 @@ export class TextureAtlas {
|
|
|
81
89
|
* @ignore
|
|
82
90
|
*/
|
|
83
91
|
sources: Map<any, any>;
|
|
92
|
+
/**
|
|
93
|
+
* paired normal-map source(s), keyed identically to `sources`.
|
|
94
|
+
* Populated from the constructor's `options.normalMap`. Used by
|
|
95
|
+
* the WebGL renderer's lit pipeline for per-pixel lighting.
|
|
96
|
+
* @type {Map}
|
|
97
|
+
* @ignore
|
|
98
|
+
*/
|
|
99
|
+
normalSources: Map<any, any>;
|
|
84
100
|
/**
|
|
85
101
|
* the atlas dictionnaries
|
|
86
102
|
* @type {Map}
|
|
@@ -122,6 +138,14 @@ export class TextureAtlas {
|
|
|
122
138
|
* @returns {HTMLImageElement|HTMLCanvasElement}
|
|
123
139
|
*/
|
|
124
140
|
getTexture(region?: object): HTMLImageElement | HTMLCanvasElement;
|
|
141
|
+
/**
|
|
142
|
+
* Return the paired normal-map texture for the given region, or `null`
|
|
143
|
+
* if no normal map was provided to this atlas. The normal map shares
|
|
144
|
+
* the same UV layout as the color texture returned by {@link TextureAtlas#getTexture}.
|
|
145
|
+
* @param {object} [region] - region name in case of multipack textures
|
|
146
|
+
* @returns {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|null}
|
|
147
|
+
*/
|
|
148
|
+
getNormalTexture(region?: object): HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | null;
|
|
125
149
|
/**
|
|
126
150
|
* add a region to the atlas
|
|
127
151
|
* @param {string} name - region mame
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atlas.d.ts","sourceRoot":"","sources":["../../../src/video/texture/atlas.js"],"names":[],"mappings":"AASA;;;GAGG;AAEH;;;GAGG;AACH;;;;;;;;;;;;;;;;;;;EAoBC;AAED;;;GAGG;AACH,+FAYC;AAED;;;;;;;;;;GAUG;AACH;IACC
|
|
1
|
+
{"version":3,"file":"atlas.d.ts","sourceRoot":"","sources":["../../../src/video/texture/atlas.js"],"names":[],"mappings":"AASA;;;GAGG;AAEH;;;GAGG;AACH;;;;;;;;;;;;;;;;;;;EAoBC;AAED;;;GAGG;AACH,+FAYC;AAED;;;;;;;;;;GAUG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,qBAjCW,MAAM,GAAC,MAAM,EAAE,QACf,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,eAAe,GAAC,MAAM,GAAC,eAAe,EAAE,GAAC,gBAAgB,EAAE,GAAC,iBAAiB,EAAE,GAAC,MAAM,EAAE,YAC3I,OAAO,GAAC,MAAM,EAsOxB;IAjMA;;;OAGG;IACH,sBAAkB;IAElB;;;;OAIG;IACH,uBAAwB;IAExB;;;;;;OAMG;IACH,6BAA8B;IAE9B;;;;OAIG;IACH,uBAAwB;IAExB;;;;OAIG;IACH,2BAA4B;IAE5B;;;OAGG;IACH;;;;;;MAA6D;IAW1D,YAA8C;IAgJlD;;;;OAIG;IACH,gBAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;OAGG;IACH,aAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACJ,gBAAgB,GAAC,iBAAiB,CAQ9C;IAED;;;;;;OAMG;IACH,0BAHW,MAAM,GACJ,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,GAAC,IAAI,CAU/E;IAED;;;;;;;;OAQG;IACH,gBAPW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAmBlB;IAED;;;;;OAKG;IACH,gBAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAiBlB;IAED;;;;;;;OAOG;IACH,aANW,MAAM,GAAC,MAAM,OACb,MAAM,OACN,MAAM,OACN,MAAM,GACJ,YAAY,CAsCxB;IAED;;;;;;;OAOG;IACH,cANW,MAAM,QACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ,YAAY,CAoBxB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,2BA1BW,MAAM,aACN,MAAM,cACN,OAAO,GACL,MAAM,GAAC,eAAe,CAqClC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,6BAnBW,MAAM,EAAE,GAAC,MAAM,EAAE,GAGf,MAAM,CAyElB;IAED,2DA2CC;CACD;mBAtqBkB,8BAA8B;iCAQjB,uCAAuC"}
|
|
@@ -103,10 +103,10 @@ export class Batcher {
|
|
|
103
103
|
glVertexBuffer: WebGLBuffer | null | undefined;
|
|
104
104
|
/**
|
|
105
105
|
* the dynamic index buffer (only for indexed batchers)
|
|
106
|
-
* @type {
|
|
106
|
+
* @type {WebGLIndexBuffer|null}
|
|
107
107
|
* @ignore
|
|
108
108
|
*/
|
|
109
|
-
indexBuffer:
|
|
109
|
+
indexBuffer: WebGLIndexBuffer | null | undefined;
|
|
110
110
|
/**
|
|
111
111
|
* Reset batcher internal state
|
|
112
112
|
* @ignore
|
|
@@ -116,6 +116,12 @@ export class Batcher {
|
|
|
116
116
|
* called by the WebGL renderer when a batcher becomes the current one
|
|
117
117
|
*/
|
|
118
118
|
bind(): void;
|
|
119
|
+
/**
|
|
120
|
+
* called by the WebGL renderer when this batcher is being replaced by another.
|
|
121
|
+
* Disables this batcher's vertex attribute locations so they don't leak across
|
|
122
|
+
* (otherwise stale stride/offset state can cause INVALID_OPERATION on the next draw).
|
|
123
|
+
*/
|
|
124
|
+
unbind(): void;
|
|
119
125
|
/**
|
|
120
126
|
* Select the shader to use for compositing
|
|
121
127
|
* @see GLShader
|
|
@@ -151,8 +157,8 @@ export class Batcher {
|
|
|
151
157
|
}
|
|
152
158
|
export default Batcher;
|
|
153
159
|
import GLShader from "../glshader.js";
|
|
154
|
-
import VertexArrayBuffer from "
|
|
155
|
-
import
|
|
160
|
+
import VertexArrayBuffer from "../../buffer/vertex.js";
|
|
161
|
+
import WebGLIndexBuffer from "../buffer/index.js";
|
|
156
162
|
import type { Matrix3d } from "../../../math/matrix3d.ts";
|
|
157
163
|
import type WebGLRenderer from "./../webgl_renderer.js";
|
|
158
164
|
//# sourceMappingURL=batcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/batcher.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH;IACC;;;;;;;;;;;;;;;OAeG;IACH,sBAfW,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,EAGA;IAED;;;OAGG;IACH,yCA6HC;IA3HA,cAAwB;IAGxB,QAAqB;IAGrB,gBAA2C;IAE3C;;;OAGG;IACH,oCAA8B;IAE9B;;;OAGG;IACH,oCAA8B;IAE9B;;;;OAIG;IACH,yBAA6B;IAE7B;;;;OAIG;IACH,iCAAoB;IAEpB;;;;;OAKG;IACH,2BAAe;IAEf;;;;;OAKG;IACH,+BAAmB;IAEnB;;;OAGG;IACH,0CAAsB;IAqCtB;;;OAGG;IACH,sCAA0E;IAE1E;;;OAGG;IACH,oCAA+C;IAE/C;;;;OAIG;IACH,+CAA0B;IAE1B;;;;OAIG;IACH,
|
|
1
|
+
{"version":3,"file":"batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/batcher.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH;IACC;;;;;;;;;;;;;;;OAeG;IACH,sBAfW,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,EAGA;IAED;;;OAGG;IACH,yCA6HC;IA3HA,cAAwB;IAGxB,QAAqB;IAGrB,gBAA2C;IAE3C;;;OAGG;IACH,oCAA8B;IAE9B;;;OAGG;IACH,oCAA8B;IAE9B;;;;OAIG;IACH,yBAA6B;IAE7B;;;;OAIG;IACH,iCAAoB;IAEpB;;;;;OAKG;IACH,2BAAe;IAEf;;;;;OAKG;IACH,+BAAmB;IAEnB;;;OAGG;IACH,0CAAsB;IAqCtB;;;OAGG;IACH,sCAA0E;IAE1E;;;OAGG;IACH,oCAA+C;IAE/C;;;;OAIG;IACH,+CAA0B;IAE1B;;;;OAIG;IACH,iDAAuB;IAUxB;;;OAGG;IACH,cAUC;IAED;;OAEG;IACH,aAYC;IAED;;;;OAIG;IACH,eAaC;IAED;;;;OAIG;IACH,kBAFW,QAAQ,QA8BlB;IAHE,uCAA4B;IAK/B;;;;;;;OAOG;IACH,mBANW,MAAM,QACN,MAAM,QACN,MAAM,cACN,OAAO,UACP,MAAM,QA+BhB;IAED;;;OAGG;IACH,sBAFW,QAAQ,QAIlB;IAED;;;;OAIG;IACH,oBAFW,MAAM,EAAE,QAOlB;IAED;;;OAGG;IACH,aAFW,MAAM,QAyEhB;CACD;;qBA7YoB,gBAAgB;8BAFP,wBAAwB;6BACzB,oBAAoB;8BAMtB,2BAA2B;+BADxB,wBAAwB"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* additional import for TypeScript
|
|
3
|
+
* @import {TextureAtlas} from "./../../texture/atlas.js";
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Lit-aware variant of `QuadBatcher` for the SpriteIlluminator workflow.
|
|
7
|
+
*
|
|
8
|
+
* Adds a 5th vertex attribute (`aNormalTextureId`) so each quad knows
|
|
9
|
+
* which paired normal-map sampler to read, and bundles the per-frame
|
|
10
|
+
* light uniforms (`uLightPos`, `uLightColor`, `uLightHeight`, `uAmbient`)
|
|
11
|
+
* that the lit fragment shader iterates.
|
|
12
|
+
*
|
|
13
|
+
* Texture-slot capacity is halved relative to `QuadBatcher` because each
|
|
14
|
+
* sprite may need a paired (color, normal) sampler — color goes to unit
|
|
15
|
+
* `n`, normal to unit `maxBatchTextures + n`. The `WebGLRenderer` only
|
|
16
|
+
* dispatches sprites here when the scene actually needs lighting (active
|
|
17
|
+
* `Light2d` AND the sprite has a `normalMap`); unlit sprites stay on
|
|
18
|
+
* `QuadBatcher` and pay nothing.
|
|
19
|
+
* @category Rendering
|
|
20
|
+
*/
|
|
21
|
+
export default class LitQuadBatcher extends QuadBatcher {
|
|
22
|
+
/**
|
|
23
|
+
* normal-map texture per color slot — keyed by the same unit index as
|
|
24
|
+
* `boundTextures`. Used by `addQuad` to detect when a normal-map slot
|
|
25
|
+
* needs (re-)uploading, mirroring the color-texture cache.
|
|
26
|
+
* @type {Array<HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|null>}
|
|
27
|
+
* @ignore
|
|
28
|
+
*/
|
|
29
|
+
boundNormalMaps: (ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | null)[] | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Map from a normal-map source image to its GL texture object.
|
|
32
|
+
* @type {Map<HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap, WebGLTexture>}
|
|
33
|
+
* @ignore
|
|
34
|
+
*/
|
|
35
|
+
normalMapTextures: Map<ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas, WebGLTexture> | undefined;
|
|
36
|
+
_lightCount: number | undefined;
|
|
37
|
+
_maxLights: number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Bind the paired normal sampler uniforms (`uNormalSampler0..N-1`)
|
|
40
|
+
* to texture units `maxBatchTextures..2*maxBatchTextures-1`. Called
|
|
41
|
+
* from `init` and `reset`.
|
|
42
|
+
* @ignore
|
|
43
|
+
*/
|
|
44
|
+
bindNormalSamplers(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Upload per-frame Light2d uniforms used by the lit fragment path.
|
|
47
|
+
* Called once per camera per frame (before the world tree walk).
|
|
48
|
+
* Lights past `MAX_LIGHTS` are silently ignored.
|
|
49
|
+
*
|
|
50
|
+
* Coordinates must be supplied in the same space as the renderer's
|
|
51
|
+
* pre-projection vertex coords (i.e. camera-local / FBO-local),
|
|
52
|
+
* matching `Stage.drawLighting`'s convention.
|
|
53
|
+
* @param {object} uniforms
|
|
54
|
+
* @param {Float32Array} uniforms.positions - flat array of `[x, y, radius, intensity]` per light, length = 4 * count
|
|
55
|
+
* @param {Float32Array} uniforms.colors - flat array of `[r, g, b]` per light, length = 3 * count
|
|
56
|
+
* @param {Float32Array} [uniforms.heights] - flat array of per-light height, length = MAX_LIGHTS
|
|
57
|
+
* @param {number} uniforms.count - number of lights to render (clamped to MAX_LIGHTS)
|
|
58
|
+
* @param {number[]} [uniforms.ambient] - `[r, g, b]` ambient floor (0..1 each)
|
|
59
|
+
*/
|
|
60
|
+
setLightUniforms(uniforms: {
|
|
61
|
+
positions: Float32Array;
|
|
62
|
+
colors: Float32Array;
|
|
63
|
+
heights?: Float32Array<ArrayBufferLike> | undefined;
|
|
64
|
+
count: number;
|
|
65
|
+
ambient?: number[] | undefined;
|
|
66
|
+
}): void;
|
|
67
|
+
/**
|
|
68
|
+
* Bind a normal-map image to the given GL texture unit. Uploads on
|
|
69
|
+
* first use (via `uploadNormalMap`) and rebinds the cached
|
|
70
|
+
* `WebGLTexture` on subsequent calls. Mirrors the
|
|
71
|
+
* `bindTexture2D` / `createTexture2D` split used by `MaterialBatcher`,
|
|
72
|
+
* but for normal-map textures which live outside the color
|
|
73
|
+
* `TextureCache` (cached per-image in `normalMapTextures`).
|
|
74
|
+
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} image - normal-map source
|
|
75
|
+
* @param {number} unit - GL texture unit (already offset by `maxBatchTextures`)
|
|
76
|
+
*/
|
|
77
|
+
bindNormalMap(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, unit: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Upload a normal-map image to GL and cache the resulting `WebGLTexture`
|
|
80
|
+
* for future `bindNormalMap` calls. Not meant to be called directly —
|
|
81
|
+
* `bindNormalMap` invokes this on the first use of a given image.
|
|
82
|
+
*
|
|
83
|
+
* `premultipliedAlpha = false` — normal maps store linear-encoded
|
|
84
|
+
* surface normals; multiplying through alpha would corrupt the
|
|
85
|
+
* encoding for any non-opaque texel.
|
|
86
|
+
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} image - normal-map source
|
|
87
|
+
* @param {number} unit - GL texture unit (already offset by `maxBatchTextures`)
|
|
88
|
+
*/
|
|
89
|
+
uploadNormalMap(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, unit: number): void;
|
|
90
|
+
/**
|
|
91
|
+
* Add a textured quad with optional paired normal map.
|
|
92
|
+
* @param {TextureAtlas} texture - Source texture atlas
|
|
93
|
+
* @param {number} x - Destination x-coordinate
|
|
94
|
+
* @param {number} y - Destination y-coordinate
|
|
95
|
+
* @param {number} w - Destination width
|
|
96
|
+
* @param {number} h - Destination height
|
|
97
|
+
* @param {number} u0 - Texture UV (u0) value
|
|
98
|
+
* @param {number} v0 - Texture UV (v0) value
|
|
99
|
+
* @param {number} u1 - Texture UV (u1) value
|
|
100
|
+
* @param {number} v1 - Texture UV (v1) value
|
|
101
|
+
* @param {number} tint - tint color (UINT32 argb)
|
|
102
|
+
* @param {boolean} [reupload=false] - Force the texture to be reuploaded
|
|
103
|
+
* @param {HTMLImageElement|HTMLCanvasElement|null} [normalMap=null] - paired normal-map (SpriteIlluminator workflow)
|
|
104
|
+
*/
|
|
105
|
+
addQuad(texture: TextureAtlas, x: number, y: number, w: number, h: number, u0: number, v0: number, u1: number, v1: number, tint: number, reupload?: boolean, normalMap?: HTMLImageElement | HTMLCanvasElement | null): void;
|
|
106
|
+
}
|
|
107
|
+
import QuadBatcher from "./quad_batcher.js";
|
|
108
|
+
import type { TextureAtlas } from "./../../texture/atlas.js";
|
|
109
|
+
//# sourceMappingURL=lit_quad_batcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit_quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/lit_quad_batcher.js"],"names":[],"mappings":"AAKA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AACH;IAoEE;;;;;;OAMG;IACH,6GAAmD;IAEnD;;;;OAIG;IACH,uHAAkC;IAElC,gCAAoB;IACpB,+BAA4B;IAK7B;;;;;OAKG;IACH,2BAOC;IAsBD;;;;;;;;;;;;;;OAcG;IACH,2BANG;QAA+B,SAAS,EAAhC,YAAY;QACW,MAAM,EAA7B,YAAY;QACY,OAAO;QACd,KAAK,EAAtB,MAAM;QACc,OAAO;KACrC,QAgBA;IAED;;;;;;;;;OASG;IACH,qBAHW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,QAC9D,MAAM,QAahB;IAED;;;;;;;;;;OAUG;IACH,uBAHW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,QAC9D,MAAM,QAiBhB;IAED;;;;;;;;;;;;;;OAcG;IACH,iBAbW,YAAY,KACZ,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QACN,MAAM,aACN,OAAO,cACP,gBAAgB,GAAC,iBAAiB,GAAC,IAAI,QA0EjD;CAwDD;wBAtXoC,mBAAmB;kCAIzB,0BAA0B"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* additional import for TypeScript
|
|
3
|
+
* @import {TextureAtlas} from "./../../texture/atlas.js";
|
|
4
|
+
*/
|
|
5
|
+
export const V_ARRAY: Vector2d[];
|
|
1
6
|
/**
|
|
2
7
|
* A WebGL Compositor object. This class handles all of the WebGL state<br>
|
|
3
8
|
* Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU
|
|
@@ -22,14 +27,39 @@ export default class QuadBatcher extends MaterialBatcher {
|
|
|
22
27
|
* @ignore
|
|
23
28
|
*/
|
|
24
29
|
useMultiTexture: boolean | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* (Re-)create the index buffer for quad batching (4 verts + 6 indices per quad).
|
|
32
|
+
* Called from `init` and `reset` (after context loss).
|
|
33
|
+
* @ignore
|
|
34
|
+
*/
|
|
35
|
+
createIndexBuffer(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Bind the color sampler uniforms (`uSampler0..uSamplerN-1`) to their
|
|
38
|
+
* respective texture units. Called from `init` and `reset`.
|
|
39
|
+
* @ignore
|
|
40
|
+
*/
|
|
41
|
+
bindColorSamplers(): void;
|
|
25
42
|
/**
|
|
26
43
|
* Select the shader to use for compositing.
|
|
27
44
|
* Multi-texture batching is automatically enabled when the default
|
|
28
45
|
* shader is active, and disabled for custom ShaderEffect shaders.
|
|
29
46
|
* @see GLShader
|
|
30
|
-
* @
|
|
47
|
+
* @see ShaderEffect
|
|
48
|
+
* @param {GLShader|ShaderEffect} shader - a reference to a GLShader or ShaderEffect instance
|
|
49
|
+
*/
|
|
50
|
+
useShader(shader: GLShader | ShaderEffect): void;
|
|
51
|
+
/**
|
|
52
|
+
* Draw a screen-aligned quad with the given raw WebGL texture through the given shader.
|
|
53
|
+
* Binds the texture to unit 0, pushes 4 vertices (Y-flipped UVs), flushes,
|
|
54
|
+
* then unbinds the texture.
|
|
55
|
+
* @param {WebGLTexture} source - the raw GL texture to blit
|
|
56
|
+
* @param {number} x - destination x
|
|
57
|
+
* @param {number} y - destination y
|
|
58
|
+
* @param {number} width - destination width
|
|
59
|
+
* @param {number} height - destination height
|
|
60
|
+
* @param {GLShader|ShaderEffect} shader - the shader effect to apply
|
|
31
61
|
*/
|
|
32
|
-
|
|
62
|
+
blitTexture(source: WebGLTexture, x: number, y: number, width: number, height: number, shader: GLShader | ShaderEffect): void;
|
|
33
63
|
/**
|
|
34
64
|
* Add a textured quad
|
|
35
65
|
* @param {TextureAtlas} texture - Source texture atlas
|
|
@@ -42,10 +72,11 @@ export default class QuadBatcher extends MaterialBatcher {
|
|
|
42
72
|
* @param {number} u1 - Texture UV (u1) value.
|
|
43
73
|
* @param {number} v1 - Texture UV (v1) value.
|
|
44
74
|
* @param {number} tint - tint color to be applied to the texture in UINT32 (argb) format
|
|
45
|
-
* @param {boolean} reupload - Force the texture to be reuploaded even if already bound
|
|
75
|
+
* @param {boolean} [reupload=false] - Force the texture to be reuploaded even if already bound
|
|
46
76
|
*/
|
|
47
77
|
addQuad(texture: TextureAtlas, x: number, y: number, w: number, h: number, u0: number, v0: number, u1: number, v1: number, tint: number, reupload?: boolean): void;
|
|
48
78
|
}
|
|
79
|
+
import { Vector2d } from "../../../math/vector2d.ts";
|
|
49
80
|
import { MaterialBatcher } from "./material_batcher.js";
|
|
50
81
|
import type { TextureAtlas } from "./../../texture/atlas.js";
|
|
51
82
|
//# sourceMappingURL=quad_batcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/quad_batcher.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/quad_batcher.js"],"names":[],"mappings":"AAMA;;;GAGG;AAMH,iCAKE;AAEF;;;;GAIG;AACH;IACC;;;OAGG;IACH,0BAwDC;IAvDA;;;;OAIG;IACH,qCAA0D;IAyC1D;;;;;OAKG;IACH,qCAA2B;IAK5B;;;;OAIG;IACH,0BAQC;IAED;;;;OAIG;IACH,0BAIC;IAED;;;;;;;OAOG;IACH,kBAFW,QAAQ,GAAC,YAAY,QAK/B;IAoDD;;;;;;;;;;OAUG;IACH,oBAPW,YAAY,KACZ,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,UACN,QAAQ,GAAC,YAAY,QAoD/B;IAED;;;;;;;;;;;;;OAaG;IACH,iBAZW,YAAY,KACZ,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QACN,MAAM,aACN,OAAO,QAqDjB;CACD;yBApTwB,2BAA2B;gCAIpB,uBAAuB;kCAIxB,0BAA0B"}
|