@zylem/game-lib 0.6.0 → 0.6.2
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/dist/behaviors.d.ts +834 -86
- package/dist/behaviors.js +1166 -355
- package/dist/behaviors.js.map +1 -1
- package/dist/{blueprints-BOCc3Wve.d.ts → blueprints-Cq3Ko6_G.d.ts} +2 -2
- package/dist/{camera-CpbDr4-V.d.ts → camera-CeJPAgGg.d.ts} +2 -2
- package/dist/camera.d.ts +1 -1
- package/dist/camera.js +126 -19
- package/dist/camera.js.map +1 -1
- package/dist/{core-CZhozNRH.d.ts → core-bO8TzV7u.d.ts} +40 -6
- package/dist/core.d.ts +8 -6
- package/dist/core.js +6554 -5033
- package/dist/core.js.map +1 -1
- package/dist/{entities-BAxfJOkk.d.ts → entities-DvByhMGU.d.ts} +43 -44
- package/dist/entities.d.ts +4 -3
- package/dist/entities.js +3236 -2013
- package/dist/entities.js.map +1 -1
- package/dist/entity-types-DAu8sGJH.d.ts +26 -0
- package/dist/main.d.ts +71 -31
- package/dist/main.js +9197 -6313
- package/dist/main.js.map +1 -1
- package/dist/{stage-types-CD21XoIU.d.ts → stage-types-Bd-KtcYT.d.ts} +65 -28
- package/dist/stage.d.ts +9 -7
- package/dist/stage.js +3993 -2453
- package/dist/stage.js.map +1 -1
- package/dist/world-C8tQ7Plj.d.ts +774 -0
- package/package.json +11 -10
- package/LICENSE +0 -21
- package/dist/entity-COvRtFNG.d.ts +0 -395
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as SetupFunction, Z as ZylemShaderObject, G as GameEntity, U as UpdateFunction, D as DestroyFunction, a as SetupContext, b as UpdateContext, c as DestroyContext, d as ZylemWorld, B as BaseNode, L as LoadingEvent, e as BehaviorSystem, f as BehaviorSystemFactory, g as GameEntityOptions, h as StageEvents } from './world-C8tQ7Plj.js';
|
|
2
2
|
import * as bitecs from 'bitecs';
|
|
3
3
|
import { defineSystem, IWorld } from 'bitecs';
|
|
4
|
-
import { Scene, Color, Object3D, Vector3
|
|
5
|
-
import { f as ZylemWorld, S as SPRITE_TYPE, g as ZylemSprite, d as SPHERE_TYPE, h as ZylemSphere, R as RECT_TYPE, i as ZylemRect, T as TEXT_TYPE, j as ZylemText, B as BOX_TYPE, Z as ZylemBox, P as PLANE_TYPE, k as ZylemPlane, e as ZONE_TYPE, l as ZylemZone, A as ACTOR_TYPE, m as ZylemActor } from './entities-BAxfJOkk.js';
|
|
4
|
+
import { Scene, Color, Object3D, Vector3 } from 'three';
|
|
6
5
|
import { E as Entity, L as LifecycleFunction, S as StageEntity } from './entity-Bq_eNEDI.js';
|
|
7
|
-
import { Z as ZylemCamera, C as CameraDebugDelegate,
|
|
8
|
-
import
|
|
6
|
+
import { Z as ZylemCamera, C as CameraDebugDelegate, a as CameraDebugState, b as CameraWrapper } from './camera-CeJPAgGg.js';
|
|
7
|
+
import { G as GameEntityInterface, B as BaseEntityInterface } from './entity-types-DAu8sGJH.js';
|
|
8
|
+
import RAPIER__default from '@dimforge/rapier3d-compat';
|
|
9
|
+
import { S as SPRITE_TYPE, Z as ZylemSprite, a as SPHERE_TYPE, b as ZylemSphere, R as RECT_TYPE, c as ZylemRect, T as TEXT_TYPE, d as ZylemText, B as BOX_TYPE, e as ZylemBox, P as PLANE_TYPE, f as ZylemPlane, g as ZONE_TYPE, h as ZylemZone, A as ACTOR_TYPE, i as ZylemActor } from './entities-DvByhMGU.js';
|
|
9
10
|
|
|
10
11
|
interface SceneState {
|
|
11
12
|
backgroundColor: Color | string;
|
|
12
13
|
backgroundImage: string | null;
|
|
14
|
+
backgroundShader?: ZylemShaderObject | null;
|
|
13
15
|
}
|
|
14
16
|
declare class ZylemScene implements Entity<ZylemScene> {
|
|
15
17
|
type: string;
|
|
@@ -22,7 +24,13 @@ declare class ZylemScene implements Entity<ZylemScene> {
|
|
|
22
24
|
_destroy?: ((globals?: any) => void) | undefined;
|
|
23
25
|
name?: string | undefined;
|
|
24
26
|
tag?: Set<string> | undefined;
|
|
27
|
+
private skyboxMaterial;
|
|
25
28
|
constructor(id: string, camera: ZylemCamera, state: SceneState);
|
|
29
|
+
/**
|
|
30
|
+
* Create a large inverted box with the shader for skybox effect
|
|
31
|
+
* Uses the pos.xyww trick to ensure skybox is always at maximum depth
|
|
32
|
+
*/
|
|
33
|
+
private setupBackgroundShader;
|
|
26
34
|
setup(): void;
|
|
27
35
|
destroy(): void;
|
|
28
36
|
/**
|
|
@@ -45,32 +53,19 @@ declare class ZylemScene implements Entity<ZylemScene> {
|
|
|
45
53
|
* Add game entity to scene
|
|
46
54
|
*/
|
|
47
55
|
addEntity(entity: GameEntity<any>): void;
|
|
56
|
+
/**
|
|
57
|
+
* Add an entity's group or mesh to the scene (for late-loaded models).
|
|
58
|
+
* Uses entity's current body position if physics is active.
|
|
59
|
+
*/
|
|
60
|
+
addEntityGroup(entity: GameEntity<any>): void;
|
|
48
61
|
/**
|
|
49
62
|
* Add debug helpers to scene
|
|
50
63
|
*/
|
|
51
64
|
debugScene(): void;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*/
|
|
57
|
-
interface BaseEntityInterface {
|
|
58
|
-
uuid: string;
|
|
59
|
-
name: string;
|
|
60
|
-
eid: number;
|
|
61
|
-
group: Group | null;
|
|
62
|
-
body: RigidBody | null;
|
|
63
|
-
collider: Collider | null;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Game entity interface - minimal interface to break circular dependencies
|
|
67
|
-
*/
|
|
68
|
-
interface GameEntityInterface extends BaseEntityInterface {
|
|
69
|
-
type: string;
|
|
70
|
-
isStatic: boolean;
|
|
71
|
-
setPosition(x: number, y: number, z: number): void;
|
|
72
|
-
setRotation(x: number, y: number, z: number): void;
|
|
73
|
-
setScale(x: number, y: number, z: number): void;
|
|
65
|
+
/**
|
|
66
|
+
* Update skybox shader uniforms
|
|
67
|
+
*/
|
|
68
|
+
updateSkybox(delta: number): void;
|
|
74
69
|
}
|
|
75
70
|
|
|
76
71
|
/**
|
|
@@ -118,6 +113,8 @@ declare class StageDebugDelegate {
|
|
|
118
113
|
private debugCursor;
|
|
119
114
|
private debugLines;
|
|
120
115
|
constructor(stage: ZylemStage, options?: StageDebugDelegateOptions);
|
|
116
|
+
private initDebugVisuals;
|
|
117
|
+
private disposeDebugVisuals;
|
|
121
118
|
update(): void;
|
|
122
119
|
dispose(): void;
|
|
123
120
|
private handleActionOnHit;
|
|
@@ -139,6 +136,7 @@ interface ZylemStageConfig {
|
|
|
139
136
|
inputs: Record<string, string[]>;
|
|
140
137
|
backgroundColor: Color | string;
|
|
141
138
|
backgroundImage: string | null;
|
|
139
|
+
backgroundShader: any | null;
|
|
142
140
|
gravity: Vector3;
|
|
143
141
|
variables: Record<string, any>;
|
|
144
142
|
stageRef?: Stage;
|
|
@@ -178,6 +176,8 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
178
176
|
ecs: bitecs.IWorld;
|
|
179
177
|
testSystem: any;
|
|
180
178
|
transformSystem: ReturnType<typeof createTransformSystem> | null;
|
|
179
|
+
private behaviorSystems;
|
|
180
|
+
private registeredSystemKeys;
|
|
181
181
|
debugDelegate: StageDebugDelegate | null;
|
|
182
182
|
cameraDebugDelegate: StageCameraDebugDelegate | null;
|
|
183
183
|
private debugStateUnsubscribe;
|
|
@@ -187,6 +187,7 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
187
187
|
cameraRef?: ZylemCamera | null;
|
|
188
188
|
private cameraDelegate;
|
|
189
189
|
private loadingDelegate;
|
|
190
|
+
private entityModelDelegate;
|
|
190
191
|
/**
|
|
191
192
|
* Create a new stage.
|
|
192
193
|
* @param options Stage options: partial config, camera, and initial entities or factories
|
|
@@ -238,6 +239,12 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
238
239
|
replayExisting?: boolean;
|
|
239
240
|
}): () => void;
|
|
240
241
|
onLoading(callback: (event: LoadingEvent) => void): () => void;
|
|
242
|
+
/**
|
|
243
|
+
* Register an ECS behavior system to run each frame.
|
|
244
|
+
* @param systemOrFactory A BehaviorSystem instance or factory function
|
|
245
|
+
* @returns this for chaining
|
|
246
|
+
*/
|
|
247
|
+
registerSystem(systemOrFactory: BehaviorSystem | BehaviorSystemFactory): this;
|
|
241
248
|
/**
|
|
242
249
|
* Remove an entity and its resources by its UUID.
|
|
243
250
|
* @returns true if removed, false if not found or stage not ready
|
|
@@ -257,6 +264,20 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
257
264
|
enqueue(...items: StageEntityInput[]): void;
|
|
258
265
|
}
|
|
259
266
|
|
|
267
|
+
type ZylemDiskOptions = GameEntityOptions & {
|
|
268
|
+
innerRadius?: number;
|
|
269
|
+
outerRadius?: number;
|
|
270
|
+
thetaSegments?: number;
|
|
271
|
+
};
|
|
272
|
+
declare const DISK_TYPE: unique symbol;
|
|
273
|
+
declare class ZylemDisk extends GameEntity<ZylemDiskOptions> {
|
|
274
|
+
static type: symbol;
|
|
275
|
+
constructor(options?: ZylemDiskOptions);
|
|
276
|
+
buildInfo(): Record<string, any>;
|
|
277
|
+
}
|
|
278
|
+
type DiskOptions = BaseNode | Partial<ZylemDiskOptions>;
|
|
279
|
+
declare function createDisk(...args: Array<DiskOptions>): ZylemDisk;
|
|
280
|
+
|
|
260
281
|
/**
|
|
261
282
|
* Maps entity type symbols to their class types.
|
|
262
283
|
* Used by getEntityByName to infer return types.
|
|
@@ -270,6 +291,7 @@ interface EntityTypeMap {
|
|
|
270
291
|
[PLANE_TYPE]: ZylemPlane;
|
|
271
292
|
[ZONE_TYPE]: ZylemZone;
|
|
272
293
|
[ACTOR_TYPE]: ZylemActor;
|
|
294
|
+
[DISK_TYPE]: ZylemDisk;
|
|
273
295
|
}
|
|
274
296
|
|
|
275
297
|
type NodeLike = {
|
|
@@ -285,6 +307,7 @@ declare class Stage {
|
|
|
285
307
|
private updateCallbacks;
|
|
286
308
|
private destroyCallbacks;
|
|
287
309
|
private pendingLoadingCallbacks;
|
|
310
|
+
private eventDelegate;
|
|
288
311
|
constructor(options: StageOptions);
|
|
289
312
|
load(id: string, camera?: ZylemCamera | CameraWrapper | null): Promise<void>;
|
|
290
313
|
private applyLifecycleCallbacks;
|
|
@@ -305,6 +328,20 @@ declare class Stage {
|
|
|
305
328
|
* @example stage.getEntityByName('scoreText', TEXT_TYPE)
|
|
306
329
|
*/
|
|
307
330
|
getEntityByName<T extends symbol | void = void>(name: string, type?: T): T extends keyof EntityTypeMap ? EntityTypeMap[T] | undefined : BaseNode | undefined;
|
|
331
|
+
/**
|
|
332
|
+
* Dispatch an event from the stage.
|
|
333
|
+
* Events are emitted both locally and to the global event bus.
|
|
334
|
+
*/
|
|
335
|
+
dispatch<K extends keyof StageEvents>(event: K, payload: StageEvents[K]): void;
|
|
336
|
+
/**
|
|
337
|
+
* Listen for events on this stage instance.
|
|
338
|
+
* @returns Unsubscribe function
|
|
339
|
+
*/
|
|
340
|
+
listen<K extends keyof StageEvents>(event: K, handler: (payload: StageEvents[K]) => void): () => void;
|
|
341
|
+
/**
|
|
342
|
+
* Clean up stage resources including event subscriptions.
|
|
343
|
+
*/
|
|
344
|
+
dispose(): void;
|
|
308
345
|
}
|
|
309
346
|
/**
|
|
310
347
|
* Create a stage with optional camera
|
|
@@ -335,4 +372,4 @@ interface StageInterface {
|
|
|
335
372
|
state: StageStateInterface;
|
|
336
373
|
}
|
|
337
374
|
|
|
338
|
-
export { type StageStateInterface as S, type StageOptions as a, Stage as b, createStage as c, type StageInterface as
|
|
375
|
+
export { type StageStateInterface as S, type StageOptions as a, Stage as b, createStage as c, createDisk as d, type StageInterface as e };
|
package/dist/stage.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { S as StageStateInterface } from './stage-types-
|
|
2
|
-
export { a as StageOptions, c as createStage } from './stage-types-
|
|
3
|
-
export { S as StageBlueprint, e as entitySpawner } from './blueprints-
|
|
4
|
-
import './
|
|
1
|
+
import { S as StageStateInterface } from './stage-types-Bd-KtcYT.js';
|
|
2
|
+
export { a as StageOptions, c as createStage } from './stage-types-Bd-KtcYT.js';
|
|
3
|
+
export { S as StageBlueprint, e as entitySpawner } from './blueprints-Cq3Ko6_G.js';
|
|
4
|
+
import './world-C8tQ7Plj.js';
|
|
5
5
|
import 'three';
|
|
6
6
|
import '@dimforge/rapier3d-compat';
|
|
7
|
-
import 'bitecs';
|
|
8
|
-
import './entities-BAxfJOkk.js';
|
|
9
7
|
import './entity-Bq_eNEDI.js';
|
|
10
|
-
import '
|
|
8
|
+
import 'bitecs';
|
|
9
|
+
import 'mitt';
|
|
10
|
+
import './camera-CeJPAgGg.js';
|
|
11
11
|
import 'three/examples/jsm/postprocessing/EffectComposer.js';
|
|
12
|
+
import './entity-types-DAu8sGJH.js';
|
|
13
|
+
import './entities-DvByhMGU.js';
|
|
12
14
|
import '@sinclair/typebox';
|
|
13
15
|
|
|
14
16
|
/**
|