@holtjs/stage 0.7.0 → 0.9.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.
@@ -1,6 +1,7 @@
1
1
  import { _ as rgbToCss, a as EventEmitter, c as Scale, h as packColorAbgr, l as Scenes, m as createMatrix2D, o as FilterMode, p as WHITE_RGB, r as BlendModes, u as TintModes } from "./types-CXsCvp1p.js";
2
2
  import { AnimationManager } from "./anims.js";
3
- import { _ as SpriteObject, a as Container, b as Camera, d as InstancedBatchObject, f as MsdfIconObject, g as ShapeBatchObject, h as RectangleObject, i as BlitterObject, l as Graphics, m as PanelObject, o as CustomPassObject, p as NineSliceObject, r as Renderer2D, s as DisplayList, t as RendererWebGpu, u as ImageObject, v as TextObject, y as TileSpriteObject } from "./renderer-webgpu-alSDj9RR.js";
3
+ import { i as Camera, r as Renderer2D, t as RendererWebGpu } from "./renderer-webgpu-BZ3J971y.js";
4
+ import { c as InstancedBatchObject, d as PanelObject, f as RectangleObject, g as TileSpriteObject, h as TextObject, i as DisplayList, l as MsdfIconObject, m as SpriteObject, n as Container, o as Graphics, p as ShapeBatchObject, r as CustomPassObject, s as ImageObject, t as BlitterObject, u as NineSliceObject } from "./display-C_NPwPrE.js";
4
5
  import { TweenManager } from "./tween.js";
5
6
  import { StageKernel } from "./kernel.js";
6
7
  // src/texture.ts
