@wildshard/engine 0.1.15 → 0.1.18
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 +23 -0
- package/index.html +157 -11
- package/lint/engine-sides.json +23 -0
- package/lint/host-callback-syntax.mjs +2 -1
- package/lint/host-callbacks.mjs +3 -3
- package/lint/host-files.mjs +5 -4
- package/lint/host-register.json +496 -0
- package/lint/no-base64.mjs +3 -1
- package/lint/ratchet.json +2 -2
- package/lint/shard-imports.d.mts +1 -0
- package/lint/shard-imports.mjs +60 -13
- package/lint/shard-source.d.mts +9 -0
- package/lint/shard-source.mjs +91 -0
- package/lint/shardfile-boundaries.mjs +10 -8
- package/lint/sim-closure.mjs +6 -3
- package/lint/wildshard-plugin.d.ts +4 -0
- package/lint/wildshard-plugin.js +44 -27
- package/package.json +24 -6
- package/scripts/app-build/buildIdentity.d.mts +3 -1
- package/scripts/app-build/buildIdentity.mjs +25 -5
- package/scripts/app-build/builtAt.d.mts +4 -0
- package/scripts/app-build/builtAt.mjs +21 -0
- package/scripts/app-build/outputProducts.d.mts +3 -0
- package/scripts/app-build/outputProducts.mjs +31 -0
- package/scripts/app-build/serviceWorker.ts +16 -2
- package/scripts/app-build/versionFiles.ts +2 -1
- package/scripts/app-build-pipeline.mjs +7 -1
- package/scripts/audio-download-proof.mjs +843 -0
- package/scripts/build-app.mjs +4 -0
- package/scripts/build-mirror.d.mts +2 -0
- package/scripts/build-mirror.mjs +5 -4
- package/scripts/built-product.mjs +3 -3
- package/scripts/cell-mem/metrics-preload.mjs +65 -0
- package/scripts/cell-mem-bench.mjs +130 -0
- package/scripts/check-chunks.mjs +2 -1
- package/scripts/check-devserver.mjs +1 -1
- package/scripts/chromium-keychain-check.mjs +4 -2
- package/scripts/chromium-keychain.mjs +3 -1
- package/scripts/cook.mjs +7 -3
- package/scripts/devices.d.mts +4 -0
- package/scripts/devices.mjs +39 -0
- package/scripts/devserver-client.d.mts +7 -0
- package/scripts/devserver-client.mjs +85 -0
- package/scripts/doctor-proof.mjs +1 -1
- package/scripts/e2e-faults.mjs +159 -0
- package/scripts/engine-ci-budget.ts +7 -1
- package/scripts/format-lock.mjs +20 -11
- package/scripts/generate-title-launch.mjs +3 -2
- package/scripts/grid-crossing-walk-proof.mjs +30 -11
- package/scripts/heavy-lane.py +25 -1
- package/scripts/host-ruler/register-migrate.mjs +242 -0
- package/scripts/host-ruler/register.d.mts +36 -0
- package/scripts/host-ruler/register.mjs +116 -0
- package/scripts/host-ruler/roots.d.mts +29 -0
- package/scripts/host-ruler/roots.mjs +333 -0
- package/scripts/host-ruler/server-roots.d.mts +23 -0
- package/scripts/host-ruler/server-roots.mjs +272 -0
- package/scripts/main-watch.d.mts +1 -1
- package/scripts/main-watch.mjs +10 -6
- package/scripts/map-hash.mjs +3 -6
- package/scripts/memory-proof.mjs +158 -0
- package/scripts/mmo-bots.mjs +2 -2
- package/scripts/offline-proof-rules.d.mts +5 -2
- package/scripts/offline-proof-rules.mjs +43 -6
- package/scripts/offline-proof.mjs +15 -6
- package/scripts/online-rig.mjs +4 -4
- package/scripts/page-release/flow.d.mts +1 -0
- package/scripts/page-release/flow.mjs +6 -2
- package/scripts/page-release.mjs +5 -1
- package/scripts/physics-route.json +0 -71
- package/scripts/pins-catalogue.ts +103 -0
- package/scripts/pins-reuse.mjs +3 -1
- package/scripts/pins.ts +22 -14
- package/scripts/preview-grid.ts +203 -0
- package/scripts/road-preload-proof.mjs +167 -0
- package/scripts/server-release/publish.mjs +2 -2
- package/scripts/server-release/served-slug.d.mts +2 -0
- package/scripts/server-release/served-slug.mjs +10 -0
- package/scripts/server-release/sign.d.mts +1 -0
- package/scripts/server-release/sign.mjs +3 -7
- package/scripts/shard-components.mjs +0 -2
- package/scripts/shard-outputs.d.mts +8 -0
- package/scripts/shard-outputs.mjs +45 -11
- package/scripts/side-parity.d.mts +2 -1
- package/scripts/side-parity.mjs +25 -4
- package/scripts/test-amber.d.mts +1 -0
- package/scripts/test-amber.mjs +10 -0
- package/scripts/test-products.json +3 -3
- package/scripts/tier-textures-proof.mjs +101 -0
- package/scripts/tier-textures.mjs +60 -0
- package/scripts/tracked-public.d.mts +1 -0
- package/scripts/tracked-public.mjs +17 -0
- package/scripts/tsconfig.json +1 -0
- package/scripts/vps/wildshard-config +79 -23
- package/scripts/worker-client-play.mjs +1 -0
- package/scripts/worker-client-proof.mjs +1 -1
- package/scripts/worker-client-slug.mjs +44 -0
- package/src/cli/engine.mjs +8 -0
- package/src/client/app/bootRoute.ts +4 -1
- package/src/client/app/dropModal.ts +15 -2
- package/src/client/app/entry.ts +96 -13
- package/src/client/app/slugPath.ts +5 -0
- package/src/client/engine/audio/Audio.ts +20 -2
- package/src/client/engine/boot/bakedTextures.ts +3 -2
- package/src/client/engine/boot/bootTrace.ts +6 -1
- package/src/client/engine/boot/bytes.ts +4 -3
- package/src/client/engine/boot/clearDownloads.ts +1 -1
- package/src/client/engine/boot/contentRead.ts +4 -0
- package/src/client/engine/boot/dropNotice.ts +20 -6
- package/src/client/engine/boot/gpuFiles.ts +25 -2
- package/src/client/engine/boot/lastEnd.ts +8 -2
- package/src/client/engine/boot/parsedPages.ts +127 -58
- package/src/client/engine/boot/shardPrefetch.ts +7 -1
- package/src/client/engine/boot/sw.ts +19 -0
- package/src/client/engine/build.d.ts +2 -0
- package/src/client/engine/core/Game.ts +29 -3
- package/src/client/engine/core/GpuRecovery.ts +7 -0
- package/src/client/engine/core/Volumetrics.ts +5 -0
- package/src/client/engine/core/assets.ts +27 -20
- package/src/client/engine/core/bootstrap.ts +5 -3
- package/src/client/engine/core/ktx2.ts +84 -11
- package/src/client/engine/debug/probe.ts +18 -1
- package/src/client/engine/explore/Compare.ts +2 -2
- package/src/client/engine/explore/TouchFly.ts +3 -5
- package/src/client/engine/fx/LightPool.ts +41 -1
- package/src/client/engine/input/dom.ts +12 -0
- package/src/client/engine/net/predictor.ts +6 -2
- package/src/client/engine/player/Player.ts +10 -2
- package/src/client/engine/player/TouchControls.ts +12 -4
- package/src/client/engine/pwa/sw.js +59 -11
- package/src/client/engine/render/drawCheck.ts +96 -0
- package/src/client/engine/render/precompile.ts +20 -14
- package/src/client/engine/saves/staleBuildNote.ts +46 -0
- package/src/client/engine/telemetry/browserErrors.ts +161 -21
- package/src/client/engine/telemetry/deviceSnapshot.ts +155 -0
- package/src/client/engine/telemetry/screenOutbox.ts +61 -0
- package/src/client/engine/telemetry/staleBuildReport.ts +12 -0
- package/src/client/engine/ui/DeathFade.ts +99 -11
- package/src/client/engine/ui/ErrorModal.ts +13 -6
- package/src/client/engine/ui/Feedback.ts +2 -1
- package/src/client/engine/ui/Loading.ts +10 -6
- package/src/client/engine/ui/Map.ts +2 -1
- package/src/client/engine/ui/WeaponStrip.ts +2 -1
- package/src/client/engine/ui/backGuard.ts +104 -0
- package/src/client/engine/ui/hudAdapters.ts +30 -4
- package/src/client/engine/ui/loading.css +17 -0
- package/src/client/engine/ui/namePrompt.ts +6 -5
- package/src/client/engine/ui/styles/combat.css +12 -0
- package/src/client/engine/ui/styles/namePrompt.css +4 -2
- package/src/client/game/boot/audio.generated.ts +0 -396
- package/src/client/game/boot/bytes.generated.ts +42 -71
- package/src/client/game/boot/versions.generated.ts +0 -13
- package/src/client/game/compendium/keepsakes.ts +16 -6
- package/src/client/game/grapple/tool.ts +10 -7
- package/src/client/game/grid/area.ts +38 -0
- package/src/client/game/grid/cellLoading.ts +23 -12
- package/src/client/game/grid/cellScreens.ts +39 -74
- package/src/client/game/grid/live.ts +28 -2
- package/src/client/game/grid/liveSession.ts +54 -10
- package/src/client/game/grid/menu.ts +4 -0
- package/src/client/game/grid/nearPlaceholderPlan.ts +8 -0
- package/src/client/game/grid/nearPlaceholderView.ts +9 -3
- package/src/client/game/grid/neighbourPanels.ts +10 -1
- package/src/client/game/grid/oneWayIn.ts +92 -27
- package/src/client/game/grid/pageEntry.ts +19 -0
- package/src/client/game/grid/pageShell.ts +1 -1
- package/src/client/game/grid/placedCards.ts +55 -0
- package/src/client/game/grid/placedCells.ts +131 -0
- package/src/client/game/grid/plotAudio.ts +114 -0
- package/src/client/game/grid/products.ts +55 -5
- package/src/client/game/grid/regionalRuntime.ts +6 -0
- package/src/client/game/grid/regionalWorld.ts +15 -2
- package/src/client/game/grid/roadCull.ts +44 -14
- package/src/client/game/grid/roadLookPlatform.ts +2 -2
- package/src/client/game/grid/roadTileBacking.ts +13 -3
- package/src/client/game/grid/session.ts +47 -22
- package/src/client/game/grid/shardfileFar.ts +9 -3
- package/src/client/game/grid/spawnGround.ts +68 -0
- package/src/client/game/grid/voidLook.ts +29 -23
- package/src/client/game/loot/runtime.ts +3 -1
- package/src/client/game/mainMenu.ts +14 -6
- package/src/client/game/riding/hud.ts +6 -4
- package/src/client/game/session/finish.ts +22 -4
- package/src/client/game/session/play.ts +8 -2
- package/src/client/game/session/session.ts +4 -1
- package/src/client/game/shard/titleList.ts +6 -2
- package/src/client/game/shardfile/clientWorker.ts +43 -13
- package/src/client/game/shardfile/serverRoute.ts +10 -22
- package/src/client/game/slugPage.css +11 -0
- package/src/client/game/slugPage.ts +84 -0
- package/src/client/game/systems/viewmodel/heldView.ts +6 -3
- package/src/client/game/titleDeck.ts +56 -32
- package/src/client/host/online/doctor.ts +7 -6
- package/src/client/host/online/linkScreens.ts +16 -0
- package/src/client/host/online/release.ts +51 -5
- package/src/client/host/online/shell.ts +62 -27
- package/src/client/host/standalone/shell.ts +7 -3
- package/src/cook/game/audioReport.ts +57 -0
- package/src/cook/game/entryTotals.ts +26 -6
- package/src/cook/game/installedRuntimeReads.ts +3 -0
- package/src/cook/game/shardCook.ts +38 -8
- package/src/cook/game/tierTextures.ts +276 -0
- package/src/e2e/smoke/game.ts +19 -14
- package/src/e2e/smoke/page-globals.d.ts +9 -8
- package/src/e2e/smoke/template2.spec.ts +8 -7
- package/src/server/engine/sim/respawn.ts +6 -1
- package/src/server/engine/sim.ts +3 -0
- package/src/server/game/grid/simulation.ts +35 -0
- package/src/server/game/loot/harvest.ts +2 -0
- package/src/server/game/loot/keepsakeProgression.ts +40 -0
- package/src/server/game/loot/playerOwned.ts +5 -1
- package/src/server/game/plugin/simulation.ts +4 -0
- package/src/server/game/population/nativeBake.ts +2 -1
- package/src/server/game/quest/chapterRecords.ts +2 -0
- package/src/server/game/quest/serverChapters.ts +4 -0
- package/src/server/game/quest/serverDoors.ts +11 -5
- package/src/server/game/roomRespawn.ts +4 -0
- package/src/server/game/shardfile/installedSides.ts +18 -0
- package/src/server/game/shardfile/nativeAssemblyHosts.ts +19 -10
- package/src/server/game/shardfile/nativeAssemblyInput.ts +1 -4
- package/src/server/host/bake/headlessWorker.ts +5 -1
- package/src/server/host/dedicated/cellHost.ts +98 -29
- package/src/server/host/dedicated/cellProtocol.ts +11 -1
- package/src/server/host/dedicated/cellWorker.ts +9 -3
- package/src/server/host/dedicated/crossing.ts +6 -2
- package/src/server/host/dedicated/dedicatedRoom.ts +21 -8
- package/src/server/host/dedicated/gridCells.ts +52 -9
- package/src/server/host/dedicated/main.ts +31 -12
- package/src/server/host/dedicated/placementFile.ts +56 -0
- package/src/server/host/dedicated/releaseFile.ts +17 -10
- package/src/server/host/dedicated/roadRoom.ts +21 -5
- package/src/server/host/dedicated/socketTransport.ts +2 -1
- package/src/server/host/dedicated/workerTable.ts +13 -1
- package/src/server/host/dedicated/world.ts +111 -10
- package/src/server/host/headlessRuntime.ts +10 -5
- package/src/server/host/installers.ts +62 -0
- package/src/server/host/openWorld.ts +59 -0
- package/src/server/host/ropeDecks.ts +2 -0
- package/src/server/host/standalone/cellWorld.ts +25 -19
- package/src/server/host/standalone/fallFloor.ts +2 -2
- package/src/server/host/standalone/gridServer.ts +7 -4
- package/src/server/host/standalone/roadWorld.ts +41 -4
- package/src/shared/engine/audio/bootAudio.ts +33 -0
- package/src/shared/engine/level/spec.ts +3 -3
- package/src/shared/engine/net/acts.ts +3 -0
- package/src/shared/engine/net/deviceWord.ts +138 -0
- package/src/shared/engine/net/socketFrames.ts +7 -4
- package/src/shared/engine/physics/query.ts +27 -0
- package/src/shared/engine/physics/terrain.ts +19 -28
- package/src/shared/engine/saves/saves.lock.json +15 -0
- package/src/shared/engine/sim/actRoutes.ts +2 -0
- package/src/shared/game/compendium/keepsakeProgression.ts +24 -0
- package/src/shared/game/grid/catalogue.ts +12 -5
- package/src/shared/game/grid/catalogueSlot.ts +18 -0
- package/src/shared/game/grid/farProxy.ts +6 -5
- package/src/shared/game/grid/pageMode.ts +1 -1
- package/src/shared/game/grid/placementRows.ts +33 -0
- package/src/shared/game/grid/roadLayout.ts +26 -3
- package/src/shared/game/grid/singleplayer.json +0 -13
- package/src/shared/game/grid/voidFloor.ts +122 -0
- package/src/shared/game/strings.ts +15 -0
- package/src/shared/host/standalone/netInput.ts +2 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { AudioData } from '@wildshard/format/audio';
|
|
2
|
+
import type { ClientPlan } from '@wildshard/format/clientPlan';
|
|
3
|
+
import type { Scope } from '@wildshard/engine/app/scope';
|
|
4
|
+
import type { LevelAudioBank } from '@wildshard/engine/audio/levelAudio';
|
|
5
|
+
import type { App } from '@wildshard/engine/app/app';
|
|
6
|
+
import type { Player } from '@wildshard/engine/player/Player';
|
|
7
|
+
import { wind } from '@wildshard/engine/world/steppeWind';
|
|
8
|
+
import { ENGINE_MUSIC_STYLE } from '@wildshard/engine/audio/bootAudio';
|
|
9
|
+
import { AudioSceneDirector } from '../audio/sceneDirector';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* AUDIO AU20: an Open Plot on the grid page is a bodyless data cell (no runtime, no declared client page), so no entered
|
|
13
|
+
* hooks run there and its client plan's `audio.scene` never installed: crossing in from a deck shard left the music and
|
|
14
|
+
* ambience buses silent. While the feet stand in such a cell, the grid binds the plot's declared audio scene (its score,
|
|
15
|
+
* bed and loops) to the page's mixer, and drops it on leaving.
|
|
16
|
+
*
|
|
17
|
+
* Where its takes come from: a play-time read (the page cache, else the network) when the feet enter the cell, never in
|
|
18
|
+
* LOAD, so the neighbour the player entered from keeps a DOWNLOAD of only its own audio.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** One wind observation the plot's `world.updates` audio-scene row feeds its director each frame. */
|
|
22
|
+
export interface PlotAudioInput { readonly name: string; readonly field: 'speed' | 'gust' }
|
|
23
|
+
/** What an Open Plot's cell plays while the feet stand in it. */
|
|
24
|
+
export interface PlotAudioScene { readonly data: AudioData; readonly inputs: readonly PlotAudioInput[] }
|
|
25
|
+
|
|
26
|
+
/** The plot's declared audio scene, or null when its cell has none the grid can play without an entered runtime: a runtime
|
|
27
|
+
* shard (its hooks own its audio), no `audio.scene` client feature, a scene in a separate file, or a frame input whose owner
|
|
28
|
+
* (an arena, the weather rig) exists only inside an entered runtime. */
|
|
29
|
+
export function plotAudioScene(source: { readonly runtime: unknown; readonly audio: AudioData }, plan: ClientPlan | undefined): PlotAudioScene | null {
|
|
30
|
+
if (source.runtime !== null || plan === undefined || source.audio.scene === undefined) return null;
|
|
31
|
+
if (!plan.features.some(feature => feature.kind === 'audio.scene')) return null;
|
|
32
|
+
const inputs: PlotAudioInput[] = [];
|
|
33
|
+
for (const feature of plan.features) {
|
|
34
|
+
if (feature.kind !== 'world.updates') continue;
|
|
35
|
+
for (const row of feature.rows) {
|
|
36
|
+
if (row.kind !== 'audio-scene') continue;
|
|
37
|
+
for (const input of row.inputs) {
|
|
38
|
+
if (input.source.kind !== 'wind') return null;
|
|
39
|
+
inputs.push({ name: input.name, field: input.source.field });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { data: source.audio, inputs };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The page owners a plot's scene borrows; tests pass their own. */
|
|
47
|
+
export interface PlotAudioPorts {
|
|
48
|
+
/** Bind the declared director to the page's mixer and music for `scope`; returns its frame update. */
|
|
49
|
+
readonly bind: (data: AudioData, scope: Scope) => (dt: number, inputs: Readonly<Record<string, number>>) => void;
|
|
50
|
+
/** Read and decode the plot's level bank (its loops, the score set's stings, the engine title) at play time; the grid
|
|
51
|
+
* keeps one read per resident cell, so walking its edge back and forth decodes it once. */
|
|
52
|
+
readonly bank: (data: AudioData) => Promise<LevelAudioBank>;
|
|
53
|
+
/** Lend the bank to the page's mixer while `scope` lives; the bank it replaced comes back after. */
|
|
54
|
+
readonly lend: (bank: LevelAudioBank, scope: Scope) => void;
|
|
55
|
+
/** Run `run` every frame while `scope` lives. */
|
|
56
|
+
readonly frame: (run: (dt: number) => void, scope: Scope) => void;
|
|
57
|
+
readonly wind: (field: PlotAudioInput['field']) => number;
|
|
58
|
+
readonly fault: (error: unknown) => void;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Enter the plot's scene for the life of `scope` (the feet in its cell). The score switches at once; its bank arrives
|
|
62
|
+
* when read, and a bank read after the feet left is never lent. */
|
|
63
|
+
export function enterPlotAudio(scene: PlotAudioScene, scope: Scope, ports: PlotAudioPorts): void {
|
|
64
|
+
if (scope.disposed) return;
|
|
65
|
+
// made before the director binds, so it ends after the director unbinds: the replaced bank returns to the page's own
|
|
66
|
+
// listeners, never to the plot's score and cue player
|
|
67
|
+
const lent = scope.child('plot-audio.bank');
|
|
68
|
+
const update = ports.bind(scene.data, scope);
|
|
69
|
+
ports.frame((dt) => {
|
|
70
|
+
const values: Record<string, number> = {};
|
|
71
|
+
for (const input of scene.inputs) values[input.name] = ports.wind(input.field);
|
|
72
|
+
update(dt, values);
|
|
73
|
+
}, scope);
|
|
74
|
+
const lend = async (): Promise<void> => {
|
|
75
|
+
try {
|
|
76
|
+
const bank = await ports.bank(scene.data);
|
|
77
|
+
if (!lent.disposed) ports.lend(bank, lent);
|
|
78
|
+
} catch (error) { if (!lent.disposed) ports.fault(error); }
|
|
79
|
+
};
|
|
80
|
+
void lend();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** One decode at a time, as the boot's decoder does (WebKit holds no pile of native PCM outputs at once). */
|
|
84
|
+
function serialDecode(decode: (bytes: ArrayBuffer) => Promise<AudioBuffer>): (bytes: ArrayBuffer) => Promise<AudioBuffer> {
|
|
85
|
+
let tail: Promise<unknown> = Promise.resolve();
|
|
86
|
+
return (bytes) => {
|
|
87
|
+
const next = tail.then(() => decode(bytes));
|
|
88
|
+
tail = next.catch(() => undefined);
|
|
89
|
+
return next;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The page's real owners: its mixer and music, the page player, the steppe wind. */
|
|
94
|
+
export function pagePlotAudioPorts(app: App, player: Player, instance: string): PlotAudioPorts | null {
|
|
95
|
+
const audio = app.audio;
|
|
96
|
+
if (audio === null) return null;
|
|
97
|
+
return {
|
|
98
|
+
bind: (data, scope) => {
|
|
99
|
+
const director = new AudioSceneDirector(data, player);
|
|
100
|
+
if (director.fieldFiles.length > 0) throw new Error('Plot audio fields need their product reads');
|
|
101
|
+
director.bind(audio, audio.music ?? undefined, undefined, scope);
|
|
102
|
+
return (dt, inputs) => { director.update(dt, inputs); };
|
|
103
|
+
},
|
|
104
|
+
bank: async (data) => {
|
|
105
|
+
const [{ createCatalogueAudio }, { cachedBytes, decodeBytes }] = await Promise.all([import('@wildshard/engine/audio/levelAudio'), import('@wildshard/engine/audio/preload')]);
|
|
106
|
+
const profile = await createCatalogueAudio(data);
|
|
107
|
+
return profile.decode(ENGINE_MUSIC_STYLE, cachedBytes, serialDecode(decodeBytes));
|
|
108
|
+
},
|
|
109
|
+
lend: (bank, scope) => { audio.lendLevelBank(bank, scope); },
|
|
110
|
+
frame: (run, scope) => { app.addContentSystem({ id: `grid.plot-audio.${instance}`, phase: 'update', after: ['engine.player.update'], run }, scope); },
|
|
111
|
+
wind: field => field === 'speed' ? wind.speed : wind.gustAt(player.position.x, player.position.z),
|
|
112
|
+
fault: (error) => { console.warn(`[grid] ${instance} plays no score`, error); },
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -75,10 +75,11 @@ async function readGridProductIndex(url: string, identity: string, options: Prod
|
|
|
75
75
|
return { index, url, options, packed };
|
|
76
76
|
}
|
|
77
77
|
/** One immutable file the index declares (a section or a blob), from the content cache or the product URL, size and hash
|
|
78
|
-
* checked; a network read is kept in the content cache like an admission's.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
* checked; a network read is kept in the content cache like an admission's. `address` is the file's URL (a versioned
|
|
79
|
+
* section's carries its `?v=`). */
|
|
80
|
+
async function readGridProductFile(at: GridProductIndex, path: string, hash: string, size: number, address = new URL(path, at.url).href): Promise<Uint8Array> {
|
|
81
|
+
const { options } = at, base = new URL('.', at.url).href, native = nativeRead(options);
|
|
82
|
+
if(native!==undefined)return native(address,size,undefined,hash);
|
|
82
83
|
const held = await options.cache?.asset(base, hash) ?? await options.cachedResponse?.(address, hash, size);
|
|
83
84
|
if ((held === null || held === undefined) && options.offline) throw new Error(`Missing cached grid product file ${path}`);
|
|
84
85
|
const bytes = held ?? (at.packed.has(hash) ? await at.packed.read(hash) : await boundedResponse(await options.fetch(address), size));
|
|
@@ -93,11 +94,60 @@ async function readGridProductFile(at: GridProductIndex, path: string, hash: str
|
|
|
93
94
|
}
|
|
94
95
|
return bytes;
|
|
95
96
|
}
|
|
97
|
+
/** OFFLINE OF8: one read per section URL in a load. The far ring's byte charge, the far proxy and the near proxy each read a
|
|
98
|
+
* neighbour's world/tiles (and both proxies its look), at once or a few hundred ms apart, and the audit saw one section URL
|
|
99
|
+
* read up to 5 times in a load. A read in flight is shared; each caller parses its own copy. */
|
|
100
|
+
const sectionReads = new Map<string, Promise<Uint8Array>>();
|
|
101
|
+
/** A first-party section's verified bytes, kept after the read settles so the next caller in the same load reads none. Its
|
|
102
|
+
* URL names its hash, so a kept copy is never stale. Least recently used leaves first past `SECTION_BYTES` (one load's
|
|
103
|
+
* neighbour sections are about 0.3-1 MB; the largest seen is 73 KB). */
|
|
104
|
+
const settledSections = new Map<string, Uint8Array>();
|
|
105
|
+
const SECTION_BYTES = 2 * 1024 * 1024;
|
|
106
|
+
let settledBytes = 0;
|
|
107
|
+
function keepSection(key: string, bytes: Uint8Array): void {
|
|
108
|
+
if (bytes.length > SECTION_BYTES || settledSections.has(key)) return;
|
|
109
|
+
settledSections.set(key, bytes); settledBytes += bytes.length;
|
|
110
|
+
for (const [oldest, held] of settledSections) {
|
|
111
|
+
if (settledBytes <= SECTION_BYTES) break;
|
|
112
|
+
settledSections.delete(oldest); settledBytes -= held.length;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/** A first-party section's URL carries `?v=` and the first 8 hex of the hash its index declares, as the cook names it in a
|
|
116
|
+
* spawn manifest (`shardCook.ts` productFile), so the service worker's `immutable()` keeps it and a spawn download's copy
|
|
117
|
+
* answers it. A third-party product's file keeps its bare URL. */
|
|
118
|
+
function gridSectionAddress(at: GridProductIndex, path: string, hash: string): string {
|
|
119
|
+
const address = new URL(path, at.url);
|
|
120
|
+
if (nativeRead(at.options) !== undefined) address.searchParams.set('v', hash.slice(0, 8));
|
|
121
|
+
return address.href;
|
|
122
|
+
}
|
|
123
|
+
/** The build-owned reader a first-party product reads through (undefined: the checked network and content-cache path). */
|
|
124
|
+
function nativeRead(options: ProductOptions): ProductOptions['firstPartyRead'] {
|
|
125
|
+
return options.firstParty ? options.firstPartyRead : undefined;
|
|
126
|
+
}
|
|
96
127
|
/** One hash-verified section of the index, parsed (null when the index has none). */
|
|
97
128
|
async function readGridSection(at: GridProductIndex, name: string): Promise<unknown> {
|
|
98
129
|
const section = at.index.sections.find(row => row.name === name);
|
|
99
130
|
if (section === undefined) return null;
|
|
100
|
-
|
|
131
|
+
const address = gridSectionAddress(at, section.path, section.hash), versioned = nativeRead(at.options) !== undefined;
|
|
132
|
+
const decode = (bytes: Uint8Array): unknown => JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
|
|
133
|
+
// Only a first-party section is kept once settled: the checked path has its own content cache and revalidation.
|
|
134
|
+
const held = versioned ? settledSections.get(`${address} ${section.hash}`) : undefined;
|
|
135
|
+
if (held !== undefined) {
|
|
136
|
+
const kept = `${address} ${section.hash}`;
|
|
137
|
+
settledSections.delete(kept); settledSections.set(kept, held);
|
|
138
|
+
return decode(held);
|
|
139
|
+
}
|
|
140
|
+
// an offline caller on the checked path refuses what an online one would fetch, so they never share a read
|
|
141
|
+
const key = `${address} ${section.hash} ${String(at.options.offline)}`;
|
|
142
|
+
let reading = sectionReads.get(key);
|
|
143
|
+
if (reading === undefined) {
|
|
144
|
+
const read = readGridProductFile(at, section.path, section.hash, section.bytes, address);
|
|
145
|
+
reading = read;
|
|
146
|
+
sectionReads.set(key, read);
|
|
147
|
+
const forget = (): void => { if (sectionReads.get(key) === read) sectionReads.delete(key); };
|
|
148
|
+
void read.then(bytes => { forget(); if (versioned) keepSection(`${address} ${section.hash}`, bytes); return bytes; }, forget);
|
|
149
|
+
}
|
|
150
|
+
return decode(await reading);
|
|
101
151
|
}
|
|
102
152
|
/** One hash-verified section of a product's bounded index (null when the index has none). No runtime or asset is admitted. */
|
|
103
153
|
async function readGridProductSection(url: string, identity: string, name: string, options: ProductOptions): Promise<unknown> {
|
|
@@ -445,6 +445,12 @@ export function createRegionalRuntimeFactory(ports: RegionalRuntimeFactoryPorts)
|
|
|
445
445
|
performance.measure(name, { start: stage.endAt - stage.elapsedMs, end: stage.endAt, detail: { units: stage.units } });
|
|
446
446
|
}
|
|
447
447
|
restored = true;
|
|
448
|
+
// RP4: this cell's road variants (no PMREM), linked in play before the player can reach its edge
|
|
449
|
+
const warmRoad = async (): Promise<void> => {
|
|
450
|
+
try { await request.page.world.game.warmExteriorRoots(owner, [...view.root.children], () => !owner.disposed && !owner.disposing); }
|
|
451
|
+
catch (error: unknown) { if (!owner.disposed && !owner.disposing) console.warn('[grid] road variant warm-up stopped', error); }
|
|
452
|
+
};
|
|
453
|
+
void warmRoad();
|
|
448
454
|
// js-heap H6 for a grid region, as the solo page's finish.ts does: the entry has built and warmed everything
|
|
449
455
|
// its admitted transport fed, so keep none of it (Nalati's 45 MB of product files stayed in a Simulator
|
|
450
456
|
// interior's JS heap, T10). A later read rechecks the immutable cache or the network, as a released tile does;
|
|
@@ -240,6 +240,12 @@ async function slicedTerrainGrid(run: (rows: () => number) => number, left: () =
|
|
|
240
240
|
|
|
241
241
|
const regionLevel = ({ id, spawn }: LevelSpec): RegionLevel => ({ id, player: { at: { x: spawn.x, y: spawn.y ?? 0, z: spawn.z }, yaw: spawn.yaw } });
|
|
242
242
|
|
|
243
|
+
/** PZ22: install the shard's KTX2 table (once per manifest) before its texture policy resolves: Auto reads KTX2 from
|
|
244
|
+
* the registered table (gpuFiles.ts, DL17), so a choice made first stays on images for the resident's whole life. */
|
|
245
|
+
export function registerRegionalTextureTable(manifest: ShardManifest): Promise<void> {
|
|
246
|
+
return prepareShardAssets(manifest, registerGpuFiles);
|
|
247
|
+
}
|
|
248
|
+
|
|
243
249
|
/** Resolve the existing texture policy once before memory admission. The resident enters this SAME policy for
|
|
244
250
|
* asynchronous construction and each frame, so a capability-probe image fallback cannot retain a compressed claim. */
|
|
245
251
|
export function resolveRegionalRuntimeTextures(manifest: Pick<ShardManifest, 'slug' | 'tiers' | 'runtimeCost'>, residents?: Parameters<typeof imagesFirstPlayingBytes>[1]): RegionalRuntimeTextures {
|
|
@@ -263,6 +269,8 @@ export function createRegionalWorldFoundation(ports: RegionalWorldPorts): (reque
|
|
|
263
269
|
const level = ports.level === undefined ? toLevelSpec(hasDeclaredClientPage(request.admitted.source) ? { ...request.manifest, ground: clientPageGround(request.admitted.source, request.admitted.assets) } : request.manifest, product) : ports.level(request.manifest);
|
|
264
270
|
const { slug: identity } = request.manifest;
|
|
265
271
|
if (level.id !== identity) throw new Error('Regional level identity differs from its trusted manifest');
|
|
272
|
+
// PZ22: the table goes in before Auto resolves, and before the resident's scope exists to leak on a refusal
|
|
273
|
+
if (request.textures === undefined) await registerRegionalTextureTable(request.manifest);
|
|
266
274
|
const resident = request.scope.child(`grid.world:${cell.instance}`), left = (): boolean => resident.disposed;
|
|
267
275
|
const pausePoint = regionalBuildCheckpoint(resident, ports.pause);
|
|
268
276
|
let pauses = clientPreparationBatch(identity, 'native.checkpoints', ['pause']);
|
|
@@ -280,7 +288,7 @@ export function createRegionalWorldFoundation(ports: RegionalWorldPorts): (reque
|
|
|
280
288
|
let rendering: Promise<[PromiseSettledResult<void>]> | undefined;
|
|
281
289
|
ownSceneTree(scene, resident, app.assets);
|
|
282
290
|
try {
|
|
283
|
-
await timeClientPreparation(identity, 'native.shard-assets', () =>
|
|
291
|
+
await timeClientPreparation(identity, 'native.shard-assets', () => registerRegionalTextureTable(request.manifest));
|
|
284
292
|
if (left()) throw new Error('Regional world left while registering its texture stand-ins');
|
|
285
293
|
// M3 tiles-swap: the admitted product's reader for the resident runtime (a painter that binds its compiled tiles reads
|
|
286
294
|
// it), handed over first: the level's declared navigation and a required manifest ground are that product's own files
|
|
@@ -534,7 +542,9 @@ export function createRegionalWorldFoundation(ports: RegionalWorldPorts): (reque
|
|
|
534
542
|
// The world-only inventory can link while kit/play continue, with the exact destination sky and look.
|
|
535
543
|
prepareWorldMaterials: async () => {
|
|
536
544
|
await skyReady;
|
|
537
|
-
if (
|
|
545
|
+
if (resident.disposed) return;
|
|
546
|
+
regionLook?.sweep();
|
|
547
|
+
LightPool.for(scene).adopt(scene);
|
|
538
548
|
},
|
|
539
549
|
precompileEnvironment: () => scene.environment,
|
|
540
550
|
// rt3-crossing2: the look's per-frame sweep never ran on what the entered hooks added (no frame draws while they
|
|
@@ -543,6 +553,9 @@ export function createRegionalWorldFoundation(ports: RegionalWorldPorts): (reque
|
|
|
543
553
|
await skyReady;
|
|
544
554
|
if (resident.disposed) return;
|
|
545
555
|
regionLook?.sweep();
|
|
556
|
+
// RP4: its content's own point lights (Sunscar's site and signal lights) show through the page's reserved lights,
|
|
557
|
+
// taken before the warm-up compiles, so showing the region never moves the page's light count
|
|
558
|
+
LightPool.for(scene).adopt(scene);
|
|
546
559
|
// op-frame21: its own composite, once its world hook has run and before the warm-up compiles the page's passes
|
|
547
560
|
const place = framePort?.composite;
|
|
548
561
|
if (cellComposite !== null && place !== undefined && viewRoot !== null && !composited) {
|
|
@@ -42,6 +42,25 @@ function binGrid(pitch: number, tileSize?: number): { size: number; offset: numb
|
|
|
42
42
|
/** A cell edge's distance from its cell centre (the seam's outer row meets the shard's own ground there). */
|
|
43
43
|
const CELL_EDGE = CHUNK_HALF;
|
|
44
44
|
|
|
45
|
+
/** IOSMEM (WILDSHARD-GAME-8G): the clip's and bin sort's working lists, growing typed storage off the JS heap. As
|
|
46
|
+
* number[] they held ~40-90 bytes a triangle of short-lived heap through an install (hundreds of MB on Driftwood's road),
|
|
47
|
+
* which an iPhone counts against the page until it collects. */
|
|
48
|
+
class Grow<A extends Uint32Array | Float64Array> {
|
|
49
|
+
length = 0;
|
|
50
|
+
constructor(private array: A, private readonly make: (size: number) => A) {}
|
|
51
|
+
push(value: number): void {
|
|
52
|
+
if (this.length === this.array.length) { const next = this.make(Math.max(64, this.array.length * 2)); next.set(this.array); this.array = next; }
|
|
53
|
+
this.array[this.length++] = value;
|
|
54
|
+
}
|
|
55
|
+
/** The filled part; `exact` copies it out so a long-kept result never pins the spare capacity. */
|
|
56
|
+
view(exact = false): A {
|
|
57
|
+
if (!exact) return this.array.subarray(0, this.length) as A;
|
|
58
|
+
return (this.length === this.array.length ? this.array : this.array.slice(0, this.length)) as A;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const growU32 = (size: number): Grow<Uint32Array> => new Grow(new Uint32Array(size), (n) => new Uint32Array(n));
|
|
62
|
+
const growF64 = (size: number): Grow<Float64Array> => new Grow(new Float64Array(size), (n) => new Float64Array(n));
|
|
63
|
+
|
|
45
64
|
|
|
46
65
|
/** The same attribute interpolation and index order, yielding between bounded triangle/copy batches. */
|
|
47
66
|
export function* clipToBinsSteps(geometry: BufferGeometry, pitch: number, tileSize?: number): Generator<void> {
|
|
@@ -70,7 +89,7 @@ export function* clipToBinsSteps(geometry: BufferGeometry, pitch: number, tileSi
|
|
|
70
89
|
for (let n = 0; n < extra.length / stride; n++) { if (n % 256 === 0) yield; for (let c = 0; c < size; c++) array[(count + n) * size + c] = extra[n * stride + o + c] ?? 0; }
|
|
71
90
|
geometry.setAttribute(name, new BufferAttribute(array, size)); o += size;
|
|
72
91
|
}
|
|
73
|
-
geometry.setIndex(new BufferAttribute(
|
|
92
|
+
geometry.setIndex(new BufferAttribute(out.slice(), 1));
|
|
74
93
|
}
|
|
75
94
|
|
|
76
95
|
/**
|
|
@@ -78,8 +97,9 @@ export function* clipToBinsSteps(geometry: BufferGeometry, pitch: number, tileSi
|
|
|
78
97
|
* x then z, a new vertex interpolating all `stride` values linearly (position at `px`). A plan that reads only positions
|
|
79
98
|
* gets exactly the builder's positions, new vertices and triangles: every value interpolates on its own.
|
|
80
99
|
*/
|
|
81
|
-
function* clipCore(triangles: number, indexAt: (i: number) => number, count: number, stride: number, px: number, read: (n: number) => Float64Array, coordinate: (n: number, axis: number) => number, pitch: number, tileSize?: number, retain = true): Generator<void, { extra:
|
|
82
|
-
|
|
100
|
+
function* clipCore(triangles: number, indexAt: (i: number) => number, count: number, stride: number, px: number, read: (n: number) => Float64Array, coordinate: (n: number, axis: number) => number, pitch: number, tileSize?: number, retain = true): Generator<void, { extra: Float64Array; out: Uint32Array; added: number; corners: number }> {
|
|
101
|
+
// Most triangles fit one bin, so the index is about three corners a triangle; cut triangles grow it.
|
|
102
|
+
const { size: s, offset } = binGrid(pitch, tileSize), extra = growF64(retain ? stride * 64 : 0), out = growU32(retain ? triangles * 3 + 64 : 0);
|
|
83
103
|
let added = 0, corners = 0;
|
|
84
104
|
// Count-only admission needs no final index or copied interpolation channels.
|
|
85
105
|
// Polygon vertices still retain every value used by the original split.
|
|
@@ -107,7 +127,7 @@ function* clipCore(triangles: number, indexAt: (i: number) => number, count: num
|
|
|
107
127
|
// polygons or copying attributes; only an interior cut needs interpolation.
|
|
108
128
|
if (!crossesBin(coordinate(a, 0), coordinate(b, 0), coordinate(third, 0), s, offset)
|
|
109
129
|
&& !crossesBin(coordinate(a, 2), coordinate(b, 2), coordinate(third, 2), s, offset)) {
|
|
110
|
-
corners += 3; if (retain) out.push(a
|
|
130
|
+
corners += 3; if (retain) { out.push(a); out.push(b); out.push(third); } continue;
|
|
111
131
|
}
|
|
112
132
|
const tri: V[] = [a, b, third].map((n) => ({ n, v: read(n) }));
|
|
113
133
|
let polys: V[][] = [tri];
|
|
@@ -127,10 +147,10 @@ function* clipCore(triangles: number, indexAt: (i: number) => number, count: num
|
|
|
127
147
|
}
|
|
128
148
|
for (const poly of polys) for (let k = 1; k + 1 < poly.length; k++) {
|
|
129
149
|
corners += 3;
|
|
130
|
-
if (retain) out.push(poly[0]?.n ?? 0
|
|
150
|
+
if (retain) { out.push(poly[0]?.n ?? 0); out.push(poly[k]?.n ?? 0); out.push(poly[k + 1]?.n ?? 0); }
|
|
131
151
|
}
|
|
132
152
|
}
|
|
133
|
-
return { extra, out, added, corners };
|
|
153
|
+
return { extra: extra.view(), out: out.view(), added, corners };
|
|
134
154
|
}
|
|
135
155
|
|
|
136
156
|
|
|
@@ -147,26 +167,36 @@ export function* cullPlanSteps(geometry: BufferGeometry, pitch: number, lod: rea
|
|
|
147
167
|
if (index === null) throw new Error('A culled road mesh needs an index');
|
|
148
168
|
// each triangle's bin (`cullBin` of its centroid) as two numbers; a bin's string key, made once, orders the bins
|
|
149
169
|
const { size, offset } = binGrid(pitch, tileSize);
|
|
150
|
-
|
|
170
|
+
// Each triangle's bin id in one typed pass, then a counting sort keeps every bin's triangles in index order (IOSMEM:
|
|
171
|
+
// no number[] list per bin on the JS heap).
|
|
172
|
+
interface BinRow { readonly key: string; readonly x: number; readonly z: number; readonly id: number; count: number }
|
|
173
|
+
const triangles = index.count / 3, byBin = new Map<number, Map<number, BinRow>>(), binOf = new Uint32Array(triangles);
|
|
174
|
+
let binCount = 0;
|
|
151
175
|
for (let t = 0; t < triangles; t++) {
|
|
152
176
|
if (t % 256 === 0) yield;
|
|
153
177
|
let x = 0, z = 0;
|
|
154
178
|
for (let c = 0; c < 3; c++) { const n = index.getX(t * 3 + c); x += position.getX(n); z += position.getZ(n); }
|
|
155
179
|
const bx = Math.floor(x / 3 / size + offset), bz = Math.floor(z / 3 / size + offset);
|
|
156
180
|
let row = byBin.get(bx); if (row === undefined) { row = new Map(); byBin.set(bx, row); }
|
|
157
|
-
|
|
158
|
-
if (bin === undefined)
|
|
181
|
+
let bin = row.get(bz);
|
|
182
|
+
if (bin === undefined) { bin = { key: `${String(bx)},${String(bz)}`, x: bx, z: bz, id: binCount++, count: 0 }; row.set(bz, bin); }
|
|
183
|
+
bin.count++; binOf[t] = bin.id;
|
|
159
184
|
}
|
|
160
|
-
const
|
|
185
|
+
const firsts = new Uint32Array(binCount + 1), members = new Uint32Array(triangles);
|
|
186
|
+
for (const row of byBin.values()) for (const bin of row.values()) firsts[bin.id + 1] = bin.count;
|
|
187
|
+
for (let b = 0; b < binCount; b++) firsts[b + 1] = (firsts[b + 1] ?? 0) + (firsts[b] ?? 0);
|
|
188
|
+
{ const cursor = firsts.slice(0, binCount); for (let t = 0; t < triangles; t++) { if (t % 4096 === 0) yield; const b = binOf[t] ?? 0; members[cursor[b] ?? 0] = t; cursor[b] = (cursor[b] ?? 0) + 1; } }
|
|
189
|
+
const out = growU32(triangles * 3 + 64), bins: CullBin[] = [];
|
|
161
190
|
const clusters = lod.map((tier) => clusterer(geometry, pitch, tier.cell, tileSize));
|
|
162
|
-
const ordered:
|
|
191
|
+
const ordered: BinRow[] = [];
|
|
163
192
|
for (const row of byBin.values()) for (const bin of row.values()) ordered.push(bin);
|
|
164
193
|
ordered.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
|
|
165
194
|
// A shared indexed vertex contributes once per bin to both bounds scans.
|
|
166
195
|
// Keep triangle publication and LOD representative order unchanged.
|
|
167
196
|
const boundedIn = new Uint32Array(position.count);
|
|
168
197
|
let binId = 0;
|
|
169
|
-
for (const {
|
|
198
|
+
for (const { id, x: tileX, z: tileZ } of ordered) {
|
|
199
|
+
const list = members.subarray(firsts[id] ?? 0, firsts[id + 1] ?? 0);
|
|
170
200
|
const start = out.length, unique: number[] = [];
|
|
171
201
|
binId++;
|
|
172
202
|
let minX = Infinity, minY = Infinity, minZ = Infinity, maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
|
|
@@ -198,13 +228,13 @@ export function* cullPlanSteps(geometry: BufferGeometry, pitch: number, lod: rea
|
|
|
198
228
|
if (i % 256 === 0) yield;
|
|
199
229
|
const t = list[i] ?? 0;
|
|
200
230
|
const a = cluster(index.getX(t * 3)), b = cluster(index.getX(t * 3 + 1)), c = cluster(index.getX(t * 3 + 2));
|
|
201
|
-
if (a !== b && b !== c && a !== c) out.push(a
|
|
231
|
+
if (a !== b && b !== c && a !== c) { out.push(a); out.push(b); out.push(c); }
|
|
202
232
|
}
|
|
203
233
|
levels.push({ start: from, count: out.length - from });
|
|
204
234
|
}
|
|
205
235
|
bins.push({ sphere, start, count, levels, ...(tileSize === undefined ? {} : { tile: { x: tileX, z: tileZ } }) });
|
|
206
236
|
}
|
|
207
|
-
return { source:
|
|
237
|
+
return { source: out.view(true), bins, lod: lod.map((tier) => tier.distance) };
|
|
208
238
|
}
|
|
209
239
|
|
|
210
240
|
/**
|
|
@@ -110,7 +110,7 @@ export async function installPlatformRoadSliced(input: PlatformRoadInput, pause:
|
|
|
110
110
|
/** the layout's pieces standing at points `within` accepts (the rail stays: it belongs to the void floor) */
|
|
111
111
|
function layoutWithin(layout: RoadLayout, within: (x: number, z: number) => boolean): RoadLayout {
|
|
112
112
|
return { segments: layout.segments.filter(s => within(s.centre.x, s.centre.z)), junctions: layout.junctions.filter(j => within(j.centre.x, j.centre.z)),
|
|
113
|
-
signs: layout.signs.filter(s => within(s.at.x, s.at.z)), lights: layout.lights.filter(l => within(l.at.x, l.at.z)), rail: layout.rail };
|
|
113
|
+
signs: layout.signs.filter(s => within(s.at.x, s.at.z)), lights: layout.lights.filter(l => within(l.at.x, l.at.z)), rail: layout.rail, edge: layout.edge, holes: layout.holes };
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/** Two builds of one road system (A1's ring-first halves) as one: their readouts summed, roots joined, hooks shared. */
|
|
@@ -153,7 +153,7 @@ function* platformRoadSteps(input: PlatformRoadInput): Generator<void, PlatformR
|
|
|
153
153
|
const road = yield* installRoadLookSteps({ layout, home, scene, scope, solid, cull: culler, admission, overlayLight, retireGeometry,
|
|
154
154
|
...(input.grain === undefined ? {} : { grain: input.grain }),
|
|
155
155
|
...(input.signs === undefined ? {} : { signs: input.signs }) });
|
|
156
|
-
const voidLook = input.voidFloor === false ? null : installVoidLook({ rail: layout.rail, home, scene, scope, solid, admission });
|
|
156
|
+
const voidLook = input.voidFloor === false ? null : installVoidLook({ rail: layout.rail, edge: layout.edge, holes: layout.holes, home, scene, scope, solid, admission });
|
|
157
157
|
// this build's own boulevard group (a split road adds one per build)
|
|
158
158
|
let boulevard: Object3D | undefined;
|
|
159
159
|
for (const child of scene.children) if (child.name === 'grid-boulevard') boulevard = child;
|
|
@@ -53,6 +53,18 @@ function archiveScratch(mesh: Mesh, indices: number): number {
|
|
|
53
53
|
const bytes = 4 * (indices * (stride + 8) + header) + 2 * (indices * (stride + 64) + header);
|
|
54
54
|
return Number.isSafeInteger(bytes) ? bytes : Infinity;
|
|
55
55
|
}
|
|
56
|
+
/** Retire a whole-road mesh once its tile pool (a child) draws instead; returns the geometry it drew, for disposal. It stays
|
|
57
|
+
* as the pool's parent but draws in no view (no camera's layers, shadow pass included). RP4: three links a program in
|
|
58
|
+
* `setProgram` before it reads the draw count, so the empty mesh linked a flat-shaded, position-less variant of each road
|
|
59
|
+
* material the first frame it drew (Driftwood's west edge, 3 links, 386 ms in Chromium) and again at every light-count move. */
|
|
60
|
+
export function retireWholeRoadMesh(mesh: Mesh): BufferGeometry {
|
|
61
|
+
const previous = mesh.geometry;
|
|
62
|
+
mesh.geometry = new BufferGeometry(); mesh.geometry.setDrawRange(0, 0);
|
|
63
|
+
mesh.onBeforeRender = () => { /* Original cull buffers are retired. */ };
|
|
64
|
+
mesh.layers.disableAll();
|
|
65
|
+
return previous;
|
|
66
|
+
}
|
|
67
|
+
|
|
56
68
|
export class RoadTileBacking {
|
|
57
69
|
private readonly sources = new Map<Mesh, Source>();
|
|
58
70
|
private readonly pending: PendingArchive[] = [];
|
|
@@ -284,9 +296,7 @@ export class RoadTileBacking {
|
|
|
284
296
|
// hidden. Geometry disposal precedes each corresponding lease shrink.
|
|
285
297
|
for (const source of this.sources.values()) if (source.pool !== null) source.pool.root.visible = true;
|
|
286
298
|
for (const source of this.sources.values()) {
|
|
287
|
-
const previous = source.mesh
|
|
288
|
-
source.mesh.geometry = new BufferGeometry(); source.mesh.geometry.setDrawRange(0, 0);
|
|
289
|
-
source.mesh.onBeforeRender = () => { /* Original cull buffers are retired. */ };
|
|
299
|
+
const previous = retireWholeRoadMesh(source.mesh);
|
|
290
300
|
this.culler.plans.delete(source.mesh); previous.dispose(); source.retire?.();
|
|
291
301
|
}
|
|
292
302
|
this.committed = true;
|
|
@@ -55,7 +55,8 @@ import { neighbourEdges } from '../../../shared/game/grid/readinessEdges';
|
|
|
55
55
|
import { DEVSERVER, gridMode } from './menu';
|
|
56
56
|
import { gridCells, pageGridInstance } from '../plugin/context';
|
|
57
57
|
import { prepareHomeMetadata, withInitialHomeMetadata } from './homeMetadata';
|
|
58
|
-
import { bootSteppedTiles } from './loadingRings';
|
|
58
|
+
import { bootSteppedTiles, stepRingsUntil } from './loadingRings';
|
|
59
|
+
import { holdSpawnGround, spawnGroundCell, type SpawnGround } from './spawnGround';
|
|
59
60
|
import type { ResidencyAllocator } from '../../../shared/game/grid/allocator';
|
|
60
61
|
import type { PageResidency } from './pageResidency';
|
|
61
62
|
import { PlatformRenderResidency } from './renderResidency';
|
|
@@ -67,7 +68,7 @@ import { FarImpostorSchema, type FarImpostor } from '@wildshard/format/shardSect
|
|
|
67
68
|
import { bindCellCover, cellCoverPort } from './cellCover';
|
|
68
69
|
import { FAR_RING, type FarLookRuntime } from '../../../shared/game/grid/farProxy';
|
|
69
70
|
import { bakedNearFiles, NearPlaceholders, type NearPlaceholderState } from './nearPlaceholderView';
|
|
70
|
-
import { PHONE_NEAR_CELLS, placeholderBlocksTiles } from './nearPlaceholderPlan';
|
|
71
|
+
import { PHONE_NEAR_CELLS, admitsCellTiles, placeholderBlocksTiles } from './nearPlaceholderPlan';
|
|
71
72
|
import { TIER } from '@wildshard/engine/core/tier';
|
|
72
73
|
import { GridFrame, type GridFrameHost, type GridFrameState } from './frame';
|
|
73
74
|
import { installHazeBand } from './hazeBand';
|
|
@@ -77,7 +78,9 @@ import { ApproachInputsDeferredError } from './productInputs';
|
|
|
77
78
|
import { GridViewAdmissions } from './viewAdmissions';
|
|
78
79
|
import { loadShardfileFar, loadShardfileNear } from './shardfileFar';
|
|
79
80
|
import { jsonResidentBytes } from '../shardfile/productCost';
|
|
80
|
-
import {
|
|
81
|
+
import { withOwner } from '@wildshard/engine/app/ownership';
|
|
82
|
+
import { roadLayout } from '../../../shared/game/grid/roadLayout';
|
|
83
|
+
import { installVoidFloor, rimWalls } from '../../../shared/game/grid/voidFloor';
|
|
81
84
|
import type { RoadLookState } from './roadLook';
|
|
82
85
|
import { combinePlatformRoads, installPlatformRoad, installPlatformRoadSliced, type PlatformRoad } from './roadLookPlatform';
|
|
83
86
|
import { collisionStrips, type CollisionStrip } from '../../../shared/game/grid/collisionStrips';
|
|
@@ -105,7 +108,7 @@ import { GAME_STRINGS } from '../../../shared/game/strings';
|
|
|
105
108
|
import { GridCellWaitingError, classifyRefusal, pageShardRefusals, refusalReason, type ShardRefusal } from './refusal';
|
|
106
109
|
import { tileRing } from '../shardfile/tileDriver';
|
|
107
110
|
import { CellLoading, type CellLoadingInput } from './cellLoading';
|
|
108
|
-
import {
|
|
111
|
+
import { CellLoadingCard } from './cellScreens';
|
|
109
112
|
import { readGridSeamData, type GridSeamAddress } from '../../../shared/game/grid/seamData';
|
|
110
113
|
import { readCompiledGridStrips } from '../../../shared/game/grid/compiledStrips';
|
|
111
114
|
import { startRoadGrain } from './roadGrainPreparation';
|
|
@@ -113,6 +116,8 @@ import { startRoadSigns } from './roadSignPreparation';
|
|
|
113
116
|
import { clientPreparationBatch } from '../shardfile/preparationTiming';
|
|
114
117
|
|
|
115
118
|
import { admittedRuntimeProduct } from '../shardfile/runtimeProduct';
|
|
119
|
+
import { gridArea } from './area';
|
|
120
|
+
import type { ProbeArea } from '@wildshard/engine/debug/probe';
|
|
116
121
|
|
|
117
122
|
/** D12: the A1 outer ring's share of a drawn frame (ms). On the phone tier its strips, colliders and road stop 4 ms after
|
|
118
123
|
* the last drawn frame (every other build keeps WORK_SLICE_MS): streamed at the shared 8 ms it held the grid's spawn
|
|
@@ -287,15 +292,9 @@ function farLook(row: unknown): FarLookRuntime { return v.parse(FarRow, row).loo
|
|
|
287
292
|
function farImpostorRow(row: unknown): FarImpostor | undefined { return v.parse(FarRow, row).far.impostor; }
|
|
288
293
|
function farBytes(row: unknown): number { const { far } = v.parse(FarRow, row); return Math.round(far.gpu + far.decoded); }
|
|
289
294
|
|
|
290
|
-
/** The closed outer rim on the
|
|
295
|
+
/** The closed outer rim on the 7 × 7's outer road shoulder (SA34): the void's rail (G89; the empty neighbour has no sim to wait for). */
|
|
291
296
|
function rimEdges(assembly: GridAssembly, home: Readonly<{ origin: Readonly<{ x: number; z: number }> }>): ReadinessEdge[] {
|
|
292
|
-
|
|
293
|
-
const minX = Math.min(...xs) * p - p / 2 - RAIL_OFFSET, maxX = Math.max(...xs) * p + p / 2 + RAIL_OFFSET, minZ = Math.min(...zs) * p - p / 2 - RAIL_OFFSET, maxZ = Math.max(...zs) * p + p / 2 + RAIL_OFFSET;
|
|
294
|
-
const cx = (minX + maxX) / 2 - home.origin.x, cz = (minZ + maxZ) / 2 - home.origin.z, hx = (maxX - minX) / 2, hz = (maxZ - minZ) / 2;
|
|
295
|
-
return [
|
|
296
|
-
{ instance: null, x: minX - home.origin.x, z: cz, axis: 'x', halfLength: hz, floor: 0 }, { instance: null, x: maxX - home.origin.x, z: cz, axis: 'x', halfLength: hz, floor: 0 },
|
|
297
|
-
{ instance: null, x: cx, z: minZ - home.origin.z, axis: 'z', halfLength: hx, floor: 0 }, { instance: null, x: cx, z: maxZ - home.origin.z, axis: 'z', halfLength: hx, floor: 0 },
|
|
298
|
-
];
|
|
297
|
+
return rimWalls(assembly.pitch).map(wall => ({ instance: null, x: wall.x - home.origin.x, z: wall.z - home.origin.z, axis: wall.axis, halfLength: wall.halfLength, floor: 0 }));
|
|
299
298
|
}
|
|
300
299
|
|
|
301
300
|
type ConstructorPhase = 'fields' | 'lights' | 'home' | 'frame' | 'road' | 'presentation' | 'physics' | 'roots' | 'streaming';
|
|
@@ -676,14 +675,8 @@ export class GridSession {
|
|
|
676
675
|
return cell.edgeLook === undefined ? look : Object.assign(look, { height: cell.edgeLook.height });
|
|
677
676
|
})),
|
|
678
677
|
ports: { closed: (id) => this.live === null || !this.live.live.ready(id) } });
|
|
679
|
-
//
|
|
680
|
-
|
|
681
|
-
this.cellLoading = new CellLoading(screen, (waiting) => {
|
|
682
|
-
const cell = this.neighbours.find(row => row.instance === waiting); if (cell === undefined) return null;
|
|
683
|
-
const centre = { x: cell.origin.x - home.origin.x, z: cell.origin.z - home.origin.z }, world = this.world();
|
|
684
|
-
const edge = facingEdge(neighbourEdges(cell, home), centre, world.x - cell.origin.x, world.z - cell.origin.z);
|
|
685
|
-
return edge === undefined ? null : { edge: { instance: waiting, x: edge.x, z: edge.z, axis: edge.axis, halfLength: edge.halfLength }, cell: centre, ground: edge.floor };
|
|
686
|
-
});
|
|
678
|
+
// QA 2026-11-13: a waiting cell's loading steps on SHARD SELECT's loading card, inset over the live world
|
|
679
|
+
this.cellLoading = new CellLoading(new CellLoadingCard(), (waiting) => this.neighbours.some(row => row.instance === waiting));
|
|
687
680
|
setParkedMatricesFrozen(true); // G580 T2: a hidden parked world skips matrix updates during its warm-up
|
|
688
681
|
host.scope.onDispose(() => { this.cellLoading.close(); if (host.heldFrame !== undefined) host.heldFrame.enabled = false; setWarmUpHeld(false); setParkedMatricesFrozen(false); setBuildHeldTimed(false); });
|
|
689
682
|
// G78: a shimmer line at every shard border on its real ground; G119: SAVING… / SAVE FAILED, RETRY while a crossing waits
|
|
@@ -697,6 +690,8 @@ export class GridSession {
|
|
|
697
690
|
this.constructorTiming?.('presentation');
|
|
698
691
|
const nativeOrigin = { origin: { x: 0, z: 0 } };
|
|
699
692
|
if (preparedRoad?.collidersInstalled !== true) for (const { mesh } of this.strips) installStripCollider(host.physics, mesh, host.scope);
|
|
693
|
+
// SA34: the 7 × 7's empty cells and the band to the rail are walkable void floor at road level, never a fall
|
|
694
|
+
withOwner(host.scope, () => installVoidFloor(host.physics, this.assembly.cells, this.assembly.pitch, false));
|
|
700
695
|
// The normal world stage owns the home's sockets; this scope adds only rebased neighbours.
|
|
701
696
|
installEntrySockets(host.physics, host.scope, this.neighbours.map((cell) => ({ x: cell.origin.x - nativeOrigin.origin.x, z: cell.origin.z - nativeOrigin.origin.z })));
|
|
702
697
|
this.walls = new ReadinessWalls(host.physics, [...this.neighbours.flatMap((cell) => neighbourEdges(cell, nativeOrigin)), ...rimEdges(this.assembly, nativeOrigin)], host.scope);
|
|
@@ -1110,10 +1105,11 @@ export class GridSession {
|
|
|
1110
1105
|
// cells keep their baked proxy without admitting their full product at boot.
|
|
1111
1106
|
if (this.startOuterRoad !== null && this.roadSettled && this.host.backgroundReady?.() !== false) { const start = this.startOuterRoad; this.startOuterRoad = null; start(); }
|
|
1112
1107
|
// DL17 (G872): the cell the player is in, drawn by its regional runtime, admits no second tile copy of itself (the
|
|
1113
|
-
// home re-read ~225 of its files after control for it); leaving starts it while the runtime is still resident
|
|
1108
|
+
// home re-read ~225 of its files after control for it); leaving starts it while the runtime is still resident. A
|
|
1109
|
+
// runtime whose ground is those tiles (D189: Pine) still admits them, or its far proxy stays over the spawn
|
|
1114
1110
|
const drawn = this.live?.runtimeDrawnCell() ?? null;
|
|
1115
1111
|
if (this.initialFarReady && this.host.backgroundReady?.() !== false) for (const cell of this.neighbours) {
|
|
1116
|
-
if (cell.instance === drawn) continue;
|
|
1112
|
+
if (cell.instance === drawn && !admitsCellTiles(cell.instance, drawn, this.clientTiles.owns(cell.instance), findShard(cell.slug)?.cellGround === 'world')) continue;
|
|
1117
1113
|
const distance = Math.hypot(Math.max(0, Math.abs(at.x - cell.origin.x) - CHUNK_HALF), Math.max(0, Math.abs(at.z - cell.origin.z) - CHUNK_HALF));
|
|
1118
1114
|
if (this.assembly.approaching(distance, 400 + Math.min(speed, 60) * 4)) void this.admitNeighbour?.(cell).catch(() => undefined);
|
|
1119
1115
|
}
|
|
@@ -1178,6 +1174,28 @@ export class GridSession {
|
|
|
1178
1174
|
/** Settles once the road system has landed (or failed): the entry's shader warm-up waits for it, so its programs are warmed. */
|
|
1179
1175
|
roadLanded(): Promise<void> { return this.roadLanding; }
|
|
1180
1176
|
|
|
1177
|
+
/** PINE-FLASH (spawnGround.ts): the loader's `spawnDetail` step holds until the entered cell's ground covers its far
|
|
1178
|
+
* proxy (Pine: its ring tiles, admitted now rather than after T10's background opens), or the ceiling. A cell that
|
|
1179
|
+
* draws its own ground, or none drawn by a runtime, holds nothing. */
|
|
1180
|
+
async prepareSpawnGround(limitMs?: number): Promise<SpawnGround> {
|
|
1181
|
+
const live = this.live, render = this.admitNeighbourRender, drawn = live?.runtimeDrawnCell() ?? null;
|
|
1182
|
+
if (live === null || render === undefined || drawn === null) return 'none';
|
|
1183
|
+
const cell = this.assembly.cell(drawn);
|
|
1184
|
+
const instance = spawnGroundCell(drawn, this.clientTiles.owns(drawn), findShard(cell.slug)?.cellGround === 'world');
|
|
1185
|
+
if (instance === null) return 'none';
|
|
1186
|
+
const feet = live.worldFeet(), start = { x: feet.x - cell.origin.x, z: feet.z - cell.origin.z };
|
|
1187
|
+
const owner = this.host.scope.child(`grid.spawn-ground.${instance}`), prepareOffered = this.clientTiles.prepareOffered;
|
|
1188
|
+
try {
|
|
1189
|
+
return await holdSpawnGround({ instance, admit: () => render(cell), require: (id, keys, level) => this.rings.require(id, keys, level),
|
|
1190
|
+
...(prepareOffered === undefined ? {} : { spawn: () => prepareOffered(instance, owner, start) }),
|
|
1191
|
+
pump: entry => stepRingsUntil(entry, { frames: () => this.lateFrames,
|
|
1192
|
+
step: () => { if (!this.host.scope.disposed) { const at = this.world(); this.rings.step({ x: at.x, z: at.z, vx: 0, vz: 0 }); } },
|
|
1193
|
+
wait: () => new Promise<void>(resolve => { if (!this.host.scope.disposed) this.host.scope.timeout(16, resolve); }) }),
|
|
1194
|
+
after: ms => new Promise<void>(resolve => { owner.timeout(ms, resolve); }), ...(limitMs === undefined ? {} : { limitMs }) },
|
|
1195
|
+
requirement => { owner.onDispose(requirement.release); });
|
|
1196
|
+
} finally { owner.dispose(); }
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1181
1199
|
/** Hold the loading screen until every visible neighbour is drawn (or the time limit: the soft walls hold anyway). */
|
|
1182
1200
|
async ready(limitMs = 20_000): Promise<boolean> {
|
|
1183
1201
|
for (let waited = 0; ; waited += 16) {
|
|
@@ -1192,6 +1210,13 @@ export class GridSession {
|
|
|
1192
1210
|
* This runs only the presentation frame; no neighbour tick, input, physics or simulation is advanced. */
|
|
1193
1211
|
prepareFrame(): void { this.frame?.frame(); }
|
|
1194
1212
|
|
|
1213
|
+
/** T2E-1b: the cell the player is in, as the test probe reads it (its shard, door panels and the server's flags there).
|
|
1214
|
+
* Without a live host no region is admitted, so no panel reads solid. */
|
|
1215
|
+
area(): ProbeArea | null {
|
|
1216
|
+
return gridArea({ current: this.live === null ? this.home.instance : this.live.live.current(), cells: this.assembly.cells,
|
|
1217
|
+
targets: id => this.panels.targets(id), flags: id => this.live?.areaFlags(id) ?? [] });
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1195
1220
|
/** The readout: what each cell shows, the rings and the allocator. */
|
|
1196
1221
|
state(): GridSessionState {
|
|
1197
1222
|
const pending = bootWaits();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Mesh, type BufferGeometry, type Object3D } from 'three';
|
|
2
2
|
import { prepareRigLoader } from '@wildshard/engine/anim/rig';
|
|
3
|
+
import { workSlice } from '@wildshard/engine/core/workSlice';
|
|
3
4
|
import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
|
|
4
5
|
import { NEAR_COLOUR, NEAR_LIGHT, nearPlaceholderCost, type NearPlaceholder } from '@wildshard/format/nearPlaceholder';
|
|
5
6
|
import type { Shardfile } from '@wildshard/format/shardSchema';
|
|
@@ -63,16 +64,21 @@ export async function loadShardfileNear(rows: ShardfileNearRows, read: (ref: str
|
|
|
63
64
|
const near = rows.near;
|
|
64
65
|
if (near.content.length === 0) throw new Error('Shardfile declares no near content');
|
|
65
66
|
const cost = nearPlaceholderCost(near, rows.inventory), loader = (await prepareRigLoader()).createRigLoader(), parts: BufferGeometry[] = [], lights: BufferGeometry[] = [], colours: BufferGeometry[] = [];
|
|
67
|
+
// GC36 / RP4: a neighbour's near placeholder loads while the traveller walks to its edge. Baking every mesh's pose in one
|
|
68
|
+
// go held the frame 60 to 170 ms per content file (Chromium, Driftwood to Sunscar); it now lets a frame through between meshes.
|
|
69
|
+
const slice = workSlice();
|
|
66
70
|
try {
|
|
67
71
|
for (const ref of near.content) {
|
|
68
72
|
const gltf = await loader.parseAsync((await read(ref)).slice().buffer, '');
|
|
69
73
|
gltf.scene.updateMatrixWorld(true);
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
const meshes: Mesh[] = [];
|
|
75
|
+
gltf.scene.traverse(node => { if (isMesh(node)) meshes.push(node); });
|
|
76
|
+
for (const node of meshes) {
|
|
77
|
+
await slice.check();
|
|
72
78
|
for (const material of Array.isArray(node.material) ? node.material : [node.material]) material.dispose();
|
|
73
79
|
// NM13: the light layer stays apart from the lit draw (drawn additively, unlit)
|
|
74
80
|
(node.name === NEAR_LIGHT ? lights : node.name === NEAR_COLOUR ? colours : parts).push(node.geometry.applyMatrix4(node.matrixWorld));
|
|
75
|
-
}
|
|
81
|
+
}
|
|
76
82
|
}
|
|
77
83
|
} catch (error) { for (const part of [...parts, ...lights, ...colours]) part.dispose(); throw error; }
|
|
78
84
|
const [first] = parts;
|