@zylem/game-lib 0.7.0 → 0.8.0

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 (95) hide show
  1. package/README.md +15 -1
  2. package/dist/actions.d.ts +71 -8
  3. package/dist/actions.js +1 -1
  4. package/dist/api/game-lib.api.json +54074 -0
  5. package/dist/api/game-lib.api.md +4544 -0
  6. package/dist/api/game-lib.d.ts +8258 -0
  7. package/dist/api/game-lib.typedoc.json +345421 -0
  8. package/dist/audio.js +1 -1
  9. package/dist/{base-node-life-cycle-CnJ-7zX-.d.ts → base-node-life-cycle-D2NuN1VB.d.ts} +12 -4
  10. package/dist/behavior.d.ts +2 -3
  11. package/dist/behavior.js +1 -1
  12. package/dist/blueprints-TbGY-h53.d.ts +162 -0
  13. package/dist/chunk-7FR5JSQ2.js +1 -0
  14. package/dist/chunk-7GYFZKK7.js +1 -0
  15. package/dist/chunk-7WRQ2UAN.js +1 -0
  16. package/dist/chunk-BH53MBAZ.js +1 -0
  17. package/dist/chunk-BIGH6D34.js +0 -0
  18. package/dist/chunk-CM5YRNBJ.js +19 -0
  19. package/dist/chunk-COM6HJ2L.js +1 -0
  20. package/dist/chunk-D2PATZCC.js +1 -0
  21. package/dist/chunk-DFLI7ICU.js +0 -0
  22. package/dist/chunk-E3UBSUPX.js +1 -0
  23. package/dist/chunk-FKIKN7RP.js +24 -0
  24. package/dist/chunk-G4HONLWC.js +1 -0
  25. package/dist/chunk-IKWE2W6L.js +1 -0
  26. package/dist/chunk-IPWUDOV5.js +1 -0
  27. package/dist/chunk-JEHFHUH4.js +0 -0
  28. package/dist/chunk-JNKPTL77.js +1 -0
  29. package/dist/chunk-JQKS42G4.js +1 -0
  30. package/dist/chunk-M3XNO56P.js +1 -0
  31. package/dist/chunk-ORIDWL3T.js +0 -0
  32. package/dist/chunk-QB3NL7VQ.js +1 -0
  33. package/dist/chunk-TAUWDQZF.js +9 -0
  34. package/dist/chunk-VS2D4B3W.js +1 -0
  35. package/dist/chunk-WQ3WMMZD.js +1 -0
  36. package/dist/chunk-XK63E4SX.js +1 -0
  37. package/dist/chunk-XNDS4YFR.js +1 -0
  38. package/dist/chunk-XNHVRFAK.js +1 -0
  39. package/dist/chunk-ZRT3ZQVH.js +1 -0
  40. package/dist/collision-builder-jF-toPIl.d.ts +38 -0
  41. package/dist/core.d.ts +45 -30
  42. package/dist/core.js +1 -24
  43. package/dist/debug-state-BPT6jEog.d.ts +17 -0
  44. package/dist/debug.d.ts +71 -19
  45. package/dist/debug.js +1 -1
  46. package/dist/{default-controls-BGc61yYl.d.ts → default-controls-0-vCnli7.d.ts} +3 -3
  47. package/dist/{entity-DNkYKfdp.d.ts → entity-BdSI8CL3.d.ts} +63 -444
  48. package/dist/entity-DZbFQ1Wg.d.ts +28 -0
  49. package/dist/{entity-type-map-C94h2TDW.d.ts → entity-type-map-Bd69SpAS.d.ts} +153 -6
  50. package/dist/entity.d.ts +11 -8
  51. package/dist/entity.js +1 -1
  52. package/dist/events.d.ts +10 -1
  53. package/dist/events.js +1 -1
  54. package/dist/{game-Cuj5gy7U.d.ts → game-C1FHVqXl.d.ts} +429 -133
  55. package/dist/game-default-QHROHW2O.js +1 -0
  56. package/dist/{game-interfaces-tfpM5NBk.d.ts → game-interfaces-mchNYSZE.d.ts} +2 -2
  57. package/dist/globals.d.ts +12 -1
  58. package/dist/globals.js +1 -1
  59. package/dist/graphics.d.ts +16 -46
  60. package/dist/graphics.js +1 -1
  61. package/dist/input-ui.d.ts +5 -4
  62. package/dist/input-ui.js +1 -1
  63. package/dist/input.d.ts +4 -3
  64. package/dist/input.js +1 -1
  65. package/dist/{material-Wz83vTTp.d.ts → material-9vJ6SZaI.d.ts} +25 -50
  66. package/dist/public.d.ts +38 -0
  67. package/dist/public.js +1 -0
  68. package/dist/runtime.d.ts +7 -381
  69. package/dist/runtime.js +1 -1
  70. package/dist/schema/entity.schema.json +244 -0
  71. package/dist/schema/game-config.schema.json +625 -0
  72. package/dist/schema/input-config.schema.json +499 -0
  73. package/dist/schema/stage-config.schema.json +93 -0
  74. package/dist/schema/stage.schema.json +271 -0
  75. package/dist/schema.d.ts +538 -0
  76. package/dist/schema.js +1 -0
  77. package/dist/stage-transition-CmGpV4tc.d.ts +46 -0
  78. package/dist/vector-CiSHbivc.d.ts +133 -0
  79. package/dist/web-components.d.ts +15 -12
  80. package/dist/web-components.js +1 -9
  81. package/dist/{zylem-stage-runtime-Cs-UDEVU.d.ts → zylem-camera-C3bn6BTI.d.ts} +62 -264
  82. package/package.json +28 -20
  83. package/dist/chunk-73VZQZUL.js +0 -1
  84. package/dist/chunk-A34ZG3L4.js +0 -1
  85. package/dist/chunk-CDPY4VOQ.js +0 -1
  86. package/dist/chunk-DR6XXZE7.js +0 -19
  87. package/dist/chunk-FM5TBEPO.js +0 -1
  88. package/dist/chunk-G2IIMSUH.js +0 -1
  89. package/dist/chunk-NIH5CONO.js +0 -1
  90. package/dist/chunk-ONWXGBWB.js +0 -1
  91. package/dist/chunk-QEDQDR27.js +0 -1
  92. package/dist/chunk-WKHW2QO2.js +0 -1
  93. package/dist/chunk-YHKXQ2ZN.js +0 -1
  94. package/dist/game-default-PZLLHYL7.js +0 -1
  95. package/dist/world-C9zdyl5d.d.ts +0 -103
