@wildshard/engine 0.1.22 → 0.1.23
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 +8 -0
- package/lint/engine-sides.json +2 -0
- package/lint/sim-players.json +2 -13
- package/package.json +9 -2
- package/scripts/apfs-clone.mjs +5 -2
- package/scripts/app-build/catalogue.ts +39 -8
- package/scripts/app-build/serviceWorker.ts +4 -1
- package/scripts/app-build/splitOutput.mjs +33 -11
- package/scripts/ci-pack.mjs +3 -3
- package/scripts/engine-ci-shard.mjs +11 -0
- package/scripts/fight-page-census.mjs +131 -0
- package/scripts/goldens/board.py +44 -11
- package/scripts/goldens/native-residency.d.mts +1 -0
- package/scripts/goldens/native-residency.mjs +18 -4
- package/scripts/keep-copy.mjs +120 -0
- package/scripts/land.mjs +36 -6
- package/scripts/lane-live.mjs +136 -0
- package/scripts/leftovers-report.mjs +47 -0
- package/scripts/loading-card-proof.mjs +42 -9
- package/scripts/loading-flow/benchmax.mjs +57 -7
- package/scripts/loading-flow/stalls.d.mts +2 -0
- package/scripts/loading-flow/stalls.mjs +13 -0
- package/scripts/mmo-bots.mjs +5 -3
- package/scripts/mmo-grid-proof.mjs +74 -0
- package/scripts/mmo-seat-proof.mjs +43 -0
- package/scripts/nightly-heads.ts +13 -13
- package/scripts/nightly-model.ts +26 -12
- package/scripts/nightly.proof.ts +18 -5
- package/scripts/nightly.ts +13 -8
- package/scripts/no-astc-boot.mjs +77 -0
- package/scripts/physics-route.json +6 -6
- package/scripts/pins-reuse.mjs +1 -0
- package/scripts/pins-staging.ts +54 -0
- package/scripts/pins.ts +5 -0
- package/scripts/ring3.proof.ts +71 -0
- package/scripts/ring3.ts +100 -0
- package/scripts/scratch-dir.mjs +31 -12
- package/scripts/scratch-sweep.mjs +15 -23
- package/scripts/server-release/items.d.mts +7 -0
- package/scripts/server-release/items.mjs +28 -0
- package/scripts/server-release/publish.mjs +9 -1
- package/scripts/side-parity.mjs +1 -1
- package/scripts/test-products.json +1 -0
- package/scripts/tsconfig.json +2 -0
- package/scripts/vitest-ci-files.ts +5 -1
- package/scripts/vps/wildshard-config +106 -1
- package/scripts/warm-native-chrome.mjs +9 -3
- package/scripts/worker-client-fights.mjs +9 -3
- package/scripts/worktree-reap.mjs +15 -131
- package/scripts/worktree.mjs +92 -12
- package/src/client/engine/audio/audioLog.ts +7 -2
- package/src/client/engine/boot/diagnostics.ts +69 -1
- package/src/client/engine/core/ktx2.ts +5 -3
- package/src/client/engine/core/ktx2Zstd.ts +2 -1
- package/src/client/engine/pwa/sw.js +26 -8
- package/src/client/engine/render/dataLook.ts +14 -7
- package/src/client/engine/render/lookLight.ts +64 -20
- package/src/client/engine/ui/Loading.ts +6 -8
- package/src/client/engine/ui/lookLightOption.ts +1 -1
- package/src/client/game/audio/cueDirector.ts +2 -1
- package/src/client/game/boss/arenaRoom.ts +4 -3
- package/src/client/game/boss/roamingProjection.ts +1 -1
- package/src/client/game/devScene/hook.ts +1 -1
- package/src/client/game/devScene/liveLook.ts +1 -1
- package/src/client/game/grid/dataCellKit.ts +9 -1
- package/src/client/game/grid/products.ts +21 -7
- package/src/client/game/grid/session.ts +6 -4
- package/src/client/game/population/signals.ts +1 -1
- package/src/client/game/quest/chapterDirector.ts +1 -0
- package/src/client/game/shardfile/clientBossTelegraph.ts +4 -3
- package/src/client/game/shardfile/clientWorker.ts +22 -6
- package/src/client/game/shardfile/look.ts +1 -1
- package/src/client/game/shardfile/runtimeProduct.ts +9 -5
- package/src/client/game/shardfile/wirePage.ts +5 -2
- package/src/client/game/shardfile/worldSceneTextures.ts +15 -9
- package/src/cook/game/cookWorker.ts +8 -5
- package/src/cook/game/tierTextures.ts +5 -3
- package/src/server/engine/net/simWorld.ts +3 -4
- package/src/server/game/grid/cellHome.ts +58 -0
- package/src/server/game/grid/simulation.ts +5 -4
- package/src/server/game/plugin/mover.ts +18 -14
- package/src/server/game/shardfile/declaredKitItems.ts +31 -7
- package/src/server/host/bake/headlessWorker.ts +3 -3
- package/src/server/host/dedicated/cellWorker.ts +4 -2
- package/src/server/host/dedicated/main.ts +7 -4
- package/src/server/host/dedicated/packReader.ts +15 -2
- package/src/server/host/dedicated/playerStore.ts +1 -1
- package/src/server/host/headlessRuntime.ts +11 -6
- package/src/server/host/standalone/cellWorld.ts +20 -6
- package/src/server/host/standalone/gridServer.ts +3 -1
- package/src/server/host/standalone/roadWorld.ts +6 -0
- package/src/shared/engine/physics/gridBorders.ts +15 -1
- package/src/shared/engine/sim/snapshot.ts +5 -5
- package/src/shared/game/ledger.ts +13 -4
- package/src/shared/game/loot/platformCatalogue.ts +14 -0
- package/src/shared/game/quest/ledger.ts +3 -3
- package/src/shared/game/shardfile/items.ts +9 -1
- package/src/shared/host/headlessJourney.ts +3 -3
- package/src/shared/host/headlessTape.ts +7 -6
- package/src/shared/host/releaseRows.ts +4 -1
|
@@ -44,7 +44,7 @@ function numbers(value:unknown,keys:readonly string[]):Record<string,number|bool
|
|
|
44
44
|
}
|
|
45
45
|
const realm=(value:unknown):string=>typeof value==='string'&&/^(?:page|service-worker|worker:[0-9]{1,5})$/u.test(value)?value:'other';
|
|
46
46
|
/** Only build-system shaped public IDs are labels; arbitrary identifiers are not. */
|
|
47
|
-
export const diagnosticBuild=(value:unknown):string=>typeof value==='string'&&/^[a-f0-9]{7,40}
|
|
47
|
+
export const diagnosticBuild=(value:unknown):string=>typeof value==='string'&&/^[a-f0-9]{7,40}(?:-[a-z0-9]{6,16})?$/u.test(value)?value:'unknown';
|
|
48
48
|
/** LD3: engine operations named in a paste beyond OPERATIONS: an explicit list (Codex review of ca3c1d8: a pattern let
|
|
49
49
|
* any `app:<text>` through). A name not listed here or in OPERATIONS still becomes `operation-N`. */
|
|
50
50
|
const NAMED_OPERATIONS=new Set(['download:cache-check','app:session-code-ready','app:session-start','app:first-game-step-start',
|
|
@@ -193,3 +193,71 @@ export function safeBootDiagnostics(timing:BootTiming|undefined):Readonly<Record
|
|
|
193
193
|
handoff:{...numbers(handoff,['timeOrigin',...DETAIL_NUMBERS]),input:input(handoff['input'])},
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
|
+
|
|
197
|
+
/** NB15: only the privacy projection reaches the clipboard. Keep the local
|
|
198
|
+
* collector complete, but rank its useful facts instead of copying its JSON. */
|
|
199
|
+
export function compactBootDiagnostics(timing:BootTiming|undefined):{summary:readonly string[];timeline:readonly string[]}{
|
|
200
|
+
const safe=safeBootDiagnostics(timing);
|
|
201
|
+
if(safe===null)return {summary:[],timeline:['timeline (LS1): unavailable']};
|
|
202
|
+
const entries=list(safe['entries']).map(record),resources=list(safe['resources']).map(record);
|
|
203
|
+
const spans=entries.flatMap(row=>{
|
|
204
|
+
const start=number(row['start']),end=number(row['end']);
|
|
205
|
+
return start!==null&&end!==null&&end>start?[{name:String(row['operation']),realm:String(row['realm']),start,end,ms:end-start}]:[];
|
|
206
|
+
});
|
|
207
|
+
const label=(value:unknown,limit:number):string=>{
|
|
208
|
+
const text=typeof value==='string'?value:'unknown';
|
|
209
|
+
return text.length<=limit?text:`${text.slice(0,Math.floor(limit/2))}…${text.slice(-Math.floor(limit/2))}`;
|
|
210
|
+
};
|
|
211
|
+
const network=resources.filter(row=>(number(row['transferSize'])??0)>0);
|
|
212
|
+
const cached=resources.filter(row=>number(row['transferSize'])===0&&(number(row['encodedBodySize'])??0)>0);
|
|
213
|
+
const bytes=(rows:readonly Readonly<Record<string,unknown>>[],key:string):number=>rows.reduce((sum,row)=>sum+(number(row[key])??0),0);
|
|
214
|
+
const seconds=(ms:number):string=>(ms/1000).toFixed(2);
|
|
215
|
+
const duration=(row:Readonly<Record<string,unknown>>):number=>number(row['duration'])??Math.max(0,(number(row['responseEnd'])??0)-(number(row['startTime'])??0));
|
|
216
|
+
const timeline=[
|
|
217
|
+
'timeline (LS1):',
|
|
218
|
+
`counts: ${entries.length} spans (${spans.length} complete), ${resources.length} resources; network ${network.length} / ${bytes(network,'transferSize')} B; cache ${cached.length} / ${bytes(cached,'encodedBodySize')} B; unknown ${resources.length-network.length-cached.length}`,
|
|
219
|
+
'longest spans (start s + duration s):',
|
|
220
|
+
...spans.sort((a,b)=>b.ms-a.ms).slice(0,15).map(row=>` ${label(row.name,88)} [${row.realm}] ${seconds(row.start)} + ${seconds(row.ms)}`),
|
|
221
|
+
'slowest resources (bytes, duration s, source):',
|
|
222
|
+
...resources.sort((a,b)=>duration(b)-duration(a)).slice(0,10).map(row=>{
|
|
223
|
+
const transfer=number(row['transferSize']),encoded=number(row['encodedBodySize'])??0;
|
|
224
|
+
const source=transfer!==null&&transfer>0?'network':transfer===0&&encoded>0?'cache':'unknown';
|
|
225
|
+
return ` ${label(row['url'],100)} ${transfer!==null&&transfer>0?transfer:encoded} B ${seconds(duration(row))} s ${source}`;
|
|
226
|
+
}),
|
|
227
|
+
];
|
|
228
|
+
// Worker resource receipts carry their measured page-clock translation.
|
|
229
|
+
// Merge those with page requests; unaligned worker clocks cannot fill a gap.
|
|
230
|
+
const end=Math.max(0,...entries.filter(row=>row['realm']==='page').map(row=>number(row['end'])??number(row['start'])??0));
|
|
231
|
+
const intervals=resources.flatMap(row=>{
|
|
232
|
+
const page=row['realm']==='page';
|
|
233
|
+
const start=number(row['pageStart'])??(page?number(row['startTime']):null);
|
|
234
|
+
const finish=number(row['pageEnd'])??(page?number(row['responseEnd'])??(start===null?null:start+duration(row)):null);
|
|
235
|
+
return start!==null&&finish!==null&&finish>start&&start<end?[{start:Math.max(0,start),end:Math.min(end,finish)}]:[];
|
|
236
|
+
});
|
|
237
|
+
const navigation=record(safe['navigation']),responseEnd=number(navigation['responseEnd']);
|
|
238
|
+
const requestStart=Math.max(0,number(navigation['startTime'])??0);
|
|
239
|
+
if(responseEnd!==null&&responseEnd>requestStart&&requestStart<end)intervals.push({start:requestStart,end:Math.min(end,responseEnd)});
|
|
240
|
+
intervals.sort((a,b)=>a.start-b.start);
|
|
241
|
+
const gaps:{start:number;ms:number}[]=[];
|
|
242
|
+
let cursor=0;
|
|
243
|
+
for(const interval of intervals){
|
|
244
|
+
if(interval.start-cursor>500)gaps.push({start:cursor,ms:interval.start-cursor});
|
|
245
|
+
cursor=Math.max(cursor,interval.end);
|
|
246
|
+
}
|
|
247
|
+
if(end-cursor>500)gaps.push({start:cursor,ms:end-cursor});
|
|
248
|
+
// Keep every interval. Repeated polling gaps need one readable run rather
|
|
249
|
+
// than hundreds of identical durations; no gap is sampled or discarded.
|
|
250
|
+
const gapLines:string[]=[],stamp=(ms:number):string=>String(Number((ms/1000).toFixed(3)));
|
|
251
|
+
for(let index=0;index<gaps.length;){
|
|
252
|
+
const gap=gaps[index];if(gap===undefined)break;
|
|
253
|
+
const next=gaps[index+1],stride=next===undefined?0:Number(((next.start-gap.start)/1000).toFixed(9));
|
|
254
|
+
let count=1;
|
|
255
|
+
if(stride>0)while(gaps[index+count]!==undefined&&stamp(gaps[index+count]?.ms??0)===stamp(gap.ms)
|
|
256
|
+
&&stamp(gaps[index+count]?.start??0)===stamp((Number(stamp(gap.start))+count*stride)*1000))count++;
|
|
257
|
+
const repeated=count>=3;
|
|
258
|
+
gapLines.push(`${stamp(gap.start)}+${stamp(gap.ms)}${repeated?` every ${stride} x${count}`:''}`);
|
|
259
|
+
index+=repeated?count:1;
|
|
260
|
+
}
|
|
261
|
+
timeline.push(`request-free gaps >0.5 s (page clock, start+duration s): ${gapLines.join(', ')||'none'}`);
|
|
262
|
+
return {summary:list(safe['summary']).filter((value):value is string=>typeof value==='string'),timeline};
|
|
263
|
+
}
|
|
@@ -40,6 +40,8 @@ import { workSlice } from '../../../shared/engine/core/workSlice';
|
|
|
40
40
|
import { TIER } from './tier';
|
|
41
41
|
import { prepareKtx2Zstd, unsupercompressKtx2 } from './ktx2Zstd';
|
|
42
42
|
import { parseKtx2 } from '@wildshard/format/ktx2Cost';
|
|
43
|
+
import { waitFor } from '../../../shared/engine/boot/waits';
|
|
44
|
+
import { bootTask } from '../../../shared/engine/boot/timing';
|
|
43
45
|
|
|
44
46
|
/** where scripts/app-build/basis.ts copies three's transcoder: versioned by three's revision, so the SW / HTTP caches never mix two */
|
|
45
47
|
/** Before transcoding `files`: start what their parses will need (the raw-texel zstd decoder) from the caller's stack. */
|
|
@@ -307,16 +309,16 @@ export function loadKtx2(target: Pick<KTX2Loader, 'manager' | 'path' | 'requestH
|
|
|
307
309
|
const resolved = target.manager.resolveURL(target.path + url);
|
|
308
310
|
let bytes = reading.get(resolved);
|
|
309
311
|
if (bytes === undefined) {
|
|
310
|
-
bytes = fetch(resolved, { headers: target.requestHeader, credentials: target.withCredentials ? 'include' : 'same-origin' }).then(response => {
|
|
312
|
+
bytes = bootTask(`texture:read ${resolved}`, () => waitFor('Reading texture', fetch(resolved, { headers: target.requestHeader, credentials: target.withCredentials ? 'include' : 'same-origin' }).then(response => {
|
|
311
313
|
if (response.status !== 200 && response.status !== 0) throw new Error(`fetch for "${response.url}" responded with ${String(response.status)}: ${response.statusText}`);
|
|
312
314
|
return response.arrayBuffer();
|
|
313
|
-
});
|
|
315
|
+
}), 'file', resolved));
|
|
314
316
|
reading.set(resolved, bytes);
|
|
315
317
|
const read = bytes;
|
|
316
318
|
const clear = (): void => { if (reading.get(resolved) === read) reading.delete(resolved); };
|
|
317
319
|
read.finally(clear).catch(() => undefined);
|
|
318
320
|
}
|
|
319
|
-
return bytes.then(buffer => new Promise<THREE.CompressedTexture>((resolve, reject) => { target.parse(buffer, resolve, reject); }));
|
|
321
|
+
return bytes.then(buffer => bootTask(`texture:decode ${resolved}`, () => waitFor('Preparing texture', new Promise<THREE.CompressedTexture>((resolve, reject) => { target.parse(buffer, resolve, reject); }), 'worker', resolved)));
|
|
320
322
|
}
|
|
321
323
|
function load(url: string, keep: boolean): Promise<THREE.CompressedTexture> {
|
|
322
324
|
let p = transcoded.get(url);
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { pageScope } from '../../../shared/engine/app/resources';
|
|
10
10
|
import type { Scope } from '../../../shared/engine/app/scope';
|
|
11
|
+
import { waitFor } from '../../../shared/engine/boot/waits';
|
|
11
12
|
|
|
12
13
|
const HEADER = 80, LEVEL = 24, SCHEME_ZSTD = 2;
|
|
13
14
|
/** level data starts at a multiple of this in the rewritten file (the spec's lcm(texel block size, 4) for every format) */
|
|
@@ -143,7 +144,7 @@ export async function unsupercompressKtx2(buffer: ArrayBuffer): Promise<ArrayBuf
|
|
|
143
144
|
const bytes = new Uint8Array(buffer), levels = zstdLevels(bytes);
|
|
144
145
|
if (levels === null) return buffer;
|
|
145
146
|
try {
|
|
146
|
-
const decoded = await decodeLevels(levels.map(level => ({ data: bytes.slice(level.offset, level.offset + level.length), size: level.size })));
|
|
147
|
+
const decoded = await waitFor('Preparing texture data', decodeLevels(levels.map(level => ({ data: bytes.slice(level.offset, level.offset + level.length), size: level.size }))), 'worker');
|
|
147
148
|
if (decoded.length !== levels.length || decoded.some((data, i) => data.byteLength !== levels[i]?.size)) return buffer;
|
|
148
149
|
const plain = plainKtx2(bytes, levels, decoded);
|
|
149
150
|
return plain.buffer instanceof ArrayBuffer ? plain.buffer : buffer;
|
|
@@ -52,11 +52,11 @@ const immutable = url => NAMED.has(url.pathname) || url.pathname.startsWith('/b/
|
|
|
52
52
|
|| /^[a-f0-9]{8,64}$/.test(url.searchParams.get('v') ?? '');
|
|
53
53
|
const isHtml = response => /\btext\/html\b/i.test(response.headers.get('content-type') ?? '');
|
|
54
54
|
/* PAGE-SIZE PZ10 (J276): content on the content base (`https://packs.wildshard.io/content/<set>/`, baked from the boot
|
|
55
|
-
* bank by serviceWorker.ts; '' when content is on the page) lives in one cross-build cache
|
|
56
|
-
*
|
|
55
|
+
* bank by serviceWorker.ts; '' when content is on the page) lives in one cross-build cache. NB11 removes the set folder
|
|
56
|
+
* only from content-named or per-file-versioned keys; mutable files retain their release URL. No activate touches it. Only a CORS 200 is
|
|
57
57
|
* kept: an opaque body cannot be checked and is padded against quota, and a range never stands for the whole file. */
|
|
58
|
-
/** @type {{ base: string, files: string[] }} one parsed value: the bundler would fold a literal base into its origin */
|
|
59
|
-
const { base: CONTENT_BASE, files: CONTENT_FILES } = JSON.parse('__CONTENT__');
|
|
58
|
+
/** @type {{ base: string, files: string[], versions?: Record<string, string> }} one parsed value: the bundler would fold a literal base into its origin */
|
|
59
|
+
const { base: CONTENT_BASE, files: CONTENT_FILES, versions: CONTENT_VERSIONS = {} } = JSON.parse('__CONTENT__');
|
|
60
60
|
/** OF5: the server book on the content base is solo-only too (a URL there, its path under the base's folder). */
|
|
61
61
|
const CONTENT_PRECACHE = CONTENT_FILES.filter(href => !WORLD || !SOLO_ONLY.test(new URL(href).pathname));
|
|
62
62
|
const CONTENT_CACHE = cacheName('ws-content-v1', CHANNEL);
|
|
@@ -78,6 +78,23 @@ const keepContent = response => (response.type === 'cors' || SAME_ORIGIN_BASE &&
|
|
|
78
78
|
* @param {Request | string} input @param {RequestInit} init */
|
|
79
79
|
const corsRequest = (input, init = {}) => new Request(input, { ...init, mode: 'cors', credentials: 'omit' });
|
|
80
80
|
|
|
81
|
+
/** NB11: a release's set folder changes when any content changes. Only a
|
|
82
|
+
* content-named file or a build-declared content hash can leave that folder.
|
|
83
|
+
* Mutable metadata keeps its exact release URL; channel stores remain separate. */
|
|
84
|
+
function contentKey(href) {
|
|
85
|
+
if (CONTENT_URL === undefined) return href;
|
|
86
|
+
const address = new URL(href);
|
|
87
|
+
if (address.origin !== CONTENT_URL.origin || !address.pathname.startsWith(CONTENT_URL.pathname)) return href;
|
|
88
|
+
const path = address.pathname.slice(CONTENT_URL.pathname.length - 1);
|
|
89
|
+
const version = CONTENT_VERSIONS[path];
|
|
90
|
+
if (!CONTENT.test(path) && !PAGE_PART.test(path) && !OWN_NAMED.test(path)
|
|
91
|
+
&& !/^[a-f0-9]{8,64}$/.test(address.searchParams.get('v') ?? '') && version === undefined) return href;
|
|
92
|
+
const key = new URL(`/__ws_content__/v1${path}`, CONTENT_URL.origin);
|
|
93
|
+
key.search = address.search;
|
|
94
|
+
if (!key.searchParams.has('v') && version !== undefined) key.searchParams.set('v', version);
|
|
95
|
+
return key.href;
|
|
96
|
+
}
|
|
97
|
+
|
|
81
98
|
// Keep the current worker's hot handles. WebKit can take a second to reopen
|
|
82
99
|
// a cache during navigation; a rejected open must remain retryable.
|
|
83
100
|
const stores = new Map();
|
|
@@ -217,14 +234,14 @@ async function precacheQueue(cache, urls, content = false) {
|
|
|
217
234
|
await whilePaused();
|
|
218
235
|
const path = pending.shift();
|
|
219
236
|
if (path === undefined) return;
|
|
220
|
-
const
|
|
237
|
+
const address = abs(path), key = content ? contentKey(address) : address, control = new AbortController();
|
|
221
238
|
inflight.add(control);
|
|
222
239
|
try {
|
|
223
240
|
const held = await cache.match(key, MATCH);
|
|
224
241
|
if (held !== undefined && !isHtml(held)) continue;
|
|
225
242
|
if (held !== undefined) await cache.delete(key);
|
|
226
243
|
if (content) {
|
|
227
|
-
const response = await fetch(corsRequest(
|
|
244
|
+
const response = await fetch(corsRequest(address, { cache: 'force-cache', signal: control.signal }));
|
|
228
245
|
if (!keepContent(response)) throw new Error(`Precache failed: ${path} (${response.type} ${response.status})`);
|
|
229
246
|
await cache.put(key, response);
|
|
230
247
|
continue;
|
|
@@ -397,10 +414,11 @@ async function networkFirst(request, name, event) {
|
|
|
397
414
|
* @param {Request} request */
|
|
398
415
|
async function contentRead(request) {
|
|
399
416
|
const reload = request.cache === 'reload' || request.cache === 'no-store';
|
|
417
|
+
const key = contentKey(request.url);
|
|
400
418
|
let cache;
|
|
401
419
|
try {
|
|
402
420
|
cache = await store(CONTENT_CACHE);
|
|
403
|
-
const held = reload ? undefined : await cache.match(request.url, MATCH);
|
|
421
|
+
const held = reload ? undefined : await cache.match(key, MATCH) ?? (key === request.url ? undefined : await cache.match(request.url, MATCH));
|
|
404
422
|
if (held !== undefined && !isHtml(held)) return held;
|
|
405
423
|
} catch { stores.delete(CONTENT_CACHE); /* Storage denial keeps online fetch working. */ }
|
|
406
424
|
let response;
|
|
@@ -409,7 +427,7 @@ async function contentRead(request) {
|
|
|
409
427
|
try { response = await fetch(corsRequest(request)); }
|
|
410
428
|
catch { return fetch(request); }
|
|
411
429
|
}
|
|
412
|
-
if (cache !== undefined && keepContent(response)) await cache.put(
|
|
430
|
+
if (cache !== undefined && keepContent(response)) await cache.put(key, response.clone()).catch(() => undefined);
|
|
413
431
|
return response;
|
|
414
432
|
}
|
|
415
433
|
|
|
@@ -66,7 +66,9 @@ export interface DataLookSpec {
|
|
|
66
66
|
readonly light?: {
|
|
67
67
|
readonly rim: LookRim | null; readonly pools: LookPools | null; readonly heightFogDensity: number;
|
|
68
68
|
/** B2: real lamps, a warm bounce and a sky-derived environment; absent or null: none */
|
|
69
|
-
readonly lamps?: readonly LookLamp[] | null;
|
|
69
|
+
readonly lamps?: readonly LookLamp[] | null;
|
|
70
|
+
/** AP28: how many lamps light a frame, the nearest the camera; absent: `DESKTOP_LAMPS` */
|
|
71
|
+
readonly lampsLit?: number; readonly bounce?: LookBounce | null; readonly environment?: LookEnvironment | null;
|
|
70
72
|
/** TEMPLATES-CLEANROOM M4: the sun's shadow look and glow motes; absent or null: the engine's shadows, no motes */
|
|
71
73
|
readonly shadow?: LookShadow | null; readonly motes?: LookMotes | null;
|
|
72
74
|
};
|
|
@@ -237,6 +239,8 @@ function cellTone(spec: { readonly neutral?: boolean; readonly aces?: boolean; r
|
|
|
237
239
|
* A level look from data: the engine's clean chain, the gradient dome, the engine fog, key light and ambient turned by
|
|
238
240
|
* the keys on the engine clock, and the LUT last in the grade. Nothing is patched into another material.
|
|
239
241
|
*/
|
|
242
|
+
const lampEye = new THREE.Vector3();
|
|
243
|
+
|
|
240
244
|
export function dataLook(spec: DataLookSpec): LookStrategy {
|
|
241
245
|
if (spec.keys.length === 0) throw new Error('[look] a data look needs at least one key');
|
|
242
246
|
const linear = spec.keys[0]?.fog.near !== undefined;
|
|
@@ -270,9 +274,9 @@ ${mist ? `
|
|
|
270
274
|
shader.fragmentShader = `#ifdef USE_FOG\nuniform float wsLookFogNear; uniform float wsLookFogFar; uniform float wsLookFogEnabled;\n#endif\n${patched}`;
|
|
271
275
|
};
|
|
272
276
|
const owned: { dome: THREE.Mesh<THREE.SphereGeometry, THREE.Material> | null; lut: LookupTexture | null; pools: THREE.Object3D | null; rim: boolean;
|
|
273
|
-
lamps: ReturnType<typeof lampLights> | null; bounce: ReturnType<typeof bounceLight> | null; environment: THREE.WebGLRenderTarget | null;
|
|
277
|
+
lamps: ReturnType<typeof lampLights> | null; eye: THREE.Camera | null; bounce: ReturnType<typeof bounceLight> | null; environment: THREE.WebGLRenderTarget | null;
|
|
274
278
|
glow: THREE.Object3D[] | null; fx: EngineEffects | null; exposure: ExposureEffect | null; clock: DayCycle | null;
|
|
275
|
-
chain: { vignette: { offset: number; darkness: number }; radius: number } | null } = { dome: null, lut: null, pools: null, rim: false, lamps: null, bounce: null, environment: null, glow: null,
|
|
279
|
+
chain: { vignette: { offset: number; darkness: number }; radius: number } | null } = { dome: null, lut: null, pools: null, rim: false, lamps: null, eye: null, bounce: null, environment: null, glow: null,
|
|
276
280
|
fx: null, exposure: null, clock: null, chain: null };
|
|
277
281
|
// AP17: what `liveLook` last set (the light rows and the LUT are compared with the build's, never set)
|
|
278
282
|
let day = spec.day, dayOverride = spec.dayOverride;
|
|
@@ -312,7 +316,9 @@ ${mist ? `
|
|
|
312
316
|
return true;
|
|
313
317
|
},
|
|
314
318
|
// the sky builds before the composer: the level scope takes the dome and the LUT here
|
|
315
|
-
mode: 'extend', chain: 'clean', compose: ({ engineChain, scene, scope, fx, renderer }) => {
|
|
319
|
+
mode: 'extend', chain: 'clean', compose: ({ engineChain, scene, scope, fx, renderer, camera }) => {
|
|
320
|
+
// AP28: the lamps nearest this camera light
|
|
321
|
+
owned.eye = camera; scope.onDispose(() => { if (owned.eye === camera) owned.eye = null; });
|
|
316
322
|
const rim = spec.light?.rim ?? null, pools = spec.light?.pools ?? null, lamps = spec.light?.lamps ?? null;
|
|
317
323
|
if (rim !== null && !owned.rim) {
|
|
318
324
|
owned.rim = true; scope.onDispose(() => { owned.rim = false; });
|
|
@@ -335,7 +341,7 @@ ${mist ? `
|
|
|
335
341
|
}
|
|
336
342
|
if (lamps !== null && owned.lamps === null) {
|
|
337
343
|
// B2: real lamps, once per look like the pools
|
|
338
|
-
const group = lampLights(lamps);
|
|
344
|
+
const group = lampLights(lamps, spec.light?.lampsLit);
|
|
339
345
|
owned.lamps = group;
|
|
340
346
|
scene.add(group); scope.onDispose(() => { group.removeFromParent(); for (const light of group.children) if (light instanceof THREE.Light) light.dispose(); if (owned.lamps === group) owned.lamps = null; });
|
|
341
347
|
}
|
|
@@ -343,7 +349,8 @@ ${mist ? `
|
|
|
343
349
|
if (owned.glow === null && ((lamps?.some((lamp) => lamp.halo !== undefined) ?? false) || motes !== null)) {
|
|
344
350
|
// M4.8: the lamps' halos (one instanced draw) and the motes (one points draw), once per look like the lamps
|
|
345
351
|
const glow: (THREE.Mesh | THREE.Points)[] = [];
|
|
346
|
-
|
|
352
|
+
// a following lamp's halo would stay at its offset: AP24b lights it, its halo waits
|
|
353
|
+
const halos = lamps === null ? null : lampHalos(lamps.filter((lamp) => lamp.follow === undefined));
|
|
347
354
|
if (halos !== null) glow.push(halos);
|
|
348
355
|
if (motes !== null) glow.push(lookMotes(motes));
|
|
349
356
|
owned.glow = glow;
|
|
@@ -436,7 +443,7 @@ ${mist ? `
|
|
|
436
443
|
owned.lut = await lutTexture(spec.lut);
|
|
437
444
|
return { clock, horizon: now.fog.clone(), lut: owned.lut, clouds: dome,
|
|
438
445
|
bind: (t) => { targets = t; apply(); },
|
|
439
|
-
update: (dt) => { clock.update(dt); apply(); flicker += dt; owned.lamps?.update?.(flicker); if (owned.glow !== null) tickGlow(owned.glow, flicker); },
|
|
446
|
+
update: (dt) => { clock.update(dt); apply(); flicker += dt; owned.lamps?.update?.(flicker, owned.eye?.getWorldPosition(lampEye)); if (owned.glow !== null) tickGlow(owned.glow, flicker); },
|
|
440
447
|
rebuild: () => undefined, attachPost: () => undefined };
|
|
441
448
|
},
|
|
442
449
|
};
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* All of it waits behind Settings ▸ Debug ▸ Look ▸ "Look light" (read at load; default on): with the row off, a look that
|
|
22
22
|
* declares every setting draws as one that declares none. TEMPLATES-CLEANROOM M4.9 gates it per field on the phone tier
|
|
23
23
|
* instead of all or nothing: a phone keeps the environment, bounce, pools, rim, height fog and shadow look, at most
|
|
24
|
-
* `PHONE_LAMPS` lamps, half the motes, and no bloom or AO.
|
|
24
|
+
* `PHONE_LAMPS` lamps lit, the nearest (AP28), half the motes, and no bloom or AO.
|
|
25
25
|
*/
|
|
26
26
|
import * as THREE from 'three';
|
|
27
27
|
import type { LookBounce, LookEnvironment, LookLamp, LookLight, LookPools, LookRim } from '@wildshard/format/look-light';
|
|
@@ -42,6 +42,8 @@ export interface LookLightResolved {
|
|
|
42
42
|
readonly rim: LookRim | null;
|
|
43
43
|
readonly pools: LookPools | null;
|
|
44
44
|
readonly lamps: readonly LookLamp[] | null;
|
|
45
|
+
/** AP28: how many of `lamps` light a frame, the nearest the eye (`PHONE_LAMPS` on a phone, `DESKTOP_LAMPS` else) */
|
|
46
|
+
readonly lampsLit: number;
|
|
45
47
|
readonly bounce: LookBounce | null;
|
|
46
48
|
readonly environment: LookEnvironment | null;
|
|
47
49
|
/** M4.2: the sun's shadow look; null: the engine's */
|
|
@@ -61,10 +63,12 @@ const NO_HEIGHT_FOG = { fogHeight: -20, fogHeightFalloff: 0, fogHeightDensity: 0
|
|
|
61
63
|
|
|
62
64
|
/** M4.9: at most this many of a look's lamps light on the phone tier (each costs every lit draw a light-loop step) */
|
|
63
65
|
export const PHONE_LAMPS = 4;
|
|
66
|
+
/** SHARD-SOURCE AP28: at most this many of a look's lamps light a desktop frame (shard-format `LOOK_LIGHT_LIT_MAX`) */
|
|
67
|
+
export const DESKTOP_LAMPS = 16;
|
|
64
68
|
|
|
65
69
|
/**
|
|
66
70
|
* Resolve a look's light settings; `on` is the Debug row ("Look light"), `tier` the page's. Off, or nothing declared: as
|
|
67
|
-
* before. The phone tier keeps the cheap fields (M4.9): no bloom or AO, the
|
|
71
|
+
* before. The phone tier keeps the cheap fields (M4.9): no bloom or AO, the nearest `PHONE_LAMPS` lamps lit (AP28), half the motes.
|
|
68
72
|
*/
|
|
69
73
|
export function lookLightManifest(look: LookLightSource, on: boolean, tier = 'desktop'): LookLightResolved {
|
|
70
74
|
const phone = tier === 'phone';
|
|
@@ -76,7 +80,8 @@ export function lookLightManifest(look: LookLightSource, on: boolean, tier = 'de
|
|
|
76
80
|
ao: light?.ao === undefined || phone ? null : { intensity: light.ao.intensity, radius: light.ao.radius },
|
|
77
81
|
rim: light?.rim ?? null,
|
|
78
82
|
pools: light?.pools ?? null,
|
|
79
|
-
lamps: light?.lamps
|
|
83
|
+
lamps: light?.lamps ?? null,
|
|
84
|
+
lampsLit: phone ? PHONE_LAMPS : DESKTOP_LAMPS,
|
|
80
85
|
bounce: light?.bounce ?? null,
|
|
81
86
|
environment: light?.environment ?? null,
|
|
82
87
|
shadow: light?.shadow ?? null,
|
|
@@ -156,29 +161,68 @@ export function bounceLight(bounce: LookBounce): { light: THREE.DirectionalLight
|
|
|
156
161
|
return { light, aim };
|
|
157
162
|
}
|
|
158
163
|
|
|
164
|
+
/** SHARD-SOURCE AP24b: what a following lamp rides (`lamps[].follow`), or null while that actor is not in the world. */
|
|
165
|
+
export type LampFollowResolve = (actor: string, bone: string | undefined) => THREE.Object3D | null;
|
|
166
|
+
const lampFollows = new WeakMap<THREE.Object3D, LampFollowResolve>();
|
|
167
|
+
/** The page's actor lookup for the following lamps drawn under `root` (its scene); returns the undo. */
|
|
168
|
+
export function setLampFollow(root: THREE.Object3D, resolve: LampFollowResolve): () => void {
|
|
169
|
+
lampFollows.set(root, resolve);
|
|
170
|
+
return () => { if (lampFollows.get(root) === resolve) lampFollows.delete(root); };
|
|
171
|
+
}
|
|
172
|
+
const rootOf = (object: THREE.Object3D): THREE.Object3D => { let at = object; while (at.parent !== null) at = at.parent; return at; };
|
|
173
|
+
|
|
174
|
+
/** a lamp group's frame step: `time` drives the flicker, `eye` (world) picks the nearest lamps when more than `lit` exist */
|
|
175
|
+
export type LampUpdate = (time: number, eye?: THREE.Vector3Like) => void;
|
|
176
|
+
|
|
159
177
|
/**
|
|
160
|
-
* The look's lamps (B2):
|
|
161
|
-
*
|
|
162
|
-
*
|
|
178
|
+
* The look's lamps (B2): a pool of at most `lit` shadowless point lights (AP28: 16 on a desktop, `PHONE_LAMPS` on a phone),
|
|
179
|
+
* physical decay unless a lamp sets its own (M4.3). The pool's size never changes, so no shader recompiles as lamps come and
|
|
180
|
+
* go: `update` gives its lights to the lamps nearest `eye`, places each following lamp (AP24b) at its offset in its actor's
|
|
181
|
+
* or bone's frame (dark while that actor is absent), and flickers the lamps that declare a flicker (two incommensurate sines
|
|
182
|
+
* per lamp, so no two pulse together). It is null when nothing moves: at most `lit` fixed lamps and no flicker, drawn
|
|
183
|
+
* exactly as before.
|
|
163
184
|
*/
|
|
164
|
-
export function lampLights(lamps: readonly LookLamp[]): THREE.Group & { update:
|
|
165
|
-
const group = Object.assign(new THREE.Group(), { update: null as
|
|
185
|
+
export function lampLights(lamps: readonly LookLamp[], lit: number = DESKTOP_LAMPS): THREE.Group & { update: LampUpdate | null } {
|
|
186
|
+
const group = Object.assign(new THREE.Group(), { update: null as LampUpdate | null });
|
|
166
187
|
group.name = 'look-light-lamps';
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
light.
|
|
188
|
+
const rows = lamps.map((lamp, i) => ({ lamp, phase: i * 2.399, at: new THREE.Vector3(...lamp.at), place: new THREE.Vector3(...lamp.at), live: lamp.follow === undefined,
|
|
189
|
+
colour: new THREE.Color().setRGB(lamp.colour[0], lamp.colour[1], lamp.colour[2], THREE.LinearSRGBColorSpace) }));
|
|
190
|
+
const pool = rows.slice(0, Math.max(0, Math.min(rows.length, lit))).map((row) => {
|
|
191
|
+
const light = new THREE.PointLight(row.colour, row.live ? row.lamp.intensity : 0, row.lamp.distance, row.lamp.decay ?? 2);
|
|
192
|
+
light.position.copy(row.place); light.castShadow = false;
|
|
171
193
|
group.add(light);
|
|
172
|
-
|
|
194
|
+
return light;
|
|
173
195
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
196
|
+
const following = rows.filter((row) => row.lamp.follow !== undefined), crowded = rows.length > pool.length;
|
|
197
|
+
const flickers = rows.some((row) => (row.lamp.flicker?.amount ?? 0) > 0);
|
|
198
|
+
if (following.length === 0 && !crowded && !flickers) return group;
|
|
199
|
+
const eyeLocal = new THREE.Vector3(), chosen: typeof rows = [];
|
|
200
|
+
group.update = (time, eye) => {
|
|
201
|
+
if (following.length > 0) {
|
|
202
|
+
const resolve = lampFollows.get(rootOf(group));
|
|
203
|
+
for (const row of following) {
|
|
204
|
+
const follow = row.lamp.follow, target = follow === undefined || resolve === undefined ? null : resolve(follow.actor, follow.bone);
|
|
205
|
+
row.live = target !== null;
|
|
206
|
+
// the bone's world matrix is renewed only inside render: renew it here, or the lamp trails a frame behind (review)
|
|
207
|
+
if (target !== null) { target.updateWorldMatrix(true, false); group.updateWorldMatrix(true, false); group.worldToLocal(target.localToWorld(row.place.copy(row.at))); }
|
|
179
208
|
}
|
|
180
|
-
}
|
|
181
|
-
|
|
209
|
+
}
|
|
210
|
+
chosen.length = 0;
|
|
211
|
+
for (const row of rows) if (row.live) chosen.push(row);
|
|
212
|
+
if (crowded && eye !== undefined) {
|
|
213
|
+
group.worldToLocal(eyeLocal.copy(eye));
|
|
214
|
+
chosen.sort((a, b) => a.place.distanceToSquared(eyeLocal) - b.place.distanceToSquared(eyeLocal));
|
|
215
|
+
}
|
|
216
|
+
pool.forEach((light, i) => {
|
|
217
|
+
const row = chosen[i];
|
|
218
|
+
if (row === undefined) { light.intensity = 0; return; }
|
|
219
|
+
const flicker = row.lamp.flicker;
|
|
220
|
+
light.color.copy(row.colour); light.distance = row.lamp.distance; light.decay = row.lamp.decay ?? 2; light.position.copy(row.place);
|
|
221
|
+
if (flicker === undefined || flicker.amount <= 0) { light.intensity = row.lamp.intensity; return; }
|
|
222
|
+
const w = Math.sin(time * flicker.rate * 2.1 + row.phase) * 0.6 + Math.sin(time * flicker.rate * 5.3 + row.phase * 1.7) * 0.4;
|
|
223
|
+
light.intensity = row.lamp.intensity * (1 - flicker.amount * 0.5 + flicker.amount * 0.5 * w);
|
|
224
|
+
});
|
|
225
|
+
};
|
|
182
226
|
return group;
|
|
183
227
|
}
|
|
184
228
|
|
|
@@ -19,7 +19,7 @@ import { loadingCacheText, loadingDownloadText, loadingDownloadFraction, loading
|
|
|
19
19
|
import { LoadingTimeline, installLoadingTimeline, type LoadingPath, type LoadingRow, type LoadingGap } from '../../../shared/engine/boot/timeline';
|
|
20
20
|
import {loadingFraction} from '../boot/weights';
|
|
21
21
|
import {TimeLeftClock,timeLeftSeconds,timeLeftText} from '../boot/timeLeft';
|
|
22
|
-
import {diagnosticBuild,diagnosticStep
|
|
22
|
+
import {compactBootDiagnostics,diagnosticBuild,diagnosticStep} from '../boot/diagnostics';
|
|
23
23
|
import { isDev, onDev } from '../core/devMode';
|
|
24
24
|
import { getSetting, onSetting } from './Settings';
|
|
25
25
|
import { listenTap } from '../input/dom';
|
|
@@ -715,14 +715,13 @@ export class Loading {
|
|
|
715
715
|
for (const [key, ms] of Object.entries(times)) setData(this.root, `${key}Ms`, String(Math.round(ms)));
|
|
716
716
|
}
|
|
717
717
|
|
|
718
|
-
/** LS4:
|
|
718
|
+
/** LS4/NB15: the card facts and a compact LS1 digest for Jake to paste. */
|
|
719
719
|
diagnosticsText(): string {
|
|
720
|
-
const localTiming = bootTiming()?.read(), timing=
|
|
721
|
-
const all = this.timeline.snapshot()
|
|
720
|
+
const localTiming = bootTiming()?.read(), timing=compactBootDiagnostics(localTiming), transfer = this.downloadProgress(), times = this.phaseTimes();
|
|
721
|
+
const all = this.timeline.snapshot();
|
|
722
722
|
const lines = [
|
|
723
723
|
`Wildshard boot diagnostics · ${new Date().toISOString()}`,
|
|
724
|
-
|
|
725
|
-
...(Array.isArray(summary) ? summary.filter((line): line is string => typeof line === 'string') : []),
|
|
724
|
+
...timing.summary,
|
|
726
725
|
`build ${diagnosticBuild(localTiming?.build)} · ${this.tierText()} · ${innerWidth}x${innerHeight} @${devicePixelRatio}x · ${this.lowPowerLine()}`,
|
|
727
726
|
`total ${seconds(times.total)} · start ${seconds(times.start)} · download ${seconds(times.download)} · load ${seconds(times.load)}${this.finished ? '' : ' · not ready'}`,
|
|
728
727
|
`download ${loadingCacheText(transfer)} · files ${transfer.filesDone} of ${transfer.filesTotal} · ${transfer.complete ? 'complete' : 'open'}${transfer.error === null ? '' : ' · error (private text omitted)'}`,
|
|
@@ -732,8 +731,7 @@ export class Loading {
|
|
|
732
731
|
...all.rows.map(row => ` ${row.number}. ${diagnosticStep(row.key,row.number)} · ${row.state} · ${Math.round(row.ms)} ms`),
|
|
733
732
|
...all.gaps.map(gap => ` gap · ${gap.state} · ${Math.round(gap.ms)} ms`),
|
|
734
733
|
'This page\'s files are named by path; other URLs use local report IDs; free text, details and errors are omitted.',
|
|
735
|
-
|
|
736
|
-
JSON.stringify(timing ?? null),
|
|
734
|
+
...timing.timeline,
|
|
737
735
|
];
|
|
738
736
|
return lines.join('\n');
|
|
739
737
|
}
|
|
@@ -19,7 +19,7 @@ export function lookLightSaved(): boolean {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Whether the settings draw on this page: the row on. TEMPLATES-CLEANROOM M4.9: the phone tier draws them too, gated per
|
|
22
|
-
* field (`lookLightManifest`: no bloom or AO,
|
|
22
|
+
* field (`lookLightManifest`: no bloom or AO, the nearest 4 lamps lit, half the motes), not all or nothing; `tier` stays for callers.
|
|
23
23
|
*/
|
|
24
24
|
export function lookLightOn(_tier: string = TIER): boolean { return lookLightSaved(); }
|
|
25
25
|
/** Save the row's value (the page reloads to apply it). */
|
|
@@ -4,6 +4,7 @@ import { parse } from 'valibot';
|
|
|
4
4
|
import type { Game } from '@wildshard/engine/core/Game';
|
|
5
5
|
import type { Scope } from '@wildshard/engine/app/scope';
|
|
6
6
|
import type { CombatCues } from '@wildshard/engine/combat/cues';
|
|
7
|
+
import { audioLog } from '@wildshard/engine/audio/audioLog';
|
|
7
8
|
import { Impacts } from '@wildshard/engine/fx/Impacts';
|
|
8
9
|
import { effectField, type EffectField } from '@wildshard/engine/fx/effectField';
|
|
9
10
|
import { ParticlePool, pointScale } from '@wildshard/engine/fx/ParticlePool';
|
|
@@ -151,7 +152,7 @@ export class CueDirector {
|
|
|
151
152
|
}
|
|
152
153
|
if (row.sound !== undefined) {
|
|
153
154
|
if (this.sounds === undefined) throw new Error('Cue sound owner is absent');
|
|
154
|
-
this.sounds.cue(row.sound as `cue.${string}`, row.soundPhase === undefined ? {} : { phase: row.soundPhase });
|
|
155
|
+
audioLog('cue', row.id, this.sounds.cue(row.sound as `cue.${string}`, row.soundPhase === undefined ? {} : { phase: row.soundPhase }), row.sound);
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
}
|
|
@@ -87,9 +87,10 @@ export function pageArenaRoomFight(ctx: ShardContext, dungeon: BossArenaRoom, in
|
|
|
87
87
|
const { animals } = play, owner = bindRuntimeBoss(ctx, ctx.product.shardfile, rows.body, undefined, { identity: rows.identity }), binding = views(rows.presentation);
|
|
88
88
|
// The server's fight runs, and its looks reach this room as it told them. A room nobody has entered has nothing built to draw on.
|
|
89
89
|
wirePage.whenLive(ctx.scope, client => client.onView(({ name, args }) => {
|
|
90
|
-
if (!dungeon.built) return;
|
|
90
|
+
if (!dungeon.built) { if (binding[name] !== undefined) wirePage.unbuilt(name); return; }
|
|
91
91
|
if (name === 'boss.glow') dungeon.actor = animals.animals.find(actor => actor.rowDriven && actor.kind === owner.row.kind) ?? null; // the server's body is the row's
|
|
92
|
-
binding[name]
|
|
92
|
+
const draw = binding[name];
|
|
93
|
+
if (draw !== undefined) { draw(...args); wirePage.drew(name); }
|
|
93
94
|
}));
|
|
94
95
|
return rowFightScript({ rewardPoint: () => new Vector3().fromArray(rows.reward), respawnPoint: () => ({ pos: new Vector3().fromArray(rows.respawn), yaw: rows.yaw }) });
|
|
95
96
|
}
|
|
@@ -204,7 +205,7 @@ export class ArenaRoomEncounter {
|
|
|
204
205
|
if(encounter.boss.rewardTaken)kit.upgradeBow('bow-reward',play.weapons);
|
|
205
206
|
}else{
|
|
206
207
|
if(this.prompt===null||this.projection===null)throw new Error('Missing open arena projection');runtime.interactables.push(this.prompt);
|
|
207
|
-
{const word=arenaTieWord(this.data.definition.id),lines=this.data.tieLines,heard=this.projection;wirePage.whenLive(ctx.scope,client=>client.onView(({name,args})=>{const line=name===word?lines[args[0]??-1]:undefined;if(line!==undefined)play.hud.toast(line);if(name.startsWith('open-arena.')){heard.hear(name,args);wirePage.drew(name);}}));}
|
|
208
|
+
{const word=arenaTieWord(this.data.definition.id),lines=this.data.tieLines,heard=this.projection;wirePage.whenLive(ctx.scope,client=>client.onView(({name,args})=>{const line=name===word?lines[args[0]??-1]:undefined;if(line!==undefined){play.hud.toast(line);wirePage.drew(name);}if(name.startsWith('open-arena.')){heard.hear(name,args);wirePage.drew(name);}}));}
|
|
208
209
|
if(encounter.boss.rewardTaken){if(blade===null)throw new Error('Missing open arena power');kit.upgradeBlade('blade-reward',play.weapons,blade);}
|
|
209
210
|
page.boundary(ctx.scope,this.projection.boundary);page.lendOpenView(this.projection,ctx.scope);
|
|
210
211
|
}
|
|
@@ -101,7 +101,7 @@ function followRoamingFight(context: ShardContext, { rows, ring, hazard, cues, l
|
|
|
101
101
|
hazardFrom.set(fromX, fromY, fromZ); hazard(index, { x, y, z, fallT }, t, beat);
|
|
102
102
|
},
|
|
103
103
|
};
|
|
104
|
-
wirePage.whenLive(context.scope, client => client.onView(({ name, args }) => { actions[name]
|
|
104
|
+
wirePage.whenLive(context.scope, client => client.onView(({ name, args }) => { const act = actions[name]; if (act !== undefined) { act(args); wirePage.drew(name); } }));
|
|
105
105
|
context.system({ id: 'roaming.followed', phase: 'update', run: (dt, t) => {
|
|
106
106
|
room(dt, t);
|
|
107
107
|
for (const [slot, row] of lanes.entries()) {
|
|
@@ -241,7 +241,7 @@ export function createDevHook(ports: DevHookPorts): DevHook & { readonly root: T
|
|
|
241
241
|
group.add(lamps);
|
|
242
242
|
owned.push({ dispose: () => { for (const light of lamps.children) if (light instanceof THREE.Light) light.dispose(); } });
|
|
243
243
|
const { update } = lamps;
|
|
244
|
-
if (update !== null) { let time = 0; partScope.onDispose(ports.watchFrames(dt => { time += dt; update(time); })); }
|
|
244
|
+
if (update !== null) { let time = 0; partScope.onDispose(ports.watchFrames(dt => { time += dt; update(time, ports.player?.()?.position); })); }
|
|
245
245
|
}
|
|
246
246
|
// the client's own water surfaces, under this part's scope
|
|
247
247
|
installClientWater(part.water, { root: group, scope: partScope, frame: run => { partScope.onDispose(ports.watchFrames(run)); } });
|
|
@@ -16,6 +16,6 @@ export function shardfileLiveLook(look: Shardfile['look'], light: boolean = look
|
|
|
16
16
|
return { day: look.day ?? DATA_LOOK_DAY, dayOverride: look.dayOverride, keys: look.keys, lut: look.grade.lut === null ? null : shardfileFileUrl(look.grade.lut),
|
|
17
17
|
neutral: look.grade.tone === 'neutral', aces: look.grade.tone === 'aces', exposure: look.grade.exposure, vignette: look.grade.vignette ?? null, bloomRadius: resolved.bloom.radius,
|
|
18
18
|
bloom: resolved.bloom,
|
|
19
|
-
light: { rim: resolved.rim, pools: resolved.pools, heightFogDensity: resolved.atmosphere.fogHeightDensity, lamps: resolved.lamps, bounce: resolved.bounce, environment: resolved.environment,
|
|
19
|
+
light: { rim: resolved.rim, pools: resolved.pools, heightFogDensity: resolved.atmosphere.fogHeightDensity, lamps: resolved.lamps, lampsLit: resolved.lampsLit, bounce: resolved.bounce, environment: resolved.environment,
|
|
20
20
|
shadow: resolved.shadow, motes: resolved.motes } };
|
|
21
21
|
}
|
|
@@ -17,7 +17,7 @@ import { EquipmentService } from '@wildshard/engine/combat/EquipmentService';
|
|
|
17
17
|
import type { Weapon } from '@wildshard/engine/combat/Weapon';
|
|
18
18
|
import { playerModes } from '@wildshard/engine/player/modes';
|
|
19
19
|
import type { Shardfile } from '@wildshard/format/shardSchema';
|
|
20
|
-
import { installDeclaredItems, leverLines } from '../../../shared/game/shardfile/items';
|
|
20
|
+
import { installDeclaredItems, leverLines, rackMeleeRows, takenLine } from '../../../shared/game/shardfile/items';
|
|
21
21
|
import { declaredItemIcon, declaredKitItemFamilies, declaredLever } from '../plugin/weaponFamily';
|
|
22
22
|
import { itemScene } from '../shardfile/clientItems';
|
|
23
23
|
import { loadItemModels } from '../shardfile/itemModels';
|
|
@@ -76,6 +76,10 @@ export async function enterDataCellKit(source: Shardfile, assets: ReadonlyMap<st
|
|
|
76
76
|
kit.enabled = enabled; kit.visible = visible; kit.stowed = false;
|
|
77
77
|
// TE-ENG2: a lever follows the server's owned lines; taken, it unlocks and comes to hand
|
|
78
78
|
const levers = weapons.flatMap(weapon => { const lever = declaredLever(weapon); return lever === null ? [] : [lever]; });
|
|
79
|
+
// TEMPLATE-E2E TC-E4: a melee weapon on a rack follows its owned taken line the same way
|
|
80
|
+
// the server's set exactly (never the loadout primary). A kit with no primary whose first weapon is racked still draws it
|
|
81
|
+
// in hand (a kit cannot lock its first); the server refuses its blows until it is taken
|
|
82
|
+
const onRacks = rackMeleeRows(source), racked = new Set(weapons.filter(weapon => onRacks.has(weapon.id)));
|
|
79
83
|
app.addContentSystem({ id: 'grid.data-cell-kit', phase: 'update', run: (dt, t) => {
|
|
80
84
|
for (const lever of levers) {
|
|
81
85
|
if (wirePage.client !== null && here()) {
|
|
@@ -84,6 +88,10 @@ export async function enterDataCellKit(source: Shardfile, assets: ReadonlyMap<st
|
|
|
84
88
|
}
|
|
85
89
|
if (lever.taken && !kit.has(lever.id)) { kit.unlock(lever.id); kit.select(lever.id); }
|
|
86
90
|
}
|
|
91
|
+
if (wirePage.client !== null && here()) for (const weapon of racked) {
|
|
92
|
+
if (wirePage.line(takenLine(weapon.id)) <= 0) continue;
|
|
93
|
+
racked.delete(weapon); if (!kit.has(weapon.id)) { kit.unlock(weapon.id); kit.select(weapon.id); }
|
|
94
|
+
}
|
|
87
95
|
kit.update(dt, t);
|
|
88
96
|
} }, entry);
|
|
89
97
|
entry.onDispose(() => { kit.enabled = false; kit.visible = false; kit.adsHeld = false; kit.altHeld = false; });
|
|
@@ -179,24 +179,38 @@ export function gridShardfileFarBytes(slug: string): Promise<number | null> | nu
|
|
|
179
179
|
* GLB), look/look (the haze colour) and world/collision sections, and the far files, each hash-verified, without admitting
|
|
180
180
|
* the whole product first (its admission, ~8-20 s a product at 4x CPU, held every shardfile neighbour's far proxy and so the
|
|
181
181
|
* grid reveal's ringsReady). No residency claim: the far ring's own lease charges the proxy. Null when the slug has no
|
|
182
|
-
* shardfile or no mesh-collision world (its far proxy is the baked folder's)
|
|
182
|
+
* shardfile or no mesh-collision world (its far proxy is the baked folder's), unless `anyWorld` (no baked folder): then
|
|
183
|
+
* null only when the product's tiles carry no far row.
|
|
183
184
|
*/
|
|
184
|
-
export function readGridShardfileFar(slug: string): Promise<GridShardfileFar | null> {
|
|
185
|
+
export function readGridShardfileFar(slug: string, anyWorld = false): Promise<GridShardfileFar | null> {
|
|
185
186
|
const descriptor = findShard(slug)?.shardfile;
|
|
186
187
|
if (descriptor === undefined) return Promise.resolve(null);
|
|
187
188
|
const url = new URL(descriptor, location.href);
|
|
188
|
-
return readGridProductFar(url.href, slug, browserShardfileOptions(new URL('.', url).href, true));
|
|
189
|
+
return readGridProductFar(url.href, slug, browserShardfileOptions(new URL('.', url).href, true), anyWorld);
|
|
189
190
|
}
|
|
190
191
|
/** A shardfile far proxy's rows and a verified reader for its declared far files. */
|
|
191
192
|
export interface GridShardfileFar { readonly rows: ShardfileFarRows; readonly read: (ref: string) => Promise<Uint8Array> }
|
|
192
|
-
/** `readGridShardfileFar` for one product URL (null: no mesh-collision world, so its far proxy is the baked folder's).
|
|
193
|
-
|
|
193
|
+
/** `readGridShardfileFar` for one product URL (null: no mesh-collision world, unless `anyWorld`, so its far proxy is the baked folder's).
|
|
194
|
+
* `anyWorld`: the build baked no far folder for this slug, so any world's own far row is read (TEMPLATE-E2E: Brasscap rev 5
|
|
195
|
+
* has no mesh collision and no repo bake; null then only when its tiles carry no far row). */
|
|
196
|
+
export async function readGridProductFar(url: string, identity: string, options: ProductOptions, anyWorld = false): Promise<GridShardfileFar | null> {
|
|
194
197
|
const at = await readGridProductIndex(url, identity, options);
|
|
195
198
|
const collision = await readGridSection(at, 'world/collision');
|
|
196
|
-
|
|
199
|
+
const mesh = collision !== null && v.parse(farRows.collision, collision).meshCollision !== null;
|
|
200
|
+
if (!mesh && !anyWorld) return null;
|
|
197
201
|
const [tiles, props, look] = await Promise.all([readGridSection(at, 'world/tiles'), readGridSection(at, 'world/props'), readGridSection(at, 'look/look')]);
|
|
198
202
|
const fog = look === null ? null : v.parse(farRows.look, look).look.keys[0]?.fog.colour ?? null;
|
|
199
|
-
const
|
|
203
|
+
const far = tiles === null ? null : v.parse(farRows.tiles, tiles).far;
|
|
204
|
+
const declared = props === null ? null : v.parse(farRows.props, props).props?.far ?? null;
|
|
205
|
+
const isGlb = (ref: string): boolean => {
|
|
206
|
+
const hash = ref.replace(/^commons:/u, ''), commons = ref.startsWith('commons:');
|
|
207
|
+
return at.index.files.some(row => row.hash === hash && (row.commons === true) === commons && row.kind === 'glb');
|
|
208
|
+
};
|
|
209
|
+
// A mesh-collision world keeps its rows as they are. Any other world (a scene upload) has no props row naming its far GLB,
|
|
210
|
+
// so it is the first far file the index lists as a GLB; with none, its far proxy is the baked folder's after all.
|
|
211
|
+
const farRef = declared ?? (mesh || far === null ? null : far.files.find(isGlb) ?? null);
|
|
212
|
+
if (!mesh && (far === null || farRef === null)) return null;
|
|
213
|
+
const rows: ShardfileFarRows = { far, farRef, fog };
|
|
200
214
|
const read = (ref: string): Promise<Uint8Array> => {
|
|
201
215
|
const hash = ref.replace(/^commons:/u, ''), commons = ref.startsWith('commons:');
|
|
202
216
|
const file = at.index.files.find(row => row.hash === hash && (row.commons === true) === commons);
|