@zylem/game-lib 0.6.0 → 0.6.3
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 +9 -16
- package/dist/actions.d.ts +30 -21
- package/dist/actions.js +628 -145
- package/dist/actions.js.map +1 -1
- package/dist/behavior/platformer-3d.d.ts +296 -0
- package/dist/behavior/platformer-3d.js +518 -0
- package/dist/behavior/platformer-3d.js.map +1 -0
- package/dist/behavior/ricochet-2d.d.ts +274 -0
- package/dist/behavior/ricochet-2d.js +394 -0
- package/dist/behavior/ricochet-2d.js.map +1 -0
- package/dist/behavior/screen-wrap.d.ts +86 -0
- package/dist/behavior/screen-wrap.js +195 -0
- package/dist/behavior/screen-wrap.js.map +1 -0
- package/dist/behavior/thruster.d.ts +10 -0
- package/dist/behavior/thruster.js +234 -0
- package/dist/behavior/thruster.js.map +1 -0
- package/dist/behavior/world-boundary-2d.d.ts +141 -0
- package/dist/behavior/world-boundary-2d.js +181 -0
- package/dist/behavior/world-boundary-2d.js.map +1 -0
- package/dist/behavior-descriptor-BWNWmIjv.d.ts +142 -0
- package/dist/{blueprints-BOCc3Wve.d.ts → blueprints-BWGz8fII.d.ts} +2 -2
- package/dist/camera-B5e4c78l.d.ts +468 -0
- package/dist/camera.d.ts +3 -2
- package/dist/camera.js +962 -166
- package/dist/camera.js.map +1 -1
- package/dist/composition-DrzFrbqI.d.ts +218 -0
- package/dist/{core-CZhozNRH.d.ts → core-DAkskq6Y.d.ts} +97 -65
- package/dist/core.d.ts +12 -6
- package/dist/core.js +4449 -1052
- package/dist/core.js.map +1 -1
- package/dist/{entities-BAxfJOkk.d.ts → entities-DC9ce_vx.d.ts} +154 -45
- package/dist/entities.d.ts +5 -2
- package/dist/entities.js +2505 -722
- package/dist/entities.js.map +1 -1
- package/dist/entity-BpbZqg19.d.ts +1100 -0
- package/dist/entity-types-DAu8sGJH.d.ts +26 -0
- package/dist/global-change-Dc8uCKi2.d.ts +25 -0
- package/dist/main.d.ts +472 -29
- package/dist/main.js +11877 -6124
- package/dist/main.js.map +1 -1
- package/dist/{stage-types-CD21XoIU.d.ts → stage-types-BFsm3qsZ.d.ts} +255 -26
- package/dist/stage.d.ts +11 -6
- package/dist/stage.js +3462 -491
- package/dist/stage.js.map +1 -1
- package/dist/thruster-DhRaJnoL.d.ts +172 -0
- package/dist/world-Be5m1XC1.d.ts +31 -0
- package/package.json +21 -4
- package/dist/behaviors.d.ts +0 -106
- package/dist/behaviors.js +0 -398
- package/dist/behaviors.js.map +0 -1
- package/dist/camera-CpbDr4-V.d.ts +0 -116
- package/dist/entity-COvRtFNG.d.ts +0 -395
- package/dist/moveable-B_vyA6cw.d.ts +0 -67
- package/dist/transformable-CUhvyuYO.d.ts +0 -67
|
@@ -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 };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Vector3 } from 'three';
|
|
2
|
-
import { RigidBody, Vector } from '@dimforge/rapier3d-compat';
|
|
3
|
-
|
|
4
|
-
interface EntityWithBody {
|
|
5
|
-
body: RigidBody | null;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Move entity based on a vector, adding to existing velocities
|
|
9
|
-
*/
|
|
10
|
-
declare function move(entity: EntityWithBody, vector: Vector3): void;
|
|
11
|
-
/**
|
|
12
|
-
* Reset entity velocity
|
|
13
|
-
*/
|
|
14
|
-
declare function resetVelocity(entity: EntityWithBody): void;
|
|
15
|
-
/**
|
|
16
|
-
* Enhanced moveable entity with bound methods
|
|
17
|
-
*/
|
|
18
|
-
interface MoveableEntity extends EntityWithBody {
|
|
19
|
-
moveX(delta: number): void;
|
|
20
|
-
moveY(delta: number): void;
|
|
21
|
-
moveZ(delta: number): void;
|
|
22
|
-
moveXY(deltaX: number, deltaY: number): void;
|
|
23
|
-
moveXZ(deltaX: number, deltaZ: number): void;
|
|
24
|
-
move(vector: Vector3): void;
|
|
25
|
-
resetVelocity(): void;
|
|
26
|
-
moveForwardXY(delta: number, rotation2DAngle: number): void;
|
|
27
|
-
getPosition(): Vector | null;
|
|
28
|
-
getVelocity(): Vector | null;
|
|
29
|
-
setPosition(x: number, y: number, z: number): void;
|
|
30
|
-
setPositionX(x: number): void;
|
|
31
|
-
setPositionY(y: number): void;
|
|
32
|
-
setPositionZ(z: number): void;
|
|
33
|
-
wrapAroundXY(boundsX: number, boundsY: number): void;
|
|
34
|
-
wrapAround3D(boundsX: number, boundsY: number, boundsZ: number): void;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Class decorator to enhance an entity with additive movement methods
|
|
38
|
-
*/
|
|
39
|
-
declare function moveable<T extends {
|
|
40
|
-
new (...args: any[]): EntityWithBody;
|
|
41
|
-
}>(constructor: T): {
|
|
42
|
-
new (...args: any[]): {
|
|
43
|
-
moveX(delta: number): void;
|
|
44
|
-
moveY(delta: number): void;
|
|
45
|
-
moveZ(delta: number): void;
|
|
46
|
-
moveXY(deltaX: number, deltaY: number): void;
|
|
47
|
-
moveXZ(deltaX: number, deltaZ: number): void;
|
|
48
|
-
move(vector: Vector3): void;
|
|
49
|
-
resetVelocity(): void;
|
|
50
|
-
moveForwardXY(delta: number, rotation2DAngle: number): void;
|
|
51
|
-
getPosition(): Vector | null;
|
|
52
|
-
getVelocity(): Vector | null;
|
|
53
|
-
setPosition(x: number, y: number, z: number): void;
|
|
54
|
-
setPositionX(x: number): void;
|
|
55
|
-
setPositionY(y: number): void;
|
|
56
|
-
setPositionZ(z: number): void;
|
|
57
|
-
wrapAroundXY(boundsX: number, boundsY: number): void;
|
|
58
|
-
wrapAround3D(boundsX: number, boundsY: number, boundsZ: number): void;
|
|
59
|
-
body: RigidBody | null;
|
|
60
|
-
};
|
|
61
|
-
} & T;
|
|
62
|
-
/**
|
|
63
|
-
* Enhance an entity with additive movement methods (retained for compatibility)
|
|
64
|
-
*/
|
|
65
|
-
declare function makeMoveable<T extends EntityWithBody>(entity: T): T & MoveableEntity;
|
|
66
|
-
|
|
67
|
-
export { type EntityWithBody as E, type MoveableEntity as M, moveable as a, move as b, makeMoveable as m, resetVelocity as r };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { E as EntityWithBody, M as MoveableEntity } from './moveable-B_vyA6cw.js';
|
|
2
|
-
import { Vector3 } from 'three';
|
|
3
|
-
import { RigidBody } from '@dimforge/rapier3d-compat';
|
|
4
|
-
|
|
5
|
-
interface RotatableEntity {
|
|
6
|
-
body: RigidBody | null;
|
|
7
|
-
group: any;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Rotate an entity in the direction of a movement vector
|
|
11
|
-
*/
|
|
12
|
-
declare function rotateInDirection(entity: RotatableEntity, moveVector: Vector3): void;
|
|
13
|
-
/**
|
|
14
|
-
* Rotatable entity API with bound methods
|
|
15
|
-
*/
|
|
16
|
-
interface RotatableEntityAPI extends RotatableEntity {
|
|
17
|
-
rotateInDirection(moveVector: Vector3): void;
|
|
18
|
-
rotateYEuler(amount: number): void;
|
|
19
|
-
rotateEuler(rotation: Vector3): void;
|
|
20
|
-
rotateY(delta: number): void;
|
|
21
|
-
rotateZ(delta: number): void;
|
|
22
|
-
setRotationY(y: number): void;
|
|
23
|
-
setRotationX(x: number): void;
|
|
24
|
-
setRotationZ(z: number): void;
|
|
25
|
-
setRotationDegrees(x: number, y: number, z: number): void;
|
|
26
|
-
setRotationDegreesY(y: number): void;
|
|
27
|
-
setRotationDegreesX(x: number): void;
|
|
28
|
-
setRotationDegreesZ(z: number): void;
|
|
29
|
-
setRotation(x: number, y: number, z: number): void;
|
|
30
|
-
getRotation(): any;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Class decorator to enhance an entity with rotatable methods
|
|
34
|
-
*/
|
|
35
|
-
declare function rotatable<T extends {
|
|
36
|
-
new (...args: any[]): RotatableEntity;
|
|
37
|
-
}>(constructor: T): {
|
|
38
|
-
new (...args: any[]): {
|
|
39
|
-
rotateInDirection(moveVector: Vector3): void;
|
|
40
|
-
rotateYEuler(amount: number): void;
|
|
41
|
-
rotateEuler(rotation: Vector3): void;
|
|
42
|
-
rotateY(delta: number): void;
|
|
43
|
-
rotateZ(delta: number): void;
|
|
44
|
-
setRotationY(y: number): void;
|
|
45
|
-
setRotationX(x: number): void;
|
|
46
|
-
setRotationZ(z: number): void;
|
|
47
|
-
setRotationDegrees(x: number, y: number, z: number): void;
|
|
48
|
-
setRotationDegreesY(y: number): void;
|
|
49
|
-
setRotationDegreesX(x: number): void;
|
|
50
|
-
setRotationDegreesZ(z: number): void;
|
|
51
|
-
setRotation(x: number, y: number, z: number): void;
|
|
52
|
-
getRotation(): any;
|
|
53
|
-
body: RigidBody | null;
|
|
54
|
-
group: any;
|
|
55
|
-
};
|
|
56
|
-
} & T;
|
|
57
|
-
/**
|
|
58
|
-
* Enhance an entity instance with rotatable methods
|
|
59
|
-
*/
|
|
60
|
-
declare function makeRotatable<T extends RotatableEntity>(entity: T): T & RotatableEntityAPI;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Enhance an entity with both movement and rotation capabilities.
|
|
64
|
-
*/
|
|
65
|
-
declare function makeTransformable<T extends RotatableEntity & EntityWithBody>(entity: T): T & MoveableEntity & RotatableEntityAPI;
|
|
66
|
-
|
|
67
|
-
export { makeTransformable as a, rotateInDirection as b, makeRotatable as m, rotatable as r };
|