@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.
@@ -1,32 +1,5 @@
1
- import { G as GameEntity, U as UpdateContext, l as GameEntityOptions, d as DestroyContext, e as BaseNode, T as TexturePath, V as Vec3, M as MaterialOptions } from './entity-COvRtFNG.js';
1
+ import { G as GameEntity, g as GameEntityOptions, b as UpdateContext, c as DestroyContext, B as BaseNode, T as TexturePath, A as CollisionHandlerDelegate, V as Vec3, M as MaterialOptions } from './world-C8tQ7Plj.js';
2
2
  import { Vector3, Sprite, Color, Vector2, Object3D } from 'three';
3
- import RAPIER__default, { World } from '@dimforge/rapier3d-compat';
4
- import { E as Entity } from './entity-Bq_eNEDI.js';
5
-
6
- /**
7
- * Interface for entities that handle collision events.
8
- */
9
- interface CollisionHandlerDelegate {
10
- handlePostCollision(params: any): boolean;
11
- handleIntersectionEvent(params: any): void;
12
- }
13
- declare class ZylemWorld implements Entity<ZylemWorld> {
14
- type: string;
15
- world: World;
16
- collisionMap: Map<string, GameEntity<any>>;
17
- collisionBehaviorMap: Map<string, GameEntity<any>>;
18
- _removalMap: Map<string, GameEntity<any>>;
19
- static loadPhysics(gravity: Vector3): Promise<RAPIER__default.World>;
20
- constructor(world: World);
21
- addEntity(entity: any): void;
22
- setForRemoval(entity: any): void;
23
- destroyEntity(entity: GameEntity<any>): void;
24
- setup(): void;
25
- update(params: UpdateContext<any>): void;
26
- updatePostCollisionBehaviors(delta: number): void;
27
- updateColliders(delta: number): void;
28
- destroy(): void;
29
- }
30
3
 
