@zylem/game-lib 0.6.4 → 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 (156) hide show
  1. package/README.md +18 -2
  2. package/dist/actions.d.ts +321 -11
  3. package/dist/actions.js +1 -936
  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.d.ts +13 -0
  9. package/dist/audio.js +1 -0
  10. package/dist/base-node-life-cycle-D2NuN1VB.d.ts +151 -0
  11. package/dist/behavior.d.ts +2 -0
  12. package/dist/behavior.js +1 -0
  13. package/dist/blueprints-TbGY-h53.d.ts +162 -0
  14. package/dist/chunk-4QLJUQSJ.js +1 -0
  15. package/dist/chunk-7FR5JSQ2.js +1 -0
  16. package/dist/chunk-7GYFZKK7.js +1 -0
  17. package/dist/chunk-7WRQ2UAN.js +1 -0
  18. package/dist/chunk-BH53MBAZ.js +1 -0
  19. package/dist/chunk-BIGH6D34.js +0 -0
  20. package/dist/chunk-CM5YRNBJ.js +19 -0
  21. package/dist/chunk-COM6HJ2L.js +1 -0
  22. package/dist/chunk-D2PATZCC.js +1 -0
  23. package/dist/chunk-DFLI7ICU.js +0 -0
  24. package/dist/chunk-E3UBSUPX.js +1 -0
  25. package/dist/chunk-FKIKN7RP.js +24 -0
  26. package/dist/chunk-G4HONLWC.js +1 -0
  27. package/dist/chunk-IKWE2W6L.js +1 -0
  28. package/dist/chunk-IPWUDOV5.js +1 -0
  29. package/dist/chunk-JEHFHUH4.js +0 -0
  30. package/dist/chunk-JNKPTL77.js +1 -0
  31. package/dist/chunk-JQKS42G4.js +1 -0
  32. package/dist/chunk-M3XNO56P.js +1 -0
  33. package/dist/chunk-MSC2BEO5.js +1 -0
  34. package/dist/chunk-ORIDWL3T.js +0 -0
  35. package/dist/chunk-QB3NL7VQ.js +1 -0
  36. package/dist/chunk-QXVH6POE.js +1 -0
  37. package/dist/chunk-RXDTAWI2.js +29 -0
  38. package/dist/chunk-TAUWDQZF.js +9 -0
  39. package/dist/chunk-VS2D4B3W.js +1 -0
  40. package/dist/chunk-WQ3WMMZD.js +1 -0
  41. package/dist/chunk-XK63E4SX.js +1 -0
  42. package/dist/chunk-XNDS4YFR.js +1 -0
  43. package/dist/chunk-XNHVRFAK.js +1 -0
  44. package/dist/chunk-XRP4JJXL.js +1 -0
  45. package/dist/chunk-YHEWKN7N.js +1 -0
  46. package/dist/chunk-ZRT3ZQVH.js +1 -0
  47. package/dist/collision-builder-jF-toPIl.d.ts +38 -0
  48. package/dist/core.d.ts +223 -16
  49. package/dist/core.js +1 -12424
  50. package/dist/debug-state-BPT6jEog.d.ts +17 -0
  51. package/dist/debug.d.ts +76 -0
  52. package/dist/debug.js +1 -0
  53. package/dist/default-controls-0-vCnli7.d.ts +111 -0
  54. package/dist/{entity-vj-HTjzU.d.ts → entity-BdSI8CL3.d.ts} +119 -626
  55. package/dist/{entity-Bq_eNEDI.d.ts → entity-DZbFQ1Wg.d.ts} +4 -4
  56. package/dist/entity-type-map-Bd69SpAS.d.ts +928 -0
  57. package/dist/entity.d.ts +268 -0
  58. package/dist/entity.js +1 -0
  59. package/dist/events.d.ts +181 -0
  60. package/dist/events.js +1 -0
  61. package/dist/game-C1FHVqXl.d.ts +1886 -0
  62. package/dist/game-default-QHROHW2O.js +1 -0
  63. package/dist/game-interfaces-mchNYSZE.d.ts +90 -0
  64. package/dist/globals.d.ts +115 -0
  65. package/dist/globals.js +1 -0
  66. package/dist/graphics.d.ts +53 -0
  67. package/dist/graphics.js +1 -0
  68. package/dist/input-ui.d.ts +35 -0
  69. package/dist/input-ui.js +1 -0
  70. package/dist/input.d.ts +73 -0
  71. package/dist/input.js +1 -0
  72. package/dist/material-9vJ6SZaI.d.ts +126 -0
  73. package/dist/public.d.ts +38 -0
  74. package/dist/public.js +1 -0
  75. package/dist/runtime.d.ts +59 -0
  76. package/dist/runtime.js +1 -0
  77. package/dist/schema/entity.schema.json +244 -0
  78. package/dist/schema/game-config.schema.json +625 -0
  79. package/dist/schema/input-config.schema.json +499 -0
  80. package/dist/schema/stage-config.schema.json +93 -0
  81. package/dist/schema/stage.schema.json +271 -0
  82. package/dist/schema.d.ts +538 -0
  83. package/dist/schema.js +1 -0
  84. package/dist/stage-transition-CmGpV4tc.d.ts +46 -0
  85. package/dist/vector-CiSHbivc.d.ts +133 -0
  86. package/dist/web-components.d.ts +70 -0
  87. package/dist/web-components.js +1 -0
  88. package/dist/zylem-camera-C3bn6BTI.d.ts +575 -0
  89. package/package.json +70 -73
  90. package/dist/actions.js.map +0 -1
  91. package/dist/behavior/jumper-2d.d.ts +0 -114
  92. package/dist/behavior/jumper-2d.js +0 -711
  93. package/dist/behavior/jumper-2d.js.map +0 -1
  94. package/dist/behavior/platformer-3d.d.ts +0 -296
  95. package/dist/behavior/platformer-3d.js +0 -761
  96. package/dist/behavior/platformer-3d.js.map +0 -1
  97. package/dist/behavior/ricochet-2d.d.ts +0 -275
  98. package/dist/behavior/ricochet-2d.js +0 -425
  99. package/dist/behavior/ricochet-2d.js.map +0 -1
  100. package/dist/behavior/ricochet-3d.d.ts +0 -117
  101. package/dist/behavior/ricochet-3d.js +0 -443
  102. package/dist/behavior/ricochet-3d.js.map +0 -1
  103. package/dist/behavior/screen-visibility.d.ts +0 -79
  104. package/dist/behavior/screen-visibility.js +0 -358
  105. package/dist/behavior/screen-visibility.js.map +0 -1
  106. package/dist/behavior/screen-wrap.d.ts +0 -87
  107. package/dist/behavior/screen-wrap.js +0 -246
  108. package/dist/behavior/screen-wrap.js.map +0 -1
  109. package/dist/behavior/shooter-2d.d.ts +0 -79
  110. package/dist/behavior/shooter-2d.js +0 -180
  111. package/dist/behavior/shooter-2d.js.map +0 -1
  112. package/dist/behavior/thruster.d.ts +0 -11
  113. package/dist/behavior/thruster.js +0 -292
  114. package/dist/behavior/thruster.js.map +0 -1
  115. package/dist/behavior/top-down-movement.d.ts +0 -56
  116. package/dist/behavior/top-down-movement.js +0 -125
  117. package/dist/behavior/top-down-movement.js.map +0 -1
  118. package/dist/behavior/world-boundary-2d.d.ts +0 -142
  119. package/dist/behavior/world-boundary-2d.js +0 -235
  120. package/dist/behavior/world-boundary-2d.js.map +0 -1
  121. package/dist/behavior/world-boundary-3d.d.ts +0 -76
  122. package/dist/behavior/world-boundary-3d.js +0 -274
  123. package/dist/behavior/world-boundary-3d.js.map +0 -1
  124. package/dist/behavior-descriptor-BXnVR8Ki.d.ts +0 -159
  125. package/dist/blueprints-DmbK2dki.d.ts +0 -26
  126. package/dist/camera-4XO5gbQH.d.ts +0 -905
  127. package/dist/camera.d.ts +0 -6
  128. package/dist/camera.js +0 -1993
  129. package/dist/camera.js.map +0 -1
  130. package/dist/composition-BASvMKrW.d.ts +0 -218
  131. package/dist/core-CARRaS55.d.ts +0 -541
  132. package/dist/core.js.map +0 -1
  133. package/dist/entities-ChFirVL9.d.ts +0 -410
  134. package/dist/entities.d.ts +0 -9
  135. package/dist/entities.js +0 -4986
  136. package/dist/entities.js.map +0 -1
  137. package/dist/entity-types-DAu8sGJH.d.ts +0 -26
  138. package/dist/global-change-2JvMaz44.d.ts +0 -25
  139. package/dist/main.d.ts +0 -1353
  140. package/dist/main.js +0 -19525
  141. package/dist/main.js.map +0 -1
  142. package/dist/physics-pose-DCc4oE44.d.ts +0 -25
  143. package/dist/physics-protocol-BDD3P5W2.d.ts +0 -200
  144. package/dist/physics-worker.d.ts +0 -21
  145. package/dist/physics-worker.js +0 -306
  146. package/dist/physics-worker.js.map +0 -1
  147. package/dist/physics.d.ts +0 -205
  148. package/dist/physics.js +0 -577
  149. package/dist/physics.js.map +0 -1
  150. package/dist/stage-types-C19IhuzA.d.ts +0 -731
  151. package/dist/stage.d.ts +0 -52
  152. package/dist/stage.js +0 -8479
  153. package/dist/stage.js.map +0 -1
  154. package/dist/sync-state-machine-CZyspBpj.d.ts +0 -16
  155. package/dist/thruster-23lzoPZd.d.ts +0 -180
  156. package/dist/world-DfgxoNMt.d.ts +0 -105
