@zylem/game-lib 0.8.4 → 0.8.7

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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/dist/actions.d.ts +7 -5
  3. package/dist/api/game-lib.api.json +3529 -500
  4. package/dist/api/game-lib.api.md +188 -10
  5. package/dist/api/game-lib.d.ts +510 -11
  6. package/dist/api/game-lib.typedoc.json +218291 -134637
  7. package/dist/base-node-idopiSw5.d.ts +96 -0
  8. package/dist/bridge.d.ts +30 -6
  9. package/dist/bridge.js +1 -1
  10. package/dist/catalog.d.ts +77 -0
  11. package/dist/catalog.js +1 -0
  12. package/dist/{chunk-TV3AZKT4.js → chunk-34MYRTRP.js} +1 -1
  13. package/dist/{chunk-CM5YRNBJ.js → chunk-7NYP4YAG.js} +1 -1
  14. package/dist/chunk-AE3CTVHY.js +1 -0
  15. package/dist/chunk-BCFFS3FP.js +1 -0
  16. package/dist/chunk-BMRFDDMR.js +1 -0
  17. package/dist/chunk-CBUQBP2U.js +1 -0
  18. package/dist/chunk-EVMLNMGU.js +1 -0
  19. package/dist/chunk-F5LROYZL.js +24 -0
  20. package/dist/chunk-GHJQ2HKI.js +1 -0
  21. package/dist/chunk-IBJLPJLE.js +1 -0
  22. package/dist/chunk-MXO4VGDB.js +1 -0
  23. package/dist/{chunk-VIPINV7V.js → chunk-Q2YDBMVY.js} +1 -1
  24. package/dist/chunk-QDQ4QMAI.js +1 -0
  25. package/dist/chunk-SAQA4SXW.js +1 -0
  26. package/dist/chunk-YOVE25NW.js +1 -0
  27. package/dist/chunk-ZTYNZ2N2.js +1 -0
  28. package/dist/{collision-builder-4TVDzXsp.d.ts → collision-builder-BckxkdmA.d.ts} +1 -1
  29. package/dist/core.d.ts +14 -11
  30. package/dist/core.js +1 -1
  31. package/dist/debug-state-CpnNRUFh.d.ts +97 -0
  32. package/dist/debug.d.ts +194 -7
  33. package/dist/debug.js +1 -1
  34. package/dist/{entity-DDks47JB.d.ts → entity-BIf_a4dl.d.ts} +1 -1
  35. package/dist/{entity-BI7cSlK8.d.ts → entity-XZNGBeca.d.ts} +32 -98
  36. package/dist/{entity-type-map-COHu4fkW.d.ts → entity-type-map-CkkFMSrL.d.ts} +5 -4
  37. package/dist/entity.d.ts +9 -7
  38. package/dist/entity.js +1 -1
  39. package/dist/{game-4fsy55uN.d.ts → game-BPOr7zTB.d.ts} +195 -17
  40. package/dist/game-default-7HCJJF5S.js +1 -0
  41. package/dist/graphics.d.ts +6 -5
  42. package/dist/graphics.js +1 -1
  43. package/dist/{material-BKPYeBC6.d.ts → material-CxxAyJYp.d.ts} +1 -1
  44. package/dist/public.d.ts +13 -11
  45. package/dist/public.js +1 -1
  46. package/dist/runtime.d.ts +3 -3
  47. package/dist/{vector-DPbwlzgG.d.ts → simulation-body-zQw-emOr.d.ts} +1 -40
  48. package/dist/vector-D3eDzvcA.d.ts +41 -0
  49. package/dist/web-components.d.ts +12 -9
  50. package/dist/web-components.js +1 -1
  51. package/dist/{zylem-camera-B73ZNcgs.d.ts → zylem-camera-DZTpPOiD.d.ts} +12 -1
  52. package/package.json +20 -17
  53. package/dist/chunk-3I537JFL.js +0 -1
  54. package/dist/chunk-4CHZUWLF.js +0 -1
  55. package/dist/chunk-6B5JP7T5.js +0 -24
  56. package/dist/chunk-C5NEGC3S.js +0 -1
  57. package/dist/chunk-D3JO4HW2.js +0 -1
  58. package/dist/chunk-LKFF6XJC.js +0 -1
  59. package/dist/chunk-OAWK2UUY.js +0 -1
  60. package/dist/chunk-PNLNC3FA.js +0 -1
  61. package/dist/chunk-W5SXED5T.js +0 -1
  62. package/dist/debug-state-s0s-qndj.d.ts +0 -49
  63. package/dist/game-default-4PPYYGAR.js +0 -1
  64. /package/dist/{chunk-DFLI7ICU.js → chunk-MSCVL5OK.js} +0 -0
@@ -28,6 +28,7 @@ import { BridgeHandler } from '@zylem/bridge';
28
28
  import { GameLoadingPayload as BridgeLoadingPayload } from '@zylem/bridge';
29
29
  import { BridgeMessages } from '@zylem/bridge';
30
30
  import { BridgeMessageType } from '@zylem/bridge';
31
+ import { BridgePose } from '@zylem/bridge';
31
32
  import { BridgeVec3 } from '@zylem/bridge';
32
33
  import { BufferGeometry } from 'three';
33
34
  import { BurstParticlePresetOptions } from '@zylem/behaviors';
@@ -84,10 +85,12 @@ import { EditorToGameMessages } from '@zylem/bridge';
84
85
  import { emitRuntimeGoal } from '@zylem/behaviors/runtime-2d';
85
86
  import { emitRuntimeRicochet } from '@zylem/behaviors/runtime-2d';
86
87
  import { emitRuntimeTriggerRegionEnter } from '@zylem/behaviors/runtime-2d';
88
+ import { EntityApplySwatchPayload } from '@zylem/bridge';
87
89
  import { EntityDefinition } from '@zylem/behaviors/core';
