melonjs 19.2.0 → 19.4.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 +13 -10
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +1 -0
- package/build/application/defaultApplicationSettings.d.ts.map +1 -1
- package/build/application/settings.d.ts +12 -0
- package/build/application/settings.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/index.js +2665 -629
- package/build/index.js.map +4 -4
- package/build/input/pointerevent.d.ts.map +1 -1
- package/build/level/tiled/TMXLayer.d.ts +72 -5
- package/build/level/tiled/TMXLayer.d.ts.map +1 -1
- package/build/level/tiled/TMXTile.d.ts +19 -1
- package/build/level/tiled/TMXTile.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/level/tiled/TMXTileset.d.ts +15 -0
- package/build/level/tiled/TMXTileset.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +7 -1
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +7 -1
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +7 -1
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.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/sat.d.ts.map +1 -1
- package/build/physics/world.d.ts +16 -0
- package/build/physics/world.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.map +1 -1
- package/build/renderable/light2d.d.ts +128 -18
- package/build/renderable/light2d.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +38 -6
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/state/stage.d.ts +65 -9
- package/build/state/stage.d.ts.map +1 -1
- package/build/utils/function.d.ts +1 -1
- package/build/utils/function.d.ts.map +1 -1
- package/build/video/buffer/vertex.d.ts +2 -1
- package/build/video/buffer/vertex.d.ts.map +1 -1
- 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 +77 -1
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/renderstate.d.ts +20 -0
- package/build/video/renderstate.d.ts.map +1 -1
- package/build/video/texture/atlas.d.ts +26 -2
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts.map +1 -1
- package/build/video/texture/resource.d.ts +113 -0
- package/build/video/texture/resource.d.ts.map +1 -0
- package/build/video/webgl/batchers/batcher.d.ts +6 -0
- 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/material_batcher.d.ts +8 -1
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts +19 -1
- package/build/video/webgl/batchers/quad_batcher.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/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/renderers/tmxlayer/orthogonal.d.ts +108 -0
- package/build/video/webgl/renderers/tmxlayer/orthogonal.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/utils/attributes.d.ts +7 -0
- package/build/video/webgl/utils/attributes.d.ts.map +1 -1
- package/build/video/webgl/utils/precision.d.ts +1 -1
- package/build/video/webgl/utils/precision.d.ts.map +1 -1
- package/build/video/webgl/utils/uniforms.d.ts +13 -0
- package/build/video/webgl/utils/uniforms.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts +36 -0
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* additional import for TypeScript
|
|
3
3
|
* @import {Vector2d} from "../math/vector2d.js";
|
|
4
|
-
* @import
|
|
5
|
-
* @import WebGLRenderer from "./../video/webgl/webgl_renderer.js";
|
|
4
|
+
* @import Renderer from "./../video/renderer.js";
|
|
6
5
|
*/
|
|
7
6
|
/**
|
|
8
7
|
* An object to display a fixed or animated sprite on screen.
|
|
@@ -22,6 +21,7 @@ export default class Sprite extends Renderable {
|
|
|
22
21
|
* @param {number} [settings.flipX] - flip the sprite on the horizontal axis
|
|
23
22
|
* @param {number} [settings.flipY] - flip the sprite on the vertical axis
|
|
24
23
|
* @param {Vector2d} [settings.anchorPoint={x:0.5, y:0.5}] - Anchor point to draw the frame at (defaults to the center of the frame).
|
|
24
|
+
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|string} [settings.normalMap] - optional normal-map texture used for per-pixel lighting (SpriteIlluminator-style). Same layout/UVs as `settings.image`. When omitted (default), the sprite renders unlit and pays no extra cost. Ignored by the Canvas renderer. Note: `HTMLVideoElement` is intentionally not supported — normal maps encode static surface directions in RGB, and the engine caches the GL texture per image reference (a video would freeze on frame 0).
|
|
25
25
|
* @example
|
|
26
26
|
* // create a single sprite from a standalone image, with anchor in the center
|
|
27
27
|
* let sprite = new me.Sprite(0, 0, {
|
|
@@ -61,6 +61,7 @@ export default class Sprite extends Renderable {
|
|
|
61
61
|
flipX?: number | undefined;
|
|
62
62
|
flipY?: number | undefined;
|
|
63
63
|
anchorPoint?: Vector2d | undefined;
|
|
64
|
+
normalMap?: string | ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | undefined;
|
|
64
65
|
});
|
|
65
66
|
/**
|
|
66
67
|
* @type {boolean}
|
|
@@ -95,6 +96,12 @@ export default class Sprite extends Renderable {
|
|
|
95
96
|
* @type {TextureAtlas}
|
|
96
97
|
*/
|
|
97
98
|
source: TextureAtlas;
|
|
99
|
+
/**
|
|
100
|
+
* backing field for the `normalMap` accessor — see the getter/setter
|
|
101
|
+
* defined on the class for the public API and validation rules.
|
|
102
|
+
* @ignore
|
|
103
|
+
*/
|
|
104
|
+
_normalMap: ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | null;
|
|
98
105
|
anim: {};
|
|
99
106
|
resetAnim: Function | (() => Sprite) | undefined;
|
|
100
107
|
current: {
|
|
@@ -127,6 +134,19 @@ export default class Sprite extends Renderable {
|
|
|
127
134
|
* @ignore
|
|
128
135
|
*/
|
|
129
136
|
removeStatePauseListener: (() => void) | undefined;
|
|
137
|
+
set normalMap(value: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | null);
|
|
138
|
+
/**
|
|
139
|
+
* The optional normal-map image paired with this sprite's color
|
|
140
|
+
* texture (SpriteIlluminator workflow). When set, the WebGL
|
|
141
|
+
* renderer's lit pipeline samples this texture for per-pixel
|
|
142
|
+
* lighting using `Stage._activeLights`. `null` when unlit.
|
|
143
|
+
* Setting any non-image value (or anything without numeric
|
|
144
|
+
* `width`/`height`) throws — assign `null` to clear.
|
|
145
|
+
*
|
|
146
|
+
* Silently ignored by the Canvas renderer.
|
|
147
|
+
* @type {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|null}
|
|
148
|
+
*/
|
|
149
|
+
get normalMap(): HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | null;
|
|
130
150
|
atlasIndices: any;
|
|
131
151
|
/**
|
|
132
152
|
* return the flickering state of the object
|
|
@@ -271,12 +291,25 @@ export default class Sprite extends Renderable {
|
|
|
271
291
|
* @returns {number} if using number indices. Returns {object} containing frame data if using texture atlas
|
|
272
292
|
*/
|
|
273
293
|
getAnimationFrameObjectByIndex(id: number): number;
|
|
294
|
+
/**
|
|
295
|
+
* Prepare the rendering context before drawing this sprite (automatically called by melonJS).
|
|
296
|
+
* Extends `Renderable.preDraw` to publish this sprite's `normalMap` (if any)
|
|
297
|
+
* on the renderer so the WebGL lit pipeline can pair it with the next
|
|
298
|
+
* `drawImage` call. Cleared back in `postDraw`.
|
|
299
|
+
* @param {Renderer} renderer - a renderer instance
|
|
300
|
+
*/
|
|
301
|
+
preDraw(renderer: Renderer): void;
|
|
302
|
+
/**
|
|
303
|
+
* restore the rendering context after drawing this sprite (automatically called by melonJS).
|
|
304
|
+
* @param {Renderer} renderer - a renderer instance
|
|
305
|
+
*/
|
|
306
|
+
postDraw(renderer: Renderer): void;
|
|
274
307
|
/**
|
|
275
308
|
* draw this sprite (automatically called by melonJS)
|
|
276
|
-
* @param {
|
|
309
|
+
* @param {Renderer} renderer - a renderer instance
|
|
277
310
|
* @param {Camera2d} [viewport] - the viewport to (re)draw
|
|
278
311
|
*/
|
|
279
|
-
draw(renderer:
|
|
312
|
+
draw(renderer: Renderer): void;
|
|
280
313
|
/**
|
|
281
314
|
* Destroy function<br>
|
|
282
315
|
* @ignore
|
|
@@ -286,7 +319,6 @@ export default class Sprite extends Renderable {
|
|
|
286
319
|
import Renderable from "./renderable.js";
|
|
287
320
|
import type { Vector2d } from "../math/vector2d.js";
|
|
288
321
|
import { TextureAtlas } from "./../video/texture/atlas.js";
|
|
289
|
-
import type
|
|
290
|
-
import type WebGLRenderer from "./../video/webgl/webgl_renderer.js";
|
|
322
|
+
import type Renderer from "./../video/renderer.js";
|
|
291
323
|
import { Color } from "../math/color.ts";
|
|
292
324
|
//# sourceMappingURL=sprite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprite.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite.js"],"names":[],"mappings":"AAWA
|
|
1
|
+
{"version":3,"file":"sprite.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite.js"],"names":[],"mappings":"AAWA;;;;GAIG;AAEH;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACH,eA1CW,MAAM,KACN,MAAM,YAEd;QAA0G,KAAK,EAAvG,gBAAgB,GAAC,iBAAiB,GAAC,gBAAgB,GAAC,YAAY,GAAC,eAAe,GAAC,MAAM;QACrE,IAAI;QACJ,MAAM;QACN,UAAU;QACV,WAAW;QACL,IAAI;QACV,KAAK;QACL,KAAK;QACH,WAAW;QACkD,SAAS;KAClG,EA6SF;IA5QA;;;OAGG;IACH,gBAHU,OAAO,CAGU;IAE3B;;;;OAIG;IACH,gBAHU,MAAM,CAGS;IAEzB;;;;OAIG;IACH,QAHU,QAAQ,CAGkB;IAEpC;;;;OAIG;IACH,SAHU,OAAO,CAGG;IAEpB;;;;OAIG;IAGH;;;OAGG;IACH,QAFU,YAAY,CAEJ;IAElB;;;;OAIG;IACH,wFAAsB;IAGtB,SAAc;IAGd,iDAA0B;IAI1B;;;;;;;;;MAgBC;IAGD,WAAW;IAEX;;;OAGG;IACH;;;;;MAKC;IAKA,WAAqC;IACrC,kBAAkC;IAiCjC,WAG8C;IAC9C,YAGgD;IAOhD;;;OAGG;IACH,mDAEE;IA4IL,qBALU,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,GAAC,IAAI,EA+B5E;IAxCD;;;;;;;;;;OAUG;IACH,iBAFU,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,GAAC,IAAI,CAI5E;IAxEC,kBAAyC;IAqG3C;;;OAGG;IACH,gBAFa,OAAO,CAInB;IAED;;OAEG;IACH,aAEC;IAED;;OAEG;IACH,cAEC;IAED;;;;;;;;;;;OAWG;IACH,kBAVW,MAAM,wBAEJ,MAAM,CAoBlB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,mBAzBW,MAAM,SACN,MAAM,EAAE,GAAC,MAAM,EAAE,GAAC,MAAM,EAAE,mBAC1B,MAAM,GACJ,MAAM,CAuFlB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,0BAlCW,MAAM,cACN,MAAM,WAAS,gBACf,OAAO,GACL,MAAM,CA0DlB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,GACJ,MAAM,CAWlB;IAED;;;;;;;;OAQG;IACH,yBAPW,MAAM,GACJ,OAAO,CAQnB;IAED;;;;;;;;OAQG;IACH,kBANW,MAAM,GACJ,MAAM,CAoDlB;IAED;;;;;;;OAOG;IACH,0BANW,MAAM,GACJ,MAAM,CAUlB;IAED;;;OAGG;IACH,4BAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,mCAHW,MAAM,GACJ,MAAM,CAIlB;IAyED;;;;;;OAMG;IACH,kBAFW,QAAQ,QAWlB;IAED;;;OAGG;IACH,mBAFW,QAAQ,QAQlB;IAED;;;;OAIG;IACH,eAHW,QAAQ,QAuDlB;IAED;;;OAGG;IACH,gBAeC;CACD;uBAt3BsB,iBAAiB;8BAOb,qBAAqB;6BARnB,6BAA6B;0BASjC,wBAAwB;sBAZ3B,kBAAkB"}
|
package/build/state/stage.d.ts
CHANGED
|
@@ -25,28 +25,50 @@ export default class Stage {
|
|
|
25
25
|
cameras: Map<string, Camera2d>;
|
|
26
26
|
/**
|
|
27
27
|
* The list of active lights in this stage.
|
|
28
|
-
*
|
|
28
|
+
*
|
|
29
|
+
* Since 19.3.0, `Light2d` is a first-class world Renderable — the
|
|
30
|
+
* recommended pattern is to add lights directly to `app.world` (or any
|
|
31
|
+
* container, including a sprite, so the light follows it via parent
|
|
32
|
+
* transforms). The `lights` Map remains for backward compatibility:
|
|
33
|
+
* any entry added via `this.lights.set(name, light)` in
|
|
34
|
+
* `onResetEvent()` is automatically adopted into the world tree at
|
|
35
|
+
* stage reset time so it renders normally.
|
|
29
36
|
* @see Light2d
|
|
30
37
|
* @see Stage.ambientLight
|
|
31
38
|
* @example
|
|
32
|
-
* //
|
|
33
|
-
* const whiteLight = new Light2d(
|
|
34
|
-
*
|
|
39
|
+
* // recommended:
|
|
40
|
+
* const whiteLight = new Light2d(100, 100, 140, 140, "#fff", 0.7);
|
|
41
|
+
* app.world.addChild(whiteLight);
|
|
42
|
+
*
|
|
43
|
+
* // legacy (still works, auto-adopted into world):
|
|
35
44
|
* this.lights.set("whiteLight", whiteLight);
|
|
36
|
-
*
|
|
45
|
+
*
|
|
37
46
|
* this.ambientLight.parseCSS("#1117");
|
|
38
|
-
* // make the light follow the mouse
|
|
39
|
-
* input.registerPointerEvent("pointermove", app.viewport, (event) => {
|
|
40
|
-
* whiteLight.centerOn(event.gameX, event.gameY);
|
|
41
|
-
* });
|
|
42
47
|
*/
|
|
43
48
|
lights: Map<string, Light2d>;
|
|
49
|
+
/**
|
|
50
|
+
* Internal set of active lights, auto-populated by `Light2d`'s
|
|
51
|
+
* `onActivateEvent` / `onDeactivateEvent` hooks. Used by Camera2d's
|
|
52
|
+
* ambient-overlay pass to compute the cutouts.
|
|
53
|
+
* @ignore
|
|
54
|
+
*/
|
|
55
|
+
_activeLights: Set<Light2d>;
|
|
44
56
|
/**
|
|
45
57
|
* an ambient light that will be added to the stage rendering
|
|
46
58
|
* @default "#000000"
|
|
47
59
|
* @see Light2d
|
|
48
60
|
*/
|
|
49
61
|
ambientLight: Color;
|
|
62
|
+
/**
|
|
63
|
+
* Base light level applied to every normal-mapped sprite in the
|
|
64
|
+
* lit rendering path. Unlike {@link Stage#ambientLight} (which is
|
|
65
|
+
* the dark overlay punched by each light's cutout), this color is
|
|
66
|
+
* added to every lit pixel so unlit areas don't render pure
|
|
67
|
+
* black. Defaults to black (0, 0, 0) — sprites without a
|
|
68
|
+
* `normalMap` ignore it entirely.
|
|
69
|
+
* @default "#000000"
|
|
70
|
+
*/
|
|
71
|
+
ambientLightingColor: Color;
|
|
50
72
|
/**
|
|
51
73
|
* The given constructor options
|
|
52
74
|
*/
|
|
@@ -58,6 +80,17 @@ export default class Stage {
|
|
|
58
80
|
* @param [settings.onDestroyEvent] - called by the state manager before switching to another state
|
|
59
81
|
*/
|
|
60
82
|
constructor(settings?: Partial<StageSettings>);
|
|
83
|
+
/**
|
|
84
|
+
* Called by `Light2d.onActivateEvent` to register the light with the
|
|
85
|
+
* stage's ambient-overlay cutout list. Users normally don't call this.
|
|
86
|
+
* @ignore
|
|
87
|
+
*/
|
|
88
|
+
_registerLight(light: Light2d): void;
|
|
89
|
+
/**
|
|
90
|
+
* Called by `Light2d.onDeactivateEvent` to deregister the light.
|
|
91
|
+
* @ignore
|
|
92
|
+
*/
|
|
93
|
+
_unregisterLight(light: Light2d): void;
|
|
61
94
|
/**
|
|
62
95
|
* Object reset function
|
|
63
96
|
* @ignore
|
|
@@ -72,11 +105,34 @@ export default class Stage {
|
|
|
72
105
|
update(dt: number): boolean;
|
|
73
106
|
/**
|
|
74
107
|
* draw the current stage
|
|
108
|
+
*
|
|
109
|
+
* Lights are rendered as part of the world tree (they're now first-class
|
|
110
|
+
* Renderables) and the ambient overlay pass runs inside each Camera's
|
|
111
|
+
* post-effect FBO bracket via {@link Stage#drawLighting}.
|
|
75
112
|
* @ignore
|
|
76
113
|
* @param renderer - the renderer object to draw with
|
|
77
114
|
* @param world - the world object to draw
|
|
78
115
|
*/
|
|
79
116
|
draw(renderer: Renderer, world: World): void;
|
|
117
|
+
/**
|
|
118
|
+
* Draw the stage's ambient-light overlay with cutouts for each active
|
|
119
|
+
* light. Called from each `Camera2d` inside its post-effect FBO bracket —
|
|
120
|
+
* lights themselves render via the world tree (they're standard
|
|
121
|
+
* Renderables); this pass only paints the dark fill that the lights cut
|
|
122
|
+
* holes through.
|
|
123
|
+
*
|
|
124
|
+
* Subclasses can override this method to implement custom lighting (e.g.
|
|
125
|
+
* per-pixel normal-mapped lighting via a custom shader). Called once per
|
|
126
|
+
* camera per frame.
|
|
127
|
+
* @param renderer - the active renderer
|
|
128
|
+
* @param camera - the camera currently rendering this stage
|
|
129
|
+
* @param translateX - the same world-to-screen X translate that
|
|
130
|
+
* `Camera2d.draw()` applies to the world container (i.e.
|
|
131
|
+
* `camera.pos.x + camera.offset.x` for the default camera, plus
|
|
132
|
+
* the container's own offset for non-default cameras)
|
|
133
|
+
* @param translateY - the world-to-screen Y translate (see `translateX`)
|
|
134
|
+
*/
|
|
135
|
+
drawLighting(renderer: Renderer, camera: Camera2d, translateX?: number, translateY?: number): void;
|
|
80
136
|
/**
|
|
81
137
|
* destroy function
|
|
82
138
|
* @ignore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stage.d.ts","sourceRoot":"","sources":["../../src/state/stage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,iCAAiC,CAAC;AAC/D,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AAEtD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AAEnD,UAAU,aAAa;IACtB,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IAC9D,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;CAC5C;AAUD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,KAAK;IACzB;;;;OAIG;IACH,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,C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C;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI;IAoCtD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAgB3B;;;;;;;;;OASG;IACH,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAM5C;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CACX,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,QAAQ,EAChB,UAAU,GAAE,MAAuC,EACnD,UAAU,GAAE,MAAuC,GACjD,IAAI;IAiCP;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;IAkB/B;;;;;;;OAOG;IACH,YAAY,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAOxD;;;;OAIG;IACH,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;CAMtC"}
|
|
@@ -20,5 +20,5 @@ export declare function defer(func: (...args: unknown[]) => unknown, thisArg: un
|
|
|
20
20
|
* @param [wait] - the delay in ms
|
|
21
21
|
* @returns the function that will be throttled
|
|
22
22
|
*/
|
|
23
|
-
export declare const throttle: (fn: () => void, wait?: number) => (...args:
|
|
23
|
+
export declare const throttle: <T extends unknown[]>(fn: (...args: T) => void, wait?: number) => (...args: T) => void;
|
|
24
24
|
//# sourceMappingURL=function.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/utils/function.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CACpB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EACrC,OAAO,EAAE,OAAO,EAChB,GAAG,IAAI,EAAE,OAAO,EAAE,UAGlB;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/utils/function.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CACpB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EACrC,OAAO,EAAE,OAAO,EAChB,GAAG,IAAI,EAAE,OAAO,EAAE,UAGlB;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,OAAO,EAAE,EAC3C,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,EACxB,OAAM,MAAY,MAKV,GAAG,MAAM,CAAC,SAkBlB,CAAC"}
|
|
@@ -30,9 +30,10 @@ export default class VertexArrayBuffer {
|
|
|
30
30
|
* @param {number} v - texture V coordinate
|
|
31
31
|
* @param {number} tint - tint color in UINT32 (argb) format
|
|
32
32
|
* @param {number} [textureId] - texture unit index for multi-texture batching
|
|
33
|
+
* @param {number} [normalTextureId] - paired normal-map texture unit index, or `-1` for unlit quads
|
|
33
34
|
* @ignore
|
|
34
35
|
*/
|
|
35
|
-
push(x: number, y: number, u: number, v: number, tint: number, textureId?: number): this;
|
|
36
|
+
push(x: number, y: number, u: number, v: number, tint: number, textureId?: number, normalTextureId?: number): this;
|
|
36
37
|
/**
|
|
37
38
|
* push a new vertex with all-float data to the buffer
|
|
38
39
|
* @param {ArrayLike<number>} data - float values for one vertex
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vertex.d.ts","sourceRoot":"","sources":["../../../src/video/buffer/vertex.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;IACC,6CAeC;IAbA,gBAA4B;IAE5B,eAA0B;IAE1B,oBAAoB;IAGpB,oBAEC;IAED,qCAA8C;IAC9C,oCAA6C;IAG9C;;;OAGG;IACH,cAEC;IAED;;;OAGG;IACH,6BAEC;IAED
|
|
1
|
+
{"version":3,"file":"vertex.d.ts","sourceRoot":"","sources":["../../../src/video/buffer/vertex.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;IACC,6CAeC;IAbA,gBAA4B;IAE5B,eAA0B;IAE1B,oBAAoB;IAGpB,oBAEC;IAED,qCAA8C;IAC9C,oCAA6C;IAG9C;;;OAGG;IACH,cAEC;IAED;;;OAGG;IACH,6BAEC;IAED;;;;;;;;;;OAUG;IACH,QATW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QACN,MAAM,cACN,MAAM,oBACN,MAAM,QA4BhB;IAED;;;;;;OAMG;IACH,iBALW,SAAS,CAAC,MAAM,CAAC,aACjB,MAAM,SACN,MAAM,QAahB;IAED;;;OAGG;IACH,kEAaC;IAED;;;OAGG;IACH,2DAMC;IAED;;;OAGG;IACH,yDAMC;CACD"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export default class CanvasRenderer extends Renderer {
|
|
15
15
|
cache: TextureCache;
|
|
16
|
+
_lightCache: WeakMap<object, any> | undefined;
|
|
16
17
|
/**
|
|
17
18
|
* Reset the canvas transform to identity
|
|
18
19
|
*/
|
|
@@ -448,6 +449,7 @@ export default class CanvasRenderer extends Renderer {
|
|
|
448
449
|
* @param {boolean} [invert=false] - either the given shape should define what is visible (default) or the opposite
|
|
449
450
|
*/
|
|
450
451
|
setMask(mask?: Rect | RoundRect | Polygon | Line | Ellipse, invert?: boolean): void;
|
|
452
|
+
_maskInvertOuterAdded: boolean | undefined;
|
|
451
453
|
}
|
|
452
454
|
import Renderer from "./../renderer.js";
|
|
453
455
|
import TextureCache from "./../texture/cache.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/canvas/canvas_renderer.js"],"names":[],"mappings":"AAYA;;;;;;;;GAQG;AAEH;;;GAGG;AACH;IAcE,oBAAmC;
|
|
1
|
+
{"version":3,"file":"canvas_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/canvas/canvas_renderer.js"],"names":[],"mappings":"AAYA;;;;;;;;GAQG;AAEH;;;GAGG;AACH;IAcE,oBAAmC;IA4CnC,8CAA4B;IAG7B;;OAEG;IACH,uBAEC;IAED;;;;;OAKG;IACH,sBAFW,QAAQ,QAclB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,oBAHW,MAAM,GACJ,MAAM,CAqClB;IAWD;;;;OAIG;IACH,mBAHW,KAAK,GAAC,MAAM,WACZ,OAAO,QAajB;IAED;;;;;;OAMG;IACH,aALW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,QAIhB;IAED;;;;;;;;;;;OAWG;IACH,qBAVW,gBAAgB,GAAC,eAAe,GAAC,gBAAgB,GAAC,iBAAiB,GAAC,WAAW,GAAC,eAAe,GAAC,UAAU,UAC1G,MAAM,GACJ,aAAa,CAUzB;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,iBAjBW,gBAAgB,GAAC,eAAe,GAAC,gBAAgB,GAAC,iBAAiB,GAAC,WAAW,GAAC,eAAe,GAAC,UAAU,MAC1G,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAgDhB;IAqED;;;;;;;;OAQG;IACH,qBAPW,aAAa,KACb,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,QAiBhB;IAmCC,oDAAkD;IAqGhD,gDAAwD;IAGxD,2DAA2D;IAkC/D;;;;;;;;;;;;;;;OAeG;IACH,kBAEC;IAED;;;;OAIG;IACH,UAHW,MAAM,KACN,MAAM,QAIhB;IAED;;OAEG;IACH,6BAEC;IAED;;;;;;OAMG;IACH,sBALW,MAAM,OACN,MAAM,KACN,MAAM,KACN,MAAM,QAIhB;IAED;;;;;;;;OAQG;IACH,oBAPW,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM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BAAkB;yBACd,uBAAuB;sBAV1B,uBAAuB;0BActB,iCAAiC;+BAC5B,iCAAiC;6BACnC,6BAA6B;0BAChC,4BAA4B;6BACzB,+BAA+B;8BAC9B,wBAAwB"}
|
|
@@ -101,6 +101,25 @@ export default class Renderer {
|
|
|
101
101
|
maskLevel: number;
|
|
102
102
|
projectionMatrix: Matrix3d;
|
|
103
103
|
uvOffset: number;
|
|
104
|
+
/**
|
|
105
|
+
* The normal-map texture associated with the next `drawImage` call,
|
|
106
|
+
* if any. Set by `Sprite.draw` (and any other normal-map-aware
|
|
107
|
+
* renderable) just before calling `drawImage`, then cleared back
|
|
108
|
+
* to `null` after. The WebGL renderer reads this state and routes
|
|
109
|
+
* lit quads through the shader's lighting path; the Canvas
|
|
110
|
+
* renderer ignores it entirely.
|
|
111
|
+
* @type {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|null}
|
|
112
|
+
*/
|
|
113
|
+
currentNormalMap: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | null;
|
|
114
|
+
/**
|
|
115
|
+
* Number of active `Light2d` instances uploaded to the lit batcher
|
|
116
|
+
* for the current frame. Set by `setLightUniforms`. The WebGL
|
|
117
|
+
* renderer's `drawImage` reads this to decide between the unlit
|
|
118
|
+
* fast-path batcher (default) and the lit batcher (only when
|
|
119
|
+
* lights AND a normal map are both in play).
|
|
120
|
+
* @type {number}
|
|
121
|
+
*/
|
|
122
|
+
activeLightCount: number;
|
|
104
123
|
set currentBlendMode(value: string);
|
|
105
124
|
/**
|
|
106
125
|
* @type {string}
|
|
@@ -242,6 +261,63 @@ export default class Renderer {
|
|
|
242
261
|
* @param {boolean} [premultipliedAlpha=true] - whether textures use premultiplied alpha (WebGL only)
|
|
243
262
|
*/
|
|
244
263
|
setBlendMode(mode?: string): void;
|
|
264
|
+
/**
|
|
265
|
+
* Upload the active scene lights to the lit sprite pipeline.
|
|
266
|
+
*
|
|
267
|
+
* Called once per camera per frame by `Camera2d.draw()` (after the
|
|
268
|
+
* FBO is bound, before the world tree walk fires `Sprite.draw` for
|
|
269
|
+
* any normal-mapped sprite). The WebGL renderer overrides this to
|
|
270
|
+
* pack the lights into the lit shader's uniform buffers; the Canvas
|
|
271
|
+
* renderer cannot do per-pixel normal-map lighting and silently
|
|
272
|
+
* ignores the call. The first time a non-empty light list is passed
|
|
273
|
+
* in Canvas mode, a one-shot console warning is emitted.
|
|
274
|
+
*
|
|
275
|
+
* Stage stays renderer-agnostic by passing the raw scene data —
|
|
276
|
+
* lights iterable and ambient color — and letting the renderer
|
|
277
|
+
* decide how to encode them.
|
|
278
|
+
* @param {Iterable<object>} [lights] - active `Light2d` instances; falsy/empty no-ops
|
|
279
|
+
* @param {object} [ambient] - ambient lighting color (0..255 RGB)
|
|
280
|
+
* @param {number} [translateX=0] - world-to-screen X translate (matches `Camera2d.draw()`)
|
|
281
|
+
* @param {number} [translateY=0] - world-to-screen Y translate
|
|
282
|
+
*/
|
|
283
|
+
setLightUniforms(lights?: Iterable<object>, ambient?: object, translateX?: number, translateY?: number): void;
|
|
284
|
+
_litPipelineWarned: boolean | undefined;
|
|
285
|
+
/**
|
|
286
|
+
* Render a `Light2d` instance.
|
|
287
|
+
*
|
|
288
|
+
* Each renderer implements its own strategy: the WebGL renderer
|
|
289
|
+
* draws lights as quads through a shared procedural radial-falloff
|
|
290
|
+
* fragment shader (no per-light texture, color and intensity
|
|
291
|
+
* encoded in the per-vertex tint so consecutive draws batch); the
|
|
292
|
+
* Canvas renderer caches a small `Gradient` config object per
|
|
293
|
+
* light in a `WeakMap` (rebuilt only when the light's radii /
|
|
294
|
+
* color / intensity change), rasterizes it with `Gradient.toCanvas()`
|
|
295
|
+
* into a single shared `CanvasRenderTarget`, and composites the
|
|
296
|
+
* result via `drawImage`. The base implementation is a no-op so
|
|
297
|
+
* renderers without a lighting path can be polymorphically
|
|
298
|
+
* substituted.
|
|
299
|
+
*
|
|
300
|
+
* Light2d itself is renderer-agnostic — it just calls
|
|
301
|
+
* `renderer.drawLight(this)` and relies on the renderer to pick
|
|
302
|
+
* the right machinery.
|
|
303
|
+
* @param {object} light - the Light2d instance to render
|
|
304
|
+
* @see Light2d
|
|
305
|
+
*/
|
|
306
|
+
drawLight(light: object): void;
|
|
307
|
+
/**
|
|
308
|
+
* Draw a TMX tile layer. Default behavior:
|
|
309
|
+
* - if `layer.canvasRenderer` is set (preRender bake), blit the cached
|
|
310
|
+
* offscreen canvas in a single `drawImage` call;
|
|
311
|
+
* - otherwise delegate to the layer's TMX orientation renderer for
|
|
312
|
+
* the per-tile loop.
|
|
313
|
+
*
|
|
314
|
+
* `WebGLRenderer` overrides this to add the procedural shader fast
|
|
315
|
+
* path on top (when `layer.renderMode === "shader"`) and fall through
|
|
316
|
+
* to this base behavior for all other layers.
|
|
317
|
+
* @param {object} layer - the TMXLayer to draw
|
|
318
|
+
* @param {Rect} rect - the visible region in world coords
|
|
319
|
+
*/
|
|
320
|
+
drawTileLayer(layer: object, rect: Rect): void;
|
|
245
321
|
/**
|
|
246
322
|
* Set the current fill & stroke style color.
|
|
247
323
|
* By default, or upon reset, the value is set to #000000.
|
|
@@ -395,8 +471,8 @@ import Path2D from "./../geometries/path2d.js";
|
|
|
395
471
|
import { Color } from "./../math/color.ts";
|
|
396
472
|
import RenderState from "./renderstate.js";
|
|
397
473
|
import { Matrix3d } from "../math/matrix3d.ts";
|
|
398
|
-
import { Gradient } from "./gradient.js";
|
|
399
474
|
import type { Rect } from "./../geometries/rectangle.ts";
|
|
475
|
+
import { Gradient } from "./gradient.js";
|
|
400
476
|
import type { Bounds } from "./../physics/bounds.ts";
|
|
401
477
|
import type { RoundRect } from "./../geometries/roundrect.ts";
|
|
402
478
|
import type { Polygon } from "../geometries/polygon.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/video/renderer.js"],"names":[],"mappings":"AASA;;GAEG;AAEH;;;;;;;GAOG;AAEH;;;GAGG;AAC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,eAAe;4BAcf,wBAAwB;+BAJrB,8BAA8B;6BAChC,0BAA0B;0BAC7B,yBAAyB;6BACtB,4BAA4B"}
|
|
@@ -82,6 +82,26 @@ export default class RenderState {
|
|
|
82
82
|
* @param {boolean} [scissorTestActive=false] - whether scissor/clip is currently enabled
|
|
83
83
|
*/
|
|
84
84
|
save(scissorTestActive?: boolean): void;
|
|
85
|
+
/**
|
|
86
|
+
* Inspect the scissor box that the next `restore()` would install,
|
|
87
|
+
* without mutating any state. Lets renderers detect whether a
|
|
88
|
+
* pending `restore()` will actually change the scissor (and
|
|
89
|
+
* decide, e.g., whether to flush GPU work first).
|
|
90
|
+
*
|
|
91
|
+
* Returns:
|
|
92
|
+
* - `Int32Array` (length 4) — `[x, y, width, height]` of the
|
|
93
|
+
* saved scissor when scissor was active at the matching `save()`
|
|
94
|
+
* call.
|
|
95
|
+
* - `null` — when the saved state had scissor disabled, or the
|
|
96
|
+
* stack is empty. Treat this as "next scissor will be inactive".
|
|
97
|
+
*
|
|
98
|
+
* The returned array is a **live reference into the internal
|
|
99
|
+
* stack** — zero allocation on a hot path. Callers MUST treat it
|
|
100
|
+
* as read-only; mutating it corrupts subsequent `restore()` calls.
|
|
101
|
+
* @ignore
|
|
102
|
+
* @returns {Int32Array | null}
|
|
103
|
+
*/
|
|
104
|
+
peekScissor(): Int32Array | null;
|
|
85
105
|
/**
|
|
86
106
|
* Restore state from the stack.
|
|
87
107
|
* Color, tint, transform, and scissor are restored in place.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderstate.d.ts","sourceRoot":"","sources":["../../src/video/renderstate.js"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;;;;GAOG;AACH;IAEE;;;OAGG;IACH,cAFU,KAAK,CAE4B;IAE3C;;;OAGG;IACH,aAFU,KAAK,CAEiC;IAEhD;;;OAGG;IACH,kBAFU,QAAQ,CAEoB;IAEtC;;;OAGG;IACH,gBAFU,UAAU,CAEmB;IAEvC;;;OAGG;I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H,oBAAoB;IAEpB,cAAc;IACd,qBAEE;IAEF,cAAc;IACd,oBAEE;IAEF,cAAc;IACd,yBAEE;IAEF,cAAc;IACd,yCAEE;IAEF,cAAc;IACd,sBAAoD;IAEpD,cAAc;IACd,wCAAyD;IAEzD,cAAc;IACd,sBAAoD;IAEpD,cAAc;IACd,mBAAiD;IAEjD,cAAc;IACd,oBAAkD;IAGnD;;;OAGG;IACH,yBAFW,OAAO,QAyBjB;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAFa,UAAU,GAAG,IAAI,CAQ7B;IAED;;;;;;;;OAQG;IACH,qBAJW,MAAM,gBACN,MAAM,GACJ;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAyBhE;IAED;;;;OAIG;IACH,aAHW,MAAM,UACN,MAAM,QAUhB;IAED,sDAAsD;IACtD,oBAiBC;CACD;sBA9OqB,oBAAoB;yBACjB,qBAAqB;8BAGnB,eAAe"}
|
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/video/texture/cache.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/video/texture/cache.js"],"names":[],"mappings":";AAIA;;;GAGG;AACH;IACC;;OAEG;IACH,8CAUC;IARA,cAAwB;IAExB,qBAAgC;IAChC,sBAAuB;IACvB,qBAAsB;IACtB,oBAA0B;IAC1B,iBAAwB;IAIzB;;OAEG;IACH,cAKC;IAED;;OAEG;IACH,8BAuBC;IAED;;;;OAIG;IACH,6BAOC;IAED;;OAEG;IACH,oCAQC;IAED;;OAEG;IACH,2BAMC;IAED;;;OAGG;IACH,4BAGC;IAED;;;OAGG;IACH,yCAEC;IAED;;OAEG;IACH,yBAEC;IAED;;;OAGG;IACH,iCAwCC;IAED;;OAEG;IACH,yBAQC;IAED;;OAEG;IACH,gCAcC;CACD;8BAzM6B,+BAA+B"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A texture data source that knows how to upload itself to a WebGL
|
|
3
|
+
* texture. Subclasses provide the actual upload logic for their kind
|
|
4
|
+
* of source (raw buffer, image, compressed data, etc.).
|
|
5
|
+
*
|
|
6
|
+
* Resources flow through the same `TextureCache` / batcher machinery
|
|
7
|
+
* as image-backed `TextureAtlas` instances: they expose the minimal
|
|
8
|
+
* shape (`sources`, `activeAtlas`, `getTexture()`, plus `width` /
|
|
9
|
+
* `height` / `premultipliedAlpha` / `repeat` / `filter`) the cache
|
|
10
|
+
* uses for unit allocation and the batcher uses for `boundTextures`
|
|
11
|
+
* bookkeeping. The cache therefore owns every `gl.bindTexture` call,
|
|
12
|
+
* which keeps the JS-side binding state in lockstep with the actual
|
|
13
|
+
* GL state across all texture kinds — image atlases included.
|
|
14
|
+
*
|
|
15
|
+
* Subclasses MUST implement `upload(gl, target)`. The framework calls
|
|
16
|
+
* it once per texture on first use (and again on forced re-upload via
|
|
17
|
+
* `batcher.uploadTexture(resource, w, h, true)`).
|
|
18
|
+
*
|
|
19
|
+
* @category Rendering
|
|
20
|
+
*/
|
|
21
|
+
export class TextureResource {
|
|
22
|
+
/**
|
|
23
|
+
* @param {object} options
|
|
24
|
+
* @param {number} options.width - pixel width of the texture
|
|
25
|
+
* @param {number} options.height - pixel height of the texture
|
|
26
|
+
* @param {boolean} [options.premultipliedAlpha=false]
|
|
27
|
+
* @param {string} [options.repeat="no-repeat"] - "no-repeat" | "repeat" | "repeat-x" | "repeat-y"
|
|
28
|
+
* @param {number} [options.filter] - `gl.NEAREST` or `gl.LINEAR`; when
|
|
29
|
+
* omitted the batcher falls back to the renderer's `antiAlias` setting
|
|
30
|
+
*/
|
|
31
|
+
constructor({ width, height, premultipliedAlpha, repeat, filter, }?: {
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
premultipliedAlpha?: boolean | undefined;
|
|
35
|
+
repeat?: string | undefined;
|
|
36
|
+
filter?: number | undefined;
|
|
37
|
+
});
|
|
38
|
+
/** @type {number} */
|
|
39
|
+
width: number;
|
|
40
|
+
/** @type {number} */
|
|
41
|
+
height: number;
|
|
42
|
+
/** @type {boolean} */
|
|
43
|
+
premultipliedAlpha: boolean;
|
|
44
|
+
/** @type {string} */
|
|
45
|
+
repeat: string;
|
|
46
|
+
/** @type {number|undefined} */
|
|
47
|
+
filter: number | undefined;
|
|
48
|
+
sources: Map<string, this>;
|
|
49
|
+
activeAtlas: string;
|
|
50
|
+
/**
|
|
51
|
+
* Returns the upload "source" the batcher hands to `createTexture2D`.
|
|
52
|
+
* For a resource this is the resource itself — `createTexture2D`
|
|
53
|
+
* dispatches to `resource.upload(gl, target)`.
|
|
54
|
+
* @ignore
|
|
55
|
+
*/
|
|
56
|
+
getTexture(): this;
|
|
57
|
+
/**
|
|
58
|
+
* Issue the `gl.texImage2D` (or equivalent) call that uploads this
|
|
59
|
+
* resource's data into the currently-bound `TEXTURE_2D` slot.
|
|
60
|
+
* Subclasses MUST override.
|
|
61
|
+
* @abstract
|
|
62
|
+
* @param {WebGLRenderingContext|WebGL2RenderingContext} gl
|
|
63
|
+
* @param {number} target - `gl.TEXTURE_2D` (or future cube-map targets)
|
|
64
|
+
*/
|
|
65
|
+
upload(gl: WebGLRenderingContext | WebGL2RenderingContext, target: number): void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A texture sourced from a raw byte buffer. Used for synthesized
|
|
69
|
+
* textures (TMX layer GID index, font atlases, color LUTs, signed-
|
|
70
|
+
* distance fields, palette tables, etc.) — any case where the texture
|
|
71
|
+
* data isn't an image file.
|
|
72
|
+
*
|
|
73
|
+
* The buffer is uploaded as-is; the resource's `premultipliedAlpha`
|
|
74
|
+
* flag is applied at upload time so a raw-data texture (typical:
|
|
75
|
+
* `premultipliedAlpha = false`) doesn't get its RGB wiped by the
|
|
76
|
+
* driver when the alpha channel is zero.
|
|
77
|
+
*
|
|
78
|
+
* @category Rendering
|
|
79
|
+
*/
|
|
80
|
+
export class BufferTextureResource extends TextureResource {
|
|
81
|
+
/**
|
|
82
|
+
* @param {ArrayBufferView} data - the pixel data; size must be
|
|
83
|
+
* `width * height * 4` bytes for the default RGBA / UNSIGNED_BYTE
|
|
84
|
+
* format
|
|
85
|
+
* @param {object} options
|
|
86
|
+
* @param {number} options.width
|
|
87
|
+
* @param {number} options.height
|
|
88
|
+
* @param {boolean} [options.premultipliedAlpha=false]
|
|
89
|
+
* @param {string} [options.repeat="no-repeat"]
|
|
90
|
+
* @param {number} [options.filter]
|
|
91
|
+
* @param {"rgba8"|"rgba8ui"} [options.format="rgba8"] - storage format.
|
|
92
|
+
* `"rgba8"` (default): normalized RGBA, sampled via `sampler2D` /
|
|
93
|
+
* `texture()`. `"rgba8ui"`: unsigned-integer RGBA, sampled via
|
|
94
|
+
* `usampler2D` / `texelFetch()` — requires WebGL2. Use the integer
|
|
95
|
+
* form for raw-data lookups (GID tables, palette indices, etc.) to
|
|
96
|
+
* skip the float-decode round trip and gain exact integer reads.
|
|
97
|
+
*/
|
|
98
|
+
constructor(data: ArrayBufferView, options: {
|
|
99
|
+
width: number;
|
|
100
|
+
height: number;
|
|
101
|
+
premultipliedAlpha?: boolean | undefined;
|
|
102
|
+
repeat?: string | undefined;
|
|
103
|
+
filter?: number | undefined;
|
|
104
|
+
format?: "rgba8" | "rgba8ui" | undefined;
|
|
105
|
+
});
|
|
106
|
+
/** @type {ArrayBufferView} */
|
|
107
|
+
data: ArrayBufferView;
|
|
108
|
+
/** @type {string} */
|
|
109
|
+
format: string;
|
|
110
|
+
/** @ignore */
|
|
111
|
+
upload(gl: any, target: any): void;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/video/texture/resource.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IACC;;;;;;;;OAQG;IACH,qEAPG;QAAwB,KAAK,EAArB,MAAM;QACU,MAAM,EAAtB,MAAM;QACY,kBAAkB;QAClB,MAAM;QACN,MAAM;KAElC,EAsBA;IAdA,qBAAqB;IACrB,OADW,MAAM,CACC;IAClB,qBAAqB;IACrB,QADW,MAAM,CACG;IACpB,sBAAsB;IACtB,oBADW,OAAO,CAC0B;IAC5C,qBAAqB;IACrB,QADW,MAAM,CACG;IACpB,+BAA+B;IAC/B,QADW,MAAM,GAAC,SAAS,CACP;IAGpB,2BAA2C;IAC3C,oBAA4B;IAG7B;;;;;OAKG;IACH,mBAEC;IAED;;;;;;;OAOG;IAEH,WAJW,qBAAqB,GAAC,sBAAsB,UAC5C,MAAM,QAKhB;CACD;AAED;;;;;;;;;;;;GAYG;AACH;IACC;;;;;;;;;;;;;;;;OAgBG;IACH,kBAhBW,eAAe,WAIvB;QAAyB,KAAK,EAAtB,MAAM;QACW,MAAM,EAAvB,MAAM;QACY,kBAAkB;QAClB,MAAM;QACN,MAAM;QACI,MAAM;KAM5C,EAOA;IAJA,8BAA8B;IAC9B,MADW,eAAe,CACV;IAChB,qBAAqB;IACrB,QADW,MAAM,CACsB;IAGxC,cAAc;IACd,mCAoCC;CACD"}
|