@@ -0,0 +1,575 @@
1
+ import { Object3D, Vector2, Scene, Camera, Vector3, Quaternion, RenderTarget, Texture } from 'three';
2
+ import { S as StageEntity } from './entity-DZbFQ1Wg.js';
3
+ import { WebGPURenderer, RenderPipeline } from 'three/webgpu';
4
+ import { R as ResolvedStageTransition } from './stage-transition-CmGpV4tc.js';
5
+
6
+ declare const Perspectives: {
7
+ readonly FirstPerson: "first-person";
8
+ readonly ThirdPerson: "third-person";
9
+ readonly Isometric: "isometric";
10
+ readonly Flat2D: "flat-2d";
11
+ readonly Fixed2D: "fixed-2d";
12
+ readonly TopDown: "top-down";
13
+ };
14
+ type PerspectiveType = (typeof Perspectives)[keyof typeof Perspectives];
15
+
16
+ interface CameraDebugState {
17
+ enabled: boolean;
18
+ selected: string[];
19
+ }
20
+ interface CameraDebugDelegate {
21
+ subscribe(listener: (state: CameraDebugState) => void): () => void;
22
+ resolveTarget(uuid: string): Object3D | null;
23
+ }
24
+
25
+ /**
26
+ * The renderer instance type. game-lib standardizes on {@link WebGPURenderer}.
27
+ */
28
+ type ZylemRenderer = WebGPURenderer;
29
+ /**
30
+ * Viewport definition in normalized coordinates (0-1).
31
+ * Represents a rectangular region of the canvas for camera rendering.
32
+ */
33
+ interface Viewport {
34
+ x: number;
35
+ y: number;
36
+ width: number;
37
+ height: number;
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;
55
+ /**
56
+ * Check if WebGPU is supported in the current browser.
57
+ *
58
+ * Informational only — game-lib always constructs a {@link WebGPURenderer},
59
+ * which transparently falls back to a WebGL2 backend when the WebGPU adapter
60
+ * is unavailable. Callers can use this to surface device capabilities.
61
+ */
62
+ declare function isWebGPUSupported(): Promise<boolean>;
63
+ /**
64
+ * RendererManager owns the shared WebGPU renderer, canvas element, the
65
+ * optional post-processing pipeline, and the render loop. There is one
66
+ * RendererManager per game.
67
+ *
68
+ * It iterates active cameras and renders each with its configured viewport.
69
+ */
70
+ declare class RendererManager {
71
+ renderer: ZylemRenderer;
72
+ /**
73
+ * Optional TSL post-processing pipeline. Bound to a single fullscreen
74
+ * scene+camera via {@link setupPostProcessing}. When present and the
75
+ * frame is a single fullscreen viewport, the pipeline drives the final
76
+ * draw instead of `renderer.render(...)`.
77
+ */
78
+ postProcessing: RenderPipeline | null;
79
+ /**
80
+ * Supersampling (SSAA) multiplier for the scene pass. `1` renders at native
81
+ * resolution (default). Values > 1 render the scene pass larger and let the
82
+ * post pipeline downsample it, trading GPU cost for smoother shading/edges
83
+ * (this is what the legacy WebGL pipeline did implicitly). Applied on the
84
+ * next {@link setupPostProcessing}.
85
+ */
86
+ renderScale: number;
87
+ screenResolution: Vector2;
88
+ private _initialized;
89
+ private _sceneRef;
90
+ private _lastAnimationTimestamp;
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);
99
+ /**
100
+ * Check if the renderer has been initialized
101
+ */
102
+ get initialized(): boolean;
103
+ /**
104
+ * Whether the active renderer is WebGPU. Always true; retained for
105
+ * backward compatibility with callers that branched on backend.
106
+ *
107
+ * @deprecated game-lib is WebGPU-only.
108
+ */
109
+ get isWebGPU(): boolean;
110
+ /**
111
+ * Initialize the renderer (must be called before rendering).
112
+ * Async because WebGPU requires async initialization.
113
+ *
114
+ * The renderer keeps Three.js's built-in WebGL2 fallback backend, so it
115
+ * still initializes on devices without native WebGPU.
116
+ */
117
+ initRenderer(): Promise<void>;
118
+ /**
119
+ * Set the current scene reference for rendering.
120
+ */
121
+ setScene(scene: Scene): void;
122
+ /**
123
+ * Set up the post-processing pipeline for a scene + camera.
124
+ *
125
+ * Builds a TSL `pass(scene, camera)` (HalfFloat + MSAA) and composes the
126
+ * final output ourselves so a display-space dither can be added: the dither
127
+ * breaks up 8-bit gradient banding (e.g. on terrain/sky) that the legacy
128
+ * WebGL pipeline hid via implicit supersampling. This is the WebGPU
129
+ * replacement for the old `EffectComposer` + `RenderPass`.
130
+ */
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;
161
+ /**
162
+ * Set the supersampling (SSAA) multiplier. Takes effect on the next
163
+ * {@link setupPostProcessing}. `1` = native resolution (default).
164
+ */
165
+ setRenderScale(scale: number): void;
166
+ /**
167
+ * Dispose the current post-processing pipeline, if any.
168
+ */
169
+ private disposePostProcessing;
170
+ /**
171
+ * Start the render loop. Calls the provided callback each frame.
172
+ */
173
+ startRenderLoop(onFrame: (delta: number) => void): void;
174
+ /**
175
+ * Stop the render loop.
176
+ */
177
+ stopRenderLoop(): void;
178
+ /**
179
+ * Render a scene from a single camera's perspective.
180
+ * Sets the viewport/scissor based on the camera's viewport config so
181
+ * split-screen / picture-in-picture layouts render to their region.
182
+ *
183
+ * @param usePostProcessing When true and a pipeline is configured, the
184
+ * post-processing pipeline drives the draw (fullscreen only).
185
+ */
186
+ renderCamera(scene: Scene, camera: ZylemCamera, usePostProcessing?: boolean): void;
187
+ /**
188
+ * Render a camera to its offscreen render target.
189
+ * Bypasses post-processing since render-to-texture output is consumed by
190
+ * an in-scene material (jumbotron / security-camera / portal effects).
191
+ *
192
+ * The camera must have a non-null renderTarget.
193
+ */
194
+ renderCameraToTarget(scene: Scene, camera: ZylemCamera): void;
195
+ /**
196
+ * Render a scene from multiple cameras, each with their own viewport.
197
+ * Cameras are rendered in order (first = bottom layer, last = top layer).
198
+ *
199
+ * Post-processing is applied only when there is a single fullscreen
200
+ * camera; split-screen layouts render directly per-viewport (a single
201
+ * fullscreen post pass cannot honor per-camera scissor regions).
202
+ */
203
+ renderCameras(scene: Scene, cameras: ZylemCamera[]): void;
204
+ /**
205
+ * Simple single-camera render (backwards compatible).
206
+ * Uses post-processing when configured.
207
+ */
208
+ render(scene: Scene, camera: Camera): void;
209
+ /**
210
+ * Resize the renderer and update resolution.
211
+ */
212
+ resize(width: number, height: number): void;
213
+ /**
214
+ * Update renderer pixel ratio (DPR).
215
+ */
216
+ setPixelRatio(dpr: number): void;
217
+ /**
218
+ * Get the DOM element for the renderer.
219
+ */
220
+ getDomElement(): HTMLCanvasElement;
221
+ /**
222
+ * Dispose renderer, post-processing, and related resources.
223
+ */
224
+ dispose(): void;
225
+ }
226
+
227
+ /**
228
+ * Represents a full camera pose: position, rotation, projection params, and optional lookAt.
229
+ * This is the canonical data structure that flows through the camera pipeline.
230
+ */
231
+ interface CameraPose {
232
+ position: Vector3;
233
+ rotation: Quaternion;
234
+ fov?: number;
235
+ zoom?: number;
236
+ near?: number;
237
+ far?: number;
238
+ /** When set, the camera orients to look at this point (takes priority over rotation). */
239
+ lookAt?: Vector3;
240
+ }
241
+ /**
242
+ * An additive delta applied on top of a CameraPose.
243
+ * Used by CameraActions to apply transient offsets (shake, recoil, etc.).
244
+ */
245
+ interface PoseDelta {
246
+ position?: Vector3;
247
+ rotation?: Quaternion;
248
+ fov?: number;
249
+ zoom?: number;
250
+ }
251
+ /**
252
+ * Minimal transform representation for pipeline targets.
253
+ */
254
+ interface TransformLike {
255
+ position: Vector3;
256
+ rotation?: Quaternion;
257
+ }
258
+ /**
259
+ * Per-frame context passed to every pipeline module (perspectives, behaviors, actions).
260
+ */
261
+ interface CameraContext {
262
+ /** Frame delta time in seconds. */
263
+ dt: number;
264
+ /** Elapsed time in seconds since camera started updating. */
265
+ time: number;
266
+ /** Current viewport dimensions and aspect ratio. */
267
+ viewport: {
268
+ width: number;
269
+ height: number;
270
+ aspect: number;
271
+ };
272
+ /** Named targets the camera can track. 'primary' is targets[0] by convention. */
273
+ targets: Record<string, TransformLike>;
274
+ }
275
+ /**
276
+ * A perspective produces the base camera pose each frame.
277
+ * Exactly one perspective is active per camera at a time.
278
+ */
279
+ interface CameraPerspective {
280
+ id: string;
281
+ /** Compute the raw desired pose for this frame given the current context. */
282
+ getBasePose(ctx: CameraContext): CameraPose;
283
+ /** Optional defaults for smoothing and other pipeline settings. */
284
+ defaults?: {
285
+ damping?: number;
286
+ };
287
+ }
288
+ /**
289
+ * Behaviors modify the desired pose each frame.
290
+ * They are keyed by name (idempotent add) and sorted by priority.
291
+ */
292
+ interface CameraBehavior {
293
+ /** Receive current context and pose, return a modified pose. */
294
+ update(ctx: CameraContext, pose: CameraPose): CameraPose;
295
+ /** Called when the behavior is attached to the pipeline. */
296
+ onAttach?(ctx: CameraContext): void;
297
+ /** Called when the behavior is removed from the pipeline. */
298
+ onDetach?(ctx: CameraContext): void;
299
+ /** Sort order: lower runs first. Default 0. */
300
+ priority?: number;
301
+ /** When false, the behavior is skipped during the pipeline run. */
302
+ enabled?: boolean;
303
+ }
304
+ /**
305
+ * Actions are transient effects that apply additive deltas (screenshake, recoil, etc.).
306
+ * They self-expire when isDone() returns true and are automatically removed.
307
+ */
308
+ interface CameraAction {
309
+ /** Return the additive delta for this frame. */
310
+ update(ctx: CameraContext): PoseDelta;
311
+ /** Return true when the action has completed and should be removed. */
312
+ isDone(ctx: CameraContext): boolean;
313
+ /** Sort order for action application. Default 0. */
314
+ priority?: number;
315
+ }
316
+ /**
317
+ * Debug snapshot returned by pipeline.getState().
318
+ */
319
+ interface CameraPipelineState {
320
+ perspectiveId: string | null;
321
+ desiredPose: CameraPose | null;
322
+ finalPose: CameraPose | null;
323
+ activeBehaviors: string[];
324
+ activeActionCount: number;
325
+ }
326
+
327
+ /**
328
+ * CameraPipeline runs a deterministic per-frame update:
329
+ *
330
+ * Perspective -> Behaviors (priority) -> Actions (deltas) -> Smoothing -> finalPose
331
+ *
332
+ * It separates "desired pose" from "final pose". Everything writes to desired;
333
+ * only smoothing converts desired into the final committed pose.
334
+ */
335
+ declare class CameraPipeline {
336
+ /** Active perspective (exactly one at a time). */
337
+ perspective: CameraPerspective | null;
338
+ /** Keyed behaviors, sorted by priority each frame. */
339
+ private behaviors;
340
+ /** Active transient actions. Expired actions are auto-removed. */
341
+ private actions;
342
+ /** The desired pose after perspective + behaviors + actions. */
343
+ private _desiredPose;
344
+ /** The smoothed final pose committed to the Three.js camera. */
345
+ private _finalPose;
346
+ /** Whether the pipeline has run at least once (prevents lerp from origin on first frame). */
347
+ private _initialized;
348
+ /** Smoothing factor: 0 = no movement, 1 = instant snap. */
349
+ damping: number;
350
+ constructor(perspective?: CameraPerspective);
351
+ /**
352
+ * Run the full pipeline for one frame.
353
+ * Returns the final pose that should be committed to the Three.js camera.
354
+ */
355
+ run(ctx: CameraContext): CameraPose;
356
+ /**
357
+ * Add or replace a behavior by key (idempotent).
358
+ * Calls onDetach on the old behavior and onAttach on the new one.
359
+ */
360
+ addBehavior(key: string, behavior: CameraBehavior, ctx?: CameraContext): void;
361
+ /**
362
+ * Remove a behavior by key. Calls onDetach if a context is provided.
363
+ */
364
+ removeBehavior(key: string, ctx?: CameraContext): boolean;
365
+ /**
366
+ * Check whether a behavior with the given key exists.
367
+ */
368
+ hasBehavior(key: string): boolean;
369
+ /**
370
+ * Add a transient action. Actions self-expire via isDone().
371
+ */
372
+ addAction(action: CameraAction): void;
373
+ /**
374
+ * Return a debug snapshot of the pipeline state.
375
+ */
376
+ getState(): CameraPipelineState;
377
+ /**
378
+ * Set a new perspective. Resets the pipeline initialization flag so the
379
+ * first frame with the new perspective snaps instead of lerping from the old pose.
380
+ */
381
+ setPerspective(perspective: CameraPerspective): void;
382
+ private getSortedBehaviors;
383
+ }
384
+
385
+ /**
386
+ * ZylemCamera is a lightweight camera wrapper that manages the Three.js camera,
387
+ * the camera pose pipeline, and viewport configuration. Rendering is handled
388
+ * by RendererManager.
389
+ *
390
+ * The pipeline runs: Perspective -> Behaviors -> Actions -> Smoothing -> Commit.
391
+ * When orbit/debug controls are active, the pipeline is bypassed.
392
+ */
393
+ declare class ZylemCamera {
394
+ /**
395
+ * @deprecated No longer used. Kept as null for backward compatibility
396
+ * with code that checks `camera.cameraRig` (e.g. scene graph insertion).
397
+ */
398
+ cameraRig: Object3D | null;
399
+ camera: Camera;
400
+ screenResolution: Vector2;
401
+ _perspective: PerspectiveType;
402
+ frustumSize: number;
403
+ sceneRef: Scene | null;
404
+ /** Name for camera manager lookup. */
405
+ name: string;
406
+ /**
407
+ * Viewport in normalized coordinates (0-1).
408
+ * Default is fullscreen: { x: 0, y: 0, width: 1, height: 1 }
409
+ */
410
+ viewport: Viewport;
411
+ /**
412
+ * Multiple targets for the camera to follow/frame.
413
+ */
414
+ targets: StageEntity[];
415
+ /**
416
+ * The camera pose pipeline.
417
+ * Exposed so CameraWrapper can delegate addBehavior/addAction/getState.
418
+ */
419
+ pipeline: CameraPipeline;
420
+ /**
421
+ * Offscreen render target for render-to-texture (RTT) cameras.
422
+ * When set, the camera renders to this target instead of the screen viewport.
423
+ * Created via createRenderTarget() or automatically by setCameraFeed().
424
+ *
425
+ * Uses the backend-agnostic {@link RenderTarget} so it works with the
426
+ * WebGPU renderer (and Three's internal WebGL2 fallback).
427
+ */
428
+ renderTarget: RenderTarget | null;
429
+ /**
430
+ * @deprecated Use `targets` array instead. Kept for backward compatibility.
431
+ */
432
+ get target(): StageEntity | null;
433
+ set target(entity: StageEntity | null);
434
+ private orbitController;
435
+ private _useOrbitalControls;
436
+ /** When true, debug-mode orbital controls are not attached to this camera. */
437
+ _skipDebugOrbit: boolean;
438
+ /** Reference to the shared renderer manager (set during setup). */
439
+ private _rendererManager;
440
+ /** Elapsed time tracker for CameraContext. */
441
+ private _elapsedTime;
442
+ constructor(perspective: PerspectiveType, screenResolution: Vector2, frustumSize?: number);
443
+ /**
444
+ * Setup the camera with a scene and renderer manager.
445
+ */
446
+ setup(scene: Scene, rendererManager?: RendererManager): Promise<void>;
447
+ /**
448
+ * Legacy setup method for backward compatibility.
449
+ * Creates a temporary RendererManager internally.
450
+ * @deprecated Use setup(scene, rendererManager) instead.
451
+ */
452
+ setupLegacy(scene: Scene): Promise<void>;
453
+ /**
454
+ * Update the camera each frame.
455
+ *
456
+ * When orbit/debug controls are active, the pipeline is skipped and
457
+ * orbit controls manage the camera directly. Otherwise, the pipeline
458
+ * runs: Perspective -> Behaviors -> Actions -> Smoothing -> Commit.
459
+ */
460
+ update(delta: number): void;
461
+ /**
462
+ * Check if debug mode is active (orbit controls taking over camera).
463
+ */
464
+ isDebugModeActive(): boolean;
465
+ /**
466
+ * True when debug orbit or user orbital controls are enabled (orbit controller is driving the camera).
467
+ */
468
+ get isOrbitActive(): boolean;
469
+ /**
470
+ * Advance OrbitControls (damping, pointer release) and follow the debug-selection orbit target.
471
+ * Intended to run once per render frame — see `CameraManager.render` and legacy `setupLegacy` render loop.
472
+ */
473
+ updateOrbitControls(): void;
474
+ /**
475
+ * Enable user-configured orbital controls (not debug mode).
476
+ */
477
+ enableOrbitalControls(): void;
478
+ /**
479
+ * Disable user-configured orbital controls.
480
+ */
481
+ disableOrbitalControls(): void;
482
+ /**
483
+ * Whether user orbital controls are enabled.
484
+ */
485
+ get useOrbitalControls(): boolean;
486
+ /**
487
+ * Add a target entity for the camera to follow/frame.
488
+ */
489
+ addTarget(entity: StageEntity): void;
490
+ /**
491
+ * Remove a target entity.
492
+ */
493
+ removeTarget(entity: StageEntity): void;
494
+ /**
495
+ * Clear all targets.
496
+ */
497
+ clearTargets(): void;
498
+ /**
499
+ * Set the viewport for this camera (normalized 0-1 coordinates).
500
+ */
501
+ setViewport(x: number, y: number, width: number, height: number): void;
502
+ /**
503
+ * Resize camera projection.
504
+ */
505
+ resize(width: number, height: number): void;
506
+ /**
507
+ * Create an offscreen render target for this camera.
508
+ * When a render target is present, CameraManager renders this camera
509
+ * to the target instead of the screen viewport.
510
+ *
511
+ * @param width Texture width in pixels (default 512)
512
+ * @param height Texture height in pixels (default 512)
513
+ */
514
+ createRenderTarget(width?: number, height?: number): RenderTarget;
515
+ /**
516
+ * Get the texture from the render target (for applying to a mesh material).
517
+ * Returns null if no render target has been created.
518
+ */
519
+ getRenderTexture(): Texture | null;
520
+ /**
521
+ * Dispose camera resources.
522
+ */
523
+ destroy(): void;
524
+ /**
525
+ * Attach a delegate to react to debug state changes.
526
+ * Skipped when _skipDebugOrbit is true so the pipeline always runs.
527
+ */
528
+ setDebugDelegate(delegate: CameraDebugDelegate | null): void;
529
+ /**
530
+ * Frame the debug orbit camera on an Object3D (AABB fit).
531
+ */
532
+ frameObject(object: Object3D): void;
533
+ /**
534
+ * Directly set the camera position.
535
+ */
536
+ move(position: Vector3): void;
537
+ /**
538
+ * Apply incremental rotation to the camera.
539
+ */
540
+ rotate(pitch: number, yaw: number, roll: number): void;
541
+ /**
542
+ * Get the DOM element for the renderer.
543
+ * @deprecated Access via RendererManager instead.
544
+ */
545
+ getDomElement(): HTMLCanvasElement;
546
+ /**
547
+ * Get the renderer manager reference.
548
+ */
549
+ getRendererManager(): RendererManager | null;
550
+ /**
551
+ * Set the renderer manager reference (used by CameraManager during setup).
552
+ */
553
+ setRendererManager(manager: RendererManager): void;
554
+ /** @deprecated Renderer is now owned by RendererManager */
555
+ get renderer(): any;
556
+ /** @deprecated Post-processing is now owned by RendererManager */
557
+ get composer(): any;
558
+ /** @deprecated Use RendererManager.setPixelRatio() instead */
559
+ setPixelRatio(dpr: number): void;
560
+ /**
561
+ * Build a CameraContext from current ZylemCamera state.
562
+ * Converts StageEntity[] targets into Record<string, TransformLike>.
563
+ */
564
+ private buildContext;
565
+ /**
566
+ * Apply the final pipeline pose to the Three.js camera.
567
+ */
568
+ private commitPose;
569
+ /**
570
+ * Create a Three.js camera based on perspective type.
571
+ */
572
+ private createCameraForPerspective;
573
+ }
574
+
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 };