88
90
  import { EntityHandle } from '@zylem/behaviors/core';
89
91
  import { EntitySummaryPayload } from '@zylem/bridge';
90
92
  import { EntityThumbnailPayload } from '@zylem/bridge';
93
+ import { EntityTypeDescriptor } from '@zylem/bridge';
91
94
  import { exp } from 'three/tsl';
92
95
  import { FacingAngle2DEntity } from '@zylem/behaviors';
93
96
  import { fireCooldown } from '@zylem/behaviors';
@@ -273,6 +276,7 @@ import { RuntimeTriggerRegion2DEvent } from '@zylem/behaviors/runtime-2d';
273
276
  import { RuntimeTriggerRegion2DHandle } from '@zylem/behaviors/runtime-2d';
274
277
  import { RuntimeTriggerRegion2DOptions } from '@zylem/behaviors/runtime-2d';
275
278
  import { Scene } from 'three';
279
+ import { SceneOperationPayload } from '@zylem/bridge';
276
280
  import { ScreenVisibilityBehavior } from '@zylem/behaviors';
277
281
  import { ScreenVisibilityChangeContext } from '@zylem/behaviors';
278
282
  import { ScreenVisibilityFSM } from '@zylem/behaviors';
@@ -333,6 +337,7 @@ import { StageTopDownPlane } from '@zylem/behaviors/core';
333
337
  import { Static } from '@sinclair/typebox';
334
338
  import { step } from 'three/tsl';
335
339
  import { Texture } from 'three';
340
+ import * as three from 'three';
336
341
  import { ThrusterBehavior } from '@zylem/behaviors';
337
342
  import { ThrusterBehaviorOptions } from '@zylem/behaviors';
338
343
  import { ThrusterEntity } from '@zylem/behaviors';
@@ -423,13 +428,16 @@ declare type ActorOptions = BaseNode | ZylemActorOptions;
423
428
  /**
424
429
  * Owns the stage's in-world debug/editor interaction layer.
425
430
  *
426
- * Self-manages around the global `debugState`: when debug is enabled it draws
427
- * the wasm simulation's collider wireframes, attaches mouse listeners,
428
- * raycasts into the physics world to hover/select/delete/spawn entities, and
429
- * drives the `DebugEntityCursor` highlight. When disabled it tears down
430
- * visuals but stays alive to re-activate. Centralizes all debug-tool plumbing
431
- * so `ZylemStage` doesn't have to know about raycasting, DOM input, or debug
432
- * rendering.
431
+ * Self-manages around the global `debugState`, in two layers that switch on
432
+ * independently. The tool layer — mouse listeners, physics raycasts to
433
+ * hover/select/delete/spawn, the `DebugEntityCursor` highlight and the
434
+ * `PlacementGhost` — is live whenever a tool is armed, so the toolbar's buttons
435
+ * work on their own. The debug layer — the wasm simulation's collider
436
+ * wireframes and the orbit camera — is the part `debugState.enabled` gates, and
437
+ * is torn down when it goes off while the delegate stays alive to re-activate.
438
+ *
439
+ * Centralizes all of this so `ZylemStage` doesn't have to know about
440
+ * raycasting, DOM input, or debug rendering.
433
441
  */
434
442
 
