@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,2 +1,2 @@
1
- import { $ as WebGpuBootstrapResult, Q as RequestWebGpuOptions, X as RendererWebGpu, Z as RendererWebGpuOptions, et as WebGpuCanvasContextLike, nt as requestWebGpuDevice, tt as WebGpuDeviceLike } from "./game-CEa0m4eX.js";
1
+ import { $ as WebGpuBootstrapResult, Q as RequestWebGpuOptions, X as RendererWebGpu, Z as RendererWebGpuOptions, et as WebGpuCanvasContextLike, nt as requestWebGpuDevice, tt as WebGpuDeviceLike } from "./game-DnJYRLZP.js";
2
2
  export { RendererWebGpu, RendererWebGpuOptions, RequestWebGpuOptions, WebGpuBootstrapResult, WebGpuCanvasContextLike, WebGpuDeviceLike, requestWebGpuDevice };
@@ -1 +1 @@
1
- export { t as RendererWebGpu, n as requestWebGpuDevice } from "./renderer-webgpu-BXU-ZDIp.js";
1
+ export { t as RendererWebGpu, n as requestWebGpuDevice } from "./renderer-webgpu-BZ3J971y.js";
package/dist/rig2d.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { T as BlendMode } from "./anims-ClNi6zZQ.js";
2
- import { Ct as ImageObject, Pt as SceneHostLike, St as Graphics, ft as Container } from "./game-CEa0m4eX.js";
2
+ import { Ct as ImageObject, Pt as SceneHostLike, St as Graphics, ft as Container } from "./game-DnJYRLZP.js";
3
3
  export type RigCurveKind = 'linear' | 'step' | 'smoothstep' | 'outBack';
4
4
  export interface RigBoneDef {
5
5
  name: string;
package/dist/tilemap.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Pt as SceneHostLike, ft as Container, ut as BlitterObject } from "./game-CEa0m4eX.js";
1
+ import { Pt as SceneHostLike, ft as Container, ut as BlitterObject } from "./game-DnJYRLZP.js";
2
2
  /** Pack signed 16-bit chunk coordinates `[-32768..32767]` into a single 32-bit integer Map key (zero string allocation). */
3
3
  export declare function packChunkKey(cx: number, cy: number): number;
4
4
  export declare function unpackChunkX(key: number): number;
package/dist/trace.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { B as SceneDigestSurfaceEntry, F as SceneDigestEngineSandbox, H as SceneDigestSurfaces, I as SceneDigestNode, L as SceneDigestOptions, N as SceneDigest, P as SceneDigestActiveFocus, R as SceneDigestOverlayStats, U as buildSceneDigest, V as SceneDigestSurfaceSource, W as sanitizeTrackToken, z as SceneDigestSandbox } from "./game-CEa0m4eX.js";
1
+ import { B as SceneDigestSurfaceEntry, F as SceneDigestEngineSandbox, H as SceneDigestSurfaces, I as SceneDigestNode, L as SceneDigestOptions, N as SceneDigest, P as SceneDigestActiveFocus, R as SceneDigestOverlayStats, U as buildSceneDigest, V as SceneDigestSurfaceSource, W as sanitizeTrackToken, z as SceneDigestSandbox } from "./game-DnJYRLZP.js";
2
2
  export { SceneDigest, SceneDigestActiveFocus, SceneDigestEngineSandbox, SceneDigestNode, SceneDigestOptions, SceneDigestOverlayStats, SceneDigestSandbox, SceneDigestSurfaceEntry, SceneDigestSurfaceSource, SceneDigestSurfaces, buildSceneDigest, sanitizeTrackToken };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holtjs/stage",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Zero-dependency TypeScript stage engine for 2D WebGPU/WebGL2/Canvas2D games, GPU SDF UI, procedural audio, StageKernel plugins, tracing-native observability, and deterministic 60 FPS headless image & video rendering.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Botiverse, Inc.",
@@ -5,7 +5,7 @@ description: Build zero-dependency WebGPU/WebGL2/Canvas2D 2D & 2.5D games, GPU S
5
5
 
6
6
  # Building 2D/2.5D Games, WebGPU UI & 60 FPS Video with `@holtjs/stage`
7
7
 
8
- Use this skill whenever creating or modifying a browser 2D/2.5D game, WebGPU/WebGL2 canvas UI, survival sandbox, automated `InputTimeline` test, or pure-Node headless image/storyboard/60 FPS video pipeline built on `@holtjs/stage` (`v0.8.0`, 21 subpaths).
8
+ Use this skill whenever creating or modifying a browser 2D/2.5D game, WebGPU/WebGL2 canvas UI, survival sandbox, automated `InputTimeline` test, or pure-Node headless image/storyboard/60 FPS video pipeline built on `@holtjs/stage` (`v0.9.0`, 21 subpaths).
9
9
 
