@holtjs/stage 0.8.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-BXU-ZDIp.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
@@ -1632,19 +1633,26 @@ function compileShader(gl, type, src) {
1632
1633
  function isPow2(v) {
1633
1634
  return v > 0 && (v & v - 1) === 0;
1634
1635
  }
1635
- function multiplyMat(parent, x, y, sx, sy, rot, out) {
1636
+ function multiplyMat(parent, x, y, sx, sy, rot, out, skewX = 0, skewY = 0) {
1636
1637
  let la, lb, lc, ld;
1637
- if (rot === 0) {
1638
- la = sx;
1639
- lb = 0;
1640
- lc = 0;
1641
- 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
+ }
1642
1651
  } else {
1643
- const cs = Math.cos(rot), sn = Math.sin(rot);
1644
- la = cs * sx;
1645
- lb = sn * sx;
1646
- lc = -sn * sy;
1647
- 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;
1648
1656
  }
1649
1657
  out.a = parent.a * la + parent.c * lb;
1650
1658
  out.b = parent.b * la + parent.d * lb;
@@ -2354,7 +2362,7 @@ var RendererGl = class extends EventEmitter {
2354
2362
  const gl = opts.context ?? canvas.getContext("webgl2", attrs) ?? canvas.getContext("webgl", attrs);
2355
2363
  if (!gl) throw new Error("Stage2D: WebGL context unavailable");
2356
2364
  this.gl = gl;
2357
- this.isWebGL2 = typeof WebGL2RenderingContext !== "undefined" && typeof gl.createVertexArray === "function";
2365
+ this.isWebGL2 = typeof gl.createVertexArray === "function" && typeof gl.bindVertexArray === "function" && typeof gl.createSampler === "function";
2358
2366
  const hwUnits = Number(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS)) || 8;
2359
2367
  this.maxTextures = Math.max(1, Math.min(16, hwUnits));
2360
2368
  this.batchMaxUnits = Math.max(1, Math.min(BATCH_MAX_UNITS, this.maxTextures));
@@ -2430,6 +2438,7 @@ var RendererGl = class extends EventEmitter {
2430
2438
  }
2431
2439
  /** Mark program/VAO/VBO state dirty after an external CustomPass without wiping the shared texture-unit cache. */
2432
2440
  invalidateProgramState() {
2441
+ if (this.isWebGL2 && typeof this.gl.bindVertexArray === "function") this.gl.bindVertexArray(null);
2433
2442
  this.batchStateBound = false;
2434
2443
  this.activeProgram = null;
2435
2444
  this.boundVao = null;
@@ -4053,10 +4062,10 @@ var RendererGl = class extends EventEmitter {
4053
4062
  }
4054
4063
  }
4055
4064
  let m;
4056
- 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;
4057
4066
  else {
4058
4067
  if (depth >= this.matPool.length) this.matPool.push(createMatrix2D());
4059
- 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);
4060
4069
  }
4061
4070
  switch (obj.type) {
4062
4071
  case "Image":
@@ -4122,6 +4131,7 @@ var RendererGl = class extends EventEmitter {
4122
4131
  case "CustomPass": {
4123
4132
  const pass = obj;
4124
4133
  this.flushAll();
4134
+ this.invalidateProgramState();
4125
4135
  pass.onRender(pass, this, camera);
4126
4136
  if (pass.restoreState) this.restoreState();
4127
4137
  else this.invalidateProgramState();
@@ -193,6 +193,8 @@ 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
200
  private _zIndex;
@@ -231,6 +233,8 @@ 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;
236
240
  get zIndex(): number;
@@ -299,7 +303,7 @@ declare class ImageObject extends DisplayObject {
299
303
  /**
300
304
  * Read the full transformed 2D pose (`x`, `y`, `rotation`, `zBias`, `hasAngle`) of an oriented socket
301
305
  * (`[x, y, angleRad, zBias]` from `@holtjs/craft/three` `charKit.handSocket`), transforming the 2D grip
302
- * tangent vector through the exact `flip -> scale -> rotate -> parentContainer` Jacobian!
306
+ * tangent vector through the exact `flip -> scale -> rotate/skew -> parentContainer` Jacobian!
303
307
  */
304
308
  getAnchorPose(name: string, space?: 'local' | 'parent' | 'world', out?: AnchorPose2D): AnchorPose2D | null;
305
309
  /**
@@ -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-CEa0m4eX.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-D46nY-B2.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,4 +1,4 @@
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-CEa0m4eX.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
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";
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-D46nY-B2.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-BXU-ZDIp.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, ft as Container, kt as PanelObject, u as Scene } from "./game-CEa0m4eX.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-CEa0m4eX.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 { Ct as ImageObject, Pt as SceneHostLike, ht as CustomPassObject } from "./game-CEa0m4eX.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;