435
443
  declare type AddEntityFactory = (params: {
@@ -1217,6 +1225,14 @@ declare interface CleanupFunction<T, TGlobals extends GlobalRecord = any> {
1217
1225
  */
1218
1226
  export declare function clearGlobalSubscriptions(): void;
1219
1227
 
1228
+ /**
1229
+ * Closest point along an infinite line to a ray, as a distance along the line.
1230
+ *
1231
+ * Returns `null` when the ray is close enough to parallel with the line that the
1232
+ * closest point becomes unstable; see {@link MAX_DRAG_GAIN}.
1233
+ */
1234
+ export declare function closestAxisValue(ray: GizmoRay, origin: Vector3, axis: Vector3): number | null;
1235
+
1220
1236
  /**
1221
1237
  * Builds plain body + collider definitions consumable by the behaviors
1222
1238
  * `Simulation` (`simulation.spawn(...)`). No physics-engine types appear
@@ -1345,6 +1361,31 @@ declare interface ConeMeshOptions extends BaseMeshOptions {
1345
1361
 
1346
1362
  declare type ConeOptions = BaseNode | Partial<ZylemConeOptions>;
1347
1363
 
1364
+ /**
1365
+ * The y=0 construction plane, drawn so the snap lattice is legible.
1366
+ *
1367
+ * Two overlaid grids: fine lines at the translation snap increment, and heavier
1368
+ * lines every metre. Without the coarse pass a 0.25 grid over any useful area
1369
+ * reads as flat grey noise.
1370
+ */
1371
+
1372
+ export declare class ConstructionGrid {
1373
+ private group;
1374
+ private scene;
1375
+ private fine;
1376
+ private coarse;
1377
+ private increment;
1378
+ constructor();
1379
+ addTo(scene: Scene): void;
1380
+ /** Rebuild only when the increment actually changed; this allocates. */
1381
+ setIncrement(increment: number): void;
1382
+ setVisible(visible: boolean): void;
1383
+ get visible(): boolean;
1384
+ dispose(): void;
1385
+ private rebuild;
1386
+ private clearHelpers;
1387
+ }
1388
+
1348
1389
  export { CooldownBehavior }
1349
1390
 
1350
1391
  export { CooldownConfig }
@@ -1722,8 +1763,26 @@ declare interface DebugState {
1722
1763
  * Proxy wrappers to engine code that expects real instances.
1723
1764
  */
1724
1765
  selectedEntityId: string | null;
1766
+ /**
1767
+ * Full selection, in click order. `selectedEntityId` mirrors the first
1768
+ * entry. Only ever holds one uuid today, but the gizmo and scene operations
1769
+ * are already written against the list so multi-select needs no rework here.
1770
+ */
1771
+ selectedEntityIds: string[];
1725
1772
  /** UUID of the hovered entity. Same constraint as `selectedEntityId`. */
1726
1773
  hoveredEntityId: string | null;
1774
+ snap: SnapSettings;
1775
+ /** Whether the construction-plane grid is drawn. */
1776
+ gridVisible: boolean;
1777
+ /** Catalog type the add tool will spawn, or null when disarmed. */
1778
+ addTypeId: string | null;
1779
+ /** Creation options merged over the armed type's defaults. */
1780
+ addTypeProps: Record<string, unknown> | null;
1781
+ /**
1782
+ * Host-driven hover picking (e.g. Creator swatch drag). Raycasts even when
1783
+ * the Select tool is not armed, and keeps the hover highlight painted.
1784
+ */
1785
+ pickMode: boolean;
1727
1786
  flags: Set<string>;
1728
1787
  }
1729
1788
 
@@ -1731,6 +1790,8 @@ export declare const debugState: DebugState;
1731
1790
 
1732
1791
  export declare type DebugTools = 'select' | 'translate' | 'rotate' | 'scale' | 'delete' | 'add' | 'none';
1733
1792
 
1793
+ export declare const DEFAULT_SNAP_SETTINGS: SnapSettings;
1794
+
1734
1795
  /**
1735
1796
  * Builds a ready-to-use {@link GameInputConfig} that wires up themed
1736
1797
  * virtual touch controls for a player. Internally composes
@@ -1790,6 +1851,9 @@ export { defineBehavior }
1790
1851
 
1791
1852
  export { DefineBehaviorConfig }
1792
1853
 
1854
+ /** Degrees to radians. */
1855
+ export declare function degreesToRadians(degrees: number): number;
1856
+
1793
1857
  /**
1794
1858
  * Wait for a duration. Useful inside `sequence()`.
1795
1859
  *
@@ -1829,6 +1893,22 @@ export { DestructibleMesh }
1829
1893
 
1830
1894
  export { DestructiblePrebakeWorkerAPI }
1831
1895
 
1896
+ /** A detached entity plus the pose to restore it at. */
1897
+ declare interface DetachedEntity {
1898
+ entity: any;
1899
+ position: {
1900
+ x: number;
1901
+ y: number;
1902
+ z: number;
1903
+ } | null;
1904
+ rotation: {
1905
+ x: number;
1906
+ y: number;
1907
+ z: number;
1908
+ w: number;
1909
+ } | null;
1910
+ }
1911
+
1832
1912
  export declare type DeviceProfile = 'auto' | 'desktop' | 'mobile';
1833
1913
 
1834
1914
  export declare interface DirectionalLightOptions extends BaseLightOptions {
@@ -1872,6 +1952,8 @@ declare interface Entity<T = any> {
1872
1952
  tag?: Set<string>;
1873
1953
  }
1874
1954
 
1955
+ export { EntityApplySwatchPayload }
1956
+
1875
1957
  export declare type EntityBlueprint = Static<typeof EntitySchema>;
1876
1958
 
1877
1959
  declare abstract class EntityBuilder<T extends GameEntity<U> & P, U extends GameEntityOptions, P = any> {
@@ -2136,6 +2218,9 @@ export declare interface EntityTypeMap {
2136
2218
  [LINE_TYPE]: ZylemLine;
2137
2219
  }
2138
2220
 
2221
+ /** Convert Euler angles (radians, XYZ order) to a quaternion. */
2222
+ export declare function eulerToQuaternion(rotation: Vec3): Quat;
2223
+
2139
2224
  /**
2140
2225
  * Reusable delegate for event emission and subscription.
2141
2226
  * Use via composition in Game, Stage, and Entity classes.
@@ -2518,6 +2603,11 @@ export declare class GameBridge {
2518
2603
  * an editor command can never echo back as a game update.
2519
2604
  */
2520
2605
  private editorKnown;
2606
+ /**
2607
+ * True while an undo/redo is being applied, so the writes it performs are
2608
+ * not themselves recorded as new operations.
2609
+ */
2610
+ private applyingSceneOperation;
2521
2611
  constructor();
2522
2612
  /**
2523
2613
  * Subscribe to editor commands and announce the game side as ready.
@@ -2581,6 +2671,17 @@ export declare class GameBridge {
2581
2671
  queueEntityRemoved(uuids: string[]): void;
2582
2672
  /** RAF-coalesced thumbnail stream; merged by uuid per frame. */
2583
2673
  queueThumbnails(thumbnails: EntityThumbnailPayload[]): void;
2674
+ /** Publish the placeable entity types the editor's Add palette offers. */
2675
+ publishCatalog(entities: EntityTypeDescriptor[]): void;
2676
+ /**
2677
+ * Publish a committed, invertible change for the editor's undo stack.
2678
+ *
2679
+ * Sent rather than queued: coalescing merges same-type payloads within a
2680
+ * frame, which would fuse two operations into one and lose an undo step.
2681
+ */
2682
+ publishSceneOperation(op: SceneOperationPayload): void;
2683
+ /** Whether an editor is tracking scene operations for undo. */
2684
+ wantsSceneOperations(): boolean;
2584
2685
  }
2585
2686
 
2586
2687
  /**
@@ -2603,6 +2704,12 @@ export declare interface GameBridgeHost {
2603
2704
  resolveEntity(uuid: string): GameEntity<any> | null;
2604
2705
  /** Write a stage variable (editor `stage:variable:set`). */
2605
2706
  setStageVariable?(key: string, value: unknown): void;
2707
+ /** Spawn a catalog entity into the current stage (editor `entity:create`). */
2708
+ createEntity?(typeId: string, props: Record<string, unknown> | undefined, pose: BridgePose | undefined): void;
2709
+ /** Undo or redo a committed scene operation (`scene:operation:apply`). */
2710
+ applySceneOperation?(op: SceneOperationPayload, direction: 'undo' | 'redo'): void;
2711
+ /** Attach a catalog shader or behavior to a live entity (`entity:apply-swatch`). */
2712
+ applySwatch?(payload: EntityApplySwatchPayload): void;
2606
2713
  }
2607
2714
 
2608
2715
  /**
@@ -2865,6 +2972,18 @@ export declare class GameEntity<O extends GameEntityOptions> extends BaseNode<O>
2865
2972
  physicsWorldRef: unknown;
2866
2973
  colliderDesc: SimulationColliderDefinition | undefined;
2867
2974
  custom: Record<string, any>;
2975
+ /**
2976
+ * Pristine collider definitions captured before the first scale change, so
2977
+ * scaling stays absolute rather than compounding. See
2978
+ * {@link ensureColliderBaseline}.
2979
+ */
2980
+ colliderBaseline: SimulationColliderDefinition[] | null;
2981
+ /**
2982
+ * Set when {@link GameEntity.setScale} has scaled the render object but the
2983
+ * colliders have not been rebuilt yet. Cleared by
2984
+ * {@link commitColliderScale}.
2985
+ */
2986
+ colliderScaleDirty: boolean;
2868
2987
  /** All collider descriptions for this entity (including primary) */
2869
2988
  colliderDescs: SimulationColliderDefinition[];
2870
2989
  /** Additional meshes for compound visual entities (added via add()) */
@@ -2904,6 +3023,8 @@ export declare class GameEntity<O extends GameEntityOptions> extends BaseNode<O>
2904
3023
  private trackAddedComponents;
2905
3024
  private trackedComponents;
2906
3025
  transformStore: TransformState;
3026
+ /** Absolute scale, authored by the editor. Unit scale until changed. */
3027
+ private _scale;
2907
3028
  /** Hide render target until spawn placement is confirmed. */
2908
3029
  _spawnPlacementPending: boolean;
2909
3030
  /** Author passed `position` in create options. */
@@ -2975,6 +3096,17 @@ export declare class GameEntity<O extends GameEntityOptions> extends BaseNode<O>
2975
3096
  w: number;
2976
3097
  };
2977
3098
  }): boolean;