10
10
  For the exhaustive exported symbol list across all 21 subpaths, see [references/subpaths.md](references/subpaths.md).
11
11
 
@@ -143,9 +143,9 @@ const dgAtlas = bakeDualGridTileset('island_dg', 36, [
143
143
  { id: 'meadow', fillColor: 0x5c8d3e, edgeColor: 0x3f6212, matches: (t) => t >= SurvivalBiomes.MEADOW },
144
144
  ]);
145
145
 
146
- // 2. Rotatable 2.5D Oblique Camera + Upright Cylindrical Billboards
146
+ // 2. Rotatable 2.5D Oblique Camera + Upright Cylindrical Billboards + True Oblique Sun Silhouette Shadows (`shadows: true`)
147
147
  const cam25 = new Camera25D({ viewportWidth: 1280, viewportHeight: 720, pitch: 0.84, zoom: 1.4 });
148
- const stage25 = mountStage25D(scene, cam25, { depth: 10 });
148
+ const stage25 = mountStage25D(scene, cam25, { depth: 10, shadows: true });
149
149
  const mountedTerrain = mountChunkedTilemap(scene, tilemap, dgAtlas);
150
150
  mountedTerrain.container.removeFromDisplayList();
151
151
  stage25.groundWorld.add(mountedTerrain.container);
@@ -175,17 +175,20 @@ rig.playOverlay('chop', { maskBones: ['arm_r', 'hand_r', 'torso'] }); // chops w
175
175
  const heroView = mountRig2D(scene, rig, { depth: 20, trackId: 'actor.survivor' });
176
176
  stage25.registerBillboard(heroView.container, 0, 0);
177
177
 
178
- // 4. Day/Night Cycle + Offscreen MULTIPLY 2D Lightmap with Flickering Torches
178
+ // 4. Day/Night Cycle + Zero-Band Radial Lightmap + Self-Lit Emissive Glow + Scene Normal-Map Rim Pass
179
179
  const dayNight = new DayNightCycle({ dayLengthMs: 60_000, initialTime01: 0.72 }); // dusk -> night
180
180
  const lighting = new Lighting2DSystem(scene, { width: 1280, height: 720, depth: 500 });
181
- lighting.addLight({ id: 'torch', x: 0, y: 0, z: 24, radius: 240, color: 0xffa94d, intensity: 1.0, flicker: 0.18 });
181
+ // Auto-drive flickering point light from `Frame.emissiveCenter` AND render `actors_emissive` above night darkness:
182
+ lighting.bindEmissive(campfireSprite, { radius: 220, color: 0xffa94d, intensity: 1.2, flicker: 0.14 });
183
+ createSceneNormalLitPass(scene, { source: stage25.billboardLayer, lighting, mode: 'rim' });
182
184
 
183
185
  // Inside Scene.update(_t, deltaMs):
184
186
  if (scene.game.kernel.actions.justPressed('rotateCW')) cam25.rotateSteps(1);
185
187
  stage25.update(deltaMs);
186
188
  mountedTerrain.update(cam25.getGroundViewportBounds());
187
189
  heroView.update(deltaMs);
188
- lighting.update(deltaMs, (wx, wy, wz, out) => { const p = cam25.worldToScreen(wx, wy, wz); out.x = p.x; out.y = p.y; out.scale = p.scale; });
190
+ const dnState = lighting.update(deltaMs, (wx, wy, wz, out) => { const p = cam25.worldToScreen(wx, wy, wz); out.x = p.x; out.y = p.y; out.scale = p.scale; });
191
+ stage25.syncDayNight(dnState); // updates oblique sun shadow angle & auto-fades sun shadows out at night!
189
192
 
190
193
  // 5. Compact Binary World Delta Save (only modified tiles + inventories + workstations)
191
194
  const deltaBytes = encodeWorldDeltaBytes(captureWorldDelta({ seed: 1337, simTimeMs: 42_000, tilemap }));
@@ -1,10 +1,10 @@
1
1
  # `@holtjs/stage` Subpath API Quick Reference
2
2
 
3
- All symbols verified against `src/*.ts` (`@holtjs/stage@0.8.0`, 21 subpaths).
3
+ All symbols verified against `src/*.ts` (`@holtjs/stage@0.9.0`, 21 subpaths).
4
4
 