@@ -0,0 +1,133 @@
1
+ import { EntityHandle, Simulation } from '@zylem/behaviors/core';
2
+ import { Vector3, Vector2 } from 'three';
3
+
4
+ interface PhysicsVector3 {
5
+ x: number;
6
+ y: number;
7
+ z: number;
8
+ }
9
+ interface PhysicsQuaternion {
10
+ x: number;
11
+ y: number;
12
+ z: number;
13
+ w: number;
14
+ }
15
+ interface PhysicsPose {
16
+ position: PhysicsVector3;
17
+ rotation: PhysicsQuaternion;
18
+ }
19
+ interface PhysicsPoseHistory {
20
+ previous: PhysicsPose;
21
+ current: PhysicsPose;
22
+ }
23
+ interface PhysicsRenderPoseProvider {
24
+ getPoseHistory(): PhysicsPoseHistory;
25
+ getRenderPose(alpha: number): PhysicsPose;
26
+ }
27
+
28
+ /** Shared step counter owned by the world; lets bodies know a step has run. */
29
+ interface SimulationStepClock {
30
+ steps: number;
31
+ }
32
+ declare class SimulationBody implements PhysicsRenderPoseProvider {
33
+ private readonly simulation;
34
+ readonly handle: EntityHandle;
35
+ private readonly clock;
36
+ private readonly poseScratch;
37
+ private readonly renderScratch;
38
+ private readonly previousScratch;
39
+ constructor(simulation: Simulation, handle: EntityHandle, clock: SimulationStepClock);
40
+ translation(): PhysicsVector3;
41
+ rotation(): PhysicsQuaternion;
42
+ linvel(): PhysicsVector3;
43
+ angvel(): PhysicsVector3;
44
+ setTranslation(translation: PhysicsVector3, _wakeUp?: boolean): void;
45
+ setRotation(rotation: PhysicsQuaternion, _wakeUp?: boolean): void;
46
+ setLinvel(velocity: PhysicsVector3, _wakeUp?: boolean): void;
47
+ setAngvel(velocity: PhysicsVector3, _wakeUp?: boolean): void;
48
+ applyImpulse(impulse: PhysicsVector3, _wakeUp?: boolean): void;
49
+ /**
50
+ * Damping is fixed at body-creation time in the wasm runtime; there is no
51
+ * live setter FFI yet, so this is accepted (for `MoveableBodyLike`
52
+ * compatibility) but has no effect.
53
+ */
54
+ setLinearDamping(_damping: number): void;
55
+ /**
56
+ * Gravity scale is fixed at body-creation time in the wasm runtime; there is
57
+ * no live setter FFI yet, so this is accepted for Rapier compat but has no
58
+ * effect. Prefer `gravityScale` on the body definition at spawn time when
59
+ * possible.
60
+ */
61
+ setGravityScale(_scale: number, _wakeUp?: boolean): void;
62
+ private bodyInfo;
63
+ bodyType(): number;
64
+ mass(): number;
65
+ isSleeping(): boolean;
66
+ isEnabled(): boolean;
67
+ private livePose;
68
+ private static slotToPose;
69
+ getPoseHistory(): PhysicsPoseHistory;
70
+ getRenderPose(alpha: number): PhysicsPose;
71
+ /**
72
+ * True when the latest render buffer marks this body as sleeping.
73
+ * Used by instancing to skip matrix writes for settled piles.
74
+ */
75
+ isRenderSleeping(): boolean;
76
+ /**
77
+ * Zero-allocation render-pose read for hot paths (instanced rendering of
78
+ * thousands of bodies). Interpolates the previous → current fixed-step
79
+ * poses straight from the shared render buffer into the provided
80
+ * out-parameters — no intermediate pose objects.
81
+ */
82
+ writeRenderPose(alpha: number, outPosition: {
83
+ x: number;
84
+ y: number;
85
+ z: number;
86
+ }, outRotation: {
87
+ x: number;
88
+ y: number;
89
+ z: number;
90
+ w: number;
91
+ }): void;
92
+ private writeLivePose;
93
+ }
94
+
95
+ type Vec2 = Vector2;
96
+ type Vec3 = Vector3 | Vec3Components;
97
+ type Vec2Components = {
98
+ x: number;
99
+ y: number;
100
+ };
101
+ type Vec3Components = {
102
+ x: number;
103
+ y: number;
104
+ z: number;
105
+ };
106
+ type Vec2Tuple = readonly [number?, number?] & {
107
+ x?: number;
108
+ y?: number;
109
+ };
110
+ type Vec3Tuple = readonly [number?, number?, number?] & {
111
+ x?: number;
112
+ y?: number;
113
+ z?: number;
114
+ };
115
+ type Vec2Input = Vec2 | {
116
+ x?: number;
117
+ y?: number;
118
+ } | Vec2Tuple;
119
+ type Vec3Input = Vec3 | {
120
+ x?: number;
121
+ y?: number;
122
+ z?: number;
123
+ } | Vec3Tuple;
124
+ declare const VEC2_ZERO: Readonly<Vec2Components>;
125
+ declare const VEC2_ONE: Readonly<Vec2Components>;
126
+ declare const VEC3_ZERO: Readonly<Vec3Components>;
127
+ declare const VEC3_ONE: Readonly<Vec3Components>;
128
+ declare function normalizeVec2(input?: Vec2Input | null, defaults?: Vec2Input | Partial<Vec2Components>): Vec2Components;
129
+ declare function normalizeVec3(input?: Vec3Input | null, defaults?: Vec3Input | Partial<Vec3Components>): Vec3Components;
130
+ declare function toThreeVector2(input?: Vec2Input | null, defaults?: Vec2Input | Partial<Vec2Components>): Vector2;
131
+ declare function toThreeVector3(input?: Vec3Input | null, defaults?: Vec3Input | Partial<Vec3Components>): Vector3;
132
+
133
+ export { type SimulationStepClock as S, type Vec2 as V, type Vec2Components as a, type Vec2Input as b, type Vec3 as c, type Vec3Components as d, type Vec3Input as e, VEC2_ONE as f, VEC2_ZERO as g, VEC3_ONE as h, VEC3_ZERO as i, normalizeVec3 as j, toThreeVector3 as k, SimulationBody as l, normalizeVec2 as n, toThreeVector2 as t };
@@ -1,20 +1,23 @@
1
- import { G as Game, D as DeviceProfile } from './game-Cuj5gy7U.js';
2
- import { DebugTools } from './debug.js';
3
- import './base-node-life-cycle-CnJ-7zX-.js';
1
+ import { G as Game, D as DeviceProfile } from './game-C1FHVqXl.js';
2
+ import { D as DebugTools } from './debug-state-BPT6jEog.js';
3
+ import './base-node-life-cycle-D2NuN1VB.js';
4
4
  import 'three';