31
4
  type SpriteImage = {
32
5
  name: string;
@@ -61,12 +34,12 @@ declare class ZylemSprite extends GameEntity<ZylemSpriteOptions> {
61
34
  protected createAnimations(animations: SpriteAnimation[]): void;
62
35
  setSprite(key: string): void;
63
36
  setAnimation(name: string, delta: number): void;
64
- spriteUpdate(params: UpdateContext<ZylemSpriteOptions>): Promise<void>;
65
- spriteDestroy(params: DestroyContext<ZylemSpriteOptions>): Promise<void>;
37
+ spriteUpdate(params: UpdateContext<ZylemSpriteOptions>): void;
38
+ spriteDestroy(params: DestroyContext<ZylemSpriteOptions>): void;
66
39
  buildInfo(): Record<string, any>;
67
40
  }
68
41
  type SpriteOptions = BaseNode | Partial<ZylemSpriteOptions>;
69
- declare function sprite(...args: Array<SpriteOptions>): Promise<ZylemSprite>;
42
+ declare function createSprite(...args: Array<SpriteOptions>): ZylemSprite;
70
43
 
71
44
  type ZylemSphereOptions = GameEntityOptions & {
72
45
  radius?: number;
@@ -78,7 +51,7 @@ declare class ZylemSphere extends GameEntity<ZylemSphereOptions> {
78
51
  buildInfo(): Record<string, any>;
79
52
  }
80
53
  type SphereOptions = BaseNode | Partial<ZylemSphereOptions>;
81
- declare function sphere(...args: Array<SphereOptions>): Promise<ZylemSphere>;
54
+ declare function createSphere(...args: Array<SphereOptions>): ZylemSphere;
82
55
 
83
56
  type ZylemRectOptions = GameEntityOptions & {
84
57
  width?: number;
@@ -122,6 +95,8 @@ declare class ZylemRect extends GameEntity<ZylemRectOptions> {
122
95
  constructor(options?: ZylemRectOptions);
123
96
  private createSprite;
124
97
  private redrawRect;
98
+ getWidth(): number;
99
+ getHeight(): number;
125
100
  private roundedRectPath;
126
101
  private toCssColor;
127
102
  private rectSetup;
@@ -133,7 +108,7 @@ declare class ZylemRect extends GameEntity<ZylemRectOptions> {
133
108
  buildInfo(): Record<string, any>;
134
109
  }
135
110
  type RectOptions = BaseNode | Partial<ZylemRectOptions>;
136
- declare function rect(...args: Array<RectOptions>): Promise<ZylemRect>;
111
+ declare function createRect(...args: Array<RectOptions>): ZylemRect;
137
112
 
138
113
  type ZylemTextOptions = GameEntityOptions & {
139
114
  text?: string;
@@ -179,7 +154,7 @@ declare class ZylemText extends GameEntity<ZylemTextOptions> {
179
154
  private textDestroy;
180
155
  }
181
156
  type TextOptions = BaseNode | Partial<ZylemTextOptions>;
182
- declare function text(...args: Array<TextOptions>): Promise<ZylemText>;
157
+ declare function createText(...args: Array<TextOptions>): ZylemText;
183
158
 
184
159
  type ZylemBoxOptions = GameEntityOptions;
185
160
  declare const BOX_TYPE: unique symbol;
@@ -189,13 +164,16 @@ declare class ZylemBox extends GameEntity<ZylemBoxOptions> {
189
164
  buildInfo(): Record<string, any>;
190
165
  }
191
166
  type BoxOptions = BaseNode | ZylemBoxOptions;
192
- declare function box(...args: Array<BoxOptions>): Promise<ZylemBox>;
167
+ declare function createBox(...args: Array<BoxOptions>): ZylemBox;
193
168
 
194
169
  type ZylemPlaneOptions = GameEntityOptions & {
195
170
  tile?: Vector2;
196
171
  repeat?: Vector2;
197
172
  texture?: TexturePath;
198
173
  subdivisions?: number;
174
+ randomizeHeight?: boolean;
175
+ heightMap?: number[];
176
+ heightScale?: number;
199
177
  };
200
178
  declare const PLANE_TYPE: unique symbol;
201
179
  declare class ZylemPlane extends GameEntity<ZylemPlaneOptions> {
@@ -203,7 +181,7 @@ declare class ZylemPlane extends GameEntity<ZylemPlaneOptions> {
203
181
  constructor(options?: ZylemPlaneOptions);
204
182
  }
205
183
  type PlaneOptions = BaseNode | Partial<ZylemPlaneOptions>;
206
- declare function plane(...args: Array<PlaneOptions>): Promise<ZylemPlane>;
184
+ declare function createPlane(...args: Array<PlaneOptions>): ZylemPlane;
207
185
 
208
186
  type OnHeldParams = {
209
187
  delta: number;
@@ -243,10 +221,12 @@ declare class ZylemZone extends GameEntity<ZylemZoneOptions> implements Collisio
243
221
  held(delta: number, other: any): void;
244
222
  }
245
223
  type ZoneOptions = BaseNode | Partial<ZylemZoneOptions>;
246
- declare function zone(...args: Array<ZoneOptions>): Promise<ZylemZone>;
224
+ declare function createZone(...args: Array<ZoneOptions>): ZylemZone;
247
225
 
248
226
  interface EntityLoaderDelegate {
249
- load(): Promise<void>;
227
+ /** Initiates loading (may be async internally, but call returns immediately) */
228
+ load(): void;
229
+ /** Returns data synchronously (may be null if still loading) */
250
230
  data(): any;
251
231
  }
252
232
 
@@ -269,12 +249,14 @@ type AnimationObject = {
269
249
  key?: string;
270
250
  path: string;
271
251
  };
252
+ type CollisionShapeType = 'capsule' | 'model';
272
253
  type ZylemActorOptions = GameEntityOptions & {
273
254
  static?: boolean;
274
255
  animations?: AnimationObject[];
275
256
  models?: string[];
276
257
  scale?: Vec3;
277
258
  material?: MaterialOptions;
259
+ collisionShape?: CollisionShapeType;
278
260
  };
279
261
  declare const ACTOR_TYPE: unique symbol;
280
262
  declare class ZylemActor extends GameEntity<ZylemActorOptions> implements EntityLoaderDelegate, DebugInfoProvider {
@@ -285,15 +267,32 @@ declare class ZylemActor extends GameEntity<ZylemActorOptions> implements Entity
285
267
  private _assetLoader;
286
268
  controlledRotation: boolean;
287
269
  constructor(options?: ZylemActorOptions);
288
- load(): Promise<void>;
289
- data(): Promise<any>;
290
- actorUpdate(params: UpdateContext<ZylemActorOptions>): Promise<void>;
270
+ /**
271
+ * Initiates model and animation loading in background (deferred).
272
+ * Call returns immediately; assets will be ready on subsequent updates.
273
+ */
274
+ load(): void;
275
+ /**
276
+ * Returns current data synchronously.
277
+ * May return null values if loading is still in progress.
278
+ */
279
+ data(): any;
280
+ actorUpdate(params: UpdateContext<ZylemActorOptions>): void;
291
281
  /**
292
282
  * Clean up actor resources including animations, models, and groups
293
283
  */
294
284
  actorDestroy(): void;
295
- private loadModels;
285
+ /**
286
+ * Deferred loading - starts async load and updates entity when complete.
287
+ * Called by synchronous load() method.
288
+ */
289
+ private loadModelsDeferred;
296
290
  playAnimation(animationOptions: AnimationOptions): void;
291
+ /**
292
+ * Apply material overrides from options to all meshes in the loaded model.
293
+ * Only applies if material options are explicitly specified (not just defaults).
294
+ */
295
+ private applyMaterialOverrides;
297
296
  get object(): Object3D | null;
298
297
  /**
299
298
  * Provide custom debug information for the actor
@@ -302,6 +301,6 @@ declare class ZylemActor extends GameEntity<ZylemActorOptions> implements Entity
302
301
  getDebugInfo(): Record<string, any>;
303
302
  }
304
303
  type ActorOptions = BaseNode | ZylemActorOptions;
305
- declare function actor(...args: Array<ActorOptions>): Promise<ZylemActor>;
304
+ declare function createActor(...args: Array<ActorOptions>): ZylemActor;
306
305
 
307
- export { ACTOR_TYPE as A, BOX_TYPE as B, PLANE_TYPE as P, RECT_TYPE as R, SPRITE_TYPE as S, TEXT_TYPE as T, ZylemBox as Z, sprite as a, box as b, actor as c, SPHERE_TYPE as d, ZONE_TYPE as e, ZylemWorld as f, ZylemSprite as g, ZylemSphere as h, ZylemRect as i, ZylemText as j, ZylemPlane as k, ZylemZone as l, ZylemActor as m, plane as p, rect as r, sphere as s, text as t, zone as z };
306
+ export { ACTOR_TYPE as A, BOX_TYPE as B, PLANE_TYPE as P, RECT_TYPE as R, SPRITE_TYPE as S, TEXT_TYPE as T, ZylemSprite as Z, SPHERE_TYPE as a, ZylemSphere as b, ZylemRect as c, ZylemText as d, ZylemBox as e, ZylemPlane as f, ZONE_TYPE as g, ZylemZone as h, ZylemActor as i, createBox as j, createSphere as k, createSprite as l, createPlane as m, createZone as n, createActor as o, createText as p, createRect as q };
@@ -1,6 +1,7 @@
1
- export { Z as ZylemBox, c as actor, b as box, p as plane, r as rect, s as sphere, a as sprite, t as text, z as zone } from './entities-BAxfJOkk.js';
2
- import './entity-COvRtFNG.js';
1
+ export { e as ZylemBox, o as createActor, j as createBox, m as createPlane, q as createRect, k as createSphere, l as createSprite, p as createText, n as createZone } from './entities-DvByhMGU.js';
2
+ import './world-C8tQ7Plj.js';
3
3
  import 'three';
4
4
  import '@dimforge/rapier3d-compat';
5
- import 'bitecs';
6
5
  import './entity-Bq_eNEDI.js';
6
+ import 'bitecs';
7
+ import 'mitt';