@zylem/game-lib 0.3.14

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 (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -0
  3. package/dist/.vite/manifest.json +8 -0
  4. package/dist/assets/bounce.wav +0 -0
  5. package/dist/assets/coin-sound.mp3 +0 -0
  6. package/dist/assets/zylem-logo.png +0 -0
  7. package/dist/lib/actions/behaviors/actions.d.ts +10 -0
  8. package/dist/lib/actions/behaviors/behavior.d.ts +5 -0
  9. package/dist/lib/actions/behaviors/boundaries/boundary.d.ts +36 -0
  10. package/dist/lib/actions/behaviors/character-controller.d.ts +5 -0
  11. package/dist/lib/actions/behaviors/debug/debug-collision.d.ts +5 -0
  12. package/dist/lib/actions/behaviors/debug/debug-update.d.ts +4 -0
  13. package/dist/lib/actions/behaviors/debug/debug.d.ts +9 -0
  14. package/dist/lib/actions/behaviors/index.d.ts +1 -0
  15. package/dist/lib/actions/behaviors/movement/movement-sequence-2d.d.ts +23 -0
  16. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts +10 -0
  17. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts +11 -0
  18. package/dist/lib/actions/behaviors/ricochet/ricochet.d.ts +41 -0
  19. package/dist/lib/actions/behaviors/zylem-behavior.d.ts +1 -0
  20. package/dist/lib/actions/capabilities/moveable.d.ts +124 -0
  21. package/dist/lib/actions/capabilities/rotatable.d.ts +110 -0
  22. package/dist/lib/actions/capabilities/transformable.d.ts +6 -0
  23. package/dist/lib/actions/global-change.d.ts +12 -0
  24. package/dist/lib/camera/camera.d.ts +15 -0
  25. package/dist/lib/camera/fixed-2d.d.ts +31 -0
  26. package/dist/lib/camera/perspective.d.ts +8 -0
  27. package/dist/lib/camera/third-person.d.ts +39 -0
  28. package/dist/lib/camera/zylem-camera.d.ts +68 -0
  29. package/dist/lib/collision/collision-builder.d.ts +23 -0
  30. package/dist/lib/collision/collision-delegate.d.ts +11 -0
  31. package/dist/lib/collision/collision-group.d.ts +27 -0
  32. package/dist/lib/collision/collision-mask.d.ts +17 -0
  33. package/dist/lib/collision/collision.d.ts +27 -0
  34. package/dist/lib/collision/physics.d.ts +4 -0
  35. package/dist/lib/collision/utils.d.ts +14 -0
  36. package/dist/lib/collision/world.d.ts +22 -0
  37. package/dist/lib/core/asset-manager.d.ts +1 -0
  38. package/dist/lib/core/base-node-life-cycle.d.ts +53 -0
  39. package/dist/lib/core/base-node.d.ts +32 -0
  40. package/dist/lib/core/entity-asset-loader.d.ts +29 -0
  41. package/dist/lib/core/errors.d.ts +4 -0
  42. package/dist/lib/core/flags.d.ts +2 -0
  43. package/dist/lib/core/game-canvas.d.ts +4 -0
  44. package/dist/lib/core/index.d.ts +4 -0
  45. package/dist/lib/core/lazy-loader.d.ts +81 -0
  46. package/dist/lib/core/lifecycle-base.d.ts +16 -0
  47. package/dist/lib/core/preset-shader.d.ts +10 -0
  48. package/dist/lib/core/three-addons/Timer.d.ts +106 -0
  49. package/dist/lib/core/utility.d.ts +15 -0
  50. package/dist/lib/core/vector.d.ts +3 -0
  51. package/dist/lib/core/vessel.d.ts +11 -0
  52. package/dist/lib/debug/console/console-state.d.ts +19 -0
  53. package/dist/lib/debug/console/console-store.d.ts +5 -0
  54. package/dist/lib/debug/debug-state.d.ts +43 -0
  55. package/dist/lib/debug/debug-store.d.ts +14 -0
  56. package/dist/lib/debug/state-based-debug-loader.d.ts +7 -0
  57. package/dist/lib/device/desktop.d.ts +1 -0
  58. package/dist/lib/device/mobile.d.ts +1 -0
  59. package/dist/lib/device/tablet.d.ts +1 -0
  60. package/dist/lib/entities/actor.d.ts +57 -0
  61. package/dist/lib/entities/box.d.ts +26 -0
  62. package/dist/lib/entities/builder.d.ts +27 -0
  63. package/dist/lib/entities/create.d.ts +14 -0
  64. package/dist/lib/entities/delegates/animation.d.ts +32 -0
  65. package/dist/lib/entities/delegates/debug.d.ts +37 -0
  66. package/dist/lib/entities/delegates/loader.d.ts +11 -0
  67. package/dist/lib/entities/destroy.d.ts +3 -0
  68. package/dist/lib/entities/entity.d.ts +100 -0
  69. package/dist/lib/entities/index.d.ts +11 -0
  70. package/dist/lib/entities/object.d.ts +1 -0
  71. package/dist/lib/entities/plane.d.ts +35 -0
  72. package/dist/lib/entities/rect.d.ts +62 -0
  73. package/dist/lib/entities/sphere.d.ts +28 -0
  74. package/dist/lib/entities/sprite.d.ts +52 -0
  75. package/dist/lib/entities/text.d.ts +41 -0
  76. package/dist/lib/entities/zone.d.ts +53 -0
  77. package/dist/lib/game/game-interfaces.d.ts +28 -0
  78. package/dist/lib/game/game-state.d.ts +10 -0
  79. package/dist/lib/game/game.d.ts +41 -0
  80. package/dist/lib/game/zylem-game.d.ts +44 -0
  81. package/dist/lib/graphics/geometries/XZPlaneGeometry.d.ts +7 -0
  82. package/dist/lib/graphics/material.d.ts +28 -0
  83. package/dist/lib/graphics/mesh.d.ts +18 -0
  84. package/dist/lib/graphics/render-pass.d.ts +16 -0
  85. package/dist/lib/graphics/zylem-scene.d.ts +49 -0
  86. package/dist/lib/input/gamepad-provider.d.ts +13 -0
  87. package/dist/lib/input/input-manager.d.ts +14 -0
  88. package/dist/lib/input/input-provider.d.ts +6 -0
  89. package/dist/lib/input/input.d.ts +51 -0
  90. package/dist/lib/input/keyboard-provider.d.ts +20 -0
  91. package/dist/lib/interfaces/entity.d.ts +31 -0
  92. package/dist/lib/interfaces/game.d.ts +19 -0
  93. package/dist/lib/sounds/index.d.ts +2 -0
  94. package/dist/lib/sounds/ping-pong-sound.d.ts +4 -0
  95. package/dist/lib/sounds/ricochet-sound.d.ts +4 -0
  96. package/dist/lib/stage/debug-entity-cursor.d.ts +23 -0
  97. package/dist/lib/stage/entity-spawner.d.ts +8 -0
  98. package/dist/lib/stage/stage-debug-delegate.d.ts +25 -0
  99. package/dist/lib/stage/stage-state.d.ts +12 -0
  100. package/dist/lib/stage/stage.d.ts +33 -0
  101. package/dist/lib/stage/zylem-stage.d.ts +127 -0
  102. package/dist/lib/systems/test-system.d.ts +1 -0
  103. package/dist/lib/systems/transformable.system.d.ts +24 -0
  104. package/dist/lib/types/entity-types.d.ts +38 -0
  105. package/dist/lib/types/index.d.ts +2 -0
  106. package/dist/lib/types/stage-types.d.ts +34 -0
  107. package/dist/lib/ui/Debug.d.ts +1 -0
  108. package/dist/lib/ui/console/Console.d.ts +6 -0
  109. package/dist/lib/ui/debug-panel/AccordionMenu.d.ts +6 -0
  110. package/dist/lib/ui/debug-panel/Menu.d.ts +5 -0
  111. package/dist/lib/ui/debug-panel/sections/EntitiesSection.d.ts +11 -0
  112. package/dist/lib/ui/debug-panel/sections/GameSection.d.ts +2 -0
  113. package/dist/lib/ui/debug-panel/sections/StagesSection.d.ts +2 -0
  114. package/dist/lib/ui/debug-panel/sections/all.d.ts +3 -0
  115. package/dist/lib/ui/toolbar/Toolbar.d.ts +5 -0
  116. package/dist/main.cjs +3980 -0
  117. package/dist/main.d.ts +40 -0
  118. package/dist/main.js +35583 -0
  119. package/dist/tests/collision/collision.spec.d.ts +1 -0
  120. package/dist/tests/core/game.spec.d.ts +1 -0
  121. package/dist/tests/core/stage.spec.d.ts +1 -0
  122. package/dist/tests/core/vessel.spec.d.ts +1 -0
  123. package/package.json +127 -0
@@ -0,0 +1,43 @@
1
+ export type DebugConfiguration = {
2
+ showCollisionBounds?: boolean;
3
+ showModelBounds?: boolean;
4
+ showSpriteBounds?: boolean;
5
+ };
6
+ export declare const DebugTools: {
7
+ readonly NONE: "NONE";
8
+ readonly SELECT: "SELECT";
9
+ readonly ADD: "ADD";
10
+ readonly DELETE: "DELETE";
11
+ };
12
+ declare const debugState: {
13
+ on: boolean;
14
+ paused: boolean;
15
+ configuration: {
16
+ showCollisionBounds: boolean;
17
+ showModelBounds: boolean;
18
+ showSpriteBounds: boolean;
19
+ };
20
+ hovered: string | null;
21
+ selected: string[];
22
+ tool: keyof typeof DebugTools;
23
+ };
24
+ declare const setDebugFlag: (flag?: boolean) => void;
25
+ declare const setSelectedEntity: (uuid: string) => void;
26
+ declare const resetSelectedEntities: () => void;
27
+ /**
28
+ * Set the active debug tool and print the selection to the debug console.
29
+ * @param tool The tool to activate
30
+ */
31
+ declare const setDebugTool: (tool: keyof typeof DebugTools) => void;
32
+ declare const getDebugTool: () => "NONE" | "SELECT" | "ADD" | "DELETE";
33
+ declare const setHoveredEntity: (uuid: string) => void;
34
+ declare const resetHoveredEntity: () => void;
35
+ declare const getHoveredEntity: () => string | null;
36
+ export { debugState, setDebugFlag, setSelectedEntity, resetSelectedEntities, setDebugTool, getDebugTool, setHoveredEntity, resetHoveredEntity, getHoveredEntity };
37
+ export declare const togglePause: () => void;
38
+ /**
39
+ * Set pause state directly and print the new state to the console.
40
+ * @param paused Whether to pause (true) or resume (false)
41
+ */
42
+ export declare const setPaused: (paused: boolean) => void;
43
+ export declare const isPaused: () => boolean;
@@ -0,0 +1,14 @@
1
+ import { DebugTools } from './debug-state';
2
+ export declare const debugStore: {
3
+ debug: boolean;
4
+ tool: keyof typeof DebugTools;
5
+ paused: boolean;
6
+ hovered: string | null;
7
+ selected: string[];
8
+ }, setDebugStore: import("solid-js/store").SetStoreFunction<{
9
+ debug: boolean;
10
+ tool: keyof typeof DebugTools;
11
+ paused: boolean;
12
+ hovered: string | null;
13
+ selected: string[];
14
+ }>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * State-Based Debug Module Loader
3
+ *
4
+ * This approach integrates with the existing debug state system
5
+ * and loads the debug module when debug state changes to true.
6
+ */
7
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function isMobile(): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,57 @@
1
+ import { ColliderDesc } from '@dimforge/rapier3d-compat';
2
+ import { Object3D, Group } from 'three';
3
+ import { BaseNode } from '../core/base-node';
4
+ import { GameEntityOptions, GameEntity } from './entity';
5
+ import { UpdateContext } from '../core/base-node-life-cycle';
6
+ import { EntityLoaderDelegate } from './delegates/loader';
7
+ import { Vec3 } from '../core/vector';
8
+ import { AnimationOptions } from './delegates/animation';
9
+ import { MaterialOptions } from '../graphics/material';
10
+ import { DebugInfoProvider } from './delegates/debug';
11
+ import { EntityBuilder } from './builder';
12
+ import { EntityCollisionBuilder } from './builder';
13
+ type AnimationObject = {
14
+ key?: string;
15
+ path: string;
16
+ };
17
+ type ZylemActorOptions = GameEntityOptions & {
18
+ static?: boolean;
19
+ animations?: AnimationObject[];
20
+ models?: string[];
21
+ scale?: Vec3;
22
+ material?: MaterialOptions;
23
+ };
24
+ export declare class ActorCollisionBuilder extends EntityCollisionBuilder {
25
+ private height;
26
+ private objectModel;
27
+ constructor(data: any);
28
+ createColliderFromObjectModel(objectModel: Group | null): ColliderDesc;
29
+ collider(options: ZylemActorOptions): ColliderDesc;
30
+ }
31
+ export declare class ActorBuilder extends EntityBuilder<ZylemActor, ZylemActorOptions> {
32
+ protected createEntity(options: Partial<ZylemActorOptions>): ZylemActor;
33
+ }
34
+ export declare const ACTOR_TYPE: unique symbol;
35
+ export declare class ZylemActor extends GameEntity<ZylemActorOptions> implements EntityLoaderDelegate, DebugInfoProvider {
36
+ static type: symbol;
37
+ private _object;
38
+ private _animationDelegate;
39
+ private _modelFileNames;
40
+ private _assetLoader;
41
+ controlledRotation: boolean;
42
+ constructor(options?: ZylemActorOptions);
43
+ load(): Promise<void>;
44
+ data(): Promise<any>;
45
+ actorUpdate(params: UpdateContext<ZylemActorOptions>): Promise<void>;
46
+ private loadModels;
47
+ playAnimation(animationOptions: AnimationOptions): void;
48
+ get object(): Object3D | null;
49
+ /**
50
+ * Provide custom debug information for the actor
51
+ * This will be merged with the default debug information
52
+ */
53
+ getDebugInfo(): Record<string, any>;
54
+ }
55
+ type ActorOptions = BaseNode | ZylemActorOptions;
56
+ export declare function actor(...args: Array<ActorOptions>): Promise<ZylemActor>;
57
+ export {};
@@ -0,0 +1,26 @@
1
+ import { ColliderDesc } from '@dimforge/rapier3d-compat';
2
+ import { BoxGeometry } from 'three';
3
+ import { BaseNode } from '../core/base-node';
4
+ import { GameEntityOptions, GameEntity } from './entity';
5
+ import { EntityBuilder } from './builder';
6
+ import { EntityCollisionBuilder } from './builder';
7
+ import { EntityMeshBuilder } from './builder';
8
+ type ZylemBoxOptions = GameEntityOptions;
9
+ export declare class BoxCollisionBuilder extends EntityCollisionBuilder {
10
+ collider(options: GameEntityOptions): ColliderDesc;
11
+ }
12
+ export declare class BoxMeshBuilder extends EntityMeshBuilder {
13
+ build(options: GameEntityOptions): BoxGeometry;
14
+ }
15
+ export declare class BoxBuilder extends EntityBuilder<ZylemBox, ZylemBoxOptions> {
16
+ protected createEntity(options: Partial<ZylemBoxOptions>): ZylemBox;
17
+ }
18
+ export declare const BOX_TYPE: unique symbol;
19
+ export declare class ZylemBox extends GameEntity<ZylemBoxOptions> {
20
+ static type: symbol;
21
+ constructor(options?: ZylemBoxOptions);
22
+ buildInfo(): Record<string, any>;
23
+ }
24
+ type BoxOptions = BaseNode | ZylemBoxOptions;
25
+ export declare function box(...args: Array<BoxOptions>): Promise<ZylemBox>;
26
+ export {};
@@ -0,0 +1,27 @@
1
+ import { ColliderDesc } from "@dimforge/rapier3d-compat";
2
+ import { GameEntity, GameEntityOptions } from "./entity";
3
+ import { BufferGeometry, Group, Material } from "three";
4
+ import { CollisionBuilder } from "../collision/collision-builder";
5
+ import { MeshBuilder } from "../graphics/mesh";
6
+ import { MaterialBuilder, MaterialOptions } from "../graphics/material";
7
+ import { Vec3 } from "../core/vector";
8
+ export declare abstract class EntityCollisionBuilder extends CollisionBuilder {
9
+ abstract collider(options: GameEntityOptions): ColliderDesc;
10
+ }
11
+ export declare abstract class EntityMeshBuilder extends MeshBuilder {
12
+ build(options: GameEntityOptions): BufferGeometry;
13
+ postBuild(): void;
14
+ }
15
+ export declare abstract class EntityBuilder<T extends GameEntity<U> & P, U extends GameEntityOptions, P = any> {
16
+ protected meshBuilder: EntityMeshBuilder | null;
17
+ protected collisionBuilder: EntityCollisionBuilder | null;
18
+ protected materialBuilder: MaterialBuilder | null;
19
+ protected options: Partial<U>;
20
+ protected entity: T;
21
+ constructor(options: Partial<U>, entity: T, meshBuilder: EntityMeshBuilder | null, collisionBuilder: EntityCollisionBuilder | null);
22
+ withPosition(setupPosition: Vec3): this;
23
+ withMaterial(options: Partial<MaterialOptions>, entityType: symbol): Promise<this>;
24
+ applyMaterialToGroup(group: Group, materials: Material[]): void;
25
+ build(): Promise<T>;
26
+ protected abstract createEntity(options: Partial<U>): T;
27
+ }
@@ -0,0 +1,14 @@
1
+ import { GameEntityOptions, GameEntity } from "./entity";
2
+ import { EntityBuilder } from "./builder";
3
+ import { EntityCollisionBuilder } from "./builder";
4
+ import { EntityMeshBuilder } from "./builder";
5
+ export interface CreateGameEntityOptions<T extends GameEntity<any>, CreateOptions extends GameEntityOptions> {
6
+ args: Array<any>;
7
+ defaultConfig: GameEntityOptions;
8
+ EntityClass: new (options: any) => T;
9
+ BuilderClass: new (options: any, entity: T, meshBuilder: any, collisionBuilder: any) => EntityBuilder<T, CreateOptions>;
10
+ MeshBuilderClass?: new (data: any) => EntityMeshBuilder;
11
+ CollisionBuilderClass?: new (data: any) => EntityCollisionBuilder;
12
+ entityType: symbol;
13
+ }
14
+ export declare function createEntity<T extends GameEntity<any>, CreateOptions extends GameEntityOptions>(params: CreateGameEntityOptions<T, CreateOptions>): Promise<T>;
@@ -0,0 +1,32 @@
1
+ import { AnimationClip, Object3D } from 'three';
2
+ export type AnimationOptions = {
3
+ key: string;
4
+ pauseAtEnd?: boolean;
5
+ pauseAtPercentage?: number;
6
+ fadeToKey?: string;
7
+ fadeDuration?: number;
8
+ };
9
+ type AnimationObject = {
10
+ key?: string;
11
+ path: string;
12
+ };
13
+ export declare class AnimationDelegate {
14
+ private target;
15
+ private _mixer;
16
+ private _actions;
17
+ private _animations;
18
+ private _currentAction;
19
+ private _pauseAtPercentage;
20
+ private _isPaused;
21
+ private _queuedKey;
22
+ private _fadeDuration;
23
+ private _currentKey;
24
+ private _assetLoader;
25
+ constructor(target: Object3D);
26
+ loadAnimations(animations: AnimationObject[]): Promise<void>;
27
+ update(delta: number): void;
28
+ playAnimation(opts: AnimationOptions): void;
29
+ get currentAnimationKey(): string;
30
+ get animations(): AnimationClip[];
31
+ }
32
+ export {};
@@ -0,0 +1,37 @@
1
+ import { GameEntity, GameEntityOptions } from '../entity';
2
+ /**
3
+ * Interface for entities that provide custom debug information
4
+ */
5
+ export interface DebugInfoProvider {
6
+ getDebugInfo(): Record<string, any>;
7
+ }
8
+ /**
9
+ * Helper to check if an object implements DebugInfoProvider
10
+ */
11
+ export declare function hasDebugInfo(obj: any): obj is DebugInfoProvider;
12
+ /**
13
+ * Debug delegate that provides debug information for entities
14
+ */
15
+ export declare class DebugDelegate {
16
+ private entity;
17
+ constructor(entity: GameEntity<any>);
18
+ /**
19
+ * Get formatted position string
20
+ */
21
+ private getPositionString;
22
+ /**
23
+ * Get formatted rotation string (in degrees)
24
+ */
25
+ private getRotationString;
26
+ /**
27
+ * Get material information
28
+ */
29
+ private getMaterialInfo;
30
+ private getPhysicsInfo;
31
+ buildDebugInfo(): Record<string, any>;
32
+ }
33
+ export declare class EnhancedDebugInfoBuilder {
34
+ private customBuilder?;
35
+ constructor(customBuilder?: (options: GameEntityOptions) => Record<string, any>);
36
+ buildInfo(options: GameEntityOptions, entity?: GameEntity<any>): Record<string, any>;
37
+ }
@@ -0,0 +1,11 @@
1
+ export declare function isLoadable(obj: any): obj is EntityLoaderDelegate;
2
+ export interface EntityLoaderDelegate {
3
+ load(): Promise<void>;
4
+ data(): any;
5
+ }
6
+ export declare class EntityLoader {
7
+ entityReference: EntityLoaderDelegate;
8
+ constructor(entity: EntityLoaderDelegate);
9
+ load(): Promise<void>;
10
+ data(): Promise<any>;
11
+ }
@@ -0,0 +1,3 @@
1
+ import { DestroyFunction } from "../core/base-node-life-cycle";
2
+ export declare function destroyEntity<T>(entity: T, globals: any, destroyFunction: DestroyFunction<T>): void;
3
+ export declare function destroy(entity: any, globals?: any): void;
@@ -0,0 +1,100 @@
1
+ import { Mesh, Material, ShaderMaterial, Group, Color } from "three";
2
+ import { Collider, ColliderDesc, RigidBody, RigidBodyDesc } from "@dimforge/rapier3d-compat";
3
+ import { Vec3 } from "../core/vector";
4
+ import { MaterialBuilder, MaterialOptions } from "../graphics/material";
5
+ import { PhysicsOptions } from "../collision/physics";
6
+ import { CollisionOptions } from "../collision/collision";
7
+ import { BaseNode } from "../core/base-node";
8
+ import { DestroyContext, SetupContext, UpdateContext } from "../core/base-node-life-cycle";
9
+ import type { EntityMeshBuilder, EntityCollisionBuilder } from "./builder";
10
+ export declare abstract class AbstractEntity {
11
+ abstract uuid: string;
12
+ abstract eid: number;
13
+ abstract name: string;
14
+ }
15
+ export interface LifeCycleDelegate<U> {
16
+ setup?: ((params: SetupContext<U>) => void)[];
17
+ update?: ((params: UpdateContext<U>) => void)[];
18
+ destroy?: ((params: DestroyContext<U>) => void)[];
19
+ }
20
+ export interface CollisionContext<T, O extends GameEntityOptions, TGlobals extends Record<string, unknown> = any> {
21
+ entity: T;
22
+ other: GameEntity<O>;
23
+ globals: TGlobals;
24
+ }
25
+ export type BehaviorContext<T, O extends GameEntityOptions> = SetupContext<T, O> | UpdateContext<T, O> | CollisionContext<T, O> | DestroyContext<T, O>;
26
+ export type BehaviorCallback<T, O extends GameEntityOptions> = (params: BehaviorContext<T, O>) => void;
27
+ export interface CollisionDelegate<T, O extends GameEntityOptions> {
28
+ collision?: ((params: CollisionContext<T, O>) => void)[];
29
+ }
30
+ export type IBuilder<BuilderOptions = any> = {
31
+ preBuild: (options: BuilderOptions) => BuilderOptions;
32
+ build: (options: BuilderOptions) => BuilderOptions;
33
+ postBuild: (options: BuilderOptions) => BuilderOptions;
34
+ };
35
+ export type GameEntityOptions = {
36
+ name?: string;
37
+ color?: Color;
38
+ size?: Vec3;
39
+ position?: Vec3;
40
+ batched?: boolean;
41
+ collision?: Partial<CollisionOptions>;
42
+ physics?: Partial<PhysicsOptions>;
43
+ material?: Partial<MaterialOptions>;
44
+ custom?: {
45
+ [key: string]: any;
46
+ };
47
+ collisionType?: string;
48
+ collisionGroup?: string;
49
+ collisionFilter?: string[];
50
+ _builders?: {
51
+ meshBuilder?: IBuilder | EntityMeshBuilder | null;
52
+ collisionBuilder?: IBuilder | EntityCollisionBuilder | null;
53
+ materialBuilder?: MaterialBuilder | null;
54
+ };
55
+ };
56
+ export declare abstract class GameEntityLifeCycle {
57
+ abstract _setup(params: SetupContext<this>): void;
58
+ abstract _update(params: UpdateContext<this>): void;
59
+ abstract _destroy(params: DestroyContext<this>): void;
60
+ }
61
+ export interface EntityDebugInfo {
62
+ buildInfo: () => Record<string, string>;
63
+ }
64
+ export type BehaviorCallbackType = 'setup' | 'update' | 'destroy' | 'collision';
65
+ export declare class GameEntity<O extends GameEntityOptions> extends BaseNode<O> implements GameEntityLifeCycle, EntityDebugInfo {
66
+ group: Group | undefined;
67
+ mesh: Mesh | undefined;
68
+ materials: Material[] | undefined;
69
+ bodyDesc: RigidBodyDesc | null;
70
+ body: RigidBody | null;
71
+ colliderDesc: ColliderDesc | undefined;
72
+ collider: Collider | undefined;
73
+ custom: Record<string, any>;
74
+ debugInfo: Record<string, any>;
75
+ debugMaterial: ShaderMaterial | undefined;
76
+ lifeCycleDelegate: LifeCycleDelegate<O>;
77
+ collisionDelegate: CollisionDelegate<this, O>;
78
+ collisionType?: string;
79
+ behaviorCallbackMap: Record<BehaviorCallbackType, BehaviorCallback<this, O>[]>;
80
+ constructor();
81
+ create(): this;
82
+ onSetup(...callbacks: ((params: SetupContext<this>) => void)[]): this;
83
+ onUpdate(...callbacks: ((params: UpdateContext<this>) => void)[]): this;
84
+ onDestroy(...callbacks: ((params: DestroyContext<this>) => void)[]): this;
85
+ onCollision(...callbacks: ((params: CollisionContext<this, O>) => void)[]): this;
86
+ _setup(params: SetupContext<this>): void;
87
+ _update(params: UpdateContext<this>): void;
88
+ _destroy(params: DestroyContext<this>): void;
89
+ _collision(other: GameEntity<O>, globals?: any): void;
90
+ addBehavior(behaviorCallback: ({
91
+ type: BehaviorCallbackType;
92
+ handler: any;
93
+ })): this;
94
+ addBehaviors(behaviorCallbacks: ({
95
+ type: BehaviorCallbackType;
96
+ handler: any;
97
+ })[]): this;
98
+ protected updateMaterials(params: any): void;
99
+ buildInfo(): Record<string, string>;
100
+ }
@@ -0,0 +1,11 @@
1
+ export * from './actor';
2
+ export * from './box';
3
+ export * from './plane';
4
+ export * from './sphere';
5
+ export * from './sprite';
6
+ export * from './zone';
7
+ export * from './text';
8
+ export * from './rect';
9
+ export { createEntity } from './create';
10
+ export * from './delegates/debug';
11
+ export type { AbstractEntity, GameEntity, GameEntityOptions, } from './entity';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ import { ColliderDesc } from '@dimforge/rapier3d-compat';
2
+ import { Vector2 } from 'three';
3
+ import { TexturePath } from '../graphics/material';
4
+ import { BaseNode } from '../core/base-node';
5
+ import { GameEntityOptions, GameEntity } from './entity';
6
+ import { EntityBuilder } from './builder';
7
+ import { EntityCollisionBuilder } from './builder';
8
+ import { EntityMeshBuilder } from './builder';
9
+ import { XZPlaneGeometry } from '../graphics/geometries/XZPlaneGeometry';
10
+ type ZylemPlaneOptions = GameEntityOptions & {
11
+ tile?: Vector2;
12
+ repeat?: Vector2;
13
+ texture?: TexturePath;
14
+ subdivisions?: number;
15
+ };
16
+ export declare class PlaneCollisionBuilder extends EntityCollisionBuilder {
17
+ collider(options: ZylemPlaneOptions): ColliderDesc;
18
+ }
19
+ export declare class PlaneMeshBuilder extends EntityMeshBuilder {
20
+ heightData: Float32Array;
21
+ columnsRows: Map<any, any>;
22
+ build(options: ZylemPlaneOptions): XZPlaneGeometry;
23
+ postBuild(): void;
24
+ }
25
+ export declare class PlaneBuilder extends EntityBuilder<ZylemPlane, ZylemPlaneOptions> {
26
+ protected createEntity(options: Partial<ZylemPlaneOptions>): ZylemPlane;
27
+ }
28
+ export declare const PLANE_TYPE: unique symbol;
29
+ export declare class ZylemPlane extends GameEntity<ZylemPlaneOptions> {
30
+ static type: symbol;
31
+ constructor(options?: ZylemPlaneOptions);
32
+ }
33
+ type PlaneOptions = BaseNode | Partial<ZylemPlaneOptions>;
34
+ export declare function plane(...args: Array<PlaneOptions>): Promise<ZylemPlane>;
35
+ export {};
@@ -0,0 +1,62 @@
1
+ import { Color, Vector2 } from 'three';
2
+ import { BaseNode } from '../core/base-node';
3
+ import { GameEntityOptions, GameEntity } from './entity';
4
+ import { EntityBuilder } from './builder';
5
+ type ZylemRectOptions = GameEntityOptions & {
6
+ width?: number;
7
+ height?: number;
8
+ fillColor?: Color | string | null;
9
+ strokeColor?: Color | string | null;
10
+ strokeWidth?: number;
11
+ radius?: number;
12
+ padding?: number;
13
+ stickToViewport?: boolean;
14
+ screenPosition?: Vector2;
15
+ zDistance?: number;
16
+ anchor?: Vector2;
17
+ bounds?: {
18
+ screen?: {
19
+ x: number;
20
+ y: number;
21
+ width: number;
22
+ height: number;
23
+ };
24
+ world?: {
25
+ left: number;
26
+ right: number;
27
+ top: number;
28
+ bottom: number;
29
+ z?: number;
30
+ };
31
+ };
32
+ };
33
+ export declare class RectBuilder extends EntityBuilder<ZylemRect, ZylemRectOptions> {
34
+ protected createEntity(options: Partial<ZylemRectOptions>): ZylemRect;
35
+ }
36
+ export declare const RECT_TYPE: unique symbol;
37
+ export declare class ZylemRect extends GameEntity<ZylemRectOptions> {
38
+ static type: symbol;
39
+ private _sprite;
40
+ private _mesh;
41
+ private _texture;
42
+ private _canvas;
43
+ private _ctx;
44
+ private _cameraRef;
45
+ private _lastCanvasW;
46
+ private _lastCanvasH;
47
+ constructor(options?: ZylemRectOptions);
48
+ private createSprite;
49
+ private redrawRect;
50
+ private roundedRectPath;
51
+ private toCssColor;
52
+ private rectSetup;
53
+ private rectUpdate;
54
+ private updateStickyTransform;
55
+ private worldToScreen;
56
+ private computeScreenBoundsFromOptions;
57
+ updateRect(options?: Partial<Pick<ZylemRectOptions, 'width' | 'height' | 'fillColor' | 'strokeColor' | 'strokeWidth' | 'radius'>>): void;
58
+ buildInfo(): Record<string, any>;
59
+ }
60
+ type RectOptions = BaseNode | Partial<ZylemRectOptions>;
61
+ export declare function rect(...args: Array<RectOptions>): Promise<ZylemRect>;
62
+ export {};
@@ -0,0 +1,28 @@
1
+ import { ColliderDesc } from '@dimforge/rapier3d-compat';
2
+ import { SphereGeometry } from 'three';
3
+ import { BaseNode } from '../core/base-node';
4
+ import { GameEntityOptions, GameEntity } from './entity';
5
+ import { EntityBuilder } from './builder';
6
+ import { EntityCollisionBuilder } from './builder';
7
+ import { EntityMeshBuilder } from './builder';
8
+ type ZylemSphereOptions = GameEntityOptions & {
9
+ radius?: number;
10
+ };
11
+ export declare class SphereCollisionBuilder extends EntityCollisionBuilder {
12
+ collider(options: ZylemSphereOptions): ColliderDesc;
13
+ }
14
+ export declare class SphereMeshBuilder extends EntityMeshBuilder {
15
+ build(options: ZylemSphereOptions): SphereGeometry;
16
+ }
17
+ export declare class SphereBuilder extends EntityBuilder<ZylemSphere, ZylemSphereOptions> {
18
+ protected createEntity(options: Partial<ZylemSphereOptions>): ZylemSphere;
19
+ }
20
+ export declare const SPHERE_TYPE: unique symbol;
21
+ export declare class ZylemSphere extends GameEntity<ZylemSphereOptions> {
22
+ static type: symbol;
23
+ constructor(options?: ZylemSphereOptions);
24
+ buildInfo(): Record<string, any>;
25
+ }
26
+ type SphereOptions = BaseNode | Partial<ZylemSphereOptions>;
27
+ export declare function sphere(...args: Array<SphereOptions>): Promise<ZylemSphere>;
28
+ export {};
@@ -0,0 +1,52 @@
1
+ import { ColliderDesc } from '@dimforge/rapier3d-compat';
2
+ import { Vector3 } from 'three';
3
+ import { Sprite as ThreeSprite } from 'three';
4
+ import { BaseNode } from '../core/base-node';
5
+ import { GameEntityOptions, GameEntity } from './entity';
6
+ import { EntityBuilder } from './builder';
7
+ import { EntityCollisionBuilder } from './builder';
8
+ import { DestroyContext, UpdateContext } from '../core/base-node-life-cycle';
9
+ export type SpriteImage = {
10
+ name: string;
11
+ file: string;
12
+ };
13
+ export type SpriteAnimation = {
14
+ name: string;
15
+ frames: string[];
16
+ speed: number | number[];
17
+ loop: boolean;
18
+ };
19
+ type ZylemSpriteOptions = GameEntityOptions & {
20
+ images?: SpriteImage[];
21
+ animations?: SpriteAnimation[];
22
+ size?: Vector3;
23
+ collisionSize?: Vector3;
24
+ };
25
+ export declare class SpriteCollisionBuilder extends EntityCollisionBuilder {
26
+ collider(options: ZylemSpriteOptions): ColliderDesc;
27
+ }
28
+ export declare class SpriteBuilder extends EntityBuilder<ZylemSprite, ZylemSpriteOptions> {
29
+ protected createEntity(options: Partial<ZylemSpriteOptions>): ZylemSprite;
30
+ }
31
+ export declare const SPRITE_TYPE: unique symbol;
32
+ export declare class ZylemSprite extends GameEntity<ZylemSpriteOptions> {
33
+ static type: symbol;
34
+ protected sprites: ThreeSprite[];
35
+ protected spriteMap: Map<string, number>;
36
+ protected currentSpriteIndex: number;
37
+ protected animations: Map<string, any>;
38
+ protected currentAnimation: any;
39
+ protected currentAnimationFrame: string;
40
+ protected currentAnimationIndex: number;
41
+ protected currentAnimationTime: number;
42
+ constructor(options?: ZylemSpriteOptions);
43
+ protected createSpritesFromImages(images: SpriteImage[]): void;
44
+ protected createAnimations(animations: SpriteAnimation[]): void;
45
+ setSprite(key: string): void;
46
+ setAnimation(name: string, delta: number): void;
47
+ spriteUpdate(params: UpdateContext<ZylemSpriteOptions>): Promise<void>;
48
+ spriteDestroy(params: DestroyContext<ZylemSpriteOptions>): Promise<void>;
49
+ }
50
+ type SpriteOptions = BaseNode | Partial<ZylemSpriteOptions>;
51
+ export declare function sprite(...args: Array<SpriteOptions>): Promise<ZylemSprite>;
52
+ export {};
@@ -0,0 +1,41 @@
1
+ import { Color, Vector2 } from 'three';
2
+ import { BaseNode } from '../core/base-node';
3
+ import { GameEntityOptions, GameEntity } from './entity';
4
+ import { EntityBuilder } from './builder';
5
+ type ZylemTextOptions = GameEntityOptions & {
6
+ text?: string;
7
+ fontFamily?: string;
8
+ fontSize?: number;
9
+ fontColor?: Color | string;
10
+ backgroundColor?: Color | string | null;
11
+ padding?: number;
12
+ stickToViewport?: boolean;
13
+ screenPosition?: Vector2;
14
+ zDistance?: number;
15
+ };
16
+ export declare class TextBuilder extends EntityBuilder<ZylemText, ZylemTextOptions> {
17
+ protected createEntity(options: Partial<ZylemTextOptions>): ZylemText;
18
+ }
19
+ export declare const TEXT_TYPE: unique symbol;
20
+ export declare class ZylemText extends GameEntity<ZylemTextOptions> {
21
+ static type: symbol;
22
+ private _sprite;
23
+ private _texture;
24
+ private _canvas;
25
+ private _ctx;
26
+ private _cameraRef;
27
+ private _lastCanvasW;
28
+ private _lastCanvasH;
29
+ constructor(options?: ZylemTextOptions);
30
+ private createSprite;
31
+ private redrawText;
32
+ private toCssColor;
33
+ private textSetup;
34
+ private textUpdate;
35
+ private updateStickyTransform;
36
+ updateText(_text: string): void;
37
+ buildInfo(): Record<string, any>;
38
+ }
39
+ type TextOptions = BaseNode | Partial<ZylemTextOptions>;
40
+ export declare function text(...args: Array<TextOptions>): Promise<ZylemText>;
41
+ export {};