5
- import './game-interfaces-tfpM5NBk.js';
6
- import './entity-DNkYKfdp.js';
7
- import '@dimforge/rapier3d-compat';
8
- import './material-Wz83vTTp.js';
5
+ import './stage-transition-CmGpV4tc.js';
6
+ import './game-interfaces-mchNYSZE.js';
7
+ import './entity-BdSI8CL3.js';
8
+ import '@zylem/behaviors/core';
9
+ import './vector-CiSHbivc.js';
10
+ import './material-9vJ6SZaI.js';
9
11
  import 'three/webgpu';
12
+ import './collision-builder-jF-toPIl.js';
10
13
  import './events.js';
11
14
  import 'mitt';
12
- import '@zylem/behaviors/core';
13
- import './world-C9zdyl5d.js';
14
- import './zylem-stage-runtime-Cs-UDEVU.js';
15
- import './entity-type-map-C94h2TDW.js';
15
+ import './entity-type-map-Bd69SpAS.js';
16
+ import './entity-DZbFQ1Wg.js';
16
17
  import '@zylem/behaviors/particle-emitter';
17
- import './default-controls-BGc61yYl.js';
18
+ import 'three/addons/lines/webgpu/Line2.js';
19
+ import './zylem-camera-C3bn6BTI.js';
20
+ import './default-controls-0-vCnli7.js';
18
21
 
