@vgai/engine 0.5.39 → 0.5.41
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/dist/adapter/authoring.d.ts +6 -0
- package/dist/adapter/authoring.d.ts.map +1 -1
- package/dist/adapter/root-adapter.d.ts +16 -0
- package/dist/adapter/root-adapter.d.ts.map +1 -1
- package/dist/adapter/root-seam-contract.d.ts +5 -0
- package/dist/adapter/root-seam-contract.d.ts.map +1 -1
- package/dist/adapter/root-seam-contract.js +1 -0
- package/dist/ai/navigation.d.ts +30 -0
- package/dist/ai/navigation.d.ts.map +1 -1
- package/dist/ai/navigation.js +248 -15
- package/dist/ecs/user-data.d.ts +6 -0
- package/dist/ecs/user-data.d.ts.map +1 -1
- package/dist/ecs/user-data.js +2 -0
- package/dist/runtime/debug-registry.d.ts +2 -0
- package/dist/runtime/debug-registry.d.ts.map +1 -1
- package/dist/runtime/debug-registry.js +1 -0
- package/dist/runtime/game.d.ts +13 -6
- package/dist/runtime/game.d.ts.map +1 -1
- package/dist/runtime/game.js +42 -6
- package/dist/world3d-react/frame-delta.d.ts +15 -0
- package/dist/world3d-react/frame-delta.d.ts.map +1 -0
- package/dist/world3d-react/frame-delta.js +21 -0
- package/dist/world3d-react/r3f-root-factory.d.ts.map +1 -1
- package/dist/world3d-react/r3f-root-factory.js +19 -6
- package/package.json +1 -1
- package/src/adapter/authoring.ts +6 -0
- package/src/adapter/root-adapter.ts +17 -0
- package/src/adapter/root-seam-contract.ts +1 -0
- package/src/ai/navigation.ts +298 -13
- package/src/ecs/user-data.ts +6 -0
- package/src/runtime/debug-registry.ts +3 -0
- package/src/runtime/game.ts +56 -11
- package/src/world3d-react/frame-delta.ts +25 -0
- package/src/world3d-react/r3f-root-factory.tsx +19 -6
package/dist/runtime/game.d.ts
CHANGED
|
@@ -89,8 +89,9 @@ export type AdapterSurface = AdapterSurfaceLeaf;
|
|
|
89
89
|
* A world's per-phase frame hooks.
|
|
90
90
|
* Populated on a `RootInstance` only for first-party mounts — an opaque/
|
|
91
91
|
* foreign mount has no phase-partitioned entry point, so it stays
|
|
92
|
-
* `undefined` and the Game's frame executor
|
|
93
|
-
*
|
|
92
|
+
* `undefined` and the Game's frame executor falls back to its single
|
|
93
|
+
* `mounted.update(dt)`. The mount's `updateCadence` chooses fixed-substep
|
|
94
|
+
* (the default) or display-rate dispatch.
|
|
94
95
|
*/
|
|
95
96
|
export interface RootFrameHooks {
|
|
96
97
|
/** Run this world's engine systems + component ticks + world-bound game
|
|
@@ -405,8 +406,8 @@ export interface Game {
|
|
|
405
406
|
* sway, a cosmetic bob. It is NOT a gameplay hook: it can fire twice
|
|
406
407
|
* between two fixed substeps (120 Hz display, 60 Hz sim) and zero times
|
|
407
408
|
* across a `runTicks` fast-forward, so anything that must be deterministic
|
|
408
|
-
* belongs in a fixed phase (`ctx.systems.add
|
|
409
|
-
* `useFrame`
|
|
409
|
+
* belongs in a fixed engine phase (`ctx.systems.add`) instead. Ecosystem
|
|
410
|
+
* presentation hooks such as R3F's `useFrame` share this display clock.
|
|
410
411
|
*
|
|
411
412
|
* Reached from game code as `ctx.game?.onRenderStep(...)`. Returns an
|
|
412
413
|
* unsubscribe function; pass `opts.signal` to unsubscribe with the same
|
|
@@ -449,13 +450,17 @@ export interface GameInternal extends Game {
|
|
|
449
450
|
* for world in roots: // after ALL phases
|
|
450
451
|
* if world.mounted.drivesOwnLoop: continue
|
|
451
452
|
* if world.frame: world.frame.endFrame?.()
|
|
452
|
-
* else
|
|
453
|
+
* else if updateCadence != 'display' OR render phases are included:
|
|
454
|
+
* world.mounted.update?.(dt) // opaque world fallback
|
|
453
455
|
* ```
|
|
454
456
|
*
|
|
455
457
|
* A single first-party world and its direct `mounted.update(dt)` entry run
|
|
456
458
|
* the same `SystemRunner` and `postFrame` work. A `drivesOwnLoop` world is
|
|
457
459
|
* never ticked here. An opaque host-driven world (no `frame`) gets exactly
|
|
458
|
-
* one `update(dt)` call per substep
|
|
460
|
+
* one `update(dt)` call per substep after the phase loop by default. A
|
|
461
|
+
* display-cadence opaque world is withheld when `skipRenderPhases` is true;
|
|
462
|
+
* the matching host calls it once from {@link runRenderFrame}. A direct
|
|
463
|
+
* `runFrame` with render phases included still calls it once.
|
|
459
464
|
*
|
|
460
465
|
* D10/T7.6 play-state addendum: when `Game.play.paused` is true, every
|
|
461
466
|
* `pausable` (and non-`drivesOwnLoop`) world skips every phase EXCEPT
|
|
@@ -495,6 +500,8 @@ export interface GameInternal extends Game {
|
|
|
495
500
|
* for world in roots (declaration order):
|
|
496
501
|
* if world.mounted.drivesOwnLoop: continue
|
|
497
502
|
* world.frame?.runPhase(phase, frozen ? 0 : displayDt)
|
|
503
|
+
* for opaque world with updateCadence == 'display':
|
|
504
|
+
* world.mounted.update?.(frozen ? 0 : displayDt)
|
|
498
505
|
* ```
|
|
499
506
|
*
|
|
500
507
|
* Advances NOTHING: no `tick`, no `simT`, no sim-clock flush, no state-bridge
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game.d.ts","sourceRoot":"","sources":["../../src/runtime/game.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAOxD,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC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;;;;;;;;;;;OAgBG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,0EAA0E;IAC1E,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAC/B,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C;;;;;;;;;kDAS8C;IAC9C,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,GAAG,YAAY,CA63Bf"}
|
package/dist/runtime/game.js
CHANGED
|
@@ -282,6 +282,7 @@ export function createGame(opts) {
|
|
|
282
282
|
const debugRegistry = createDebugRegistry({
|
|
283
283
|
getTick: () => tick,
|
|
284
284
|
getSimT: () => simT,
|
|
285
|
+
getFixedDt: () => opts.loop.fixedDt,
|
|
285
286
|
// D15/T-D15.5 — "the manifest's first/default world" for the debug
|
|
286
287
|
// registry's world-addressed input-target surface. Every
|
|
287
288
|
// first-party root now registers the SAME game-owned InputManager, but the
|
|
@@ -435,7 +436,12 @@ export function createGame(opts) {
|
|
|
435
436
|
reportGateShortfallOnce('loop', world.id, 'self-driven world, adapter declares no setPaused capability');
|
|
436
437
|
}
|
|
437
438
|
}
|
|
438
|
-
|
|
439
|
+
// A native entry's static `systems` export is this root's primary
|
|
440
|
+
// declaration surface. `computeSystemAdapters()` already gives it
|
|
441
|
+
// precedence over a substrate-seeded mounted adapter; pause must read
|
|
442
|
+
// the same source or a valid entry-declared audio graph is visible to
|
|
443
|
+
// the editor yet paradoxically reported as ungateable here.
|
|
444
|
+
const audio = declaredSystemAdapters.get(world.id)?.audio ?? world.mounted.systems?.audio;
|
|
439
445
|
if (audio) {
|
|
440
446
|
audio.setMuted(next);
|
|
441
447
|
}
|
|
@@ -643,11 +649,19 @@ export function createGame(opts) {
|
|
|
643
649
|
// Checklist item 2: same isolation for the opaque-world fallback —
|
|
644
650
|
// one foreign mount's `update` throwing must not starve its
|
|
645
651
|
// siblings' `endFrame`/`update` calls this same loop.
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
652
|
+
// A display-cadence opaque update is the root's indivisible native
|
|
653
|
+
// presentation (R3F `advance()` is callbacks + draw). The real
|
|
654
|
+
// rAF host withholds render phases from EVERY fixed catch-up step;
|
|
655
|
+
// withhold this update beside them, then run it once in
|
|
656
|
+
// `runRenderFrameImpl`. A direct/offline `runFrame` includes render
|
|
657
|
+
// phases and therefore still advances the root exactly once.
|
|
658
|
+
if (!(skipRenderPhases && world.mounted.updateCadence === 'display')) {
|
|
659
|
+
try {
|
|
660
|
+
world.mounted.update?.(dt);
|
|
661
|
+
}
|
|
662
|
+
catch (err) {
|
|
663
|
+
console.error(`[game] world "${world.id}" (kind: ${world.kind}) update() threw:`, err);
|
|
664
|
+
}
|
|
651
665
|
}
|
|
652
666
|
}
|
|
653
667
|
}
|
|
@@ -746,6 +760,28 @@ export function createGame(opts) {
|
|
|
746
760
|
}
|
|
747
761
|
profiler.endPhase(phase);
|
|
748
762
|
}
|
|
763
|
+
// An opaque display-cadence root cannot expose phase hooks because its
|
|
764
|
+
// native advance is inseparable. It still belongs to THIS presentation
|
|
765
|
+
// frame, once — never to every fixed catch-up substep that preceded it.
|
|
766
|
+
// A frozen world redraws at dt=0, preserving the established pause rule.
|
|
767
|
+
for (let i = 0; i < n; i++) {
|
|
768
|
+
const world = roots[i];
|
|
769
|
+
if (world.disposed)
|
|
770
|
+
continue;
|
|
771
|
+
if (world.mounted.drivesOwnLoop)
|
|
772
|
+
continue;
|
|
773
|
+
if (world.frame)
|
|
774
|
+
continue;
|
|
775
|
+
if (world.mounted.updateCadence !== 'display')
|
|
776
|
+
continue;
|
|
777
|
+
const frozen = paused && world.pausable;
|
|
778
|
+
try {
|
|
779
|
+
world.mounted.update?.(frozen ? 0 : displayDt);
|
|
780
|
+
}
|
|
781
|
+
catch (err) {
|
|
782
|
+
console.error(`[game] world "${world.id}" (kind: ${world.kind}) update() threw (display frame):`, err);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
749
785
|
profiler.endFrame();
|
|
750
786
|
if (rngTrapEnabled)
|
|
751
787
|
rngTrap.disable();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The exact host-owned delta for the synchronous R3F frame currently being dispatched.
|
|
3
|
+
*
|
|
4
|
+
* Fiber's `frameloop: 'never'` API accepts an absolute timestamp and reconstructs the frame
|
|
5
|
+
* delta by subtracting its previous timestamp. Once that timestamp is large enough, ordinary
|
|
6
|
+
* floating-point cancellation can turn an exact host `1 / 60` into either adjacent double. The
|
|
7
|
+
* host still owns the original exact `dt`; adapter-boundary runtimes that must reproduce another
|
|
8
|
+
* engine's clock can read it here instead of mistaking Fiber's reconstruction residue for game
|
|
9
|
+
* time. The seat exists only for the synchronous `advance(...)` call and is cleared immediately
|
|
10
|
+
* afterwards, so an async consumer can never read a stale frame.
|
|
11
|
+
*/
|
|
12
|
+
export declare function setHostFrameDelta(state: object, delta: number): void;
|
|
13
|
+
export declare function clearHostFrameDelta(state: object): void;
|
|
14
|
+
export declare function hostFrameDelta(state: object, fiberDelta: number): number;
|
|
15
|
+
//# sourceMappingURL=frame-delta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-delta.d.ts","sourceRoot":"","sources":["../../src/world3d-react/frame-delta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEpE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAEvD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAExE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The exact host-owned delta for the synchronous R3F frame currently being dispatched.
|
|
3
|
+
*
|
|
4
|
+
* Fiber's `frameloop: 'never'` API accepts an absolute timestamp and reconstructs the frame
|
|
5
|
+
* delta by subtracting its previous timestamp. Once that timestamp is large enough, ordinary
|
|
6
|
+
* floating-point cancellation can turn an exact host `1 / 60` into either adjacent double. The
|
|
7
|
+
* host still owns the original exact `dt`; adapter-boundary runtimes that must reproduce another
|
|
8
|
+
* engine's clock can read it here instead of mistaking Fiber's reconstruction residue for game
|
|
9
|
+
* time. The seat exists only for the synchronous `advance(...)` call and is cleared immediately
|
|
10
|
+
* afterwards, so an async consumer can never read a stale frame.
|
|
11
|
+
*/
|
|
12
|
+
const hostFrameDeltas = new WeakMap();
|
|
13
|
+
export function setHostFrameDelta(state, delta) {
|
|
14
|
+
hostFrameDeltas.set(state, delta);
|
|
15
|
+
}
|
|
16
|
+
export function clearHostFrameDelta(state) {
|
|
17
|
+
hostFrameDeltas.delete(state);
|
|
18
|
+
}
|
|
19
|
+
export function hostFrameDelta(state, fiberDelta) {
|
|
20
|
+
return hostFrameDeltas.get(state) ?? fiberDelta;
|
|
21
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"r3f-root-factory.d.ts","sourceRoot":"","sources":["../../src/world3d-react/r3f-root-factory.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAWH,OAAO,KAAK,EAAoB,WAAW,EAAoB,MAAM,YAAY,CAAC;AAelF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"r3f-root-factory.d.ts","sourceRoot":"","sources":["../../src/world3d-react/r3f-root-factory.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAWH,OAAO,KAAK,EAAoB,WAAW,EAAoB,MAAM,YAAY,CAAC;AAelF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAmanE;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAI/F;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,qBAO5B,CAAC"}
|
|
@@ -45,6 +45,7 @@ import { WorldProvider } from '../react/world-state';
|
|
|
45
45
|
import { getDebugRegistry } from '../runtime/debug-registry';
|
|
46
46
|
import { devBuildEnabled } from '../runtime/dev-build';
|
|
47
47
|
import { DEFAULT_INPUT_MAP_PATH, wireGameInputSeams } from '../runtime/game-input-seams';
|
|
48
|
+
import { clearHostFrameDelta, setHostFrameDelta } from './frame-delta';
|
|
48
49
|
/**
|
|
49
50
|
* Build the `RootAdapter` for one default-exported R3F world. Mounts through
|
|
50
51
|
* react-three-fiber, gated entirely by the host's own loop and rendering
|
|
@@ -291,11 +292,10 @@ function threeWorldAdapter(id, component) {
|
|
|
291
292
|
if (renderDebugWiring)
|
|
292
293
|
systemAdapters.renderDebug = renderDebugWiring.adapter;
|
|
293
294
|
// The engine drives every `useFrame` through the mounted world's
|
|
294
|
-
// `update(dt)` hook, never off a raw
|
|
295
|
-
//
|
|
296
|
-
//
|
|
297
|
-
//
|
|
298
|
-
// once.
|
|
295
|
+
// `update(dt)` hook, never off a raw Fiber loop. This mount declares
|
|
296
|
+
// that indivisible Fiber advance at DISPLAY cadence below: the real
|
|
297
|
+
// host calls it once per presentation, a paused world gets dt=0, and an
|
|
298
|
+
// explicit `Game.play.step()` still ticks it exactly once.
|
|
299
299
|
//
|
|
300
300
|
// `advance(timestamp, runGlobalEffects, state)`'s `timestamp` is
|
|
301
301
|
// consumed as `THREE.Clock.elapsedTime` DIRECTLY when
|
|
@@ -327,6 +327,14 @@ function threeWorldAdapter(id, component) {
|
|
|
327
327
|
return live().camera;
|
|
328
328
|
},
|
|
329
329
|
drivesOwnLoop: false,
|
|
330
|
+
// Fiber's `advance()` cannot separate its `useFrame` callbacks from
|
|
331
|
+
// its WebGL draw. Running this opaque update in every fixed catch-up
|
|
332
|
+
// substep renders N complete frames inside one rAF callback: once a
|
|
333
|
+
// scene costs more than 16.7ms, the accumulator asks for more draws,
|
|
334
|
+
// those draws make the next gap larger, and the loop spirals to its
|
|
335
|
+
// max-substep ceiling. The host's display pass is the one clock that
|
|
336
|
+
// must own this inseparable native advance.
|
|
337
|
+
updateCadence: 'display',
|
|
330
338
|
// Adapter surface: `debug` (the shared game registry) and, when a real
|
|
331
339
|
// WebGL2 context exists, `renderDebug` are engine-seeded. The game's
|
|
332
340
|
// own capabilities arrive as the entry module's declared `systems`.
|
|
@@ -334,8 +342,12 @@ function threeWorldAdapter(id, component) {
|
|
|
334
342
|
update(dt) {
|
|
335
343
|
elapsed += dt;
|
|
336
344
|
const current = live();
|
|
337
|
-
|
|
345
|
+
// Fiber receives an ABSOLUTE timestamp and reconstructs `delta` by subtraction. Publish
|
|
346
|
+
// the exact host-owned dt beside the synchronous advance so compatibility adapters that
|
|
347
|
+
// reproduce another engine's frame clock do not inherit one-ulp cancellation residue.
|
|
348
|
+
setHostFrameDelta(current, dt);
|
|
338
349
|
try {
|
|
350
|
+
renderDebugWiring?.beforeRender();
|
|
339
351
|
const profiler = host.game?.profiler;
|
|
340
352
|
if (!profiler?.enabled) {
|
|
341
353
|
advance(elapsed, true, current);
|
|
@@ -374,6 +386,7 @@ function threeWorldAdapter(id, component) {
|
|
|
374
386
|
}
|
|
375
387
|
}
|
|
376
388
|
finally {
|
|
389
|
+
clearHostFrameDelta(current);
|
|
377
390
|
renderDebugWiring?.afterRender();
|
|
378
391
|
}
|
|
379
392
|
},
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@vgai/engine",
|
|
3
3
|
"author": "Volter AI, Inc.",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "0.5.
|
|
5
|
+
"version": "0.5.41",
|
|
6
6
|
"description": "Readable TypeScript game engine and universal host for Three.js, PixiJS, and React games.",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"game-engine",
|
package/src/adapter/authoring.ts
CHANGED
|
@@ -110,6 +110,12 @@ export interface EditorNode {
|
|
|
110
110
|
typeLabel?: string;
|
|
111
111
|
parentId: string | null;
|
|
112
112
|
childIds: string[];
|
|
113
|
+
/** Opaque project-owned identity shared by authored rows across adapter roots. */
|
|
114
|
+
crossSurfaceId?: string;
|
|
115
|
+
/** Optional authored parent identity resolved against another row's cross-surface id. */
|
|
116
|
+
crossSurfaceParentId?: string;
|
|
117
|
+
/** Source-owned sibling ordinal used only when native rows are joined across surfaces. */
|
|
118
|
+
crossSurfaceOrder?: number;
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
export interface PropertyDescriptor {
|
|
@@ -65,6 +65,23 @@ export interface MountedRootBase {
|
|
|
65
65
|
*/
|
|
66
66
|
readonly drivesOwnLoop: boolean;
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Which host clock owns an opaque mounted root's single `update(dt)` hook.
|
|
70
|
+
*
|
|
71
|
+
* `fixed` (the default) preserves the adapter seam's original contract:
|
|
72
|
+
* the callback runs once per consumed simulation substep. `display` is for
|
|
73
|
+
* a reconciler whose one native advance is inseparably BOTH its callbacks
|
|
74
|
+
* and its draw (React Three Fiber's `advance()` is the measured case). The
|
|
75
|
+
* real host then withholds it from fixed catch-up substeps and invokes it
|
|
76
|
+
* exactly once from the display pass. A direct/offline `runFrame` that does
|
|
77
|
+
* not skip render phases still invokes it once, preserving capture and
|
|
78
|
+
* explicit-tick semantics.
|
|
79
|
+
*
|
|
80
|
+
* Absent means `fixed`. This changes no foreign/ingest adapter unless that
|
|
81
|
+
* adapter opts in explicitly.
|
|
82
|
+
*/
|
|
83
|
+
readonly updateCadence?: 'fixed' | 'display';
|
|
84
|
+
|
|
68
85
|
update?(dt: number): void; // host-driven only
|
|
69
86
|
fixedUpdate?(dt: number): void;
|
|
70
87
|
setPaused?(paused: boolean): void; // capability, not promise — see loop-model note above
|
|
@@ -18,6 +18,7 @@ export const ROOT_ADAPTER_SHAPE = defineSeamShape<RootAdapter<AdapterSurface>>()
|
|
|
18
18
|
|
|
19
19
|
export const MOUNTED_ROOT_BASE_SHAPE = defineSeamShape<MountedRootBase>()({
|
|
20
20
|
drivesOwnLoop: { optional: false, kind: 'value', required: 'shape' },
|
|
21
|
+
updateCadence: { optional: true, kind: 'value', required: 'shape' },
|
|
21
22
|
update: { optional: true, kind: 'function', required: 'effect' },
|
|
22
23
|
fixedUpdate: { optional: true, kind: 'function', required: 'effect' },
|
|
23
24
|
setPaused: { optional: true, kind: 'function', required: 'effect' },
|