@@ -92,7 +93,7 @@ var Frame = class {
92
93
  pivotY = .5;
93
94
  pixelPivotX = 0;
94
95
  pixelPivotY = 0;
95
- /** Named frame-space pixel sockets relative to trimmed `(0, 0)`, e.g. `{ hand: [28, 34] }`. */
96
+ /** Named frame-space pixel sockets relative to trimmed `(0, 0)`: `[x, y]` or oriented `[x, y, angleRad, zBias]`. */
96
97
  anchors = null;
97
98
  emissiveCenter = null;
98
99
  emissivePower = 0;
@@ -141,13 +142,21 @@ var Frame = class {
141
142
  this.pivotY = this.height > 0 ? ay / this.height : .5;
142
143
  return this;
143
144
  }
144
- /** Attach or update a named pixel socket `(x, y)` relative to trimmed frame top-left `(0, 0)`. */
145
- setAnchor(name, x, y) {
145
+ /** Attach or update a named pixel socket `(x, y)` (with optional projected `angleRad` & front/back `zBias`). */
146
+ setAnchor(name, x, y, angleRad, zBias) {
146
147
  if (!this.anchors) this.anchors = Object.create(null);
147
- this.anchors[name] = [x, y];
148
+ if (typeof angleRad === "number" && Number.isFinite(angleRad)) {
149
+ const zb = typeof zBias === "number" && Number.isFinite(zBias) ? zBias >= 0 ? 1 : -1 : 1;
150
+ this.anchors[name] = [
151
+ x,
152
+ y,
153
+ angleRad,
154
+ zb
155
+ ];
156
+ } else this.anchors[name] = [x, y];
148
157
  return this;
149
158
  }
150
- /** Read a named pixel socket `[x, y]` (falls back to `emissiveCenter` when `name === 'emissive'`). */
159
+ /** Read a named pixel socket `[x, y]` or `[x, y, angleRad, zBias]` (falls back to `emissiveCenter` when `name === 'emissive'`). */
151
160
  getAnchor(name) {
152
161
  if (this.anchors && Object.prototype.hasOwnProperty.call(this.anchors, name)) return this.anchors[name];
153
162
  if (name === "emissive" && this.emissiveCenter) return this.emissiveCenter;
@@ -157,7 +166,7 @@ var Frame = class {
157
166
  if (typeof meta.ax === "number" && typeof meta.ay === "number") this.setPixelPivot(meta.ax, meta.ay);
158
167
  else if (typeof meta.pivotX === "number" || typeof meta.pivotY === "number") this.setPivot(meta.pivotX ?? .5, meta.pivotY ?? .5);
159
168
  if (meta.anchors) {
160
- for (const [k, pt] of Object.entries(meta.anchors)) if (Array.isArray(pt) && pt.length >= 2) this.setAnchor(k, Number(pt[0]) || 0, Number(pt[1]) || 0);
169
+ for (const [k, pt] of Object.entries(meta.anchors)) if (Array.isArray(pt) && pt.length >= 2) this.setAnchor(k, Number(pt[0]) || 0, Number(pt[1]) || 0, pt.length >= 3 && typeof pt[2] === "number" ? Number(pt[2]) : void 0, pt.length >= 4 && typeof pt[3] === "number" ? Number(pt[3]) : void 0);
161
170
  }
162
171
  if (Array.isArray(meta.emissiveCenter) && meta.emissiveCenter.length >= 2) this.emissiveCenter = [Number(meta.emissiveCenter[0]) || 0, Number(meta.emissiveCenter[1]) || 0];
163
172
  if (typeof meta.emissivePower === "number") this.emissivePower = meta.emissivePower;
@@ -1624,19 +1633,26 @@ function compileShader(gl, type, src) {
1624
1633
  function isPow2(v) {
1625
1634
  return v > 0 && (v & v - 1) === 0;
1626
1635
  }
1627
- function multiplyMat(parent, x, y, sx, sy, rot, out) {
1636
+ function multiplyMat(parent, x, y, sx, sy, rot, out, skewX = 0, skewY = 0) {
1628
1637
  let la, lb, lc, ld;
1629
- if (rot === 0) {
1630
- la = sx;
1631
- lb = 0;
1632
- lc = 0;
1633
- ld = sy;
1638
+ if (skewX === 0 && skewY === 0) {
1639
+ if (rot === 0) {
1640
+ la = sx;
1641
+ lb = 0;
1642
+ lc = 0;
1643
+ ld = sy;
1644
+ } else {
1645
+ const cs = Math.cos(rot), sn = Math.sin(rot);
1646
+ la = cs * sx;
1647
+ lb = sn * sx;
1648
+ lc = -sn * sy;
1649
+ ld = cs * sy;
1650
+ }
1634
1651
  } else {
1635
- const cs = Math.cos(rot), sn = Math.sin(rot);
1636
- la = cs * sx;
1637
- lb = sn * sx;
1638
- lc = -sn * sy;
1639
- ld = cs * sy;
1652
+ la = Math.cos(rot + skewY) * sx;
1653
+ lb = Math.sin(rot + skewY) * sx;
1654
+ lc = -Math.sin(rot - skewX) * sy;
1655
+ ld = Math.cos(rot - skewX) * sy;
1640
1656
  }
1641
1657
  out.a = parent.a * la + parent.c * lb;
1642
1658
  out.b = parent.b * la + parent.d * lb;
@@ -2346,7 +2362,7 @@ var RendererGl = class extends EventEmitter {
2346
2362
  const gl = opts.context ?? canvas.getContext("webgl2", attrs) ?? canvas.getContext("webgl", attrs);
2347
2363
  if (!gl) throw new Error("Stage2D: WebGL context unavailable");
2348
2364
  this.gl = gl;
2349
- this.isWebGL2 = typeof WebGL2RenderingContext !== "undefined" && typeof gl.createVertexArray === "function";
2365
+ this.isWebGL2 = typeof gl.createVertexArray === "function" && typeof gl.bindVertexArray === "function" && typeof gl.createSampler === "function";
2350
2366
  const hwUnits = Number(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS)) || 8;
2351
2367
  this.maxTextures = Math.max(1, Math.min(16, hwUnits));
2352
2368
  this.batchMaxUnits = Math.max(1, Math.min(BATCH_MAX_UNITS, this.maxTextures));
@@ -2422,6 +2438,7 @@ var RendererGl = class extends EventEmitter {
2422
2438
  }
2423
2439
  /** Mark program/VAO/VBO state dirty after an external CustomPass without wiping the shared texture-unit cache. */
2424
2440
  invalidateProgramState() {
2441
+ if (this.isWebGL2 && typeof this.gl.bindVertexArray === "function") this.gl.bindVertexArray(null);
2425
2442
  this.batchStateBound = false;
2426
2443
  this.activeProgram = null;
2427
2444
  this.boundVao = null;
@@ -4045,10 +4062,10 @@ var RendererGl = class extends EventEmitter {
4045
4062
  }
4046
4063
  }
4047
4064
  let m;
4048
- if (obj.x === 0 && obj.y === 0 && obj.scaleX === 1 && obj.scaleY === 1 && obj.rotation === 0) m = baseMat;
4065
+ if (obj.x === 0 && obj.y === 0 && obj.scaleX === 1 && obj.scaleY === 1 && obj.rotation === 0 && obj.skewX === 0 && obj.skewY === 0) m = baseMat;
4049
4066
  else {
4050
4067
  if (depth >= this.matPool.length) this.matPool.push(createMatrix2D());
4051
- m = multiplyMat(baseMat, obj.x, obj.y, obj.scaleX, obj.scaleY, obj.rotation, this.matPool[depth]);
4068
+ m = multiplyMat(baseMat, obj.x, obj.y, obj.scaleX, obj.scaleY, obj.rotation, this.matPool[depth], obj.skewX, obj.skewY);
4052
4069
  }
4053
4070
  switch (obj.type) {
4054
4071
  case "Image":
@@ -4114,6 +4131,7 @@ var RendererGl = class extends EventEmitter {
4114
4131
  case "CustomPass": {
4115
4132
  const pass = obj;
4116
4133
  this.flushAll();
4134
+ this.invalidateProgramState();
4117
4135
  pass.onRender(pass, this, camera);
4118
4136
  if (pass.restoreState) this.restoreState();
4119
4137
  else this.invalidateProgramState();
@@ -1,4 +1,4 @@
1
- import { D as EventEmitter, F as ScaleMode, H as WorldView2D, L as TintMode, M as Rect2D, N as RgbaColor, _ as Texture, b as TextureManager, d as AtlasJsonLike, g as SpriteSheetConfig, h as GlTextureHost, j as Matrix2D, p as Frame, r as AnimationManager, u as StageAnimation, v as TextureImageOptions, w as BlendMode, x as TextureSource } from "./anims-CS0rfUIz.js";
1
+ import { I as ScaleMode, M as Matrix2D, N as Rect2D, O as EventEmitter, P as RgbaColor, R as TintMode, S as TextureSource, T as BlendMode, U as WorldView2D, _ as SpriteSheetConfig, d as AtlasJsonLike, g as GlTextureHost, p as Frame, r as AnimationManager, u as StageAnimation, v as Texture, x as TextureManager, y as TextureImageOptions } from "./anims-ClNi6zZQ.js";
2
2
  import { c as TweenManager, u as TweenStats } from "./tween-BiF1FUvc.js";
3
3
  interface CameraFollowOptions {
4
4
  /** Horizontal smoothing factor in `(0, 1]` (`1` = instant lock; default `1`). */
@@ -193,9 +193,11 @@ declare abstract class DisplayObject extends EventEmitter {
193
193
  scaleX: number;
194
194
  scaleY: number;
195
195
  rotation: number;
196
+ skewX: number;
197
+ skewY: number;
196
198
  alpha: number;
197
199
  depth: number;
198
- zIndex: number;
200
+ private _zIndex;
199
201
  trackId: string | null;
200
202
  alt: string | null;
201
203
  role: string | null;
@@ -231,8 +233,12 @@ declare abstract class DisplayObject extends EventEmitter {
231
233
  setScale(sx: number, sy?: number): this;
232
234
  setRotation(rad: number): this;
233
235
  setAngle(deg: number): this;
236
+ /** Set 2D angular shear in radians (`skewX` tilts the Y axis, `skewY` tilts the X axis; completes full 6-DOF affine `Matrix2D`). */
237
+ setSkew(sx: number, sy?: number): this;
234
238
  setAlpha(a: number): this;
235
239
  setDepth(d: number): this;
240
+ get zIndex(): number;
241
+ set zIndex(z: number);
236
242
  /** Native container-local stacking order (0 by default; sorted stably when any sibling has non-zero zIndex). */
237
243
  setZIndex(z: number): this;
238
244
  /** Attach a stable, privacy-safe telemetry/automation identifier (never user text or PII). */
@@ -294,12 +300,51 @@ declare class ImageObject extends DisplayObject {
294
300
  x: number;
295
301
  y: number;
296
302
  } | null;
303
+ /**
304
+ * Read the full transformed 2D pose (`x`, `y`, `rotation`, `zBias`, `hasAngle`) of an oriented socket
305
+ * (`[x, y, angleRad, zBias]` from `@holtjs/craft/three` `charKit.handSocket`), transforming the 2D grip
306
+ * tangent vector through the exact `flip -> scale -> rotate/skew -> parentContainer` Jacobian!
307
+ */
308
+ getAnchorPose(name: string, space?: 'local' | 'parent' | 'world', out?: AnchorPose2D): AnchorPose2D | null;
309
+ /**
310
+ * Align an equipped weapon/tool `DisplayObject` (`axe`, `spear`, `torch`, `shield`) to a named socket (`'hand'`) in one call:
311
+ * - Sets `child.x` & `child.y` to the transformed socket position
312
+ * - Rotates `child.rotation` so `restAngle` (default `-Math.PI / 2` = upright sprite) aligns with the socket's projected 2D shaft angle
313
+ * - Mirrors asymmetric blades (`mirrorBlade: true`) across the shaft axis via `O(2)` reflection when aiming left (`cos < 0`) so single-bladed axes never strike backwards!
314
+ * - Applies `zBias` (`+1` in front of body, `-1` behind body) via `child.setZIndex(baseZIndex + zBias)`
315
+ */
316
+ syncAttachment(child: DisplayObject, anchorName: string, opts?: SyncAttachmentOptions): boolean;
297
317
  setTint(color: number): this;
298
318
  setTintMode(mode: TintMode): this;
299
319
  clearTint(): this;
300
320
  setPixelAA(on?: boolean): this;
301
321
  setCrop(x?: number, y?: number, w?: number, h?: number): this;
302
322
  }
323
+ interface AnchorPose2D {
324
+ x: number;
325
+ y: number;
326
+ /** Transformed 2D aim/shaft angle in radians (`[-PI, PI]`), accounting for `flipX`, `flipY`, `rotation`, and ancestor `Container`s. */
327
+ rotation: number;
328
+ /** Front/back occlusion hint (`+1` in front of body, `-1` behind body). */
329
+ zBias: number;
330
+ /** True when the baked frame socket included an explicit 3D->2D projected angle (`[x, y, angleRad, zBias]`). */
331
+ hasAngle: boolean;
332
+ }
333
+ interface SyncAttachmentOptions {
334
+ /**
335
+ * Screen-space angle (in radians) at which the attachment sprite's shaft points in its own unrotated frame.
336
+ * Default `-Math.PI / 2` (pointing straight UP `-Y`, matching upright weapons/tools baked along `+Y` in `@holtjs/craft/three`).
337
+ */
338
+ readonly restAngle?: number;
339
+ /** Additional additive angle offset in radians (automatically negated when `mirrorBlade` mirrors leftward aims). */
340
+ readonly angleOffset?: number;
341
+ /** Mirror asymmetric blades (axes, scythes, pistols) across their shaft axis when aiming left (`cos < 0`). Default `true`. */
342
+ readonly mirrorBlade?: boolean;
343
+ /** Coordinate space used to align `child` (`'local' | 'parent' | 'world'`; default `'parent'`). */
344
+ readonly space?: 'local' | 'parent' | 'world';
345
+ /** Base `zIndex` around which `pose.zBias` (`+1` front / `-1` behind) is applied (`default = this.zIndex`; `false` skips `zIndex`). */
346
+ readonly baseZIndex?: number | false;
347
+ }
303
348
  interface SpritePlayOptions {
304
349
  /** Keep current animation running untouched when already playing the requested key (default `false`, or pass boolean shorthand `sprite.play(key, true)`). */
305
350
  readonly ignoreIfPlaying?: boolean;
@@ -1890,4 +1935,4 @@ declare class Game {
1890
1935
  step(time: number, delta: number): void;
1891
1936
  destroy(removeCanvas?: boolean): void;
1892
1937
  }
1893
- export { WebGpuBootstrapResult as $, createInputRecorder as A, PanelStyleConfig as At, SceneDigestSurfaceEntry as B, TextObject as Bt, RecordedInputEntry as C, InstancedBatchObject as Ct, TimelineClickOptions as D, NineSliceObject as Dt, StagePlugin as E, MsdfIconObject as Et, SceneDigestEngineSandbox as F, ShapeBatchObject as Ft, InputConfig as G, HiDpiConfigureOptions as Gt, SceneDigestSurfaces as H, TileSpriteObject as Ht, SceneDigestNode as I, ShapeBatchStyleDefaults as It, Pointer as J, InputPlugin as K, HiDpiScaleLike as Kt, SceneDigestOptions as L, SpriteAnimEventListener as Lt, createInputTimeline as M, RectangleObject as Mt, SceneDigest as N, SceneHostLike as Nt, TimelineDragOptions as O, PanelObject as Ot, SceneDigestActiveFocus as P, ShapeBatchColumns as Pt, RequestWebGpuOptions as Q, SceneDigestOverlayStats as R, SpriteObject as Rt, InputTimelinePlugin as S, ImageObject as St, StageKernel as T, MsdfIconConfig as Tt, buildSceneDigest as U, Camera as Ut, SceneDigestSurfaceSource as V, TextStyleConfig as Vt, sanitizeTrackToken as W, CameraFollowOptions as Wt, RendererWebGpu as X, PointerSample as Y, RendererWebGpuOptions as Z, ActionMap as _, DisplayList as _t, GameLoop as a, RendererGlOptions as at, InputTargetSpec as b, DisplaySemantics as bt, LoaderPlugin as c, StageRenderTarget as ct, SceneCtor as d, Container as dt, WebGpuCanvasContextLike as et, SceneInput as f, ContainerFiltersShim as ft, ViewportFitResult as g, DirectionalPlayOptions as gt, StageRenderer as h, CustomPassOptions as ht, GameConfig as i, RendererGl as it, createInputReplay as j, RectClipMask as jt, TimelineKeyOptions as k, PanelOpenSide as kt, ScaleManager as l, BlitterObject as lt, SceneManager as m, CustomPassObject as mt, EngineClockSnapshot as n, requestWebGpuDevice as nt, GameObjectFactory as o, RendererStats as ot, SceneLifecycleStats as p, CustomPassCallback as pt, KeyboardPlugin as q, Game as r, Renderer2D as rt, JsonCache as s, Stage2DCustomImageHandler as st, EngineClock as t, WebGpuDeviceLike as tt, Scene as u, Bob as ut, InputProvider as v, DisplayObject as vt, StageInputEvent as w, InstancedColumns as wt, InputTimelineOptions as x, Graphics as xt, InputRecorderPlugin as y, DisplayObjectType as yt, SceneDigestSandbox as z, SpritePlayOptions as zt };
1938
+ export { WebGpuBootstrapResult as $, createInputRecorder as A, PanelOpenSide as At, SceneDigestSurfaceEntry as B, SpritePlayOptions as Bt, RecordedInputEntry as C, ImageObject as Ct, TimelineClickOptions as D, MsdfIconObject as Dt, StagePlugin as E, MsdfIconConfig as Et, SceneDigestEngineSandbox as F, ShapeBatchColumns as Ft, InputConfig as G, Camera as Gt, SceneDigestSurfaces as H, TextObject as Ht, SceneDigestNode as I, ShapeBatchObject as It, Pointer as J, HiDpiScaleLike as Jt, InputPlugin as K, CameraFollowOptions as Kt, SceneDigestOptions as L, ShapeBatchStyleDefaults as Lt, createInputTimeline as M, RectClipMask as Mt, SceneDigest as N, RectangleObject as Nt, TimelineDragOptions as O, NineSliceObject as Ot, SceneDigestActiveFocus as P, SceneHostLike as Pt, RequestWebGpuOptions as Q, SceneDigestOverlayStats as R, SpriteAnimEventListener as Rt, InputTimelinePlugin as S, Graphics as St, StageKernel as T, InstancedColumns as Tt, buildSceneDigest as U, TextStyleConfig as Ut, SceneDigestSurfaceSource as V, SyncAttachmentOptions as Vt, sanitizeTrackToken as W, TileSpriteObject as Wt, RendererWebGpu as X, PointerSample as Y, RendererWebGpuOptions as Z, ActionMap as _, DirectionalPlayOptions as _t, GameLoop as a, RendererGlOptions as at, InputTargetSpec as b, DisplayObjectType as bt, LoaderPlugin as c, StageRenderTarget as ct, SceneCtor as d, Bob as dt, WebGpuCanvasContextLike as et, SceneInput as f, Container as ft, ViewportFitResult as g, CustomPassOptions as gt, StageRenderer as h, CustomPassObject as ht, GameConfig as i, RendererGl as it, createInputReplay as j, PanelStyleConfig as jt, TimelineKeyOptions as k, PanelObject as kt, ScaleManager as l, AnchorPose2D as lt, SceneManager as m, CustomPassCallback as mt, EngineClockSnapshot as n, requestWebGpuDevice as nt, GameObjectFactory as o, RendererStats as ot, SceneLifecycleStats as p, ContainerFiltersShim as pt, KeyboardPlugin as q, HiDpiConfigureOptions as qt, Game as r, Renderer2D as rt, JsonCache as s, Stage2DCustomImageHandler as st, EngineClock as t, WebGpuDeviceLike as tt, Scene as u, BlitterObject as ut, InputProvider as v, DisplayList as vt, StageInputEvent as w, InstancedBatchObject as wt, InputTimelineOptions as x, DisplaySemantics as xt, InputRecorderPlugin as y, DisplayObject as yt, SceneDigestSandbox as z, SpriteObject as zt };
@@ -1,4 +1,4 @@
1
- import { E as StagePlugin, L as SceneDigestOptions, N as SceneDigest, f as SceneInput, n as EngineClockSnapshot, r as Game, u as Scene } from "./game-3L9wS-Bv.js";
1
+ import { E as StagePlugin, L as SceneDigestOptions, N as SceneDigest, f as SceneInput, n as EngineClockSnapshot, r as Game, u as Scene } from "./game-DnJYRLZP.js";
2
2
  /** Minimal Canvas2D surface compatible with `@napi-rs/canvas`, `node-canvas`, and browser `<canvas>`. */
3
3
  export interface HeadlessCanvasLike {
4
4
  width: number;
package/dist/headless.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./types-CXsCvp1p.js";
2
- import { n as Game } from "./game-BnSWR44q.js";
2
+ import { n as Game } from "./game-C-yXzyAX.js";
3
3
  import { buildSceneDigest } from "./trace.js";
4
4
  // src/headless.ts
5
5
  function createVirtualDomHost(createCanvas, width, height) {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as WebGpuBootstrapResult, A as createInputRecorder, At as PanelStyleConfig, B as SceneDigestSurfaceEntry, Bt as TextObject, C as RecordedInputEntry, Ct as InstancedBatchObject, D as TimelineClickOptions, Dt as NineSliceObject, E as StagePlugin, Et as MsdfIconObject, F as SceneDigestEngineSandbox, Ft as ShapeBatchObject, G as InputConfig, Gt as HiDpiConfigureOptions, H as SceneDigestSurfaces, Ht as TileSpriteObject, I as SceneDigestNode, It as ShapeBatchStyleDefaults, J as Pointer, K as InputPlugin, Kt as HiDpiScaleLike, L as SceneDigestOptions, Lt as SpriteAnimEventListener, M as createInputTimeline, Mt as RectangleObject, N as SceneDigest, Nt as SceneHostLike, O as TimelineDragOptions, Ot as PanelObject, P as SceneDigestActiveFocus, Pt as ShapeBatchColumns, Q as RequestWebGpuOptions, R as SceneDigestOverlayStats, Rt as SpriteObject, S as InputTimelinePlugin, St as ImageObject, T as StageKernel, Tt as MsdfIconConfig, U as buildSceneDigest, Ut as Camera, V as SceneDigestSurfaceSource, Vt as TextStyleConfig, W as sanitizeTrackToken, Wt as CameraFollowOptions, X as RendererWebGpu, Y as PointerSample, Z as RendererWebGpuOptions, _ as ActionMap, _t as DisplayList, a as GameLoop, at as RendererGlOptions, b as InputTargetSpec, bt as DisplaySemantics, c as LoaderPlugin, ct as StageRenderTarget, d as SceneCtor, dt as Container, et as WebGpuCanvasContextLike, f as SceneInput, ft as ContainerFiltersShim, g as ViewportFitResult, gt as DirectionalPlayOptions, h as StageRenderer, ht as CustomPassOptions, i as GameConfig$1, it as RendererGl, j as createInputReplay, jt as RectClipMask, k as TimelineKeyOptions, kt as PanelOpenSide, l as ScaleManager, lt as BlitterObject, m as SceneManager, mt as CustomPassObject, n as EngineClockSnapshot, nt as requestWebGpuDevice, o as GameObjectFactory, ot as RendererStats, p as SceneLifecycleStats, pt as CustomPassCallback, q as KeyboardPlugin, r as Game, rt as Renderer2D, s as JsonCache, st as Stage2DCustomImageHandler, t as EngineClock, tt as WebGpuDeviceLike, u as Scene, ut as Bob$1, v as InputProvider, vt as DisplayObject, w as StageInputEvent, wt as InstancedColumns, x as InputTimelineOptions, xt as Graphics, y as InputRecorderPlugin, yt as DisplayObjectType, z as SceneDigestSandbox, zt as SpritePlayOptions } from "./game-3L9wS-Bv.js";
2
- import { A as HEX_MASK, B as WEBGPU, C as BLACK_RGB, D as EventEmitter, E as CANVAS, F as ScaleMode, G as parseColor, H as WorldView2D, I as Scenes, K as rgbToCss, L as TintMode, M as Rect2D, N as RgbaColor, O as FilterMode, P as Scale, R as TintModes, S as AUTO, T as BlendModes, U as createMatrix2D, V as WHITE_RGB, W as packColorAbgr, _ as Texture, a as AtlasClipRule, b as TextureManager, c as GenerateFrameNamesConfig, d as AtlasJsonLike, f as CanvasTexture, g as SpriteSheetConfig, h as GlTextureHost, i as AtlasAutoAnimOptions, j as Matrix2D, k as FilterModeValue, l as GenerateFrameNumbersConfig, m as FrameExtraMeta, n as AnimationFrameInput, o as CompiledAnimationFrame, p as Frame, r as AnimationManager, s as DirectionalAnimGroup, t as AnimationConfig, u as StageAnimation, v as TextureImageOptions, w as BlendMode, x as TextureSource, y as TextureImageSource, z as WEBGL } from "./anims-CS0rfUIz.js";
1
+ import { $ as WebGpuBootstrapResult, A as createInputRecorder, At as PanelOpenSide, B as SceneDigestSurfaceEntry, Bt as SpritePlayOptions, C as RecordedInputEntry, Ct as ImageObject, D as TimelineClickOptions, Dt as MsdfIconObject, E as StagePlugin, Et as MsdfIconConfig, F as SceneDigestEngineSandbox, Ft as ShapeBatchColumns, G as InputConfig, Gt as Camera, H as SceneDigestSurfaces, Ht as TextObject, I as SceneDigestNode, It as ShapeBatchObject, J as Pointer, Jt as HiDpiScaleLike, K as InputPlugin, Kt as CameraFollowOptions, L as SceneDigestOptions, Lt as ShapeBatchStyleDefaults, M as createInputTimeline, Mt as RectClipMask, N as SceneDigest, Nt as RectangleObject, O as TimelineDragOptions, Ot as NineSliceObject, P as SceneDigestActiveFocus, Pt as SceneHostLike, Q as RequestWebGpuOptions, R as SceneDigestOverlayStats, Rt as SpriteAnimEventListener, S as InputTimelinePlugin, St as Graphics, T as StageKernel, Tt as InstancedColumns, U as buildSceneDigest, Ut as TextStyleConfig, V as SceneDigestSurfaceSource, Vt as SyncAttachmentOptions, W as sanitizeTrackToken, Wt as TileSpriteObject, X as RendererWebGpu, Y as PointerSample, Z as RendererWebGpuOptions, _ as ActionMap, _t as DirectionalPlayOptions, a as GameLoop, at as RendererGlOptions, b as InputTargetSpec, bt as DisplayObjectType, c as LoaderPlugin, ct as StageRenderTarget, d as SceneCtor, dt as Bob$1, et as WebGpuCanvasContextLike, f as SceneInput, ft as Container, g as ViewportFitResult, gt as CustomPassOptions, h as StageRenderer, ht as CustomPassObject, i as GameConfig$1, it as RendererGl, j as createInputReplay, jt as PanelStyleConfig, k as TimelineKeyOptions, kt as PanelObject, l as ScaleManager, lt as AnchorPose2D, m as SceneManager, mt as CustomPassCallback, n as EngineClockSnapshot, nt as requestWebGpuDevice, o as GameObjectFactory, ot as RendererStats, p as SceneLifecycleStats, pt as ContainerFiltersShim, q as KeyboardPlugin, qt as HiDpiConfigureOptions, r as Game, rt as Renderer2D, s as JsonCache, st as Stage2DCustomImageHandler, t as EngineClock, tt as WebGpuDeviceLike, u as Scene, ut as BlitterObject, v as InputProvider, vt as DisplayList, w as StageInputEvent, wt as InstancedBatchObject, x as InputTimelineOptions, xt as DisplaySemantics, y as InputRecorderPlugin, yt as DisplayObject, z as SceneDigestSandbox, zt as SpriteObject } from "./game-DnJYRLZP.js";
2
+ import { A as FilterModeValue, B as WEBGL, C as AUTO, D as CANVAS, E as BlendModes, F as Scale, G as packColorAbgr, H as WHITE_RGB, I as ScaleMode, K as parseColor, L as Scenes, M as Matrix2D, N as Rect2D, O as EventEmitter, P as RgbaColor, R as TintMode, S as TextureSource, T as BlendMode, U as WorldView2D, V as WEBGPU, W as createMatrix2D, _ as SpriteSheetConfig, a as AtlasClipRule, b as TextureImageSource, c as GenerateFrameNamesConfig, d as AtlasJsonLike, f as CanvasTexture, g as GlTextureHost, h as FrameExtraMeta, i as AtlasAutoAnimOptions, j as HEX_MASK, k as FilterMode, l as GenerateFrameNumbersConfig, m as FrameAnchorTuple, n as AnimationFrameInput, o as CompiledAnimationFrame, p as Frame, q as rgbToCss, r as AnimationManager, s as DirectionalAnimGroup, t as AnimationConfig, u as StageAnimation, v as Texture, w as BLACK_RGB, x as TextureManager, y as TextureImageOptions, z as TintModes } from "./anims-ClNi6zZQ.js";
3
3
  import { FlexAlign, FlexContainerSpec, FlexDir, FlexItemRect, FlexItemSpec, FlexJustify, FlexPadding, FlexResult, WrapContainerSpec, WrapItemRect, WrapItemSpec, WrapJustify, WrapResult, computeFlexLayout, computeWrapLayout, resolvePadding } from "./flex.js";
4
4
  import { a as SpringHandle, c as TweenManager, i as Easings, l as TweenOptions, n as EasingFn, o as SpringOptions, r as EasingName, s as TweenHandle, t as DisposableOwner, u as TweenStats } from "./tween-BiF1FUvc.js";
5
5
  import { JoystickDpad, JoystickDpadOptions, JoystickState, JoystickVector, JoystickViewport, JoystickZone, JoystickZonePredicate, JoystickZoneRect, VirtualJoystick, VirtualJoystickMode, VirtualJoystickOptions, VirtualJoystickStyle, clampJoystickOrigin, computeJoystickVector, isInJoystickZone, pullJoystickOrigin, quantizeJoystickDpad } from "./joystick.js";
@@ -331,4 +331,4 @@ export declare const Stage: {
331
331
  };
332
332
  };
333
333
  };
334
- export { AUTO, ActionMap, type AnimationConfig, type AnimationFrameInput, AnimationManager, type AtlasAutoAnimOptions, type AtlasClipRule, type AtlasJsonLike, BLACK_RGB, type BlendMode, BlendModes, BlitterObject, type Bob$1 as Bob, CANVAS, Camera, type CameraFollowOptions, CanvasTexture, type CompiledAnimationFrame, Container, type ContainerFiltersShim, type CustomPassCallback, CustomPassObject, type CustomPassOptions, type DirectionalAnimGroup, type DirectionalPlayOptions, DisplayList, DisplayObject, type DisplayObjectType, type DisplaySemantics, type DisposableOwner, type EasingFn, type EasingName, Easings, EngineClock, type EngineClockSnapshot, EventEmitter, FilterMode, type FilterModeValue, type FlexAlign, type FlexContainerSpec, type FlexDir, type FlexItemRect, type FlexItemSpec, type FlexJustify, type FlexPadding, type FlexResult, Frame, type FrameExtraMeta, Game, type GameConfig$1 as GameConfig, GameLoop, GameObjectFactory, type GenerateFrameNamesConfig, type GenerateFrameNumbersConfig, type GlTextureHost, Graphics, HEX_MASK, type HiDpiConfigureOptions, type HiDpiScaleLike, ImageObject, type InputConfig, InputPlugin, type InputProvider, type InputRecorderPlugin, type InputTargetSpec, type InputTimelineOptions, type InputTimelinePlugin, InstancedBatchObject, type InstancedColumns, type JoystickDpad, type JoystickDpadOptions, type JoystickState, type JoystickVector, type JoystickViewport, type JoystickZone, type JoystickZonePredicate, type JoystickZoneRect, JsonCache, KeyboardPlugin, LoaderPlugin, type Matrix2D, type MsdfIconConfig, MsdfIconObject, NineSliceObject, PanelObject, type PanelOpenSide, type PanelStyleConfig, Pointer, type PointerSample, type RecordedInputEntry, type Rect2D, type RectClipMask, RectangleObject, Renderer2D, RendererGl, type RendererGlOptions, type RendererStats, RendererWebGpu, type RendererWebGpuOptions, type RequestWebGpuOptions, type RgbaColor, SURFACE_BAND, Scale, ScaleManager, type ScaleMode, Scene, type SceneCtor, type SceneDigest, type SceneDigestActiveFocus, type SceneDigestEngineSandbox, type SceneDigestNode, type SceneDigestOptions, type SceneDigestOverlayStats, type SceneDigestSandbox, type SceneDigestSurfaceEntry, type SceneDigestSurfaceSource, type SceneDigestSurfaces, type SceneHostLike, type SceneInput, type SceneLifecycleStats, SceneManager, Scenes, type ShapeBatchColumns, ShapeBatchObject, type ShapeBatchStyleDefaults, type SpringHandle, type SpringOptions, type SpriteAnimEventListener, SpriteObject, type SpritePlayOptions, type SpriteSheetConfig, Stage as default, type Stage2DCustomImageHandler, type StageAnimation, type StageInputEvent, StageKernel, type StagePlugin, type StageRenderTarget, type StageRenderer, type SurfaceBand, type SurfaceBandName, type SurfaceBarrier, type SurfaceCancelContext, type SurfaceCancelDispatchResult, type SurfaceCancelResult, type SurfaceDomEntry, type SurfaceFocusContext, type SurfaceFocusDispatchResult, type SurfaceFocusResult, type SurfaceKeyContext, type SurfaceKeyDispatchResult, type SurfaceKeyResult, type SurfaceNodeInfo, type SurfaceNodeInput, type SurfaceScope, type SurfaceTree, TextObject, type TextStyleConfig, Texture, type TextureImageOptions, type TextureImageSource, TextureManager, TextureSource, TileSpriteObject, type TimelineClickOptions, type TimelineDragOptions, type TimelineKeyOptions, type TintMode, TintModes, type TweenHandle, TweenManager, type TweenOptions, type TweenStats, type ViewportFitResult, VirtualJoystick, type VirtualJoystickMode, type VirtualJoystickOptions, type VirtualJoystickStyle, WEBGL, WEBGPU, WHITE_RGB, type WebGpuBootstrapResult, type WebGpuCanvasContextLike, type WebGpuDeviceLike, type WorldView2D, type WrapContainerSpec, type WrapItemRect, type WrapItemSpec, type WrapJustify, type WrapResult, buildSceneDigest, clampJoystickOrigin, computeFlexLayout, computeJoystickVector, computeSurfaceDomZ, computeWrapLayout, createInputRecorder, createInputReplay, createInputTimeline, createMatrix2D, createSurfaceTree, isInJoystickZone, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
334
+ export { AUTO, ActionMap, type AnchorPose2D, type AnimationConfig, type AnimationFrameInput, AnimationManager, type AtlasAutoAnimOptions, type AtlasClipRule, type AtlasJsonLike, BLACK_RGB, type BlendMode, BlendModes, BlitterObject, type Bob$1 as Bob, CANVAS, Camera, type CameraFollowOptions, CanvasTexture, type CompiledAnimationFrame, Container, type ContainerFiltersShim, type CustomPassCallback, CustomPassObject, type CustomPassOptions, type DirectionalAnimGroup, type DirectionalPlayOptions, DisplayList, DisplayObject, type DisplayObjectType, type DisplaySemantics, type DisposableOwner, type EasingFn, type EasingName, Easings, EngineClock, type EngineClockSnapshot, EventEmitter, FilterMode, type FilterModeValue, type FlexAlign, type FlexContainerSpec, type FlexDir, type FlexItemRect, type FlexItemSpec, type FlexJustify, type FlexPadding, type FlexResult, Frame, type FrameAnchorTuple, type FrameExtraMeta, Game, type GameConfig$1 as GameConfig, GameLoop, GameObjectFactory, type GenerateFrameNamesConfig, type GenerateFrameNumbersConfig, type GlTextureHost, Graphics, HEX_MASK, type HiDpiConfigureOptions, type HiDpiScaleLike, ImageObject, type InputConfig, InputPlugin, type InputProvider, type InputRecorderPlugin, type InputTargetSpec, type InputTimelineOptions, type InputTimelinePlugin, InstancedBatchObject, type InstancedColumns, type JoystickDpad, type JoystickDpadOptions, type JoystickState, type JoystickVector, type JoystickViewport, type JoystickZone, type JoystickZonePredicate, type JoystickZoneRect, JsonCache, KeyboardPlugin, LoaderPlugin, type Matrix2D, type MsdfIconConfig, MsdfIconObject, NineSliceObject, PanelObject, type PanelOpenSide, type PanelStyleConfig, Pointer, type PointerSample, type RecordedInputEntry, type Rect2D, type RectClipMask, RectangleObject, Renderer2D, RendererGl, type RendererGlOptions, type RendererStats, RendererWebGpu, type RendererWebGpuOptions, type RequestWebGpuOptions, type RgbaColor, SURFACE_BAND, Scale, ScaleManager, type ScaleMode, Scene, type SceneCtor, type SceneDigest, type SceneDigestActiveFocus, type SceneDigestEngineSandbox, type SceneDigestNode, type SceneDigestOptions, type SceneDigestOverlayStats, type SceneDigestSandbox, type SceneDigestSurfaceEntry, type SceneDigestSurfaceSource, type SceneDigestSurfaces, type SceneHostLike, type SceneInput, type SceneLifecycleStats, SceneManager, Scenes, type ShapeBatchColumns, ShapeBatchObject, type ShapeBatchStyleDefaults, type SpringHandle, type SpringOptions, type SpriteAnimEventListener, SpriteObject, type SpritePlayOptions, type SpriteSheetConfig, Stage as default, type Stage2DCustomImageHandler, type StageAnimation, type StageInputEvent, StageKernel, type StagePlugin, type StageRenderTarget, type StageRenderer, type SurfaceBand, type SurfaceBandName, type SurfaceBarrier, type SurfaceCancelContext, type SurfaceCancelDispatchResult, type SurfaceCancelResult, type SurfaceDomEntry, type SurfaceFocusContext, type SurfaceFocusDispatchResult, type SurfaceFocusResult, type SurfaceKeyContext, type SurfaceKeyDispatchResult, type SurfaceKeyResult, type SurfaceNodeInfo, type SurfaceNodeInput, type SurfaceScope, type SurfaceTree, type SyncAttachmentOptions, TextObject, type TextStyleConfig, Texture, type TextureImageOptions, type TextureImageSource, TextureManager, TextureSource, TileSpriteObject, type TimelineClickOptions, type TimelineDragOptions, type TimelineKeyOptions, type TintMode, TintModes, type TweenHandle, TweenManager, type TweenOptions, type TweenStats, type ViewportFitResult, VirtualJoystick, type VirtualJoystickMode, type VirtualJoystickOptions, type VirtualJoystickStyle, WEBGL, WEBGPU, WHITE_RGB, type WebGpuBootstrapResult, type WebGpuCanvasContextLike, type WebGpuDeviceLike, type WorldView2D, type WrapContainerSpec, type WrapItemRect, type WrapItemSpec, type WrapJustify, type WrapResult, buildSceneDigest, clampJoystickOrigin, computeFlexLayout, computeJoystickVector, computeSurfaceDomZ, computeWrapLayout, createInputRecorder, createInputReplay, createInputTimeline, createMatrix2D, createSurfaceTree, isInJoystickZone, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { _ as rgbToCss, a as EventEmitter, c as Scale, d as WEBGL, f as WEBGPU, g as parseColor, h as packColorAbgr, i as CANVAS, l as Scenes, m as createMatrix2D, n as BLACK_RGB, o as FilterMode, p as WHITE_RGB, r as BlendModes, s as HEX_MASK, t as AUTO, u as TintModes } from "./types-CXsCvp1p.js";
2
- import { _ as CanvasTexture, a as JsonCache, b as TextureManager, c as Scene, d as KeyboardPlugin, f as Pointer, g as SdfPanelBatcher, h as MsdfIconBatcher, i as GameObjectFactory, l as SceneManager, m as PixelAaBatcher, n as Game, o as LoaderPlugin, p as RendererGl, r as GameLoop, s as ScaleManager, t as EngineClock, u as InputPlugin, v as Frame, x as TextureSource, y as Texture } from "./game-BnSWR44q.js";
2
+ import { _ as CanvasTexture, a as JsonCache, b as TextureManager, c as Scene, d as KeyboardPlugin, f as Pointer, g as SdfPanelBatcher, h as MsdfIconBatcher, i as GameObjectFactory, l as SceneManager, m as PixelAaBatcher, n as Game, o as LoaderPlugin, p as RendererGl, r as GameLoop, s as ScaleManager, t as EngineClock, u as InputPlugin, v as Frame, x as TextureSource, y as Texture } from "./game-C-yXzyAX.js";
3
3
  import { AnimationManager } from "./anims.js";
4
- import { _ as SpriteObject, a as Container, b as Camera, c as DisplayObject, d as InstancedBatchObject, f as MsdfIconObject, g as ShapeBatchObject, h as RectangleObject, i as BlitterObject, l as Graphics, m as PanelObject, n as requestWebGpuDevice, o as CustomPassObject, p as NineSliceObject, r as Renderer2D, s as DisplayList, t as RendererWebGpu, u as ImageObject, v as TextObject, y as TileSpriteObject } from "./renderer-webgpu-alSDj9RR.js";
4
+ import { i as Camera, n as requestWebGpuDevice, r as Renderer2D, t as RendererWebGpu } from "./renderer-webgpu-BZ3J971y.js";
5
+ import { a as DisplayObject, c as InstancedBatchObject, d as PanelObject, f as RectangleObject, g as TileSpriteObject, h as TextObject, i as DisplayList, l as MsdfIconObject, m as SpriteObject, n as Container, o as Graphics, p as ShapeBatchObject, r as CustomPassObject, s as ImageObject, t as BlitterObject, u as NineSliceObject } from "./display-C_NPwPrE.js";
5
6
  import { ActionMap, StageKernel, createInputRecorder, createInputReplay, createInputTimeline } from "./kernel.js";
6
7
  import { buildSceneDigest, sanitizeTrackToken } from "./trace.js";
7
8
  import { computeFlexLayout, computeWrapLayout, resolvePadding } from "./flex.js";
@@ -1,4 +1,4 @@
1
- import { J as Pointer, Ot as PanelObject, dt as Container, u as Scene } from "./game-3L9wS-Bv.js";
1
+ import { J as Pointer, ft as Container, kt as PanelObject, u as Scene } from "./game-DnJYRLZP.js";
2
2
  export type VirtualJoystickMode = 'floating' | 'fixed';
3
3
  export interface JoystickVector {
4
4
  /** Normalized X axis in [-1, 1] after deadzone remapping. */
package/dist/kernel.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as createInputRecorder, C as RecordedInputEntry, D as TimelineClickOptions, E as StagePlugin, M as createInputTimeline, O as TimelineDragOptions, S as InputTimelinePlugin, T as StageKernel, _ as ActionMap, b as InputTargetSpec, j as createInputReplay, k as TimelineKeyOptions, v as InputProvider, w as StageInputEvent, x as InputTimelineOptions, y as InputRecorderPlugin } from "./game-3L9wS-Bv.js";
1
+ import { A as createInputRecorder, C as RecordedInputEntry, D as TimelineClickOptions, E as StagePlugin, M as createInputTimeline, O as TimelineDragOptions, S as InputTimelinePlugin, T as StageKernel, _ as ActionMap, b as InputTargetSpec, j as createInputReplay, k as TimelineKeyOptions, v as InputProvider, w as StageInputEvent, x as InputTimelineOptions, y as InputRecorderPlugin } from "./game-DnJYRLZP.js";
2
2
  export { ActionMap, InputProvider, InputRecorderPlugin, InputTargetSpec, InputTimelineOptions, InputTimelinePlugin, RecordedInputEntry, StageInputEvent, StageKernel, StagePlugin, TimelineClickOptions, TimelineDragOptions, TimelineKeyOptions, createInputRecorder, createInputReplay, createInputTimeline };
@@ -1,4 +1,4 @@
1
- import { Nt as SceneHostLike, St as ImageObject, mt as CustomPassObject } from "./game-3L9wS-Bv.js";
1
+ import { Ct as ImageObject, Pt as SceneHostLike, ft as Container, ht as CustomPassObject, yt as DisplayObject } from "./game-DnJYRLZP.js";
2
2
  export type DayPhase = 'day' | 'dusk' | 'night';
3
3
  export interface DayNightConfig {
4
4
  dayLengthMs?: number;
@@ -11,7 +11,7 @@ export interface DayNightState {
11
11
  dayCount: number;
12
12
  phase: DayPhase;
13
13
  ambientRgb: number;
14
- /** 0.0 at bright noon -> up to ~0.92 in pitch-black night. */
14
+ /** 0.0 at bright noon -> up to ~0.88 in pitch-black night. */
15
15
  darkness: number;
16
16
  sunAzimuthRad: number;
17
17
  sunElevationRad: number;
@@ -55,16 +55,53 @@ export interface PointLight2D {
55
55
  /** Torch flame organic flicker amplitude in `[0, 0.5]` (`default = 0`). */
56
56
  flicker?: number;
57
57
  enabled?: boolean;
58
+ /** Coordinate space of `(x, y)` (`'world'` default; `'screen'` when driven directly by `bindEmissive` screen projection). */
59
+ space?: 'world' | 'screen';
60
+ /** Effective scale multiplier when `space === 'screen'` (`default = 1`). */
61
+ screenScale?: number;
62
+ }
63
+ export interface ScreenLightSample2D {
64
+ screenX: number;
65
+ screenY: number;
66
+ z: number;
67
+ radius: number;
68
+ color: number;
69
+ intensity: number;
58
70
  }
59
71
  /**
60
72
  * Evaluate exact 2D normal-mapped Lambertian + specular lighting at pixel `(px, py)` for unit-testing & CPU reference parity.
61
73
  */
62
74
  export declare function evaluateNormalLitPixel(baseRgb: number, normalX: number, normalY: number, normalZ: number, px: number, py: number, ambientRgb: number, lights: ReadonlyArray<PointLight2D>): number;
75
+ export interface EmissiveBindOptions {
76
+ /** Optional point-light RGB color (`default = 0xff9a2e` warm flame). */
77
+ color?: number;
78
+ /** Optional point-light radius in pixels (`0` = self-lit emissive overlay only, `default = 0`). */
79
+ radius?: number;
80
+ /** Point-light intensity (`default = 1.0`, multiplied by `frame.emissivePower` when present). */
81
+ intensity?: number;
82
+ /** Light Z height above sprite plane (`default = 36`). */
83
+ z?: number;
84
+ /** Organic flame flicker amplitude in `[0, 0.5]` (`default = 0.1`). */
85
+ flicker?: number;
86
+ /** Explicit emissive atlas texture key (`default = "${sprite.texture.key}_emissive"` if registered on `scene.textures`). */
87
+ emissiveKey?: string;
88
+ /** Self-lit `ADD` overlay opacity (`default = 0.95`). */
89
+ emissiveAlpha?: number;
90
+ /** Optional tint on the self-lit `ADD` overlay (`default = 0xffffff`). */
91
+ emissiveTint?: number;
92
+ }
93
+ export interface EmissiveBinding {
94
+ readonly id: string;
95
+ readonly sprite: ImageObject;
96
+ readonly light: PointLight2D | null;
97
+ readonly glowSprite: ImageObject | null;
98
+ destroy(): void;
99
+ }
63
100
  export interface Lighting2DSystemOptions {
64
101
  key?: string;
65
102
  width: number;
66
103
  height: number;
67
- /** Downscale factor for the offscreen lightmap FBO (`2` = half-res soft butter-smooth light falloff at 1/4 fillrate!). */
104
+ /** Downscale factor for the offscreen lightmap FBO (`0.5` = half-res soft butter-smooth light falloff at 1/4 fillrate!). */
68
105
  resolutionScale?: number;
69
106
  depth?: number;
70
107
  cycle?: DayNightCycle;
@@ -73,23 +110,52 @@ export declare class Lighting2DSystem {
73
110
  readonly scene: SceneHostLike;
74
111
  readonly cycle: DayNightCycle;
75
112
  readonly overlayImage: ImageObject;
113
+ /** Screen-space `BlendModes.ADD` container right above `overlayImage` so emissive flames/eyes shine crisp in pitch-black night! */
114
+ readonly emissiveLayer: Container;
76
115
  private renderTarget;
77
116
  private readonly lightGraphics;
117
+ private glowBatch;
118
+ private glowCap;
119
+ private glowX;
120
+ private glowY;
121
+ private glowScale;
122
+ private glowAlpha;
123
+ private glowTint;
78
124
  private readonly lights;
125
+ private readonly emissives;
126
+ private readonly activeScreenLights;
79
127
  private resScale;
80
128
  private viewportW;
81
129
  private viewportH;
82
130
  private elapsedSec;
83
131
  private manualAmbientRgb;
132
+ private lastAmbientRgb;
133
+ private nextEmissiveSeq;
134
+ private readonly matScratch;
135
+ private readonly decompScratch;
84
136
  constructor(scene: SceneHostLike, opts: Lighting2DSystemOptions);
137
+ private ensureGlowCapacity;
85
138
  addLight(light: PointLight2D): PointLight2D;
86
139
  getLight(id: string): PointLight2D | undefined;
87
140
  removeLight(id: string): boolean;
88
141
  get lightCount(): number;
142
+ /** Latest ambient RGB evaluated during `update()` (handy for `createSceneNormalLitPass`). */
143
+ get currentAmbientRgb(): number;
144
+ /** Live flickering screen-space point lights from the latest `update()` pass. */
145
+ get screenLights(): ReadonlyArray<ScreenLightSample2D>;
146
+ /**
147
+ * Bind a sprite (`ImageObject` / `SpriteObject`) whose atlas carries `@holtjs/craft` `Frame.emissiveCenter`
148
+ * and/or a sibling `${key}_emissive` self-lit texture:
149
+ * - Automatically tracks `emissiveCenter` in screen space across animations, `flipX`, `rotation`, and `Camera25D` spins!
150
+ * - Optionally drives a flickering `PointLight2D` (`opts.radius > 0`)
151
+ * - Renders `${key}_emissive` in `emissiveLayer` (`BlendModes.ADD` above night darkness) so flames/embers/eyes never dim at night!
152
+ */
153
+ bindEmissive(sprite: ImageObject, opts?: EmissiveBindOptions): EmissiveBinding;
89
154
  setAmbientOverride(rgb: number | null): void;
90
155
  resize(width: number, height: number): void;
156
+ private syncEmissiveBindings;
91
157
  /**
92
- * Step the day/night cycle + torch flicker and render the `MULTIPLY` lightmap FBO!
158
+ * Step the day/night cycle + torch flicker, sync bound emissive sprites, and render the `MULTIPLY` lightmap FBO!
93
159
  * Pass `projectToScreen` when using `Camera25D`; otherwise defaults to `scene.cameras.main.worldToScreen`.
94
160
  */
95
161
  update(deltaMs: number, projectToScreen?: (wx: number, wy: number, wz: number, out: {
@@ -110,20 +176,38 @@ export interface NormalLitQuad {
110
176
  v1?: number;
111
177
  originX?: number;
112
178
  originY?: number;
179
+ rotation?: number;
180
+ flipX?: boolean;
181
+ flipY?: boolean;
113
182
  }
114
183
  /**
115
- * Create a state-isolated WebGL2 `CustomPass` that renders normal-mapped 2D props/characters with per-pixel
116
- * 3D tangent-space point lighting (`uDiffuse` + `uNormal`), gracefully no-oping on Canvas2D!
184
+ * Create a state-isolated, single-draw batched WebGL2 `CustomPass` that renders normal-mapped 2D props/characters with per-pixel
185
+ * 3D tangent-space point lighting (`uDiffuse` + `uNormal`, supporting `rotation`, `flipX`, and `flipY`), gracefully no-oping on Canvas2D!
117
186
  */
118
187
  export declare function createNormalLitSpritePass(scene: SceneHostLike, diffuseKey: string, normalKey: string, getQuadsAndLights: () => {
119
188
  ambientRgb: number;
120
189
  quads: ReadonlyArray<NormalLitQuad>;
121
- lights: ReadonlyArray<{
122
- screenX: number;
123
- screenY: number;
124
- z: number;
125
- radius: number;
126
- color: number;
127
- intensity: number;
128
- }>;
129
- }): CustomPassObject;
190
+ lights: ReadonlyArray<ScreenLightSample2D>;
191
+ }): CustomPassObject;
192
+ export interface SceneNormalLitPassOptions {
193
+ /** `Container` (e.g. `stage25d.billboardLayer`) or array of `DisplayObject`s traversed in painter's order. */
194
+ source: Container | ReadonlyArray<DisplayObject>;
195
+ /** `Lighting2DSystem` supplying live ambient color & flickering screen-space point lights. */
196
+ lighting: Lighting2DSystem;
197
+ /**
198
+ * `'rim'` (default): additive directional 3D normal-map rim & Blinn-Phong specular relief that pairs seamlessly with
199
+ * `Lighting2DSystem` without double-darkening shadows or occluding interleaved non-normal-mapped sprites!
200
+ * `'replace'`: full `base * (ambient + lights)` opaque draw in painter's order.
201
+ */
202
+ mode?: 'rim' | 'replace';
203
+ /** Directional rim/specular intensity multiplier in `'rim'` mode (`default = 0.6`). */
204
+ rimStrength?: number;
205
+ /** Scene depth of this pass (`default = lighting.overlayImage.depth - 1` so `'rim'` sits right beneath darkness cutout or above sprites). */
206
+ depth?: number;
207
+ }
208
+ /**
209
+ * Scene-graph native 2D Normal-Map lighting pass: automatically traverses `source` (`stage25d.billboardLayer` or nested `Container`s),
210
+ * discovers matching `${texture.key}_normal` atlases registered by `@holtjs/craft`, transforms `customPivot` (`ax/ay`), `flipX`, `flipY`,
211
+ * `rotation`, and `skew` into tangent-space screen basis vectors, and batches consecutive same-atlas sprites into a single WebGL draw call!
212
+ */
213
+ export declare function createSceneNormalLitPass(scene: SceneHostLike, opts: SceneNormalLitPassOptions): CustomPassObject;