19
22
  /**
20
23
  * State interface for editor-to-game communication
@@ -1,9 +1 @@
1
- import{a as n,c as o,e as a}from"./chunk-CDPY4VOQ.js";var s=class r extends HTMLElement{_game=null;_state={};container;resizeObserver=null;_viewportProfile="auto";static HOST_CONFIG_MARKER=Symbol("zylem:host-config");constructor(){super(),this.attachShadow({mode:"open"});let e=document.createElement("style");e.textContent=`
2
- :host {
3
- display: block;
4
- width: 100%;
5
- height: 100%;
6
- min-width: 0;
7
- min-height: 0;
8
- }
9
- `,this.container=document.createElement("div"),this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="relative",this.container.style.outline="none",this.container.tabIndex=0,this.shadowRoot.append(e,this.container)}focus(){this.container.focus()}connectedCallback(){typeof ResizeObserver<"u"&&!this.resizeObserver&&(this.resizeObserver=new ResizeObserver(()=>{this.syncDisplayRuntime()}),this.resizeObserver.observe(this)),this.syncDisplayRuntime()}set game(e){this._game&&this._game.dispose(),this._game=e,this.attachHostContainer(e),this.syncDisplayRuntime(),e.start()}get game(){return this._game}set state(e){this._state=e,this.syncDebugState(),this.syncToolbarState()}get state(){return this._state}set viewportProfile(e){let t=e==="mobile"||e==="desktop"?e:"auto";this._viewportProfile!==t&&(this._viewportProfile=t,this.syncDisplayRuntime())}get viewportProfile(){return this._viewportProfile}static get observedAttributes(){return["viewport-profile"]}attributeChangedCallback(e,t,i){e==="viewport-profile"&&(this.viewportProfile=i??"auto")}syncDebugState(){let e=this._state.gameState?.debugFlag;e!==void 0&&(n.enabled=e)}syncToolbarState(){let{tool:e,paused:t}=this._state.toolbarState??{};e!==void 0&&a(e),t!==void 0&&o(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),this.resizeObserver=null,this._game&&(this._game.dispose(),this._game=null)}attachHostContainer(e){let t=r.HOST_CONFIG_MARKER,i=e.options.find(l=>!!l?.[t]);if(i){i.container=this.container;return}e.options.push({container:this.container,[t]:!0})}syncDisplayRuntime(){if(!this._game)return;let e=this.getBoundingClientRect(),t=Math.round(e.width||this.clientWidth||0),i=Math.round(e.height||this.clientHeight||0);this._game.setDisplayRuntime({deviceProfile:this._viewportProfile,viewportSize:t>0&&i>0?{width:t,height:i}:void 0})}};customElements.define("zylem-game",s);export{s as ZylemGameElement};
1
+ import{a}from"./chunk-TAUWDQZF.js";import"./chunk-JQKS42G4.js";export{a as ZylemGameElement};
@@ -1,9 +1,7 @@
1
- import { h as SetupFunction, a as Inputs } from './base-node-life-cycle-CnJ-7zX-.js';
2
- import { G as GameEntity } from './entity-DNkYKfdp.js';
3
- import { Object3D, Vector2, Scene, Camera, Vector3, Quaternion, RenderTarget, Texture, Color } from 'three';
4
- import { S as StageEntity, E as Entity, L as LifecycleFunction, Z as ZylemWorld } from './world-C9zdyl5d.js';
1
+ import { Object3D, Vector2, Scene, Camera, Vector3, Quaternion, RenderTarget, Texture } from 'three';
2
+ import { S as StageEntity } from './entity-DZbFQ1Wg.js';
5
3
  import { WebGPURenderer, RenderPipeline } from 'three/webgpu';
6
- import { o as ZylemShader } from './material-Wz83vTTp.js';
4
+ import { R as ResolvedStageTransition } from './stage-transition-CmGpV4tc.js';
7
5
 
8
6
  declare const Perspectives: {
9
7
  readonly FirstPerson: "first-person";
@@ -24,16 +22,6 @@ interface CameraDebugDelegate {
24
22
  resolveTarget(uuid: string): Object3D | null;
25
23
  }
26
24
 
27
- /**
28
- * Renderer type option.
29
- *
30
- * @deprecated game-lib now always renders with WebGPU (Three.js
31
- * {@link WebGPURenderer}, which keeps its own internal WebGL2 fallback for
32
- * devices without WebGPU). This type is retained only so existing public
33
- * APIs (e.g. `CameraOptions.rendererType`) keep type-checking; the value is
34
- * ignored by the renderer.
35
- */
36
- type RendererType = 'auto' | 'webgpu' | 'webgl';
37
25
  /**
38
26
  * The renderer instance type. game-lib standardizes on {@link WebGPURenderer}.
39
27
  */
@@ -48,6 +36,22 @@ interface Viewport {
48
36
  width: number;
49
37
  height: number;
50
38
  }
39
+ /**
40
+ * A postprocessing effect for the render pipeline. Receives the current
41
+ * pipeline node (initially the scene pass) and returns the transformed node.
42
+ * `ctx.scenePass` is the original scene `PassNode` for effects that need
43
+ * extra channels (depth, velocity, ...). `ctx.scene`/`ctx.camera` are the
44
+ * rendered scene and camera, for effects that build their own scene pass
45
+ * (e.g. pixelation, retro). Such pass-replacing effects should be first in
46
+ * the effect chain — the default scene pass simply goes unused.
47
+ *
48
+ * Structurally compatible with `ZylemPostEffect` from `@zylem/shaders`.
49
+ */
50
+ type ZylemPostEffect = (inputNode: any, ctx: {
51
+ scenePass: any;
52
+ scene: any;
53
+ camera: any;
54
+ }) => any;
51
55
  /**
52
56
  * Check if WebGPU is supported in the current browser.
53
57
  *
@@ -81,14 +85,17 @@ declare class RendererManager {
81
85
  */
82
86
  renderScale: number;
83
87
  screenResolution: Vector2;
84
- /**
85
- * @deprecated Always `'webgpu'`. Retained for backward compatibility.
86
- */
87
- rendererType: RendererType;
88
88
  private _initialized;
