@zylem/game-lib 0.7.0 → 0.8.2
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/README.md +15 -1
- package/dist/actions.d.ts +71 -8
- package/dist/actions.js +1 -1
- package/dist/api/game-lib.api.json +55350 -0
- package/dist/api/game-lib.api.md +4608 -0
- package/dist/api/game-lib.d.ts +8447 -0
- package/dist/api/game-lib.typedoc.json +352456 -0
- package/dist/audio.js +1 -1
- package/dist/{base-node-life-cycle-CnJ-7zX-.d.ts → base-node-life-cycle-BK9xebT9.d.ts} +18 -4
- package/dist/behavior.d.ts +2 -3
- package/dist/behavior.js +1 -1
- package/dist/blueprints-TbGY-h53.d.ts +162 -0
- package/dist/chunk-3PRBSSTS.js +24 -0
- package/dist/chunk-47DG7I7M.js +1 -0
- package/dist/chunk-7GYFZKK7.js +1 -0
- package/dist/chunk-7QF6YTEZ.js +1 -0
- package/dist/chunk-7WRQ2UAN.js +1 -0
- package/dist/chunk-BH53MBAZ.js +1 -0
- package/dist/chunk-BIGH6D34.js +0 -0
- package/dist/chunk-CD7ZOZ35.js +1 -0
- package/dist/chunk-CFVRRRZZ.js +1 -0
- package/dist/chunk-CM5YRNBJ.js +19 -0
- package/dist/chunk-COM6HJ2L.js +1 -0
- package/dist/chunk-D2PATZCC.js +1 -0
- package/dist/chunk-DFLI7ICU.js +0 -0
- package/dist/chunk-EVYHPR3J.js +1 -0
- package/dist/chunk-IPWUDOV5.js +1 -0
- package/dist/chunk-JNFFTNMH.js +1 -0
- package/dist/chunk-JQKS42G4.js +1 -0
- package/dist/chunk-KVSJE4XD.js +1 -0
- package/dist/chunk-MZZCDXFB.js +1 -0
- package/dist/chunk-ORIDWL3T.js +0 -0
- package/dist/{chunk-RXDTAWI2.js → chunk-PCFF4LLO.js} +1 -1
- package/dist/chunk-QB3NL7VQ.js +1 -0
- package/dist/chunk-TAUWDQZF.js +9 -0
- package/dist/chunk-UG22Z42P.js +1 -0
- package/dist/chunk-VS2D4B3W.js +1 -0
- package/dist/chunk-WQ3WMMZD.js +1 -0
- package/dist/chunk-XK63E4SX.js +1 -0
- package/dist/chunk-YAOXFYOD.js +1 -0
- package/dist/chunk-ZRT3ZQVH.js +1 -0
- package/dist/collision-builder-B_tm8OVy.d.ts +49 -0
- package/dist/core.d.ts +45 -30
- package/dist/core.js +1 -24
- package/dist/debug-state-DRoeasG2.d.ts +17 -0
- package/dist/debug.d.ts +71 -19
- package/dist/debug.js +1 -1
- package/dist/{default-controls-BGc61yYl.d.ts → default-controls-CAKJ5zlo.d.ts} +3 -3
- package/dist/entity-B9yZeBm4.d.ts +34 -0
- package/dist/{entity-DNkYKfdp.d.ts → entity-BGEq1yfC.d.ts} +91 -444
- package/dist/{entity-type-map-C94h2TDW.d.ts → entity-type-map-CW6RHQkx.d.ts} +153 -6
- package/dist/entity.d.ts +15 -10
- package/dist/entity.js +1 -1
- package/dist/events.d.ts +10 -1
- package/dist/events.js +1 -1
- package/dist/{game-Cuj5gy7U.d.ts → game-DbqBQiFC.d.ts} +460 -135
- package/dist/game-default-6AZZCNST.js +1 -0
- package/dist/{game-interfaces-tfpM5NBk.d.ts → game-interfaces-vF5sRi1n.d.ts} +8 -2
- package/dist/globals.d.ts +12 -1
- package/dist/globals.js +1 -1
- package/dist/graphics.d.ts +16 -46
- package/dist/graphics.js +1 -1
- package/dist/input-ui.d.ts +5 -4
- package/dist/input-ui.js +1 -1
- package/dist/input.d.ts +48 -4
- package/dist/input.js +1 -1
- package/dist/{material-Wz83vTTp.d.ts → material-DbSuZBbP.d.ts} +25 -50
- package/dist/public.d.ts +38 -0
- package/dist/public.js +1 -0
- package/dist/runtime.d.ts +7 -381
- package/dist/runtime.js +1 -1
- package/dist/schema/entity.schema.json +244 -0
- package/dist/schema/game-config.schema.json +643 -0
- package/dist/schema/input-config.schema.json +517 -0
- package/dist/schema/stage-config.schema.json +93 -0
- package/dist/schema/stage.schema.json +271 -0
- package/dist/schema.d.ts +550 -0
- package/dist/schema.js +1 -0
- package/dist/stage-transition-CmGpV4tc.d.ts +46 -0
- package/dist/vector-DN6zlPoE.d.ts +161 -0
- package/dist/web-components.d.ts +15 -12
- package/dist/web-components.js +1 -9
- package/dist/{zylem-stage-runtime-Cs-UDEVU.d.ts → zylem-camera-Du2UPW9O.d.ts} +74 -264
- package/package.json +28 -20
- package/dist/chunk-73VZQZUL.js +0 -1
- package/dist/chunk-A34ZG3L4.js +0 -1
- package/dist/chunk-CDPY4VOQ.js +0 -1
- package/dist/chunk-DR6XXZE7.js +0 -19
- package/dist/chunk-FM5TBEPO.js +0 -1
- package/dist/chunk-G2IIMSUH.js +0 -1
- package/dist/chunk-MSC2BEO5.js +0 -1
- package/dist/chunk-NIH5CONO.js +0 -1
- package/dist/chunk-ONWXGBWB.js +0 -1
- package/dist/chunk-QEDQDR27.js +0 -1
- package/dist/chunk-WKHW2QO2.js +0 -1
- package/dist/chunk-YHKXQ2ZN.js +0 -1
- package/dist/game-default-PZLLHYL7.js +0 -1
- package/dist/world-C9zdyl5d.d.ts +0 -103
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { G as GameInputConfig, B as BaseGlobals, Z as ZylemGameConfig } from './game-interfaces-
|
|
3
|
-
import { G as GameEntity,
|
|
4
|
-
import { Object3D, BufferGeometry, Material, Group,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import { e as InputPlayerNumber, f as InputProvider, I as Inputs, h as SetupFunction, g as UpdateFunction, j as DestroyFunction, a as SetupContext, U as UpdateContext, D as DestroyContext, L as LoadingEvent, m as IGame, S as StageNavigationOptions } from './base-node-life-cycle-BK9xebT9.js';
|
|
2
|
+
import { G as GameInputConfig, B as BaseGlobals, Z as ZylemGameConfig } from './game-interfaces-vF5sRi1n.js';
|
|
3
|
+
import { G as GameEntity, a as GameEntityOptions, B as BaseNode, y as GameEntityLifeCycle } from './entity-BGEq1yfC.js';
|
|
4
|
+
import { Scene, Color, Object3D, Vector3, BufferGeometry, Material, Group, Texture } from 'three';
|
|
5
|
+
import { ak as ZylemWorld, ai as EntityTypeMap } from './entity-type-map-CW6RHQkx.js';
|
|
6
|
+
import { E as Entity, L as LifecycleFunction, S as StageEntity } from './entity-B9yZeBm4.js';
|
|
7
|
+
import { k as ZylemCamera, R as RendererManager, e as CameraPerspective, d as CameraContext, C as CameraPose, P as PerspectiveType, f as CameraBehavior, g as CameraAction, h as CameraPipelineState, V as Viewport, Z as ZylemPostEffect } from './zylem-camera-Du2UPW9O.js';
|
|
8
|
+
import { d as ZylemShader } from './material-DbSuZBbP.js';
|
|
9
|
+
import { l as SimulationBody, e as Vec3Input, b as Vec2Input, d as Vec3Components } from './vector-DN6zlPoE.js';
|
|
10
|
+
import { BehaviorSystem, BehaviorEntityLink, BehaviorRuntime, BehaviorSystemFactory, Simulation } from '@zylem/behaviors/core';
|
|
11
11
|
import { StageEvents, GameEvents } from './events.js';
|
|
12
|
-
import { D as DefaultTouchControlsOptions } from './default-controls-
|
|
12
|
+
import { D as DefaultTouchControlsOptions } from './default-controls-CAKJ5zlo.js';
|
|
13
|
+
import { S as StageTransitionConfig } from './stage-transition-CmGpV4tc.js';
|
|
13
14
|
|
|
14
15
|
declare class InputManager {
|
|
15
16
|
private inputMap;
|
|
@@ -127,91 +128,315 @@ declare class Timer {
|
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
/**
|
|
130
|
-
*
|
|
131
|
+
* CameraManager orchestrates multiple cameras per stage.
|
|
132
|
+
*
|
|
133
|
+
* Responsibilities:
|
|
134
|
+
* - Named camera registry (add/remove/get by name or reference)
|
|
135
|
+
* - Active camera list management (determines which cameras render)
|
|
136
|
+
* - Always-available debug camera with orbit controls
|
|
137
|
+
* - Per-frame update of all active cameras' perspective controllers
|
|
138
|
+
* - Coordinating rendering via RendererManager for all active viewports
|
|
131
139
|
*/
|
|
132
|
-
|
|
140
|
+
declare class CameraManager {
|
|
141
|
+
/** Named camera registry */
|
|
142
|
+
private cameras;
|
|
143
|
+
/** Currently active cameras, ordered by render layer (first = bottom) */
|
|
144
|
+
private _activeCameras;
|
|
145
|
+
/** Auto-created debug camera with orbit controls */
|
|
146
|
+
private _debugCamera;
|
|
147
|
+
/** Gameplay primary camera saved while the debug camera is active. */
|
|
148
|
+
private _preDebugPrimary;
|
|
149
|
+
/** Scene anchor at world origin for debug orbit when nothing is selected. */
|
|
150
|
+
private _debugOrbitTargetAnchor;
|
|
151
|
+
/** Reference to the shared renderer manager */
|
|
152
|
+
private _rendererManager;
|
|
153
|
+
/** Scene reference */
|
|
154
|
+
private _sceneRef;
|
|
155
|
+
/** Counter for auto-generated camera names */
|
|
156
|
+
private _autoNameCounter;
|
|
157
|
+
constructor();
|
|
158
|
+
/**
|
|
159
|
+
* Get the list of currently active cameras.
|
|
160
|
+
*/
|
|
161
|
+
get activeCameras(): ReadonlyArray<ZylemCamera>;
|
|
162
|
+
/**
|
|
163
|
+
* Get the primary active camera (first in the active list).
|
|
164
|
+
*/
|
|
165
|
+
get primaryCamera(): ZylemCamera | null;
|
|
166
|
+
/**
|
|
167
|
+
* Get the debug camera.
|
|
168
|
+
*/
|
|
169
|
+
get debugCamera(): ZylemCamera | null;
|
|
170
|
+
/**
|
|
171
|
+
* Gameplay primary camera that was active before debug mode was enabled.
|
|
172
|
+
*/
|
|
173
|
+
get preDebugPrimary(): ZylemCamera | null;
|
|
174
|
+
/**
|
|
175
|
+
* Get all registered cameras.
|
|
176
|
+
*/
|
|
177
|
+
get allCameras(): ReadonlyArray<ZylemCamera>;
|
|
178
|
+
/**
|
|
179
|
+
* Add a camera to the manager.
|
|
180
|
+
* If no name is provided, one is auto-generated.
|
|
181
|
+
* The first camera added becomes the active camera.
|
|
182
|
+
*
|
|
183
|
+
* @param camera The ZylemCamera instance to add
|
|
184
|
+
* @param name Optional name for lookup
|
|
185
|
+
* @returns The assigned name
|
|
186
|
+
*/
|
|
187
|
+
addCamera(camera: ZylemCamera, name?: string): string;
|
|
188
|
+
/**
|
|
189
|
+
* Remove a camera by name or reference.
|
|
190
|
+
* Cannot remove the debug camera via this method.
|
|
191
|
+
*/
|
|
192
|
+
removeCamera(nameOrRef: string | ZylemCamera): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Set a camera as the primary active camera (replaces all active cameras
|
|
195
|
+
* except additional viewport cameras).
|
|
196
|
+
*
|
|
197
|
+
* @param nameOrRef Camera name or reference to activate
|
|
198
|
+
*/
|
|
199
|
+
setActiveCamera(nameOrRef: string | ZylemCamera): boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Add a camera as an additional active camera (for split-screen or PiP).
|
|
202
|
+
*/
|
|
203
|
+
addActiveCamera(nameOrRef: string | ZylemCamera): boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Remove a camera from the active render list (does not remove from registry).
|
|
206
|
+
*/
|
|
207
|
+
deactivateCamera(nameOrRef: string | ZylemCamera): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Get a camera by name.
|
|
210
|
+
*/
|
|
211
|
+
getCamera(name: string): ZylemCamera | null;
|
|
212
|
+
/**
|
|
213
|
+
* Setup all cameras with the given scene and renderer manager.
|
|
214
|
+
* Also creates the debug camera.
|
|
215
|
+
*/
|
|
216
|
+
setup(scene: Scene, rendererManager: RendererManager): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Switch the primary viewport to the debug orbit camera, remembering the
|
|
219
|
+
* previous primary so gameplay cameras (e.g. first-person) can be restored.
|
|
220
|
+
*/
|
|
221
|
+
activateDebugCamera(): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Restore the gameplay primary camera that was active before
|
|
224
|
+
* {@link activateDebugCamera}.
|
|
225
|
+
*/
|
|
226
|
+
deactivateDebugCamera(): boolean;
|
|
227
|
+
/**
|
|
228
|
+
* Update all active cameras' controllers.
|
|
229
|
+
*/
|
|
230
|
+
update(delta: number): void;
|
|
231
|
+
/**
|
|
232
|
+
* Render all active cameras through the renderer manager.
|
|
233
|
+
* RTT cameras (those with a renderTarget) are rendered first to their
|
|
234
|
+
* offscreen textures, then viewport cameras are rendered to the screen.
|
|
235
|
+
*/
|
|
236
|
+
render(scene: Scene): void;
|
|
237
|
+
private updateOrbitingCamerasForRender;
|
|
238
|
+
/**
|
|
239
|
+
* Create a default third-person camera if no cameras have been added.
|
|
240
|
+
*/
|
|
241
|
+
ensureDefaultCamera(): ZylemCamera;
|
|
242
|
+
/**
|
|
243
|
+
* Dispose all cameras and cleanup.
|
|
244
|
+
*/
|
|
245
|
+
dispose(): void;
|
|
246
|
+
/**
|
|
247
|
+
* Create the always-available debug camera with orbit controls.
|
|
248
|
+
* Registered for lookup/activation, but not added to the active list.
|
|
249
|
+
*/
|
|
250
|
+
private createDebugCamera;
|
|
251
|
+
/**
|
|
252
|
+
* Seed the debug camera orbit pose on first activation, framing the origin
|
|
253
|
+
* or offsetting from the saved gameplay primary.
|
|
254
|
+
*/
|
|
255
|
+
private seedDebugCameraPose;
|
|
256
|
+
/**
|
|
257
|
+
* Resolve a camera from a name or reference.
|
|
258
|
+
*/
|
|
259
|
+
private resolveCamera;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface SceneState {
|
|
263
|
+
backgroundColor: Color | string;
|
|
264
|
+
backgroundImage: string | null;
|
|
265
|
+
backgroundShader?: ZylemShader | null;
|
|
266
|
+
/**
|
|
267
|
+
* When `false`, skip the engine's built-in ambient + directional lights so
|
|
268
|
+
* the caller can configure the scene's lighting entirely via
|
|
269
|
+
* `createLight(...)` entities. Defaults to `true` for backward
|
|
270
|
+
* compatibility with existing demos.
|
|
271
|
+
*/
|
|
272
|
+
defaultLighting?: boolean;
|
|
273
|
+
}
|
|
274
|
+
declare class ZylemScene implements Entity<ZylemScene> {
|
|
275
|
+
type: string;
|
|
276
|
+
_setup?: SetupFunction<ZylemScene>;
|
|
277
|
+
scene: Scene;
|
|
278
|
+
/** @deprecated Use cameraManager instead */
|
|
279
|
+
zylemCamera: ZylemCamera;
|
|
280
|
+
cameraManager: CameraManager | null;
|
|
281
|
+
containerElement: HTMLElement | null;
|
|
282
|
+
update: LifecycleFunction<ZylemScene>;
|
|
283
|
+
_collision?: ((entity: any, other: any, globals?: any) => void) | undefined;
|
|
284
|
+
_destroy?: ((globals?: any) => void) | undefined;
|
|
285
|
+
name?: string | undefined;
|
|
286
|
+
tag?: Set<string> | undefined;
|
|
287
|
+
constructor(id: string, camera: ZylemCamera, state: SceneState);
|
|
288
|
+
/**
|
|
289
|
+
* Render the shader as a true skybox via the WebGPU renderer's
|
|
290
|
+
* `scene.backgroundNode`. The node is evaluated per background pixel at
|
|
291
|
+
* infinite depth — inside it, `normalWorld` (from `three/tsl`) is the
|
|
292
|
+
* per-pixel view direction, so the sky is stable under camera movement
|
|
293
|
+
* with no skybox mesh, far-plane sizing, or camera-follow logic.
|
|
294
|
+
*
|
|
295
|
+
* WebGPU-only: background shaders must be authored in TSL
|
|
296
|
+
* ({@link ZylemTSLShader}). A GLSL shader logs a warning and is ignored
|
|
297
|
+
* (the solid background color is kept).
|
|
298
|
+
*/
|
|
299
|
+
private setupBackgroundShader;
|
|
300
|
+
setup(): void;
|
|
301
|
+
destroy(): void;
|
|
302
|
+
/**
|
|
303
|
+
* Setup camera with the scene.
|
|
304
|
+
* Supports both legacy single camera and CameraManager modes.
|
|
305
|
+
*/
|
|
306
|
+
setupCamera(scene: Scene, camera: ZylemCamera, rendererManager?: RendererManager): Promise<void>;
|
|
307
|
+
/**
|
|
308
|
+
* Setup with a CameraManager (multi-camera support).
|
|
309
|
+
*/
|
|
310
|
+
setupCameraManager(scene: Scene, cameraManager: CameraManager, rendererManager: RendererManager): Promise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Add a camera (rig or direct) to the scene graph.
|
|
313
|
+
*/
|
|
314
|
+
private addCameraToScene;
|
|
315
|
+
/**
|
|
316
|
+
* Setup scene lighting
|
|
317
|
+
*/
|
|
318
|
+
setupLighting(scene: Scene): void;
|
|
319
|
+
/**
|
|
320
|
+
* Update renderer size - delegates to camera manager or camera
|
|
321
|
+
*/
|
|
322
|
+
updateRenderer(width: number, height: number): void;
|
|
323
|
+
/**
|
|
324
|
+
* Add object to scene
|
|
325
|
+
*/
|
|
326
|
+
add(object: Object3D, position?: Vector3): void;
|
|
327
|
+
/**
|
|
328
|
+
* Add game entity to scene
|
|
329
|
+
*/
|
|
330
|
+
addEntity(entity: GameEntity<any>): void;
|
|
331
|
+
/**
|
|
332
|
+
* Add an entity's group or mesh to the scene (for late-loaded models).
|
|
333
|
+
* Uses entity's current body position if physics is active.
|
|
334
|
+
*
|
|
335
|
+
* Fog entities ({@link ZylemFog}) are routed through the normal add
|
|
336
|
+
* pipeline so their empty placeholder group is parented for cleanup,
|
|
337
|
+
* but they also get an `attachToScene` call that wires `scene.fog`
|
|
338
|
+
* and starts the optional material patcher.
|
|
339
|
+
*/
|
|
340
|
+
addEntityGroup(entity: GameEntity<any>): void;
|
|
341
|
+
private isAttachedOutsideScene;
|
|
342
|
+
/**
|
|
343
|
+
* Add debug helpers to scene
|
|
344
|
+
*/
|
|
345
|
+
debugScene(): void;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** Configuration for pack key generation */
|
|
349
|
+
interface PackKeyConfig {
|
|
133
350
|
geometryType: string;
|
|
134
351
|
dimensions: Record<string, number>;
|
|
135
352
|
materialPath?: string | null;
|
|
136
353
|
shaderType?: 'standard' | 'custom';
|
|
137
354
|
colorHex?: number;
|
|
138
355
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Manages instanced mesh batching for entities
|
|
141
|
-
*/
|
|
356
|
+
/** Manages instanced mesh packs for `category: 'pack'` entities */
|
|
142
357
|
declare class InstanceManager {
|
|
143
|
-
private
|
|
144
|
-
private
|
|
358
|
+
private packs;
|
|
359
|
+
private entityToPack;
|
|
145
360
|
private scene;
|
|
146
|
-
/** Default initial capacity for new
|
|
361
|
+
/** Default initial capacity for new packs */
|
|
147
362
|
static DEFAULT_CAPACITY: number;
|
|
148
|
-
/** Factor to grow
|
|
363
|
+
/** Factor to grow a pack when full */
|
|
149
364
|
static GROWTH_FACTOR: number;
|
|
150
|
-
/**
|
|
151
|
-
* Set the scene to add instanced meshes to
|
|
152
|
-
*/
|
|
153
365
|
setScene(scene: Object3D): void;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
*/
|
|
157
|
-
static generateBatchKey(config: BatchKeyConfig): string;
|
|
158
|
-
static generateEntityBatchKey(entity: Pick<GameEntity<GameEntityOptions>, 'options' | 'materials'> & {
|
|
366
|
+
static generatePackKey(config: PackKeyConfig): string;
|
|
367
|
+
static generateEntityPackKey(entity: Pick<GameEntity<GameEntityOptions>, 'options' | 'materials'> & {
|
|
159
368
|
constructor: any;
|
|
160
369
|
}): string;
|
|
161
370
|
/**
|
|
162
|
-
* Register an entity with the instance manager
|
|
371
|
+
* Register an entity with the instance manager.
|
|
163
372
|
* @returns The instance index, or -1 if registration failed
|
|
164
373
|
*/
|
|
165
|
-
register(entity: GameEntity<any>, geometry: BufferGeometry, material: Material,
|
|
166
|
-
/**
|
|
167
|
-
* Unregister an entity from the instance manager
|
|
168
|
-
*/
|
|
374
|
+
register(entity: GameEntity<any>, geometry: BufferGeometry, material: Material, packKey: string): number;
|
|
169
375
|
unregister(entity: GameEntity<any>): void;
|
|
170
|
-
/**
|
|
171
|
-
* Mark an entity's transform as dirty (needs syncing)
|
|
172
|
-
*/
|
|
173
376
|
markDirty(entity: GameEntity<any>): void;
|
|
174
377
|
/**
|
|
175
|
-
* Update all
|
|
176
|
-
* Call
|
|
378
|
+
* Update all active instance transforms.
|
|
379
|
+
* Call once per frame after the simulation step and render-buffer sync.
|
|
177
380
|
*/
|
|
178
|
-
|
|
179
|
-
* Update all active instance transforms
|
|
180
|
-
* Call this once per frame
|
|
181
|
-
*/
|
|
182
|
-
update(): void;
|
|
381
|
+
update(interpolationAlpha?: number): void;
|
|
183
382
|
private updateInstanceMatrix;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
*/
|
|
187
|
-
getBatchInfo(entity: GameEntity<any>): {
|
|
188
|
-
batchKey: string;
|
|
383
|
+
getPackInfo(entity: GameEntity<any>): {
|
|
384
|
+
packKey: string;
|
|
189
385
|
instanceId: number;
|
|
190
386
|
} | null;
|
|
191
|
-
/**
|
|
192
|
-
* Get statistics about current batching
|
|
193
|
-
*/
|
|
194
387
|
getStats(): {
|
|
195
|
-
|
|
388
|
+
packCount: number;
|
|
196
389
|
totalInstances: number;
|
|
197
|
-
|
|
390
|
+
packs: {
|
|
198
391
|
key: string;
|
|
199
392
|
count: number;
|
|
200
393
|
capacity: number;
|
|
201
394
|
}[];
|
|
202
395
|
};
|
|
203
|
-
/**
|
|
204
|
-
* Dispose all batches and release resources
|
|
205
|
-
*/
|
|
206
396
|
dispose(): void;
|
|
397
|
+
private createPack;
|
|
398
|
+
private growPack;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Groups static environment meshes into WebGPU `BundleGroup`s for record-once
|
|
403
|
+
* replay. Dynamic entities must use `pack` (instancing) or `none` (scene-direct).
|
|
404
|
+
*/
|
|
405
|
+
declare class RenderBundleManager {
|
|
406
|
+
private readonly bundles;
|
|
407
|
+
private readonly entityToBundle;
|
|
408
|
+
private scene;
|
|
409
|
+
setScene(scene: Object3D): void;
|
|
207
410
|
/**
|
|
208
|
-
*
|
|
411
|
+
* Parent the entity's renderable into a static bundle group.
|
|
412
|
+
* @returns `true` when registration succeeded.
|
|
209
413
|
*/
|
|
210
|
-
|
|
414
|
+
register(entity: GameEntity<any>, _geometry: BufferGeometry, _material: Material, bundleKey: string): boolean;
|
|
415
|
+
unregister(entity: GameEntity<any>): void;
|
|
416
|
+
getStats(): {
|
|
417
|
+
bundleCount: number;
|
|
418
|
+
entityCount: number;
|
|
419
|
+
};
|
|
420
|
+
dispose(): void;
|
|
421
|
+
private getOrCreateBundle;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Routes entities to scene-direct (`none`), WebGPU bundles (`environment`), or
|
|
426
|
+
* instanced meshes (`pack`) based on `options.category`.
|
|
427
|
+
*/
|
|
428
|
+
declare class RenderStrategyManager {
|
|
429
|
+
readonly bundles: RenderBundleManager;
|
|
430
|
+
readonly instances: InstanceManager;
|
|
431
|
+
setScene(scene: Object3D): void;
|
|
211
432
|
/**
|
|
212
|
-
*
|
|
433
|
+
* Register an entity with the appropriate managed render path.
|
|
434
|
+
* @returns `true` when the entity was placed into bundle or instanced rendering.
|
|
213
435
|
*/
|
|
214
|
-
|
|
436
|
+
register(entity: GameEntity<any>): boolean;
|
|
437
|
+
unregister(entity: GameEntity<any>): void;
|
|
438
|
+
update(interpolationAlpha?: number): void;
|
|
439
|
+
dispose(): void;
|
|
215
440
|
}
|
|
216
441
|
|
|
217
442
|
/**
|
|
@@ -221,8 +446,7 @@ interface BaseEntityInterface {
|
|
|
221
446
|
uuid: string;
|
|
222
447
|
name: string;
|
|
223
448
|
group: Group | null | undefined;
|
|
224
|
-
body:
|
|
225
|
-
collider: Collider | null | undefined;
|
|
449
|
+
body: SimulationBody | null | undefined;
|
|
226
450
|
}
|
|
227
451
|
/**
|
|
228
452
|
* Game entity interface - minimal interface to break circular dependencies
|
|
@@ -430,6 +654,8 @@ declare class FirstPersonPerspective implements CameraPerspective {
|
|
|
430
654
|
look(deltaYaw: number, deltaPitch: number): void;
|
|
431
655
|
/** Set absolute yaw and pitch. Pitch is clamped to the configured limit. */
|
|
432
656
|
setLook(yaw: number, pitch: number): void;
|
|
657
|
+
/** Set eye height above the followed target (used when syncing from FirstPersonBehavior). */
|
|
658
|
+
setEyeHeight(height: number): void;
|
|
433
659
|
/** Current yaw in radians. */
|
|
434
660
|
get yaw(): number;
|
|
435
661
|
/** Current pitch in radians. */
|
|
@@ -478,15 +704,6 @@ interface CameraOptions {
|
|
|
478
704
|
target?: Vec3Input;
|
|
479
705
|
zoom?: number;
|
|
480
706
|
screenResolution?: Vec2Input;
|
|
481
|
-
/**
|
|
482
|
-
* Renderer type.
|
|
483
|
-
*
|
|
484
|
-
* @deprecated game-lib always renders with WebGPU (Three.js keeps its own
|
|
485
|
-
* internal WebGL2 fallback for devices without WebGPU). This option is
|
|
486
|
-
* ignored and retained only for backward compatibility.
|
|
487
|
-
* @default 'webgpu'
|
|
488
|
-
*/
|
|
489
|
-
rendererType?: RendererType;
|
|
490
707
|
/**
|
|
491
708
|
* Enable orbital controls for this camera.
|
|
492
709
|
* Can be toggled at runtime via enableOrbitalControls() / disableOrbitalControls().
|
|
@@ -626,6 +843,18 @@ declare class CameraWrapper {
|
|
|
626
843
|
*/
|
|
627
844
|
declare function createCamera(options: CameraOptions): CameraWrapper;
|
|
628
845
|
|
|
846
|
+
/**
|
|
847
|
+
* Owns the stage's in-world debug/editor interaction layer.
|
|
848
|
+
*
|
|
849
|
+
* Self-manages around the global `debugState`: when debug is enabled it draws
|
|
850
|
+
* the wasm simulation's collider wireframes, attaches mouse listeners,
|
|
851
|
+
* raycasts into the physics world to hover/select/delete/spawn entities, and
|
|
852
|
+
* drives the `DebugEntityCursor` highlight. When disabled it tears down
|
|
853
|
+
* visuals but stays alive to re-activate. Centralizes all debug-tool plumbing
|
|
854
|
+
* so `ZylemStage` doesn't have to know about raycasting, DOM input, or debug
|
|
855
|
+
* rendering.
|
|
856
|
+
*/
|
|
857
|
+
|
|
629
858
|
type AddEntityFactory = (params: {
|
|
630
859
|
position: Vector3;
|
|
631
860
|
normal?: Vector3;
|
|
@@ -651,15 +880,22 @@ declare class StageDebugDelegate {
|
|
|
651
880
|
private domListenersAttached;
|
|
652
881
|
private debugCursor;
|
|
653
882
|
private debugLines;
|
|
654
|
-
private runtimeDebugLines;
|
|
655
883
|
private cameraDebugDelegate;
|
|
656
884
|
private debugStateUnsubscribe;
|
|
885
|
+
private focusContextUnregister;
|
|
657
886
|
constructor(stage: ZylemStage, options?: StageDebugDelegateOptions);
|
|
887
|
+
/** Camera used for debug orbit / raycasts (active primary, usually `__debug__`). */
|
|
888
|
+
private getDebugViewCamera;
|
|
889
|
+
private resolveEntity;
|
|
890
|
+
/** Copy all stage children into debugMap so raycast/select tools work after enabling debug mid-session. */
|
|
891
|
+
private populateDebugMap;
|
|
892
|
+
private ensureCameraDebugDelegate;
|
|
658
893
|
private syncWithDebugState;
|
|
659
|
-
/** Initialize DOM listeners and
|
|
894
|
+
/** Initialize DOM listeners and switch rendering to the debug orbit camera. */
|
|
660
895
|
private activate;
|
|
661
|
-
/** Tear down visuals and
|
|
896
|
+
/** Tear down visuals and restore the gameplay primary camera. */
|
|
662
897
|
private deactivate;
|
|
898
|
+
private rebindPostProcessing;
|
|
663
899
|
private initDebugVisuals;
|
|
664
900
|
private disposeDebugVisuals;
|
|
665
901
|
update(): void;
|
|
@@ -669,15 +905,16 @@ declare class StageDebugDelegate {
|
|
|
669
905
|
private attachDomListeners;
|
|
670
906
|
}
|
|
671
907
|
|
|
672
|
-
/**
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
908
|
+
/**
|
|
909
|
+
* Stage configuration: types, defaults, and option parsing.
|
|
910
|
+
*
|
|
911
|
+
* Defines the user-facing stage config shape (`StageConfigLike`), the internal
|
|
912
|
+
* `StageConfig` class, and the engine defaults applied to every stage. Its core
|
|
913
|
+
* job is `parseStageOptions`, which untangles the heterogeneous `createStage(...)`
|
|
914
|
+
* argument list (config objects, camera wrappers, sync/async entities) into a
|
|
915
|
+
* normalized `ParsedStageOptions` that `ZylemStage` can consume directly.
|
|
916
|
+
*/
|
|
917
|
+
|
|
681
918
|
type StageGLTFAssetLoaderConfig = {
|
|
682
919
|
meshopt?: boolean;
|
|
683
920
|
ktx2TranscoderPath?: URL | string;
|
|
@@ -698,21 +935,18 @@ type StageConfigLike = Partial<{
|
|
|
698
935
|
/** Physics update rate in Hz (default 60). */
|
|
699
936
|
physicsRate: number;
|
|
700
937
|
assetLoaders: StageAssetLoaderConfig;
|
|
701
|
-
runtimeAdapter: StageRuntimeAdapter;
|
|
702
|
-
/** Binds stage debug policy into wasm runtime adapters (see {@link RuntimeDebugBinding}). */
|
|
703
|
-
runtimeDebugBinding?: RuntimeDebugBinding;
|
|
704
|
-
/**
|
|
705
|
-
* When set, the stage instantiates a {@link WasmStageRuntime} from the given
|
|
706
|
-
* source during `load()`. Behavior descriptors that have been ported to the
|
|
707
|
-
* unified-Stage Rust runtime read this via `BehaviorSystemContext.wasmStage`.
|
|
708
|
-
*/
|
|
709
|
-
wasmRuntime?: StageWasmRuntimeConfig;
|
|
710
938
|
/**
|
|
711
939
|
* When `false`, the engine's built-in ambient + directional lights are
|
|
712
940
|
* suppressed so the stage can be lit entirely via `createLight(...)`
|
|
713
941
|
* entities. Defaults to `true`.
|
|
714
942
|
*/
|
|
715
943
|
defaultLighting: boolean;
|
|
944
|
+
/**
|
|
945
|
+
* Postprocessing effects applied in order between the scene pass and the
|
|
946
|
+
* display output (e.g. effects from `@zylem/shaders`). Only active for
|
|
947
|
+
* single fullscreen-camera rendering.
|
|
948
|
+
*/
|
|
949
|
+
postProcessingEffects: ZylemPostEffect[];
|
|
716
950
|
}>;
|
|
717
951
|
/**
|
|
718
952
|
* Factory for authoring stage configuration objects in user code.
|
|
@@ -720,6 +954,16 @@ type StageConfigLike = Partial<{
|
|
|
720
954
|
*/
|
|
721
955
|
declare function stageConfig(config: StageConfigLike): StageConfigLike;
|
|
722
956
|
|
|
957
|
+
/**
|
|
958
|
+
* Fan-out hub for a stage's loading lifecycle events.
|
|
959
|
+
*
|
|
960
|
+
* Collects start/progress/complete loading events and broadcasts them both to
|
|
961
|
+
* direct per-stage subscribers and to the global `gameEventBus` (tagged with
|
|
962
|
+
* stage name/index) for game-level loading UIs. Exists so the entity-load
|
|
963
|
+
* generator and stage code can emit progress through one place without knowing
|
|
964
|
+
* who is listening.
|
|
965
|
+
*/
|
|
966
|
+
|
|
723
967
|
/**
|
|
724
968
|
* Delegate for managing loading events and progress within a stage.
|
|
725
969
|
* Handles subscription to loading events and broadcasting progress.
|
|
@@ -797,6 +1041,17 @@ declare class StageEntityModelDelegate {
|
|
|
797
1041
|
dispose(): void;
|
|
798
1042
|
}
|
|
799
1043
|
|
|
1044
|
+
/**
|
|
1045
|
+
* The stage's entity lifecycle engine.
|
|
1046
|
+
*
|
|
1047
|
+
* Owns everything about entities within a stage: queuing (sync, async, and
|
|
1048
|
+
* factory inputs), progressive load via a yielding generator, spawning into
|
|
1049
|
+
* scene/world/runtime, instanced-mesh batching, deferred-model handling,
|
|
1050
|
+
* removal, name/UUID lookup, and ECS behavior-system registration/indexing.
|
|
1051
|
+
* Extracted from `ZylemStage` so entity bookkeeping lives in one cohesive place
|
|
1052
|
+
* and can be shared with the debug delegate and transform system.
|
|
1053
|
+
*/
|
|
1054
|
+
|
|
800
1055
|
type NodeLike$1 = {
|
|
801
1056
|
create: Function;
|
|
802
1057
|
};
|
|
@@ -807,12 +1062,9 @@ type StageEntityInput = NodeLike$1 | Promise<any> | (() => NodeLike$1 | Promise<
|
|
|
807
1062
|
interface EntityDelegateContext {
|
|
808
1063
|
scene: ZylemScene;
|
|
809
1064
|
world: ZylemWorld;
|
|
810
|
-
|
|
1065
|
+
renderStrategy: RenderStrategyManager | null;
|
|
811
1066
|
/** Resolved camera for entity setup contexts. */
|
|
812
1067
|
camera: ZylemCamera;
|
|
813
|
-
runtimeAdapter?: StageRuntimeAdapter | null;
|
|
814
|
-
/** Optional unified-Stage wasm runtime (Phase 2+ of the runtime-only migration). */
|
|
815
|
-
wasmStage?: WasmStageRuntime | null;
|
|
816
1068
|
}
|
|
817
1069
|
/**
|
|
818
1070
|
* Delegate responsible for entity spawning, tracking, queuing, removal, and lookup.
|
|
@@ -840,11 +1092,13 @@ declare class StageEntityDelegate {
|
|
|
840
1092
|
private readonly behaviorLinksByUuid;
|
|
841
1093
|
private scene;
|
|
842
1094
|
private world;
|
|
843
|
-
private
|
|
1095
|
+
private renderStrategy;
|
|
844
1096
|
private camera;
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
1097
|
+
/**
|
|
1098
|
+
* The behaviors runtime adapter backing the world's Simulation; shared with
|
|
1099
|
+
* descriptor `systemFactory` calls as `ctx.wasmStage`.
|
|
1100
|
+
*/
|
|
1101
|
+
wasmStage: BehaviorRuntime | null;
|
|
848
1102
|
private loadingDelegate;
|
|
849
1103
|
private entityModelDelegate;
|
|
850
1104
|
constructor(loadingDelegate: StageLoadingDelegate, entityModelDelegate: StageEntityModelDelegate);
|
|
@@ -862,9 +1116,15 @@ declare class StageEntityDelegate {
|
|
|
862
1116
|
spawnEntity(child: BaseNode): Promise<void>;
|
|
863
1117
|
handleLateModelReady(entity: GameEntity<any>): void;
|
|
864
1118
|
/**
|
|
865
|
-
* Register an entity for instanced rendering
|
|
1119
|
+
* Register an entity for bundle or instanced rendering when opted in via
|
|
1120
|
+
* `category: 'environment'` or `category: 'pack'`.
|
|
866
1121
|
*/
|
|
867
|
-
private
|
|
1122
|
+
private tryRegisterRenderStrategy;
|
|
1123
|
+
/**
|
|
1124
|
+
* Environment bundles require static bodies. Force static collision and
|
|
1125
|
+
* patch any already-built body description.
|
|
1126
|
+
*/
|
|
1127
|
+
private ensureEnvironmentStatic;
|
|
868
1128
|
private maybeAttachEntityPhysics;
|
|
869
1129
|
/** Add the entity to internal maps and notify listeners. */
|
|
870
1130
|
addEntityToStage(entity: BaseNode): void;
|
|
@@ -895,15 +1155,12 @@ declare class StageEntityDelegate {
|
|
|
895
1155
|
enqueue(...items: StageEntityInput[]): void;
|
|
896
1156
|
private handleEntityImmediatelyOrQueue;
|
|
897
1157
|
private handlePromiseWithSpawnOnResolve;
|
|
898
|
-
/**
|
|
899
|
-
* Generator that yields between entity loads for real-time progress updates.
|
|
900
|
-
*/
|
|
901
|
-
private entityLoadGenerator;
|
|
902
1158
|
/** Yields to the event loop via MessageChannel (~0.1ms vs ~4ms for setTimeout). */
|
|
903
1159
|
private yieldToEventLoop;
|
|
904
1160
|
/**
|
|
905
|
-
*
|
|
906
|
-
*
|
|
1161
|
+
* Spawns all queued entities, awaiting each attach before the stage is
|
|
1162
|
+
* marked loaded so the game loop never steps wasm while bodies are still
|
|
1163
|
+
* being added. Yields to the event loop in batches for loading UI updates.
|
|
907
1164
|
*/
|
|
908
1165
|
runEntityLoadGenerator(): Promise<void>;
|
|
909
1166
|
/**
|
|
@@ -920,6 +1177,18 @@ declare class StageEntityDelegate {
|
|
|
920
1177
|
private unregisterBehaviorLinks;
|
|
921
1178
|
}
|
|
922
1179
|
|
|
1180
|
+
/**
|
|
1181
|
+
* The runtime heart of a loaded stage.
|
|
1182
|
+
*
|
|
1183
|
+
* `ZylemStage` is the disposable per-load object that actually owns and drives
|
|
1184
|
+
* the scene, physics world, cameras, optional wasm runtime, and the suite of
|
|
1185
|
+
* delegates (entity, camera, loading, model, debug). It parses options into
|
|
1186
|
+
* config, builds scene/world during `load()`, runs the per-frame update loop
|
|
1187
|
+
* (physics step, behavior systems, entity updates, transform sync, camera
|
|
1188
|
+
* updates, render), and tears everything down on destroy. The author-facing
|
|
1189
|
+
* `Stage` wraps and recreates one of these on each load.
|
|
1190
|
+
*/
|
|
1191
|
+
|
|
923
1192
|
interface ZylemStageConfig {
|
|
924
1193
|
inputs: Record<string, string[]>;
|
|
925
1194
|
backgroundColor: Color | string;
|
|
@@ -931,22 +1200,18 @@ interface ZylemStageConfig {
|
|
|
931
1200
|
physicsRate: number;
|
|
932
1201
|
/** Optional runtime loader configuration for stage-managed assets. */
|
|
933
1202
|
assetLoaders?: StageAssetLoaderConfig;
|
|
934
|
-
/** Optional runtime adapter for wasm-driven simulation/rendering. */
|
|
935
|
-
runtimeAdapter?: StageRuntimeAdapter;
|
|
936
|
-
/** Optional debug binding for wasm runtime adapters (heat tint, etc.). */
|
|
937
|
-
runtimeDebugBinding?: RuntimeDebugBinding;
|
|
938
|
-
/**
|
|
939
|
-
* Optional unified-Stage wasm runtime configuration. When set, the stage
|
|
940
|
-
* instantiates a {@link WasmStageRuntime} during `load()` and exposes it
|
|
941
|
-
* to behavior systems via `BehaviorSystemContext.wasmStage`.
|
|
942
|
-
*/
|
|
943
|
-
wasmRuntime?: StageWasmRuntimeConfig;
|
|
944
1203
|
/**
|
|
945
1204
|
* When `false`, suppress the engine's built-in ambient + directional
|
|
946
1205
|
* lights so the stage owns its lighting rig entirely (usually via
|
|
947
1206
|
* `createLight(...)` entities). Defaults to `true`.
|
|
948
1207
|
*/
|
|
949
1208
|
defaultLighting: boolean;
|
|
1209
|
+
/**
|
|
1210
|
+
* Postprocessing effects applied in order between the scene pass and the
|
|
1211
|
+
* display output (e.g. effects from `@zylem/shaders`). Only active for
|
|
1212
|
+
* single fullscreen-camera rendering.
|
|
1213
|
+
*/
|
|
1214
|
+
postProcessingEffects?: ZylemPostEffect[];
|
|
950
1215
|
stageRef?: Stage;
|
|
951
1216
|
}
|
|
952
1217
|
type StageOptionItem = Partial<ZylemStageConfig> | CameraWrapper | StageEntityInput;
|
|
@@ -969,9 +1234,7 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
969
1234
|
gravity: Vector3 | Vec3Components;
|
|
970
1235
|
world: ZylemWorld | null;
|
|
971
1236
|
scene: ZylemScene | null;
|
|
972
|
-
|
|
973
|
-
/** Unified-Stage wasm runtime; non-null only when `wasmRuntime` was configured. */
|
|
974
|
-
wasmStage: WasmStageRuntime | null;
|
|
1237
|
+
renderStrategy: RenderStrategyManager | null;
|
|
975
1238
|
debugDelegate: StageDebugDelegate | null;
|
|
976
1239
|
uuid: string;
|
|
977
1240
|
wrapperRef: Stage | null;
|
|
@@ -982,7 +1245,6 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
982
1245
|
cameraManagerRef: CameraManager | null;
|
|
983
1246
|
/** Shared renderer manager (injected by the game) */
|
|
984
1247
|
rendererManager: RendererManager | null;
|
|
985
|
-
runtimeAdapter: StageRuntimeAdapter | null;
|
|
986
1248
|
private cameraDelegate;
|
|
987
1249
|
private loadingDelegate;
|
|
988
1250
|
private entityModelDelegate;
|
|
@@ -1045,14 +1307,6 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
1045
1307
|
/** Forward to entity delegate. */
|
|
1046
1308
|
enqueue(...items: StageEntityInput[]): void;
|
|
1047
1309
|
logMissingEntities(): void;
|
|
1048
|
-
private runtimeContext;
|
|
1049
|
-
/**
|
|
1050
|
-
* Resolve a {@link StageWasmRuntimeConfig} into a live {@link WasmStageRuntime}.
|
|
1051
|
-
* Accepts wasm bytes (`ArrayBuffer`), a fetch URL, or a deferred async
|
|
1052
|
-
* builder so demos can `?url`-import a Vite asset without forcing the engine
|
|
1053
|
-
* to bundle the wasm itself.
|
|
1054
|
-
*/
|
|
1055
|
-
private loadWasmStage;
|
|
1056
1310
|
/** Add a camera to this stage's camera manager. */
|
|
1057
1311
|
addCamera(camera: ZylemCamera, name?: string): string | null;
|
|
1058
1312
|
/** Remove a camera from this stage's camera manager. */
|
|
@@ -1065,6 +1319,17 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
1065
1319
|
resize(width: number, height: number): void;
|
|
1066
1320
|
}
|
|
1067
1321
|
|
|
1322
|
+
/**
|
|
1323
|
+
* The user-facing stage handle and its fluent authoring API.
|
|
1324
|
+
*
|
|
1325
|
+
* `Stage` is the durable, author-time wrapper game code holds onto: it stores
|
|
1326
|
+
* options, pending entities, and lifecycle/loading callbacks, then constructs
|
|
1327
|
+
* and drives a fresh internal `ZylemStage` on each `load()`. Exists to give a
|
|
1328
|
+
* stable, ergonomic surface (`add`, `onSetup/onUpdate/onDestroy`, camera, input,
|
|
1329
|
+
* and event helpers) that survives stage reloads, while `ZylemStage` owns the
|
|
1330
|
+
* disposable per-load runtime. `createStage(...)` is the entry point.
|
|
1331
|
+
*/
|
|
1332
|
+
|
|
1068
1333
|
type NodeLike = {
|
|
1069
1334
|
create: Function;
|
|
1070
1335
|
};
|
|
@@ -1410,6 +1675,13 @@ declare class ZylemGame<TGlobals extends BaseGlobals> {
|
|
|
1410
1675
|
gameCanvas: GameCanvas | null;
|
|
1411
1676
|
private animationFrameId;
|
|
1412
1677
|
private isDisposed;
|
|
1678
|
+
/**
|
|
1679
|
+
* True while a `loadStage` is in progress. Used to reject re-entrant stage
|
|
1680
|
+
* navigation (e.g. a button press during a transition), which would race
|
|
1681
|
+
* two loads on `stageMap`/the render loop and, because `currentStageId` is
|
|
1682
|
+
* transiently `''`, misresolve the target stage.
|
|
1683
|
+
*/
|
|
1684
|
+
private loadInFlight;
|
|
1413
1685
|
/**
|
|
1414
1686
|
* True once `start()` has been invoked for this game's initial stage.
|
|
1415
1687
|
* Used by `loadStage` to decide whether to drive the stage's `_setup`
|
|
@@ -1421,6 +1693,17 @@ declare class ZylemGame<TGlobals extends BaseGlobals> {
|
|
|
1421
1693
|
private loadingDelegate;
|
|
1422
1694
|
private rendererObserver;
|
|
1423
1695
|
private eventBusUnsubscribes;
|
|
1696
|
+
private thumbnailUnsubscribes;
|
|
1697
|
+
/**
|
|
1698
|
+
* Trailing-debounce timer for entity-driven state dispatches. Building a
|
|
1699
|
+
* `state:dispatch` payload is O(entities) (and downstream editor stores
|
|
1700
|
+
* re-proxy/reconcile every entity), so bursts of thumbnail/destroy events
|
|
1701
|
+
* must coalesce into a single dispatch instead of one per entity.
|
|
1702
|
+
*/
|
|
1703
|
+
private entityDispatchTimer;
|
|
1704
|
+
private pendingEntityDispatchPath;
|
|
1705
|
+
/** Debounce window (ms) for coalescing entity-driven state dispatches. */
|
|
1706
|
+
private static readonly ENTITY_DISPATCH_DEBOUNCE_MS;
|
|
1424
1707
|
private readonly gameUpdateParams;
|
|
1425
1708
|
private readonly stageSetupParams;
|
|
1426
1709
|
private readonly stageUpdateParams;
|
|
@@ -1434,7 +1717,10 @@ declare class ZylemGame<TGlobals extends BaseGlobals> {
|
|
|
1434
1717
|
setDisplayRuntime(runtime: ResolveGameConfigRuntime): void;
|
|
1435
1718
|
loadGameCanvas(config: GameConfig): void;
|
|
1436
1719
|
loadDebugOptions(options: ZylemGameOptions<TGlobals>): void;
|
|
1437
|
-
|
|
1720
|
+
/** Whether a stage load is currently in progress. */
|
|
1721
|
+
isLoading(): boolean;
|
|
1722
|
+
loadStage(stage: Stage, stageIndex?: number, transition?: StageTransitionConfig): Promise<void>;
|
|
1723
|
+
private performLoadStage;
|
|
1438
1724
|
/**
|
|
1439
1725
|
* Merges game-level global input config with the stage's per-stage overrides
|
|
1440
1726
|
* and reconfigures the InputManager.
|
|
@@ -1474,6 +1760,16 @@ declare class ZylemGame<TGlobals extends BaseGlobals> {
|
|
|
1474
1760
|
* Build the entities payload for the current stage.
|
|
1475
1761
|
*/
|
|
1476
1762
|
private buildEntitiesPayload;
|
|
1763
|
+
/**
|
|
1764
|
+
* Generate entity thumbnails as entities become available, then refresh editor state.
|
|
1765
|
+
*/
|
|
1766
|
+
private wireEntityThumbnails;
|
|
1767
|
+
private clearEntityThumbnailWiring;
|
|
1768
|
+
/**
|
|
1769
|
+
* Coalesce entity-driven state dispatches (thumbnail resolutions, entity
|
|
1770
|
+
* destruction) into one trailing `emitStateDispatch` per burst.
|
|
1771
|
+
*/
|
|
1772
|
+
private queueEntityStateDispatch;
|
|
1477
1773
|
/**
|
|
1478
1774
|
* Emit a state:dispatch event to the zylemEventBus.
|
|
1479
1775
|
* Called after stage load and on global state changes.
|
|
@@ -1544,6 +1840,18 @@ declare class Game<TGlobals extends BaseGlobals> implements IGame<TGlobals> {
|
|
|
1544
1840
|
* Get the current stage wrapper.
|
|
1545
1841
|
*/
|
|
1546
1842
|
getCurrentStage(): Stage | null;
|
|
1843
|
+
/**
|
|
1844
|
+
* Experimental escape hatches. APIs here are unstable and may change or be
|
|
1845
|
+
* removed without a major version bump.
|
|
1846
|
+
*/
|
|
1847
|
+
readonly experimental: {
|
|
1848
|
+
/**
|
|
1849
|
+
* The `@zylem/behaviors` {@link Simulation} backing the current stage's
|
|
1850
|
+
* physics world, or `null` before a stage is loaded. Intended for debug
|
|
1851
|
+
* tooling and the editor; games should not need it.
|
|
1852
|
+
*/
|
|
1853
|
+
getRuntime: () => Simulation | null;
|
|
1854
|
+
};
|
|
1547
1855
|
pause(): Promise<void>;
|
|
1548
1856
|
resume(): Promise<void>;
|
|
1549
1857
|
/**
|
|
@@ -1552,10 +1860,27 @@ declare class Game<TGlobals extends BaseGlobals> implements IGame<TGlobals> {
|
|
|
1552
1860
|
* @param deltaTime Optional delta time in seconds (defaults to 1/60)
|
|
1553
1861
|
*/
|
|
1554
1862
|
step(deltaTime?: number): void;
|
|
1555
|
-
|
|
1556
|
-
|
|
1863
|
+
/**
|
|
1864
|
+
* Reload the first stage. Pass `{ transition }` to blend from the current
|
|
1865
|
+
* stage instead of cutting.
|
|
1866
|
+
* @example game.reset({ transition: { duration: 1 } });
|
|
1867
|
+
*/
|
|
1868
|
+
reset(options?: StageNavigationOptions): Promise<void>;
|
|
1869
|
+
/**
|
|
1870
|
+
* Go to the previous stage in the stage array. Pass `{ transition }` to
|
|
1871
|
+
* blend from the current stage instead of cutting.
|
|
1872
|
+
*/
|
|
1873
|
+
previousStage(options?: StageNavigationOptions): void;
|
|
1557
1874
|
loadStageFromId(stageId: string): Promise<void>;
|
|
1558
|
-
|
|
1875
|
+
/**
|
|
1876
|
+
* Go to the next stage. Pass `{ transition }` to blend from the current
|
|
1877
|
+
* stage instead of cutting.
|
|
1878
|
+
* @example
|
|
1879
|
+
* game.nextStage({
|
|
1880
|
+
* transition: { duration: 1.2, shader: createStageTransition({ pattern: 'noise' }) },
|
|
1881
|
+
* });
|
|
1882
|
+
*/
|
|
1883
|
+
nextStage(options?: StageNavigationOptions): void;
|
|
1559
1884
|
goToStage(): Promise<void>;
|
|
1560
1885
|
end(): Promise<void>;
|
|
1561
1886
|
dispose(): void;
|
|
@@ -1587,4 +1912,4 @@ declare class Game<TGlobals extends BaseGlobals> implements IGame<TGlobals> {
|
|
|
1587
1912
|
*/
|
|
1588
1913
|
declare function createGame<TGlobals extends BaseGlobals>(...options: GameOptions<TGlobals>): Game<TGlobals>;
|
|
1589
1914
|
|
|
1590
|
-
export { AspectRatio as A, CameraWrapper as C, type DeviceProfile as D, Fixed2DPerspective as F, Game as G, type PerspectiveOptions as P, type ResolutionInput as R,
|
|
1915
|
+
export { AspectRatio as A, Stage as B, CameraWrapper as C, type DeviceProfile as D, type StageStateInterface as E, Fixed2DPerspective as F, Game as G, type PerspectiveOptions as P, type ResolutionInput as R, type StageConfigLike as S, ThirdPersonPerspective as T, type GameLoadingEvent as a, type GameConfigLike as b, createGame as c, type GameDeviceConfig as d, type ResolveGameConfigRuntime as e, createStage as f, gameConfig as g, type StageOptions as h, createCamera as i, type CameraOptions as j, CameraManager as k, FirstPersonPerspective as l, createPerspective as m, type ThirdPersonOptions as n, type Fixed2DOptions as o, type FirstPersonOptions as p, type AspectRatioValue as q, getDisplayAspect as r, stageConfig as s, getPresetResolution as t, parseResolution as u, type RetroPreset as v, type RetroPresetKey as w, type RetroResolution as x, RenderBundleManager as y, RenderStrategyManager as z };
|