3099
+ /** Current absolute scale. */
3100
+ getScale(): Vec3;
3101
+ /**
3102
+ * Set absolute scale on the render object.
3103
+ *
3104
+ * Colliders are *not* resized here — they are baked into the wasm
3105
+ * simulation and can only be replaced by respawning the body, which is far
3106
+ * too costly to do per drag frame. The entity is flagged instead, and
3107
+ * {@link commitColliderScale} rebuilds them once the gesture commits.
3108
+ */
3109
+ setScale(x: number, y: number, z: number): void;
2978
3110
  /**
2979
3111
  * Add meshes, collision components, or child entities to this entity.
2980
3112
  * Supports fluent chaining: `entity.add(boxMesh()).add(boxCollision())`.
@@ -3403,6 +3535,12 @@ export declare function getSelectedEntity(): GameEntity<any> | null;
3403
3535
 
3404
3536
  export declare function getSelectedEntityId(): string | null;
3405
3537
 
3538
+ /** Every selected uuid, in click order. */
3539
+ export declare function getSelectedEntityIds(): string[];
3540
+
3541
+ /** Current snap increments. */
3542
+ export declare function getSnapSettings(): SnapSettings;
3543
+
3406
3544
  /**
3407
3545
  * Get a variable from an object by path.
3408
3546
  * @example getVariable(stage1, 'totalAngle') // 0.5
@@ -3414,6 +3552,30 @@ export { getVelocity }
3414
3552
 
3415
3553
  export { getZylemBridge }
3416
3554
 
3555
+ /** Single-axis, planar, and uniform handle identifiers. */
3556
+ export declare type GizmoAxis = 'x' | 'y' | 'z' | 'xy' | 'yz' | 'xz' | 'xyz';
3557
+
3558
+ /** A raw, unsnapped drag result in world space. */
3559
+ export declare type GizmoDelta = {
3560
+ kind: 'translate';
3561
+ offset: Vector3;
3562
+ } | {
3563
+ kind: 'rotate';
3564
+ axis: Vector3;
3565
+ angle: number;
3566
+ } | {
3567
+ kind: 'scale';
3568
+ factor: Vector3;
3569
+ };
3570
+
3571
+ export declare type GizmoMode = 'translate' | 'rotate' | 'scale';
3572
+
3573
+ /** A mouse ray in world space. */
3574
+ export declare interface GizmoRay {
3575
+ origin: Vector3;
3576
+ direction: Vector3;
3577
+ }
3578
+
3417
3579
  /**
3418
3580
  * Listen for a single global key change inside an onUpdate pipeline.
3419
3581
  * Usage: onUpdate(globalChange('p1Score', (value) => { ... }))
@@ -3634,6 +3796,14 @@ declare class InstanceManager {
3634
3796
  private growPack;
3635
3797
  }
3636
3798
 
3799
+ /**
3800
+ * Intersect a ray with the plane through `origin` with the given normal.
3801
+ *
3802
+ * Returns `null` for a plane seen too close to edge-on, where the hit point
3803
+ * races away across the plane for very little pointer motion.
3804
+ */
3805
+ export declare function intersectPlane(ray: GizmoRay, origin: Vector3, normal: Vector3, target: Vector3): Vector3 | null;
3806
+
3637
3807
  /**
3638
3808
  * Check if a shader is a GLSL shader
3639
3809
  */
@@ -3645,12 +3815,16 @@ export declare function isManagedRenderEntity(entity: {
3645
3815
  isBundled?: boolean;
3646
3816
  }): boolean;
3647
3817
 
3818
+ export declare function isPickMode(): boolean;
3819
+
3648
3820
  declare interface IStage {
3649
3821
  onUpdate: (callback: UpdateFunction<IStage>) => void;
3650
3822
  onSetup: (callback: SetupFunction<IStage>) => void;
3651
3823
  onDestroy: (callback: DestroyFunction<IStage>) => void;
3652
3824
  }