89
89
  private _sceneRef;
90
90
  private _lastAnimationTimestamp;
91
- constructor(screenResolution?: Vector2, _rendererType?: RendererType);
91
+ /** Registered postprocessing effects, applied in order over the scene pass. */
92
+ private _postEffects;
93
+ /** Scene/camera the current pipeline was built for (for rebuilds). */
94
+ private _postSceneRef;
95
+ private _postCameraRef;
96
+ /** In-flight stage transition, if any. */
97
+ private _transition;
98
+ constructor(screenResolution?: Vector2);
92
99
  /**
93
100
  * Check if the renderer has been initialized
94
101
  */
@@ -122,6 +129,35 @@ declare class RendererManager {
122
129
  * replacement for the old `EffectComposer` + `RenderPass`.
123
130
  */
124
131
  setupPostProcessing(scene: Scene, camera: Camera): void;
132
+ /** Whether a stage transition is currently in flight. */
133
+ get transitionActive(): boolean;
134
+ /**
135
+ * Arm a stage transition: renders one final frame of the outgoing scene
136
+ * into a texture, to be blended with the incoming stage's frames once
137
+ * its pipeline is set up. Call before tearing down the outgoing stage.
138
+ */
139
+ beginSnapshotTransition(resolved: ResolvedStageTransition, scene: Scene, camera: Camera): void;
140
+ /**
141
+ * Complete the active transition immediately: rebuild the normal
142
+ * pipeline, release transition resources, and fire `onComplete`.
143
+ * No-op when no transition is active.
144
+ */
145
+ finishTransition(): void;
146
+ /**
147
+ * Drop the active transition without rebuilding the pipeline (renderer
148
+ * teardown path). Still fires `onComplete`.
149
+ */
150
+ private cancelTransition;
151
+ private releaseTransitionResources;
152
+ /** Advance transition progress; called once per render-loop frame. */
153
+ private advanceTransition;
154
+ /**
155
+ * Register postprocessing effects (e.g. from `@zylem/shaders`). Effects
156
+ * are applied in order between the scene pass and the display output
157
+ * transform. If a pipeline is already active it is rebuilt immediately;
158
+ * otherwise the effects apply on the next {@link setupPostProcessing}.
159
+ */
160
+ setPostProcessingEffects(effects: ZylemPostEffect[]): void;
125
161
  /**
126
162
  * Set the supersampling (SSAA) multiplier. Takes effect on the next
127
163
  * {@link setupPostProcessing}. `1` = native resolution (default).
@@ -364,7 +400,6 @@ declare class ZylemCamera {
364
400
  screenResolution: Vector2;
365
401
  _perspective: PerspectiveType;
366
402
  frustumSize: number;
367
- rendererType: RendererType;
368
403
  sceneRef: Scene | null;
369
404
  /** Name for camera manager lookup. */
370
405
  name: string;
@@ -404,7 +439,7 @@ declare class ZylemCamera {
404
439
  private _rendererManager;
405
440
  /** Elapsed time tracker for CameraContext. */
406
441
  private _elapsedTime;
407
- constructor(perspective: PerspectiveType, screenResolution: Vector2, frustumSize?: number, rendererType?: RendererType);
442
+ constructor(perspective: PerspectiveType, screenResolution: Vector2, frustumSize?: number);
408
443
  /**
409
444
  * Setup the camera with a scene and renderer manager.
410
445
  */
@@ -491,6 +526,10 @@ declare class ZylemCamera {
491
526
  * Skipped when _skipDebugOrbit is true so the pipeline always runs.
492
527
  */
493
528
  setDebugDelegate(delegate: CameraDebugDelegate | null): void;
529
+ /**
530
+ * Frame the debug orbit camera on an Object3D (AABB fit).
531
+ */
532
+ frameObject(object: Object3D): void;
494
533
  /**
495
534
  * Directly set the camera position.
496
535
  */
@@ -533,245 +572,4 @@ declare class ZylemCamera {
533
572
  private createCameraForPerspective;
534
573
  }
535
574
 
536
- /**
537
- * CameraManager orchestrates multiple cameras per stage.
538
- *
539
- * Responsibilities:
540
- * - Named camera registry (add/remove/get by name or reference)
541
- * - Active camera list management (determines which cameras render)
542
- * - Always-available debug camera with orbit controls
543
- * - Per-frame update of all active cameras' perspective controllers
544
- * - Coordinating rendering via RendererManager for all active viewports
545
- */
546
- declare class CameraManager {
547
- /** Named camera registry */
548
- private cameras;
549
- /** Currently active cameras, ordered by render layer (first = bottom) */
550
- private _activeCameras;
551
- /** Auto-created debug camera with orbit controls */
552
- private _debugCamera;
553
- /** Reference to the shared renderer manager */
554
- private _rendererManager;
555
- /** Scene reference */
556
- private _sceneRef;
557
- /** Counter for auto-generated camera names */
558
- private _autoNameCounter;
559
- constructor();
560
- /**
561
- * Get the list of currently active cameras.
562
- */
563
- get activeCameras(): ReadonlyArray<ZylemCamera>;
564
- /**
565
- * Get the primary active camera (first in the active list).
566
- */
567
- get primaryCamera(): ZylemCamera | null;
568
- /**
569
- * Get the debug camera.
570
- */
571
- get debugCamera(): ZylemCamera | null;
572
- /**
573
- * Get all registered cameras.
574
- */
575
- get allCameras(): ReadonlyArray<ZylemCamera>;
576
- /**
577
- * Add a camera to the manager.
578
- * If no name is provided, one is auto-generated.
579
- * The first camera added becomes the active camera.
580
- *
581
- * @param camera The ZylemCamera instance to add
582
- * @param name Optional name for lookup
583
- * @returns The assigned name
584
- */
585
- addCamera(camera: ZylemCamera, name?: string): string;
586
- /**
587
- * Remove a camera by name or reference.
588
- * Cannot remove the debug camera via this method.
589
- */
590
- removeCamera(nameOrRef: string | ZylemCamera): boolean;
591
- /**
592
- * Set a camera as the primary active camera (replaces all active cameras
593
- * except additional viewport cameras).
594
- *
595
- * @param nameOrRef Camera name or reference to activate
596
- */
597
- setActiveCamera(nameOrRef: string | ZylemCamera): boolean;
598
- /**
599
- * Add a camera as an additional active camera (for split-screen or PiP).
600
- */
601
- addActiveCamera(nameOrRef: string | ZylemCamera): boolean;
602
- /**
603
- * Remove a camera from the active render list (does not remove from registry).
604
- */
605
- deactivateCamera(nameOrRef: string | ZylemCamera): boolean;
606
- /**
607
- * Get a camera by name.
608
- */
609
- getCamera(name: string): ZylemCamera | null;
610
- /**
611
- * Setup all cameras with the given scene and renderer manager.
612
- * Also creates the debug camera.
613
- */
614
- setup(scene: Scene, rendererManager: RendererManager): Promise<void>;
615
- /**
616
- * Update all active cameras' controllers.
617
- */
618
- update(delta: number): void;
619
- /**
620
- * Render all active cameras through the renderer manager.
621
- * RTT cameras (those with a renderTarget) are rendered first to their
622
- * offscreen textures, then viewport cameras are rendered to the screen.
623
- */
624
- render(scene: Scene): void;
625
- private updateOrbitingCamerasForRender;
626
- /**
627
- * Create a default third-person camera if no cameras have been added.
628
- */
629
- ensureDefaultCamera(): ZylemCamera;
630
- /**
631
- * Dispose all cameras and cleanup.
632
- */
633
- dispose(): void;
634
- /**
635
- * Create the always-available debug camera with orbit controls.
636
- */
637
- private createDebugCamera;
638
- /**
639
- * Resolve a camera from a name or reference.
640
- */
641
- private resolveCamera;
642
- }
643
-
644
- interface SceneState {
645
- backgroundColor: Color | string;
646
- backgroundImage: string | null;
647
- backgroundShader?: ZylemShader | null;
648
- /**
649
- * When `false`, skip the engine's built-in ambient + directional lights so
650
- * the caller can configure the scene's lighting entirely via
651
- * `createLight(...)` entities. Defaults to `true` for backward
652
- * compatibility with existing demos.
653
- */
654
- defaultLighting?: boolean;
655
- }
656
- declare class ZylemScene implements Entity<ZylemScene> {
657
- type: string;
658
- _setup?: SetupFunction<ZylemScene>;
659
- scene: Scene;
660
- /** @deprecated Use cameraManager instead */
661
- zylemCamera: ZylemCamera;
662
- cameraManager: CameraManager | null;
663
- containerElement: HTMLElement | null;
664
- update: LifecycleFunction<ZylemScene>;
665
- _collision?: ((entity: any, other: any, globals?: any) => void) | undefined;
666
- _destroy?: ((globals?: any) => void) | undefined;
667
- name?: string | undefined;
668
- tag?: Set<string> | undefined;
669
- private skyboxMaterial;
670
- private skyboxMesh;
671
- constructor(id: string, camera: ZylemCamera, state: SceneState);
672
- /**
673
- * Create a large inverted box with the shader for a skybox effect.
674
- *
675
- * WebGPU-only: background shaders must be authored in TSL
676
- * ({@link ZylemTSLShader}). A GLSL shader logs a warning and is ignored
677
- * (the solid background color is kept).
678
- */
679
- private setupBackgroundShader;
680
- setup(): void;
681
- destroy(): void;
682
- /**
683
- * Setup camera with the scene.
684
- * Supports both legacy single camera and CameraManager modes.
685
- */
686
- setupCamera(scene: Scene, camera: ZylemCamera, rendererManager?: RendererManager): Promise<void>;
687
- /**
688
- * Setup with a CameraManager (multi-camera support).
689
- */
690
- setupCameraManager(scene: Scene, cameraManager: CameraManager, rendererManager: RendererManager): Promise<void>;
691
- /**
692
- * Add a camera (rig or direct) to the scene graph.
693
- */
694
- private addCameraToScene;
695
- /**
696
- * Setup scene lighting
697
- */
698
- setupLighting(scene: Scene): void;
699
- /**
700
- * Update renderer size - delegates to camera manager or camera
701
- */
702
- updateRenderer(width: number, height: number): void;
703
- /**
704
- * Add object to scene
705
- */
706
- add(object: Object3D, position?: Vector3): void;
707
- /**
708
- * Add game entity to scene
709
- */
710
- addEntity(entity: GameEntity<any>): void;
711
- /**
712
- * Add an entity's group or mesh to the scene (for late-loaded models).
713
- * Uses entity's current body position if physics is active.
714
- *
715
- * Fog entities ({@link ZylemFog}) are routed through the normal add
716
- * pipeline so their empty placeholder group is parented for cleanup,
717
- * but they also get an `attachToScene` call that wires `scene.fog`
718
- * and starts the optional material patcher.
719
- */
720
- addEntityGroup(entity: GameEntity<any>): void;
721
- private isAttachedOutsideScene;
722
- /**
723
- * Add debug helpers to scene
724
- */
725
- debugScene(): void;
726
- /**
727
- * Per-frame skybox hook. Ensures the skybox cube follows the active camera
728
- * position so it always appears infinitely far away regardless of camera
729
- * movement. TSL background shaders animate via the `time` node, which the
730
- * renderer advances automatically.
731
- */
732
- updateSkybox(_delta: number): void;
733
- }
734
-
735
- /**
736
- * Host-provided debug signals for wasm runtime adapters (no direct `debugState` import in adapters).
737
- */
738
- interface RuntimeDebugBinding {
739
- /** When true, show wasm-side diagnostics (e.g. instanced collision heat tint). */
740
- runtimeDiagnostics(): boolean;
741
- }
742
- interface StageRuntimeContext {
743
- scene: ZylemScene;
744
- world: ZylemWorld;
745
- camera: ZylemCamera;
746
- /** Optional; when set, adapters may enable extra runtime visualization. */
747
- debug?: RuntimeDebugBinding;
748
- }
749
- interface StageRuntimeStepContext extends StageRuntimeContext {
750
- delta: number;
751
- inputs: Inputs;
752
- }
753
- interface StageRuntimeAdapter {
754
- init(context: StageRuntimeContext): Promise<void> | void;
755
- step(context: StageRuntimeStepContext): void;
756
- destroy(context: StageRuntimeContext | null): void;
757
- ownsEntity(entity: GameEntity<any>): boolean;
758
- rendersEntity(entity: GameEntity<any>): boolean;
759
- registerEntity(entity: GameEntity<any>): void;
760
- unregisterEntity(entity: GameEntity<any>): void;
761
- /**
762
- * Optional: when implemented, the stage debug delegate will draw the
763
- * returned line segments alongside the TS Rapier debug overlay so wasm
764
- * runtime adapters can visualize their own colliders. Returning `null`
765
- * (or omitting the method entirely) disables the second pass.
766
- */
767
- getDebugRender?(): {
768
- vertices: Float32Array;
769
- colors: Float32Array;
770
- } | null;
771
- }
772
- interface ZylemRuntimeStageAdapterSource {
773
- source: RequestInfo | URL | ArrayBuffer;
774
- }
775
- declare function createZylemRuntimeStageAdapter(options: ZylemRuntimeStageAdapterSource): StageRuntimeAdapter;
776
-
777
- export { type CameraBehavior as C, type PerspectiveType as P, type RuntimeDebugBinding as R, type StageRuntimeAdapter as S, type TransformLike as T, type Viewport as V, type ZylemRenderer as Z, type StageRuntimeContext as a, type StageRuntimeStepContext as b, createZylemRuntimeStageAdapter as c, Perspectives as d, type RendererType as e, CameraManager as f, type CameraPose as g, type PoseDelta as h, isWebGPUSupported as i, type CameraContext as j, type CameraPerspective as k, type CameraAction as l, type CameraPipelineState as m, CameraPipeline as n, ZylemCamera as o, ZylemScene as p, RendererManager as q };
575
+ export { type CameraPose as C, type PerspectiveType as P, RendererManager as R, type TransformLike as T, type Viewport as V, type ZylemPostEffect as Z, Perspectives as a, type ZylemRenderer as b, type PoseDelta as c, type CameraContext as d, type CameraPerspective as e, type CameraBehavior as f, type CameraAction as g, type CameraPipelineState as h, isWebGPUSupported as i, CameraPipeline as j, ZylemCamera as k };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zylem/game-lib",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "description": "A powerful and easy-to-use framework for creating simple 3D digital interactive applications using TypeScript.",
6
6
  "license": "MIT",
@@ -68,13 +68,25 @@
68
68
  "./runtime": {
69
69
  "types": "./dist/runtime.d.ts",
70
70
  "import": "./dist/runtime.js"
71
- }
71
+ },
72
+ "./schema": {
73
+ "types": "./dist/schema.d.ts",
74
+ "import": "./dist/schema.js"
75
+ },
76
+ "./api/rollup": "./dist/api/game-lib.d.ts",
77
+ "./api/report": "./dist/api/game-lib.api.md",
78
+ "./api/model": "./dist/api/game-lib.api.json",
79
+ "./api/typedoc": "./dist/api/game-lib.typedoc.json",
80
+ "./schema/entity": "./dist/schema/entity.schema.json",
81
+ "./schema/stage": "./dist/schema/stage.schema.json",
82
+ "./schema/game-config": "./dist/schema/game-config.schema.json",
83
+ "./schema/stage-config": "./dist/schema/stage-config.schema.json",
84
+ "./schema/input-config": "./dist/schema/input-config.schema.json"
72
85
  },
73
86
  "keywords": [
74
87
  "game",
75
88
  "three",
76
89
  "typescript",
77
- "rapier3d",
78
90
  "physics",
79
91
  "framework",
80
92
  "vite",
@@ -86,51 +98,47 @@
86
98
  "dist"
87
99
  ],
88
100
  "dependencies": {
89
- "comlink": "^4.4.2",
90
101
  "@dgreenheck/three-pinata": "^2.0.1",
91
- "@dimforge/rapier3d-compat": "^0.11.2",
92
102
  "@sinclair/typebox": "^0.34.41",
93
- "@zylem/behaviors": "^0.3.0",
94
103
  "@types/howler": "^2.2.12",
104
+ "@zylem/behaviors": "link:../../../behaviors",
105
+ "comlink": "^4.4.2",
95
106
  "howler": "^2.2.4",
96
107
  "idb-keyval": "^6.2.2",
97
108
  "msgpackr": "^1.11.5",
98
109
  "nanoid": "^5.1.5",
99
110
  "stats.js": "^0.17.0",
100
- "three": "^0.184.0",
111
+ "three": "^0.185.0",
101
112
  "typescript-fsm": "^1.6.0",
102
113
  "valtio": "^2.1.7"
103
114
  },
104
115
  "peerDependencies": {
105
- "@dimforge/rapier3d-compat": "^0.11.2",
106
- "@zylem/runtime": "^0.1.0",
107
116
  "howler": "^2.2.4",
108
117
  "nanoid": "^5.1.5",
109
- "three": "^0.184.0",
118
+ "three": "^0.185.0",
110
119
  "valtio": "^2.1.7"
111
120
  },
112
- "peerDependenciesMeta": {
113
- "@zylem/runtime": {
114
- "optional": true
115
- }
116
- },
117
121
  "devDependencies": {
122
+ "@microsoft/api-extractor": "^7.58.9",
118
123
  "@types/node": "^20.19.13",
119
124
  "@types/stats.js": "^0.17.4",
120
- "@types/three": "^0.184.0",
125
+ "@types/three": "^0.185.0",
126
+ "@typescript/native-preview": "latest",
121
127
  "happy-dom": "^18.0.1",
122
128
  "jsdom": "^27.2.0",
123
129
  "tslib": "^2.8.1",
124
130
  "tsup": "^8.5.1",
131
+ "typedoc": "^0.28.20",
125
132
  "typescript": "6.0.3",
126
- "@typescript/native-preview": "latest",
127
133
  "vite-plugin-solid": "^2.11.8",
128
- "vitest": "^4.0.9",
129
- "@zylem/runtime": "0.1.0"
134
+ "vitest": "^4.0.9"
130
135
  },
131
136
  "scripts": {
132
- "build": "tsup",
137
+ "build": "tsup && pnpm api:extract && pnpm api:typedoc && pnpm schema:emit",
133
138
  "dev": "tsup --watch",
139
+ "api:extract": "mkdir -p dist/api temp && api-extractor run --local --verbose",
140
+ "api:typedoc": "mkdir -p dist/api && typedoc --options typedoc.json",
141
+ "schema:emit": "node --experimental-strip-types ./scripts/emit-json-schemas.ts",
134
142
  "lint": "biome check .",
135
143
  "typecheck": "tsgo --noEmit",
136
144
  "test": "vitest --reporter=verbose",
@@ -1 +0,0 @@
1
- import{c as l,d as c,h as a,k as d}from"./chunk-G2IIMSUH.js";import{ActiveCollisionTypes as D,ColliderDesc as g,RigidBodyDesc as h,RigidBodyType as p,Vector3 as I}from"@dimforge/rapier3d-compat";var u=new Map,m=0;function C(o){let e=u.get(o);return e===void 0&&(e=m++%16,u.set(o,e)),e}function x(o){let e=0;return o.forEach(t=>{let i=C(t);e|=1<<i}),e}var y=class{static=!1;sensor=!1;gravity=new I(0,0,0);build(e){let t=this.bodyDesc({isDynamicBody:!this.static}),i=this.collider(e),s=e.collisionType;if(s){let f=C(s),r=65535;e.collisionFilter&&(r=x(e.collisionFilter)),i.setCollisionGroups(f<<16|r)}let{KINEMATIC_FIXED:n,DEFAULT:b}=D;return i.activeCollisionTypes=this.sensor?n:b,[t,i]}withCollision(e){return this.sensor=e?.sensor??this.sensor,this.static=e?.static??this.static,this}collider(e){let t=d(e.size,c),i={x:t.x/2,y:t.y/2,z:t.z/2},s=g.cuboid(i.x,i.y,i.z),n=a(e.position,l);return s.setTranslation(n.x,n.y,n.z),s}bodyDesc({isDynamicBody:e=!0}){let t=e?p.Dynamic:p.Fixed;return new h(t).setTranslation(0,0,0).setGravityScale(1).setCanSleep(!1).setCcdEnabled(!0)}};export{C as a,x as b,y as c};