@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.
- package/CHANGELOG.md +27 -0
- package/dist/{anims-CS0rfUIz.d.ts → anims-ClNi6zZQ.d.ts} +11 -9
- package/dist/anims.d.ts +1 -1
- package/dist/display-C_NPwPrE.js +1945 -0
- package/dist/{game-BnSWR44q.js → game-C-yXzyAX.js} +39 -21
- package/dist/{game-3L9wS-Bv.d.ts → game-DnJYRLZP.d.ts} +48 -3
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -2
- package/dist/joystick.d.ts +1 -1
- package/dist/kernel.d.ts +1 -1
- package/dist/lighting.d.ts +99 -15
- package/dist/lighting.js +602 -98
- package/dist/projection.d.ts +47 -14
- package/dist/projection.js +200 -4
- package/dist/{renderer-webgpu-alSDj9RR.js → renderer-webgpu-BZ3J971y.js} +43 -1831
- package/dist/renderer-webgpu.d.ts +1 -1
- package/dist/renderer-webgpu.js +1 -1
- package/dist/rig2d.d.ts +2 -2
- package/dist/tilemap.d.ts +1 -1
- package/dist/trace.d.ts +1 -1
- package/package.json +1 -1
- package/skills/stage/SKILL.md +11 -7
- package/skills/stage/references/subpaths.md +10 -10
|
@@ -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-
|
|
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 };
|
package/dist/renderer-webgpu.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as RendererWebGpu, n as requestWebGpuDevice } from "./renderer-webgpu-
|
|
1
|
+
export { t as RendererWebGpu, n as requestWebGpuDevice } from "./renderer-webgpu-BZ3J971y.js";
|
package/dist/rig2d.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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-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 {
|
|
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-
|
|
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.
|
|
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.",
|
package/skills/stage/SKILL.md
CHANGED
|
@@ -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
|
+
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);
|
|
@@ -164,7 +164,8 @@ survivor.trackId = 'actor.survivor';
|
|
|
164
164
|
survivor.onAnimEvent((ev) => { if (ev === 'footstep') playStepSfx(); });
|
|
165
165
|
stage25.registerBillboard(survivor, 0, 0);
|
|
166
166
|
// Inside update(): survivor.playDirectional('survivor/walk', Math.atan2(vy, vx), { cameraYaw: cam25.yaw });
|
|
167
|
-
// Attach held weapon
|
|
167
|
+
// Attach held weapon with exact 3D->2D projected shaft angle, O(2) blade mirroring & front/back zIndex occlusion:
|
|
168
|
+
// survivor.syncAttachment(axeSprite, 'hand', { restAngle: -Math.PI / 2, mirrorBlade: true });
|
|
168
169
|
|
|
169
170
|
// 3B. Or 2D Cutout Skeletal Rig: O(1) equipment swap + 2-layer bone-masked overlay animation
|
|
170
171
|
const rig = new Rig2DInstance(heroSkeleton);
|
|
@@ -174,17 +175,20 @@ rig.playOverlay('chop', { maskBones: ['arm_r', 'hand_r', 'torso'] }); // chops w
|
|
|
174
175
|
const heroView = mountRig2D(scene, rig, { depth: 20, trackId: 'actor.survivor' });
|
|
175
176
|
stage25.registerBillboard(heroView.container, 0, 0);
|
|
176
177
|
|
|
177
|
-
// 4. Day/Night Cycle +
|
|
178
|
+
// 4. Day/Night Cycle + Zero-Band Radial Lightmap + Self-Lit Emissive Glow + Scene Normal-Map Rim Pass
|
|
178
179
|
const dayNight = new DayNightCycle({ dayLengthMs: 60_000, initialTime01: 0.72 }); // dusk -> night
|
|
179
180
|
const lighting = new Lighting2DSystem(scene, { width: 1280, height: 720, depth: 500 });
|
|
180
|
-
|
|
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' });
|
|
181
184
|
|
|
182
185
|
// Inside Scene.update(_t, deltaMs):
|
|
183
186
|
if (scene.game.kernel.actions.justPressed('rotateCW')) cam25.rotateSteps(1);
|
|
184
187
|
stage25.update(deltaMs);
|
|
185
188
|
mountedTerrain.update(cam25.getGroundViewportBounds());
|
|
186
189
|
heroView.update(deltaMs);
|
|
187
|
-
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!
|
|
188
192
|
|
|
189
193
|
// 5. Compact Binary World Delta Save (only modified tiles + inventories + workstations)
|
|
190
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.
|
|
3
|
+
All symbols verified against `src/*.ts` (`@holtjs/stage@0.9.0`, 21 subpaths).
|
|
4
4
|
|
|
5
|
-
## `@holtjs/stage` (~
|
|
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`, `Container`, `ImageObject` (`.useFramePivot()`, `.getAnchor(name, space?)`), `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.7.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` (~
|
|
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` (~
|
|
52
|
-
- `DayNightCycle`: `.step(deltaMs)`, `.setTime01(t)`, `.sample(out?)` -> `DayNightState` (`phase`, `ambientRgb`, `
|
|
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 &
|
|
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)
|