@jgengine/core 0.32.0 → 0.34.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
@@ -26,6 +26,64 @@ At publish, rename this heading to the new version and mirror the entries into
26
26
  `packages/core/src/meta/changelog.ts` (the typed `CHANGELOG` export).
27
27
  -->
28
28
 
29
+ ## 0.34.0
30
+
31
+ ### Migrate
32
+
33
+ - **Bump lockstep SDK packages to `^0.34.0`:** `@jgengine/{core,rapier,react,ws,node,sql,convex,shell,editor,assets,navbake}`. CLI `jgengine` is `0.31.0`; `@jgengine/github` is `0.21.0`.
34
+
35
+ ### Added
36
+
37
+ - `createRunLoop` (`@jgengine/core/run/runLoop`) holds a run's at-risk haul, banks it scaled by the line or loses it on a failure, and draws one authored change for each next run from a seeded table, so the same seed and run history replay the same sequence. State round-trips through `snapshot`/`restore`; the money stays in `progression/careerBank`.
38
+
39
+ ## 0.33.0
40
+
41
+ ### Migrate
42
+
43
+ - **Bump lockstep SDK packages to `^0.33.0`:** `@jgengine/{core,rapier,react,ws,node,sql,convex,shell,editor,assets,navbake}`. CLI `jgengine` is `0.30.0`; `@jgengine/github` is `0.20.0`.
44
+ - `useSceneObjects` (`@jgengine/react/hooks`) keeps one list identity across `move` and `rotate`, so a record's `position`/`rotationY` is what it was at the last render. Read the live placement with `ctx.scene.object.get(instanceId)` (a `useFrame` loop or a rAF-ticked HUD) when a mesh or readout must follow a moving object.
45
+ - A read of a mismatched stored value now converts losslessly where it can (a number as its digits, a boolean as `"true"`/`"false"`, those strings back) and throws where it cannot. No in-repo caller relied on the old fallback; `useSetting` (`@jgengine/react/settings`) is the generic path that could, so a game that stored a number under a key it reads with a string fallback now gets the digits.
46
+
47
+ ### Added
48
+
49
+ - `releasePostfxOverlayTracking(scene)` (`@jgengine/shell/postfx/postfxOverlay`) drops the cached prepass overlay set and its listeners for a scene that is being torn down.
50
+ - `canvasCover` (`@jgengine/react/canvasCover`): one page-wide hold a covering surface takes, plus `useCanvasCover(declared)` for a React overlay. While it is held the shell stops drawing the world, its shadow passes and postfx; input, audio and the DOM HUD keep running, and the first frame after release draws the untouched scene. A scrim or side panel must not take it.
51
+ - `MenuScreen` and `TitleMenu` take `coversCanvas` (default false) to declare that the screen paints over the whole canvas. A menu with only a translucent scrim leaves the live scene drawing.
52
+ - The dev runner pins the cover with `?cover=1`, and the devtools agent bridge answers `canvas_cover`, so a perf run or `bun run drive` can measure a covered frame on any game.
53
+ - `combat.damage` carries an optional `position`: the effect path fills it from the target's own spot, and `createDamageRuntime` takes one per hit (`hit({ position })`) or from a `positionOf` reader, so a status tick is placed too. A cue with a position pans and attenuates; one without stays centred.
54
+ - `createHapticsRoute` (`@jgengine/shell/audio/hapticsRoute`) sends a feedback pulse to a connected gamepad, and to `navigator.vibrate` on a phone with no pad. `FeedbackHost` wires it; reduced motion still drops the camera shake only.
55
+ - `PerfReport.render.drawsFrame` is every draw a frame issues — shadow, main, postfx prepasses, AO and DOF together — as the 95th percentile of the measured window, with `drawsFrames` naming how many frames it covers. `bun run perf:gate` compares it against each game's re-based `drawsFrame` budget; the renderer's own single-sample `draws` is printed beside it and is no longer gated.
56
+ - `ObjectStore.version()` / `ObjectStore.markSpatialChange()` (`ctx.scene.object`) — a counter that moves whenever membership, a position, a rotation or a consumer-owned collider set changes, so derived spells spatial data can share one cache key.
57
+ - `SolidObstacleSource.version?()` (`@jgengine/core/movement/solidObstacles`) — a source that reports one gets its blocking obstacles resolved once per version into a coarse XZ index; a source without it keeps the per-query `inBox` gather.
58
+ - `SettingsTypeError` and `asSettingType` (`@jgengine/core/settings/settingsModel`) report and resolve a stored setting read as another type.
59
+
60
+ ### Changed
61
+
62
+ - `bun run land` queues landings on one lock per repo instead of running them beside each other, so two lanes no longer stack two pull requests' sixteen jobs against the account's 20-job cap. A waiting landing names the branch and pid it waits on; a lock whose process died, or that is older than 30 minutes, is broken with a warning.
63
+ - The scene io browser test skips Playwright's two-frame click stability check and lets three rendered frames pass instead of ten: on a runner its second test went from 53s to 11-24s and the file from 76s to 50s, of which 16-36s is the fixture's own start.
64
+ - `check-game-front-end` recognizes the shipped `CreditsPanel`, so a game that renders credits through the engine's panel is no longer flagged as having no credits screen.
65
+ - The shell's frame loop switches to `frameloop="never"` under a cover instead of drawing a world nobody can see (measured on Brightway Park's pause menu: 1,095 whole-frame draws and 5.2 ms/frame before, 0 draws and 0.11 ms/frame covered). A frame-rate cap no longer advances a covered canvas.
66
+ - `FeedbackDeps.play` takes an optional `position`, which `FeedbackHost` forwards to `ctx.game.audio.play`, so a positioned damage or death cue reaches the spatial engine.
67
+ - Each game's `perf-budget.json` entry now budgets `drawsFrame` and records the budget it replaced as `previousDraws`; an entry that still carries only `draws` fails by name instead of gating a count from a different measurement.
68
+ - The in-page report reads the devtools render probe's frame sample instead of the live renderer counter, so `window.__JG.report()` and the devtools panel no longer report a mid-frame partial count.
69
+ - Movement gathers obstacles from that index instead of re-resolving every nearby object every frame. On Harbor Heat the query fell from 0.62-0.65 ms to 0.10 ms a frame (2.0-2.1 ms to 1.4 ms of simulation a frame).
70
+ - `objectStore.inBox` walks a coarse grid for big boxes instead of scanning every placed object; a 1 m cell lookup costs a string hash, so the switch happens past 32 cells rather than 4096.
71
+ - Ambient occlusion reads the beauty pass's depth buffer instead of rendering the scene a second time for its normal/depth GBuffer. That prepass cost 537 extra draws and 2.6-2.9 ms/frame in Harbor Heat and 2,105 extra draws in Drift Foundry at 1600x900; AO now draws nothing of its own. A post chain whose antialiasing is `"smaa"` (the default) keeps SMAA and drops the beauty target's extra MSAA resolve, because WebGL2 cannot sample a multisampled depth texture; `"msaa"` chains keep the old prepass. Fixed-viewpoint captures differ only on geometry edges (#2173).
72
+
73
+ ### Fixed
74
+
75
+ - Postfx prepasses no longer walk the whole scene twice a frame to hide overlays, points and lines: the set is cached per scene and rescanned when the scene graph changes. Drift Foundry 2.11 ms/frame and Harbor Heat 0.66 ms/frame of `traverse` removed.
76
+ - A rig posed from an animation graph no longer allocates a motion sample, a position triple and a fresh pose record every frame, and foot IK no longer allocates a probe input, filter, closure and per-leg records every frame.
77
+ - The Graphics tab lists a post-processing stage toggle only when the game's resolved chain can build that stage. Depth of field, which no reference game authors, hid behind a row that switched a pass the composer never created, so the toggle changed nothing. The rule covers every stage: a chain with `ao: false`, `bloom: false` or `aa: "msaa"`/`false` no longer offers those rows, and a game with no post chain gets none of them. Every other settings row is unchanged (`@jgengine/shell/settings/settingsController`, `availablePostfxStages` in `@jgengine/shell/postfx/PostProcessing`).
78
+ - Positional loops declared through `entitySounds`/`objectSounds` are tracked instead of rebuilt: spawn, despawn and a moved emitter update one retained loop each, and a frame where nothing moved reads only the emitters that already sound. On scrap-signal's 560 placed props (69 sounding), the tracking path drops from 16.7 µs to 1.2 µs per frame and a steady frame allocates no Set, array or record.
79
+ - `useAccessibilitySettings`, `useHoldVsToggle` and `useAccessibilityRows` show a setting written before the component subscribed — a saved profile or the demo path seeding values before first paint — instead of waiting for the player's next change (#2180).
80
+ - `useFeed`, `useQuestJournal` and `useFriends` (`@jgengine/react/hooks`) keep one list identity while membership holds instead of allocating a new array on every store write and comparing it with `Object.is`, so a HUD reading them no longer re-renders on every entity pose write. A pushed feed entry, an accepted, progressed or abandoned quest, and an accepted or removed friend each re-render once. Measured on the three read sites (`ToastStack`, `FriendsList`, `JournalQuestTracker`) with 15 quests, 20 friends and 20 feed rows: 900 renders → 0 across 300 pose writes, 0.14 ms/frame → 0.04 ms/frame.
81
+ - `useWorldItems` (`@jgengine/react/hooks`) keeps one list identity until an item spawns, is picked up or is removed. It read `worldItem.list()`, which allocates a new array per call, against a store signal that also fires on every entity pose write, so a HUD re-rendered every dropped-item marker each frame (0.97 ms/frame of React work in Harbor Heat).
82
+ - `WorldItems` (`@jgengine/shell`) reads each marker's live pose in `useFrame` instead of taking it as a prop, so a moving item still follows without re-rendering its marker.
83
+ - `useSceneEntities` and `useSceneObjects` (`@jgengine/react/hooks`) keep one list identity while membership holds, instead of allocating a new array on every store write and comparing it with `Object.is`. A pose write no longer re-renders every HUD that reads them (30-entity roster: 0.066 ms/frame → 0; the whole loop 0.24 → 0.05 ms/frame), while a spawn, despawn, replace, place or remove still re-renders. Non-pose object writes (state, visual, animation, slots, catalog id) still re-render.
84
+ - `RevealHighlights` (`@jgengine/shell/vision`) drives its own per-frame refresh only while Dark Sight is enabled, so a disabled reveal overlay no longer re-renders (0.019 ms/frame → 0) and an enabled one still follows the origin and its targets.
85
+ - `createSettingsStore().get` returns a stored setting of another type instead of quietly returning the fallback, so a numeric setting read with a string fallback applies instead of vanishing (#2189). Root cause: `coerce` treated the fallback's type as the stored type and replaced every other type with the fallback. A stored value that cannot be read as the asked-for type now throws `SettingsTypeError` naming the key, the stored type and the fallback type.
86
+
29
87
  ## 0.32.0
30
88
 
31
89
  ### Migrate
@@ -28,7 +28,44 @@ export interface DriverGoal {
28
28
  stopAtGoal?: boolean;
29
29
  /** Cap on desired speed for this goal (a speed limit, a formation speed); default unlimited. */
30
30
  speedLimit?: number;
31
+ /**
32
+ * This car's catch-up pacing band, applied to the goal's pace. The caller measures {@link paceGap}
33
+ * (it owns the spatial query) and tunes the band; {@link paceBandFactor} is the rule.
34
+ */
35
+ paceBand?: PaceBand;
36
+ /** Signed gap to the band's reference: positive when this car is ahead of it; default `0`. */
37
+ paceGap?: number;
31
38
  }
39
+ /**
40
+ * Catch-up pacing for one car in a field: the gap it tries to hold to a reference car (a rival, the
41
+ * player, a convoy lead) and how its pace bends when it drifts off that gap. Past `margin` by
42
+ * `tolerance` it sheds up to `ease` of its pace; short of it by `tolerance` it gains up to `push`;
43
+ * inside that tolerance it leaves the car alone. The push never outdrives `DriverTuning.maxSpeed`,
44
+ * so a band changes how hard a car tries, never what it is built to do.
45
+ */
46
+ export interface PaceBand {
47
+ /** Gap to the reference this car aims to hold, world units; default `0` (level with it). */
48
+ margin?: number;
49
+ /** Gap error either side of `margin` the car leaves alone; default `0`. */
50
+ tolerance?: number;
51
+ /** Gap error past `tolerance` where the ease reaches full strength; default `0` (at once). */
52
+ easeAt?: number;
53
+ /** Fraction of the goal's pace shed at full ease; default `0`. */
54
+ ease?: number;
55
+ /** Gap error past `tolerance` where the push reaches full strength; default `0` (at once). */
56
+ pushAt?: number;
57
+ /** Fraction of the goal's pace added at full push; default `0`. */
58
+ push?: number;
59
+ /** Share of the band this car accepts, `0..1`; default `1`. */
60
+ scale?: number;
61
+ }
62
+ /**
63
+ * The pace multiplier a {@link PaceBand} asks for at `gap`: `1` inside the tolerance, `1 - ease *
64
+ * scale` fully ahead of it, `1 + push * scale` fully behind it, ramped linearly across `easeAt` /
65
+ * `pushAt` in between. Pure scalar math, so a band is deterministic and costs no allocation per
66
+ * step; the result never goes negative.
67
+ */
68
+ export declare function paceBandFactor(band: PaceBand, gap: number): number;
32
69
  /** Vehicle-feel numbers the game supplies; everything has a sensible default except `maxSpeed`. */
33
70
  export interface DriverTuning {
34
71
  /** Top desired speed on a straight, world units/second. */
@@ -86,8 +123,10 @@ export interface DriverStep extends AxisInput {
86
123
  * `speed * reactionSeconds`, so easy tiers brake at the last moment and expert tiers with proper
87
124
  * margin. The steering target is a delay-line over the goal — resampled every `reactionSeconds`,
88
125
  * so it trails a moving goal by up to that long, which is what makes an easy chaser visibly cut
89
- * toward where the target *was*. When throttle produces no motion for a tier-scaled while the
90
- * driver reverses out with counter-steer (brake past standstill — the shared sim's reverse).
126
+ * toward where the target *was*. A {@link PaceBand} on the goal eases a car ahead of its margin and
127
+ * pushes one behind it, bounded by the car's own top speed. When throttle produces no motion for a
128
+ * tier-scaled while the driver reverses out with counter-steer (brake past standstill — the shared
129
+ * sim's reverse).
91
130
  *
92
131
  * @capability ai-driver difficulty-aware chase/route driving step producing throttle/brake/steer for the vehicle sim
93
132
  */
package/dist/ai/driver.js CHANGED
@@ -1,4 +1,30 @@
1
1
  import { executionError } from "./difficulty.js";
2
+ /**
3
+ * The pace multiplier a {@link PaceBand} asks for at `gap`: `1` inside the tolerance, `1 - ease *
4
+ * scale` fully ahead of it, `1 + push * scale` fully behind it, ramped linearly across `easeAt` /
5
+ * `pushAt` in between. Pure scalar math, so a band is deterministic and costs no allocation per
6
+ * step; the result never goes negative.
7
+ */
8
+ export function paceBandFactor(band, gap) {
9
+ const scale = band.scale ?? 1;
10
+ if (scale <= 0)
11
+ return 1;
12
+ const error = gap - (band.margin ?? 0);
13
+ const tolerance = band.tolerance ?? 0;
14
+ if (error > tolerance) {
15
+ const ease = band.ease ?? 0;
16
+ if (ease <= 0)
17
+ return 1;
18
+ return Math.max(0, 1 - ease * scale * Math.min(1, (error - tolerance) / (band.easeAt ?? 0)));
19
+ }
20
+ if (error < -tolerance) {
21
+ const push = band.push ?? 0;
22
+ if (push <= 0)
23
+ return 1;
24
+ return Math.max(0, 1 + push * scale * Math.min(1, (-error - tolerance) / (band.pushAt ?? 0)));
25
+ }
26
+ return 1;
27
+ }
2
28
  /**
3
29
  * Fresh driver state committed to an initial target (usually the spawn-time goal or the spawn
4
30
  * position itself).
@@ -32,8 +58,10 @@ const clamp01 = (value) => (value < 0 ? 0 : value > 1 ? 1 : value);
32
58
  * `speed * reactionSeconds`, so easy tiers brake at the last moment and expert tiers with proper
33
59
  * margin. The steering target is a delay-line over the goal — resampled every `reactionSeconds`,
34
60
  * so it trails a moving goal by up to that long, which is what makes an easy chaser visibly cut
35
- * toward where the target *was*. When throttle produces no motion for a tier-scaled while the
36
- * driver reverses out with counter-steer (brake past standstill — the shared sim's reverse).
61
+ * toward where the target *was*. A {@link PaceBand} on the goal eases a car ahead of its margin and
62
+ * pushes one behind it, bounded by the car's own top speed. When throttle produces no motion for a
63
+ * tier-scaled while the driver reverses out with counter-steer (brake past standstill — the shared
64
+ * sim's reverse).
37
65
  *
38
66
  * @capability ai-driver difficulty-aware chase/route driving step producing throttle/brake/steer for the vehicle sim
39
67
  */
@@ -75,6 +103,9 @@ export function driveStep(state, dt, pose, goal, profile, tuning, rng, obstacleA
75
103
  const cornerSlowdown = tuning.cornerSlowdown ?? 0.75;
76
104
  const cornerFactor = 1 - cornerSlowdown * Math.min(1, Math.abs(headingError) / (Math.PI / 2));
77
105
  let desiredSpeed = Math.min(tuning.maxSpeed, goal.speedLimit ?? Number.POSITIVE_INFINITY);
106
+ if (goal.paceBand !== undefined) {
107
+ desiredSpeed = Math.min(tuning.maxSpeed, desiredSpeed * paceBandFactor(goal.paceBand, goal.paceGap ?? 0));
108
+ }
78
109
  desiredSpeed *= cornerFactor;
79
110
  if (goal.stopAtGoal === true) {
80
111
  // Ease in over the last stretch so the stop lands inside the radius instead of overshooting.
@@ -27,6 +27,8 @@ export interface DamageRuntimeHitInput {
27
27
  zone?: string;
28
28
  source?: string;
29
29
  statuses?: readonly (string | DamageStatusRequest)[];
30
+ /** Where the blow landed, when the caller knows it; overridable per hit. */
31
+ position?: readonly [number, number, number];
30
32
  }
31
33
  /** Every stage of one resolved hit, so a UI or a test can read why the final number is what it is. */
32
34
  export interface DamageRuntimeResolution {
@@ -87,6 +89,12 @@ export interface DamageRuntimeConfig {
87
89
  * reader and every event reports `remaining: null` and `lethal: false`.
88
90
  */
89
91
  healthOf?: (targetId: string) => number | null;
92
+ /**
93
+ * Where a target stands, read once per application. Gives the event a `position` so a cue pans
94
+ * and attenuates, including status ticks and hits whose input named none; omit it and the event
95
+ * carries no position and feedback stays centred.
96
+ */
97
+ positionOf?: (targetId: string) => readonly [number, number, number] | null | undefined;
90
98
  /** Register a one-line devtools probe under this name. */
91
99
  devtoolsName?: string;
92
100
  }
@@ -156,7 +164,8 @@ export declare class UnknownTargetProfileError extends Error {
156
164
  * `base × zone multiplier × type multiplier × (1 − armor mitigation)`; statuses tick through the
157
165
  * same table and armor, so a burn on an armored target is mitigated like a bullet. Every application
158
166
  * — a hit or a status tick — is announced as `combat.damage` carrying the target, source, type,
159
- * amount, absorbed, remaining health and a lethal flag, so a HUD names the blow instead of guessing.
167
+ * amount, absorbed, remaining health, a lethal flag and, when `positionOf` or the hit names one,
168
+ * where the blow landed, so a HUD names the blow and a cue pans instead of guessing.
160
169
  *
161
170
  * @capability damage-runtime resolve hits through a damage table, hit zones, and armor, and tick data-defined statuses with declared stacking
162
171
  */
@@ -23,7 +23,8 @@ export class UnknownTargetProfileError extends Error {
23
23
  * `base × zone multiplier × type multiplier × (1 − armor mitigation)`; statuses tick through the
24
24
  * same table and armor, so a burn on an armored target is mitigated like a bullet. Every application
25
25
  * — a hit or a status tick — is announced as `combat.damage` carrying the target, source, type,
26
- * amount, absorbed, remaining health and a lethal flag, so a HUD names the blow instead of guessing.
26
+ * amount, absorbed, remaining health, a lethal flag and, when `positionOf` or the hit names one,
27
+ * where the blow landed, so a HUD names the blow and a cue pans instead of guessing.
27
28
  *
28
29
  * @capability damage-runtime resolve hits through a damage table, hit zones, and armor, and tick data-defined statuses with declared stacking
29
30
  */
@@ -33,6 +34,7 @@ export function createDamageRuntime(config) {
33
34
  const rng = resolveRng(config.rng, "createDamageRuntime");
34
35
  const bus = config.events;
35
36
  const healthOf = config.healthOf;
37
+ const positionOf = config.positionOf;
36
38
  let table = config.table;
37
39
  let zones = config.zones;
38
40
  let armorStat = config.armorStat ?? "armor";
@@ -77,6 +79,7 @@ export function createDamageRuntime(config) {
77
79
  dealt,
78
80
  ...(tick.source !== undefined ? { source: tick.source } : {}),
79
81
  status: tick.status,
82
+ ...(positionOf === undefined ? {} : { position: positionOf(tick.target) ?? undefined }),
80
83
  });
81
84
  return dealt;
82
85
  }
@@ -92,6 +95,7 @@ export function createDamageRuntime(config) {
92
95
  remaining,
93
96
  lethal: remaining !== null && remaining <= 0,
94
97
  ...(input.status !== undefined ? { status: input.status } : {}),
98
+ ...(input.position === undefined ? {} : { position: input.position }),
95
99
  };
96
100
  recent.push(event);
97
101
  if (recent.length > RECENT_DAMAGE_LIMIT)
@@ -160,6 +164,9 @@ export function createDamageRuntime(config) {
160
164
  incoming,
161
165
  dealt: damage,
162
166
  ...(input.source !== undefined ? { source: input.source } : {}),
167
+ ...(input.position !== undefined
168
+ ? { position: input.position }
169
+ : positionOf === undefined ? {} : { position: positionOf(input.target) ?? undefined }),
163
170
  });
164
171
  return {
165
172
  target: input.target,
@@ -93,6 +93,8 @@ export interface EffectDamageApplication {
93
93
  remaining: number | null;
94
94
  /** True when the last pool reached its minimum. */
95
95
  lethal: boolean;
96
+ /** The target's position when the spatial seam knows it, for a panned cue or a decal at the hit. */
97
+ at?: EntityPosition;
96
98
  }
97
99
  export interface EffectSystemDeps {
98
100
  resolveReceive(instanceId: string): ReceiveMap | null | undefined;
@@ -109,6 +109,7 @@ export function createEffectSystem(deps) {
109
109
  if (delta.delta < 0)
110
110
  dealt -= delta.delta;
111
111
  const lastStatId = rule.order[rule.order.length - 1];
112
+ const at = deps.spatial.positionOf(instanceId);
112
113
  deps.onDamage({
113
114
  target: instanceId,
114
115
  source: from,
@@ -117,6 +118,7 @@ export function createEffectSystem(deps) {
117
118
  dealt,
118
119
  remaining: statPools.get(instanceId, lastStatId)?.current ?? null,
119
120
  lethal: result.lethal,
121
+ ...(at === undefined ? {} : { at }),
120
122
  });
121
123
  }
122
124
  if (result.lethal) {
@@ -22,7 +22,20 @@ export interface FrameWindow {
22
22
  }
23
23
  /** Renderer-side counts for the measured window; `null` where the source could not read them. */
24
24
  export interface RenderReport {
25
+ /**
26
+ * The renderer's own draw counter as the devtools probe samples it. three accumulates this across
27
+ * every pass in a frame (the probe sets `info.autoReset = false`), but one sample is one frame, so
28
+ * two runs of the same build can differ by a pass that runs on a cadence.
29
+ */
25
30
  draws: number | null;
31
+ /**
32
+ * Every draw issued in a frame, all passes (shadow, main, postfx, AO, DOF), as the 95th percentile
33
+ * of the measured window: the count the budget gate compares. Only the CDP harness can wrap the
34
+ * draw calls, so the in-page sampler reports `null` here.
35
+ */
36
+ drawsFrame: number | null;
37
+ /** Frames the whole-frame count was taken over; 0 where nothing measured it. */
38
+ drawsFrames: number;
26
39
  triangles: number | null;
27
40
  geometries: number | null;
28
41
  textures: number | null;
@@ -39,6 +39,12 @@ export interface DamageAppliedEvent {
39
39
  lethal: boolean;
40
40
  /** The status that ticked, when the damage came from a carried status rather than a direct hit. */
41
41
  status?: string;
42
+ /**
43
+ * Where the blow landed, for spatial feedback (a panned cue, a decal, a floating number that
44
+ * belongs on the body rather than on screen). Omitted by an emitter that knows no position, so a
45
+ * listener must fall back to a centred, unattenuated reaction.
46
+ */
47
+ position?: readonly [number, number, number];
42
48
  }
43
49
  /** Request that an entity's rig play a one-shot animation clip bound to `event` in its `animation.oneShots` (e.g. an "attack" swing); the shell resolves the clip and plays it once over the locomotion state. With an `animation.graph`, `event` arms the trigger of that name. */
44
50
  export interface EntityAnimationEvent {
@@ -1,5 +1,5 @@
1
1
  /** Installed `@jgengine/core` semver — compare against {@link CHANGELOG} keys when migrating. */
2
- export declare const VERSION = "0.32.0";
2
+ export declare const VERSION = "0.34.0";
3
3
  /** One release's migrate steps plus added/changed/removed notes (typed mirror of CHANGELOG.md). */
4
4
  export interface ChangelogEntry {
5
5
  migrate: readonly string[];
@@ -1,7 +1,60 @@
1
1
  /** Installed `@jgengine/core` semver — compare against {@link CHANGELOG} keys when migrating. */
2
- export const VERSION = "0.32.0";
2
+ export const VERSION = "0.34.0";
3
3
  /** Per-version engine changelog keyed by semver string (e.g. `"0.10.0"`). */
4
4
  export const CHANGELOG = {
5
+ "0.34.0": {
6
+ migrate: [
7
+ "Bump lockstep SDK packages to `^0.34.0`: `@jgengine/{core,rapier,react,ws,node,sql,convex,shell,editor,assets,navbake}`. CLI `jgengine` is `0.31.0`; `@jgengine/github` is `0.21.0`.",
8
+ ],
9
+ added: [
10
+ "`createRunLoop` (`@jgengine/core/run/runLoop`) holds a run's at-risk haul, banks it scaled by the line or loses it on a failure, and draws one authored change for each next run from a seeded table, so the same seed and run history replay the same sequence. State round-trips through `snapshot`/`restore`; the money stays in `progression/careerBank`.",
11
+ ],
12
+ changed: [],
13
+ removed: [],
14
+ },
15
+ "0.33.0": {
16
+ migrate: [
17
+ "Bump lockstep SDK packages to `^0.33.0`: `@jgengine/{core,rapier,react,ws,node,sql,convex,shell,editor,assets,navbake}`. CLI `jgengine` is `0.30.0`; `@jgengine/github` is `0.20.0`.",
18
+ "`useSceneObjects` (`@jgengine/react/hooks`) keeps one list identity across `move` and `rotate`, so a record's `position`/`rotationY` is what it was at the last render. Read the live placement with `ctx.scene.object.get(instanceId)` (a `useFrame` loop or a rAF-ticked HUD) when a mesh or readout must follow a moving object.",
19
+ "A read of a mismatched stored value now converts losslessly where it can (a number as its digits, a boolean as `\"true\"`/`\"false\"`, those strings back) and throws where it cannot. No in-repo caller relied on the old fallback; `useSetting` (`@jgengine/react/settings`) is the generic path that could, so a game that stored a number under a key it reads with a string fallback now gets the digits.",
20
+ ],
21
+ added: [
22
+ "`releasePostfxOverlayTracking(scene)` (`@jgengine/shell/postfx/postfxOverlay`) drops the cached prepass overlay set and its listeners for a scene that is being torn down.",
23
+ "`canvasCover` (`@jgengine/react/canvasCover`): one page-wide hold a covering surface takes, plus `useCanvasCover(declared)` for a React overlay. While it is held the shell stops drawing the world, its shadow passes and postfx; input, audio and the DOM HUD keep running, and the first frame after release draws the untouched scene. A scrim or side panel must not take it.",
24
+ "`MenuScreen` and `TitleMenu` take `coversCanvas` (default false) to declare that the screen paints over the whole canvas. A menu with only a translucent scrim leaves the live scene drawing.",
25
+ "The dev runner pins the cover with `?cover=1`, and the devtools agent bridge answers `canvas_cover`, so a perf run or `bun run drive` can measure a covered frame on any game.",
26
+ "`combat.damage` carries an optional `position`: the effect path fills it from the target's own spot, and `createDamageRuntime` takes one per hit (`hit({ position })`) or from a `positionOf` reader, so a status tick is placed too. A cue with a position pans and attenuates; one without stays centred.",
27
+ "`createHapticsRoute` (`@jgengine/shell/audio/hapticsRoute`) sends a feedback pulse to a connected gamepad, and to `navigator.vibrate` on a phone with no pad. `FeedbackHost` wires it; reduced motion still drops the camera shake only.",
28
+ "`PerfReport.render.drawsFrame` is every draw a frame issues — shadow, main, postfx prepasses, AO and DOF together — as the 95th percentile of the measured window, with `drawsFrames` naming how many frames it covers. `bun run perf:gate` compares it against each game's re-based `drawsFrame` budget; the renderer's own single-sample `draws` is printed beside it and is no longer gated.",
29
+ "`ObjectStore.version()` / `ObjectStore.markSpatialChange()` (`ctx.scene.object`) — a counter that moves whenever membership, a position, a rotation or a consumer-owned collider set changes, so derived spells spatial data can share one cache key.",
30
+ "`SolidObstacleSource.version?()` (`@jgengine/core/movement/solidObstacles`) — a source that reports one gets its blocking obstacles resolved once per version into a coarse XZ index; a source without it keeps the per-query `inBox` gather.",
31
+ "`SettingsTypeError` and `asSettingType` (`@jgengine/core/settings/settingsModel`) report and resolve a stored setting read as another type.",
32
+ ],
33
+ changed: [
34
+ "`bun run land` queues landings on one lock per repo instead of running them beside each other, so two lanes no longer stack two pull requests' sixteen jobs against the account's 20-job cap. A waiting landing names the branch and pid it waits on; a lock whose process died, or that is older than 30 minutes, is broken with a warning.",
35
+ "The scene io browser test skips Playwright's two-frame click stability check and lets three rendered frames pass instead of ten: on a runner its second test went from 53s to 11-24s and the file from 76s to 50s, of which 16-36s is the fixture's own start.",
36
+ "`check-game-front-end` recognizes the shipped `CreditsPanel`, so a game that renders credits through the engine's panel is no longer flagged as having no credits screen.",
37
+ "The shell's frame loop switches to `frameloop=\"never\"` under a cover instead of drawing a world nobody can see (measured on Brightway Park's pause menu: 1,095 whole-frame draws and 5.2 ms/frame before, 0 draws and 0.11 ms/frame covered). A frame-rate cap no longer advances a covered canvas.",
38
+ "`FeedbackDeps.play` takes an optional `position`, which `FeedbackHost` forwards to `ctx.game.audio.play`, so a positioned damage or death cue reaches the spatial engine.",
39
+ "Each game's `perf-budget.json` entry now budgets `drawsFrame` and records the budget it replaced as `previousDraws`; an entry that still carries only `draws` fails by name instead of gating a count from a different measurement.",
40
+ "The in-page report reads the devtools render probe's frame sample instead of the live renderer counter, so `window.__JG.report()` and the devtools panel no longer report a mid-frame partial count.",
41
+ "Movement gathers obstacles from that index instead of re-resolving every nearby object every frame. On Harbor Heat the query fell from 0.62-0.65 ms to 0.10 ms a frame (2.0-2.1 ms to 1.4 ms of simulation a frame).",
42
+ "`objectStore.inBox` walks a coarse grid for big boxes instead of scanning every placed object; a 1 m cell lookup costs a string hash, so the switch happens past 32 cells rather than 4096.",
43
+ "Ambient occlusion reads the beauty pass's depth buffer instead of rendering the scene a second time for its normal/depth GBuffer. That prepass cost 537 extra draws and 2.6-2.9 ms/frame in Harbor Heat and 2,105 extra draws in Drift Foundry at 1600x900; AO now draws nothing of its own. A post chain whose antialiasing is `\"smaa\"` (the default) keeps SMAA and drops the beauty target's extra MSAA resolve, because WebGL2 cannot sample a multisampled depth texture; `\"msaa\"` chains keep the old prepass. Fixed-viewpoint captures differ only on geometry edges (#2173).",
44
+ "Postfx prepasses no longer walk the whole scene twice a frame to hide overlays, points and lines: the set is cached per scene and rescanned when the scene graph changes. Drift Foundry 2.11 ms/frame and Harbor Heat 0.66 ms/frame of `traverse` removed.",
45
+ "A rig posed from an animation graph no longer allocates a motion sample, a position triple and a fresh pose record every frame, and foot IK no longer allocates a probe input, filter, closure and per-leg records every frame.",
46
+ "The Graphics tab lists a post-processing stage toggle only when the game's resolved chain can build that stage. Depth of field, which no reference game authors, hid behind a row that switched a pass the composer never created, so the toggle changed nothing. The rule covers every stage: a chain with `ao: false`, `bloom: false` or `aa: \"msaa\"`/`false` no longer offers those rows, and a game with no post chain gets none of them. Every other settings row is unchanged (`@jgengine/shell/settings/settingsController`, `availablePostfxStages` in `@jgengine/shell/postfx/PostProcessing`).",
47
+ "Positional loops declared through `entitySounds`/`objectSounds` are tracked instead of rebuilt: spawn, despawn and a moved emitter update one retained loop each, and a frame where nothing moved reads only the emitters that already sound. On scrap-signal's 560 placed props (69 sounding), the tracking path drops from 16.7 µs to 1.2 µs per frame and a steady frame allocates no Set, array or record.",
48
+ "`useAccessibilitySettings`, `useHoldVsToggle` and `useAccessibilityRows` show a setting written before the component subscribed — a saved profile or the demo path seeding values before first paint — instead of waiting for the player's next change (#2180).",
49
+ "`useFeed`, `useQuestJournal` and `useFriends` (`@jgengine/react/hooks`) keep one list identity while membership holds instead of allocating a new array on every store write and comparing it with `Object.is`, so a HUD reading them no longer re-renders on every entity pose write. A pushed feed entry, an accepted, progressed or abandoned quest, and an accepted or removed friend each re-render once. Measured on the three read sites (`ToastStack`, `FriendsList`, `JournalQuestTracker`) with 15 quests, 20 friends and 20 feed rows: 900 renders → 0 across 300 pose writes, 0.14 ms/frame → 0.04 ms/frame.",
50
+ "`useWorldItems` (`@jgengine/react/hooks`) keeps one list identity until an item spawns, is picked up or is removed. It read `worldItem.list()`, which allocates a new array per call, against a store signal that also fires on every entity pose write, so a HUD re-rendered every dropped-item marker each frame (0.97 ms/frame of React work in Harbor Heat).",
51
+ "`WorldItems` (`@jgengine/shell`) reads each marker's live pose in `useFrame` instead of taking it as a prop, so a moving item still follows without re-rendering its marker.",
52
+ "`useSceneEntities` and `useSceneObjects` (`@jgengine/react/hooks`) keep one list identity while membership holds, instead of allocating a new array on every store write and comparing it with `Object.is`. A pose write no longer re-renders every HUD that reads them (30-entity roster: 0.066 ms/frame → 0; the whole loop 0.24 → 0.05 ms/frame), while a spawn, despawn, replace, place or remove still re-renders. Non-pose object writes (state, visual, animation, slots, catalog id) still re-render.",
53
+ "`RevealHighlights` (`@jgengine/shell/vision`) drives its own per-frame refresh only while Dark Sight is enabled, so a disabled reveal overlay no longer re-renders (0.019 ms/frame → 0) and an enabled one still follows the origin and its targets.",
54
+ "`createSettingsStore().get` returns a stored setting of another type instead of quietly returning the fallback, so a numeric setting read with a string fallback applies instead of vanishing (#2189). Root cause: `coerce` treated the fallback's type as the stored type and replaced every other type with the fallback. A stored value that cannot be read as the asked-for type now throws `SettingsTypeError` naming the key, the stored type and the fallback type.",
55
+ ],
56
+ removed: [],
57
+ },
5
58
  "0.32.0": {
6
59
  migrate: [
7
60
  "Bump lockstep SDK packages to `^0.32.0`: `@jgengine/{core,rapier,react,ws,node,sql,convex,shell,editor,assets,navbake}`. CLI `jgengine` is `0.29.0`; `@jgengine/github` is `0.19.0`.",
@@ -29,11 +29,35 @@ export interface SolidObstacleSource {
29
29
  rotationY: number;
30
30
  }[];
31
31
  collidersOf(instanceId: string): Parameters<typeof resolveColliders>[0] | null;
32
+ /**
33
+ * Bumps whenever membership, a position, a rotation or a collider set changes. A source that reports
34
+ * one is indexed once per version instead of re-resolving every object on every query.
35
+ */
36
+ version?(): number;
32
37
  }
33
- /** Mutable reach cache; one per source, invalidated by object count. */
38
+ /** A placed object's blocking geometry, resolved once per index build and shared read-only by queries. */
39
+ interface ObstacleGroup {
40
+ x: number;
41
+ y: number;
42
+ z: number;
43
+ obstacles: CollisionObstacle[];
44
+ }
45
+ /**
46
+ * Version-keyed obstacle index: object centre → its prebuilt obstacles, bucketed in coarse XZ cells so
47
+ * a city-scale movement box walks a few populated cells rather than every object in the world.
48
+ */
49
+ interface ObstacleIndex {
50
+ cells: Map<number, ObstacleGroup[]>;
51
+ groups: ObstacleGroup[];
52
+ }
53
+ /** Mutable reach cache; one per source, invalidated by object count or by the source's version. */
34
54
  export interface ObstacleReachCache {
35
55
  count: number;
36
56
  value: ObstacleReach;
57
+ /** Version the value and index were built from; absent for a source that reports none. */
58
+ version?: number | undefined;
59
+ /** Built index, present only for a versioned source. */
60
+ index?: ObstacleIndex | undefined;
37
61
  }
38
62
  /** A fresh {@link ObstacleReachCache} for a caller that owns its own source. */
39
63
  export declare function createObstacleReachCache(): ObstacleReachCache;
@@ -71,15 +95,19 @@ export declare function obstacleFromSolid(solid: WorldSolid): CollisionObstacle;
71
95
  * @capability solid-obstacles the one blocking-geometry query the player resolver and NPC movers share
72
96
  */
73
97
  export declare function solidObstaclesNear(ctx: GameContext, position: EntityPosition, reachX: number, reachZ: number, height?: number): CollisionObstacle[];
74
- /** {@link solidObstaclesNear} against a bare source and an already-resolved reach. */
75
- export declare function sourceObstaclesNear(source: SolidObstacleSource, reach: ObstacleReach, position: EntityPosition, reachX: number, reachZ: number, height?: number): CollisionObstacle[];
98
+ /**
99
+ * {@link solidObstaclesNear} against a bare source and an already-resolved reach. Pass the source's
100
+ * {@link ObstacleReachCache} to use the version-keyed obstacle index; a source that reports no
101
+ * `version()` keeps the per-query `inBox` gather.
102
+ */
103
+ export declare function sourceObstaclesNear(source: SolidObstacleSource, reach: ObstacleReach, position: EntityPosition, reachX: number, reachZ: number, height?: number, cache?: ObstacleReachCache): CollisionObstacle[];
76
104
  /**
77
105
  * Slide a walker's horizontal step against the same solid geometry that stops the player, returning the
78
106
  * X/Z it may actually take this tick. A step into a wall is cut on the blocked axis and preserved on the
79
107
  * other, exactly as {@link stepPlayerMovement} resolves the player's.
80
108
  *
81
- * Bounded by the same broadphase as the player's gather: one `inBox` query sized to this step, never a
82
- * full-world scan, so it stays affordable per NPC per tick.
109
+ * Bounded by the same broadphase as the player's gather: one query sized to this step, answered from the
110
+ * source's obstacle index, never a full-world scan, so it stays affordable per NPC per tick.
83
111
  *
84
112
  * The sliding is already axis-separated: X and Z are resolved independently inside, so a caller that
85
113
  * also splits its own movement by axis must hand this exactly one axis per call (`stepZ: 0`, then
@@ -118,3 +146,4 @@ export declare function slideStep(position: EntityPosition, stepX: number, stepZ
118
146
  stepX: number;
119
147
  stepZ: number;
120
148
  };
149
+ export {};