@holtjs/stage 0.8.0 → 0.10.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/CHANGELOG.md CHANGED
@@ -6,6 +6,37 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.10.0] - 2026-12-04
10
+
11
+ ### Added
12
+ - **Lockstep 3D Z-Holdout Equipment Binding & Auto-Empty Placeholder Detection (`SpriteObject.bindEquipment`, `Frame.empty`, `src/display.ts`, `src/texture.ts`, `src/game.ts`, `src/projection.ts`)**:
13
+ - Added `SpriteObject.bindEquipment(target, prefix, opts?)` returning an `EquipmentBinding` handle (`setPrefix(nextPrefix)`, `sync()`, `destroy()`), paired directly with `@holtjs/craft/three` `baker.bakeEquipment()`.
14
+ - Automatically resolves `<prefix>/<clip>/d<dir>/f<frame>` (or non-directional `<prefix>/<clip>/f<frame>`) on every animation frame & direction turn, aligns ground-origin `ax/ay` pivots via `useFramePivot()`, locks `x/y`, `flipX/flipY`, `scale`, `rotation`, `skew`, and `zIndex + zOffset` in both `stepSimOnly` (post-`update`) and `step` (pre-render, eliminating any 1-frame lag after `hero.x += ...` movement!), and hides occluded or missing frames (`0` wasted GPU/Canvas2D draw calls or stray `mountStage25D` shadow quads).
15
+ - `TextureManager.addAtlas()` now populates `Frame.empty` automatically across `1x1` Craft holdout cells, `<=4x4` all-transparent placeholder frames (e.g. `2x2` transparent cells preserving directional frame counts), and explicit `empty: true` entries.
16
+ - **2x2 Projected Basis Sockets & 6-DOF Affine `syncAttachment` with Per-Clip `clipAngles` (`src/texture.ts`, `src/display.ts`)**:
17
+ - Extended `FrameAnchorTuple` & `ImageObject.getAnchorPose()` to support 8-tuple sockets `[x, y, angleRad, zBias, ux, uy, vx, vy]` (from `@holtjs/craft/three` `charKit.handBasisSocket`), transforming both shaft `(ux, uy)` and blade `(vx, vy)` vectors through `flip -> scale -> rotate/skew -> parentContainer`.
18
+ - Upgraded `ImageObject.syncAttachment(child, anchorName, opts?)` with exact closed-form 2x2 polar decomposition into `(scaleX, scaleY, rotation, skewY)` (including reflected `det < 0` chirality), simultaneously solving perspective shaft foreshortening (`||u|| < 1`), `45°/30°` non-orthogonal isometric blade shear (`u · v != 0`), and per-clip 3D grip-plane wrist angles (`clipAngles: { walk: 0.66, thrust: 0 }`).
19
+ - **`playDirectional` `startFrame` Forwarding & `createFromAtlas` Cross-Actor Rule Inheritance (`src/display.ts`, `src/anims.ts`)**:
20
+ - Added `startFrame?: number` to `DirectionalPlayOptions` (`SpriteObject.playDirectional`), forwarding directly to `play()` (and restarting cleanly even when already playing the same direction).
21
+ - Added `inheritFrom?: Readonly<Record<string, string>>` (supporting exact keys and prefix globs such as `{ 'held/*': 'survivor' }`) plus automatic `Frame.baseActor` (`baseChar` from `@holtjs/craft/three` `bakeEquipment`) inheritance in `AnimationManager.createFromAtlas()` so secondary equipment/overlay actors inherit `frameRate`, `duration`, `repeat`, `yoyo`, and `events` without duplicating clip rules.
22
+
23
+ ## [0.9.0] - 2026-12-04
24
+
25
+ ### Added
26
+ - **Complete 6-DOF 2D Affine Scene-Graph Transforms (`skewX` / `skewY`, `src/display.ts`, `src/renderer-gl.ts`, `src/renderer-webgpu.ts`, `src/renderer-2d.ts`)**:
27
+ - Added `skewX`, `skewY`, and `setSkew(sx, sy?)` on `DisplayObject`, completing the full 6-degree-of-freedom 2D affine group across `getWorldTransformMatrix()`, `ImageObject.getAnchor()`, `ImageObject.getAnchorPose()`, `RendererGl`, `RendererWebGpu`, and `Renderer2D` (unified onto direct `ctx.setTransform(m.a, m.b, m.c, m.d, m.tx, m.ty)` with zero cumulative drift).
28
+ - **True Oblique Sun-Cast Silhouette Shadows in `mountStage25D` (`@holtjs/stage/projection`)**:
29
+ - Added `Stage25DRig.shadowLayer` (`zIndex = 5`: strictly above `groundWorld` tiles and below `billboardLayer` sprites), `MountStage25DOptions.shadows` (`Shadow25DConfig`), `setSunShadow(cfg)`, and `syncDayNight(state)`.
30
+ - Automatically projects crisp ground-pinned silhouette shadows for both `ImageObject`/`SpriteObject` billboards and multi-part `Container` billboards (e.g. character + `syncAttachment` weapon), detaches along the sun ray when jumping (`wz > 0`), fades smoothly to zero at night (`0` shadow draw calls in darkness), and auto-disposes shadow clones via `onDispose()`.
31
+ - **Zero-Banding Analytical Radial Glow, Self-Lit `bindEmissive` Layer & Batched `flipX`/Rotation-Aware Normal-Lit Pass (`@holtjs/stage/lighting`)**:
32
+ - Upgraded `Lighting2DSystem` point lights from 5-ring stepped `Graphics` circles to a shared `128x128` smooth $C^1$ analytical radial falloff texture (`__stage_radial_glow`) rendered via `InstancedBatchObject` (`5x` fewer quads, zero Mach banding across WebGPU, WebGL2 & Canvas2D).
33
+ - Added `Lighting2DSystem.emissiveLayer` and `Lighting2DSystem.bindEmissive(sprite, opts?)` natively consuming `@holtjs/craft` `Frame.emissiveCenter`, `Frame.emissivePower`, and `${key}_emissive` self-lit atlases so campfires, torches, and glowing eyes shine brightly above the night `MULTIPLY` overlay across WebGPU, WebGL2, and Canvas2D.
34
+ - Upgraded `createNormalLitSpritePass` to single-draw batching with `flipX`/`flipY`/`rotation` tangent-basis transformation (`aBasis`), and added scene-graph native `createSceneNormalLitPass(scene, opts)` (`mode: 'rim' | 'replace'`) traversing `Container`s in painter's order.
35
+
36
+ ### Fixed
37
+ - **WebGL2 `CustomPass` VAO State Isolation (`src/renderer-gl.ts`)**:
38
+ - `RendererGl.invalidateProgramState()` now explicitly unbinds any bound WebGL2 VAO via `gl.bindVertexArray(null)` before entering `CustomPass.onRender` and during `restoreState()`, preventing custom `gl.vertexAttribPointer` calls from mutating `RendererGl`'s internal `quadVao` / `polyVao`.
39
+
9
40
  ## [0.8.0] - 2026-12-04