5
- ## `@holtjs/stage` (~68.0 kB gz · Core Engine Barrel)
5
+ ## `@holtjs/stage` (~69.3 kB gz · Core Engine Barrel)
6
6
  - **Bootstrap & Lifecycle**: `Stage` / `Stage2D` (namespaces), `AUTO`, `WEBGPU`, `WEBGL`, `CANVAS`, `Scale` (`NONE`, `FIT`, `RESIZE`), `Scenes`, `Game` (`.stepSimOnly()`, `.kernel`, `.anims`), `Scene` (`.update()` simulation + `.preRender()` presentation, `.anims`), `SceneManager`, `ScaleManager` (`.fitToContainer()`), `GameLoop`, `EngineClock`, `LoaderPlugin` (`.atlas()`), `JsonCache`, `GameObjectFactory` (`scene.add.sprite`, `shapeBatch`, `instancedBatch`, `customPass`, `panel`, `blitter`, etc.), `AnimationManager` (`.create()`, `.createFromAtlas()`, `.generateFrameNames()`, `.generateFrameNumbers()`)
7
- - **Display Graph**: `DisplayList`, `DisplayObject` (reactive `.zIndex`), `Container`, `ImageObject` (`.useFramePivot()`, `.getAnchor(name, space?)`, `.getAnchorPose(name, space?)`, `.syncAttachment(child, name, opts?)`), `SpriteObject` (`.play()`, `.playDirectional()`, `.onAnimEvent()`, `.pause()`, `.resume()`, `.stop()`), `NineSliceObject`, `TileSpriteObject`, `RectangleObject`, `PanelObject`, `MsdfIconObject`, `TextObject`, `Graphics` (GPU SDF fast-path + Canvas2D `Path2D` cache), `BlitterObject`, `InstancedBatchObject`, `ShapeBatchObject` (zero-texture SoA analytical SDF shapes), `CustomPassObject` (`restoreState: true` default)
7
+ - **Display Graph**: `DisplayList`, `DisplayObject` (reactive `.zIndex`, 6-DOF `.skewX`/`.skewY`/`.setSkew()`), `Container`, `ImageObject` (`.useFramePivot()`, `.getAnchor(name, space?)`, `.getAnchorPose(name, space?)`, `.syncAttachment(child, name, opts?)`), `SpriteObject` (`.play()`, `.playDirectional()`, `.onAnimEvent()`, `.pause()`, `.resume()`, `.stop()`), `NineSliceObject`, `TileSpriteObject`, `RectangleObject`, `PanelObject`, `MsdfIconObject`, `TextObject`, `Graphics` (GPU SDF fast-path + Canvas2D `Path2D` cache), `BlitterObject`, `InstancedBatchObject`, `ShapeBatchObject` (zero-texture SoA analytical SDF shapes), `CustomPassObject` (`restoreState: true` default, VAO-isolated)
8
8
  - **Renderers & GPU Batchers**: `RendererWebGpu`, `requestWebGpuDevice`, `RendererGl` (`.createRenderTarget()`, `.renderToTarget(rt, content, cam?)`, `.restoreState()`), `StageRenderTarget` (`.camera`, `.readPixels()`), `Renderer2D` (4-corner frustum culling + sprite tint LRU cache), `SdfPanelBatcher`, `MsdfIconBatcher`, `PixelAaBatcher`, `Camera` (`.configureHiDpi()`, `.setBounds()`, `.clearBounds()`, `.startFollow()`, `.stopFollow()`, `.screenToWorld()`, `.worldToScreen()`, `.logicalToWorld()`, `.worldToLogical()`, `.clientToWorld()`), `Texture` (`.atlasYaw`), `CanvasTexture`, `TextureSource`, `Frame` (`.setPivot()`, `.setPixelPivot()`, `.setAnchor()`, `.getAnchor()`), `TextureManager` (`.exists()`, `.addAtlas()`, `.addCanvas()`, `.get()`)
9
9
  - **Kernel & Input**: `StageKernel`, `ActionMap`, `createInputTimeline`, `createInputRecorder`, `createInputReplay`, `EventEmitter`, `Pointer`, `KeyboardPlugin` (`.isDown()`, `.justPressed()`, `.justReleased()`, `.injectKey()`), `InputPlugin`
10
10
  - **Math & Color**: `BlendModes` (`NORMAL`, `ADD`, `MULTIPLY`, `SCREEN`), `TintModes`, `FilterMode`, `WHITE_RGB`, `BLACK_RGB`, `HEX_MASK`, `createMatrix2D`, `parseColor`, `rgbToCss`, `packColorAbgr`
@@ -43,16 +43,16 @@ All symbols verified against `src/*.ts` (`@holtjs/stage@0.8.0`, 21 subpaths).
43
43
  - Scene Streaming Adapter: `mountChunkedTilemap(scene, tilemap, atlas, opts?)` -> `MountedChunkedTilemap` (`.container`, `.update(viewBounds)`, `.destroy()`)
44
44
  - Types: `TileChunk`, `ChunkGeneratorFn`, `ChunkedTilemapOptions`, `IslandBiomeConfig`, `DualGridLayerSpec`, `BakedDualGridAtlas`, `MountedChunkedTilemap`
