@zylem/game-lib 0.6.3 → 0.6.4
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/actions.d.ts +5 -5
- package/dist/actions.js +196 -32
- package/dist/actions.js.map +1 -1
- package/dist/behavior/jumper-2d.d.ts +114 -0
- package/dist/behavior/jumper-2d.js +711 -0
- package/dist/behavior/jumper-2d.js.map +1 -0
- package/dist/behavior/platformer-3d.d.ts +14 -14
- package/dist/behavior/platformer-3d.js +347 -104
- package/dist/behavior/platformer-3d.js.map +1 -1
- package/dist/behavior/ricochet-2d.d.ts +4 -3
- package/dist/behavior/ricochet-2d.js +53 -22
- package/dist/behavior/ricochet-2d.js.map +1 -1
- package/dist/behavior/ricochet-3d.d.ts +117 -0
- package/dist/behavior/ricochet-3d.js +443 -0
- package/dist/behavior/ricochet-3d.js.map +1 -0
- package/dist/behavior/screen-visibility.d.ts +79 -0
- package/dist/behavior/screen-visibility.js +358 -0
- package/dist/behavior/screen-visibility.js.map +1 -0
- package/dist/behavior/screen-wrap.d.ts +4 -3
- package/dist/behavior/screen-wrap.js +100 -49
- package/dist/behavior/screen-wrap.js.map +1 -1
- package/dist/behavior/shooter-2d.d.ts +79 -0
- package/dist/behavior/shooter-2d.js +180 -0
- package/dist/behavior/shooter-2d.js.map +1 -0
- package/dist/behavior/thruster.d.ts +5 -4
- package/dist/behavior/thruster.js +133 -75
- package/dist/behavior/thruster.js.map +1 -1
- package/dist/behavior/top-down-movement.d.ts +56 -0
- package/dist/behavior/top-down-movement.js +125 -0
- package/dist/behavior/top-down-movement.js.map +1 -0
- package/dist/behavior/world-boundary-2d.d.ts +4 -3
- package/dist/behavior/world-boundary-2d.js +90 -36
- package/dist/behavior/world-boundary-2d.js.map +1 -1
- package/dist/behavior/world-boundary-3d.d.ts +76 -0
- package/dist/behavior/world-boundary-3d.js +274 -0
- package/dist/behavior/world-boundary-3d.js.map +1 -0
- package/dist/{behavior-descriptor-BWNWmIjv.d.ts → behavior-descriptor-BXnVR8Ki.d.ts} +22 -5
- package/dist/{blueprints-BWGz8fII.d.ts → blueprints-DmbK2dki.d.ts} +2 -2
- package/dist/camera-4XO5gbQH.d.ts +905 -0
- package/dist/camera.d.ts +1 -1
- package/dist/camera.js +876 -289
- package/dist/camera.js.map +1 -1
- package/dist/{composition-DrzFrbqI.d.ts → composition-BASvMKrW.d.ts} +1 -1
- package/dist/{core-DAkskq6Y.d.ts → core-CARRaS55.d.ts} +57 -14
- package/dist/core.d.ts +9 -8
- package/dist/core.js +4519 -1255
- package/dist/core.js.map +1 -1
- package/dist/{entities-DC9ce_vx.d.ts → entities-ChFirVL9.d.ts} +22 -28
- package/dist/entities.d.ts +4 -4
- package/dist/entities.js +1231 -314
- package/dist/entities.js.map +1 -1
- package/dist/{entity-BpbZqg19.d.ts → entity-vj-HTjzU.d.ts} +80 -11
- package/dist/{global-change-Dc8uCKi2.d.ts → global-change-2JvMaz44.d.ts} +1 -1
- package/dist/main.d.ts +718 -19
- package/dist/main.js +12129 -5959
- package/dist/main.js.map +1 -1
- package/dist/physics-pose-DCc4oE44.d.ts +25 -0
- package/dist/physics-protocol-BDD3P5W2.d.ts +200 -0
- package/dist/physics-worker.d.ts +21 -0
- package/dist/physics-worker.js +306 -0
- package/dist/physics-worker.js.map +1 -0
- package/dist/physics.d.ts +205 -0
- package/dist/physics.js +577 -0
- package/dist/physics.js.map +1 -0
- package/dist/{stage-types-BFsm3qsZ.d.ts → stage-types-C19IhuzA.d.ts} +253 -89
- package/dist/stage.d.ts +9 -8
- package/dist/stage.js +3782 -1041
- package/dist/stage.js.map +1 -1
- package/dist/sync-state-machine-CZyspBpj.d.ts +16 -0
- package/dist/{thruster-DhRaJnoL.d.ts → thruster-23lzoPZd.d.ts} +16 -8
- package/dist/world-DfgxoNMt.d.ts +105 -0
- package/package.json +25 -1
- package/dist/camera-B5e4c78l.d.ts +0 -468
- package/dist/world-Be5m1XC1.d.ts +0 -31
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
import { J as UpdateFunction, S as SetupFunction, Z as ZylemShader, I as GameEntity, K as DestroyFunction, L as SetupContext, U as UpdateContext, M as DestroyContext, N as
|
|
1
|
+
import { J as UpdateFunction, S as SetupFunction, Z as ZylemShader, I as GameEntity, K as DestroyFunction, L as SetupContext, U as UpdateContext, M as DestroyContext, N as LoadingEvent, O as BaseNode, P as GameEntityOptions, Q as StageEvents } from './entity-vj-HTjzU.js';
|
|
2
2
|
import * as bitecs from 'bitecs';
|
|
3
3
|
import { defineSystem, IWorld } from 'bitecs';
|
|
4
4
|
import { Scene, Color, Object3D, Vector3, BufferGeometry, Material } from 'three';
|
|
5
|
-
import { Z as ZylemWorld } from './world-
|
|
5
|
+
import { Z as ZylemWorld } from './world-DfgxoNMt.js';
|
|
6
6
|
import { E as Entity, L as LifecycleFunction, S as StageEntity } from './entity-Bq_eNEDI.js';
|
|
7
|
-
import { Z as ZylemCamera, C as CameraManager, R as RendererManager, a as
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import { S as SPRITE_TYPE, Z as ZylemSprite, a as SPHERE_TYPE, b as ZylemSphere, R as RECT_TYPE, c as ZylemRect, T as TEXT_TYPE, d as ZylemText, B as BOX_TYPE, e as ZylemBox, P as PLANE_TYPE, f as ZylemPlane, g as ZONE_TYPE, h as ZylemZone, A as ACTOR_TYPE, i as ZylemActor, C as CONE_TYPE, j as ZylemCone, k as PYRAMID_TYPE, l as ZylemPyramid, m as CYLINDER_TYPE, n as ZylemCylinder, o as PILL_TYPE, p as ZylemPill } from './entities-
|
|
11
|
-
import { B as BehaviorSystem, a as BehaviorSystemFactory } from './behavior-descriptor-
|
|
7
|
+
import { Z as ZylemCamera, C as CameraManager, R as RendererManager, a as CameraWrapper } from './camera-4XO5gbQH.js';
|
|
8
|
+
import { B as BaseEntityInterface, G as GameEntityInterface } from './entity-types-DAu8sGJH.js';
|
|
9
|
+
import { b as PhysicsPoseReadable } from './physics-pose-DCc4oE44.js';
|
|
10
|
+
import { S as SPRITE_TYPE, Z as ZylemSprite, a as SPHERE_TYPE, b as ZylemSphere, R as RECT_TYPE, c as ZylemRect, T as TEXT_TYPE, d as ZylemText, B as BOX_TYPE, e as ZylemBox, P as PLANE_TYPE, f as ZylemPlane, g as ZONE_TYPE, h as ZylemZone, A as ACTOR_TYPE, i as ZylemActor, C as CONE_TYPE, j as ZylemCone, k as PYRAMID_TYPE, l as ZylemPyramid, m as CYLINDER_TYPE, n as ZylemCylinder, o as PILL_TYPE, p as ZylemPill } from './entities-ChFirVL9.js';
|
|
11
|
+
import { B as BehaviorSystem, a as BehaviorEntityLink, b as BehaviorSystemFactory } from './behavior-descriptor-BXnVR8Ki.js';
|
|
12
12
|
|
|
13
13
|
type BasicTypes = number | string | boolean;
|
|
14
14
|
type BaseGlobals = Record<string, BasicTypes>;
|
|
15
15
|
type KeyboardMapping = Record<string, string[]>;
|
|
16
16
|
type MouseMapping = Record<string, string[]>;
|
|
17
|
+
interface MouseConfig {
|
|
18
|
+
/** Custom mapping from mouse actions to input properties. */
|
|
19
|
+
mapping?: MouseMapping;
|
|
20
|
+
/** Whether to capture the cursor via Pointer Lock API. */
|
|
21
|
+
pointerLock?: boolean;
|
|
22
|
+
/** Sensitivity multiplier for mouse movement (default 0.002). */
|
|
23
|
+
sensitivity?: number;
|
|
24
|
+
}
|
|
17
25
|
interface GameInputPlayerConfig {
|
|
18
26
|
key?: KeyboardMapping;
|
|
19
|
-
mouse?:
|
|
27
|
+
mouse?: MouseConfig;
|
|
20
28
|
includeDefaults?: boolean;
|
|
21
29
|
}
|
|
22
30
|
interface GameInputConfig {
|
|
@@ -100,6 +108,7 @@ declare class ZylemScene implements Entity<ZylemScene> {
|
|
|
100
108
|
* Uses entity's current body position if physics is active.
|
|
101
109
|
*/
|
|
102
110
|
addEntityGroup(entity: GameEntity<any>): void;
|
|
111
|
+
private isAttachedOutsideScene;
|
|
103
112
|
/**
|
|
104
113
|
* Add debug helpers to scene
|
|
105
114
|
*/
|
|
@@ -214,8 +223,11 @@ declare abstract class LifeCycleBase<TSelf> {
|
|
|
214
223
|
|
|
215
224
|
type StageSystem = {
|
|
216
225
|
_childrenMap: Map<number, StageEntity & {
|
|
217
|
-
body:
|
|
226
|
+
body: PhysicsPoseReadable | null;
|
|
218
227
|
}>;
|
|
228
|
+
_world: {
|
|
229
|
+
interpolationAlpha: number;
|
|
230
|
+
} | null;
|
|
219
231
|
};
|
|
220
232
|
type TransformSystemResult = {
|
|
221
233
|
system: ReturnType<typeof defineSystem>;
|
|
@@ -231,33 +243,236 @@ interface StageDebugDelegateOptions {
|
|
|
231
243
|
maxRayDistance?: number;
|
|
232
244
|
addEntityFactory?: AddEntityFactory | null;
|
|
233
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Self-managing debug delegate that subscribes to `debugState` internally.
|
|
248
|
+
*
|
|
249
|
+
* When debug is enabled it lazily initializes visuals and DOM listeners.
|
|
250
|
+
* When debug is disabled it tears down visuals but stays alive so it can
|
|
251
|
+
* re-activate without being recreated. Call `dispose()` to fully tear down.
|
|
252
|
+
*/
|
|
234
253
|
declare class StageDebugDelegate {
|
|
235
254
|
private stage;
|
|
236
255
|
private options;
|
|
237
256
|
private mouseNdc;
|
|
238
257
|
private raycaster;
|
|
239
258
|
private isMouseDown;
|
|
240
|
-
private
|
|
259
|
+
private domDisposeFns;
|
|
260
|
+
private domListenersAttached;
|
|
241
261
|
private debugCursor;
|
|
242
262
|
private debugLines;
|
|
263
|
+
private cameraDebugDelegate;
|
|
264
|
+
private debugStateUnsubscribe;
|
|
243
265
|
constructor(stage: ZylemStage, options?: StageDebugDelegateOptions);
|
|
266
|
+
private syncWithDebugState;
|
|
267
|
+
/** Initialize DOM listeners and camera debug delegate when debug is turned on. */
|
|
268
|
+
private activate;
|
|
269
|
+
/** Tear down visuals and camera debug delegate when debug is turned off. */
|
|
270
|
+
private deactivate;
|
|
244
271
|
private initDebugVisuals;
|
|
245
272
|
private disposeDebugVisuals;
|
|
246
273
|
update(): void;
|
|
274
|
+
/** Full teardown — unsubscribes from debugState and cleans up all resources. */
|
|
247
275
|
dispose(): void;
|
|
248
276
|
private handleActionOnHit;
|
|
249
277
|
private attachDomListeners;
|
|
250
278
|
}
|
|
251
279
|
|
|
252
280
|
/**
|
|
253
|
-
*
|
|
281
|
+
* Delegate for managing loading events and progress within a stage.
|
|
282
|
+
* Handles subscription to loading events and broadcasting progress.
|
|
283
|
+
* Emits to game event bus for game-level observation.
|
|
254
284
|
*/
|
|
255
|
-
declare class
|
|
256
|
-
private
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
285
|
+
declare class StageLoadingDelegate {
|
|
286
|
+
private loadingHandlers;
|
|
287
|
+
private stageName?;
|
|
288
|
+
private stageIndex?;
|
|
289
|
+
/**
|
|
290
|
+
* Set stage context for event bus emissions.
|
|
291
|
+
*/
|
|
292
|
+
setStageContext(stageName: string, stageIndex: number): void;
|
|
293
|
+
/**
|
|
294
|
+
* Subscribe to loading events.
|
|
295
|
+
*
|
|
296
|
+
* @param callback Invoked for each loading event (start, progress, complete)
|
|
297
|
+
* @returns Unsubscribe function
|
|
298
|
+
*/
|
|
299
|
+
onLoading(callback: (event: LoadingEvent) => void): () => void;
|
|
300
|
+
/**
|
|
301
|
+
* Emit a loading event to all subscribers and to the game event bus.
|
|
302
|
+
*
|
|
303
|
+
* @param event The loading event to broadcast
|
|
304
|
+
*/
|
|
305
|
+
emit(event: LoadingEvent): void;
|
|
306
|
+
/**
|
|
307
|
+
* Emit a start loading event.
|
|
308
|
+
*/
|
|
309
|
+
emitStart(message?: string): void;
|
|
310
|
+
/**
|
|
311
|
+
* Emit a progress loading event.
|
|
312
|
+
*/
|
|
313
|
+
emitProgress(message: string, current: number, total: number): void;
|
|
314
|
+
/**
|
|
315
|
+
* Emit a complete loading event.
|
|
316
|
+
*/
|
|
317
|
+
emitComplete(message?: string): void;
|
|
318
|
+
/**
|
|
319
|
+
* Clear all loading handlers.
|
|
320
|
+
*/
|
|
321
|
+
dispose(): void;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Delegate for handling deferred model loading in entities.
|
|
326
|
+
* Subscribes to model:loaded events and adds entity groups to the scene
|
|
327
|
+
* when they become available after async loading completes.
|
|
328
|
+
*/
|
|
329
|
+
declare class StageEntityModelDelegate {
|
|
330
|
+
private scene;
|
|
331
|
+
private onEntityReady;
|
|
332
|
+
private pendingEntities;
|
|
333
|
+
private modelLoadedHandler;
|
|
334
|
+
/**
|
|
335
|
+
* Initialize the delegate with the scene reference and start listening.
|
|
336
|
+
*/
|
|
337
|
+
attach(scene: ZylemScene, onEntityReady?: (entity: GameEntity<any>) => void): void;
|
|
338
|
+
/**
|
|
339
|
+
* Register an entity for observation.
|
|
340
|
+
* When its model loads, the group will be added to the scene.
|
|
341
|
+
*/
|
|
342
|
+
observe(entity: GameEntity<any>): void;
|
|
343
|
+
/**
|
|
344
|
+
* Unregister an entity (e.g., when removed before model loads).
|
|
345
|
+
*/
|
|
346
|
+
unobserve(entityId: string): void;
|
|
347
|
+
/**
|
|
348
|
+
* Handle model loaded event - add group to scene if entity is pending.
|
|
349
|
+
*/
|
|
350
|
+
private handleModelLoaded;
|
|
351
|
+
/**
|
|
352
|
+
* Cleanup all subscriptions and pending entities.
|
|
353
|
+
*/
|
|
354
|
+
dispose(): void;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
type NodeLike$1 = {
|
|
358
|
+
create: Function;
|
|
359
|
+
};
|
|
360
|
+
type StageEntityInput = NodeLike$1 | Promise<any> | (() => NodeLike$1 | Promise<any>);
|
|
361
|
+
/**
|
|
362
|
+
* Runtime context provided by ZylemStage after scene and world are initialized.
|
|
363
|
+
*/
|
|
364
|
+
interface EntityDelegateContext {
|
|
365
|
+
scene: ZylemScene;
|
|
366
|
+
world: ZylemWorld;
|
|
367
|
+
ecs: ReturnType<typeof bitecs.createWorld>;
|
|
368
|
+
instanceManager: InstanceManager | null;
|
|
369
|
+
/** Resolved camera for entity setup contexts. */
|
|
370
|
+
camera: ZylemCamera;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Delegate responsible for entity spawning, tracking, queuing, removal, and lookup.
|
|
374
|
+
*
|
|
375
|
+
* Owns all entity-related state and exposes it to ZylemStage for orchestration
|
|
376
|
+
* and to external consumers (debug delegate, transform system) via public getters.
|
|
377
|
+
*/
|
|
378
|
+
declare class StageEntityDelegate {
|
|
379
|
+
private static readonly EMPTY_BEHAVIOR_LINKS;
|
|
380
|
+
/** Entities queued before load completes. */
|
|
381
|
+
children: BaseNode[];
|
|
382
|
+
/** EID → BaseNode map of all live entities. */
|
|
383
|
+
readonly childrenMap: Map<number, BaseNode>;
|
|
384
|
+
/** UUID → BaseNode map populated when debug mode is active. */
|
|
385
|
+
readonly debugMap: Map<string, BaseNode>;
|
|
386
|
+
/** UUID → EID reverse lookup for O(1) removal. */
|
|
387
|
+
private readonly uuidToEid;
|
|
388
|
+
private pendingEntities;
|
|
389
|
+
private pendingPromises;
|
|
390
|
+
private _isLoaded;
|
|
391
|
+
private entityAddedHandlers;
|
|
392
|
+
/** ECS behavior systems auto-registered from entity refs or manually added. */
|
|
393
|
+
readonly behaviorSystems: BehaviorSystem[];
|
|
394
|
+
readonly registeredSystemKeys: Set<symbol>;
|
|
395
|
+
readonly behaviorEntityIndex: Map<symbol, Set<BehaviorEntityLink>>;
|
|
396
|
+
private readonly behaviorLinksByUuid;
|
|
397
|
+
private scene;
|
|
398
|
+
private world;
|
|
399
|
+
private ecs;
|
|
400
|
+
private instanceManager;
|
|
401
|
+
private camera;
|
|
402
|
+
private loadingDelegate;
|
|
403
|
+
private entityModelDelegate;
|
|
404
|
+
constructor(loadingDelegate: StageLoadingDelegate, entityModelDelegate: StageEntityModelDelegate);
|
|
405
|
+
get isLoaded(): boolean;
|
|
406
|
+
set isLoaded(value: boolean);
|
|
407
|
+
/**
|
|
408
|
+
* Bind runtime context after scene and world are initialized.
|
|
409
|
+
* Must be called before any spawn/enqueue operations.
|
|
410
|
+
*/
|
|
411
|
+
attach(context: EntityDelegateContext): void;
|
|
412
|
+
/**
|
|
413
|
+
* Create, register, and add an entity to the scene/world.
|
|
414
|
+
* Safe to call only after `attach` when scene/world exist.
|
|
415
|
+
*/
|
|
416
|
+
spawnEntity(child: BaseNode): Promise<void>;
|
|
417
|
+
handleLateModelReady(entity: GameEntity<any>): void;
|
|
418
|
+
/**
|
|
419
|
+
* Register an entity for instanced rendering if opted in with `batched: true`.
|
|
420
|
+
*/
|
|
421
|
+
private tryRegisterInstance;
|
|
422
|
+
private maybeAttachEntityPhysics;
|
|
423
|
+
/** Add the entity to internal maps and notify listeners. */
|
|
424
|
+
addEntityToStage(entity: BaseNode): void;
|
|
425
|
+
/**
|
|
426
|
+
* Remove an entity and its resources by its UUID.
|
|
427
|
+
* Uses a uuid→eid reverse map for O(1) lookup.
|
|
428
|
+
* @returns true if removed, false if not found or stage not ready
|
|
429
|
+
*/
|
|
430
|
+
removeEntityByUuid(uuid: string): boolean;
|
|
431
|
+
/** Get an entity by its name; returns null if not found. */
|
|
432
|
+
getEntityByName(name: string): BaseNode | null;
|
|
433
|
+
/** Build a serializable state snapshot for an entity. */
|
|
434
|
+
buildEntityState(child: BaseNode): Partial<BaseEntityInterface>;
|
|
435
|
+
/**
|
|
436
|
+
* Subscribe to entity-added events.
|
|
437
|
+
* @param callback Invoked for each entity when added
|
|
438
|
+
* @param options.replayExisting If true and stage already loaded, replays existing entities
|
|
439
|
+
* @returns Unsubscribe function
|
|
440
|
+
*/
|
|
441
|
+
onEntityAdded(callback: (entity: BaseNode) => void, options?: {
|
|
442
|
+
replayExisting?: boolean;
|
|
443
|
+
}): () => void;
|
|
444
|
+
/**
|
|
445
|
+
* Enqueue items to be spawned. Items can be:
|
|
446
|
+
* - BaseNode instances (immediate or deferred until load)
|
|
447
|
+
* - Factory functions returning BaseNode or Promise<BaseNode>
|
|
448
|
+
* - Promises resolving to BaseNode
|
|
449
|
+
*/
|
|
450
|
+
enqueue(...items: StageEntityInput[]): void;
|
|
451
|
+
private handleEntityImmediatelyOrQueue;
|
|
452
|
+
private handlePromiseWithSpawnOnResolve;
|
|
453
|
+
/**
|
|
454
|
+
* Generator that yields between entity loads for real-time progress updates.
|
|
455
|
+
*/
|
|
456
|
+
private entityLoadGenerator;
|
|
457
|
+
/** Yields to the event loop via MessageChannel (~0.1ms vs ~4ms for setTimeout). */
|
|
458
|
+
private yieldToEventLoop;
|
|
459
|
+
/**
|
|
460
|
+
* Runs the entity load generator, yielding to the event loop in batches.
|
|
461
|
+
* Emits progress events through the loading delegate.
|
|
462
|
+
*/
|
|
463
|
+
runEntityLoadGenerator(): Promise<void>;
|
|
464
|
+
/**
|
|
465
|
+
* Register an ECS behavior system to run each frame.
|
|
466
|
+
* @param systemOrFactory A BehaviorSystem instance or factory function
|
|
467
|
+
*/
|
|
468
|
+
registerSystem(systemOrFactory: BehaviorSystem | BehaviorSystemFactory): void;
|
|
469
|
+
/**
|
|
470
|
+
* Destroy all entities and clear internal state.
|
|
471
|
+
* Called by ZylemStage._destroy().
|
|
472
|
+
*/
|
|
473
|
+
destroyAll(): void;
|
|
474
|
+
private registerBehaviorLinks;
|
|
475
|
+
private unregisterBehaviorLinks;
|
|
261
476
|
}
|
|
262
477
|
|
|
263
478
|
interface ZylemStageConfig {
|
|
@@ -267,12 +482,14 @@ interface ZylemStageConfig {
|
|
|
267
482
|
backgroundShader: any | null;
|
|
268
483
|
gravity: Vector3;
|
|
269
484
|
variables: Record<string, any>;
|
|
485
|
+
/** Physics update rate in Hz (default 60). */
|
|
486
|
+
physicsRate: number;
|
|
487
|
+
/** Run physics in a Web Worker for true parallelism (default false). */
|
|
488
|
+
usePhysicsWorker: boolean;
|
|
489
|
+
/** URL to the physics worker script (required when usePhysicsWorker is true). */
|
|
490
|
+
physicsWorkerUrl?: URL | string;
|
|
270
491
|
stageRef?: Stage;
|
|
271
492
|
}
|
|
272
|
-
type NodeLike$1 = {
|
|
273
|
-
create: Function;
|
|
274
|
-
};
|
|
275
|
-
type StageEntityInput = NodeLike$1 | Promise<any> | (() => NodeLike$1 | Promise<any>);
|
|
276
493
|
type StageOptionItem = Partial<ZylemStageConfig> | CameraWrapper | StageEntityInput;
|
|
277
494
|
type StageOptions = [] | [Partial<ZylemStageConfig>, ...StageOptionItem[]];
|
|
278
495
|
type StageState = ZylemStageConfig & {
|
|
@@ -284,7 +501,7 @@ type StageState = ZylemStageConfig & {
|
|
|
284
501
|
* Responsibilities:
|
|
285
502
|
* - Manage stage configuration (background, inputs, gravity, variables)
|
|
286
503
|
* - Initialize and own `ZylemScene` and `ZylemWorld`
|
|
287
|
-
* -
|
|
504
|
+
* - Coordinate delegates for entities, camera, loading, debug, and models
|
|
288
505
|
* - Drive per-frame updates and transform system
|
|
289
506
|
*/
|
|
290
507
|
declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
@@ -294,22 +511,9 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
294
511
|
world: ZylemWorld | null;
|
|
295
512
|
scene: ZylemScene | null;
|
|
296
513
|
instanceManager: InstanceManager | null;
|
|
297
|
-
children: Array<BaseNode>;
|
|
298
|
-
_childrenMap: Map<number, BaseNode>;
|
|
299
|
-
_removalMap: Map<number, BaseNode>;
|
|
300
|
-
private pendingEntities;
|
|
301
|
-
private pendingPromises;
|
|
302
|
-
private isLoaded;
|
|
303
|
-
_debugMap: Map<string, BaseNode>;
|
|
304
|
-
private entityAddedHandlers;
|
|
305
514
|
ecs: bitecs.IWorld;
|
|
306
|
-
testSystem: any;
|
|
307
515
|
transformSystem: ReturnType<typeof createTransformSystem> | null;
|
|
308
|
-
private behaviorSystems;
|
|
309
|
-
private registeredSystemKeys;
|
|
310
516
|
debugDelegate: StageDebugDelegate | null;
|
|
311
|
-
cameraDebugDelegate: StageCameraDebugDelegate | null;
|
|
312
|
-
private debugStateUnsubscribe;
|
|
313
517
|
uuid: string;
|
|
314
518
|
wrapperRef: Stage | null;
|
|
315
519
|
camera?: CameraWrapper;
|
|
@@ -322,14 +526,14 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
322
526
|
private cameraDelegate;
|
|
323
527
|
private loadingDelegate;
|
|
324
528
|
private entityModelDelegate;
|
|
529
|
+
private readonly childUpdateParams;
|
|
530
|
+
/** Entity management delegate — public for external consumers (debug, transform system). */
|
|
531
|
+
readonly entityDelegate: StageEntityDelegate;
|
|
325
532
|
/**
|
|
326
533
|
* Create a new stage.
|
|
327
534
|
* @param options Stage options: partial config, camera, and initial entities or factories
|
|
328
535
|
*/
|
|
329
536
|
constructor(options?: StageOptions);
|
|
330
|
-
private handleEntityImmediatelyOrQueue;
|
|
331
|
-
private handlePromiseWithSpawnOnResolve;
|
|
332
|
-
private saveState;
|
|
333
537
|
private setState;
|
|
334
538
|
/**
|
|
335
539
|
* Load and initialize the stage's scene and world.
|
|
@@ -338,42 +542,18 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
338
542
|
* @param camera Optional camera override
|
|
339
543
|
*/
|
|
340
544
|
load(id: string, camera?: ZylemCamera | null, rendererManager?: RendererManager | null): Promise<void>;
|
|
341
|
-
/**
|
|
342
|
-
* Generator that yields between entity loads for real-time progress updates.
|
|
343
|
-
*/
|
|
344
|
-
private entityLoadGenerator;
|
|
345
|
-
/**
|
|
346
|
-
* Runs the entity load generator, yielding to the event loop between loads.
|
|
347
|
-
* This allows the browser to process events and update the UI in real-time.
|
|
348
|
-
*/
|
|
349
|
-
private runEntityLoadGenerator;
|
|
350
545
|
protected _setup(params: SetupContext<ZylemStage>): void;
|
|
351
|
-
private updateDebugDelegate;
|
|
352
546
|
protected _update(params: UpdateContext<ZylemStage>): void;
|
|
353
547
|
outOfLoop(): void;
|
|
354
548
|
/** Update debug overlays and helpers if enabled. */
|
|
355
549
|
debugUpdate(): void;
|
|
356
550
|
/** Cleanup owned resources when the stage is destroyed. */
|
|
357
551
|
protected _destroy(params: DestroyContext<ZylemStage>): void;
|
|
358
|
-
/**
|
|
359
|
-
* Create, register, and add an entity to the scene/world.
|
|
360
|
-
* Safe to call only after `load` when scene/world exist.
|
|
361
|
-
*/
|
|
552
|
+
/** Forward to entity delegate. */
|
|
362
553
|
spawnEntity(child: BaseNode): Promise<void>;
|
|
363
|
-
/**
|
|
364
|
-
* Try to register an entity for instanced rendering.
|
|
365
|
-
* Batching is enabled by default unless explicitly disabled with batched: false.
|
|
366
|
-
*/
|
|
367
|
-
private tryRegisterInstance;
|
|
554
|
+
/** Forward to entity delegate. */
|
|
368
555
|
buildEntityState(child: BaseNode): Partial<BaseEntityInterface>;
|
|
369
|
-
/**
|
|
370
|
-
addEntityToStage(entity: BaseNode): void;
|
|
371
|
-
/**
|
|
372
|
-
* Subscribe to entity-added events.
|
|
373
|
-
* @param callback Invoked for each entity when added
|
|
374
|
-
* @param options.replayExisting If true and stage already loaded, replays existing entities
|
|
375
|
-
* @returns Unsubscribe function
|
|
376
|
-
*/
|
|
556
|
+
/** Forward to entity delegate. */
|
|
377
557
|
onEntityAdded(callback: (entity: BaseNode) => void, options?: {
|
|
378
558
|
replayExisting?: boolean;
|
|
379
559
|
}): () => void;
|
|
@@ -384,39 +564,23 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
384
564
|
* @returns this for chaining
|
|
385
565
|
*/
|
|
386
566
|
registerSystem(systemOrFactory: BehaviorSystem | BehaviorSystemFactory): this;
|
|
387
|
-
/**
|
|
388
|
-
* Remove an entity and its resources by its UUID.
|
|
389
|
-
* @returns true if removed, false if not found or stage not ready
|
|
390
|
-
*/
|
|
567
|
+
/** Forward to entity delegate. */
|
|
391
568
|
removeEntityByUuid(uuid: string): boolean;
|
|
392
|
-
/**
|
|
569
|
+
/** Forward to entity delegate. */
|
|
393
570
|
getEntityByName(name: string): BaseNode<any, any> | null;
|
|
571
|
+
/** Forward to entity delegate. */
|
|
572
|
+
enqueue(...items: StageEntityInput[]): void;
|
|
394
573
|
logMissingEntities(): void;
|
|
395
|
-
/**
|
|
396
|
-
* Add a camera to this stage's camera manager.
|
|
397
|
-
*/
|
|
574
|
+
/** Add a camera to this stage's camera manager. */
|
|
398
575
|
addCamera(camera: ZylemCamera, name?: string): string | null;
|
|
399
|
-
/**
|
|
400
|
-
* Remove a camera from this stage's camera manager.
|
|
401
|
-
*/
|
|
576
|
+
/** Remove a camera from this stage's camera manager. */
|
|
402
577
|
removeCamera(nameOrRef: string | ZylemCamera): boolean;
|
|
403
|
-
/**
|
|
404
|
-
* Set the active camera by name or reference.
|
|
405
|
-
*/
|
|
578
|
+
/** Set the active camera by name or reference. */
|
|
406
579
|
setActiveCamera(nameOrRef: string | ZylemCamera): boolean;
|
|
407
|
-
/**
|
|
408
|
-
* Get a camera by name from the camera manager.
|
|
409
|
-
*/
|
|
580
|
+
/** Get a camera by name from the camera manager. */
|
|
410
581
|
getCamera(name: string): ZylemCamera | null;
|
|
411
582
|
/** Resize renderer viewport. */
|
|
412
583
|
resize(width: number, height: number): void;
|
|
413
|
-
/**
|
|
414
|
-
* Enqueue items to be spawned. Items can be:
|
|
415
|
-
* - BaseNode instances (immediate or deferred until load)
|
|
416
|
-
* - Factory functions returning BaseNode or Promise<BaseNode>
|
|
417
|
-
* - Promises resolving to BaseNode
|
|
418
|
-
*/
|
|
419
|
-
enqueue(...items: StageEntityInput[]): void;
|
|
420
584
|
}
|
|
421
585
|
|
|
422
586
|
type ZylemDiskOptions = GameEntityOptions & {
|
package/dist/stage.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { S as StageStateInterface } from './stage-types-
|
|
2
|
-
export { a as StageOptions, c as createStage } from './stage-types-
|
|
3
|
-
export { S as StageBlueprint, e as entitySpawner } from './blueprints-
|
|
4
|
-
import './entity-
|
|
1
|
+
import { S as StageStateInterface } from './stage-types-C19IhuzA.js';
|
|
2
|
+
export { a as StageOptions, c as createStage } from './stage-types-C19IhuzA.js';
|
|
3
|
+
export { S as StageBlueprint, e as entitySpawner } from './blueprints-DmbK2dki.js';
|
|
4
|
+
import './entity-vj-HTjzU.js';
|
|
5
5
|
import 'three';
|
|
6
6
|
import '@dimforge/rapier3d-compat';
|
|
7
7
|
import 'bitecs';
|
|
8
8
|
import 'mitt';
|
|
9
|
-
import './behavior-descriptor-
|
|
10
|
-
import './world-
|
|
9
|
+
import './behavior-descriptor-BXnVR8Ki.js';
|
|
10
|
+
import './world-DfgxoNMt.js';
|
|
11
11
|
import './entity-Bq_eNEDI.js';
|
|
12
|
-
import './camera-
|
|
12
|
+
import './camera-4XO5gbQH.js';
|
|
13
13
|
import 'three/webgpu';
|
|
14
14
|
import 'three/examples/jsm/postprocessing/EffectComposer.js';
|
|
15
15
|
import './entity-types-DAu8sGJH.js';
|
|
16
|
-
import './
|
|
16
|
+
import './physics-pose-DCc4oE44.js';
|
|
17
|
+
import './entities-ChFirVL9.js';
|
|
17
18
|
import '@sinclair/typebox';
|
|
18
19
|
|
|
19
20
|
/**
|