10
41
 
11
42
  ### Added
package/README.md CHANGED
@@ -3,9 +3,9 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@holtjs/stage.svg)](https://www.npmjs.com/package/@holtjs/stage)
4
4
  [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
5
5
  [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen.svg)](package.json)
6
- [![20 Subpaths](https://img.shields.io/badge/subpaths-20%20tree--shakeable-informational.svg)](scripts/size.mjs)
6
+ [![21 Subpaths](https://img.shields.io/badge/subpaths-21%20tree--shakeable-informational.svg)](scripts/size.mjs)
7
7
 
8
- A zero-dependency, tracing-first **WebGPU / WebGL2 / Canvas2D** 2D & 2.5D game, UI, and 60 FPS programmable video engine written in strict TypeScript — covering GPU SDF panels, `StageKernel` plugins & unified `InputTimeline` automation, Flex/Wrap layout, damped springs, `SurfaceTree` barriers, zero-GC SoA ECS, FlowField/A* navigation, procedural foley audio, 2D cutout skeletal rigs, Dual-Grid chunked tilemaps, rotatable 2.5D camera projection, 2D normal-map lighting, and world delta saves.
8
+ A zero-dependency, tracing-first **WebGPU / WebGL2 / Canvas2D** 2D & 2.5D game, UI, and 60 FPS programmable video engine written in strict TypeScript — covering GPU SDF panels & shapes, 4/8-directional `SpriteObject` & `AnimationManager` (`bindEquipment` 3D Z-holdout layering + 6-DOF affine `syncAttachment`), `StageKernel` plugins & unified `InputTimeline` automation, Flex/Wrap layout, damped springs, `SurfaceTree` barriers, zero-GC SoA ECS, FlowField/A* navigation, procedural foley audio, 2D cutout skeletal rigs, Dual-Grid chunked tilemaps, rotatable 2.5D camera projection + oblique sun shadows, 2D normal-map & emissive lighting, and world delta saves.
9
9
 
10
10
  - **Official Docs & Playground**: https://holt.js.org
11
11
  - **npm**: https://www.npmjs.com/package/@holtjs/stage
@@ -16,7 +16,7 @@ A zero-dependency, tracing-first **WebGPU / WebGL2 / Canvas2D** 2D & 2.5D game,
16
16
 
17
17
  ## Highlights
18
18
 
19
- - **Zero runtime dependencies & 20 tree-shakeable subpaths**: Pure ESM TypeScript (`sideEffects: false`); individual subpaths range from **1.1 kB to 7.4 kB gzipped**.
19
+ - **Zero runtime dependencies & 21 tree-shakeable subpaths**: Pure ESM TypeScript (`sideEffects: false`); individual subpaths range from **1.1 kB to 15.9 kB gzipped**.
20
20
  - **WebGPU + WebGL2 + Isomorphic Canvas2D + Node 60 FPS Headless**:
21
21
  - **Native WebGPU (`@holtjs/stage/webgpu`)**: Zero-dependency `RendererWebGpu` + `requestWebGpuDevice()` with WGSL quad/polygon batching and WGSL analytical rounded/stepped-pixel SDF `PanelObject` pipelines across `NORMAL`, `ADD`, `MULTIPLY`, and `SCREEN` blends.
22
22
  - **WebGL2 Primary (`RendererGl`)**: 1-sampler zero-branch shader + 8-unit multi-texture uber-batcher, `InstancedBatchObject` (`drawElementsInstanced`), offscreen `StageRenderTarget` FBOs, GPU SDF panels, Sharp-Bilinear Pixel-AA, MTSDF vector icons, and state-isolated `CustomPassObject`.
@@ -39,18 +39,19 @@ A zero-dependency, tracing-first **WebGPU / WebGL2 / Canvas2D** 2D & 2.5D game,
39
39
  pnpm add @holtjs/stage
40
40
  ```
41
41
 
42
- ## 20 Subpath Exports
42
+ ## 21 Subpath Exports
43
43
 
44
44
  | Import Path | Gzip | Description | DOM Required? |
45
45
  |---|---|---|---|
46
- | `@holtjs/stage` | `57.3 kB` | Full engine barrel (`Stage`, `Game`, `Scene`, renderers, `InstancedBatch`, `Panel`, `StageKernel`, layout, tweens, tracing, surfaces) | Browser (`Game`/renderers) |
47
- | `@holtjs/stage/webgpu` | `7.4 kB` | Native WebGPU WGSL batch & analytical SDF `PanelObject` renderer (`RendererWebGpu`, `requestWebGpuDevice`) | Browser WebGPU |
48
- | `@holtjs/stage/kernel` | `4.8 kB` | `StageKernel`, `StagePlugin`, `ActionMap`, `createInputTimeline` (`trackId` clicks + cursor), recorder/replay | No |
49
- | `@holtjs/stage/headless` | `38.6 kB` | Zero-browser 60 FPS `createHeadlessStage`, `fastForward`, `renderStoryboard`, `createAudioTimeline` WAV mixer | No (`@napi-rs/canvas`) |
46
+ | `@holtjs/stage` | `71.3 kB` | Full engine barrel (`Stage`, `Game`, `Scene`, `SpriteObject` + `bindEquipment` + 6-DOF `syncAttachment`, `AnimationManager`, renderers, `ShapeBatch`, `InstancedBatch`, `Panel`, `StageKernel`, layout, tweens, tracing, surfaces) | Browser (`Game`/renderers) |
47
+ | `@holtjs/stage/anims` | `2.9 kB` | 4/8-directional & sprite-sheet `AnimationManager` (`createFromAtlas` with `inheritFrom` + `baseChar`, bare aliases, phase-preserving `playDirectional`) | No |
48
+ | `@holtjs/stage/webgpu` | `15.9 kB` | Native WebGPU WGSL batch & analytical SDF `PanelObject` / `ShapeBatch` renderer (`RendererWebGpu`, `requestWebGpuDevice`) | Browser WebGPU |
49
+ | `@holtjs/stage/kernel` | `4.9 kB` | `StageKernel`, `StagePlugin`, `ActionMap`, `createInputTimeline` (`trackId` clicks + cursor), recorder/replay | No |
50
+ | `@holtjs/stage/headless` | `50.4 kB` | Zero-browser 60 FPS `createHeadlessStage`, `fastForward`, `toRgbaInto`, `renderStoryboard`, `createAudioTimeline` WAV mixer | No (`@napi-rs/canvas`) |
50
51
  | `@holtjs/stage/rig2d` | `5.7 kB` | 2D cutout skeletal rig (`defineRig2DSkeleton`, `Rig2DInstance`, `mountRig2D`, `bakeCutoutAtlas`), O(1) slot swap & 2-layer mixer | No |
51
- | `@holtjs/stage/tilemap` | `3.5 kB` | Sparse `ChunkedTilemap`, 16-tile Dual-Grid & 47-tile Blob autotilers, biome generator, `mountChunkedTilemap` | No |
52
- | `@holtjs/stage/projection` | `1.6 kB` | Rotatable 2.5D `Camera25D` (`worldToScreen` ↔ `screenToGround`) + `mountStage25D` upright cylindrical billboards | No |
53
- | `@holtjs/stage/lighting` | `4.1 kB` | `DayNightCycle`, 3×3 Sobel normal-map baker, `Lighting2DSystem` (`MULTIPLY` lightmap), WebGL2 normal-lit sprite pass | No |
52
+ | `@holtjs/stage/tilemap` | `4.0 kB` | Sparse `ChunkedTilemap`, 16-tile Dual-Grid & 47-tile Blob autotilers, biome generator, chunk-cached `mountChunkedTilemap` | No |
53
+ | `@holtjs/stage/projection` | `2.8 kB` | Rotatable 2.5D `Camera25D` (`worldToScreen` ↔ `screenToGround`) + `mountStage25D` upright cylindrical billboards & oblique sun shadows | No |
54
+ | `@holtjs/stage/lighting` | `9.2 kB` | `DayNightCycle`, 3×3 Sobel normal-map baker, `Lighting2DSystem` (smooth radial glow + `bindEmissive`), batched `createSceneNormalLitPass` | No |
54
55
  | `@holtjs/stage/world` | `2.8 kB` | `ItemRegistry`, `InventoryContainer` (spoilage), `RecipeRegistry`, `WorkstationScheduler`, `HWLD` binary `WorldDeltaSave` | No |
55
56
  | `@holtjs/stage/flex` | `2.3 kB` | Pure 1D Flex & Wrap layout solvers (`computeFlexLayout`, `computeWrapLayout`, `resolvePadding`) | No |
56
57
  | `@holtjs/stage/tween` | `1.4 kB` | Deterministic `TweenManager`, `Easings`, and damped springs | No |
@@ -98,8 +98,13 @@ interface SpriteSheetConfig {
98
98
  margin?: number;
99
99
  spacing?: number;
100
100
  }
101
- /** Frame-space socket tuple: `[x, y]` or oriented `[x, y, angleRad, zBias]` (`zBias = +1` front, `-1` behind). */
102
- type FrameAnchorTuple = readonly [number, number] | readonly [number, number, number, number];
101
+ /**
102
+ * Frame-space socket tuple:
103
+ * - `[x, y]` point
104
+ * - `[x, y, angleRad, zBias]` oriented shaft (`zBias = +1` front, `-1` behind)
105
+ * - `[x, y, angleRad, zBias, ux, uy, vx, vy]` full 2x2 projected 3D->2D basis (`u` = foreshortened shaft, `v` = sheared blade axis)
106
+ */
107
+ type FrameAnchorTuple = readonly [number, number] | readonly [number, number, number, number] | readonly [number, number, number, number, number, number, number, number];
103
108
  interface FrameExtraMeta {
104
109
  /** Exact pixel pivot X from trimmed frame top-left `(0, 0)` (takes precedence over `pivotX` to avoid float drift). */
105
110
  ax?: number;
@@ -118,6 +123,9 @@ interface FrameExtraMeta {
118
123
  /** Optional character/actor identifier from offline baker metadata (e.g. `'chars/survivor'` or `'survivor'`). */
119
124
  char?: string;
120
125
  actor?: string;
126
+ /** Optional parent/base character identifier (`@holtjs/craft/three` `bakeEquipment` sets `baseChar` so `createFromAtlas` inherits clip rules!). */
127
+ baseChar?: string;
128
+ baseActor?: string;
121
129
  /** Optional animation clip name from offline baker metadata (e.g. `'walk'`, `'idle'`, `'attack'`). */
122
130
  clip?: string;
123
131
  /** Optional discrete direction index (`0 .. dirs - 1`) or label (`'down'`, `'right'`, ...). */
@@ -128,6 +136,8 @@ interface FrameExtraMeta {
128
136
  frames?: number;
129
137
  /** Optional loop hint from offline baker (`true` for locomotion/idle, `false` for one-shot actions). */
130
138
  loop?: boolean;
139
+ /** True when this frame is an all-transparent occlusion placeholder (`1x1` cell, `2x2` transparent placeholder, or explicit `empty: true`). */
140
+ empty?: boolean;
131
141
  }
132
142
  interface AtlasJsonLike {
133
143
  readonly yaw?: number;
@@ -207,18 +217,21 @@ declare class Frame {
207
217
  emissiveCenter: readonly [number, number] | null;
208
218
  emissivePower: number;
209
219
  actor: string | null;
220
+ baseActor: string | null;
210
221
  clip: string | null;
211
222
  dir: number | string | null;
212
223
  animFrameIndex: number | null;
213
224
  animLoop: boolean | undefined;
225
+ /** True when the frame contains zero visible pixels (`1x1` cell, `<=4x4` all-transparent placeholder, or explicit `empty: true`). */
226
+ empty: boolean;
214
227
  constructor(texture: Texture, name: string | number, sourceIndex: number, x: number, y: number, w: number, h: number, meta?: FrameExtraMeta);
215
228
  setSize(width: number, height: number, x?: number, y?: number): this;
216
229
  /** Set normalized `[0..1]` per-frame pivot (marks `customPivot = true`). */
217
230
  setPivot(pivotX: number, pivotY: number): this;
218
231
  /** Set exact pixel pivot `(ax, ay)` from trimmed frame top-left `(0, 0)` (avoids float rounding drift). */
219
232
  setPixelPivot(ax: number, ay: number): this;
220
- /** Attach or update a named pixel socket `(x, y)` (with optional projected `angleRad` & front/back `zBias`). */
221
- setAnchor(name: string, x: number, y: number, angleRad?: number, zBias?: number): this;
233
+ /** Attach or update a named pixel socket `(x, y)` (with optional `angleRad`, `zBias`, and 2x2 projected basis `[ux, uy, vx, vy]`). */
234
+ setAnchor(name: string, x: number, y: number, angleRad?: number, zBias?: number, ux?: number, uy?: number, vx?: number, vy?: number): this;
222
235
  /** Read a named pixel socket `[x, y]` or `[x, y, angleRad, zBias]` (falls back to `emissiveCenter` when `name === 'emissive'`). */
223
236
  getAnchor(name: string): FrameAnchorTuple | null;
224
237
  applyMeta(meta: FrameExtraMeta): this;
@@ -343,6 +356,12 @@ interface AtlasAutoAnimOptions {
343
356
  readonly defaultRepeat?: number;
344
357
  /** Per-clip or per-`actor/clip` overrides, e.g. `{ walk: { frameRate: 10, events: { 1: 'footstep', 4: 'footstep' } } }`. */
345
358
  readonly clips?: Readonly<Record<string, AtlasClipRule>>;
359
+ /**
360
+ * Inherit clip rules (`frameRate`, `duration`, `repeat`, `yoyo`, `events`) across secondary/equipment actors.
361
+ * Supports exact actor keys (`{ 'held/axe': 'survivor' }`) and prefix globs (`{ 'held/*': 'survivor', 'equip/*': 'chars/survivor' }`).
362
+ * Frames baked via `@holtjs/craft/three` `bakeEquipment` also inherit automatically via frame `baseChar` metadata!
363
+ */
364
+ readonly inheritFrom?: Readonly<Record<string, string>>;
346
365
  }
347
366
  interface DirectionalAnimGroup {
348
367
  readonly baseKey: string;
package/dist/anims.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as AtlasClipRule, c as GenerateFrameNamesConfig, i as AtlasAutoAnimOptions, l as GenerateFrameNumbersConfig, n as AnimationFrameInput, o as CompiledAnimationFrame, r as AnimationManager, s as DirectionalAnimGroup, t as AnimationConfig, u as StageAnimation } from "./anims-ClNi6zZQ.js";
1
+ import { a as AtlasClipRule, c as GenerateFrameNamesConfig, i as AtlasAutoAnimOptions, l as GenerateFrameNumbersConfig, n as AnimationFrameInput, o as CompiledAnimationFrame, r as AnimationManager, s as DirectionalAnimGroup, t as AnimationConfig, u as StageAnimation } from "./anims-xOSYNG79.js";
2
2
  export { AnimationConfig, AnimationFrameInput, AnimationManager, AtlasAutoAnimOptions, AtlasClipRule, CompiledAnimationFrame, DirectionalAnimGroup, GenerateFrameNamesConfig, GenerateFrameNumbersConfig, StageAnimation };
package/dist/anims.js CHANGED
@@ -74,12 +74,30 @@ function actorBasename(actor) {
74
74
  const slash = actor.lastIndexOf("/");
75
75
  return slash >= 0 ? actor.slice(slash + 1) : actor;
76
76
  }
77
+ function matchInheritActor(actor, inheritFrom) {
78
+ if (!actor || !inheritFrom) return null;
79
+ if (Object.prototype.hasOwnProperty.call(inheritFrom, actor)) return inheritFrom[actor];
80
+ const bare = actorBasename(actor);
81
+ if (bare !== actor && Object.prototype.hasOwnProperty.call(inheritFrom, bare)) return inheritFrom[bare];
82
+ let bestTarget = null;
83
+ let bestLen = -1;
84
+ for (const [pattern, target] of Object.entries(inheritFrom)) {
85
+ if (!pattern.endsWith("*")) continue;
86
+ const prefix = pattern.slice(0, -1);
87
+ if (actor.startsWith(prefix) && prefix.length > bestLen) {
88
+ bestLen = prefix.length;
89
+ bestTarget = target;
90
+ }
91
+ }
92
+ return bestTarget;
93
+ }
77
94
  function parseFrameConvention(frame) {
78
95
  const name = String(frame.name);
79
96
  if (name === "__BASE") return null;
80
97
  if (frame.clip && frame.animFrameIndex !== null) return {
81
98
  frameName: name,
82
99
  actor: frame.actor ?? "",
100
+ baseActor: frame.baseActor,
83
101
  clip: frame.clip,
84
102
  dir: frame.dir,
85
103
  frameIdx: frame.animFrameIndex,
@@ -92,6 +110,7 @@ function parseFrameConvention(frame) {
92
110
  return {
93
111
  frameName: name,
94
112
  actor: slashDir[1],
113
+ baseActor: frame.baseActor,
95
114
  clip: slashDir[2],
96
115
  dir,
97
116
  frameIdx: Number(slashDir[4])
@@ -101,6 +120,7 @@ function parseFrameConvention(frame) {
101
120
  if (slashFlat) return {
102
121
  frameName: name,
103
122
  actor: slashFlat[1],
123
+ baseActor: frame.baseActor,
104
124
  clip: slashFlat[2],
105
125
  dir: null,
106
126
  frameIdx: Number(slashFlat[3])
@@ -112,6 +132,7 @@ function parseFrameConvention(frame) {
112
132
  return {
113
133
  frameName: name,
114
134
  actor: underDir[1],
135
+ baseActor: frame.baseActor,
115
136
  clip: underDir[2],
116
137
  dir,
117
138
  frameIdx: Number(underDir[4])
@@ -121,6 +142,7 @@ function parseFrameConvention(frame) {
121
142
  if (underTwo) return {
122
143
  frameName: name,
123
144
  actor: underTwo[1],
145
+ baseActor: frame.baseActor,
124
146
  clip: underTwo[2],
125
147
  dir: null,
126
148
  frameIdx: Number(underTwo[3])
@@ -129,6 +151,7 @@ function parseFrameConvention(frame) {
129
151
  if (underOne) return {
130
152
  frameName: name,
131
153
  actor: "",
154
+ baseActor: frame.baseActor,
132
155
  clip: underOne[1],
133
156
  dir: null,
134
157
  frameIdx: Number(underOne[2])
@@ -302,9 +325,26 @@ var AnimationManager = class {
302
325
  }
303
326
  set.add(p.actor);
304
327
  }
305
- const resolveRule = (actor, clip) => {
306
- const bare = actor ? actorBasename(actor) : "";
307
- return (actor ? rules[`${actor}/${clip}`] ?? rules[`${actor}_${clip}`] : void 0) ?? (bare && bare !== actor ? rules[`${bare}/${clip}`] ?? rules[`${bare}_${clip}`] : void 0) ?? rules[clip];
328
+ const lookupActorRule = (act, clip) => {
329
+ if (!act) return void 0;
330
+ const bare = actorBasename(act);
331
+ const direct = rules[`${act}/${clip}`] ?? rules[`${act}_${clip}`] ?? (bare && bare !== act ? rules[`${bare}/${clip}`] ?? rules[`${bare}_${clip}`] : void 0);
332
+ if (direct) return direct;
333
+ const fullSet = actorsByBase.get(bare);
334
+ if (fullSet && fullSet.size === 1) {
335
+ const fullAct = Array.from(fullSet)[0];
336
+ if (fullAct !== act) return rules[`${fullAct}/${clip}`] ?? rules[`${fullAct}_${clip}`];
337
+ }
338
+ };
339
+ const resolveRule = (actor, clip, baseActorHint) => {
340
+ const own = lookupActorRule(actor, clip);
341
+ if (own) return own;
342
+ const parentActor = matchInheritActor(actor, options.inheritFrom) ?? baseActorHint;
343
+ if (parentActor && parentActor !== actor) {
344
+ const inherited = lookupActorRule(parentActor, clip);
345
+ if (inherited) return inherited;
346
+ }
347
+ return rules[clip];
308
348
  };
309
349
  const buckets = /* @__PURE__ */ new Map();
310
350
  for (const p of parsed) {
@@ -313,12 +353,16 @@ var AnimationManager = class {
313
353
  if (!b) {
314
354
  b = {
315
355
  actor: p.actor,
356
+ baseActor: p.baseActor,
316
357
  clip: p.clip,
317
358
  byDir: /* @__PURE__ */ new Map(),
318
359
  loopHint: p.loop
319
360
  };
320
361
  buckets.set(bKey, b);
321
- } else if (b.loopHint === void 0 && p.loop !== void 0) b.loopHint = p.loop;
362
+ } else {
363
+ if (b.loopHint === void 0 && p.loop !== void 0) b.loopHint = p.loop;
364
+ if (b.baseActor === null && p.baseActor !== null) b.baseActor = p.baseActor;
365
+ }
322
366
  let arr = b.byDir.get(p.dir);
323
367
  if (!arr) {
324
368
  arr = [];
@@ -329,7 +373,7 @@ var AnimationManager = class {
329
373
  const created = [];
330
374
  const atlasYaw = tex.atlasYaw ?? 0;
331
375
  for (const b of buckets.values()) {
332
- const rule = resolveRule(b.actor, b.clip);
376
+ const rule = resolveRule(b.actor, b.clip, b.baseActor);
333
377
  const repeat = rule?.repeat !== void 0 ? rule.repeat : options.defaultRepeat !== void 0 ? options.defaultRepeat : b.loopHint !== void 0 ? b.loopHint ? -1 : 0 : LOOP_CLIP_RE.test(b.clip) ? -1 : 0;
334
378
  const fps = rule?.frameRate ?? defaultFps;
335
379
  const bare = b.actor ? actorBasename(b.actor) : "";