@zylem/game-lib 0.6.4 → 0.7.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.
- package/README.md +3 -1
- package/dist/actions.d.ts +255 -8
- package/dist/actions.js +1 -936
- package/dist/audio.d.ts +13 -0
- package/dist/audio.js +1 -0
- package/dist/base-node-life-cycle-CnJ-7zX-.d.ts +143 -0
- package/dist/behavior.d.ts +3 -0
- package/dist/behavior.js +1 -0
- package/dist/chunk-4QLJUQSJ.js +1 -0
- package/dist/chunk-73VZQZUL.js +1 -0
- package/dist/chunk-A34ZG3L4.js +1 -0
- package/dist/chunk-CDPY4VOQ.js +1 -0
- package/dist/chunk-DR6XXZE7.js +19 -0
- package/dist/chunk-FM5TBEPO.js +1 -0
- package/dist/chunk-G2IIMSUH.js +1 -0
- package/dist/chunk-MSC2BEO5.js +1 -0
- package/dist/chunk-NIH5CONO.js +1 -0
- package/dist/chunk-ONWXGBWB.js +1 -0
- package/dist/chunk-QEDQDR27.js +1 -0
- package/dist/chunk-QXVH6POE.js +1 -0
- package/dist/chunk-RXDTAWI2.js +29 -0
- package/dist/chunk-WKHW2QO2.js +1 -0
- package/dist/chunk-XRP4JJXL.js +1 -0
- package/dist/chunk-YHEWKN7N.js +1 -0
- package/dist/chunk-YHKXQ2ZN.js +1 -0
- package/dist/core.d.ts +206 -14
- package/dist/core.js +24 -12424
- package/dist/debug.d.ts +24 -0
- package/dist/debug.js +1 -0
- package/dist/default-controls-BGc61yYl.d.ts +111 -0
- package/dist/{entity-vj-HTjzU.d.ts → entity-DNkYKfdp.d.ts} +452 -578
- package/dist/entity-type-map-C94h2TDW.d.ts +781 -0
- package/dist/entity.d.ts +265 -0
- package/dist/entity.js +1 -0
- package/dist/events.d.ts +172 -0
- package/dist/events.js +1 -0
- package/dist/game-Cuj5gy7U.d.ts +1590 -0
- package/dist/game-default-PZLLHYL7.js +1 -0
- package/dist/game-interfaces-tfpM5NBk.d.ts +90 -0
- package/dist/globals.d.ts +104 -0
- package/dist/globals.js +1 -0
- package/dist/graphics.d.ts +83 -0
- package/dist/graphics.js +1 -0
- package/dist/input-ui.d.ts +34 -0
- package/dist/input-ui.js +1 -0
- package/dist/input.d.ts +72 -0
- package/dist/input.js +1 -0
- package/dist/material-Wz83vTTp.d.ts +151 -0
- package/dist/runtime.d.ts +433 -0
- package/dist/runtime.js +1 -0
- package/dist/web-components.d.ts +67 -0
- package/dist/web-components.js +9 -0
- package/dist/world-C9zdyl5d.d.ts +103 -0
- package/dist/{camera-4XO5gbQH.d.ts → zylem-stage-runtime-Cs-UDEVU.d.ts} +201 -329
- package/package.json +52 -63
- package/dist/actions.js.map +0 -1
- package/dist/behavior/jumper-2d.d.ts +0 -114
- package/dist/behavior/jumper-2d.js +0 -711
- package/dist/behavior/jumper-2d.js.map +0 -1
- package/dist/behavior/platformer-3d.d.ts +0 -296
- package/dist/behavior/platformer-3d.js +0 -761
- package/dist/behavior/platformer-3d.js.map +0 -1
- package/dist/behavior/ricochet-2d.d.ts +0 -275
- package/dist/behavior/ricochet-2d.js +0 -425
- package/dist/behavior/ricochet-2d.js.map +0 -1
- package/dist/behavior/ricochet-3d.d.ts +0 -117
- package/dist/behavior/ricochet-3d.js +0 -443
- package/dist/behavior/ricochet-3d.js.map +0 -1
- package/dist/behavior/screen-visibility.d.ts +0 -79
- package/dist/behavior/screen-visibility.js +0 -358
- package/dist/behavior/screen-visibility.js.map +0 -1
- package/dist/behavior/screen-wrap.d.ts +0 -87
- package/dist/behavior/screen-wrap.js +0 -246
- package/dist/behavior/screen-wrap.js.map +0 -1
- package/dist/behavior/shooter-2d.d.ts +0 -79
- package/dist/behavior/shooter-2d.js +0 -180
- package/dist/behavior/shooter-2d.js.map +0 -1
- package/dist/behavior/thruster.d.ts +0 -11
- package/dist/behavior/thruster.js +0 -292
- package/dist/behavior/thruster.js.map +0 -1
- package/dist/behavior/top-down-movement.d.ts +0 -56
- package/dist/behavior/top-down-movement.js +0 -125
- package/dist/behavior/top-down-movement.js.map +0 -1
- package/dist/behavior/world-boundary-2d.d.ts +0 -142
- package/dist/behavior/world-boundary-2d.js +0 -235
- package/dist/behavior/world-boundary-2d.js.map +0 -1
- package/dist/behavior/world-boundary-3d.d.ts +0 -76
- package/dist/behavior/world-boundary-3d.js +0 -274
- package/dist/behavior/world-boundary-3d.js.map +0 -1
- package/dist/behavior-descriptor-BXnVR8Ki.d.ts +0 -159
- package/dist/blueprints-DmbK2dki.d.ts +0 -26
- package/dist/camera.d.ts +0 -6
- package/dist/camera.js +0 -1993
- package/dist/camera.js.map +0 -1
- package/dist/composition-BASvMKrW.d.ts +0 -218
- package/dist/core-CARRaS55.d.ts +0 -541
- package/dist/core.js.map +0 -1
- package/dist/entities-ChFirVL9.d.ts +0 -410
- package/dist/entities.d.ts +0 -9
- package/dist/entities.js +0 -4986
- package/dist/entities.js.map +0 -1
- package/dist/entity-Bq_eNEDI.d.ts +0 -28
- package/dist/entity-types-DAu8sGJH.d.ts +0 -26
- package/dist/global-change-2JvMaz44.d.ts +0 -25
- package/dist/main.d.ts +0 -1353
- package/dist/main.js +0 -19525
- package/dist/main.js.map +0 -1
- package/dist/physics-pose-DCc4oE44.d.ts +0 -25
- package/dist/physics-protocol-BDD3P5W2.d.ts +0 -200
- package/dist/physics-worker.d.ts +0 -21
- package/dist/physics-worker.js +0 -306
- package/dist/physics-worker.js.map +0 -1
- package/dist/physics.d.ts +0 -205
- package/dist/physics.js +0 -577
- package/dist/physics.js.map +0 -1
- package/dist/stage-types-C19IhuzA.d.ts +0 -731
- package/dist/stage.d.ts +0 -52
- package/dist/stage.js +0 -8479
- package/dist/stage.js.map +0 -1
- package/dist/sync-state-machine-CZyspBpj.d.ts +0 -16
- package/dist/thruster-23lzoPZd.d.ts +0 -180
- package/dist/world-DfgxoNMt.d.ts +0 -105
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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';
|
|
5
|
+
import { WebGPURenderer, RenderPipeline } from 'three/webgpu';
|
|
6
|
+
import { o as ZylemShader } from './material-Wz83vTTp.js';
|
|
5
7
|
|
|
6
8
|
declare const Perspectives: {
|
|
7
9
|
readonly FirstPerson: "first-person";
|
|
@@ -23,16 +25,19 @@ interface CameraDebugDelegate {
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
|
-
* Renderer type option
|
|
27
|
-
*
|
|
28
|
-
* -
|
|
29
|
-
*
|
|
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.
|
|
30
35
|
*/
|
|
31
36
|
type RendererType = 'auto' | 'webgpu' | 'webgl';
|
|
32
37
|
/**
|
|
33
|
-
*
|
|
38
|
+
* The renderer instance type. game-lib standardizes on {@link WebGPURenderer}.
|
|
34
39
|
*/
|
|
35
|
-
type ZylemRenderer =
|
|
40
|
+
type ZylemRenderer = WebGPURenderer;
|
|
36
41
|
/**
|
|
37
42
|
* Viewport definition in normalized coordinates (0-1).
|
|
38
43
|
* Represents a rectangular region of the canvas for camera rendering.
|
|
@@ -44,36 +49,63 @@ interface Viewport {
|
|
|
44
49
|
height: number;
|
|
45
50
|
}
|
|
46
51
|
/**
|
|
47
|
-
* Check if WebGPU is supported in the current browser
|
|
52
|
+
* Check if WebGPU is supported in the current browser.
|
|
53
|
+
*
|
|
54
|
+
* Informational only — game-lib always constructs a {@link WebGPURenderer},
|
|
55
|
+
* which transparently falls back to a WebGL2 backend when the WebGPU adapter
|
|
56
|
+
* is unavailable. Callers can use this to surface device capabilities.
|
|
48
57
|
*/
|
|
49
58
|
declare function isWebGPUSupported(): Promise<boolean>;
|
|
50
59
|
/**
|
|
51
|
-
* RendererManager owns the shared
|
|
52
|
-
*
|
|
60
|
+
* RendererManager owns the shared WebGPU renderer, canvas element, the
|
|
61
|
+
* optional post-processing pipeline, and the render loop. There is one
|
|
62
|
+
* RendererManager per game.
|
|
53
63
|
*
|
|
54
64
|
* It iterates active cameras and renders each with its configured viewport.
|
|
55
65
|
*/
|
|
56
66
|
declare class RendererManager {
|
|
57
67
|
renderer: ZylemRenderer;
|
|
58
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Optional TSL post-processing pipeline. Bound to a single fullscreen
|
|
70
|
+
* scene+camera via {@link setupPostProcessing}. When present and the
|
|
71
|
+
* frame is a single fullscreen viewport, the pipeline drives the final
|
|
72
|
+
* draw instead of `renderer.render(...)`.
|
|
73
|
+
*/
|
|
74
|
+
postProcessing: RenderPipeline | null;
|
|
75
|
+
/**
|
|
76
|
+
* Supersampling (SSAA) multiplier for the scene pass. `1` renders at native
|
|
77
|
+
* resolution (default). Values > 1 render the scene pass larger and let the
|
|
78
|
+
* post pipeline downsample it, trading GPU cost for smoother shading/edges
|
|
79
|
+
* (this is what the legacy WebGL pipeline did implicitly). Applied on the
|
|
80
|
+
* next {@link setupPostProcessing}.
|
|
81
|
+
*/
|
|
82
|
+
renderScale: number;
|
|
59
83
|
screenResolution: Vector2;
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated Always `'webgpu'`. Retained for backward compatibility.
|
|
86
|
+
*/
|
|
60
87
|
rendererType: RendererType;
|
|
61
|
-
private _isWebGPU;
|
|
62
88
|
private _initialized;
|
|
63
89
|
private _sceneRef;
|
|
64
90
|
private _lastAnimationTimestamp;
|
|
65
|
-
constructor(screenResolution?: Vector2,
|
|
91
|
+
constructor(screenResolution?: Vector2, _rendererType?: RendererType);
|
|
66
92
|
/**
|
|
67
93
|
* Check if the renderer has been initialized
|
|
68
94
|
*/
|
|
69
95
|
get initialized(): boolean;
|
|
70
96
|
/**
|
|
71
|
-
*
|
|
97
|
+
* Whether the active renderer is WebGPU. Always true; retained for
|
|
98
|
+
* backward compatibility with callers that branched on backend.
|
|
99
|
+
*
|
|
100
|
+
* @deprecated game-lib is WebGPU-only.
|
|
72
101
|
*/
|
|
73
102
|
get isWebGPU(): boolean;
|
|
74
103
|
/**
|
|
75
104
|
* Initialize the renderer (must be called before rendering).
|
|
76
105
|
* Async because WebGPU requires async initialization.
|
|
106
|
+
*
|
|
107
|
+
* The renderer keeps Three.js's built-in WebGL2 fallback backend, so it
|
|
108
|
+
* still initializes on devices without native WebGPU.
|
|
77
109
|
*/
|
|
78
110
|
initRenderer(): Promise<void>;
|
|
79
111
|
/**
|
|
@@ -81,9 +113,24 @@ declare class RendererManager {
|
|
|
81
113
|
*/
|
|
82
114
|
setScene(scene: Scene): void;
|
|
83
115
|
/**
|
|
84
|
-
*
|
|
116
|
+
* Set up the post-processing pipeline for a scene + camera.
|
|
117
|
+
*
|
|
118
|
+
* Builds a TSL `pass(scene, camera)` (HalfFloat + MSAA) and composes the
|
|
119
|
+
* final output ourselves so a display-space dither can be added: the dither
|
|
120
|
+
* breaks up 8-bit gradient banding (e.g. on terrain/sky) that the legacy
|
|
121
|
+
* WebGL pipeline hid via implicit supersampling. This is the WebGPU
|
|
122
|
+
* replacement for the old `EffectComposer` + `RenderPass`.
|
|
123
|
+
*/
|
|
124
|
+
setupPostProcessing(scene: Scene, camera: Camera): void;
|
|
125
|
+
/**
|
|
126
|
+
* Set the supersampling (SSAA) multiplier. Takes effect on the next
|
|
127
|
+
* {@link setupPostProcessing}. `1` = native resolution (default).
|
|
128
|
+
*/
|
|
129
|
+
setRenderScale(scale: number): void;
|
|
130
|
+
/**
|
|
131
|
+
* Dispose the current post-processing pipeline, if any.
|
|
85
132
|
*/
|
|
86
|
-
|
|
133
|
+
private disposePostProcessing;
|
|
87
134
|
/**
|
|
88
135
|
* Start the render loop. Calls the provided callback each frame.
|
|
89
136
|
*/
|
|
@@ -94,13 +141,17 @@ declare class RendererManager {
|
|
|
94
141
|
stopRenderLoop(): void;
|
|
95
142
|
/**
|
|
96
143
|
* Render a scene from a single camera's perspective.
|
|
97
|
-
* Sets the viewport based on the camera's viewport config
|
|
144
|
+
* Sets the viewport/scissor based on the camera's viewport config so
|
|
145
|
+
* split-screen / picture-in-picture layouts render to their region.
|
|
146
|
+
*
|
|
147
|
+
* @param usePostProcessing When true and a pipeline is configured, the
|
|
148
|
+
* post-processing pipeline drives the draw (fullscreen only).
|
|
98
149
|
*/
|
|
99
|
-
renderCamera(scene: Scene, camera: ZylemCamera): void;
|
|
150
|
+
renderCamera(scene: Scene, camera: ZylemCamera, usePostProcessing?: boolean): void;
|
|
100
151
|
/**
|
|
101
|
-
* Render a camera to its offscreen render target
|
|
102
|
-
* Bypasses
|
|
103
|
-
*
|
|
152
|
+
* Render a camera to its offscreen render target.
|
|
153
|
+
* Bypasses post-processing since render-to-texture output is consumed by
|
|
154
|
+
* an in-scene material (jumbotron / security-camera / portal effects).
|
|
104
155
|
*
|
|
105
156
|
* The camera must have a non-null renderTarget.
|
|
106
157
|
*/
|
|
@@ -108,11 +159,15 @@ declare class RendererManager {
|
|
|
108
159
|
/**
|
|
109
160
|
* Render a scene from multiple cameras, each with their own viewport.
|
|
110
161
|
* Cameras are rendered in order (first = bottom layer, last = top layer).
|
|
162
|
+
*
|
|
163
|
+
* Post-processing is applied only when there is a single fullscreen
|
|
164
|
+
* camera; split-screen layouts render directly per-viewport (a single
|
|
165
|
+
* fullscreen post pass cannot honor per-camera scissor regions).
|
|
111
166
|
*/
|
|
112
167
|
renderCameras(scene: Scene, cameras: ZylemCamera[]): void;
|
|
113
168
|
/**
|
|
114
169
|
* Simple single-camera render (backwards compatible).
|
|
115
|
-
* Uses
|
|
170
|
+
* Uses post-processing when configured.
|
|
116
171
|
*/
|
|
117
172
|
render(scene: Scene, camera: Camera): void;
|
|
118
173
|
/**
|
|
@@ -128,7 +183,7 @@ declare class RendererManager {
|
|
|
128
183
|
*/
|
|
129
184
|
getDomElement(): HTMLCanvasElement;
|
|
130
185
|
/**
|
|
131
|
-
* Dispose renderer,
|
|
186
|
+
* Dispose renderer, post-processing, and related resources.
|
|
132
187
|
*/
|
|
133
188
|
dispose(): void;
|
|
134
189
|
}
|
|
@@ -331,8 +386,11 @@ declare class ZylemCamera {
|
|
|
331
386
|
* Offscreen render target for render-to-texture (RTT) cameras.
|
|
332
387
|
* When set, the camera renders to this target instead of the screen viewport.
|
|
333
388
|
* Created via createRenderTarget() or automatically by setCameraFeed().
|
|
389
|
+
*
|
|
390
|
+
* Uses the backend-agnostic {@link RenderTarget} so it works with the
|
|
391
|
+
* WebGPU renderer (and Three's internal WebGL2 fallback).
|
|
334
392
|
*/
|
|
335
|
-
renderTarget:
|
|
393
|
+
renderTarget: RenderTarget | null;
|
|
336
394
|
/**
|
|
337
395
|
* @deprecated Use `targets` array instead. Kept for backward compatibility.
|
|
338
396
|
*/
|
|
@@ -369,6 +427,15 @@ declare class ZylemCamera {
|
|
|
369
427
|
* Check if debug mode is active (orbit controls taking over camera).
|
|
370
428
|
*/
|
|
371
429
|
isDebugModeActive(): boolean;
|
|
430
|
+
/**
|
|
431
|
+
* True when debug orbit or user orbital controls are enabled (orbit controller is driving the camera).
|
|
432
|
+
*/
|
|
433
|
+
get isOrbitActive(): boolean;
|
|
434
|
+
/**
|
|
435
|
+
* Advance OrbitControls (damping, pointer release) and follow the debug-selection orbit target.
|
|
436
|
+
* Intended to run once per render frame — see `CameraManager.render` and legacy `setupLegacy` render loop.
|
|
437
|
+
*/
|
|
438
|
+
updateOrbitControls(): void;
|
|
372
439
|
/**
|
|
373
440
|
* Enable user-configured orbital controls (not debug mode).
|
|
374
441
|
*/
|
|
@@ -409,7 +476,7 @@ declare class ZylemCamera {
|
|
|
409
476
|
* @param width Texture width in pixels (default 512)
|
|
410
477
|
* @param height Texture height in pixels (default 512)
|
|
411
478
|
*/
|
|
412
|
-
createRenderTarget(width?: number, height?: number):
|
|
479
|
+
createRenderTarget(width?: number, height?: number): RenderTarget;
|
|
413
480
|
/**
|
|
414
481
|
* Get the texture from the render target (for applying to a mesh material).
|
|
415
482
|
* Returns null if no render target has been created.
|
|
@@ -447,7 +514,7 @@ declare class ZylemCamera {
|
|
|
447
514
|
setRendererManager(manager: RendererManager): void;
|
|
448
515
|
/** @deprecated Renderer is now owned by RendererManager */
|
|
449
516
|
get renderer(): any;
|
|
450
|
-
/** @deprecated
|
|
517
|
+
/** @deprecated Post-processing is now owned by RendererManager */
|
|
451
518
|
get composer(): any;
|
|
452
519
|
/** @deprecated Use RendererManager.setPixelRatio() instead */
|
|
453
520
|
setPixelRatio(dpr: number): void;
|
|
@@ -555,6 +622,7 @@ declare class CameraManager {
|
|
|
555
622
|
* offscreen textures, then viewport cameras are rendered to the screen.
|
|
556
623
|
*/
|
|
557
624
|
render(scene: Scene): void;
|
|
625
|
+
private updateOrbitingCamerasForRender;
|
|
558
626
|
/**
|
|
559
627
|
* Create a default third-person camera if no cameras have been added.
|
|
560
628
|
*/
|
|
@@ -573,333 +641,137 @@ declare class CameraManager {
|
|
|
573
641
|
private resolveCamera;
|
|
574
642
|
}
|
|
575
643
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
/** Distance behind the target. Default 8. */
|
|
581
|
-
distance?: number;
|
|
582
|
-
/** Height above the target. Default 5. */
|
|
583
|
-
height?: number;
|
|
584
|
-
/** Lateral offset from the target (shoulder cam). Default 0. */
|
|
585
|
-
shoulderOffset?: number;
|
|
586
|
-
/** Key in CameraContext.targets to follow. Default 'primary'. */
|
|
587
|
-
targetKey?: string;
|
|
588
|
-
/** Perspective field of view. Default 75. */
|
|
589
|
-
fov?: number;
|
|
590
|
-
/** Padding multiplier when framing multiple targets. Default 1.5. */
|
|
591
|
-
paddingFactor?: number;
|
|
592
|
-
/** Minimum camera distance when multi-framing. Default 5. */
|
|
593
|
-
minDistance?: number;
|
|
594
|
-
/** Fallback camera position when no targets exist (e.g. the user-specified initial position). */
|
|
595
|
-
initialPosition?: Vector3;
|
|
596
|
-
/** Fallback lookAt point when no targets exist. */
|
|
597
|
-
initialLookAt?: Vector3;
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* Third-person 3D perspective.
|
|
601
|
-
*
|
|
602
|
-
* - 0 targets: returns a static pose behind the origin.
|
|
603
|
-
* - 1 target: camera positioned behind and above the target, looking at it.
|
|
604
|
-
* - 2+ targets: weighted-centroid framing with dynamic distance.
|
|
605
|
-
*/
|
|
606
|
-
declare class ThirdPersonPerspective implements CameraPerspective {
|
|
607
|
-
readonly id = "third-person";
|
|
608
|
-
readonly defaults: {
|
|
609
|
-
damping: number;
|
|
610
|
-
};
|
|
611
|
-
private opts;
|
|
612
|
-
private initialPosition?;
|
|
613
|
-
private initialLookAt?;
|
|
614
|
-
constructor(options?: ThirdPersonOptions);
|
|
615
|
-
getBasePose(ctx: CameraContext): CameraPose;
|
|
616
|
-
/**
|
|
617
|
-
* No targets: use the user-specified initial position if available,
|
|
618
|
-
* otherwise fall back to a default pose behind the origin.
|
|
619
|
-
*/
|
|
620
|
-
private staticPose;
|
|
621
|
-
/**
|
|
622
|
-
* Single target: position = target + offset, lookAt = target.
|
|
623
|
-
*/
|
|
624
|
-
private singleTargetPose;
|
|
644
|
+
interface SceneState {
|
|
645
|
+
backgroundColor: Color | string;
|
|
646
|
+
backgroundImage: string | null;
|
|
647
|
+
backgroundShader?: ZylemShader | null;
|
|
625
648
|
/**
|
|
626
|
-
*
|
|
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.
|
|
627
653
|
*/
|
|
628
|
-
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* Configuration for the fixed 2D perspective.
|
|
633
|
-
*/
|
|
634
|
-
interface Fixed2DOptions {
|
|
635
|
-
/** Fixed camera position. Default (0, 0, 10). */
|
|
636
|
-
position?: {
|
|
637
|
-
x: number;
|
|
638
|
-
y: number;
|
|
639
|
-
z: number;
|
|
640
|
-
};
|
|
641
|
-
/** Orthographic zoom (frustum size). Default 10. */
|
|
642
|
-
zoom?: number;
|
|
643
|
-
}
|
|
644
|
-
/**
|
|
645
|
-
* Fixed 2D perspective.
|
|
646
|
-
*
|
|
647
|
-
* Returns a static orthographic pose looking down the Z-axis.
|
|
648
|
-
* No target following -- the camera stays at the configured position.
|
|
649
|
-
*/
|
|
650
|
-
declare class Fixed2DPerspective implements CameraPerspective {
|
|
651
|
-
readonly id = "fixed-2d";
|
|
652
|
-
readonly defaults: {
|
|
653
|
-
damping: number;
|
|
654
|
-
};
|
|
655
|
-
private opts;
|
|
656
|
-
constructor(options?: Fixed2DOptions);
|
|
657
|
-
getBasePose(_ctx: CameraContext): CameraPose;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
/**
|
|
661
|
-
* Configuration for the first-person perspective.
|
|
662
|
-
*/
|
|
663
|
-
interface FirstPersonOptions {
|
|
664
|
-
/** Vertical offset above the target entity's position (eye height). @default 1.7 */
|
|
665
|
-
eyeHeight?: number;
|
|
666
|
-
/** Default field of view in degrees. @default 75 */
|
|
667
|
-
defaultFov?: number;
|
|
668
|
-
/** Maximum pitch angle in radians. @default Math.PI/2 - 0.01 */
|
|
669
|
-
pitchLimit?: number;
|
|
670
|
-
/** Lerp speed for smooth look-at transitions. @default 5 */
|
|
671
|
-
lookAtLerpSpeed?: number;
|
|
672
|
-
/** Lerp speed for FOV zoom transitions. @default 8 */
|
|
673
|
-
fovLerpSpeed?: number;
|
|
674
|
-
/** Key in CameraContext.targets to follow. @default 'primary' */
|
|
675
|
-
targetKey?: string;
|
|
676
|
-
/** Fallback position when no target entity is attached. */
|
|
677
|
-
initialPosition?: Vector3;
|
|
678
|
-
/** Fallback look-at point used to derive initial yaw/pitch when no target. */
|
|
679
|
-
initialLookAt?: Vector3;
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* First-person camera perspective.
|
|
683
|
-
*
|
|
684
|
-
* Position is derived from the attached target entity (+ eye height).
|
|
685
|
-
* Rotation is driven via `look()` / `setLook()` methods called by game code
|
|
686
|
-
* or a future FPS behavior. Supports smooth FOV zoom and lerp'd look-at.
|
|
687
|
-
*/
|
|
688
|
-
declare class FirstPersonPerspective implements CameraPerspective {
|
|
689
|
-
readonly id = "first-person";
|
|
690
|
-
readonly defaults: {
|
|
691
|
-
damping: number;
|
|
692
|
-
};
|
|
693
|
-
private opts;
|
|
694
|
-
/** Fallback position when no target entity is attached. Mutate directly for manual movement. */
|
|
695
|
-
initialPosition?: Vector3;
|
|
696
|
-
private initialLookAt?;
|
|
697
|
-
private _yaw;
|
|
698
|
-
private _pitch;
|
|
699
|
-
private _currentFov;
|
|
700
|
-
private _targetFov;
|
|
701
|
-
private _lookAtTarget;
|
|
702
|
-
private _lookAtLerpSpeed;
|
|
703
|
-
private _currentRotation;
|
|
704
|
-
private _rotationInitialized;
|
|
705
|
-
constructor(options?: FirstPersonOptions);
|
|
706
|
-
/** Accumulate yaw and pitch deltas. Pitch is clamped to the configured limit. */
|
|
707
|
-
look(deltaYaw: number, deltaPitch: number): void;
|
|
708
|
-
/** Set absolute yaw and pitch. Pitch is clamped to the configured limit. */
|
|
709
|
-
setLook(yaw: number, pitch: number): void;
|
|
710
|
-
/** Current yaw in radians. */
|
|
711
|
-
get yaw(): number;
|
|
712
|
-
/** Current pitch in radians. */
|
|
713
|
-
get pitch(): number;
|
|
714
|
-
/** Set the target FOV for a smooth zoom transition (e.g. sniper scope). */
|
|
715
|
-
zoom(fov: number): void;
|
|
716
|
-
/** Return to the default FOV. */
|
|
717
|
-
resetZoom(): void;
|
|
718
|
-
/** Current field of view. */
|
|
719
|
-
get currentFov(): number;
|
|
720
|
-
/**
|
|
721
|
-
* Enable smooth look-at toward a world position.
|
|
722
|
-
* The camera will slerp from the current rotation toward the look-at direction.
|
|
723
|
-
*/
|
|
724
|
-
lookAt(target: Vector3, lerpSpeed?: number): void;
|
|
725
|
-
/** Disable look-at and return to manual yaw/pitch control. */
|
|
726
|
-
clearLookAt(): void;
|
|
727
|
-
getBasePose(ctx: CameraContext): CameraPose;
|
|
728
|
-
private computePosition;
|
|
729
|
-
private computeRotation;
|
|
730
|
-
private lerpFov;
|
|
731
|
-
private deriveYawPitchFromLookAt;
|
|
732
|
-
private deriveYawPitchFromQuaternion;
|
|
654
|
+
defaultLighting?: boolean;
|
|
733
655
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
*/
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
};
|
|
753
|
-
target?: Vector3 | {
|
|
754
|
-
x: number;
|
|
755
|
-
y: number;
|
|
756
|
-
z: number;
|
|
757
|
-
} | any;
|
|
758
|
-
zoom?: number;
|
|
759
|
-
screenResolution?: Vector2;
|
|
760
|
-
/**
|
|
761
|
-
* Renderer type: 'auto' | 'webgpu' | 'webgl'
|
|
762
|
-
* Use 'webgpu' for TSL shaders
|
|
763
|
-
* @default 'webgl'
|
|
764
|
-
*/
|
|
765
|
-
rendererType?: RendererType;
|
|
766
|
-
/**
|
|
767
|
-
* Enable orbital controls for this camera.
|
|
768
|
-
* Can be toggled at runtime via enableOrbitalControls() / disableOrbitalControls().
|
|
769
|
-
* @default false
|
|
770
|
-
*/
|
|
771
|
-
useOrbitalControls?: boolean;
|
|
772
|
-
/**
|
|
773
|
-
* Viewport in normalized coordinates (0-1).
|
|
774
|
-
* Defines where this camera renders on the canvas.
|
|
775
|
-
* @default { x: 0, y: 0, width: 1, height: 1 } (fullscreen)
|
|
776
|
-
*/
|
|
777
|
-
viewport?: Viewport;
|
|
778
|
-
/**
|
|
779
|
-
* Optional name for camera manager lookup.
|
|
780
|
-
*/
|
|
781
|
-
name?: string;
|
|
782
|
-
/**
|
|
783
|
-
* Initial behaviors to attach to the camera pipeline.
|
|
784
|
-
* Keys are used for idempotent add/remove.
|
|
785
|
-
*/
|
|
786
|
-
behaviors?: Record<string, CameraBehavior>;
|
|
787
|
-
/**
|
|
788
|
-
* Pipeline smoothing factor (0-1).
|
|
789
|
-
* 1 = instant snap, 0 = no movement.
|
|
790
|
-
* @default 0.15
|
|
791
|
-
*/
|
|
792
|
-
damping?: number;
|
|
793
|
-
/**
|
|
794
|
-
* When set, the camera renders to an offscreen texture instead of a
|
|
795
|
-
* screen viewport. Use with setCameraFeed() to display the feed on
|
|
796
|
-
* an in-scene mesh (jumbotron, security monitor, portal, etc.).
|
|
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.
|
|
797
674
|
*
|
|
798
|
-
*
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
/** Texture width in pixels. @default 512 */
|
|
802
|
-
width?: number;
|
|
803
|
-
/** Texture height in pixels. @default 512 */
|
|
804
|
-
height?: number;
|
|
805
|
-
};
|
|
806
|
-
/**
|
|
807
|
-
* When true, this camera will not activate orbital controls in debug mode.
|
|
808
|
-
* The pipeline (and its behaviors) will always run for this camera.
|
|
809
|
-
* Use for cameras with custom behaviors (e.g. FPS mouse-look) that must
|
|
810
|
-
* control the camera through the pipeline rather than debug orbit controls.
|
|
811
|
-
* @default false
|
|
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).
|
|
812
678
|
*/
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
* CameraWrapper is the user-facing camera handle returned by createCamera().
|
|
817
|
-
* It provides convenience methods for target management, orbital controls,
|
|
818
|
-
* viewport configuration, and the camera pose pipeline.
|
|
819
|
-
*/
|
|
820
|
-
declare class CameraWrapper {
|
|
821
|
-
cameraRef: ZylemCamera;
|
|
822
|
-
constructor(camera: ZylemCamera);
|
|
823
|
-
/**
|
|
824
|
-
* Add a target entity for the camera to follow/frame.
|
|
825
|
-
* With multiple targets, the camera auto-frames to include all of them.
|
|
826
|
-
*/
|
|
827
|
-
addTarget(entity: StageEntity): void;
|
|
679
|
+
private setupBackgroundShader;
|
|
680
|
+
setup(): void;
|
|
681
|
+
destroy(): void;
|
|
828
682
|
/**
|
|
829
|
-
*
|
|
683
|
+
* Setup camera with the scene.
|
|
684
|
+
* Supports both legacy single camera and CameraManager modes.
|
|
830
685
|
*/
|
|
831
|
-
|
|
686
|
+
setupCamera(scene: Scene, camera: ZylemCamera, rendererManager?: RendererManager): Promise<void>;
|
|
832
687
|
/**
|
|
833
|
-
*
|
|
688
|
+
* Setup with a CameraManager (multi-camera support).
|
|
834
689
|
*/
|
|
835
|
-
|
|
690
|
+
setupCameraManager(scene: Scene, cameraManager: CameraManager, rendererManager: RendererManager): Promise<void>;
|
|
836
691
|
/**
|
|
837
|
-
*
|
|
838
|
-
* Allows the user to orbit, pan, and zoom the camera.
|
|
692
|
+
* Add a camera (rig or direct) to the scene graph.
|
|
839
693
|
*/
|
|
840
|
-
|
|
694
|
+
private addCameraToScene;
|
|
841
695
|
/**
|
|
842
|
-
*
|
|
696
|
+
* Setup scene lighting
|
|
843
697
|
*/
|
|
844
|
-
|
|
698
|
+
setupLighting(scene: Scene): void;
|
|
845
699
|
/**
|
|
846
|
-
*
|
|
847
|
-
* @param x Left edge (0 = left of canvas)
|
|
848
|
-
* @param y Bottom edge (0 = bottom of canvas)
|
|
849
|
-
* @param width Width as fraction of canvas
|
|
850
|
-
* @param height Height as fraction of canvas
|
|
700
|
+
* Update renderer size - delegates to camera manager or camera
|
|
851
701
|
*/
|
|
852
|
-
|
|
702
|
+
updateRenderer(width: number, height: number): void;
|
|
853
703
|
/**
|
|
854
|
-
* Add
|
|
855
|
-
* Behaviors modify the desired camera pose each frame.
|
|
856
|
-
*
|
|
857
|
-
* @param key Unique key for this behavior (used for replacement/removal).
|
|
858
|
-
* @param behavior The CameraBehavior implementation.
|
|
704
|
+
* Add object to scene
|
|
859
705
|
*/
|
|
860
|
-
|
|
706
|
+
add(object: Object3D, position?: Vector3): void;
|
|
861
707
|
/**
|
|
862
|
-
*
|
|
708
|
+
* Add game entity to scene
|
|
863
709
|
*/
|
|
864
|
-
|
|
710
|
+
addEntity(entity: GameEntity<any>): void;
|
|
865
711
|
/**
|
|
866
|
-
* Add
|
|
867
|
-
*
|
|
868
|
-
*/
|
|
869
|
-
addAction(action: CameraAction): void;
|
|
870
|
-
/**
|
|
871
|
-
* Switch the camera's active perspective at runtime.
|
|
872
|
-
* The first frame after switching snaps to the new pose (no lerp).
|
|
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.
|
|
873
714
|
*
|
|
874
|
-
* @
|
|
875
|
-
*
|
|
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.
|
|
876
719
|
*/
|
|
877
|
-
|
|
720
|
+
addEntityGroup(entity: GameEntity<any>): void;
|
|
721
|
+
private isAttachedOutsideScene;
|
|
878
722
|
/**
|
|
879
|
-
*
|
|
880
|
-
* Useful for calling perspective-specific methods (e.g. FirstPersonPerspective.look()).
|
|
881
|
-
*
|
|
882
|
-
* @example
|
|
883
|
-
* const fps = camera.getPerspective<FirstPersonPerspective>();
|
|
884
|
-
* fps.look(dx, dy);
|
|
723
|
+
* Add debug helpers to scene
|
|
885
724
|
*/
|
|
886
|
-
|
|
725
|
+
debugScene(): void;
|
|
887
726
|
/**
|
|
888
|
-
*
|
|
889
|
-
*
|
|
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.
|
|
890
731
|
*/
|
|
891
|
-
|
|
892
|
-
/**
|
|
893
|
-
* Get the offscreen render texture for this camera.
|
|
894
|
-
* Returns null if the camera was not created with renderToTexture.
|
|
895
|
-
* Use with setCameraFeed() or apply directly to a mesh material.
|
|
896
|
-
*/
|
|
897
|
-
getRenderTexture(): Texture | null;
|
|
732
|
+
updateSkybox(_delta: number): void;
|
|
898
733
|
}
|
|
734
|
+
|
|
899
735
|
/**
|
|
900
|
-
*
|
|
901
|
-
* Returns a CameraWrapper for convenient access to camera features.
|
|
736
|
+
* Host-provided debug signals for wasm runtime adapters (no direct `debugState` import in adapters).
|
|
902
737
|
*/
|
|
903
|
-
|
|
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;
|
|
904
776
|
|
|
905
|
-
export {
|
|
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 };
|