@zylem/game-lib 0.9.2 → 0.9.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.
@@ -681,22 +681,24 @@ export const CameraKeyframeSchema: _sinclair_typebox.TObject<{
681
681
  easing: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"linear">, _sinclair_typebox.TLiteral<"easeIn">, _sinclair_typebox.TLiteral<"easeOut">, _sinclair_typebox.TLiteral<"easeInOut">]>;
682
682
  }>;
683
683
 
684
+ // Warning: (ae-forgotten-export) The symbol "EditorCameraHost" needs to be exported by the entry point public.d.ts
685
+ //
684
686
  // @public
685
- export class CameraManager {
686
- constructor();
687
- activateDebugCamera(): boolean;
687
+ export class CameraManager implements EditorCameraHost {
688
+ activateCameraById(id: string): boolean;
688
689
  // Warning: (ae-forgotten-export) The symbol "ZylemCamera" needs to be exported by the entry point public.d.ts
689
690
  get activeCameras(): ReadonlyArray<ZylemCamera>;
690
691
  addActiveCamera(nameOrRef: string | ZylemCamera): boolean;
691
692
  addCamera(camera: ZylemCamera, name?: string): string;
692
693
  get allCameras(): ReadonlyArray<ZylemCamera>;
693
694
  deactivateCamera(nameOrRef: string | ZylemCamera): boolean;
694
- deactivateDebugCamera(): boolean;
695
- get debugCamera(): ZylemCamera | null;
695
+ destroyEditorCameras(): void;
696
696
  dispose(): void;
697
697
  ensureDefaultCamera(): ZylemCamera;
698
+ ensureEditorCameras(): Promise<void>;
698
699
  getCamera(name: string): ZylemCamera | null;
699
- get preDebugPrimary(): ZylemCamera | null;
700
+ hasEditorCameras(): boolean;
701
+ isEditorViewActive(): boolean;
700
702
  get primaryCamera(): ZylemCamera | null;
701
703
  removeCamera(nameOrRef: string | ZylemCamera): boolean;
702
704
  render(scene: Scene): void;
@@ -2154,6 +2156,7 @@ export class GameBridge {
2154
2156
  // (undocumented)
2155
2157
  disconnect(): void;
2156
2158
  onEditorAttached(callback: () => void): () => void;
2159
+ onEditorDetached(callback: () => void): () => void;
2157
2160
  publishCatalog(entities: EntityTypeDescriptor[]): void;
2158
2161
  // (undocumented)
2159
2162
  publishConfig(config: GameConfigPayload): void;
@@ -6205,8 +6208,8 @@ export class ZylemZone extends GameEntity<ZylemZoneOptions> implements Collision
6205
6208
  // dist/entity-XqvuWgPm.d.ts:343:9 - (ae-forgotten-export) The symbol "EntityMeshBuilder" needs to be exported by the entry point public.d.ts
6206
6209
  // dist/entity-XqvuWgPm.d.ts:344:9 - (ae-forgotten-export) The symbol "EntityCollisionBuilder" needs to be exported by the entry point public.d.ts
6207
6210
  // dist/entity-XqvuWgPm.d.ts:345:9 - (ae-forgotten-export) The symbol "MaterialBuilder" needs to be exported by the entry point public.d.ts
6208
- // dist/game-D8KTP3fD.d.ts:258:5 - (ae-forgotten-export) The symbol "StageInterface" needs to be exported by the entry point public.d.ts
6209
- // dist/stage-CAPlk_cN.d.ts:1117:5 - (ae-forgotten-export) The symbol "StageAssetLoaderConfig" needs to be exported by the entry point public.d.ts
6211
+ // dist/game-DBt7iVu4.d.ts:258:5 - (ae-forgotten-export) The symbol "StageInterface" needs to be exported by the entry point public.d.ts
6212
+ // dist/stage-PBmwT5-Y.d.ts:1150:5 - (ae-forgotten-export) The symbol "StageAssetLoaderConfig" needs to be exported by the entry point public.d.ts
6210
6213
 
6211
6214
  // (No @packageDocumentation comment for this package)
6212
6215
 
@@ -458,8 +458,9 @@ declare type ActorOptions = BaseNode | ZylemActorOptions;
458
458
  * hover/select/delete/spawn, the `DebugEntityCursor` highlight and the
459
459
  * `PlacementGhost` — is live whenever a tool is armed, so the toolbar's buttons
460
460
  * work on their own. The debug layer — the wasm simulation's collider
461
- * wireframes and the orbit camera — is the part `debugState.enabled` gates, and
462
- * is torn down when it goes off while the delegate stays alive to re-activate.
461
+ * wireframes — is the part `debugState.enabled` gates, and is torn down when
462
+ * it goes off while the delegate stays alive to re-activate. Debug mode does
463
+ * not switch cameras; picking and gizmos use whichever camera is rendering.
463
464
  *
464
465
  * Centralizes all of this so `ZylemStage` doesn't have to know about
465
466
  * raycasting, DOM input, or debug rendering.
@@ -958,28 +959,40 @@ export declare const CameraKeyframeSchema: _sinclair_typebox.TObject<{
958
959
  * Responsibilities:
959
960
  * - Named camera registry (add/remove/get by name or reference)
960
961
  * - Active camera list management (determines which cameras render)
961
- * - Always-available debug camera with orbit controls
962
+ * - Editor view cameras (side, top, isometric, free), created only while an editor is attached
962
963
  * - Per-frame update of all active cameras' perspective controllers
963
964
  * - Coordinating rendering via RendererManager for all active viewports
964
965
  */
965
- export declare class CameraManager {
966
+ export declare class CameraManager implements EditorCameraHost {
966
967
  /** Named camera registry */
967
968
  private cameras;
968
969
  /** Currently active cameras, ordered by render layer (first = bottom) */
969
970
  private _activeCameras;
970
- /** Auto-created debug camera with orbit controls */
971
- private _debugCamera;
972
- /** Gameplay primary camera saved while the debug camera is active. */
973
- private _preDebugPrimary;
974
- /** Scene anchor at world origin for debug orbit when nothing is selected. */
975
- private _debugOrbitTargetAnchor;
971
+ /** Editor view cameras, keyed by `editor:*` id. */
972
+ private _editorCameras;
973
+ /** Which editor views freeze rotation. */
974
+ private _lockedEditorIds;
975
+ /** Which editor views pan in screen space (the view plane). */
976
+ private _screenSpacePanIds;
977
+ /** Game camera to restore when the editor releases the main view. */
978
+ private _rememberedGameCamera;
979
+ /**
980
+ * True while an editor view is the main camera. Game calls to
981
+ * {@link setActiveCamera} update {@link _rememberedGameCamera} and leave
982
+ * the view on screen.
983
+ */
984
+ private _editorViewLocked;
985
+ /** Game cameras whose orbit input was suspended for an editor view. */
986
+ private _suspendedOrbits;
987
+ /** In-flight creation, so a second attach does not build a second set. */
988
+ private _editorCamerasPromise;
976
989
  /** Reference to the shared renderer manager */
977
990
  private _rendererManager;
978
991
  /** Scene reference */
979
992
  private _sceneRef;
980
993
  /** Counter for auto-generated camera names */
981
994
  private _autoNameCounter;
982
- constructor();
995
+ private _unregisterEditorHost;
983
996
  /**
984
997
  * Get the list of currently active cameras.
985
998
  */
@@ -988,14 +1001,10 @@ export declare class CameraManager {
988
1001
  * Get the primary active camera (first in the active list).
989
1002
  */
990
1003
  get primaryCamera(): ZylemCamera | null;
991
- /**
992
- * Get the debug camera.
993
- */
994
- get debugCamera(): ZylemCamera | null;
995
- /**
996
- * Gameplay primary camera that was active before debug mode was enabled.
997
- */
998
- get preDebugPrimary(): ZylemCamera | null;
1004
+ /** True while side, top, isometric, or free is the main view. */
1005
+ isEditorViewActive(): boolean;
1006
+ /** True after the four editor views have been created. */
1007
+ hasEditorCameras(): boolean;
999
1008
  /**
1000
1009
  * Get all registered cameras.
1001
1010
  */
@@ -1012,13 +1021,15 @@ export declare class CameraManager {
1012
1021
  addCamera(camera: ZylemCamera, name?: string): string;
1013
1022
  /**
1014
1023
  * Remove a camera by name or reference.
1015
- * Cannot remove the debug camera via this method.
1016
1024
  */
1017
1025
  removeCamera(nameOrRef: string | ZylemCamera): boolean;
1018
1026
  /**
1019
1027
  * Set a camera as the primary active camera (replaces all active cameras
1020
1028
  * except additional viewport cameras).
1021
1029
  *
1030
+ * While an editor view owns the main view, a game camera is remembered
1031
+ * and the rendered camera does not change.
1032
+ *
1022
1033
  * @param nameOrRef Camera name or reference to activate
1023
1034
  */
1024
1035
  setActiveCamera(nameOrRef: string | ZylemCamera): boolean;
@@ -1036,19 +1047,27 @@ export declare class CameraManager {
1036
1047
  getCamera(name: string): ZylemCamera | null;
1037
1048
  /**
1038
1049
  * Setup all cameras with the given scene and renderer manager.
1039
- * Also creates the debug camera.
1050
+ * Editor view cameras are created here only when an editor is already attached.
1040
1051
  */
1041
1052
  setup(scene: Scene, rendererManager: RendererManager): Promise<void>;
1042
1053
  /**
1043
- * Switch the primary viewport to the debug orbit camera, remembering the
1044
- * previous primary so gameplay cameras (e.g. first-person) can be restored.
1054
+ * Create side, top, isometric, and free cameras seeded from the current
1055
+ * game camera. Does not change which camera is rendering.
1056
+ */
1057
+ ensureEditorCameras(): Promise<void>;
1058
+ /**
1059
+ * Restore the game camera when an editor view is showing, then destroy
1060
+ * the four editor cameras.
1045
1061
  */
1046
- activateDebugCamera(): boolean;
1062
+ destroyEditorCameras(): void;
1047
1063
  /**
1048
- * Restore the gameplay primary camera that was active before
1049
- * {@link activateDebugCamera}.
1064
+ * Switch the main view.
1065
+ *
1066
+ * `game` releases to the remembered game camera. Editor view ids show
1067
+ * that view. Any other id activates a game-registered camera and clears
1068
+ * the editor override.
1050
1069
  */
1051
- deactivateDebugCamera(): boolean;
1070
+ activateCameraById(id: string): boolean;
1052
1071
  /**
1053
1072
  * Update all active cameras' controllers.
1054
1073
  */
@@ -1068,16 +1087,19 @@ export declare class CameraManager {
1068
1087
  * Dispose all cameras and cleanup.
1069
1088
  */
1070
1089
  dispose(): void;
1071
- /**
1072
- * Create the always-available debug camera with orbit controls.
1073
- * Registered for lookup/activation, but not added to the active list.
1074
- */
1075
- private createDebugCamera;
1076
- /**
1077
- * Seed the debug camera orbit pose on first activation, framing the origin
1078
- * or offsetting from the saved gameplay primary.
1079
- */
1080
- private seedDebugCameraPose;
1090
+ private createEditorCameras;
1091
+ private showEditorCamera;
1092
+ private showGameCamera;
1093
+ /** Enable orbit on the active editor view only. Inactive views keep their pose. */
1094
+ private syncEditorOrbit;
1095
+ /** Stop game-camera orbit controls from sharing the canvas with an editor view. */
1096
+ private suspendOtherOrbits;
1097
+ private restoreOrbitFor;
1098
+ private gameCameraToRestore;
1099
+ private cameraIsRegistered;
1100
+ private isEditorCamera;
1101
+ /** Replace the primary camera and keep picture-in-picture viewports. */
1102
+ private commitActive;
1081
1103
  /**
1082
1104
  * Resolve a camera from a name or reference.
1083
1105
  */
@@ -2694,6 +2716,19 @@ export { dot }
2694
2716
  */
2695
2717
  export declare function easeValue(easing: CutsceneEasing, t: number): number;
2696
2718
 
2719
+ /**
2720
+ * Editor-view cameras exist only while an editor is attached.
2721
+ *
2722
+ * `GameBridge.connect()` runs for every game, so it is not the signal. The
2723
+ * bridge marks the session attached when an editor subscribes, and every live
2724
+ * camera manager creates or destroys its four view cameras from that flag.
2725
+ */
2726
+ declare interface EditorCameraHost {
2727
+ ensureEditorCameras(): Promise<void>;
2728
+ destroyEditorCameras(): void;
2729
+ activateCameraById(id: string): boolean;
2730
+ }
2731
+
2697
2732
  export { EditorToGameMessages }
2698
2733
 
2699
2734
  export declare type EffectType = Static<typeof EffectTypeSchema>;
@@ -3322,8 +3357,9 @@ export { floor }
3322
3357
  export { Fn }
3323
3358
 
3324
3359
  /**
3325
- * Select an entity by UUID and frame the debug camera to fit it.
3326
- * Enables debug mode so orbit controls are active.
3360
+ * Select an entity by UUID and frame the active editor camera to fit it.
3361
+ * When the game camera is showing, the stage switches to the free editor
3362
+ * camera first. Enables debug mode so the selection is visible.
3327
3363
  *
3328
3364
  * @returns true if the entity was found and framed
3329
3365
  */
@@ -3490,6 +3526,8 @@ export declare class GameBridge {
3490
3526
  * not themselves recorded as new operations.
3491
3527
  */
3492
3528
  private applyingSceneOperation;
3529
+ /** Frame watch used when the channel cannot report subscriber removal. */
3530
+ private editorCameraFrame;
3493
3531
  constructor();
3494
3532
  /**
3495
3533
  * Subscribe to editor commands and announce the game side as ready.
@@ -3542,6 +3580,29 @@ export declare class GameBridge {
3542
3580
  * @returns An unsubscribe function.
3543
3581
  */
3544
3582
  onEditorAttached(callback: () => void): () => void;
3583
+ /**
3584
+ * Run a callback when the editor drops both entity subscriptions.
3585
+ *
3586
+ * Mirrors {@link onEditorAttached}: the first of the pair to unsubscribe
3587
+ * is the same editor finishing teardown, so the callback waits until the
3588
+ * other type is already at zero.
3589
+ *
3590
+ * @returns An unsubscribe function.
3591
+ */
3592
+ onEditorDetached(callback: () => void): () => void;
3593
+ /** True when an editor is listening for entity data. */
3594
+ private editorIsAttached;
3595
+ /** Create the view cameras and, if needed, watch for the editor leaving. */
3596
+ private attachEditorCameras;
3597
+ /** Destroy the view cameras and stop watching for editor removal. */
3598
+ private detachEditorCameras;
3599
+ /**
3600
+ * Published bridge builds do not report the last subscriber leaving.
3601
+ * While the editor is attached, look again each frame and tear the view
3602
+ * cameras down once both entity subscriptions are gone.
3603
+ */
3604
+ private watchEditorDetached;
3605
+ private stopWatchingEditorDetached;
3545
3606
  publishConfig(config: GameConfigPayload): void;
3546
3607
  publishLoading(payload: BridgeLoadingPayload): void;
3547
3608
  publishStatus(status: {
@@ -7620,7 +7681,6 @@ declare class StageDebugDelegate {
7620
7681
  private debugCursor;
7621
7682
  private placementGhost;
7622
7683
  private debugLines;
7623
- private cameraDebugDelegate;
7624
7684
  private debugStateUnsubscribe;
7625
7685
  private focusContextUnregister;
7626
7686
  private entityResolverUnregister;
@@ -7642,7 +7702,7 @@ declare class StageDebugDelegate {
7642
7702
  * point. Without one the tool warns instead of silently doing nothing.
7643
7703
  */
7644
7704
  setAddEntityFactory(factory: AddEntityFactory | null): void;
7645
- /** Camera used for debug orbit / raycasts (active primary, usually `__debug__`). */
7705
+ /** Camera used for raycasts and gizmos: whichever one is rendering. */
7646
7706
  private getDebugViewCamera;
7647
7707
  private resolveEntity;
7648
7708
  /**
@@ -7654,7 +7714,6 @@ declare class StageDebugDelegate {
7654
7714
  private forEachSelectableEntity;
7655
7715
  /** Copy all stage children into debugMap so raycast/select tools work after enabling debug mid-session. */
7656
7716
  private populateDebugMap;
7657
- private ensureCameraDebugDelegate;
7658
7717
  /**
7659
7718
  * Activate/deactivate only when `debugState.enabled` actually flips.
7660
7719
  * Hover and selection write to `debugState` every frame, and `activate()`
@@ -7665,9 +7724,9 @@ declare class StageDebugDelegate {
7665
7724
  /** Hand the transform tool its mode whenever the active tool changes. */
7666
7725
  private syncToolMode;
7667
7726
  private syncGrid;
7668
- /** Initialize DOM listeners and switch rendering to the debug orbit camera. */
7727
+ /** Initialize DOM listeners. The rendering camera stays whatever the editor selected. */
7669
7728
  private activate;
7670
- /** Tear down visuals and restore the gameplay primary camera. */
7729
+ /** Tear down visuals without changing which camera is rendering. */
7671
7730
  private deactivate;
7672
7731
  private rebindPostProcessing;
7673
7732
  /**
@@ -9762,6 +9821,18 @@ declare class ZylemCamera {
9762
9821
  * Disable user-configured orbital controls.
9763
9822
  */
9764
9823
  disableOrbitalControls(): void;
9824
+ /**
9825
+ * Turn on orbit for an editor view camera.
9826
+ *
9827
+ * Locked views keep pan and zoom and freeze the seeded angle. Screen-space
9828
+ * pan keeps those drags on the view plane: side moves on Y and Z, top on
9829
+ * X and Z. The free view can rotate. Controls stay allocated after this so
9830
+ * a later visit keeps the panned pose; use {@link setOrbitInteractionEnabled}
9831
+ * to ignore pointer input while another camera is showing.
9832
+ */
9833
+ armEditorOrbit(lockRotation: boolean, screenSpacePan?: boolean): void;
9834
+ /** Ignore pointer input without disposing orbit controls or their pose. */
9835
+ disarmEditorOrbit(): void;
9765
9836
  /**
9766
9837
  * Whether user orbital controls are enabled.
9767
9838
  */