@jgengine/shell 0.25.0 → 0.26.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 +65 -0
- package/dist/Shell3dPresentation.js +29 -11
- package/dist/devtools/FrameTelemetry.d.ts +12 -0
- package/dist/devtools/FrameTelemetry.js +68 -0
- package/dist/devtools/agentBridge.js +2 -0
- package/dist/devtools/devtoolsReports.d.ts +2 -0
- package/dist/devtools/devtoolsReports.js +3 -0
- package/dist/devtools/frameSampler.d.ts +127 -0
- package/dist/devtools/frameSampler.js +345 -0
- package/dist/environment/AuthoredDaylight.d.ts +28 -0
- package/dist/environment/AuthoredDaylight.js +42 -0
- package/dist/environment/Daylight.d.ts +55 -7
- package/dist/environment/Daylight.js +126 -29
- package/dist/environment/daylightCycle.d.ts +26 -4
- package/dist/environment/daylightCycle.js +36 -5
- package/dist/postfx/PostProcessing.d.ts +7 -1
- package/dist/postfx/PostProcessing.js +28 -2
- package/dist/postfx/autoExposure.d.ts +49 -0
- package/dist/postfx/autoExposure.js +189 -0
- package/dist/postfx/gradeShader.js +43 -4
- package/dist/presentationRecovery3d.js +2 -1
- package/dist/render/CascadedShadows.d.ts +3 -1
- package/dist/render/CascadedShadows.js +9 -1
- package/dist/render/EnvironmentLighting.d.ts +10 -1
- package/dist/render/EnvironmentLighting.js +11 -3
- package/dist/render/IrradianceVolumeLighting.d.ts +18 -0
- package/dist/render/IrradianceVolumeLighting.js +35 -0
- package/dist/render/SceneLighting.d.ts +14 -1
- package/dist/render/SceneLighting.js +29 -8
- package/dist/render/authoredGrade.d.ts +11 -0
- package/dist/render/authoredGrade.js +26 -0
- package/dist/render/presentationLook.d.ts +15 -0
- package/dist/render/presentationLook.js +18 -0
- package/dist/render/stableTextureSet.d.ts +9 -0
- package/dist/render/stableTextureSet.js +24 -0
- package/dist/render/triplanarMaterial.d.ts +52 -0
- package/dist/render/triplanarMaterial.js +169 -0
- package/dist/settings/appliedSettings.js +16 -13
- package/package.json +4 -4
- package/skills/jgengine/api.md +59 -6
- package/skills/jgengine/capabilities.md +4 -0
- package/skills/jgengine-ui/api.md +82 -22
- package/skills/jgengine-ui/capabilities.md +10 -0
- package/skills/jgengine-ui/reference-primitives.md +4 -2
- package/skills/jgengine-world/SKILL.md +3 -1
- package/skills/jgengine-world/api.md +107 -3
- package/skills/jgengine-world/capabilities.md +22 -2
- package/skills/jgengine-world/recipes/npc-senses.md +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -26,6 +26,71 @@ 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.26.0
|
|
30
|
+
|
|
31
|
+
### Migrate
|
|
32
|
+
|
|
33
|
+
- **Bump lockstep SDK packages to `^0.26.0`:** `@jgengine/{core,rapier,react,ws,node,sql,convex,shell,editor,assets,navbake}`. CLI `jgengine` is `0.23.0`; `@jgengine/github` is `0.13.0`.
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- `createLogBus` (`@jgengine/core/devtools/logBus`): a fixed-capacity ring of log lines tagged by owning system, with a separate ring for warnings and errors so a crash line is never pushed out by info traffic. `devtools.logs` now writes through it (`write(level, system, message)`, `snapshot()`, `counts()`, `dropped()`); `DevtoolsLogEntry` gained `system`.
|
|
38
|
+
- `devtools.probes.registerSystem(id, { counters, timers, state })`: a system reports its own counters, named timings and one state line in a few lines, with no shell wiring. Readings surface as `systems` in `devtools.snapshot()`, in `debug_snapshot`, and in every perf record.
|
|
39
|
+
- `PerfReport` (`@jgengine/core/devtools/report`): the one perf record shape shared by `bun run perf` and the in-page report.
|
|
40
|
+
- The shell samples frame telemetry in-page in dev builds: `window.__JG.report()` returns that record, and the page pushes it about once a second to the dev server's `GET/POST /__jgengine/report` route. `bun run debug <game>` prints the record of a game already open and exits non-zero on a budget breach in `scripts/perf-budget.json`.
|
|
41
|
+
- `createNeedSet` (`@jgengine/core/gameplay`) drains named needs on game time and reads them by index — decaying hunger, energy, fun with snapshot/restore and per-need rate retuning.
|
|
42
|
+
- `createUtilityBrain` (`@jgengine/core/world`) picks an action from decaying-need appeal: linear, quadratic, logistic, exponential and threshold response curves, candidate cost (travel, queues, price), a switch margin plus minimum hold (hysteresis), declared interrupts, optional seeded jitter, and a devtools probe string.
|
|
43
|
+
- `createNavRuntime` (`@jgengine/core/world`) consumes an editor-baked nav mesh: reads the `nav` bake off a scene document (`navMeshFromBake`), routes with the mesh query, resolves authored doors, ladders and jumps (`AuthoredNavLink`, priced by kind) onto the current surface, and swaps in a new bake after an edit while matching polygon identity by geometry — `applyMesh` returns a `remap` so only routes over changed polygons need re-planning.
|
|
44
|
+
- `createNavCrowd` (`@jgengine/core/world`) moves many agents across that mesh: plans a corridor, follows the funnel-smoothed waypoints, keeps agents apart with reciprocal velocity obstacle avoidance, bounds path searches per tick by count and milliseconds, fans converging agents out with `spread`, and round-trips through `snapshot`/`restore`.
|
|
45
|
+
- `createRvoCrowd` (`@jgengine/core/world`) is the avoidance solver on its own: RVO/ORCA half-plane solve over a uniform-grid neighbour search capped at `maxNeighbors`, deterministic tie-breaking, overlap relief, retunable `timeHorizon`/`neighborDist`/`maxNeighbors`/`sideBias`/`overlapRelief`, and `snapshot`/`restore` for saves and replays.
|
|
46
|
+
- `resolveRoutine` (`@jgengine/core/gameplay`) resolves an authored day into real arrival and departure times against the world clock. Travel time is injected per stop or as a callback, so a stop departs early enough to walk to the next one and an arrival that runs late slips instead of teleporting; `phaseAt(time)` returns the held place, the walking leg and its progress, and `nextChangeAfter(time)` drives a scheduler. A day whose walks cannot fit its cycle throws at construction.
|
|
47
|
+
- `createOffScreenWorld` (`@jgengine/core/gameplay`) keeps a whole population without simulating it: residents beyond the injected radius are cheap state (position, routine phase, needs) that only moves when the clock crosses a routine boundary, and they spawn into the game's own near simulation through a `NearAgents` interface when they come close. The radius, an optional per-agent cost model, a near budget and a per-tick switch budget are all injected; `snapshot`/`restore` round-trip the whole population, and crossing the boundary preserves identity, schedule progress, need values and position.
|
|
48
|
+
- `createNearAgents` (`@jgengine/core/gameplay`) is the default near half of that seam: a nav crowd with a need set and utility brain per agent, goal-tracking as routines move residents between places, and a decision counter for tests and probes.
|
|
49
|
+
- `createPerception` shares squad knowledge: `squadMates(observerId)` names an observer's roster, and a sighting one member makes is written into every mate's memory with `sourceId` (who saw it) and `sourceTick` (the observe pass it was recorded on). A mate's own sighting at the same instant replaces the hand-off. `maxSharesPerTick` (default 64, per observer pass) bounds a large roster and reports elided shares.
|
|
50
|
+
- Perception memory is auditable without guessing: `memoryOf(observerId, targetId)` returns the one remembered target with its confidence right now or `null` once it has faded, and `stats()` counts pair checks, range prunes, cone tests, line-of-sight calls, sightings, heard stimuli, shares and dropped shares. The check order is range → cone → line of sight, so occlusion work only sees the pruned set. `resetStats()` opens a measurement window; `memories` are pruned per observer so a 200-observer pass does not rescan every memory.
|
|
51
|
+
- `devtoolsName` registers a probe showing observers, remembered targets and the work counters, and `dispose()` removes it.
|
|
52
|
+
- `createCoverField` and `coverPointsFromSolids` (`@jgengine/core/combat`) derive stand-able cover from authored solid boxes instead of a coordinate list: one row of points per vertical face, clear of the corners, filtered by an injected `walkable` test, rebuilt when the world is edited, and queried through a bounded `near(position, radius, limit)`. `CoverSource` is the seam, so a game with its own spatial index can supply cover without the box generator.
|
|
53
|
+
- `selectCover` / `scoreCoverPoint` choose cover by threat: `hidden` is the confidence-weighted share of remembered threats whose line of sight the point (and a body-sized footprint at it) blocks, scored against the role's preferred fighting range, flank angle around the threat, distance, a squadmate's claim on the point, and whether the walk to it is a detour. Fading memories stop steering at `minConfidence`, and a point that hides from only one of two shooters is not cover.
|
|
54
|
+
- `createSquadCombat` (`@jgengine/core/combat`) drives a squad over existing seams: role-driven cover selection, fire discipline (hold, lean out, shoot), suppression from `underFire()`, retreat below a role's health threshold, and relocation under sustained fire. Threat comes only from `threatsFromMemory`, i.e. the perception memory the game already keeps; movement goes through `NavCrowd` with a tighter arrival tolerance so a body actually reaches the stand point. Serializable through `snapshot()`/`restore()` (member decisions, crowd, tuning), retunable, and a `devtoolsName` probe reports pins, peeks, shots and the worst exposure.
|
|
55
|
+
- `assignSquadRoles` and `threatsFromMemory` (`@jgengine/core/combat`): deterministic role assignment over a caller-authored `SquadComposition` (role ids, counts, ranges, flank angles, retreat thresholds and cover weights are all content), and a bounded, confidence-ranked threat list from one observer's memory.
|
|
56
|
+
- A 2v4 arena soak proves the behavior: 90 simulated seconds, 2700 ticks, 4 squad members against 2 scripted raiders, worst exposure 2.33 s (bar 3 s), 0 of 38 exposure spells over 3 s, per-tick cost p50 0.05 ms / p95 0.19 ms.
|
|
57
|
+
- `createDamageRuntime` (`@jgengine/core/combat`) composes a damage table, hit zones, the armor curve and carried statuses into one stateful model: `hit()` returns every stage of the number (`base × zone multiplier × type multiplier × (1 − armor mitigation)`), `tick()` runs status effects through the same table and armor, `timeToKill()` quotes a fight, and `table()` reads the whole chart. `snapshot()`/`restore()` carry registered targets and carried statuses; `retune()` swaps table, zones or status definitions without dropping either; a `devtoolsName` probe reports hits, crits, ticks and the last hit.
|
|
58
|
+
- A damage table (`combat/damageTable`) of damage type × resistance class, with `armor / (armor + halfValue)` mitigation — armor equal to the half value halves the hit — a per-type `bypassArmor`, and `readDamageTable` / `formatDamageTable` to read every row at given armor values. An unknown damage type throws instead of silently dealing 1×.
|
|
59
|
+
- Hit zones and crits (`combat/hitZones`): a zone carries a normal multiplier and an optional crit multiplier, `resolveHitZone` rolls once and returns one multiplier, and a crit replaces the zone multiplier rather than compounding with it. `hitZoneMultiplier` quotes the same number without a roll.
|
|
60
|
+
- `createStatusRuntime` (`combat/statusRuntime`): data-defined statuses with the existing `StatusStackPolicy` (`refresh`, stack to `max`, `replace`, `ignore`) as the only thing that changes stacks, per-tick effects of `{ kind: "damage", channel }` or `{ kind: "stat", stat }`, damage routed through an injected `applyDamage` so resistances and armor still apply, bounded ticks per call, and plain-data state out and back.
|
|
61
|
+
- Numbers from the tests: 25 base kinetic against a 150 HP target, 0.15 s between shots — 8 shots / 1.05 s unarmored, 20 shots / 2.85 s at 60 armor, 36 shots / 5.25 s at 200 armor; two stacked burns of 4 per tick deal 8, not 16; a 1.5× head zone with a 2.5× crit multiplier deals 2.5×, not 3.75×.
|
|
62
|
+
- `createWeaponSystem` (`@jgengine/core/combat`) runs one `WeaponDefinition`: single, automatic or burst fire, hitscan or ballistic projectiles, recoil that moves the aim the shot flies down, spread bloom, interrupted/resumed reloads, a readable ammo economy (`ammo()`, `stats()`), `snapshot()`/`restore()` and a devtools probe. Every hit, hitscan or projectile, resolves through `createDamageRuntime`. Pellet work is bounded per tick (`maxShotsPerTick`, default 4) and per weapon (`maxInFlight`, default 32).
|
|
63
|
+
- `WeaponDefinition` (`@jgengine/core/combat/weaponDefinition`) as plain JSON — rate, fire mode, delivery, magazine, handling, damage, falloff — with `assertWeaponDefinition`, `weaponIntervalMs`, `weaponDamageAt` and `weaponMaxInFlight`. A generated gun is the same shape.
|
|
64
|
+
- `Magazine.pauseReload()` / `resumeReload()` / `isPaused()` suspend a reload and keep its progress; a paused reload is not `isReloading()`, does not advance in `tick`, and round-trips through `snapshot()`/`restore()`.
|
|
65
|
+
- `environment.grading` on the scene document authors a per-game colour grade: shadow/midtone/highlight swatches plus tint, saturation and contrast bake into a small display-space LUT (`lutCubeFromGrading`, `colorGradeFromDocument` in `@jgengine/core/editor/environment`), edited in the Lighting workspace. The shell applies it from `editorLayers`, and a graded game needs no LUT asset or hardcoded pass.
|
|
66
|
+
- Clamped auto-exposure: `postProcessing.autoExposure: { min, max, adaptationSeconds } | false` meters the pre-tone-map frame every four frames toward 18% grey and stays inside the authored range. `WHITE_POINT` and `MID_GREY` in `@jgengine/core/render/colorPipeline` are the single documented calibration the pipeline uses.
|
|
67
|
+
- `GradeConfig.lut` also accepts a baked `{ cube: { size, data } }` LUT, sampled trilinearly after the numeric grade.
|
|
68
|
+
- `MATERIAL_LIBRARY` (`@jgengine/assets/catalogs/materialLibrary`) names 56 PBR surfaces — wet asphalt, painted metal, stucco, brick, wood, foliage with cut-out coverage and sheen, glass, water, sand, concrete and more — each mapping a name to an ambientCG source, a world tile size in metres and a physical response. `libraryMaterialAsset("asphalt/wet")` returns the editable `MaterialAsset` those names resolve to, and `filterLibraryMaterials` backs pickers. `assets pull library` pulls every pinned map set.
|
|
69
|
+
- `TriplanarAssetMaterial` / `useTriplanarAssetMaterial` / `applyTriplanarProjection` (`@jgengine/shell/render/triplanarMaterial`) render a material asset from world position, so world geometry without a `uv` attribute still gets colour, normal, roughness and AO maps. Tile size is world metres; instanced meshes project in instanced space.
|
|
70
|
+
- The editor's Materials workspace browses the library by name and writes the chosen entry into the document's material assets.
|
|
71
|
+
|
|
72
|
+
### Changed
|
|
73
|
+
|
|
74
|
+
- `createPerception` (`@jgengine/core/world`, also `@jgengine/core/sensor/perception`) takes `isSegmentClear` instead of `occluded`: the game supplies collision as a "nothing blocks this segment" test, and it is only called for pairs already inside range and cone. **Migration:** flip the predicate — a `occluded: (from, to) => blocked(from, to)` becomes `isSegmentClear: (from, to) => !blocked(from, to)`.
|
|
75
|
+
- `MagazineSnapshot` gains an optional `paused: true` field, present only while a reload is suspended, so existing snapshots and idle shapes are unchanged.
|
|
76
|
+
- AgX is the pipeline's tone map: `postProcessing.toneMapping` defaults to `"agx"`, and the `cinematic`, `photoreal`, `comic`, `retro` and `STUDIO_STAGE_POST` configs now pick it too. `"toon"` keeps `"linear"` on purpose. Games that authored `"aces"` explicitly are unchanged.
|
|
77
|
+
- The grade pass samples LUT tiles at texel centres and blends the blue axis by hand, so a supplied strip LUT no longer bleeds across slices.
|
|
78
|
+
|
|
79
|
+
### Fixed
|
|
80
|
+
|
|
81
|
+
- `bun run debug <game>` now finds the server `bun dev` started. The website dev server publishes the same checkout marker the runner does (`scripts/devServerMarker.ts`, written at listen, removed on shutdown, dev builds only), and the marker records the host that answers, since Vite's default `localhost` can be IPv6-only where `127.0.0.1` hangs.
|
|
82
|
+
- The website dev server serves `GET/POST /__jgengine/report` too, so a game opened at `/games/<id>` reports from the `/play` runner it embeds.
|
|
83
|
+
- The in-page sampler installs when the dev report route answers, not on a build-time `PROD` check: the `/play` runner is a production build, so the old check silently disabled the report on `bun dev`.
|
|
84
|
+
- A report taken inside the sampler's warmup is no longer judged on link/framebuffer counts, which only mean something after the warmup baseline exists.
|
|
85
|
+
- `extractMaterialMaps` and `buildMaterialCatalog` now recognise ambientCG's `_Opacity` map, so cut-out foliage and decal scans keep their coverage instead of rendering as solid cards.
|
|
86
|
+
- Capture runs no longer leak a ~150 MB temp Chrome profile each. `shoot`, `drive` and `perf` delete their profile on every exit path — success, throw, watchdog and SIGINT — `bun run shoot` reclaims profiles a killed run left untouched for three hours, the capture guard sweeps the profile of a run it force-kills, and the generated `browser.mjs` harness for game repos removes its own. A capture also refuses to start when the temp drive has less free space than it needs.
|
|
87
|
+
- The post-processing chain, graphics settings and textured terrain material keep a stable identity across renders. Before, every render rebuilt the effect composer and recompiled shaders, which dropped games to single-digit FPS.
|
|
88
|
+
|
|
89
|
+
### Numbers
|
|
90
|
+
|
|
91
|
+
- Test fixture at 600 rpm, 30-round magazine: 2.9 s to empty; 17.0° pitch and 3.1° yaw climb over the magazine; back to half climb in 0.37 s and within 5% in 0.6 s; bloom 2.0 → 8.0 → 12.0 mrad (cap) by the tenth shot, settling to base 0.63 s after the last shot.
|
|
92
|
+
- A hitscan and a projectile contact at the same distance return the same damage (20 body, 30 on a 1.5x head zone) through one damage model; a 60 m/s projectile crosses 20 m in 0.33 s and drops 2.45 m in 0.5 s at 9.81 m/s².
|
|
93
|
+
|
|
29
94
|
## 0.25.0
|
|
30
95
|
|
|
31
96
|
### Migrate
|
|
@@ -9,9 +9,8 @@ import { CAMERA_FRUSTUM_DEFAULTS } from "@jgengine/core/game/playableGame";
|
|
|
9
9
|
import { pixelPerfectFrustum, snapPixelPerfectPosition } from "@jgengine/core/game/pixelPerfect";
|
|
10
10
|
import { BUILT_IN_SETTING_CATEGORIES, } from "@jgengine/core/settings/settingsModel";
|
|
11
11
|
import { playControlsActive } from "@jgengine/core/game/controlGate";
|
|
12
|
-
import { sky as resolveSkyDescriptor } from "@jgengine/core/world/features";
|
|
13
|
-
import { resolveGameLook } from "@jgengine/core/render/lookPreset";
|
|
14
12
|
import { balanceLightingForIbl } from "@jgengine/core/render/lightingBalance";
|
|
13
|
+
import { skyNoonKeyframes } from "@jgengine/core/render/skyOwnedLighting";
|
|
15
14
|
import { GameViewportProvider } from "@jgengine/react/gameViewport";
|
|
16
15
|
import { GameProvider } from "@jgengine/react/provider";
|
|
17
16
|
import { SettingsProvider } from "@jgengine/react/settings";
|
|
@@ -24,11 +23,14 @@ import { PostProcessing } from "./postfx/PostProcessing.js";
|
|
|
24
23
|
import { EnvironmentLighting } from "./render/EnvironmentLighting.js";
|
|
25
24
|
import { CollisionDebugWorld } from "./devtools/CollisionDebugWorld.js";
|
|
26
25
|
import { DevtoolsRendererProbe } from "./devtools/DevtoolsOverlay.js";
|
|
26
|
+
import { FrameTelemetry } from "./devtools/FrameTelemetry.js";
|
|
27
27
|
import { CAMERA_TRANSPARENT_USERDATA, GameCameraRig, PlayerFovProvider, PlayerFovSlider, resolveRigKind, rtsPanKeysConflict, } from "./camera/index.js";
|
|
28
28
|
import { CullingProvider } from "./visibility/CullingProvider.js";
|
|
29
29
|
import { BuildingRenderBudget } from "./structures/BuildingRenderBudget.js";
|
|
30
30
|
import { SkyDaylight, TimeOfDayDaylight } from "./environment.js";
|
|
31
|
+
import { AuthoredDaylight } from "./environment/AuthoredDaylight.js";
|
|
31
32
|
import { bearingFromDirection } from "./environment/daylightCycle.js";
|
|
33
|
+
import { colorGradeFromDocument, lightProbesFromDocument } from "@jgengine/core/editor/environment";
|
|
32
34
|
import { resolveSkyLightOwnership, skyEmitsLights } from "./environment/skyLightingPolicy.js";
|
|
33
35
|
import { EnvironmentScene } from "./environment/EnvironmentScene.js";
|
|
34
36
|
import { PointerProbe } from "./pointer/PointerProbe.js";
|
|
@@ -47,6 +49,8 @@ import { TextureFiltering } from "./render/TextureFiltering.js";
|
|
|
47
49
|
import { FrameRateLimiter } from "./drivers/FrameRateLimiter.js";
|
|
48
50
|
import { FpsCounter, FpsProbe } from "./diagnostics/FpsCounter.js";
|
|
49
51
|
import { ConfiguredLighting, BackdropFog } from "./render/SceneLighting.js";
|
|
52
|
+
import { IrradianceVolumeLighting } from "./render/IrradianceVolumeLighting.js";
|
|
53
|
+
import { usePresentationLook } from "./render/presentationLook.js";
|
|
50
54
|
import { WorldView, RemotePlayers } from "./world/WorldScene.js";
|
|
51
55
|
import { FrameDriver } from "./drivers/FrameDriver.js";
|
|
52
56
|
import { GamepadSource } from "./input/gamepadSource.js";
|
|
@@ -115,24 +119,38 @@ export function Shell3dPresentation({ playable, ctx, multiplayer, tracker, point
|
|
|
115
119
|
: world?.kind === "biomes" || world?.kind === "voxel" || world?.kind === "plots" || world?.kind === "tilemap"
|
|
116
120
|
? () => _jsx(GridWorldScene, { feature: world })
|
|
117
121
|
: undefined);
|
|
118
|
-
|
|
122
|
+
// The post chain and sky rebuild on identity change; a fresh look object per render recompiled every pass each frame.
|
|
123
|
+
const hasWorldSky = worldSky !== undefined;
|
|
124
|
+
const authoredGrade = useMemo(() => (playable.editorLayers === undefined ? undefined : colorGradeFromDocument(playable.editorLayers)), [playable.editorLayers]);
|
|
125
|
+
const { look: resolvedLook, backdropSky } = usePresentationLook({
|
|
119
126
|
look: playable.look,
|
|
120
127
|
lighting: playable.lighting,
|
|
121
128
|
backdrop: playable.backdrop,
|
|
122
129
|
postProcessing: playable.postProcessing,
|
|
123
|
-
hasWorldSky
|
|
124
|
-
});
|
|
130
|
+
hasWorldSky,
|
|
131
|
+
}, authoredGrade);
|
|
125
132
|
const cinematicLook = (playable.look ?? "cinematic") !== "flat";
|
|
126
133
|
const backdrop = resolvedLook.backdrop;
|
|
127
|
-
const backdropSky = backdrop?.sky !== undefined ? resolveSkyDescriptor(backdrop.sky) : undefined;
|
|
128
134
|
const authoredSky = backdropSky ?? worldSky;
|
|
129
135
|
const lighting = resolvedLook.lighting;
|
|
130
136
|
const sunFromLighting = lighting?.directional?.[0]?.position;
|
|
131
137
|
const sceneLighting = useMemo(() => (cinematicLook ? balanceLightingForIbl(lighting) : lighting), [cinematicLook, lighting]);
|
|
132
|
-
const effectiveSky = useMemo(() =>
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
const effectiveSky = useMemo(() => {
|
|
139
|
+
if (authoredSky === undefined)
|
|
140
|
+
return undefined;
|
|
141
|
+
const bearing = authoredSky.sun ??
|
|
142
|
+
(!authoredSky.timeOfDay && sunFromLighting !== undefined ? bearingFromDirection(sunFromLighting) : undefined);
|
|
143
|
+
const sky = bearing === undefined ? authoredSky : { ...authoredSky, sun: bearing };
|
|
144
|
+
return authoredSky.timeOfDay ? skyNoonKeyframes(sky, sceneLighting, backdrop?.fog?.color) : sky;
|
|
145
|
+
}, [authoredSky, sunFromLighting, sceneLighting, backdrop?.fog?.color]);
|
|
146
|
+
/**
|
|
147
|
+
* Under a day cycle the sky scales the game's authored sun and ambient fill; without this a
|
|
148
|
+
* time-of-day sky only repaints the dome and the world stays lit like noon after dark.
|
|
149
|
+
*/
|
|
150
|
+
const authoredDaylight = effectiveSky?.timeOfDay === true && sceneLighting?.directional !== undefined;
|
|
151
|
+
const daylightModulation = useMemo(() => ({ sunFactor: 1, sunColor: effectiveSky?.sunColor ?? "#fff1c9", ambientFactor: 1 }), [effectiveSky?.sunColor]);
|
|
135
152
|
const backgroundColor = backdrop?.background ?? (effectiveSky === undefined ? DEFAULT_BACKGROUND_COLOR : undefined);
|
|
153
|
+
const irradianceVolumes = useMemo(() => (playable.editorLayers === undefined ? [] : lightProbesFromDocument(playable.editorLayers)), [playable.editorLayers]);
|
|
136
154
|
const orthographic = playable.camera?.projection === "orthographic";
|
|
137
155
|
const pointerDownRef = useRef(null);
|
|
138
156
|
const marqueeStartRef = useRef(null);
|
|
@@ -378,7 +396,7 @@ export function Shell3dPresentation({ playable, ctx, multiplayer, tracker, point
|
|
|
378
396
|
fov: playable.camera?.frustum?.fov ?? CAMERA_FRUSTUM_DEFAULTS.fov,
|
|
379
397
|
near: playable.camera?.frustum?.near ?? CAMERA_FRUSTUM_DEFAULTS.near,
|
|
380
398
|
far: playable.camera?.frustum?.far ?? CAMERA_FRUSTUM_DEFAULTS.far,
|
|
381
|
-
}, shadows: graphics.shadows ? "percentage" : false, dpr: [Math.min(1, graphics.dpr), graphics.dpr], gl: { preserveDrawingBuffer: true, powerPreference: "high-performance" }, style: { touchAction: "none" }, children: [_jsx(TextureFiltering, { anisotropy: graphics.profile.anisotropy }), graphics.frameRateLimit > 0 && !poster ? _jsx(FrameRateLimiter, { fps: graphics.frameRateLimit }) : null, graphics.showFps ? _jsx(FpsProbe, { tally: frameTally }) : null, orthographic && playable.camera?.pixelPerfect !== undefined ? (_jsx(PixelPerfectCamera, { ...playable.camera.pixelPerfect })) : null, backgroundColor !== undefined ? _jsx("color", { attach: "background", args: [backgroundColor] }) : null, cinematicLook ? (_jsx(EnvironmentLighting, { source: playable.environmentSource, skyColor: sceneLighting?.hemisphere?.skyColor ?? "#87b5e0", groundColor: sceneLighting?.hemisphere?.groundColor ?? "#3d4a38", horizonTint: sceneLighting?.ambient?.color, sunDirection: sceneLighting?.directional?.[0]?.position, sunColor: sceneLighting?.directional?.[0]?.color ?? "#fff2d6" })) : null, sceneLighting !== undefined ? (_jsx(ConfiguredLighting, { lighting: sceneLighting, profile: graphics.profile })) : effectiveSky === undefined ? (_jsxs(_Fragment, { children: [_jsx("ambientLight", { intensity: cinematicLook ? 0.3 : 0.55 }), _jsx("directionalLight", { position: [10, 16, 6], intensity: 1.3 })] })) : null, effectiveSky !== undefined ? (effectiveSky.timeOfDay ? (_jsx(TimeOfDayDaylight, { sky: effectiveSky, clock: ctx.time, bands: effectiveSky === worldSky ? biomeBands : undefined, lights: skyEmitsLights(resolveSkyLightOwnership(lighting !== undefined)) })) : (_jsx(SkyDaylight, { sky: effectiveSky, bands: effectiveSky === worldSky ? biomeBands : undefined, lights: skyEmitsLights(resolveSkyLightOwnership(lighting !== undefined)) }))) : null, _jsx(BackdropFog, { fog: backdrop?.fog }), _jsx(GameProvider, { context: ctx, children: _jsx(TerrainQualityContext.Provider, { value: graphics.quality, children: _jsxs(BuildingRenderBudget, { drawDistance: graphics.profile.drawDistance, visibility: playable.visibility, cullingDisabled: splitScreen, children: [_jsxs(CullingProvider, { config: playable.visibility, drawDistance: graphics.profile.drawDistance, children: [_jsx(WorldView, { entitySprites: playable.entitySprites, entityModels: playable.entityModels, objectModels: playable.objectModels, objectStyles: playable.objectStyles, environment: AutoEnvironment, assets: playable.game.assets, renderEntity: playable.renderEntity, renderObject: playable.renderObject, selectedIds: selectedIds, hideLocalActor: firstPerson, editorLayers: playable.editorLayers }), bars !== null ? (_jsx(WorldEntityBars, { statId: bars.statId, roles: bars.roles, resolveRole: resolveEntityRole, ...(bars.maxSamples === undefined ? {} : { maxSamples: bars.maxSamples }), ...(bars.tickMs === undefined ? {} : { tickMs: bars.tickMs }), ...(bars.maxDistance === undefined ? {} : { maxDistance: bars.maxDistance }), ...(bars.occlude === undefined ? {} : { occlude: bars.occlude }) })) : null, nameplates !== null ? (_jsx(WorldNameplates, { statId: nameplates.statId, roles: nameplates.roles, resolveRole: resolveEntityRole, ...(nameplates.maxSamples === undefined ? {} : { maxSamples: nameplates.maxSamples }), ...(nameplates.tickMs === undefined ? {} : { tickMs: nameplates.tickMs }), ...(nameplates.maxDistance === undefined ? {} : { maxDistance: nameplates.maxDistance }), occlude: nameplates.occlude, ...(nameplates.resolveName === undefined ? {} : { resolveName: nameplates.resolveName }), ...(nameplates.showHealth === undefined ? {} : { showHealth: nameplates.showHealth }) })) : null, WorldOverlay !== undefined ? (_jsx("group", { userData: CAMERA_TRANSPARENT_USERDATA, children: _jsx(WorldOverlay, { ctx: ctx }) })) : null] }), _jsx(WorldItems, { config: playable.worldItem }), _jsx(WorldParticles, { quality: graphics.quality, particleCap: graphics.profile.particleCap, diagnostics: devtoolsEnabled }), _jsx(CombatPresentation, { effects: effects }), devtoolsEnabled ? _jsx(CollisionDebugWorld, {}) : null, _jsx(AudioListener, { engine: audioEngine, anchor: playable.camera?.rig === "rts" || playable.camera?.rig === "topDown" ? "ground" : "camera" }), _jsx(EntityAudioEmitters, { engine: audioEngine, entitySounds: playable.entitySounds }), _jsx(ObjectAudioEmitters, { engine: audioEngine, objectSounds: playable.objectSounds }), _jsx(GameCameraRig, { yawRef: yawRef, pitchRef: pitchRef, config: cameraConfig, viewmodel: playable.viewmodel, pointerControls: pointerUsesLeft, panKeysEnabled: rtsPanKeysEnabled, director: ctx.camera, onDragChange: (dragging) => {
|
|
399
|
+
}, shadows: graphics.shadows ? "percentage" : false, dpr: [Math.min(1, graphics.dpr), graphics.dpr], gl: { preserveDrawingBuffer: true, powerPreference: "high-performance" }, style: { touchAction: "none" }, children: [_jsx(TextureFiltering, { anisotropy: graphics.profile.anisotropy }), graphics.frameRateLimit > 0 && !poster ? _jsx(FrameRateLimiter, { fps: graphics.frameRateLimit }) : null, graphics.showFps ? _jsx(FpsProbe, { tally: frameTally }) : null, orthographic && playable.camera?.pixelPerfect !== undefined ? (_jsx(PixelPerfectCamera, { ...playable.camera.pixelPerfect })) : null, backgroundColor !== undefined ? _jsx("color", { attach: "background", args: [backgroundColor] }) : null, cinematicLook ? (_jsx(EnvironmentLighting, { source: playable.environmentSource, skyColor: sceneLighting?.hemisphere?.skyColor ?? "#87b5e0", groundColor: sceneLighting?.hemisphere?.groundColor ?? "#3d4a38", horizonTint: sceneLighting?.ambient?.color, sunDirection: sceneLighting?.directional?.[0]?.position, sunColor: sceneLighting?.directional?.[0]?.color ?? "#fff2d6", ...(authoredDaylight ? { daylight: daylightModulation } : {}) })) : null, sceneLighting !== undefined ? (_jsx(ConfiguredLighting, { lighting: sceneLighting, profile: graphics.profile, ...(authoredDaylight ? { modulation: daylightModulation } : {}) })) : effectiveSky === undefined ? (_jsxs(_Fragment, { children: [_jsx("ambientLight", { intensity: cinematicLook ? 0.3 : 0.55 }), _jsx("directionalLight", { position: [10, 16, 6], intensity: 1.3 })] })) : null, authoredDaylight && effectiveSky !== undefined ? (_jsx(AuthoredDaylight, { sky: effectiveSky, clock: ctx.time, modulation: daylightModulation })) : null, effectiveSky !== undefined ? (effectiveSky.timeOfDay ? (_jsx(TimeOfDayDaylight, { sky: effectiveSky, clock: ctx.time, bands: effectiveSky === worldSky ? biomeBands : undefined, lights: skyEmitsLights(resolveSkyLightOwnership(lighting !== undefined)), fogRange: backdrop?.fog })) : (_jsx(SkyDaylight, { sky: effectiveSky, bands: effectiveSky === worldSky ? biomeBands : undefined, lights: skyEmitsLights(resolveSkyLightOwnership(lighting !== undefined)), fogRange: backdrop?.fog }))) : null, irradianceVolumes.length > 0 ? _jsx(IrradianceVolumeLighting, { volumes: irradianceVolumes }) : null, effectiveSky === undefined ? _jsx(BackdropFog, { fog: backdrop?.fog }) : null, _jsx(GameProvider, { context: ctx, children: _jsx(TerrainQualityContext.Provider, { value: graphics.quality, children: _jsxs(BuildingRenderBudget, { drawDistance: graphics.profile.drawDistance, visibility: playable.visibility, cullingDisabled: splitScreen, children: [_jsxs(CullingProvider, { config: playable.visibility, drawDistance: graphics.profile.drawDistance, children: [_jsx(WorldView, { entitySprites: playable.entitySprites, entityModels: playable.entityModels, objectModels: playable.objectModels, objectStyles: playable.objectStyles, environment: AutoEnvironment, assets: playable.game.assets, renderEntity: playable.renderEntity, renderObject: playable.renderObject, selectedIds: selectedIds, hideLocalActor: firstPerson, editorLayers: playable.editorLayers }), bars !== null ? (_jsx(WorldEntityBars, { statId: bars.statId, roles: bars.roles, resolveRole: resolveEntityRole, ...(bars.maxSamples === undefined ? {} : { maxSamples: bars.maxSamples }), ...(bars.tickMs === undefined ? {} : { tickMs: bars.tickMs }), ...(bars.maxDistance === undefined ? {} : { maxDistance: bars.maxDistance }), ...(bars.occlude === undefined ? {} : { occlude: bars.occlude }) })) : null, nameplates !== null ? (_jsx(WorldNameplates, { statId: nameplates.statId, roles: nameplates.roles, resolveRole: resolveEntityRole, ...(nameplates.maxSamples === undefined ? {} : { maxSamples: nameplates.maxSamples }), ...(nameplates.tickMs === undefined ? {} : { tickMs: nameplates.tickMs }), ...(nameplates.maxDistance === undefined ? {} : { maxDistance: nameplates.maxDistance }), occlude: nameplates.occlude, ...(nameplates.resolveName === undefined ? {} : { resolveName: nameplates.resolveName }), ...(nameplates.showHealth === undefined ? {} : { showHealth: nameplates.showHealth }) })) : null, WorldOverlay !== undefined ? (_jsx("group", { userData: CAMERA_TRANSPARENT_USERDATA, children: _jsx(WorldOverlay, { ctx: ctx }) })) : null] }), _jsx(WorldItems, { config: playable.worldItem }), _jsx(WorldParticles, { quality: graphics.quality, particleCap: graphics.profile.particleCap, diagnostics: devtoolsEnabled }), _jsx(CombatPresentation, { effects: effects }), devtoolsEnabled ? _jsx(CollisionDebugWorld, {}) : null, _jsx(AudioListener, { engine: audioEngine, anchor: playable.camera?.rig === "rts" || playable.camera?.rig === "topDown" ? "ground" : "camera" }), _jsx(EntityAudioEmitters, { engine: audioEngine, entitySounds: playable.entitySounds }), _jsx(ObjectAudioEmitters, { engine: audioEngine, objectSounds: playable.objectSounds }), _jsx(GameCameraRig, { yawRef: yawRef, pitchRef: pitchRef, config: cameraConfig, viewmodel: playable.viewmodel, pointerControls: pointerUsesLeft, panKeysEnabled: rtsPanKeysEnabled, director: ctx.camera, onDragChange: (dragging) => {
|
|
382
400
|
cameraDraggingRef.current = dragging;
|
|
383
401
|
} }), _jsx(PointerProbe, { service: pointerService })] }) }) }), _jsx(RemotePlayers, { rows: remotePlayers }), _jsx(FrameDriver, { ctx: ctx, playable: playable, tracker: tracker, yawRef: yawRef, pitchRef: pitchRef, primaryClickRef: primaryClickRef, pointerAxisRef: pointerAxisRef, analogRef: analogRef, gateRef: gateRef, onRuntimeError: reportRuntimeError, multiplayer: multiplayer, serverIdRef: serverIdRef, pointerService: pointerService, pointerAim: pointer?.aim === true, pingCommand: pointer?.pingCommand, poster: poster, onPosterSettled: onPosterSettled, authoritativeFrameRef: authoritativeFrameRef }), _jsx(GamepadSource, { tracker: tracker, bindings: inputBindings ?? {}, analogRef: analogRef, input: ctx.input, feel: playable.gamepad, seats: localPlayers(ctx), onSeatJoin: (slot) => {
|
|
384
402
|
try {
|
|
@@ -387,7 +405,7 @@ export function Shell3dPresentation({ playable, ctx, multiplayer, tracker, point
|
|
|
387
405
|
catch (error) {
|
|
388
406
|
reportRuntimeError(error, "tick");
|
|
389
407
|
}
|
|
390
|
-
}, seatsActive: () => !gateRef.current && playControlsActive(ctx) }), _jsx(DevtoolsRendererProbe, {}), splitScreen ? (_jsx(SplitScreenRenderer, { ctx: ctx, viewports: seatViewports, config: playable.viewports, mainCamera: playable.camera })) : null, !splitScreen && resolvedLook.postProcessing !== undefined && resolvedLook.postProcessing.enabled !== false ? (_jsx(PostProcessing, { config: resolvedLook.postProcessing, quality: graphics.quality, stages: graphics.profile.postStages })) : null] }), graphics.showFps && !poster ? _jsx(FpsCounter, { tally: frameTally }) : null, !poster &&
|
|
408
|
+
}, seatsActive: () => !gateRef.current && playControlsActive(ctx) }), _jsx(DevtoolsRendererProbe, {}), devtoolsEnabled ? (_jsx(FrameTelemetry, { game: playable.game.name, quality: graphics.quality === "low" ? "draft" : "full" })) : null, splitScreen ? (_jsx(SplitScreenRenderer, { ctx: ctx, viewports: seatViewports, config: playable.viewports, mainCamera: playable.camera })) : null, !splitScreen && resolvedLook.postProcessing !== undefined && resolvedLook.postProcessing.enabled !== false ? (_jsx(PostProcessing, { config: resolvedLook.postProcessing, quality: graphics.quality, stages: graphics.profile.postStages })) : null] }), graphics.showFps && !poster ? _jsx(FpsCounter, { tally: frameTally }) : null, !poster &&
|
|
391
409
|
!orientationGate &&
|
|
392
410
|
coarsePointer &&
|
|
393
411
|
controlsActive &&
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PerfQuality } from "@jgengine/core/devtools/devtools";
|
|
2
|
+
/**
|
|
3
|
+
* Mounts the in-page frame sampler for the live 3D scene: it wraps this renderer's
|
|
4
|
+
* context for GPU-object counts, reads renderer and scene numbers on demand, and
|
|
5
|
+
* publishes `window.__JG.report()`. It installs only when the dev server answers its
|
|
6
|
+
* report route, so a shipped game pays for one probe request and nothing else.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function FrameTelemetry({ game, quality }: {
|
|
10
|
+
game: string;
|
|
11
|
+
quality: PerfQuality;
|
|
12
|
+
}): null;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useThree } from "@react-three/fiber";
|
|
3
|
+
import { readUrlParam } from "@jgengine/core/devtools/urlFlags";
|
|
4
|
+
import { attachGlCounters, installFrameTelemetry, probeReportRoute, reportGameId, TELEMETRY_FLAG, } from "./frameSampler.js";
|
|
5
|
+
/**
|
|
6
|
+
* Mounts the in-page frame sampler for the live 3D scene: it wraps this renderer's
|
|
7
|
+
* context for GPU-object counts, reads renderer and scene numbers on demand, and
|
|
8
|
+
* publishes `window.__JG.report()`. It installs only when the dev server answers its
|
|
9
|
+
* report route, so a shipped game pays for one probe request and nothing else.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export function FrameTelemetry({ game, quality }) {
|
|
13
|
+
const gl = useThree((state) => state.gl);
|
|
14
|
+
const scene = useThree((state) => state.scene);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if ((readUrlParam(TELEMETRY_FLAG) ?? "").toLowerCase() === "off")
|
|
17
|
+
return;
|
|
18
|
+
let active = true;
|
|
19
|
+
let telemetry = null;
|
|
20
|
+
void probeReportRoute(undefined, reportGameId(game)).then((available) => {
|
|
21
|
+
if (!active || !available)
|
|
22
|
+
return;
|
|
23
|
+
let counters = {
|
|
24
|
+
totals: { programsLinked: 0, framebuffers: 0, buffers: 0, textures: 0, vertexArrays: 0 },
|
|
25
|
+
attached: false,
|
|
26
|
+
};
|
|
27
|
+
try {
|
|
28
|
+
counters = attachGlCounters(gl.getContext());
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
counters.attached = false;
|
|
32
|
+
}
|
|
33
|
+
telemetry = installFrameTelemetry({
|
|
34
|
+
game,
|
|
35
|
+
quality: () => quality,
|
|
36
|
+
viewport: () => `${window.innerWidth}x${window.innerHeight}`,
|
|
37
|
+
gpu: () => readGpuLabel(gl.getContext()),
|
|
38
|
+
render: () => ({
|
|
39
|
+
drawCalls: gl.info.render.calls,
|
|
40
|
+
triangles: gl.info.render.triangles,
|
|
41
|
+
geometries: gl.info.memory.geometries,
|
|
42
|
+
textures: gl.info.memory.textures,
|
|
43
|
+
}),
|
|
44
|
+
scene: () => scene,
|
|
45
|
+
gl: () => counters,
|
|
46
|
+
residentPrograms: () => gl.info.programs?.length ?? null,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return () => {
|
|
50
|
+
active = false;
|
|
51
|
+
telemetry?.dispose();
|
|
52
|
+
};
|
|
53
|
+
}, [game, quality, gl, scene]);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
function readGpuLabel(context) {
|
|
57
|
+
const info = context.getExtension("WEBGL_debug_renderer_info");
|
|
58
|
+
try {
|
|
59
|
+
if (info === null)
|
|
60
|
+
return String(context.getParameter(0x1f01));
|
|
61
|
+
const vendor = String(context.getParameter(info.UNMASKED_VENDOR_WEBGL));
|
|
62
|
+
const renderer = String(context.getParameter(info.UNMASKED_RENDERER_WEBGL));
|
|
63
|
+
return vendor.length > 0 ? `${vendor} ${renderer}` : renderer;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return "unknown";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -3,6 +3,7 @@ import { getSaveEndpoint } from "@jgengine/core/devtools/saveEndpoint";
|
|
|
3
3
|
import { isHudAnchor, listActiveHudLayouts, } from "@jgengine/core/ui/hudLayout";
|
|
4
4
|
import { listHudPanelTypes, resolvePanelResize, resizePanelSize, } from "@jgengine/core/ui/hudDocument";
|
|
5
5
|
import { buildFullReport, buildLeanReport, summarizeLeanReport } from "./devtoolsReports.js";
|
|
6
|
+
import { resetFrameTelemetry } from "./frameSampler.js";
|
|
6
7
|
import { advanceSimulation } from "./simStepper.js";
|
|
7
8
|
/**
|
|
8
9
|
* @internal
|
|
@@ -213,6 +214,7 @@ export function installAgentBridge(options) {
|
|
|
213
214
|
return { ok: true, report: buildFullReport(playable) };
|
|
214
215
|
case "debug_perf_reset":
|
|
215
216
|
devtools.frame.reset();
|
|
217
|
+
resetFrameTelemetry();
|
|
216
218
|
return { ok: true };
|
|
217
219
|
case "canvas_state":
|
|
218
220
|
return { ok: true, layouts: canvasPanels() };
|
|
@@ -50,6 +50,8 @@ export declare function buildLeanReport(playable: PlayableGame): {
|
|
|
50
50
|
render: import("@jgengine/core/devtools/types").RenderSample | null;
|
|
51
51
|
}[];
|
|
52
52
|
probes: Record<string, unknown>;
|
|
53
|
+
systems: Record<string, import("@jgengine/core/devtools/types").SystemProbeReading>;
|
|
54
|
+
logSummary: import("@jgengine/core/devtools/report").ReportLogs;
|
|
53
55
|
logs: import("@jgengine/core/devtools/types").DevtoolsLogEntry[] | undefined;
|
|
54
56
|
controls: {
|
|
55
57
|
name: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { devtools } from "@jgengine/core/devtools/devtools";
|
|
2
|
+
import { toReportLogs } from "@jgengine/core/devtools/report";
|
|
2
3
|
import { diagnose } from "./perfDiagnose.js";
|
|
3
4
|
function roundMs(value, digits = 1) {
|
|
4
5
|
const scale = 10 ** digits;
|
|
@@ -88,6 +89,8 @@ export function buildLeanReport(playable) {
|
|
|
88
89
|
longFrameSummary: summarizeLongFrames(longs),
|
|
89
90
|
longFrames: longs.slice(-6).map(compactLongFrame),
|
|
90
91
|
probes: snap.probes,
|
|
92
|
+
systems: snap.systems,
|
|
93
|
+
logSummary: toReportLogs(devtools.logs.snapshot()),
|
|
91
94
|
logs: hotLogs.length > 0 ? hotLogs : undefined,
|
|
92
95
|
controls: changedControls.length > 0 ? changedControls : undefined,
|
|
93
96
|
discovered: enabledDiscovered.length > 0 ? enabledDiscovered : undefined,
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { type PerfQuality, type PerfReport, type ReportLogs } from "@jgengine/core/devtools/report";
|
|
2
|
+
import type { FrameStats, RenderSample, SystemProbeReading } from "@jgengine/core/devtools/types";
|
|
3
|
+
/**
|
|
4
|
+
* In-page frame telemetry: the game reports on itself instead of needing a second
|
|
5
|
+
* process to attach a profiler. Frame timings come from the devtools frame ring,
|
|
6
|
+
* renderer counts from the live renderer, GPU-object creation from wrapped GL calls,
|
|
7
|
+
* and per-system numbers from `devtools.probes` — all read on demand, so nothing
|
|
8
|
+
* here runs on the hot path.
|
|
9
|
+
*/
|
|
10
|
+
/** Query flag that turns the sampler off for an A/B frame-time comparison. */
|
|
11
|
+
export declare const TELEMETRY_FLAG = "telemetry";
|
|
12
|
+
/** How long after the sampler starts the GL counters get their post-warmup baseline. */
|
|
13
|
+
export declare const TELEMETRY_WARMUP_MS = 5000;
|
|
14
|
+
/** Cadence of the push to the dev server, in milliseconds. */
|
|
15
|
+
export declare const REPORT_PUSH_MS = 1000;
|
|
16
|
+
/** GPU-object creation counts, the fields the budget gate compares. */
|
|
17
|
+
export interface GlCounterTotals {
|
|
18
|
+
programsLinked: number;
|
|
19
|
+
framebuffers: number;
|
|
20
|
+
buffers: number;
|
|
21
|
+
textures: number;
|
|
22
|
+
vertexArrays: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Wrap the live context's creation calls so a leak shows up as a non-zero counter.
|
|
26
|
+
* Only object creation is wrapped — never a draw call — so a steady-state frame
|
|
27
|
+
* pays nothing. Returns whether any call was actually wrapped, since a zero is only
|
|
28
|
+
* evidence when it was.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export declare function attachGlCounters(context: object): {
|
|
32
|
+
totals: GlCounterTotals;
|
|
33
|
+
attached: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Count live three.js nodes from the scene the game is drawing; `null` when it cannot be walked.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare function countSceneNodes(scene: unknown): {
|
|
40
|
+
nodes: number | null;
|
|
41
|
+
scenes: number;
|
|
42
|
+
};
|
|
43
|
+
/** Everything the report needs, gathered by whichever producer is asking. */
|
|
44
|
+
export interface FrameReportInputs {
|
|
45
|
+
game: string;
|
|
46
|
+
gpu: string;
|
|
47
|
+
quality: PerfQuality;
|
|
48
|
+
viewport: string;
|
|
49
|
+
at: number;
|
|
50
|
+
/** Frame stats from the devtools ring; `null` before the first frame. */
|
|
51
|
+
frame: FrameStats | null;
|
|
52
|
+
render: RenderSample | null;
|
|
53
|
+
scene: {
|
|
54
|
+
nodes: number | null;
|
|
55
|
+
scenes: number;
|
|
56
|
+
};
|
|
57
|
+
gl: {
|
|
58
|
+
totals: GlCounterTotals;
|
|
59
|
+
since: GlCounterTotals;
|
|
60
|
+
residentPrograms: number | null;
|
|
61
|
+
attached: boolean;
|
|
62
|
+
};
|
|
63
|
+
systems: Record<string, SystemProbeReading>;
|
|
64
|
+
logs: ReportLogs | null;
|
|
65
|
+
heapBytes: number | null;
|
|
66
|
+
ageMs: number;
|
|
67
|
+
warmedUp: boolean;
|
|
68
|
+
buildMs: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Assemble the shared report shape from live sources. Pure: every number arrives as
|
|
72
|
+
* an argument, so a test can assert the shape without a renderer or a browser.
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
export declare function buildFrameReport(inputs: FrameReportInputs): PerfReport;
|
|
76
|
+
/** What the shell hands the sampler: live getters, called only when a report is built. */
|
|
77
|
+
export interface FrameTelemetrySources {
|
|
78
|
+
game: string;
|
|
79
|
+
quality: () => PerfQuality;
|
|
80
|
+
viewport: () => string;
|
|
81
|
+
gpu: () => string;
|
|
82
|
+
render: () => RenderSample | null;
|
|
83
|
+
scene: () => unknown;
|
|
84
|
+
gl: () => {
|
|
85
|
+
totals: GlCounterTotals;
|
|
86
|
+
attached: boolean;
|
|
87
|
+
};
|
|
88
|
+
residentPrograms: () => number | null;
|
|
89
|
+
heapBytes?: () => number | null;
|
|
90
|
+
endpoint?: string;
|
|
91
|
+
push?: boolean;
|
|
92
|
+
}
|
|
93
|
+
/** The installed sampler: ask it for a report, reset its window, or tear it down. */
|
|
94
|
+
export interface FrameTelemetry {
|
|
95
|
+
report(): PerfReport;
|
|
96
|
+
resetWindow(): void;
|
|
97
|
+
dispose(): void;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* `Harbor Heat` -> `harbor-heat`, unless the dev runner's `?game=` says otherwise. The
|
|
101
|
+
* report is keyed by this, so it matches `bun run perf` and the budget file.
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
export declare function reportGameId(displayName: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Ask the dev server whether its report route exists. This is the sampler's only
|
|
107
|
+
* production guard and it is behaviour, not a build flag: the route is mounted by the
|
|
108
|
+
* dev Vite configs only, so a shipped game answers this one request and installs
|
|
109
|
+
* nothing — no timers, no GL wrapping, no `window.__JG`. The website dev server serves
|
|
110
|
+
* the /play runner as a production build, which is why a build-time `PROD` check would
|
|
111
|
+
* wrongly disable the report there.
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
export declare function probeReportRoute(endpoint?: string, game?: string, fetchImpl?: typeof fetch | null, timeoutMs?: number): Promise<boolean>;
|
|
115
|
+
/**
|
|
116
|
+
* Reset the sampler's warmup baseline, so a fresh measurement starts from zero.
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
export declare function resetFrameTelemetry(): void;
|
|
120
|
+
/**
|
|
121
|
+
* Install the sampler for the page: publishes `window.__JG.report()` and pushes the
|
|
122
|
+
* same record to the dev server's report route every second. Returns `null` when
|
|
123
|
+
* `?telemetry=off` asks for the comparison run; callers gate installation on
|
|
124
|
+
* {@link probeReportRoute}, so a shipped game never starts the sampler.
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
export declare function installFrameTelemetry(sources: FrameTelemetrySources): FrameTelemetry | null;
|