@wildshard/engine 0.1.19 → 0.1.21
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 +16 -0
- package/lint/engine-sides.json +5 -0
- package/package.json +5 -2
- package/scripts/app-build/gen.ts +11 -0
- package/scripts/cell-mem-bench.mjs +2 -0
- package/scripts/chaos-proxy-core.mjs +14 -1
- package/scripts/chaos-proxy-proof.mjs +22 -0
- package/scripts/check-devserver.mjs +1 -1
- package/scripts/failmode-cases.d.mts +8 -0
- package/scripts/failmode-cases.mjs +97 -0
- package/scripts/failmode-proof.mjs +532 -0
- package/scripts/grid-crossing-nightly.mjs +5 -4
- package/scripts/grid-crossing-report.mjs +5 -2
- package/scripts/grid-crossing-tour.mjs +36 -12
- package/scripts/grid-crossing-walk-proof.mjs +4 -2
- package/scripts/hover-speed-probe.mjs +136 -0
- package/scripts/land.mjs +2 -1
- package/scripts/loading-flow/benchmax.mjs +34 -11
- package/scripts/loading-flow/deskbench.mjs +276 -0
- package/scripts/loading-flow/stalls.d.mts +17 -3
- package/scripts/loading-flow/stalls.mjs +82 -3
- package/scripts/net-lag-proof.mjs +3 -2
- package/scripts/nightly-model.ts +9 -6
- package/scripts/offline-proof.mjs +7 -1
- package/scripts/online-rig.mjs +9 -7
- package/scripts/parity/boot-smoke.mjs +13 -2
- package/scripts/pin-format.ts +5 -2
- package/scripts/pins-reuse.d.mts +1 -0
- package/scripts/pins-reuse.mjs +22 -0
- package/scripts/release-cook.mjs +109 -0
- package/scripts/scratch-dir.mjs +95 -0
- package/scripts/scratch-sweep.mjs +182 -0
- package/scripts/tsconfig.json +2 -12
- package/scripts/vps/harden-prometheus.sh +3 -0
- package/scripts/vps/rebuild.sh +35 -9
- package/scripts/vps/wildshard-apply.mjs +5 -1
- package/scripts/vps/wildshard-config +117 -1
- package/scripts/worktree-reap.mjs +54 -8
- package/scripts/worktree.mjs +19 -5
- package/src/client/engine/anim/rigParser.ts +2 -2
- package/src/client/engine/boot/contentRead.ts +54 -5
- package/src/client/engine/boot/gpuFiles.ts +3 -3
- package/src/client/engine/boot/leaveAfterPaint.ts +4 -1
- package/src/client/engine/core/Game.ts +63 -19
- package/src/client/engine/core/gpuOnly.ts +10 -0
- package/src/client/engine/core/renderBudget.ts +134 -0
- package/src/client/engine/core/shadowLayer.ts +18 -0
- package/src/client/engine/explore/pick.ts +13 -1
- package/src/client/engine/net/predictor.ts +12 -4
- package/src/client/engine/net/redial.ts +40 -5
- package/src/client/engine/player/TouchControls.ts +3 -2
- package/src/client/engine/render/dataLook.ts +70 -7
- package/src/client/engine/render/families/pbr.ts +2 -0
- package/src/client/engine/render/families/registry.ts +11 -2
- package/src/client/engine/render/families/sceneSurface.ts +118 -0
- package/src/client/engine/render/look.ts +7 -1
- package/src/client/engine/render/precompile.ts +4 -2
- package/src/client/engine/render/tiers.ts +4 -1
- package/src/client/engine/telemetry/browserErrors.ts +3 -1
- package/src/client/engine/ui/ErrorModal.ts +1 -1
- package/src/client/engine/ui/Loading.ts +14 -2
- package/src/client/engine/ui/errorScreen.ts +51 -9
- package/src/client/engine/ui/hoverBoost.ts +31 -4
- package/src/client/engine/ui/styles/touch.css +6 -0
- package/src/client/engine/world/declaredProps.ts +5 -1
- package/src/client/engine/world/skyRig.ts +4 -1
- package/src/client/engine/world/terrainTileView.ts +64 -23
- package/src/client/game/boot/spawnDownload.ts +44 -6
- package/src/client/game/devScene/hook.ts +149 -12
- package/src/client/game/devScene/liveLook.ts +21 -0
- package/src/client/game/grid/live.ts +47 -10
- package/src/client/game/grid/liveSession.ts +25 -6
- package/src/client/game/grid/pageEntry.ts +12 -1
- package/src/client/game/grid/productInputs.ts +22 -11
- package/src/client/game/grid/session.ts +15 -4
- package/src/client/game/grid/shardfileFar.ts +13 -2
- package/src/client/game/session/finish.ts +4 -1
- package/src/client/game/shardfile/client.ts +24 -7
- package/src/client/game/shardfile/clientPropMaterials.ts +4 -1
- package/src/client/game/shardfile/clientSource.ts +7 -3
- package/src/client/game/shardfile/clientViews.ts +36 -8
- package/src/client/game/shardfile/clientWorker.ts +4 -4
- package/src/client/game/shardfile/constructionCheckpoint.ts +2 -2
- package/src/client/game/shardfile/groundMerge.ts +59 -5
- package/src/client/game/shardfile/hybrid.ts +2 -0
- package/src/client/game/shardfile/look.ts +1 -1
- package/src/client/game/shardfile/slabLibrary.ts +115 -49
- package/src/client/game/shardfile/tileContent.ts +1 -1
- package/src/client/game/shardfile/tileDriver.ts +38 -11
- package/src/client/game/shardfile/wirePage.ts +7 -3
- package/src/client/game/shardfile/worldScenes.ts +17 -10
- package/src/client/host/online/doctor.ts +20 -7
- package/src/client/host/online/doctorView.ts +2 -0
- package/src/client/host/online/linkScreens.ts +95 -11
- package/src/client/host/online/reconnectStrip.ts +3 -2
- package/src/client/host/online/release.ts +87 -16
- package/src/client/host/online/releaseScreens.ts +108 -0
- package/src/client/host/online/shell.ts +24 -5
- package/src/client/host/online/voice.ts +45 -1
- package/src/client/host/online/voiceUi.ts +24 -6
- package/src/client/host/standalone/shell.ts +37 -1
- package/src/server/engine/sim/playerSim.ts +1 -1
- package/src/server/game/grid/simulation.ts +12 -6
- package/src/server/game/quest/eliteDrops.ts +7 -3
- package/src/server/game/riding/nativeTaming.ts +13 -2
- package/src/server/host/dedicated/cellHost.ts +21 -2
- package/src/server/host/dedicated/cellProtocol.ts +2 -0
- package/src/server/host/dedicated/cellWorker.ts +1 -1
- package/src/server/host/dedicated/dedicatedRoom.ts +38 -8
- package/src/server/host/dedicated/roadRoom.ts +3 -0
- package/src/server/host/dedicated/serverMetrics.ts +9 -0
- package/src/server/host/dedicated/workerTable.ts +31 -24
- package/src/server/host/standalone/gridServer.ts +1 -1
- package/src/server/host/standalone/serverHost.ts +56 -10
- package/src/server/host/standalone/serverProduct.ts +9 -7
- package/src/server/host/standalone/serverRuntime.ts +1 -1
- package/src/shared/engine/boot/loadingWaits.ts +10 -2
- package/src/shared/engine/core/config.ts +3 -0
- package/src/shared/engine/core/framePacing.ts +12 -1
- package/src/shared/engine/physics/terrainTiles.ts +20 -4
- package/src/shared/engine/player/hoverSpeed.ts +3 -3
- package/src/shared/engine/strings.ts +12 -1
- package/src/shared/game/devColliders.ts +60 -0
- package/src/shared/game/devGameplay.ts +41 -0
- package/src/shared/game/grid/rules.ts +12 -0
|
@@ -90,7 +90,7 @@ export interface LiveGridPorts {
|
|
|
90
90
|
export interface LiveGridState {
|
|
91
91
|
current: string | null; worldFeet: GridPoint; crossings: number;
|
|
92
92
|
/** GC5: the world built ahead of the traveller (on the road or pre-warmed inside the source), and how many pre-warms began */
|
|
93
|
-
ahead?: { readonly instance: string | null; readonly warms: number; readonly refused?: string | null };
|
|
93
|
+
ahead?: { readonly instance: string | null; readonly warms: number; readonly refused?: string | null; readonly deferred?: readonly string[]; readonly demanded?: string | null; readonly released?: number };
|
|
94
94
|
/** Last complete world remains fully charged and pressure-evictable on the road. */
|
|
95
95
|
retainedCell?: { readonly instance: string; readonly remainingMs: number; readonly playingBytes: number; readonly capBytes: number } | null;
|
|
96
96
|
transitions: readonly { from: string | null; to: string | null }[];
|
|
@@ -176,6 +176,9 @@ export class LiveGridHost {
|
|
|
176
176
|
private readonly productRequests = new Map<string, { work: Promise<LiveGridAdmission>; required: boolean;
|
|
177
177
|
trigger: 'entry' | 'explicit' | 'radial' | 'boulevard' }>();
|
|
178
178
|
private readonly deferredProducts = new Map<string, number>();
|
|
179
|
+
/** GC6: a demand read (the neighbour ahead) the budget refused, by allocator revision: kept apart from the radial reads'
|
|
180
|
+
* deferrals, since a radial read deferred for want of headroom must not stop the demand read that may make room */
|
|
181
|
+
private readonly deferredDemand = new Map<string, number>();
|
|
179
182
|
private readonly issues = new Map<string, string>();
|
|
180
183
|
private readonly refusals = new Map<string, unknown>();
|
|
181
184
|
/** One failed cold unload per excursion; quota failures retain their full claim until retry or re-approach. */
|
|
@@ -191,6 +194,9 @@ export class LiveGridHost {
|
|
|
191
194
|
private turnedSince: { instance: string; at: number } | null = null;
|
|
192
195
|
/** GC5: why the last pre-warm the heading asked for did not start (its product still reading, an exclusive runtime, or the budget) */
|
|
193
196
|
private warmRefusal: string | null = null;
|
|
197
|
+
/** GC6: the neighbour whose product is read as demand (the nearest edge's, or the heading's) and not yet admitted: radial
|
|
198
|
+
* reads of other cells wait while it is missing, so they don't take back the headroom its read needs. */
|
|
199
|
+
private demanded: string | null = null;
|
|
194
200
|
private previousFeet: GridPoint | undefined;
|
|
195
201
|
/** fixed steps since `previousFeet` moved, for the traveller's speed (GC5) */
|
|
196
202
|
private stepsSincePrevious = 0;
|
|
@@ -289,12 +295,16 @@ export class LiveGridHost {
|
|
|
289
295
|
if ((bundle.hybridWireBytes > 0 || admission.exclusiveRuntime === true) && admission.prepareRuntime === undefined) throw new Error('Hybrid runtime admission is missing');
|
|
290
296
|
await (timing === undefined ? admission.prepareRuntime?.() : timing.run('runtime', async () => { await admitted.prepareRuntime?.(); }));
|
|
291
297
|
this.assertAlive();
|
|
292
|
-
this.deferredProducts.delete(instance); this.products.set(instance, admission); return admission;
|
|
298
|
+
this.deferredProducts.delete(instance); this.deferredDemand.delete(instance); this.products.set(instance, admission); return admission;
|
|
293
299
|
} catch (error) {
|
|
294
300
|
this.tileMetadata.delete(instance);
|
|
295
301
|
if (this.tileApproach?.instance === instance) { this.tileApproach.controller.abort(); this.tileApproach = null; }
|
|
296
302
|
const refused = error instanceof ApproachInputsDeferredError || (error instanceof Error && error.message.includes(PRODUCT_DEFERRED));
|
|
297
|
-
|
|
303
|
+
// GC6 (QA 11-14 row 6): inside Driftwood the page held 3 to 5 neighbours' radial products (1199 of 1200 MB), pinned
|
|
304
|
+
// while held, so Nalati's demand read was refused the whole approach and its world was built only on the road. A
|
|
305
|
+
// refused demand read lets the speculative products of other cells go, farthest first, and is read again.
|
|
306
|
+
if (required && speculative && refused) { if (this.releaseSpeculative(instance) > 0) this.deferredDemand.delete(instance); else { this.deferredDemand.set(instance, this.ports.allocator.revision); if (this.demanded === instance) this.demanded = null; } }
|
|
307
|
+
else if (!required && refused) this.deferredProducts.set(instance, this.ports.allocator.revision);
|
|
298
308
|
else { this.issues.set(instance, error instanceof Error ? error.message : String(error)); this.refusals.set(instance, error); }
|
|
299
309
|
try { admission?.cancel?.(); }
|
|
300
310
|
catch (cleanup) { throw new AggregateError([error, cleanup], 'Live product admission and cancellation failed', { cause: cleanup }); }
|
|
@@ -303,6 +313,23 @@ export class LiveGridHost {
|
|
|
303
313
|
})();
|
|
304
314
|
this.productRequests.set(instance, { work: request, required, trigger }); return request;
|
|
305
315
|
}
|
|
316
|
+
/** GC6: let every admitted product nobody builds, enters or reads ahead go except `kept`'s, farthest first (each releases
|
|
317
|
+
* its claim, so the allocator's revision moves and a deferred demand read is tried again). Returns how many went. */
|
|
318
|
+
private releaseSpeculative(kept: string): number {
|
|
319
|
+
const feet = this.worldFeet(), keep = (id: string): boolean => id === kept || id === this.active || id === this.ahead
|
|
320
|
+
|| this.constructing.has(id) || this.requests.has(id) || this.residents.has(id)
|
|
321
|
+
|| id === this.tileApproach?.instance || id === this.transportApproach?.instance;
|
|
322
|
+
const idle = [...this.products.keys()].filter(id => !keep(id))
|
|
323
|
+
.sort((a, b) => this.distance(this.assembly.cell(b), feet) - this.distance(this.assembly.cell(a), feet));
|
|
324
|
+
for (const id of idle) {
|
|
325
|
+
const admission = this.products.get(id); this.products.delete(id); this.tileMetadata.delete(id);
|
|
326
|
+
try { admission?.cancel?.(); } catch (error) { console.warn(`[grid] ${id}: releasing a speculative product`, error); }
|
|
327
|
+
}
|
|
328
|
+
this.released += idle.length;
|
|
329
|
+
return idle.length;
|
|
330
|
+
}
|
|
331
|
+
/** GC6: how many speculative products a demand read let go (`releaseSpeculative`), for the tour */
|
|
332
|
+
private released = 0;
|
|
306
333
|
/** GC5 / GC36: the cell whose world the road is building or built ahead of its line (`buildAhead`), kept until the
|
|
307
334
|
* traveller enters a cell or heads into another's mouth. */
|
|
308
335
|
private ahead: string | null = null;
|
|
@@ -439,7 +466,7 @@ export class LiveGridHost {
|
|
|
439
466
|
}
|
|
440
467
|
private retainedFits(instance: string): boolean {
|
|
441
468
|
const policy = this.ports.lastCell;
|
|
442
|
-
return policy !== undefined && this.ports.allocator.ownerCost(instance).playing <= Math.min(
|
|
469
|
+
return policy !== undefined && this.ports.allocator.ownerCost(instance).playing <= Math.min(this.ports.allocator.envelope(), policy.playingBytes);
|
|
443
470
|
}
|
|
444
471
|
/** Call only after entered leave hooks finish. Keep the same ready world,
|
|
445
472
|
* without a second claim, snapshot, physics host or shader preparation. */
|
|
@@ -507,10 +534,13 @@ export class LiveGridHost {
|
|
|
507
534
|
}
|
|
508
535
|
return released;
|
|
509
536
|
}
|
|
537
|
+
/** GC6: whether a world is being built (pre-warmed inside the source, built ahead on the road, or entered): every world build
|
|
538
|
+
* is for a cell the traveller heads into, so its slices are urgent (`setBuildUrgent`). */
|
|
539
|
+
building(): boolean { return this.requests.size > 0; }
|
|
510
540
|
/** Retry after a durability/budget change, instead of fetching the same failed request every tick. */
|
|
511
541
|
retry(instance: string): void {
|
|
512
542
|
if (this.requests.has(instance) || this.productRequests.has(instance)) throw new Error('Live admission is still pending');
|
|
513
|
-
this.coldUnloadRefused.delete(instance); this.deferredProducts.delete(instance);
|
|
543
|
+
this.coldUnloadRefused.delete(instance); this.deferredProducts.delete(instance); this.deferredDemand.delete(instance);
|
|
514
544
|
// A quota-refused unload kept a complete native region: retry must not invalidate its valid readiness ticket.
|
|
515
545
|
if (this.residents.has(instance)) return;
|
|
516
546
|
this.issues.delete(instance); this.refusals.delete(instance); this.readiness.invalidate(instance);
|
|
@@ -552,8 +582,13 @@ export class LiveGridHost {
|
|
|
552
582
|
if (this.active !== null && this.ahead !== null && (this.ahead === this.active
|
|
553
583
|
|| this.distance(this.assembly.cell(this.ahead), feet) > WARM_KEEP_METRES)) this.ahead = null;
|
|
554
584
|
this.retireInactiveRegions();
|
|
585
|
+
// GC6: the demanded neighbour stays demanded until its product is in, it is entered, or the traveller is far from it
|
|
586
|
+
const demanded = this.demanded;
|
|
587
|
+
if (demanded !== null && (this.products.has(demanded) || this.residents.has(demanded) || demanded === this.active || this.issues.has(demanded)
|
|
588
|
+
|| this.distance(this.assembly.cell(demanded), feet) > DEMAND_METRES + WARM_LEAD_METRES * 4)) this.demanded = null;
|
|
555
589
|
for (const cell of nearby) {
|
|
556
590
|
const estimate = readinessModel(this.ports.readiness.bundle(cell), this.ports.readiness.link), distance = this.distance(cell, feet);
|
|
591
|
+
if (this.demanded !== null && this.demanded !== cell.instance) continue;
|
|
557
592
|
if (this.assembly.approaching(distance, estimate.distance) && !this.issues.has(cell.instance) && this.ports.backgroundReady?.() !== false) void background(cell.instance, this.prefetch([cell.instance], 'radial'), () => !this.disposed);
|
|
558
593
|
}
|
|
559
594
|
// GC5: the neighbour across the source's nearest edge, within DEMAND_METRES, has its product read as demand, standing or
|
|
@@ -566,8 +601,9 @@ export class LiveGridHost {
|
|
|
566
601
|
const pending = near === undefined ? undefined : this.productRequests.get(near.instance);
|
|
567
602
|
if (near !== undefined && this.distance(near, feet) <= DEMAND_METRES && !this.products.has(near.instance) && !this.residents.has(near.instance)
|
|
568
603
|
&& (pending === undefined || !pending.required && this.raised !== pending.work) && !this.issues.has(near.instance) && !this.constructing.has(near.instance)
|
|
569
|
-
&& this.
|
|
604
|
+
&& this.deferredDemand.get(near.instance) !== this.ports.allocator.revision && this.ports.backgroundReady?.() !== false) {
|
|
570
605
|
if (pending !== undefined) this.raised = pending.work;
|
|
606
|
+
this.demanded = near.instance;
|
|
571
607
|
void background(near.instance, this.prefetchProduct(near.instance, true, 'explicit', true), () => !this.disposed);
|
|
572
608
|
}
|
|
573
609
|
}
|
|
@@ -669,7 +705,8 @@ export class LiveGridHost {
|
|
|
669
705
|
// guess, which the shared budget declines while the page's other neighbours compete for the same headroom.
|
|
670
706
|
if (product === undefined) {
|
|
671
707
|
this.warmRefusal = 'product';
|
|
672
|
-
|
|
708
|
+
this.demanded = moving.instance;
|
|
709
|
+
if (!this.productRequests.has(moving.instance) && this.deferredDemand.get(moving.instance) !== this.ports.allocator.revision)
|
|
673
710
|
void background(moving.instance, this.prefetchProduct(moving.instance, true, 'explicit', true), () => !this.disposed);
|
|
674
711
|
}
|
|
675
712
|
else if (product.isolatedPreparation !== true) this.warmRefusal = 'exclusive';
|
|
@@ -860,10 +897,10 @@ export class LiveGridHost {
|
|
|
860
897
|
private retainedState(): Exclude<LiveGridState['retainedCell'], undefined> {
|
|
861
898
|
const last = this.lastCell, policy = this.ports.lastCell;
|
|
862
899
|
return last === null || policy === undefined ? null : { instance: last.instance, remainingMs: Math.max(0, last.until - diagnosticNow()),
|
|
863
|
-
playingBytes: this.ports.allocator.ownerCost(last.instance).playing, capBytes: Math.min(
|
|
900
|
+
playingBytes: this.ports.allocator.ownerCost(last.instance).playing, capBytes: Math.min(this.ports.allocator.envelope(), policy.playingBytes) };
|
|
864
901
|
}
|
|
865
902
|
/** Read-only crossing evidence and failures for the real grid physics harness. */
|
|
866
|
-
state(): LiveGridState { return { current: this.active, worldFeet: this.worldFeet(), crossings: this.crossings, ahead: { instance: this.ahead, warms: this.warms, refused: this.warmRefusal }, transitions: this.transitions.map((row) => ({ ...row })), residents: [...this.residents.keys()].sort(), pending: [...new Set([...this.requests.keys(), ...this.productRequests.keys()])].sort(), pendingWork: [
|
|
903
|
+
state(): LiveGridState { return { current: this.active, worldFeet: this.worldFeet(), crossings: this.crossings, ahead: { instance: this.ahead, warms: this.warms, refused: this.warmRefusal, deferred: [...new Set([...this.deferredProducts.keys(), ...this.deferredDemand.keys()])], demanded: this.demanded, released: this.released }, transitions: this.transitions.map((row) => ({ ...row })), residents: [...this.residents.keys()].sort(), pending: [...new Set([...this.requests.keys(), ...this.productRequests.keys()])].sort(), pendingWork: [
|
|
867
904
|
...[...this.requests.keys()].sort().map(instance => ({ instance, kind: 'world' as const, trigger: 'entry' as const })),
|
|
868
905
|
...[...this.productRequests].sort(([a], [b]) => a.localeCompare(b)).map(([instance, request]) => ({ instance, kind: request.required ? 'required-metadata' as const : 'optional-metadata' as const, trigger: request.trigger })),
|
|
869
906
|
], issues: Object.fromEntries(this.issues), gameplayReady: this.active === null || this.ports.gameplayReady(this.active), ...(this.ports.lastCell === undefined ? {} : { retainedCell: this.retainedState() }), retirements: this.retirements.map(row => ({ ...row })), retiring: [...this.retiring.keys()], ghosts: { count: this.ghosts.count(), regions: this.ghosts.regions() } }; }
|
|
@@ -903,7 +940,7 @@ export class LiveGridHost {
|
|
|
903
940
|
try { this.highway.dispose(); this.highwayDisposed = true; this.highwayLease.release(); }
|
|
904
941
|
catch (error) { failures.push(error); }
|
|
905
942
|
}
|
|
906
|
-
this.deferredProducts.clear();
|
|
943
|
+
this.deferredProducts.clear(); this.deferredDemand.clear();
|
|
907
944
|
if (failures.length > 0) throw new AggregateError(failures, 'Live grid disposal failed');
|
|
908
945
|
}
|
|
909
946
|
}
|
|
@@ -27,7 +27,7 @@ import { Vector3, type PerspectiveCamera } from 'three';
|
|
|
27
27
|
import { createProgramKeeper, RETAINED_PROGRAM_BYTES, RETAINED_PROGRAM_LIMIT, type ProgramKeeper } from '@wildshard/engine/render/programRetention';
|
|
28
28
|
import { diagnosticNow } from '@wildshard/engine/core/clock';
|
|
29
29
|
import { WORK_SLICE_MS, workSlice } from '@wildshard/engine/core/workSlice';
|
|
30
|
-
import { CHUNK_HALF,
|
|
30
|
+
import { CHUNK_HALF, ENTRY_ASPHALT } from '@wildshard/engine/core/config';
|
|
31
31
|
import type { DisposeStep, Scope } from '@wildshard/engine/app/scope';
|
|
32
32
|
import type { Events } from '@wildshard/engine/events/events';
|
|
33
33
|
import type { Physics } from '@wildshard/engine/physics/Physics';
|
|
@@ -293,7 +293,7 @@ export class LiveGridSession {
|
|
|
293
293
|
const highwayBytes = (ports.initialStripBytes ?? ports.strips.reduce((sum, strip) => sum + strip.mesh.positions.byteLength + strip.mesh.indices.byteLength, 0))
|
|
294
294
|
+ assembly.cells.length * TRANSFER_WALL_BYTES;
|
|
295
295
|
try { this.live = new LiveGridHost(assembly, {
|
|
296
|
-
lastCell: { windowMs: 30_000, playingBytes:
|
|
296
|
+
lastCell: { windowMs: 30_000, playingBytes: ports.allocator.envelope(), schedule: (expire, ms) => {
|
|
297
297
|
const timer = scope.child('grid.last-cell-expiry');
|
|
298
298
|
timer.timeout(ms, () => { timer.dispose(); scope.run(expire); });
|
|
299
299
|
return () => { timer.dispose(); };
|
|
@@ -398,7 +398,7 @@ export class LiveGridSession {
|
|
|
398
398
|
|
|
399
399
|
private installCrossing(): GridCrossingSession {
|
|
400
400
|
return installGridCrossing({ current: () => this.live.current(), prepare: (from, to) => this.prepareCrossing(from, to),
|
|
401
|
-
ready: (instance) => this.live.ready(instance), checkpoint: (instance) => {
|
|
401
|
+
ready: (instance) => this.live.ready(instance) && (instance === null || !this.entryPending(instance)), checkpoint: (instance) => {
|
|
402
402
|
if (this.wire !== null) return true; // the server's saves are the session's
|
|
403
403
|
const readiness = this.page.crossingSaveReady?.(instance) ?? true;
|
|
404
404
|
return readiness === true ? this.live.checkpoint(instance) : readiness;
|
|
@@ -870,8 +870,16 @@ export class LiveGridSession {
|
|
|
870
870
|
const current = this.live.current();
|
|
871
871
|
return current !== null && this.runtimeRegions.has(current) ? current : null;
|
|
872
872
|
}
|
|
873
|
+
/** GC6 (QA 11-14 row 6): a world built ahead whose entry still prepares (deferred inside the source, or running on the
|
|
874
|
+
* road). Inside the cell its gameplay gate (`frameReady`) stops the page's frames, and that preparation's warm-up waits on
|
|
875
|
+
* drawn frames: the traveller stood in the cell with no control for good. Its crossing holds on the road instead. */
|
|
876
|
+
entryPending(instance: string): boolean { return this.deferredEntries.has(instance) || this.queuedEntries.has(instance) || this.hybrid.preparing().includes(instance); }
|
|
877
|
+
/** GC6: whether any world built ahead still prepares its entry (the road then builds with the urgent budget) */
|
|
878
|
+
entriesPending(): boolean { return this.deferredEntries.size > 0 || this.queuedEntries.size > 0 || this.hybrid.preparing().length > 0; }
|
|
879
|
+
/** GC6: entries taken from `deferredEntries` and waiting their turn behind another's preparation (`prepareInTurn`) */
|
|
880
|
+
private readonly queuedEntries = new Set<string>();
|
|
873
881
|
/** GC9: once the source is left (the hybrid session is neutral), each world pre-warmed inside it prepares its entry, so the
|
|
874
|
-
* crossing finds it ready;
|
|
882
|
+
* crossing finds it ready; a crossing that arrives first holds on the road until it is (`entryPending`, GC6). */
|
|
875
883
|
private prepareDeferredEntries(): void {
|
|
876
884
|
// one at a time, nearest first: an entry preparation binds the page's one construction environment
|
|
877
885
|
const feet = this.live.worldFeet(), gap = (instance: string): number => {
|
|
@@ -879,6 +887,7 @@ export class LiveGridSession {
|
|
|
879
887
|
};
|
|
880
888
|
const rows = [...this.deferredEntries].sort(([a], [b]) => gap(a) - gap(b));
|
|
881
889
|
this.deferredEntries.clear();
|
|
890
|
+
for (const [instance] of rows) this.queuedEntries.add(instance);
|
|
882
891
|
this.deferredPreparation = this.prepareInTurn(this.deferredPreparation, rows);
|
|
883
892
|
}
|
|
884
893
|
private async prepareInTurn(previous: Promise<void>, rows: readonly (readonly [string, { readonly prepared: PreparedRegionalRuntime; readonly signal: AbortSignal | undefined }])[]): Promise<void> {
|
|
@@ -888,15 +897,25 @@ export class LiveGridSession {
|
|
|
888
897
|
private deferredPreparation: Promise<void> = Promise.resolve();
|
|
889
898
|
private async prepareEntryOnRoad(instance: string, row: { readonly prepared: PreparedRegionalRuntime; readonly signal: AbortSignal | undefined }): Promise<void> {
|
|
890
899
|
const live = (): boolean => this.runtimeRegions.get(instance) === row.prepared && row.signal?.aborted !== true;
|
|
891
|
-
|
|
900
|
+
// prepareEntry registers its installation synchronously, so the entry stays pending across this hand-over
|
|
901
|
+
this.queuedEntries.delete(instance);
|
|
902
|
+
const entered = (): boolean => this.hybrid.state().instance === instance;
|
|
903
|
+
if (!live() || this.hybrid.state().instance !== null) { if (live() && !entered()) this.deferredEntries.set(instance, row); return; }
|
|
892
904
|
let prepared = false;
|
|
893
905
|
try { prepared = await this.hybrid.prepareEntry(instance, row.signal); }
|
|
894
906
|
catch (error) { console.warn(`[grid] ${instance}: entry preparation on the road`, error); }
|
|
895
907
|
// a turn back into the source meanwhile (its entry made the session active) waits for the next leave
|
|
896
|
-
if (!prepared && live() && this.hybrid.state().instance !== null) this.deferredEntries.set(instance, row);
|
|
908
|
+
if (!prepared && live() && this.hybrid.state().instance !== null && !entered()) this.deferredEntries.set(instance, row);
|
|
897
909
|
}
|
|
898
910
|
/** G555: the entered runtime hooks' timings (the one running and those finished), for the cell loading screen. */
|
|
899
911
|
hookTimings(): ReturnType<HybridRuntimeSession['timings']> { return this.hybrid.timings(); }
|
|
912
|
+
/** GC6: the entered runtime, whether its hooks finished, the hook running, the last finished, and the entries preparing */
|
|
913
|
+
hybridState(): { readonly instance: string | null; readonly ready: boolean; readonly hook: string | null; readonly last: string | null; readonly preparing: readonly string[]; readonly deferred: readonly string[]; readonly warm: readonly string[] } {
|
|
914
|
+
const state = this.hybrid.state(), timings = this.hybrid.timings(), last = timings.completed.at(-1);
|
|
915
|
+
return { ...state, hook: timings.current === null ? null : `${timings.current.instance}:${timings.current.hook}`,
|
|
916
|
+
last: last === undefined ? null : `${last.instance}:${last.hook}:${last.outcome}`, preparing: this.hybrid.preparing(), deferred: [...this.deferredEntries.keys()],
|
|
917
|
+
warm: this.hybrid.preparing().map(id => { const w = this.warmPreparation(id); return w === null ? `${id}:-` : `${id}:${w.phase}:${w.completed ? 'done' : w.progress?.detail ?? ''}`; }) };
|
|
918
|
+
}
|
|
900
919
|
/** GC2: the server still has this client in `instance` (an online cell is still walled, C5). */
|
|
901
920
|
serverHolds(instance: string): boolean { return this.wire !== null && this.wire.site() === instance; }
|
|
902
921
|
|
|
@@ -140,6 +140,17 @@ export function enterGrid(): void {
|
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
|
|
143
|
+
/** The grid page's address: its path, and only the harness flags skipintro, mute and nolock, none of which selects a level, and `skipintro` dropped here sent a
|
|
144
|
+
* `?chunk=<slug>&skipintro` link on a world build back under the title (OFFLINE OF18: every Open Plot in the offline proof). */
|
|
145
|
+
export function gridPageUrl(href: string): URL {
|
|
146
|
+
const from = new URL(href).searchParams, to = new URL(new URL(href).pathname, new URL(href).origin);
|
|
147
|
+
const skipintro = from.get('skipintro'), mute = from.get('mute'), nolock = from.get('nolock');
|
|
148
|
+
if (skipintro !== null) to.searchParams.set('skipintro', skipintro);
|
|
149
|
+
if (mute !== null) to.searchParams.set('mute', mute);
|
|
150
|
+
if (nolock !== null) to.searchParams.set('nolock', nolock);
|
|
151
|
+
return to;
|
|
152
|
+
}
|
|
153
|
+
|
|
143
154
|
/** The boot's one read of the tap intent (used or not), overridden by validated recovery before ordinary admission.
|
|
144
155
|
* In grid mode the address becomes the bare title URL, preventing an unrecorded automatic restart. */
|
|
145
156
|
export function bootPageMode(slug: string): PageMode {
|
|
@@ -172,7 +183,7 @@ export function bootPageMode(slug: string): PageMode {
|
|
|
172
183
|
registerBeforeReload(pageScope, reason => gridRecovery(saves).write(assembly, home, road, reason === 'settings' ? 'reload' : reason)); // SR12: a Settings reload continues play
|
|
173
184
|
}
|
|
174
185
|
if (mode === 'grid' && typeof history !== 'undefined') {
|
|
175
|
-
try { history.replaceState(history.state, '',
|
|
186
|
+
try { history.replaceState(history.state, '', gridPageUrl(location.href)); } catch { /* a sandboxed frame: the URL stays */ }
|
|
176
187
|
}
|
|
177
188
|
return mode;
|
|
178
189
|
}
|
|
@@ -10,6 +10,22 @@ export class ApproachInputsDeferredError extends Error {
|
|
|
10
10
|
constructor() { super('Product input residency admission deferred'); this.name = 'ApproachInputsDeferredError'; }
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/** GC6: reads in flight for a world's input read-back, and for a cancellable approach's. */
|
|
14
|
+
export const INPUT_READS = 16, APPROACH_INPUT_READS = 12;
|
|
15
|
+
/** Run `read` over `refs` with at most `width` in flight; the first failure stops new reads, waits for those in flight and
|
|
16
|
+
* throws. `active` is checked before each new read (it throws on cancellation). */
|
|
17
|
+
export async function readWindow(refs: readonly string[], width: number, active: () => void, read: (ref: string) => Promise<void>): Promise<void> {
|
|
18
|
+
let next = 0, failure: { readonly error: unknown } | undefined;
|
|
19
|
+
const lane = async (): Promise<void> => {
|
|
20
|
+
while (failure === undefined && next < refs.length) {
|
|
21
|
+
const ref = refs[next++]; if (ref === undefined) return;
|
|
22
|
+
try { active(); await read(ref); } catch (error) { failure ??= { error }; }
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
await Promise.all(Array.from({ length: Math.min(width, refs.length) }, lane));
|
|
26
|
+
if (failure !== undefined) throw failure.error;
|
|
27
|
+
}
|
|
28
|
+
|
|
13
29
|
/** One admitted grid product's transient inputs, shared by overlapping preparations, never by finished promises. */
|
|
14
30
|
export class ProductInputs {
|
|
15
31
|
readonly reader: ClientAssets;
|
|
@@ -73,17 +89,12 @@ export class ProductInputs {
|
|
|
73
89
|
const lease = this.reserve(bytes, signal !== undefined), loaded = new Map<string, Uint8Array>();
|
|
74
90
|
try {
|
|
75
91
|
// GC9: a cell's world reads its inputs back from the cache before it builds (Pine: about 1,500 files); one at a time
|
|
76
|
-
// that read was most of the build behind a moving player's loading wall.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (result.status === 'rejected') throw result.reason;
|
|
83
|
-
const ref = batch[index]; if (ref === undefined) throw new Error('Missing approach transport identity');
|
|
84
|
-
loaded.set(ref, result.value);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
92
|
+
// that read was most of the build behind a moving player's loading wall.
|
|
93
|
+
// GC6 (QA 11-14 row 6): each read is a cache round trip that waits on drawn frames, so it is latency-bound, not
|
|
94
|
+
// byte-bound: Nalati's ~860 inputs in lockstep batches of four took 20 s of its world's 30 s at Jake's 2992x1434@2.
|
|
95
|
+
// A sliding window keeps INPUT_READS (a cancellable approach APPROACH_INPUT_READS) in flight; the bytes held are
|
|
96
|
+
// the same (all of them are kept, and the lease above already charges them).
|
|
97
|
+
await readWindow(missing, signal === undefined ? INPUT_READS : APPROACH_INPUT_READS, active, async ref => { loaded.set(ref, await this.reader.read(ref)); });
|
|
87
98
|
active();
|
|
88
99
|
for (const [ref, value] of loaded) this.assets.set(ref, value);
|
|
89
100
|
this.claims.push({ refs: new Set(missing), bytes, lease });
|
|
@@ -98,6 +98,7 @@ import { clientTileViews, type ClientTileViews } from '../shardfile/clientViews'
|
|
|
98
98
|
import type { ClientSkin } from '../shardfile/clientSkins';
|
|
99
99
|
import { setParkedMatricesFrozen, setWarmUpHeld } from '@wildshard/engine/render/precompile';
|
|
100
100
|
import { setBuildHeldTimed } from '@wildshard/engine/core/heldTiming';
|
|
101
|
+
import { setBuildUrgent } from '@wildshard/engine/core/framePacing';
|
|
101
102
|
import { NeighbourLife, type NeighbourLifeCell } from './neighbourLife';
|
|
102
103
|
import { NeighbourPanels } from './neighbourPanels';
|
|
103
104
|
import { copyMarks } from './copyIdentity';
|
|
@@ -214,8 +215,12 @@ export interface GridSessionState {
|
|
|
214
215
|
readonly cellStage: string | null;
|
|
215
216
|
/** GC8: the `cell` path step that screen shows now and its detail, so a harness times each step. */
|
|
216
217
|
readonly cellStep: { readonly step: string; readonly detail: string } | null;
|
|
218
|
+
/** GC6: the hybrid runtime session's entry state (liveSession `hybridState`) */
|
|
219
|
+
readonly hybrid?: ReturnType<LiveGridSession['hybridState']> | null;
|
|
217
220
|
/** the allocator's grid content (MB) and the §3.2 playing total with the engine base (MB, the 1.0 GB envelope, G65) */
|
|
218
221
|
readonly residentMB: number; readonly playingMB: number;
|
|
222
|
+
/** GC6: the playing envelope the allocator admits against (MB) */
|
|
223
|
+
readonly envelopeMB?: number;
|
|
219
224
|
/** Exact category sum before engine base, overlap allowance or calibration factor; used by the soak harness. */
|
|
220
225
|
readonly accountedBytes: number;
|
|
221
226
|
readonly rings: { readonly frame?: number; readonly far: number; readonly l1: number; readonly l0: number; readonly refused: number; readonly inFlight: number; readonly queued: number;
|
|
@@ -688,7 +693,7 @@ export class GridSession {
|
|
|
688
693
|
// QA 2026-11-13: a waiting cell's loading steps on SHARD SELECT's loading card, inset over the live world
|
|
689
694
|
this.cellLoading = new CellLoading(new CellLoadingCard(), (waiting) => this.neighbours.some(row => row.instance === waiting));
|
|
690
695
|
setParkedMatricesFrozen(true); // G580 T2: a hidden parked world skips matrix updates during its warm-up
|
|
691
|
-
host.scope.onDispose(() => { this.cellLoading.close(); if (host.heldFrame !== undefined) host.heldFrame.enabled = false; setWarmUpHeld(false); setParkedMatricesFrozen(false); setBuildHeldTimed(false); });
|
|
696
|
+
host.scope.onDispose(() => { this.cellLoading.close(); if (host.heldFrame !== undefined) host.heldFrame.enabled = false; setWarmUpHeld(false); setParkedMatricesFrozen(false); setBuildHeldTimed(false); setBuildUrgent(false); });
|
|
692
697
|
// G78: a shimmer line at every shard border on its real ground; G119: SAVING… / SAVE FAILED, RETRY while a crossing waits
|
|
693
698
|
const rows = new Map((edges ?? []).map((cell) => [cell.instance, cell.edges]));
|
|
694
699
|
let status: CrossingSaveStatus = null, polled = 0;
|
|
@@ -885,6 +890,8 @@ export class GridSession {
|
|
|
885
890
|
const homeClaim = residency.home(), homeResidency = (): { instance: string; bytes: number } => ({ instance: homeClaim.instance, bytes: homeClaim.bytes });
|
|
886
891
|
host.scope.onDispose(app.debug.scopedExpose('grid', { state: () => this.state(), roadView: () => this.roadBudget.view(), roadResident: () => this.roadBudget.resident(),
|
|
887
892
|
roadTileResidency: () => this.roadTiles?.state() ?? null,
|
|
893
|
+
// GC6: the hybrid hooks' timings (each entry's world, kit, play and their after-hooks), for the crossing tour
|
|
894
|
+
hookTimings: () => this.live?.hookTimings() ?? null,
|
|
888
895
|
// G144 admission receipts read the same allocator, without reserving or changing any claim.
|
|
889
896
|
residency: () => ({ cost: this.allocator.cost(), claims: this.allocator.entries(), home: homeResidency() }),
|
|
890
897
|
// Per-frame travel needs the same fresh live/crossing facts, without the
|
|
@@ -972,7 +979,8 @@ export class GridSession {
|
|
|
972
979
|
*/
|
|
973
980
|
private cellLoadingInput(): CellLoadingInput | null {
|
|
974
981
|
const live = this.live; if (live === null) return null;
|
|
975
|
-
|
|
982
|
+
// GC6: a world built ahead whose entry still prepares holds its crossing on the road: the screen shows it
|
|
983
|
+
const current = live.live.current(), ready = (id: string): boolean => live.live.ready(id) && !live.entryPending(id) && (current !== id || live.gameplayReady());
|
|
976
984
|
let target: GridCell | undefined = current !== null && !ready(current) ? this.assembly.cell(current) : undefined;
|
|
977
985
|
if (target === undefined) {
|
|
978
986
|
const at = this.world();
|
|
@@ -1011,6 +1019,9 @@ export class GridSession {
|
|
|
1011
1019
|
// G580 T2 / T5: a held traveller's warm-up issues more programs a frame and its builds run a bigger budget
|
|
1012
1020
|
setWarmUpHeld(this.cellLoading.open !== null);
|
|
1013
1021
|
setBuildHeldTimed(this.cellLoading.open !== null);
|
|
1022
|
+
// GC6: a world the traveller heads into, or the road (where its entry prepares), builds with the urgent budget
|
|
1023
|
+
const live = this.live;
|
|
1024
|
+
setBuildUrgent(live !== null && (live.live.building() || live.entriesPending()));
|
|
1014
1025
|
}
|
|
1015
1026
|
private refusal(instance: string): ShardRefusal | null {
|
|
1016
1027
|
const live = this.live?.refusal(instance);
|
|
@@ -1247,8 +1258,8 @@ export class GridSession {
|
|
|
1247
1258
|
pitch: this.assembly.pitch,
|
|
1248
1259
|
home: this.home.instance, inside: gridCells.cell?.instance ?? null, feet: { x: Math.round(at.x * 100) / 100, z: Math.round(at.z * 100) / 100 },
|
|
1249
1260
|
cells: this.assembly.cells.map((cell) => { const d = drawn(cell.instance); return { instance: cell.instance, slug: cell.slug, cell: cell.cell, shows: shows(cell.instance, d), drawn: d }; }),
|
|
1250
|
-
strips: this.strips.length, road: this.road, seams: this.seams, softWalls: this.softWalls.state(), shimmer: this.shimmer.state(), cellLoading: this.cellLoading.open, cellStage: this.cellLoading.stage, cellStep: this.cellLoading.now, ringsReady: this.rings.ready(), ringsWait: { cells: this.rings.waiting(), far: this.rings.farPlan(), preparation: this.farPreparation(), waits: { count: pending.length, oldest: pending.map(({ label, kind, ageMs }) => ({ label, kind, ageMs })).sort((a, b) => b.ageMs - a.ageMs).slice(0, 16) } },
|
|
1251
|
-
residentMB: Math.round(cost.accounted / 1e4) / 100, playingMB: Math.round(cost.playing / 1e4) / 100,
|
|
1261
|
+
strips: this.strips.length, road: this.road, seams: this.seams, softWalls: this.softWalls.state(), shimmer: this.shimmer.state(), cellLoading: this.cellLoading.open, cellStage: this.cellLoading.stage, cellStep: this.cellLoading.now, hybrid: this.live?.hybridState() ?? null, ringsReady: this.rings.ready(), ringsWait: { cells: this.rings.waiting(), far: this.rings.farPlan(), preparation: this.farPreparation(), waits: { count: pending.length, oldest: pending.map(({ label, kind, ageMs }) => ({ label, kind, ageMs })).sort((a, b) => b.ageMs - a.ageMs).slice(0, 16) } },
|
|
1262
|
+
residentMB: Math.round(cost.accounted / 1e4) / 100, playingMB: Math.round(cost.playing / 1e4) / 100, envelopeMB: Math.round(this.allocator.envelope() / 1e4) / 100,
|
|
1252
1263
|
accountedBytes: cost.accounted,
|
|
1253
1264
|
rings: { frame: stats.frame, far: stats.resident.far, l1: stats.resident.l1, l0: stats.resident.l0, refused: stats.refused, inFlight: stats.inFlight, queued: stats.queued,
|
|
1254
1265
|
ghosts: { count: this.tileGhosts.count(), tiles: this.tileGhosts.regions() } },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mesh, type BufferGeometry, type Object3D } from 'three';
|
|
1
|
+
import { Matrix4, Mesh, type BufferGeometry, type Object3D } from 'three';
|
|
2
2
|
import { prepareRigLoader } from '@wildshard/engine/anim/rig';
|
|
3
3
|
import { workSlice } from '@wildshard/engine/core/workSlice';
|
|
4
4
|
import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
|
|
@@ -52,6 +52,17 @@ function shardfileHaze(fog: ShardfileFarRows['fog']): FarPrepared['look'] {
|
|
|
52
52
|
return { family: 'pbr', haze: { colour: fog ?? [1, 1, 1] } };
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
const IDENTITY = new Matrix4();
|
|
56
|
+
/** GC6: a mesh's geometry in its scene pose. The loader's accessor bounds would be recomputed from every vertex by
|
|
57
|
+
* `applyMatrix4` (two passes; ~45 % of the near bake's main-thread time on Driftwood to Nalati, where the neighbours' near
|
|
58
|
+
* views load on the road beside the entry's preparation), and nothing reads a part's bounds: the merged draw computes its
|
|
59
|
+
* own once. An identity pose is no transform at all. */
|
|
60
|
+
export function bakePose(node: Mesh): BufferGeometry {
|
|
61
|
+
const geometry = node.geometry;
|
|
62
|
+
geometry.boundingBox = null; geometry.boundingSphere = null;
|
|
63
|
+
return node.matrixWorld.equals(IDENTITY) ? geometry : geometry.applyMatrix4(node.matrixWorld);
|
|
64
|
+
}
|
|
65
|
+
|
|
55
66
|
/**
|
|
56
67
|
* G348: any shardfile's own near placeholder (its admitted `near` row, which `wildshard build` bakes for every terrain
|
|
57
68
|
* shardfile, an unknown uploaded one included): its content GLBs' meshes merged into the near view's one draw, masked by
|
|
@@ -77,7 +88,7 @@ export async function loadShardfileNear(rows: ShardfileNearRows, read: (ref: str
|
|
|
77
88
|
await slice.check();
|
|
78
89
|
for (const material of Array.isArray(node.material) ? node.material : [node.material]) material.dispose();
|
|
79
90
|
// NM13: the light layer stays apart from the lit draw (drawn additively, unlit)
|
|
80
|
-
(node.name === NEAR_LIGHT ? lights : node.name === NEAR_COLOUR ? colours : parts).push(
|
|
91
|
+
(node.name === NEAR_LIGHT ? lights : node.name === NEAR_COLOUR ? colours : parts).push(bakePose(node));
|
|
81
92
|
}
|
|
82
93
|
}
|
|
83
94
|
} catch (error) { for (const part of [...parts, ...lights, ...colours]) part.dispose(); throw error; }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BuiltWorld } from './context';
|
|
2
2
|
import { bootMark, bootTask } from '@wildshard/engine/boot/timing';
|
|
3
3
|
import { diagnosticNow } from '@wildshard/engine/core/clock';
|
|
4
|
+
import { captureHeightfield } from '@wildshard/engine/world/Heightfield';
|
|
4
5
|
import { sustainedFrames } from '@wildshard/engine/core/sustainedFrames';
|
|
5
6
|
import { Rng } from '@wildshard/engine/core/rng';
|
|
6
7
|
import { gridCells } from '../plugin/context';
|
|
@@ -401,7 +402,9 @@ export async function finishStage(ctx: Awaited<ReturnType<typeof playStage>>): P
|
|
|
401
402
|
// build's define makes this `false` in this module, so the import and its chunk go (scripts/check-devserver.mjs checks;
|
|
402
403
|
// DEVSERVER imported from grid/menu did not fold across modules and kept the chunk).
|
|
403
404
|
if (typeof __DEVSERVER__ === 'boolean' && __DEVSERVER__) void import('../devScene/hook').then(dev => dev.installDevHook({ scope: game.levelScope, scene: game.rootScene, physics: () => world.physics,
|
|
404
|
-
look: () => game.look, server: () => window.__workerClientDevColliders ?? null,
|
|
405
|
+
look: () => game.look, server: () => window.__workerClientDevColliders ?? null, serverGround: () => window.__workerClientDevGround ?? null,
|
|
406
|
+
restart: () => window.__workerClientDevRestart ?? null, quests: () => window.__shardfileDevQuests ?? null,
|
|
407
|
+
player: () => world.player, terrainField: captureHeightfield, watchFrames: fn => game.watchFrames(fn) }))
|
|
405
408
|
.catch((cause: unknown) => { console.error('[devScene]', cause); });
|
|
406
409
|
ctx.startExplore?.();
|
|
407
410
|
document.dispatchEvent(new Event('ws:ready')); // booted to the title
|
|
@@ -2,6 +2,7 @@ import {readModuleGroups} from '@wildshard/engine/boot/download';
|
|
|
2
2
|
import { whenControl } from '@wildshard/engine/boot/prefetch';
|
|
3
3
|
import type * as ScriptPresentation from '../plugin/ui';
|
|
4
4
|
import type { Scope } from '@wildshard/engine/app/scope';
|
|
5
|
+
import type { SystemSpec } from '@wildshard/engine/app/systems';
|
|
5
6
|
import type * as LootPresentation from '../loot/runtime';
|
|
6
7
|
import type * as CompendiumPresentation from '../compendium/install';
|
|
7
8
|
|
|
@@ -610,13 +611,29 @@ export class ShardfileClient {
|
|
|
610
611
|
player: () => world.player.position });
|
|
611
612
|
ctx.debug.expose('shardfileTalks', { talks: () => talks.map(talk => ({ id: talk.id, node: talk.node() ?? null, open: box?.isOpen ?? false })) });
|
|
612
613
|
}
|
|
613
|
-
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
614
|
+
const installQuests = (quests: Shardfile['quests'], at: ShardContext, ui: typeof presentation): void => {
|
|
615
|
+
for (const declaration of quests.quests) {
|
|
616
|
+
const quest = new QuestState(declaration, flags, ctx.app.events, at.scope);
|
|
617
|
+
const options = declaration.track === false ? { chip: () => ({ label: '', count: '' }) } : {};
|
|
618
|
+
// a retained (grid) runtime's chip, pins and card are its entered cell's only
|
|
619
|
+
if (ui === null) throw new Error('Missing quest presentation module');
|
|
620
|
+
if (retainsRuntimeServices(ctx)) ui.installEnteredQuestPresentation(at, quest, options); else ui.installQuestPresentation(at, quest, options);
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
// SHARD-SOURCE AP19 (DEVSERVER): `wildshard watch`'s soft restart rebuilds the quest views from a new quest section, so on a
|
|
624
|
+
// watched (one-shard) page they live in one child scope it replaces; elsewhere they are the context's, as they always were.
|
|
625
|
+
if (typeof __DEVSERVER__ === 'boolean' && __DEVSERVER__ && !retainsRuntimeServices(ctx) && typeof window !== 'undefined') {
|
|
626
|
+
const views = (scope: Scope): ShardContext => Object.create(ctx, { scope: { value: scope }, system: { value: (spec: SystemSpec) => { ctx.app.addSystem(spec, scope); } } }) as ShardContext;
|
|
627
|
+
let held = ctx.scope.child('shardfile.quests');
|
|
628
|
+
installQuests(source.quests, views(held), presentation);
|
|
629
|
+
ctx.scope.expose(window, '__shardfileDevQuests', async (quests: Shardfile['quests']): Promise<boolean> => {
|
|
630
|
+
const ui = presentation ?? await import('../plugin/ui');
|
|
631
|
+
if (ctx.scope.disposed) return false;
|
|
632
|
+
// the old views go first: a quest's system keeps its id across the swap
|
|
633
|
+
held.dispose(); held = ctx.scope.child('shardfile.quests');
|
|
634
|
+
try { installQuests(quests, views(held), ui); return true; } catch (cause) { console.error('[devScene] quest views', cause); return false; }
|
|
635
|
+
});
|
|
636
|
+
} else installQuests(source.quests, ctx, presentation);
|
|
620
637
|
if (ctx.product.has('ui/completion') && ctx.product.section('ui/completion').trigger === 'quest') installCompletion(ctx, flags, play.progress);
|
|
621
638
|
runtime.hooks.questFlags = () => flags.all; runtime.hooks.adventureFlags = () => flags.all;
|
|
622
639
|
// An admitted scene installs its own declared profiles once in the play phase.
|
|
@@ -23,6 +23,7 @@ import { materialGraphIr } from '@wildshard/format/materials';
|
|
|
23
23
|
import { FAMILY_IDS } from '@wildshard/format/materialFamilies';
|
|
24
24
|
import { propMaterialSlots, propSlotUse, type PropMaterials, type PropTextureSlot } from '@wildshard/format/propMaterials';
|
|
25
25
|
import type { Shardfile } from '@wildshard/format/shardSchema';
|
|
26
|
+
import { sceneSurfaceChannels } from '@wildshard/engine/render/families/sceneSurface';
|
|
26
27
|
|
|
27
28
|
const WRAPS: Readonly<Record<number, Wrapping>> = { 33071: ClampToEdgeWrapping, 33648: MirroredRepeatWrapping, 10497: RepeatWrapping };
|
|
28
29
|
const MAG: Readonly<Record<number, MagnificationTextureFilter>> = { 9728: NearestFilter, 9729: LinearFilter };
|
|
@@ -90,7 +91,9 @@ export async function propSurfaces(materials: PropMaterials, ports: {
|
|
|
90
91
|
for (const [slot, value] of slots) { const param = params[slot]; if (param?.type !== 'texture' && slot === 'colour' && graphUsesMeshMap(graph)) continue; if (param?.type !== 'texture') throw new Error(`props material "${name}": graph ${row.id} has no texture param ${slot}`); params[slot] = { ...param, value: value.file }; }
|
|
91
92
|
material = ownedGraph(ports.compile({ family: 'graph', graph: { ...graph, params } }), `${row.id}:${name}`);
|
|
92
93
|
} else material = base(row.id);
|
|
93
|
-
|
|
94
|
+
// SHARD-SOURCE AP11, AP12: a card reads its corners and a swaying surface its sway from their GLB channels
|
|
95
|
+
const channels = sceneSurfaceChannels(entry);
|
|
96
|
+
resolved.set(name, { material, maps, ...(channels === null ? {} : { channels }) });
|
|
94
97
|
}
|
|
95
98
|
return (name) => {
|
|
96
99
|
const binding = resolved.get(name);
|
|
@@ -10,11 +10,12 @@ import { isOutputIndex } from '@wildshard/format/outputAddress';
|
|
|
10
10
|
import { SHARDFILE_ADMISSION_LIMITS as limits } from '@wildshard/format/admissionLimits';
|
|
11
11
|
import type { Shardfile } from '@wildshard/format/shardSchema';
|
|
12
12
|
import { isDev } from '@wildshard/engine/core/devMode';
|
|
13
|
-
import { CONTENT_CAPS, _applyChunkConstants } from '@wildshard/engine/core/config';
|
|
13
|
+
import { CONTENT_CAPS, PHONE_PLAYING_BYTES, _applyChunkConstants } from '@wildshard/engine/core/config';
|
|
14
14
|
import { configureLevel } from '@wildshard/engine/level/selection';
|
|
15
15
|
import { pageGridInstance, sourceManifest, compiledPageBoot, type PageMode } from '../plugin/context';
|
|
16
16
|
import { PageResidency } from '../grid/pageResidency';
|
|
17
17
|
import { ResidencyAllocator } from '../../../shared/game/grid/allocator';
|
|
18
|
+
import { TIER, type Tier } from '@wildshard/engine/core/tier';
|
|
18
19
|
import type { GridRecoveryRecord } from '../../../shared/game/grid/recovery';
|
|
19
20
|
import { bootPageMode, pageGridRecovery } from '../grid/pageEntry';
|
|
20
21
|
import { currentPageMode } from '../../../shared/game/grid/pageMode';
|
|
@@ -51,13 +52,16 @@ export interface PageResidencyBoot {
|
|
|
51
52
|
* against their declared sim cost, then their actual library and tile claims. The root disposes failed hydration; the
|
|
52
53
|
* successful session installs the owner's level lifetime.
|
|
53
54
|
*/
|
|
55
|
+
/** GC13: the page's playing envelope: the phone tier's 1.0 GB (G65), else the shared caps' */
|
|
56
|
+
export function pagePlayingBytes(tier: Tier = TIER): number { return tier === 'phone' ? PHONE_PLAYING_BYTES : CONTENT_CAPS.playing; }
|
|
57
|
+
|
|
54
58
|
export function preparePageResidency(manifest: Pick<ShardManifest, 'slug' | 'shardfile' | 'runtimeCost'>, configuredSlug?: string, memory: MemoryAdmission = new MemoryAdmission(() => MEMORY_GATES.reportOnly || isDev())): PageResidencyBoot {
|
|
55
59
|
const mode = bootPageMode(configuredSlug ?? manifest.slug);
|
|
56
60
|
const measuredHome = configuredSlug === undefined && manifest.shardfile === undefined;
|
|
57
61
|
if (mode !== 'grid' && (!measuredHome || manifest.runtimeCost === undefined)) return { mode, instance: null, memory };
|
|
58
62
|
const instance = mode === 'grid' ? pageGridInstance() : manifest.slug;
|
|
59
63
|
if (instance === null) throw new Error('Grid residency requires the consumed home instance');
|
|
60
|
-
const residency = new PageResidency(new ResidencyAllocator({ memory }));
|
|
64
|
+
const residency = new PageResidency(new ResidencyAllocator({ memory, playing: pagePlayingBytes() }));
|
|
61
65
|
try {
|
|
62
66
|
if (measuredHome) {
|
|
63
67
|
if (manifest.runtimeCost === undefined) throw new Error('Grid runtime home requires reviewed memory measurements before bootstrap');
|
|
@@ -100,7 +104,7 @@ function clientSource(admitted: AdmittedProduct, options: ProductOptions, bindin
|
|
|
100
104
|
const sections = outputDescriptor(source)?.sections;
|
|
101
105
|
if (sections !== undefined) prepareClientModuleGroups(source, sections);
|
|
102
106
|
const ownedBindings = { ...bindings,
|
|
103
|
-
...(bindings.allocator === undefined && bindings.residency === undefined && options.memory !== undefined ? { allocator: new ResidencyAllocator({ memory: options.memory }) } : {}),
|
|
107
|
+
...(bindings.allocator === undefined && bindings.residency === undefined && options.memory !== undefined ? { allocator: new ResidencyAllocator({ memory: options.memory, playing: pagePlayingBytes() }) } : {}),
|
|
104
108
|
...(options.firstParty ? {} : { instance: admitted.instance ?? '' }) };
|
|
105
109
|
const residency = clientResidency(source, ownedBindings);
|
|
106
110
|
const assets = new ClientAssets(source, admitted.assets, options);
|