@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zylem/game-lib",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A powerful and easy-to-use framework for creating simple 3D digital interactive applications using TypeScript.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -65,6 +65,14 @@
|
|
|
65
65
|
"files": [
|
|
66
66
|
"dist"
|
|
67
67
|
],
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "tsup",
|
|
70
|
+
"dev": "tsup --watch",
|
|
71
|
+
"lint": "biome check .",
|
|
72
|
+
"typecheck": "tsc --noEmit",
|
|
73
|
+
"test": "vitest --reporter=verbose",
|
|
74
|
+
"coverage": "vitest run --coverage"
|
|
75
|
+
},
|
|
68
76
|
"dependencies": {
|
|
69
77
|
"@dimforge/rapier3d-compat": "^0.11.2",
|
|
70
78
|
"@sinclair/typebox": "^0.34.41",
|
|
@@ -76,6 +84,7 @@
|
|
|
76
84
|
"nanoid": "^5.1.5",
|
|
77
85
|
"stats.js": "^0.17.0",
|
|
78
86
|
"three": "^0.180.0",
|
|
87
|
+
"typescript-fsm": "^1.6.0",
|
|
79
88
|
"valtio": "^2.1.7"
|
|
80
89
|
},
|
|
81
90
|
"peerDependencies": {
|
|
@@ -97,13 +106,5 @@
|
|
|
97
106
|
"typescript": "5.8.2",
|
|
98
107
|
"vite-plugin-solid": "^2.11.8",
|
|
99
108
|
"vitest": "^4.0.9"
|
|
100
|
-
},
|
|
101
|
-
"scripts": {
|
|
102
|
-
"build": "tsup",
|
|
103
|
-
"dev": "tsup --watch",
|
|
104
|
-
"lint": "biome check .",
|
|
105
|
-
"typecheck": "tsc --noEmit",
|
|
106
|
-
"test": "vitest --reporter=verbose",
|
|
107
|
-
"coverage": "vitest run --coverage"
|
|
108
109
|
}
|
|
109
|
-
}
|
|
110
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Timothy Cool
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
import { Vector3, Vector2, Color, Material, BufferGeometry, Mesh, Group, ShaderMaterial } from 'three';
|
|
2
|
-
import { Vector3 as Vector3$1, RigidBodyDesc, ColliderDesc, RigidBody, Collider } from '@dimforge/rapier3d-compat';
|
|
3
|
-
import { IComponent } from 'bitecs';
|
|
4
|
-
|
|
5
|
-
/** Input
|
|
6
|
-
*
|
|
7
|
-
* Maximum number of local players is 8.
|
|
8
|
-
* All input can be mapped to a gamepad or keyboard but shares the common
|
|
9
|
-
* interface represented as a gamepad.
|
|
10
|
-
*/
|
|
11
|
-
type InputPlayerNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
12
|
-
type InputPlayer = `p${InputPlayerNumber}`;
|
|
13
|
-
interface ButtonState {
|
|
14
|
-
pressed: boolean;
|
|
15
|
-
released: boolean;
|
|
16
|
-
held: number;
|
|
17
|
-
}
|
|
18
|
-
interface AnalogState {
|
|
19
|
-
value: number;
|
|
20
|
-
held: number;
|
|
21
|
-
}
|
|
22
|
-
interface InputGamepad {
|
|
23
|
-
playerNumber: InputPlayerNumber;
|
|
24
|
-
buttons: {
|
|
25
|
-
A: ButtonState;
|
|
26
|
-
B: ButtonState;
|
|
27
|
-
X: ButtonState;
|
|
28
|
-
Y: ButtonState;
|
|
29
|
-
Start: ButtonState;
|
|
30
|
-
Select: ButtonState;
|
|
31
|
-
L: ButtonState;
|
|
32
|
-
R: ButtonState;
|
|
33
|
-
};
|
|
34
|
-
directions: {
|
|
35
|
-
Up: ButtonState;
|
|
36
|
-
Down: ButtonState;
|
|
37
|
-
Left: ButtonState;
|
|
38
|
-
Right: ButtonState;
|
|
39
|
-
};
|
|
40
|
-
shoulders: {
|
|
41
|
-
LTrigger: ButtonState;
|
|
42
|
-
RTrigger: ButtonState;
|
|
43
|
-
};
|
|
44
|
-
axes: {
|
|
45
|
-
Horizontal: AnalogState;
|
|
46
|
-
Vertical: AnalogState;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
type Inputs = Record<InputPlayer, InputGamepad>;
|
|
50
|
-
|
|
51
|
-
type LoadingEvent = {
|
|
52
|
-
type: 'start' | 'progress' | 'complete';
|
|
53
|
-
message?: string;
|
|
54
|
-
progress?: number;
|
|
55
|
-
total?: number;
|
|
56
|
-
current?: number;
|
|
57
|
-
};
|
|
58
|
-
interface IGame<TGlobals extends Record<string, unknown> = any> {
|
|
59
|
-
start: () => Promise<this>;
|
|
60
|
-
nextStage: () => void;
|
|
61
|
-
previousStage: () => void;
|
|
62
|
-
reset: () => Promise<void>;
|
|
63
|
-
pause: () => Promise<void>;
|
|
64
|
-
resume: () => Promise<void>;
|
|
65
|
-
onLoading: (callback: (event: LoadingEvent) => void) => void;
|
|
66
|
-
loadStageFromId: (stageId: string) => Promise<void>;
|
|
67
|
-
end: () => Promise<void>;
|
|
68
|
-
goToStage: () => void;
|
|
69
|
-
}
|
|
70
|
-
interface IStage {
|
|
71
|
-
onUpdate: (callback: UpdateFunction<IStage>) => void;
|
|
72
|
-
onSetup: (callback: SetupFunction<IStage>) => void;
|
|
73
|
-
onDestroy: (callback: DestroyFunction<IStage>) => void;
|
|
74
|
-
}
|
|
75
|
-
interface ICamera {
|
|
76
|
-
move: (position: Vector3) => void;
|
|
77
|
-
rotate: (pitch: number, yaw: number, roll: number) => void;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
type GlobalRecord = Record<string, unknown>;
|
|
81
|
-
/** Setup */
|
|
82
|
-
interface SetupContext<T, TGlobals extends GlobalRecord = any> {
|
|
83
|
-
me: T;
|
|
84
|
-
globals: TGlobals;
|
|
85
|
-
inputs?: Inputs;
|
|
86
|
-
camera?: ICamera;
|
|
87
|
-
stage?: IStage;
|
|
88
|
-
game?: IGame<TGlobals>;
|
|
89
|
-
}
|
|
90
|
-
interface SetupFunction<T, TGlobals extends GlobalRecord = any> {
|
|
91
|
-
(context: SetupContext<T, TGlobals>): void;
|
|
92
|
-
}
|
|
93
|
-
/** Loaded */
|
|
94
|
-
interface LoadedContext<T, TGlobals extends GlobalRecord = any> {
|
|
95
|
-
me: T;
|
|
96
|
-
globals: TGlobals;
|
|
97
|
-
}
|
|
98
|
-
interface LoadedFunction<T, TGlobals extends GlobalRecord = any> {
|
|
99
|
-
(context: LoadedContext<T, TGlobals>): void;
|
|
100
|
-
}
|
|
101
|
-
/** Update */
|
|
102
|
-
type UpdateContext<T, TGlobals extends GlobalRecord = any> = {
|
|
103
|
-
me: T;
|
|
104
|
-
delta: number;
|
|
105
|
-
inputs: Inputs;
|
|
106
|
-
globals: TGlobals;
|
|
107
|
-
camera: ICamera;
|
|
108
|
-
stage?: IStage;
|
|
109
|
-
game?: IGame<TGlobals>;
|
|
110
|
-
};
|
|
111
|
-
interface UpdateFunction<T, TGlobals extends GlobalRecord = any> {
|
|
112
|
-
(context: UpdateContext<T, TGlobals>): void;
|
|
113
|
-
}
|
|
114
|
-
/** Destroy */
|
|
115
|
-
interface DestroyContext<T, TGlobals extends GlobalRecord = any> {
|
|
116
|
-
me: T;
|
|
117
|
-
globals: TGlobals;
|
|
118
|
-
}
|
|
119
|
-
interface DestroyFunction<T, TGlobals extends GlobalRecord = any> {
|
|
120
|
-
(context: DestroyContext<T, TGlobals>): void;
|
|
121
|
-
}
|
|
122
|
-
/** Cleanup */
|
|
123
|
-
interface CleanupContext<T, TGlobals extends GlobalRecord = any> {
|
|
124
|
-
me: T;
|
|
125
|
-
globals: TGlobals;
|
|
126
|
-
}
|
|
127
|
-
interface CleanupFunction<T, TGlobals extends GlobalRecord = any> {
|
|
128
|
-
(context: CleanupContext<T, TGlobals>): void;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
interface NodeInterface {
|
|
132
|
-
uuid: string;
|
|
133
|
-
name: string;
|
|
134
|
-
markedForRemoval: boolean;
|
|
135
|
-
nodeSetup(params: SetupContext<any>): void;
|
|
136
|
-
nodeUpdate(params: UpdateContext<any>): void;
|
|
137
|
-
nodeDestroy(params: DestroyContext<any>): void;
|
|
138
|
-
setParent(parent: NodeInterface | null): void;
|
|
139
|
-
getParent(): NodeInterface | null;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
type BaseNodeOptions<T = any> = BaseNode | Partial<T>;
|
|
143
|
-
/**
|
|
144
|
-
* Lifecycle callback arrays - each lifecycle event can have multiple callbacks
|
|
145
|
-
* that execute in order.
|
|
146
|
-
*/
|
|
147
|
-
interface LifecycleCallbacks<T> {
|
|
148
|
-
setup: Array<SetupFunction<T>>;
|
|
149
|
-
loaded: Array<LoadedFunction<T>>;
|
|
150
|
-
update: Array<UpdateFunction<T>>;
|
|
151
|
-
destroy: Array<DestroyFunction<T>>;
|
|
152
|
-
cleanup: Array<CleanupFunction<T>>;
|
|
153
|
-
}
|
|
154
|
-
declare abstract class BaseNode<Options = any, T = any> implements NodeInterface {
|
|
155
|
-
protected parent: NodeInterface | null;
|
|
156
|
-
protected children: NodeInterface[];
|
|
157
|
-
options: Options;
|
|
158
|
-
eid: number;
|
|
159
|
-
uuid: string;
|
|
160
|
-
name: string;
|
|
161
|
-
markedForRemoval: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* Lifecycle callback arrays - use onSetup(), onUpdate(), etc. to add callbacks
|
|
164
|
-
*/
|
|
165
|
-
protected lifecycleCallbacks: LifecycleCallbacks<this>;
|
|
166
|
-
constructor(args?: BaseNodeOptions[]);
|
|
167
|
-
/**
|
|
168
|
-
* Add setup callbacks to be executed in order during nodeSetup
|
|
169
|
-
*/
|
|
170
|
-
onSetup(...callbacks: Array<SetupFunction<this>>): this;
|
|
171
|
-
/**
|
|
172
|
-
* Add loaded callbacks to be executed in order during nodeLoaded
|
|
173
|
-
*/
|
|
174
|
-
onLoaded(...callbacks: Array<LoadedFunction<this>>): this;
|
|
175
|
-
/**
|
|
176
|
-
* Add update callbacks to be executed in order during nodeUpdate
|
|
177
|
-
*/
|
|
178
|
-
onUpdate(...callbacks: Array<UpdateFunction<this>>): this;
|
|
179
|
-
/**
|
|
180
|
-
* Add destroy callbacks to be executed in order during nodeDestroy
|
|
181
|
-
*/
|
|
182
|
-
onDestroy(...callbacks: Array<DestroyFunction<this>>): this;
|
|
183
|
-
/**
|
|
184
|
-
* Add cleanup callbacks to be executed in order during nodeCleanup
|
|
185
|
-
*/
|
|
186
|
-
onCleanup(...callbacks: Array<CleanupFunction<this>>): this;
|
|
187
|
-
/**
|
|
188
|
-
* Prepend setup callbacks (run before existing ones)
|
|
189
|
-
*/
|
|
190
|
-
prependSetup(...callbacks: Array<SetupFunction<this>>): this;
|
|
191
|
-
/**
|
|
192
|
-
* Prepend update callbacks (run before existing ones)
|
|
193
|
-
*/
|
|
194
|
-
prependUpdate(...callbacks: Array<UpdateFunction<this>>): this;
|
|
195
|
-
setParent(parent: NodeInterface | null): void;
|
|
196
|
-
getParent(): NodeInterface | null;
|
|
197
|
-
add(baseNode: NodeInterface): void;
|
|
198
|
-
remove(baseNode: NodeInterface): void;
|
|
199
|
-
getChildren(): NodeInterface[];
|
|
200
|
-
isComposite(): boolean;
|
|
201
|
-
abstract create(): T;
|
|
202
|
-
protected abstract _setup(params: SetupContext<this>): void;
|
|
203
|
-
protected abstract _loaded(params: LoadedContext<this>): Promise<void>;
|
|
204
|
-
protected abstract _update(params: UpdateContext<this>): void;
|
|
205
|
-
protected abstract _destroy(params: DestroyContext<this>): void;
|
|
206
|
-
protected abstract _cleanup(params: CleanupContext<this>): Promise<void>;
|
|
207
|
-
nodeSetup(params: SetupContext<this>): void;
|
|
208
|
-
nodeUpdate(params: UpdateContext<this>): void;
|
|
209
|
-
nodeDestroy(params: DestroyContext<this>): void;
|
|
210
|
-
nodeLoaded(params: LoadedContext<this>): Promise<void>;
|
|
211
|
-
nodeCleanup(params: CleanupContext<this>): Promise<void>;
|
|
212
|
-
getOptions(): Options;
|
|
213
|
-
setOptions(options: Partial<Options>): void;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
type Vec3 = Vector3 | Vector3$1;
|
|
217
|
-
|
|
218
|
-
declare function shortHash(objString: string): string;
|
|
219
|
-
|
|
220
|
-
type ZylemShaderType = 'standard' | 'fire' | 'star' | 'debug';
|
|
221
|
-
|
|
222
|
-
interface MaterialOptions {
|
|
223
|
-
path?: string;
|
|
224
|
-
repeat?: Vector2;
|
|
225
|
-
shader?: ZylemShaderType;
|
|
226
|
-
color?: Color;
|
|
227
|
-
}
|
|
228
|
-
type BatchGeometryMap = Map<symbol, number>;
|
|
229
|
-
interface BatchMaterialMapObject {
|
|
230
|
-
geometryMap: BatchGeometryMap;
|
|
231
|
-
material: Material;
|
|
232
|
-
}
|
|
233
|
-
type BatchKey = ReturnType<typeof shortHash>;
|
|
234
|
-
type TexturePath = string | null;
|
|
235
|
-
declare class MaterialBuilder {
|
|
236
|
-
static batchMaterialMap: Map<BatchKey, BatchMaterialMapObject>;
|
|
237
|
-
materials: Material[];
|
|
238
|
-
batchMaterial(options: Partial<MaterialOptions>, entityType: symbol): void;
|
|
239
|
-
build(options: Partial<MaterialOptions>, entityType: symbol): Promise<void>;
|
|
240
|
-
withColor(color: Color): this;
|
|
241
|
-
withShader(shaderType: ZylemShaderType): this;
|
|
242
|
-
setTexture(texturePath?: TexturePath, repeat?: Vector2): Promise<void>;
|
|
243
|
-
setColor(color: Color): void;
|
|
244
|
-
setShader(customShader: ZylemShaderType): void;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Options for configuring entity collision behavior.
|
|
249
|
-
*/
|
|
250
|
-
interface CollisionOptions {
|
|
251
|
-
static?: boolean;
|
|
252
|
-
sensor?: boolean;
|
|
253
|
-
size?: Vector3$1;
|
|
254
|
-
position?: Vector3$1;
|
|
255
|
-
collisionType?: string;
|
|
256
|
-
collisionFilter?: string[];
|
|
257
|
-
}
|
|
258
|
-
declare class CollisionBuilder {
|
|
259
|
-
static: boolean;
|
|
260
|
-
sensor: boolean;
|
|
261
|
-
gravity: Vec3;
|
|
262
|
-
build(options: Partial<CollisionOptions>): [RigidBodyDesc, ColliderDesc];
|
|
263
|
-
withCollision(collisionOptions: Partial<CollisionOptions>): this;
|
|
264
|
-
collider(options: CollisionOptions): ColliderDesc;
|
|
265
|
-
bodyDesc({ isDynamicBody }: {
|
|
266
|
-
isDynamicBody?: boolean | undefined;
|
|
267
|
-
}): RigidBodyDesc;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* TODO: allow for multiple materials requires geometry groups
|
|
272
|
-
* TODO: allow for instanced uniforms
|
|
273
|
-
* TODO: allow for geometry groups
|
|
274
|
-
* TODO: allow for batched meshes
|
|
275
|
-
* import { InstancedUniformsMesh } from 'three-instanced-uniforms-mesh';
|
|
276
|
-
* may not need geometry groups for shaders though
|
|
277
|
-
* setGeometry<T extends BufferGeometry>(geometry: T) {
|
|
278
|
-
* MeshBuilder.bachedMesh = new BatchedMesh(10, 5000, 10000, material);
|
|
279
|
-
* }
|
|
280
|
-
*/
|
|
281
|
-
type MeshBuilderOptions = Partial<Pick<GameEntityOptions, 'batched' | 'material'>>;
|
|
282
|
-
declare class MeshBuilder {
|
|
283
|
-
_build(meshOptions: MeshBuilderOptions, geometry: BufferGeometry, materials: Material[]): Mesh;
|
|
284
|
-
_postBuild(): void;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
declare abstract class EntityCollisionBuilder extends CollisionBuilder {
|
|
288
|
-
abstract collider(options: GameEntityOptions): ColliderDesc;
|
|
289
|
-
}
|
|
290
|
-
declare abstract class EntityMeshBuilder extends MeshBuilder {
|
|
291
|
-
build(options: GameEntityOptions): BufferGeometry;
|
|
292
|
-
postBuild(): void;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
interface Behavior {
|
|
296
|
-
component: IComponent;
|
|
297
|
-
values: any;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
interface CollisionContext<T, O extends GameEntityOptions, TGlobals extends Record<string, unknown> = any> {
|
|
301
|
-
entity: T;
|
|
302
|
-
other: GameEntity<O>;
|
|
303
|
-
globals: TGlobals;
|
|
304
|
-
}
|
|
305
|
-
type BehaviorContext<T, O extends GameEntityOptions> = SetupContext<T, O> | UpdateContext<T, O> | CollisionContext<T, O> | DestroyContext<T, O>;
|
|
306
|
-
type BehaviorCallback<T, O extends GameEntityOptions> = (params: BehaviorContext<T, O>) => void;
|
|
307
|
-
interface CollisionDelegate<T, O extends GameEntityOptions> {
|
|
308
|
-
collision?: ((params: CollisionContext<T, O>) => void)[];
|
|
309
|
-
}
|
|
310
|
-
type IBuilder<BuilderOptions = any> = {
|
|
311
|
-
preBuild: (options: BuilderOptions) => BuilderOptions;
|
|
312
|
-
build: (options: BuilderOptions) => BuilderOptions;
|
|
313
|
-
postBuild: (options: BuilderOptions) => BuilderOptions;
|
|
314
|
-
};
|
|
315
|
-
type GameEntityOptions = {
|
|
316
|
-
name?: string;
|
|
317
|
-
color?: Color;
|
|
318
|
-
size?: Vec3;
|
|
319
|
-
position?: Vec3;
|
|
320
|
-
batched?: boolean;
|
|
321
|
-
collision?: Partial<CollisionOptions>;
|
|
322
|
-
material?: Partial<MaterialOptions>;
|
|
323
|
-
custom?: {
|
|
324
|
-
[key: string]: any;
|
|
325
|
-
};
|
|
326
|
-
collisionType?: string;
|
|
327
|
-
collisionGroup?: string;
|
|
328
|
-
collisionFilter?: string[];
|
|
329
|
-
_builders?: {
|
|
330
|
-
meshBuilder?: IBuilder | EntityMeshBuilder | null;
|
|
331
|
-
collisionBuilder?: IBuilder | EntityCollisionBuilder | null;
|
|
332
|
-
materialBuilder?: MaterialBuilder | null;
|
|
333
|
-
};
|
|
334
|
-
};
|
|
335
|
-
declare abstract class GameEntityLifeCycle {
|
|
336
|
-
abstract _setup(params: SetupContext<this>): void;
|
|
337
|
-
abstract _update(params: UpdateContext<this>): void;
|
|
338
|
-
abstract _destroy(params: DestroyContext<this>): void;
|
|
339
|
-
}
|
|
340
|
-
interface EntityDebugInfo {
|
|
341
|
-
buildInfo: () => Record<string, string>;
|
|
342
|
-
}
|
|
343
|
-
type BehaviorCallbackType = 'setup' | 'update' | 'destroy' | 'collision';
|
|
344
|
-
declare class GameEntity<O extends GameEntityOptions> extends BaseNode<O> implements GameEntityLifeCycle, EntityDebugInfo {
|
|
345
|
-
behaviors: Behavior[];
|
|
346
|
-
group: Group | undefined;
|
|
347
|
-
mesh: Mesh | undefined;
|
|
348
|
-
materials: Material[] | undefined;
|
|
349
|
-
bodyDesc: RigidBodyDesc | null;
|
|
350
|
-
body: RigidBody | null;
|
|
351
|
-
colliderDesc: ColliderDesc | undefined;
|
|
352
|
-
collider: Collider | undefined;
|
|
353
|
-
custom: Record<string, any>;
|
|
354
|
-
debugInfo: Record<string, any>;
|
|
355
|
-
debugMaterial: ShaderMaterial | undefined;
|
|
356
|
-
collisionDelegate: CollisionDelegate<this, O>;
|
|
357
|
-
collisionType?: string;
|
|
358
|
-
behaviorCallbackMap: Record<BehaviorCallbackType, BehaviorCallback<this, O>[]>;
|
|
359
|
-
constructor();
|
|
360
|
-
create(): this;
|
|
361
|
-
/**
|
|
362
|
-
* Add collision callbacks
|
|
363
|
-
*/
|
|
364
|
-
onCollision(...callbacks: ((params: CollisionContext<this, O>) => void)[]): this;
|
|
365
|
-
/**
|
|
366
|
-
* Entity-specific setup - runs behavior callbacks
|
|
367
|
-
* (User callbacks are handled by BaseNode's lifecycleCallbacks.setup)
|
|
368
|
-
*/
|
|
369
|
-
_setup(params: SetupContext<this>): void;
|
|
370
|
-
protected _loaded(_params: LoadedContext<this>): Promise<void>;
|
|
371
|
-
/**
|
|
372
|
-
* Entity-specific update - updates materials and runs behavior callbacks
|
|
373
|
-
* (User callbacks are handled by BaseNode's lifecycleCallbacks.update)
|
|
374
|
-
*/
|
|
375
|
-
_update(params: UpdateContext<this>): void;
|
|
376
|
-
/**
|
|
377
|
-
* Entity-specific destroy - runs behavior callbacks
|
|
378
|
-
* (User callbacks are handled by BaseNode's lifecycleCallbacks.destroy)
|
|
379
|
-
*/
|
|
380
|
-
_destroy(params: DestroyContext<this>): void;
|
|
381
|
-
protected _cleanup(_params: CleanupContext<this>): Promise<void>;
|
|
382
|
-
_collision(other: GameEntity<O>, globals?: any): void;
|
|
383
|
-
addBehavior(behaviorCallback: ({
|
|
384
|
-
type: BehaviorCallbackType;
|
|
385
|
-
handler: any;
|
|
386
|
-
})): this;
|
|
387
|
-
addBehaviors(behaviorCallbacks: ({
|
|
388
|
-
type: BehaviorCallbackType;
|
|
389
|
-
handler: any;
|
|
390
|
-
})[]): this;
|
|
391
|
-
protected updateMaterials(params: any): void;
|
|
392
|
-
buildInfo(): Record<string, string>;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
export { type AnalogState as A, type BehaviorCallbackType as B, type CleanupContext as C, type DestroyFunction as D, GameEntity as G, type InputGamepad as I, type LoadingEvent as L, type MaterialOptions as M, type SetupContext as S, type TexturePath as T, type UpdateContext as U, type Vec3 as V, type Behavior as a, type SetupFunction as b, type UpdateFunction as c, type DestroyContext as d, BaseNode as e, type InputPlayerNumber as f, type Inputs as g, type ButtonState as h, GameEntityLifeCycle as i, type IGame as j, type LoadedContext as k, type GameEntityOptions as l, type CollisionContext as m };
|