melonjs 19.2.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 +12 -10
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/index.js +1623 -529
- package/build/index.js.map +4 -4
- package/build/physics/bounds.d.ts +5 -2
- package/build/physics/bounds.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/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/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 +62 -0
- 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/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/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/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 +17 -0
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -135,12 +135,15 @@ export declare class Bounds {
|
|
|
135
135
|
*/
|
|
136
136
|
addPoint(point: Vector2d | Point, m?: Matrix2d | Matrix3d): void;
|
|
137
137
|
/**
|
|
138
|
-
*
|
|
138
|
+
* Expands this bounds to include the axis-aligned bounding box of
|
|
139
|
+
* the given rect's four corners, optionally transformed through `m`
|
|
140
|
+
* first. With a non-identity `m` (rotation, scale, etc.) the result
|
|
141
|
+
* is the AABB of the transformed quad, not a transformed AABB.
|
|
139
142
|
* @param x0 - The left x coordinate of the quad.
|
|
140
143
|
* @param y0 - The top y coordinate of the quad.
|
|
141
144
|
* @param x1 - The right x coordinate of the quad.
|
|
142
145
|
* @param y1 - The bottom y coordinate of the quad.
|
|
143
|
-
* @param [m] - An optional transform to
|
|
146
|
+
* @param [m] - An optional transform applied to each corner before inclusion.
|
|
144
147
|
*/
|
|
145
148
|
addFrame(x0: number, y0: number, x1: number, y1: number, m?: Matrix2d | Matrix3d): void;
|
|
146
149
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounds.d.ts","sourceRoot":"","sources":["../../src/physics/bounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"bounds.d.ts","sourceRoot":"","sources":["../../src/physics/bounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAA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;IACH,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,EAAE,EAAE,KAAK,UAAQ;IAoB7D;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,UAAQ;IAsBvC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ;IAQzD;;;;;;;;;;OAUG;IACH,QAAQ,CACP,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ;IAqCxB;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;IACvC,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO;IA2B5C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM;IASvB;;;OAGG;IACH,QAAQ;IASR;;;;OAIG;IACH,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IACrC,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI;IAiBjC;;;;OAIG;IACH,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IACjC,KAAK,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI;IAsB7B;;;OAGG;IACH,KAAK;IAML;;;OAGG;IACH,SAAS;CAQT;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,yFAcrB,CAAC"}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* Container represents a collection of child objects.
|
|
25
25
|
* When no explicit dimensions are given, width and height default to Infinity,
|
|
26
26
|
* meaning the container has no intrinsic size, no clipping, and acts as a pure
|
|
27
|
-
* grouping/transform node
|
|
27
|
+
* grouping/transform node.
|
|
28
28
|
* In this case, anchorPoint is treated as (0, 0) since there is no meaningful
|
|
29
29
|
* center for an infinite area. Bounds are then derived entirely from children
|
|
30
30
|
* when {@link Container#enableChildBoundsUpdate} is enabled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/renderable/container.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;GASG;AACH;IACC;;;;;;;OAOG;IACH,gBAPW,MAAM,MACN,MAAM,UACN,MAAM,WACN,MAAM,SACN,OAAO,EAgHjB;IAzGA;;;OAGG;IACH,iBAAuB;IAEvB;;;;OAIG;IACH,MAHU,OAAO,CAGD;IAEhB;;;OAGG;IACH,4BAAyB;IAEzB;;;;;OAKG;IACH,SAHU,MAAM,CAGE;IAClB,wCAA8B;IAE9B;;;;OAIG;IACH,UAHU,OAAO,CAGG;IAEpB;;;;OAIG;IACH,WAHU,OAAO,CAGI;IAErB;;;;OAIG;IACH,UAHU,OAAO,CAGI;IAErB;;;OAGG;IACH,0BAEC;IAED;;;;;;OAMG;IACH,yBAHU,OAAO,CAGmB;IAEpC;;;;;;;OAOG;IACH,iBANU,KAAK,CAMmC;IAElD;;;OAGG;IACH,kBAAkB;IAoCnB,kBANU,MAAM,EAef;IAlBD;;;;;OAKG;IACH,cAHU,MAAM,CAKf;IAYD;;OAEG;IACH,cAmBC;IAED;;;;;;;;;;;;;OAaG;IACH,gBAJW,UAAU,GAAC,MAAM,GAAC,MAAM,GAAC,WAAW,GAAC,OAAO,GAAC,SAAS,GAAC,UAAU,GAAC,eAAe,GAAC,UAAU,GAAC,UAAU,GAAC,OAAO,GAAC,aAAa,GAAC,eAAe,GAAC,YAAY,GAAC,IAAI,GAAC,UAAU,MAC1K,MAAM,GACJ,UAAU,CAwEtB;IAED;;;;;;OAMG;IACH,kBAJW,UAAU,GAAC,MAAM,GAAC,MAAM,G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GAAC,SAAS,GAAC,UAAU,GAAC,eAAe,GAAC,UAAU,GAAC,UAAU,GAAC,OAAO,GAAC,aAAa,GAAC,eAAe,GAAC,YAAY,GAAC,IAAI,GAAC,UAAU,QAUpL;IAED;;;OAGG;IACH,iBAFW,UAAU,GAAC,MAAM,GAAC,MAAM,GAAC,WAAW,GAAC,OAAO,GAAC,SAAS,GAAC,UAAU,GAAC,eAAe,GAAC,UAAU,GAAC,UAAU,GAAC,OAAO,GAAC,aAAa,GAAC,eAAe,GAAC,YAAY,GAAC,IAAI,GAAC,UAAU,QAapL;IAED;;;OAGG;IACH,oBAFW,UAAU,GAAC,MAAM,GAAC,MAAM,GAAC,WAAW,GAAC,OAAO,GAAC,SAAS,GAAC,UAAU,GAAC,eAAe,GAAC,UAAU,GAAC,UAAU,GAAC,OAAO,GAAC,aAAa,GAAC,eAAe,GAAC,YAAY,GAAC,IAAI,GAAC,UAAU,QAiBpL;IAED;;;OAGG;IACH,iBAFW,OAAO,QAuBjB;IAED;;OAEG;IACH,0BAMC;IAED;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,sCAEC;IAED;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,+BAEC;CA4ID;uBAv+BsB,iBAAiB;2BAchB,oBAAoB;wBACrB,oBAAoB;wBACpB,aAAa;6BACR,kBAAkB;yBACtB,cAAc;+BACR,gBAAgB;gCACf,gBAAgB;iCACf,sBAAsB;4BAC3B,iBAAiB;4BACjB,iBAAiB;yBACpB,cAAc;+BACR,uBAAuB;iCACrB,yBAAyB;8BAC5B,sBAAsB;sBAC9B,gBAAgB;4BACV,sBAAsB;4BACxB,wBAAwB"}
|
|
@@ -1,18 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* additional import for TypeScript
|
|
3
|
+
* @import {Color} from "./../math/color.ts";
|
|
4
|
+
* @import {Ellipse} from "./../geometries/ellipse.ts";
|
|
5
|
+
* @import Renderer from "./../video/renderer.js";
|
|
6
|
+
*/
|
|
1
7
|
/**
|
|
2
8
|
* A 2D point light.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
9
|
+
*
|
|
10
|
+
* Light2d carries the *properties* of a light (color, radii, intensity,
|
|
11
|
+
* height, flags, position) and asks the active renderer to render it
|
|
12
|
+
* via `renderer.drawLight(this)`. The renderer picks the right machinery:
|
|
13
|
+
*
|
|
14
|
+
* - **WebGL**: a single quad through a shared procedural radial-falloff
|
|
15
|
+
* fragment shader (`RadialGradientEffect`). One shader is reused across
|
|
16
|
+
* every Light2d on the renderer; no per-light texture is allocated.
|
|
17
|
+
* - **Canvas**: a small `Gradient` config object (cached per-light in a
|
|
18
|
+
* `WeakMap` and rebuilt only when radii / color / intensity change),
|
|
19
|
+
* rasterized via `Gradient.toCanvas()` on every draw into a single
|
|
20
|
+
* shared `CanvasRenderTarget`, then composited with `drawImage`. The
|
|
21
|
+
* per-light cache holds only the gradient stops, not the bitmap — the
|
|
22
|
+
* render target is one-per-engine.
|
|
23
|
+
*
|
|
24
|
+
* Light2d itself is renderer-agnostic — no shader knowledge, no canvas
|
|
25
|
+
* allocation, no renderer reference held.
|
|
6
26
|
* @see stage.lights
|
|
7
27
|
*/
|
|
8
28
|
export default class Light2d extends Renderable {
|
|
9
29
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
30
|
+
* Create a 2D point light.
|
|
31
|
+
*
|
|
32
|
+
* A `Light2d` is a first-class world Renderable: add it to a container
|
|
33
|
+
* with `app.world.addChild(light)` (or any sub-container, including a
|
|
34
|
+
* `Sprite`, so the light follows the parent via its transform). On
|
|
35
|
+
* activation, the light auto-registers with the active `Stage`'s
|
|
36
|
+
* lighting set so the ambient overlay (`Stage.ambientLight`) cuts a
|
|
37
|
+
* hole at the light's visible area, and a radial gradient from the
|
|
38
|
+
* given `color` (full intensity at center → fully transparent at the
|
|
39
|
+
* radius) is composited additively on top — producing a soft spot
|
|
40
|
+
* light. Rendering happens inside each `Camera2d`'s post-effect FBO
|
|
41
|
+
* bracket so any camera shader (vignette, color-matrix, scanlines,
|
|
42
|
+
* etc.) wraps the lighting output.
|
|
43
|
+
*
|
|
44
|
+
* Set `radiusY` to a different value than `radiusX` for a stretched
|
|
45
|
+
* (elliptical) light. The `intensity` parameter scales the gradient's
|
|
46
|
+
* inner alpha; the `Stage.ambientLight` color and alpha control how
|
|
47
|
+
* dark the unlit areas are. Use `light.blendMode` to override the
|
|
48
|
+
* default additive blend if needed.
|
|
49
|
+
* @param {number} x - The horizontal position of the light's center (matches `Ellipse(x, y, w, h)` conventions).
|
|
50
|
+
* @param {number} y - The vertical position of the light's center.
|
|
12
51
|
* @param {number} radiusX - The horizontal radius of the light.
|
|
13
52
|
* @param {number} [radiusY=radiusX] - The vertical radius of the light.
|
|
14
|
-
* @param {Color|string} [color="#FFF"] -
|
|
15
|
-
* @param {number} [intensity=0.7] - The
|
|
53
|
+
* @param {Color|string} [color="#FFF"] - The color of the light at full intensity.
|
|
54
|
+
* @param {number} [intensity=0.7] - The peak alpha of the radial gradient at the light's center (0–1).
|
|
16
55
|
*/
|
|
17
56
|
constructor(x: number, y: number, radiusX: number, radiusY?: number, color?: Color | string, intensity?: number);
|
|
18
57
|
/**
|
|
@@ -39,25 +78,98 @@ export default class Light2d extends Renderable {
|
|
|
39
78
|
intensity: number;
|
|
40
79
|
/** @ignore */
|
|
41
80
|
visibleArea: Ellipse;
|
|
42
|
-
/** @ignore */
|
|
43
|
-
texture: CanvasRenderTarget;
|
|
44
81
|
/**
|
|
45
|
-
*
|
|
82
|
+
* When `true`, this light acts as a pure illumination source —
|
|
83
|
+
* the gradient texture isn't drawn. The light still feeds the
|
|
84
|
+
* `Stage` ambient-cutout pass and the WebGL lit-sprite
|
|
85
|
+
* pipeline's per-frame uniforms, so normal-mapped sprites still
|
|
86
|
+
* get shaded by it. Use this for SpriteIlluminator-style demos
|
|
87
|
+
* where the light should be invisible (only its effect on
|
|
88
|
+
* normal-mapped surfaces is what you want to see).
|
|
89
|
+
*
|
|
90
|
+
* Default `false`, preserving the legacy "soft glowing spot"
|
|
91
|
+
* behavior.
|
|
92
|
+
* @type {boolean}
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
illuminationOnly: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Light height above the sprite plane (Z axis), in the same
|
|
98
|
+
* units as `radiusX`/`radiusY`. Used by the WebGL lit-sprite
|
|
99
|
+
* pipeline as the Z component of the light direction in the
|
|
100
|
+
* `dot(normal, lightDir)` calculation: a low height makes the
|
|
101
|
+
* lighting graze across the surface (long visible shadows on
|
|
102
|
+
* normal-map detail), a high height makes it head-on (more
|
|
103
|
+
* uniform brightness on the lit hemisphere).
|
|
104
|
+
*
|
|
105
|
+
* Default is `max(radiusX, radiusY) * 0.075` — a balanced look
|
|
106
|
+
* at the asset's native scale that prevents lights at the
|
|
107
|
+
* sprite's center from producing degenerate flat shading.
|
|
108
|
+
*
|
|
109
|
+
* Named `lightHeight` (not just `height`) to avoid colliding
|
|
110
|
+
* with the bbox-height getter Light2d inherits from `Rect`.
|
|
111
|
+
* @type {number}
|
|
112
|
+
*/
|
|
113
|
+
lightHeight: number;
|
|
114
|
+
/**
|
|
115
|
+
* Set new radii for this light.
|
|
116
|
+
*
|
|
117
|
+
* Updates `radiusX`/`radiusY` and the underlying bbox (via
|
|
118
|
+
* `Renderable.resize(width, height)`) so `getBounds()` and
|
|
119
|
+
* `getVisibleArea()` — which feed the ambient-cutout pass — track the
|
|
120
|
+
* new size. The Canvas renderer's gradient cache auto-invalidates on
|
|
121
|
+
* next draw via its property comparison; the WebGL procedural shader
|
|
122
|
+
* adapts to the new dimensions automatically.
|
|
123
|
+
*
|
|
124
|
+
* Named `setRadii` (not `resize`) so it does not shadow
|
|
125
|
+
* `Renderable.resize(width, height)` — code that operates on a
|
|
126
|
+
* generic `Renderable` and calls `.resize(w, h)` keeps working when
|
|
127
|
+
* the instance happens to be a `Light2d`.
|
|
128
|
+
* @param {number} radiusX - new horizontal radius
|
|
129
|
+
* @param {number} [radiusY=radiusX] - new vertical radius
|
|
130
|
+
*/
|
|
131
|
+
setRadii(radiusX: number, radiusY?: number): void;
|
|
132
|
+
/**
|
|
133
|
+
* returns a geometry representing the visible area of this light, in
|
|
134
|
+
* world-space coordinates (so it aligns with the rendered gradient
|
|
135
|
+
* regardless of camera scroll or container parenting).
|
|
46
136
|
* @returns {Ellipse} the light visible mask
|
|
47
137
|
*/
|
|
48
138
|
getVisibleArea(): Ellipse;
|
|
49
139
|
/**
|
|
50
140
|
* update function
|
|
51
|
-
* @param {number} dt - time since the last update in milliseconds.
|
|
52
141
|
* @returns {boolean} true if dirty
|
|
53
142
|
*/
|
|
54
143
|
update(): boolean;
|
|
55
144
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @param {
|
|
58
|
-
|
|
145
|
+
* preDraw this Light2d (automatically called by melonJS)
|
|
146
|
+
* @param {Renderer} renderer - a renderer instance
|
|
147
|
+
*/
|
|
148
|
+
preDraw(renderer: Renderer): void;
|
|
149
|
+
/**
|
|
150
|
+
* draw this Light2d (automatically called by melonJS).
|
|
151
|
+
*
|
|
152
|
+
* Delegates to `renderer.drawLight(this)` — each renderer picks its
|
|
153
|
+
* own implementation (procedural shader on WebGL; cached `Gradient`
|
|
154
|
+
* rasterized into a shared `CanvasRenderTarget` on Canvas). Light2d
|
|
155
|
+
* itself doesn't know which path is used.
|
|
156
|
+
* @param {Renderer} renderer - a renderer instance
|
|
157
|
+
*/
|
|
158
|
+
draw(renderer: Renderer): void;
|
|
159
|
+
/**
|
|
160
|
+
* Auto-register this light with the active Stage's lighting set when
|
|
161
|
+
* added to a container. The Stage uses that set to build the ambient
|
|
162
|
+
* overlay cutouts; rendering the light itself is handled normally as
|
|
163
|
+
* part of the world tree walk.
|
|
164
|
+
* @ignore
|
|
165
|
+
*/
|
|
166
|
+
onActivateEvent(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Auto-deregister this light from the active Stage's lighting set when
|
|
169
|
+
* removed from a container.
|
|
170
|
+
* @ignore
|
|
59
171
|
*/
|
|
60
|
-
|
|
172
|
+
onDeactivateEvent(): void;
|
|
61
173
|
/**
|
|
62
174
|
* Destroy function<br>
|
|
63
175
|
* @ignore
|
|
@@ -67,7 +179,5 @@ export default class Light2d extends Renderable {
|
|
|
67
179
|
import Renderable from "./renderable.js";
|
|
68
180
|
import type { Color } from "./../math/color.ts";
|
|
69
181
|
import type { Ellipse } from "./../geometries/ellipse.ts";
|
|
70
|
-
import
|
|
71
|
-
import type CanvasRenderer from "./../video/canvas/canvas_renderer.js";
|
|
72
|
-
import type WebGLRenderer from "./../video/webgl/webgl_renderer.js";
|
|
182
|
+
import type Renderer from "./../video/renderer.js";
|
|
73
183
|
//# sourceMappingURL=light2d.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"light2d.d.ts","sourceRoot":"","sources":["../../src/renderable/light2d.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"light2d.d.ts","sourceRoot":"","sources":["../../src/renderable/light2d.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,eAPW,MAAM,KACN,MAAM,WACN,MAAM,YACN,MAAM,UACN,KAAK,GAAC,MAAM,cACZ,MAAM,EAiGhB;IAlFA;;;;OAIG;IACH,OAHU,KAAK,CAG6B;IAE5C;;;OAGG;IACH,SAFU,MAAM,CAEM;IAEtB;;;OAGG;IACH,SAFU,MAAM,CAEM;IAEtB;;;;OAIG;IACH,WAHU,MAAM,CAGU;IAa1B,cAAc;IACd,qBAKC;IAKD;;;;;;;;;;;;;OAaG;IACH,kBAHU,OAAO,CAGY;IAE7B;;;;;;;;;;;;;;;;OAgBG;IACH,aAFU,MAAM,CAEqC;IAiCtD;;;;;;;;;;;;;;;;OAgBG;IACH,kBAHW,MAAM,YACN,MAAM,QAMhB;IAED;;;;;OAKG;IACH,kBAFa,OAAO,CAOnB;IAED;;;OAGG;IACH,UAFa,OAAO,CAInB;IAED;;;OAGG;IACH,kBAFW,QAAQ,QAKlB;IAED;;;;;;;;OAQG;IACH,eAFW,QAAQ,QAOlB;IAED;;;;;;OAMG;IACH,wBAKC;IAED;;;;OAIG;IACH,0BAKC;IAED;;;OAGG;IACH,gBAQC;CACD;uBArSsB,iBAAiB;2BAIhB,oBAAoB;6BAClB,4BAA4B;0BAC7B,wBAAwB"}
|
|
@@ -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,CAAC;IAE/B
|
|
1
|
+
{"version":3,"file":"stage.d.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W,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"}
|
|
@@ -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,O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AI,GAAC,SAAS,GAAC,OAAO,GAAC,IAAI,GAAC,OAAO,WACnC,OAAO,QAgGjB;IApFC,2CAAkC;CAgGpC;qBA3xCoB,kBAAkB;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,49 @@ 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;
|
|
245
307
|
/**
|
|
246
308
|
* Set the current fill & stroke style color.
|
|
247
309
|
* By default, or upon reset, the value is set to #000000.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/video/renderer.js"],"names":[],"mappings":"AASA;;GAEG;AAEH;;;;;;;GAOG;AAEH;;;GAGG;AACH;IACC;;OAEG;IACH,sBAFW,mBAAmB,
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/video/renderer.js"],"names":[],"mappings":"AASA;;GAEG;AAEH;;;;;;;GAOG;AAEH;;;GAGG;AACH;IACC;;OAEG;IACH,sBAFW,mBAAmB,EAyI7B;IAtIA;;;;OAIG;IACH,cAFU,kBAAkB,CAS3B;IAED;;;;OAIG;IACH,iBAFU,MAAM,CAEO;IAEvB;;;;OAIG;IACH,oBAFU,MAAM,CAE6C;IAE7D;;;;OAIG;IACH,YAHU,QAAQ,CAGsD;IAExE;;;;OAIG;IACH,gBAFU,OAAO,CAES;IAE1B;;;OAGG;IACH,aAFU,MAAM,GAAC,SAAS,CAEE;IAE5B;;;;;;OAMG;IACH,cAHU,QAAQ,GAAC,YAAY,GAAC,SAAS,CAGZ;IAE7B;;;;;OAKG;IACH,mBAHU,gBAAgB,GAAC,IAAI,CAGF;IAE7B;;;OAGG;IACH,QAFU,MAAM,CAEU;IAE1B;;;;OAIG;IACH,MAFU,MAAM,CAEK;IAErB;;;;;OAKG;IACH,iBAFU,KAAK,CAOd;IAED;;;;OAIG;IACH,aAFU,WAAW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