3653
3825
 
3826
+ export declare function isTransformTool(tool: DebugTools): tool is TransformTool;
3827
+
3654
3828
  /**
3655
3829
  * Check if a shader is a TSL shader
3656
3830
  */
@@ -4480,6 +4654,26 @@ declare interface PyramidMeshOptions extends BaseMeshOptions {
4480
4654
 
4481
4655
  declare type PyramidOptions = BaseNode | Partial<ZylemPyramidOptions>;
4482
4656
 
4657
+ /**
4658
+ * Pure transform math shared by the editor gizmo, the bridge adapter, and
4659
+ * their tests. No THREE scene state and no simulation access, so it can be
4660
+ * exercised in a plain node environment.
4661
+ */
4662
+
4663
+ /** Quaternion as carried by the bridge and the wasm runtime. */
4664
+ export declare interface Quat {
4665
+ x: number;
4666
+ y: number;
4667
+ z: number;
4668
+ w: number;
4669
+ }
4670
+
4671
+ /** Convert a quaternion to Euler angles (radians, XYZ order). */
4672
+ export declare function quaternionToEuler(rotation: Quat): Vec3;
4673
+
4674
+ /** Radians to degrees. */
4675
+ export declare function radiansToDegrees(radians: number): number;
4676
+
4483
4677
  export declare const RECT_TYPE: unique symbol;
4484
4678
 
4485
4679
  declare type RectOptions = BaseNode | Partial<ZylemRectOptions>;
@@ -5175,6 +5369,9 @@ export { SemanticParticlePresetOptions }
5175
5369
  */
5176
5370
  export declare function sequence(...actions: Action[]): Action;
5177
5371
 
5372
+ /** Arm the add tool with a catalog type, or pass `null` to disarm it. */
5373
+ export declare function setAddType(typeId: string | null, props?: Record<string, unknown> | null): void;
5374
+
5178
5375
  /**
5179
5376
  * Display a camera's live feed on an entity's mesh surface.
5180
5377
  *
@@ -5214,10 +5411,15 @@ export declare function setDebugTool(tool: DebugTools): void;
5214
5411
  */
5215
5412
  export declare function setGlobal(path: string, value: unknown): void;
5216
5413
 
5414
+ export declare function setGridVisible(visible: boolean): void;
5415
+
5217
5416
  export declare function setHoveredEntityId(uuid: string | null): void;
5218
5417
 
5219
5418
  export declare function setPaused(paused: boolean): void;
5220
5419
 
5420
+ /** Hosts arm this while forwarding pointer coords for entity hover (no Select tool). */
5421
+ export declare function setPickMode(enabled: boolean): void;
5422
+
5221
5423
  export { setPosition }
5222
5424
 
5223
5425
  export { setPositionX }
@@ -5274,6 +5476,15 @@ export declare function setSelectedEntity(entity: GameEntity<any> | string | nul
5274
5476
 
5275
5477
  export declare function setSelectedEntityId(uuid: string | null): void;
5276
5478
 
5479
+ /**
5480
+ * Replace the selection. `selectedEntityId` follows the first entry so the
5481
+ * single-select consumers (debug cursor, orbit focus target, bridge mirror)
5482
+ * keep working unchanged.
5483
+ */
5484
+ export declare function setSelectedEntityIds(uuids: string[]): void;
5485
+
5486
+ export declare function setSnapSettings(snap: Partial<SnapSettings>): void;
5487
+
5277
5488
  export declare function setStageFrameProfilerEnabled(value: boolean): void;
5278
5489
 
5279
5490
  /** Setup */
@@ -5459,6 +5670,36 @@ export { sin }
5459
5670
 
5460
5671
  export { smoothstep }
5461
5672
 
5673
+ /**
5674
+ * Snap a scale, clamped away from zero.
5675
+ *
5676
+ * A snapped-to-zero axis would collapse the collider into a degenerate shape
5677
+ * that the physics runtime cannot solve, so the smallest representable scale
5678
+ * is one increment.
5679
+ */
5680
+ export declare function snapScale(value: Vec3, increment: number): Vec3;
5681
+
5682
+ /** Grid increments applied to gizmo drags, in world units and radians. */
5683
+ export declare interface SnapSettings {
5684
+ enabled: boolean;
5685
+ translate: number;
5686
+ /** Radians. Defaults to 15 degrees. */
5687
+ rotate: number;
5688
+ scale: number;
5689
+ }
5690
+
5691
+ /**
5692
+ * Snap a value onto an absolute lattice of `increment`-sized steps.
5693
+ *
5694
+ * Absolute rather than relative to where the drag started: the result is
5695
+ * always a multiple of the increment, so independently placed entities line up
5696
+ * with each other instead of each keeping its own arbitrary offset.
5697
+ */
5698
+ export declare function snapToIncrement(value: number, increment: number): number;
5699
+
5700
+ /** {@link snapToIncrement} across all three components. */
5701
+ export declare function snapVec3(value: Vec3, increment: number): Vec3;
5702
+
5462
5703
  export declare const SPHERE_TYPE: unique symbol;
5463
5704
 
5464
5705
  /**
@@ -5721,10 +5962,10 @@ declare class StageDebugDelegate {
5721
5962
  private options;
5722
5963
  private mouseNdc;
5723
5964
  private raycaster;
5724
- private isMouseDown;
5725
5965
  private domDisposeFns;
5726
5966
  private domListenersAttached;
5727
5967
  private debugCursor;
5968
+ private placementGhost;
5728
5969
  private debugLines;
5729
5970
  private cameraDebugDelegate;
5730
5971
  private debugStateUnsubscribe;
@@ -5732,6 +5973,11 @@ declare class StageDebugDelegate {
5732
5973
  private entityResolverUnregister;
5733
5974
  private lastDebugEnabled;
5734
5975
  private warnedMissingAddFactory;
5976
+ private transformTool;
5977
+ private grid;
5978
+ private lastTool;
5979
+ /** Element the current gizmo drag captured, so pointerup is never missed. */
5980
+ private capturedPointer;
5735
5981
  constructor(stage: ZylemStage, options?: StageDebugDelegateOptions);
5736
5982
  /**
5737
5983
  * Supply the factory the `add` tool uses to spawn entities at the clicked
@@ -5751,18 +5997,116 @@ declare class StageDebugDelegate {
5751
5997
  * rebuild the render pipeline once per frame.
5752
5998
  */
5753
5999
  private syncWithDebugState;
6000
+ /** Hand the transform tool its mode whenever the active tool changes. */
6001
+ private syncToolMode;
6002
+ private syncGrid;
5754
6003
  /** Initialize DOM listeners and switch rendering to the debug orbit camera. */
5755
6004
  private activate;
5756
6005
  /** Tear down visuals and restore the gameplay primary camera. */
5757
6006
  private deactivate;
5758
6007
  private rebindPostProcessing;
6008
+ /**
6009
+ * Collider wireframes: the one overlay that really is debug-mode-only, since
6010
+ * it draws the simulation itself rather than anything being edited.
6011
+ */
5759
6012
  private initDebugVisuals;
5760
6013
  private disposeDebugVisuals;
6014
+ /**
6015
+ * Tool feedback, built on first use and kept for the delegate's life.
6016
+ *
6017
+ * Separate from {@link initDebugVisuals} because the hover highlight and the
6018
+ * placement ghost belong to the tools, not to debug mode: they have to be
6019
+ * available when a tool is armed with debug off.
6020
+ */
6021
+ private ensureToolVisuals;
6022
+ /**
6023
+ * Hide the overlays whose tool has just gone away.
6024
+ *
6025
+ * `update()` normally does this, but it stops being called once nothing is
6026
+ * armed and debug is off — so the frame that would have hidden a disarmed
6027
+ * Add's ghost never arrives, and the preview is left floating in the scene.
6028
+ * Driven from the tool transition, which always fires.
6029
+ */
6030
+ private parkToolVisuals;
6031
+ private disposeToolVisuals;
5761
6032
  update(): void;
6033
+ /**
6034
+ * Raycast at NDC coordinates (from a host that cannot send DOM pointer
6035
+ * events, e.g. an overlay sitting on a preview iframe). Updates hover so
6036
+ * the next `update()` paints the highlight.
6037
+ */
6038
+ pickAtNdc(ndcX: number, ndcY: number): {
6039
+ uuid: string;
6040
+ name: string;
6041
+ } | null;
6042
+ /** Collider wireframes, straight from the wasm simulation. */
6043
+ private updateColliderWireframes;
6044
+ /**
6045
+ * Make sure an armed tool can actually receive the pointer.
6046
+ *
6047
+ * The listeners outlive debug mode once attached — `deactivate()` leaves them
6048
+ * in place and only `dispose()` removes them — so this only ever has to run
6049
+ * until it succeeds.
6050
+ */
6051
+ private ensureInteraction;
6052
+ /**
6053
+ * Drive the translucent preview of the armed entity type from the cursor.
6054
+ *
6055
+ * Runs while the game is paused as well as while it plays: only the
6056
+ * fixed-step `step()` is pause-gated, so this pass still ticks and the
6057
+ * ghost keeps following the mouse in a frozen scene — which is exactly when
6058
+ * a scene is usually being built. It runs with debug mode off too, for the
6059
+ * same reason: arming Add is a request to place something, not to inspect
6060
+ * colliders.
6061
+ *
6062
+ * The ghost is a scene overlay, not an entity, so it is invisible to the
6063
+ * physics raycast here and cannot preview itself.
6064
+ */
6065
+ private updatePlacementGhost;
5762
6066
  /** Full teardown — unsubscribes from debugState and cleans up all resources. */
5763
6067
  dispose(): void;
5764
- private handleActionOnHit;
6068
+ /**
6069
+ * Undo or redo a committed operation.
6070
+ *
6071
+ * The editor holds the history but cannot apply it: reverting a delete means
6072
+ * producing the original entity, which only the stage can do. So the editor
6073
+ * hands the record back and the inversion happens here.
6074
+ */
6075
+ applySceneOperation(op: SceneOperationPayload, direction: 'undo' | 'redo'): void;
6076
+ /** The mouse ray in world space, from the last pointer position. */
6077
+ private currentRay;
6078
+ private handleAction;
6079
+ /**
6080
+ * Spawn the armed entity type at the clicked point.
6081
+ *
6082
+ * Placement resolves in two steps because a click into empty sky is the
6083
+ * common case when building a scene from nothing: the physics hit is
6084
+ * preferred (the entity rests on the surface it was dropped onto), and
6085
+ * otherwise the ray is intersected with the y=0 construction plane. Before
6086
+ * this, clicking anywhere without an existing collider under the cursor did
6087
+ * nothing at all.
6088
+ */
6089
+ private placeEntity;
6090
+ /**
6091
+ * Nudge a freshly placed entity out along the surface normal by half its
6092
+ * own size, so it sits on the surface rather than half-buried in it.
6093
+ *
6094
+ * Runs after spawn because the entity's bounds are not known until its mesh
6095
+ * exists.
6096
+ */
6097
+ private restOnSurface;
6098
+ private warnMissingAddSource;
5765
6099
  private attachDomListeners;
6100
+ /**
6101
+ * Own the pointer for the duration of a gizmo drag.
6102
+ *
6103
+ * Capture keeps events coming even when the cursor leaves the canvas, which
6104
+ * happens constantly when dragging an axis toward the edge of the viewport.
6105
+ * Orbit is suspended for the same window so the drag does not also swing the
6106
+ * camera.
6107
+ */
6108
+ private beginPointerCapture;
6109
+ private endPointerCapture;
5766
6110
  }
5767
6111
 
5768
6112
  declare interface StageDebugDelegateOptions {
@@ -5805,6 +6149,11 @@ declare class StageEntityDelegate {
5805
6149
  readonly childrenMap: Map<string, BaseNode>;
5806
6150
  /** UUID → BaseNode map populated when debug mode is active. */
5807
6151
  readonly debugMap: Map<string, BaseNode>;
6152
+ /**
6153
+ * Entities detached from the stage but kept alive so an editor undo can put
6154
+ * them back. See {@link StageEntityDelegate.detachEntity}.
6155
+ */
6156
+ readonly detachedMap: Map<string, DetachedEntity>;
5808
6157
  private pendingEntities;
5809
6158
  private pendingPromises;
5810
6159
  private _isLoaded;
@@ -5854,10 +6203,48 @@ declare class StageEntityDelegate {
5854
6203
  /** Add the entity to internal maps and notify listeners. */
5855
6204
  addEntityToStage(entity: BaseNode): void;
5856
6205
  /**
5857
- * Remove an entity and its resources by its UUID.
6206
+ * Remove an entity from the stage by its UUID.
6207
+ *
6208
+ * Detaches rather than destroys, so an editor undo can put the same
6209
+ * instance back. See {@link StageEntityDelegate.detachEntity}.
6210
+ *
5858
6211
  * @returns true if removed, false if not found or stage not ready
5859
6212
  */
5860
6213
  removeEntityByUuid(uuid: string): boolean;
6214
+ /**
6215
+ * Take an entity out of the stage while keeping the instance alive.
6216
+ *
6217
+ * The editor cannot rebuild an entity — all it ever receives is a summary of
6218
+ * name, type, and transform, with no material, behaviors, or collider
6219
+ * config. So undoing a delete has to restore the original object, which
6220
+ * means holding onto it here. Keeping the same instance also keeps its uuid
6221
+ * stable, which every other entry in the undo stack depends on.
6222
+ *
6223
+ * Observers are still told the entity is gone: from the outside it has left
6224
+ * the stage, and leaving it in the editor's list or the thumbnail cache
6225
+ * would leak.
6226
+ *
6227
+ * @returns true when the entity was found and detached.
6228
+ */
6229
+ detachEntity(uuid: string): boolean;
6230
+ /**
6231
+ * Put a detached entity back into the stage at the pose it left.
6232
+ *
6233
+ * Unlike {@link StageEntityDelegate.spawnEntity} this never calls
6234
+ * `create()`: the entity is already fully built, and rebuilding it would
6235
+ * discard its meshes and colliders along with any editor scale applied to
6236
+ * them.
6237
+ *
6238
+ * @returns true when the entity was found and restored.
6239
+ */
6240
+ restoreEntity(uuid: string): boolean;
6241
+ /** Whether a uuid is currently recoverable via {@link restoreEntity}. */
6242
+ isDetached(uuid: string): boolean;
6243
+ /**
6244
+ * Destroy detached entities past the recoverable window. Insertion-ordered,
6245
+ * so the oldest detachments go first.
6246
+ */
6247
+ private evictOldestDetached;
5861
6248
  /** Get an entity by its name; returns null if not found. */
5862
6249
  getEntityByName(name: string): BaseNode | null;
5863
6250
  /** Build a serializable state snapshot for an entity. */
@@ -5899,6 +6286,11 @@ declare class StageEntityDelegate {
5899
6286
  */
5900
6287
  destroyAll(): void;
5901
6288
  private registerBehaviorLinks;
6289
+ /**
6290
+ * Re-index an entity's behavior refs after a late `entity.use(...)`.
6291
+ * Spawn-time registration only sees refs that existed at attach.
6292
+ */
6293
+ syncBehaviorLinks(entity: any): void;
5902
6294
  private unregisterBehaviorLinks;
5903
6295
  }
5904
6296
 
@@ -6575,6 +6967,9 @@ export declare const touchThemes: {
6575
6967
  readonly lagoon: TouchTheme;
6576
6968
  };
6577
6969
 
6970
+ /** Tools that manipulate a selected entity's transform via the gizmo. */
6971
+ export declare const TRANSFORM_TOOLS: readonly ["translate", "rotate", "scale"];
6972
+
6578
6973
  /**
6579
6974
  * Structural slice of the simulation body facade used to flush transform
6580
6975
  * intents. `SimulationBody` satisfies this shape.
@@ -6632,6 +7027,91 @@ declare interface TransformableEntity {
6632
7027
 
6633
7028
  export { TransformComponent }
6634
7029
 
7030
+ export declare class TransformGizmo {
7031
+ /** Root added to the scene; carries the pivot transform. */
7032
+ readonly root: Group<three.Object3DEventMap>;
7033
+ private scene;
7034
+ private modeGroups;
7035
+ private handles;
7036
+ private materials;
7037
+ private geometries;
7038
+ private mode;
7039
+ private highlighted;
7040
+ private drag;
7041
+ private raycaster;
7042
+ constructor();
7043
+ addTo(scene: Scene): void;
7044
+ removeFromScene(): void;
7045
+ dispose(): void;
7046
+ setMode(mode: GizmoMode): void;
7047
+ getMode(): GizmoMode;
7048
+ /** Place the gizmo at a pivot and show it. */
7049
+ show(pivot: Vector3): void;
7050
+ hide(): void;
7051
+ get visible(): boolean;
7052
+ get pivot(): Vector3;
7053
+ /**
7054
+ * Keep the gizmo a constant size on screen.
7055
+ *
7056
+ * A world-sized gizmo is unusable in an orbit view: it fills the screen up
7057
+ * close and disappears from a distance.
7058
+ */
7059
+ update(camera: Camera): void;
7060
+ /**
7061
+ * Which handle a ray hits, or `null`.
7062
+ *
7063
+ * Raycasts the gizmo's own meshes rather than the physics world. Handles are
7064
+ * render-only objects with no colliders, so the physics raycast used to pick
7065
+ * entities cannot see them at all.
7066
+ */
7067
+ pick(ray: GizmoRay): GizmoAxis | null;
7068
+ /**
7069
+ * Whether a handle can be dragged from the current viewing angle.
7070
+ *
7071
+ * Each handle type degenerates differently: an arrow aimed at the camera has
7072
+ * no screen-space direction left to follow, while a plane quad or rotation
7073
+ * ring seen edge-on turns a pixel of motion into a huge sweep across it.
7074
+ */
7075
+ private isHandleDraggable;
7076
+ /** Tint a handle to show it is hovered or being dragged. */
7077
+ setHighlight(axis: GizmoAxis | null): void;
7078
+ /**
7079
+ * Begin a drag on a handle.
7080
+ *
7081
+ * @returns `false` when the gesture cannot be tracked (a near-parallel view
7082
+ * of the drag axis), so the caller can ignore the press rather than start a
7083
+ * drag that would jump.
7084
+ */
7085
+ beginDrag(axis: GizmoAxis, ray: GizmoRay, camera: Camera): boolean;
7086
+ /** Raw delta for the current pointer position, or `null` when unusable. */
7087
+ updateDrag(ray: GizmoRay, camera: Camera): GizmoDelta | null;
7088
+ endDrag(): void;
7089
+ get isDragging(): boolean;
7090
+ get draggingAxis(): GizmoAxis | null;
7091
+ private isPlaneAxis;
7092
+ /** Signed angle of the ray's hit point around `normal`, in radians. */
7093
+ private angleOnPlane;
7094
+ /** Distance from pivot to the ray hit on the camera-facing plane. */
7095
+ private cameraPlaneRadius;
7096
+ private applyModeVisibility;
7097
+ private makeMaterial;
7098
+ private track;
7099
+ /**
7100
+ * An invisible, generously sized mesh used only for hit testing.
7101
+ *
7102
+ * The visible shafts and rings are a couple of pixels wide, which is
7103
+ * miserable to click. The raycaster still reaches `visible: false` meshes,
7104
+ * so picking accuracy is decoupled from how thin the handle looks.
7105
+ */
7106
+ private makePicker;
7107
+ private orientAlongAxis;
7108
+ private buildTranslate;
7109
+ private positionPlaneHandle;
7110
+ private buildRotate;
7111
+ private orientRing;
7112
+ private buildScale;
7113
+ }
7114
+
6635
7115
  /**
6636
7116
  * Minimal transform representation for pipeline targets.
6637
7117
  */
@@ -6642,6 +7122,8 @@ export declare interface TransformLike {
6642
7122
 
6643
7123
  export { TransformState }
6644
7124
 
7125
+ export declare type TransformTool = (typeof TRANSFORM_TOOLS)[number];
7126
+
6645
7127
  export { uniform }
6646
7128
 
6647
7129
  export { updateBoundaryRicochet }
@@ -7437,6 +7919,17 @@ declare class ZylemCamera {
7437
7919
  * Frame the debug orbit camera on an Object3D (AABB fit).
7438
7920
  */
7439
7921
  frameObject(object: Object3D): void;
7922
+ /**
7923
+ * Suspend or resume orbit input. Used by the debug transform tools so a
7924
+ * gizmo drag does not also swing the camera.
7925
+ */
7926
+ setOrbitInteractionEnabled(enabled: boolean): void;
7927
+ /**
7928
+ * Stop or resume tracking the debug selection with the orbit target. Used by
7929
+ * the transform tools, which cannot be dragged accurately while the camera
7930
+ * re-aims at the entity being moved.
7931
+ */
7932
+ setOrbitFollowEnabled(enabled: boolean): void;
7440
7933
  /**
7441
7934
  * Directly set the camera position.
7442
7935
  */
@@ -7771,6 +8264,8 @@ declare class ZylemGame<TGlobals extends BaseGlobals> {
7771
8264
  private lastPublishedGameConfig;
7772
8265
  /** Editor ↔ game bridge adapter (RAF-coalesced publishes, command intake). */
7773
8266
  private gameBridge;
8267
+ /** Stops republishing the entity catalog on registry changes. */
8268
+ private catalogUnsubscribe;
7774
8269
  private readonly gameUpdateParams;
7775
8270
  private readonly stageSetupParams;
7776
8271
  private readonly stageUpdateParams;
@@ -7781,6 +8276,10 @@ declare class ZylemGame<TGlobals extends BaseGlobals> {
7781
8276
  static FRAME_DURATION: number;
7782
8277
  static MAX_DELTA_SECONDS: number;
7783
8278
  constructor(options: ZylemGameOptions<TGlobals>, wrapperRef: Game<TGlobals>, displayRuntime?: ResolveGameConfigRuntime);
8279
+ /** Publish the placeable entity types the editor's Add palette lists. */
8280
+ private publishEntityCatalog;
8281
+ /** Spawn a catalog type programmatically (editor `entity:create`). */
8282
+ private createCatalogEntity;
7784
8283
  setDisplayRuntime(runtime: ResolveGameConfigRuntime): void;
7785
8284
  loadGameCanvas(config: GameConfig): void;
7786
8285
  loadDebugOptions(options: ZylemGameOptions<TGlobals>): void;
@@ -8405,7 +8904,7 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
8405
8904
  protected _setup(params: SetupContext<ZylemStage>): void;
8406
8905
  protected _update(params: UpdateContext<ZylemStage>): void;
8407
8906
  outOfLoop(): void;
8408
- /** Update debug overlays and helpers if enabled. */
8907
+ /** Update debug overlays and the editor's pointer tools. */
8409
8908
  debugUpdate(): void;
8410
8909
  /** Cleanup owned resources when the stage is destroyed. */
8411
8910
  protected _destroy(params: DestroyContext<ZylemStage>): void;