45
45
 
46
- ## `@holtjs/stage/projection` (~1.6 kB gz · zero DOM)
46
+ ## `@holtjs/stage/projection` (~2.8 kB gz · zero DOM)
47
47
  - `Camera25D`: `.worldToScreen(wx, wy, wz?, out?)`, `.screenToGround(sx, sy, planeZ?, out?)` (exact inverse across any 360° `yaw`), `.rotateSteps(steps, stepAngleRad?)`, `.setYawImmediate(yawRad)`, `.step(deltaMs)`, `.getGroundViewportBounds()`, `.computeSunShadowVector(...)`
48
- - `mountStage25D(scene, cam, opts?)` -> `Stage25DRig` (`.groundWorld`, `.shadowLayer`, `.billboardLayer`, `.registerBillboard(node, wx, wy, opts?)`, `.removeBillboard(entryOrNode)`, `.update(deltaMs?)`, `.destroy()`)
49
- - Types: `Camera25DConfig`, `ProjectedPoint25D`, `BillboardEntry`, `Stage25DRig`
48
+ - `mountStage25D(scene, cam, opts?)` -> `Stage25DRig` (`.groundWorld`, `.shadowLayer`, `.billboardLayer`, `.registerBillboard(node, wx, wy, opts?)`, `.removeBillboard(entryOrNode)`, `.setSunShadow(cfg)`, `.syncDayNight(state)`, `.update(deltaMs?)`, `.destroy()`)
49
+ - Types: `Camera25DConfig`, `ProjectedPoint25D`, `Shadow25DConfig`, `BillboardOptions25D`, `BillboardEntry`, `MountStage25DOptions`, `Stage25DRig`
50
50
 
51
- ## `@holtjs/stage/lighting` (~4.1 kB gz · zero DOM)
52
- - `DayNightCycle`: `.step(deltaMs)`, `.setTime01(t)`, `.sample(out?)` -> `DayNightState` (`phase`, `ambientRgb`, `ambientIntensity`, `sunAzimuth`, `sunElevation`, `shadowScale`), `lerpRgb`
51
+ ## `@holtjs/stage/lighting` (~9.2 kB gz · zero DOM)
52
+ - `DayNightCycle`: `.step(deltaMs)`, `.setTime01(t)`, `.sample(out?)` -> `DayNightState` (`phase`, `ambientRgb`, `darkness`, `sunAzimuthRad`, `sunElevationRad`), `lerpRgb`
53
53
  - Normal Maps & Per-Pixel Evaluation: `computeNormalMapPixels(rgba, w, h, opts?)` (3×3 Sobel height-to-normal), `bakeNormalMapCanvas(srcCanvas, createCanvas?, opts?)`, `evaluateNormalLitPixel(...)`
54
- - Scene Lightmap & WebGL2 Normal Pass: `Lighting2DSystem` (`.addLight(light)`, `.getLight(id)`, `.removeLight(id)`, `.setAmbientOverride(rgb)`, `.update(dayNight, simTimeMs, projectToScreen?)`, `.destroy()`), `createNormalLitSpritePass(scene, opts)`
55
- - Types: `DayPhase`, `DayNightConfig`, `DayNightState`, `NormalMapBakeOptions`, `PointLight2D`, `Lighting2DSystemOptions`, `NormalLitQuad`
54
+ - Scene Lightmap, Self-Lit Emissive & Batched Normal Passes: `Lighting2DSystem` (`.emissiveLayer`, `.screenLights`, `.currentAmbientRgb`, `.addLight(light)`, `.getLight(id)`, `.removeLight(id)`, `.bindEmissive(sprite, opts?)`, `.setAmbientOverride(rgb)`, `.update(deltaMs, projectToScreen?)`, `.destroy()`), `createNormalLitSpritePass(scene, diffKey, normKey, getQuadsAndLights)`, `createSceneNormalLitPass(scene, opts)`
55
+ - Types: `DayPhase`, `DayNightConfig`, `DayNightState`, `NormalMapBakeOptions`, `PointLight2D`, `ScreenLightSample2D`, `EmissiveBindOptions`, `EmissiveBinding`, `Lighting2DSystemOptions`, `NormalLitQuad`, `SceneNormalLitPassOptions`
56
56
 
57
57
  ## `@holtjs/stage/world` (~2.8 kB gz · zero DOM)
58
58
  - Items, Spoilage & Crafting: `ItemRegistry`, `InventoryContainer` (`.addItem()`, `.removeItem()`, `.countItem()`, `.hasItems()`, `.stepSpoilage(deltaMs)`), `RecipeRegistry` (`.canCraft()`, `.craftInstant()`), `WorkstationInstance` (`.enqueue()`, `.step()`), `WorkstationScheduler` (`.stepAll(deltaMs)` offline catch-up)