Repository navigation
Expand file tree
/
Copy pathEngineProxy.js
More file actions
513 lines (480 loc) · 21.7 KB
/
Copy pathEngineProxy.js
File metadata and controls
513 lines (480 loc) · 21.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
import { hasStoredPerfSettings, loadPerfSettings, savePerfSettings } from './render/PerformanceSettings.js';
import { InputFrameBridge } from './InputFrameBridge.js';
import { MinimapPresenter } from './MinimapPresenter.js';
import { saveBlob } from '../platform/DesktopBridge.js';
import { exportError } from '../export/ExportDiagnostics.js';
import { parseShaderBenchmarkOptions } from './render/ShaderBenchmark.js';
const DEVELOPMENT_WORKER_OVERRIDE = import.meta.env.DEV && typeof location !== 'undefined'
? new URLSearchParams(location.search).get('workerRenderer')
: null;
// ---------------------------------------------------------------------------
// Boot shader-link policy (render worker only).
// Chrome only WRITES a WebGL program to its on-disk shader cache when the link
// is resolved synchronously (KHR_parallel_shader_compile links are never
// stored), but asynchronous links DO read cached programs. Measured on the
// reference GPU: an uncached boot compiles the terrain for ~7-10 s every
// launch; once cached, a boot is ready in ~1 s. A synchronous link runs on the
// browser's GPU main thread (page presentation pauses for the compile, and a
// very long one could trip the GPU watchdog), so it is used sparingly:
// * boots are asynchronous by default (no freeze, watchdog-safe);
// * after an async boot that missed the cache (compile >= CACHE_MISS_MS) and
// was comfortably short (< SAFE_MS), the NEXT boot links synchronously
// once to populate the cache; the boot after that is async again and reads
// it. A shader update therefore costs one cache-filling launch.
// * a synchronous boot that never completes falls back to async.
const BOOT_SHADER_RECORD_KEY = 'terrain-studio-boot-shaders-v1';
export const SYNC_BOOT_LINK_SAFE_MS = 12000;
export const BOOT_CACHE_MISS_MS = 2000;
function readBootShaderRecord() {
try {
const raw = localStorage.getItem(BOOT_SHADER_RECORD_KEY);
return raw ? JSON.parse(raw) : null;
} catch {
return null;
}
}
function writeBootShaderRecord(record) {
try { localStorage.setItem(BOOT_SHADER_RECORD_KEY, JSON.stringify(record)); } catch { /* storage unavailable */ }
}
export function chooseBootLinkMode(record = readBootShaderRecord()) {
if (!record || record.pendingSync || record.linkMode === 'sync') return 'async';
const compileMs = Number(record.compileMs);
return Number.isFinite(compileMs)
&& compileMs >= BOOT_CACHE_MISS_MS
&& compileMs < SYNC_BOOT_LINK_SAFE_MS
? 'sync' : 'async';
}
function markBootLinkAttempt(mode) {
if (mode !== 'sync') return;
writeBootShaderRecord({ ...(readBootShaderRecord() || {}), pendingSync: true });
}
export function recordBootShaderStats(stats) {
const compileMs = Number(stats?.compileMs);
if (!Number.isFinite(compileMs)) return;
writeBootShaderRecord({
compileMs: Math.round(compileMs),
linkMode: stats?.linkMode === 'sync' ? 'sync' : 'async',
at: Date.now(),
});
}
export function supportsWorkerRenderer(canvas) {
return typeof OffscreenCanvas !== 'undefined'
&& typeof canvas?.transferControlToOffscreen === 'function'
&& typeof Worker !== 'undefined';
}
export const ENGINE_METHODS = Object.freeze([
'addManualShapeLayer', 'applyErosionPreset', 'applyNoisePresetByKey',
'buildAndSetSurfaceAtlas',
'applyNoiseStackPresetByKey', 'applyPalettePresetByKey', 'applyPlanetPresetByKey',
'applyPresetByKey', 'applyWaterBaselineScene', 'bakeErosion', 'beginManualShapeDrag',
'cancelSplineCreation', 'capturePreviewThumbnail', 'captureWaterBaseline',
'clearErosion', 'clearExplosions', 'clearManualPropPaint', 'clearManualSculpt',
'clearManualTexturePaint', 'clearPaintLayers', 'confirmSplineCreation',
'createProjectPayload', 'createSnapshot', 'createSpline', 'deleteManualShape',
'deleteManualShapeLayer', 'deleteSnapshot', 'deleteSpline', 'duplicateManualShape',
'duplicateManualShapeLayer', 'duplicateSpline', 'endManualShapeDrag',
'export3DTerrain', 'exportHeightmap', 'exportPlanetStyle', 'exportScreenshot',
'exportWaterMasks', 'focusCenter', 'generatePalette', 'getCachedSurfaceAtlas',
'getClientSnapshot', 'getMinimapInfoAt', 'getPerfDiagnostics', 'getTargetTerrainVariant',
'getGraphicsDiagnostics',
'hasErosionResult', 'importPlanetStyleJSON', 'importTileMap', 'installCachedSurfaceAtlas',
'clearReferenceImage',
'getMinimapFrame',
'loadRealWorldCustom', 'loadRealWorldLocation', 'setRealWorldResolution', 'loadSeedJSON', 'moveManualShape',
'moveManualShapeLayer', 'newProject', 'randomizePlanetPreset', 'randomizeSeed',
'regenerate', 'removeTile', 'renameSnapshot', 'resetPanelSettings', 'resetPerfSettings',
'resetView', 'restoreSnapshot', 'restoreState', 'retryBoot', 'selectManualShape',
'selectSpline', 'serializeErosion', 'serializeManualSculpt', 'serializeManualSurface',
'serializePaint', 'serializeState', 'setAnalysisMode', 'setAnalysisSettings',
'setAutoRotate', 'setBehindCameraCulling', 'setCameraMode', 'setCameraView',
'setClientState', 'setCloudQuality', 'setCullingEnabled', 'setDebugFlag',
'setExplodeSetting', 'setExplodeToolEnabled', 'setExploreMode', 'setFov',
'setGraphView', 'setLandingShowcase', 'setManualPlacementType',
'setManualSculptEnabled', 'setManualSculptSetting', 'setManualTexturePaintEnabled',
'setManualTexturePaintSetting', 'setManualTransformMode', 'setManualWorkspaceActive',
'setPerformanceProfilerActive',
'setMinimapCanvases', 'setMinimapConfig', 'setMinimapHover', 'setNoiseStack',
'setPaintBaseMode', 'setPaintMode', 'setPaintSetting', 'setParam', 'setPerfPreset',
'setPerfSetting', 'setPlanetStyleColor', 'setPlanetStyleTuning', 'setQuality',
'refreshCityMarkers', 'setMarkerRoutePicking', 'selectMarkerForRoute',
'setRealWorldMarkers', 'setRealWorldBuildingsVisible', 'setRealWorldImageryStyle', 'setSoloLayer',
'setSplineEditingEnabled', 'setSurfaceAtlas', 'setTerrainGraph', 'setTileAssemblyShape',
'setTileDebug', 'setTileMapSetting', 'setTimeOfDay', 'setTouchInput', 'setViewport',
'smoothExplosionEdges', 'startEmptyTerrain', 'transitionMode', 'updateManualShape',
'updateManualShapeLayer', 'updateSpline', 'applyInputFrame',
'getMiniTerrain', 'setMiniTerrain', 'regenerateMiniTerrain', 'frameMiniTerrain',
'saveMiniView', 'removeMiniView', 'goToMiniView',
]);
const cloneError = (payload) => {
const error = new Error(payload?.message || 'Engine command failed');
error.name = payload?.name || 'Error';
error.code = payload?.code;
error.stack = payload?.stack || error.stack;
return error;
};
export class MainThreadEngineTransport {
constructor() { this.engine = null; }
async initialize(options) {
const { Engine } = await import('./EnergySavingEngine.js');
this.engine = new Engine(options);
return this.engine.getClientSnapshot();
}
invoke(method, args = [], { signal } = {}) {
const fn = this.engine?.[method];
if (typeof fn !== 'function') throw new Error(`Unknown engine method: ${method}`);
const result = fn.apply(this.engine, args);
if (!signal || !result?.then) return result;
return Promise.race([
result,
new Promise((_, reject) => signal.addEventListener('abort', () => reject(
Object.assign(new Error('Engine command cancelled'), { code: 'ENGINE_COMMAND_CANCELLED' }),
), { once: true })),
]);
}
snapshot() { return this.engine?.getClientSnapshot?.() || null; }
async dispose() { this.engine?.dispose?.(); this.engine = null; }
}
export class WorkerEngineTransport {
constructor() {
this.worker = null;
this.failure = null;
this.disposed = false;
this.pending = new Map();
this.nextId = 1;
this.nextCallbackId = 1;
this.surfaceAtlasRevision = 0;
this.remoteCallbacks = new Map();
this.onEvent = null;
this.inputBridge = null;
this.minimapPresenter = new MinimapPresenter();
this.minimapPresenter.requestFrame = () => this._request('invoke', ['getMinimapFrame', []]);
}
initialize(options) {
const canvas = options.canvas;
const offscreen = canvas.transferControlToOffscreen();
const rect = canvas.parentElement?.getBoundingClientRect?.() || canvas.getBoundingClientRect();
this.worker = new Worker(new URL('./engine.worker.js', import.meta.url), { type: 'module' });
this.worker.onmessage = ({ data }) => this._message(data);
this.worker.onerror = (event) => this._handleFailure(
Object.assign(new Error(event.message || 'Render worker failed'), { code: 'ENGINE_WORKER_FAILED' }),
);
this.worker.onmessageerror = () => this._handleFailure(
Object.assign(new Error('Render worker message could not be decoded'), { code: 'ENGINE_WORKER_FAILED' }),
);
const initialized = this._request('initialize', [{
canvas: offscreen,
initialParams: options.initialParams,
initialPerf: options.initialPerf,
perfSettingsStored: options.perfSettingsStored,
initialView: options.initialView,
initialBootMode: options.initialBootMode,
coldShaderRun: options.coldShaderRun,
shaderBenchmark: options.shaderBenchmark,
bootLinkMode: options.bootLinkMode,
viewport: {
width: Math.max(1, rect.width),
height: Math.max(1, rect.height),
pixelRatio: globalThis.devicePixelRatio || 1,
visible: document.visibilityState === 'visible',
},
}], [offscreen]);
this.inputBridge = new InputFrameBridge({
canvas,
send: (method, args) => this.invoke(method, args),
});
return initialized.then((snapshot) => {
this.inputBridge?.setPointerLockEnabled(snapshot?.pointerLockEnabled);
return snapshot;
});
}
invoke(method, args = [], { transfer = [], signal } = {}) {
if (method === 'setMinimapCanvases') {
this.minimapPresenter.setCanvases(args[0], args[1]);
return null;
}
if (method === 'buildAndSetSurfaceAtlas') return this._buildSurfaceAtlas(args[0], signal);
const callbackIds = [];
const encodedArgs = this._encodeCallbacks(args, callbackIds);
const result = this._request('invoke', [method, encodedArgs], transfer, signal);
if (method === 'setMinimapConfig' || method === 'setMinimapHover') {
Promise.resolve(result).finally(() => this.minimapPresenter.refresh());
}
return Promise.resolve(result).finally(() => {
callbackIds.forEach((id) => this.remoteCallbacks.delete(id));
});
}
async _buildSurfaceAtlas(source, signal) {
const revision = ++this.surfaceAtlasRevision;
const { captureSurfaceAtlasMaps, surfaceAtlasSuperseded } = await import('./terrain/surface/SurfaceAtlasBridge.js');
const maps = await captureSurfaceAtlasMaps(source, { signal });
if (signal?.aborted) throw Object.assign(new Error('Engine command cancelled'), { code: 'ENGINE_COMMAND_CANCELLED' });
if (revision !== this.surfaceAtlasRevision) throw surfaceAtlasSuperseded();
return this._request('invoke', ['buildAndSetSurfaceAtlas', [source, maps, revision]], [], signal);
}
_encodeCallbacks(value, callbackIds, seen = new WeakMap()) {
if (typeof value === 'function') {
const id = this.nextCallbackId++;
callbackIds.push(id);
this.remoteCallbacks.set(id, value);
return { __terrainCallback: id };
}
if (!value || typeof value !== 'object' || value instanceof Blob
|| value instanceof ArrayBuffer || ArrayBuffer.isView(value)) return value;
if (seen.has(value)) return seen.get(value);
const output = Array.isArray(value) ? [] : {};
seen.set(value, output);
for (const [key, child] of Object.entries(value)) {
output[key] = this._encodeCallbacks(child, callbackIds, seen);
}
return output;
}
_request(type, args, transfer = [], signal = null) {
if (this.disposed) {
return Promise.reject(Object.assign(new Error('Engine client disposed'), { code: 'ENGINE_DISPOSED' }));
}
if (this.failure) return Promise.reject(this.failure);
if (!this.worker) {
return Promise.reject(Object.assign(new Error('Render worker is unavailable'), { code: 'ENGINE_WORKER_FAILED' }));
}
const id = this.nextId++;
const promise = new Promise((resolve, reject) => {
const abort = () => {
if (!this.pending.delete(id)) return;
this.worker?.postMessage?.({ type: 'cancel', id });
reject(Object.assign(new Error('Engine command cancelled'), { code: 'ENGINE_COMMAND_CANCELLED' }));
};
this.pending.set(id, { resolve, reject, signal, abort });
signal?.addEventListener?.('abort', abort, { once: true });
});
this.worker.postMessage({ type, id, args }, transfer);
return promise;
}
_message(data) {
if (data?.type === 'exitPointerLock') {
this.inputBridge?.exitPointerLock();
return;
}
if (data?.type === 'callback') {
this.remoteCallbacks.get(data.callbackId)?.(...(data.args || []));
return;
}
if (data?.type === 'event') {
if (data.snapshot) this.inputBridge?.setPointerLockEnabled(data.snapshot.pointerLockEnabled);
this.onEvent?.(data.event, data.args || [], data.snapshot || null, data.seq);
if (data.event === 'onCamera' || data.event === 'onParams' || data.event === 'onTiles') {
void this.minimapPresenter.refresh();
}
return;
}
const pending = this.pending.get(data?.id);
if (!pending) return;
this.pending.delete(data.id);
pending.signal?.removeEventListener?.('abort', pending.abort);
if (data.type === 'error') pending.reject(cloneError(data.error));
else pending.resolve(data.result);
}
_failAll(error) {
for (const pending of this.pending.values()) {
pending.signal?.removeEventListener?.('abort', pending.abort);
pending.reject(error);
}
this.pending.clear();
}
_handleFailure(error) {
if (this.failure || this.disposed) return;
this.failure = error;
this.inputBridge?.dispose?.();
this.inputBridge = null;
this.minimapPresenter.setCanvases(null, null);
this.worker?.terminate?.();
this.worker = null;
this.remoteCallbacks.clear();
this._failAll(error);
}
async dispose() {
if (this.disposed) return;
this.inputBridge?.dispose?.();
this.inputBridge = null;
this.minimapPresenter.setCanvases(null, null);
const worker = this.worker;
if (worker && !this.failure) {
try { await this._request('dispose', []); } catch { /* worker may already be gone */ }
}
this.disposed = true;
worker?.terminate?.();
this.worker = null;
this.remoteCallbacks.clear();
this._failAll(Object.assign(new Error('Engine client disposed'), { code: 'ENGINE_DISPOSED' }));
}
}
export class EngineClient {
constructor(options, transport) {
this.options = options;
this.transport = transport;
this.snapshot = Object.freeze({});
this.listeners = new Set();
this.disposed = false;
this.workerActive = transport instanceof WorkerEngineTransport;
this.lastEventSequence = 0;
}
async initialize() {
const callbacks = this.options.callbacks || {};
const wrappedCallbacks = Object.fromEntries(Object.entries(callbacks).map(([name, callback]) => [
name,
(...args) => {
this._applyEvent(name, args);
callback?.(...args);
},
]));
if (this.transport instanceof WorkerEngineTransport) {
this.transport.onEvent = (name, args, snapshot, seq) => {
if (!this._acceptEventSequence(seq)) return;
if (snapshot) this._setSnapshot(snapshot);
this._applyEvent(name, args, seq);
if (name === 'onArtifact') {
const artifact = args[0];
const saving = saveBlob(artifact.blob, artifact.filename, { mime: artifact.mime })
.then((result) => ({ result }), (error) => ({ error: exportError(error, 'Could not save export') }));
if (this.exportArtifactSaves) this.exportArtifactSaves.push(saving);
else void saving.then(({ error }) => { if (error) callbacks.onToast?.(`Export failed: ${error.message}`); });
return;
}
callbacks[name]?.(...args);
};
}
const snapshot = await this.transport.initialize({
...this.options,
callbacks: wrappedCallbacks,
});
this._setSnapshot(snapshot);
return snapshot;
}
command(method, args = [], options = {}) {
if (this.disposed) throw Object.assign(new Error('Engine client disposed'), { code: 'ENGINE_DISPOSED' });
if (options.signal?.aborted) throw Object.assign(new Error('Engine command cancelled'), { code: 'ENGINE_COMMAND_CANCELLED' });
if (method === 'export3DTerrain') {
if (this.exportArtifactSaves) return Promise.reject(new Error('An export is already running'));
const saves = this.exportArtifactSaves = [];
return Promise.resolve().then(() => this.transport.invoke(method, args, options)).then(async (result) => {
const outcomes = await Promise.all(saves);
for (const outcome of outcomes) {
if (outcome.error) throw outcome.error;
if (outcome.result?.canceled) throw new Error('Export save was canceled');
}
return result;
}).finally(() => { this.exportArtifactSaves = null; this._refreshSnapshot(); });
}
const result = this.transport.invoke(method, args, options);
if (result && typeof result.then === 'function') return result.finally(() => this._refreshSnapshot());
this._refreshSnapshot();
return result;
}
query(method, args = [], options = {}) { return this.command(method, args, options); }
getSnapshot() { return this.snapshot; }
subscribe(listener) { this.listeners.add(listener); return () => this.listeners.delete(listener); }
_refreshSnapshot() {
const next = this.transport.snapshot?.();
if (next) this._setSnapshot(next);
}
_setSnapshot(next) {
this.snapshot = Object.freeze({ ...(next || {}) });
for (const listener of this.listeners) listener(this.snapshot);
}
_applyEvent(name, args, seq = null) {
const patch = { lastEvent: { name, seq, at: performance.now() } };
if (name === 'onParams') patch.params = args[0];
if (name === 'onPerfChange') {
patch.perf = args[0];
// Render workers have no localStorage. Persist their settings here too.
if (args[0]) savePerfSettings(args[0]);
}
if (name === 'onProjectMode') patch.projectMode = args[0];
if (name === 'onMiniTerrain') patch.miniTerrain = args[0];
if (name === 'onTimeOfDayChange') patch.timeOfDay = args[0];
if (name === 'onBootShaderStats') recordBootShaderStats(args[0]);
this._setSnapshot({ ...this.snapshot, ...patch });
}
_acceptEventSequence(seq) {
if (!Number.isFinite(seq)) return true;
if (seq <= this.lastEventSequence) return false;
this.lastEventSequence = seq;
return true;
}
async dispose() {
if (this.disposed) return;
this.disposed = true;
await this.transport.dispose();
this.listeners.clear();
this._setSnapshot({ ...this.snapshot, disposed: true });
}
}
for (const method of ENGINE_METHODS) {
if (method in EngineClient.prototype) continue;
Object.defineProperty(EngineClient.prototype, method, {
value(...args) { return this.command(method, args); },
});
}
const snapshotGetters = {
params: 'params', perf: 'perf', gpuName: 'gpuName', rendererConfig: 'rendererConfig',
rendererCapabilities: 'rendererCapabilities', worldMode: 'worldMode',
projectMode: 'projectMode', realWorldSource: 'realWorldSource', timeOfDay: 'timeOfDay',
miniTerrain: 'miniTerrain',
_soloLayerId: 'soloLayerId', _disposed: 'disposed',
};
for (const [property, snapshotKey] of Object.entries(snapshotGetters)) {
Object.defineProperty(EngineClient.prototype, property, {
get() { return this.snapshot[snapshotKey]; },
});
}
Object.defineProperty(EngineClient.prototype, 'workspacePreset', {
get() { return this.snapshot.workspacePreset; },
set(value) { void this.command('setClientState', [{ workspacePreset: value }]); },
});
Object.defineProperty(EngineClient.prototype, 'erosionField', {
get() { return { hasResult: () => !!this.snapshot.erosionHasResult }; },
});
Object.defineProperty(EngineClient.prototype, '_targetTerrainVariant', {
get() { return () => this.snapshot.targetTerrainVariant; },
});
export async function createEngineProxy(options) {
const loadedPerf = options.initialPerf || loadPerfSettings();
const perf = DEVELOPMENT_WORKER_OVERRIDE === '1'
? { ...loadedPerf, useWorker: true }
: DEVELOPMENT_WORKER_OVERRIDE === '0'
? { ...loadedPerf, useWorker: false }
: loadedPerf;
const workerSupported = supportsWorkerRenderer(options.canvas);
const workerRequested = DEVELOPMENT_WORKER_OVERRIDE === '1'
|| (DEVELOPMENT_WORKER_OVERRIDE !== '0' && !!perf.useWorker);
const useWorker = workerRequested && workerSupported;
const coldShaderRun = typeof location !== 'undefined'
? new URLSearchParams(location.search).get('coldShaderRun')
: null;
const shaderBenchmark = typeof location !== 'undefined'
? parseShaderBenchmarkOptions(location.search)
: null;
const transport = useWorker ? new WorkerEngineTransport() : new MainThreadEngineTransport();
const bootLinkMode = useWorker && !shaderBenchmark ? chooseBootLinkMode() : 'async';
markBootLinkAttempt(bootLinkMode);
const client = new EngineClient({
...options,
initialPerf: perf,
perfSettingsStored: DEVELOPMENT_WORKER_OVERRIDE != null || hasStoredPerfSettings(),
renderWorker: useWorker,
coldShaderRun: shaderBenchmark ? null : coldShaderRun,
shaderBenchmark,
bootLinkMode,
}, transport);
await client.initialize();
const rendererConfig = {
...(client.snapshot.rendererConfig || {}),
workerSupported,
workerRequested,
workerActive: useWorker,
transport: useWorker ? 'worker' : 'main-thread',
workerFallbackReason: workerRequested && !workerSupported ? 'OffscreenCanvas renderer unavailable' : '',
};
client._setSnapshot({ ...client.snapshot, rendererConfig });
if (!useWorker && transport.engine?.rendererConfig) transport.engine.rendererConfig = rendererConfig;
return client;
}