@zylem/game-lib 0.6.4 → 0.7.0
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 +3 -1
- package/dist/actions.d.ts +255 -8
- package/dist/actions.js +1 -936
- package/dist/audio.d.ts +13 -0
- package/dist/audio.js +1 -0
- package/dist/base-node-life-cycle-CnJ-7zX-.d.ts +143 -0
- package/dist/behavior.d.ts +3 -0
- package/dist/behavior.js +1 -0
- package/dist/chunk-4QLJUQSJ.js +1 -0
- package/dist/chunk-73VZQZUL.js +1 -0
- package/dist/chunk-A34ZG3L4.js +1 -0
- package/dist/chunk-CDPY4VOQ.js +1 -0
- package/dist/chunk-DR6XXZE7.js +19 -0
- package/dist/chunk-FM5TBEPO.js +1 -0
- package/dist/chunk-G2IIMSUH.js +1 -0
- package/dist/chunk-MSC2BEO5.js +1 -0
- package/dist/chunk-NIH5CONO.js +1 -0
- package/dist/chunk-ONWXGBWB.js +1 -0
- package/dist/chunk-QEDQDR27.js +1 -0
- package/dist/chunk-QXVH6POE.js +1 -0
- package/dist/chunk-RXDTAWI2.js +29 -0
- package/dist/chunk-WKHW2QO2.js +1 -0
- package/dist/chunk-XRP4JJXL.js +1 -0
- package/dist/chunk-YHEWKN7N.js +1 -0
- package/dist/chunk-YHKXQ2ZN.js +1 -0
- package/dist/core.d.ts +206 -14
- package/dist/core.js +24 -12424
- package/dist/debug.d.ts +24 -0
- package/dist/debug.js +1 -0
- package/dist/default-controls-BGc61yYl.d.ts +111 -0
- package/dist/{entity-vj-HTjzU.d.ts → entity-DNkYKfdp.d.ts} +452 -578
- package/dist/entity-type-map-C94h2TDW.d.ts +781 -0
- package/dist/entity.d.ts +265 -0
- package/dist/entity.js +1 -0
- package/dist/events.d.ts +172 -0
- package/dist/events.js +1 -0
- package/dist/game-Cuj5gy7U.d.ts +1590 -0
- package/dist/game-default-PZLLHYL7.js +1 -0
- package/dist/game-interfaces-tfpM5NBk.d.ts +90 -0
- package/dist/globals.d.ts +104 -0
- package/dist/globals.js +1 -0
- package/dist/graphics.d.ts +83 -0
- package/dist/graphics.js +1 -0
- package/dist/input-ui.d.ts +34 -0
- package/dist/input-ui.js +1 -0
- package/dist/input.d.ts +72 -0
- package/dist/input.js +1 -0
- package/dist/material-Wz83vTTp.d.ts +151 -0
- package/dist/runtime.d.ts +433 -0
- package/dist/runtime.js +1 -0
- package/dist/web-components.d.ts +67 -0
- package/dist/web-components.js +9 -0
- package/dist/world-C9zdyl5d.d.ts +103 -0
- package/dist/{camera-4XO5gbQH.d.ts → zylem-stage-runtime-Cs-UDEVU.d.ts} +201 -329
- package/package.json +52 -63
- package/dist/actions.js.map +0 -1
- package/dist/behavior/jumper-2d.d.ts +0 -114
- package/dist/behavior/jumper-2d.js +0 -711
- package/dist/behavior/jumper-2d.js.map +0 -1
- package/dist/behavior/platformer-3d.d.ts +0 -296
- package/dist/behavior/platformer-3d.js +0 -761
- package/dist/behavior/platformer-3d.js.map +0 -1
- package/dist/behavior/ricochet-2d.d.ts +0 -275
- package/dist/behavior/ricochet-2d.js +0 -425
- package/dist/behavior/ricochet-2d.js.map +0 -1
- package/dist/behavior/ricochet-3d.d.ts +0 -117
- package/dist/behavior/ricochet-3d.js +0 -443
- package/dist/behavior/ricochet-3d.js.map +0 -1
- package/dist/behavior/screen-visibility.d.ts +0 -79
- package/dist/behavior/screen-visibility.js +0 -358
- package/dist/behavior/screen-visibility.js.map +0 -1
- package/dist/behavior/screen-wrap.d.ts +0 -87
- package/dist/behavior/screen-wrap.js +0 -246
- package/dist/behavior/screen-wrap.js.map +0 -1
- package/dist/behavior/shooter-2d.d.ts +0 -79
- package/dist/behavior/shooter-2d.js +0 -180
- package/dist/behavior/shooter-2d.js.map +0 -1
- package/dist/behavior/thruster.d.ts +0 -11
- package/dist/behavior/thruster.js +0 -292
- package/dist/behavior/thruster.js.map +0 -1
- package/dist/behavior/top-down-movement.d.ts +0 -56
- package/dist/behavior/top-down-movement.js +0 -125
- package/dist/behavior/top-down-movement.js.map +0 -1
- package/dist/behavior/world-boundary-2d.d.ts +0 -142
- package/dist/behavior/world-boundary-2d.js +0 -235
- package/dist/behavior/world-boundary-2d.js.map +0 -1
- package/dist/behavior/world-boundary-3d.d.ts +0 -76
- package/dist/behavior/world-boundary-3d.js +0 -274
- package/dist/behavior/world-boundary-3d.js.map +0 -1
- package/dist/behavior-descriptor-BXnVR8Ki.d.ts +0 -159
- package/dist/blueprints-DmbK2dki.d.ts +0 -26
- package/dist/camera.d.ts +0 -6
- package/dist/camera.js +0 -1993
- package/dist/camera.js.map +0 -1
- package/dist/composition-BASvMKrW.d.ts +0 -218
- package/dist/core-CARRaS55.d.ts +0 -541
- package/dist/core.js.map +0 -1
- package/dist/entities-ChFirVL9.d.ts +0 -410
- package/dist/entities.d.ts +0 -9
- package/dist/entities.js +0 -4986
- package/dist/entities.js.map +0 -1
- package/dist/entity-Bq_eNEDI.d.ts +0 -28
- package/dist/entity-types-DAu8sGJH.d.ts +0 -26
- package/dist/global-change-2JvMaz44.d.ts +0 -25
- package/dist/main.d.ts +0 -1353
- package/dist/main.js +0 -19525
- package/dist/main.js.map +0 -1
- package/dist/physics-pose-DCc4oE44.d.ts +0 -25
- package/dist/physics-protocol-BDD3P5W2.d.ts +0 -200
- package/dist/physics-worker.d.ts +0 -21
- package/dist/physics-worker.js +0 -306
- package/dist/physics-worker.js.map +0 -1
- package/dist/physics.d.ts +0 -205
- package/dist/physics.js +0 -577
- package/dist/physics.js.map +0 -1
- package/dist/stage-types-C19IhuzA.d.ts +0 -731
- package/dist/stage.d.ts +0 -52
- package/dist/stage.js +0 -8479
- package/dist/stage.js.map +0 -1
- package/dist/sync-state-machine-CZyspBpj.d.ts +0 -16
- package/dist/thruster-23lzoPZd.d.ts +0 -180
- package/dist/world-DfgxoNMt.d.ts +0 -105
package/README.md
CHANGED
|
@@ -39,7 +39,9 @@ npm install @zylem/game-lib
|
|
|
39
39
|
* the ball can be controlled with the arrow keys or gamepad
|
|
40
40
|
* the ball cannot go outside the boundaries
|
|
41
41
|
*/
|
|
42
|
-
import { createGame
|
|
42
|
+
import { createGame } from '@zylem/game-lib/core';
|
|
43
|
+
import { createSphere } from '@zylem/game-lib/entity';
|
|
44
|
+
import { WorldBoundary2DBehavior } from '@zylem/game-lib/behavior';
|
|
43
45
|
|
|
44
46
|
// Creates a sphere (movement capabilities are built-in)
|
|
45
47
|
const ball = createSphere();
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,12 +1,259 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
import { A as Action, G as GameEntity } from './entity-DNkYKfdp.js';
|
|
2
|
+
export { H as getRotation, t as rotateEuler, r as rotateInDirection, u as rotateX, v as rotateY, s as rotateYEuler, w as rotateZ, F as setRotation, B as setRotationDegrees, D as setRotationDegreesX, C as setRotationDegreesY, E as setRotationDegreesZ, y as setRotationX, x as setRotationY, z as setRotationZ } from './entity-DNkYKfdp.js';
|
|
3
|
+
import { Object3D } from 'three';
|
|
4
|
+
import { TransformState } from '@zylem/behaviors/core';
|
|
5
|
+
export { TransformState, createTransformStore, getPosition, getVelocity, move, moveForwardXY, moveX, moveXY, moveXZ, moveY, moveZ, resetTransformStore, resetVelocity, setPosition, setPositionX, setPositionY, setPositionZ, wrapAround3D, wrapAroundXY } from '@zylem/behaviors/core';
|
|
4
6
|
import { RigidBody } from '@dimforge/rapier3d-compat';
|
|
5
|
-
|
|
6
|
-
import 'three';
|
|
7
|
-
import '
|
|
7
|
+
import './material-Wz83vTTp.js';
|
|
8
|
+
import 'three/webgpu';
|
|
9
|
+
import './base-node-life-cycle-CnJ-7zX-.js';
|
|
10
|
+
import './events.js';
|
|
8
11
|
import 'mitt';
|
|
9
|
-
|
|
12
|
+
|
|
13
|
+
/** Minimal entity shape for opacity helpers (avoids GameEntity generic variance). */
|
|
14
|
+
type OpacityEntity = {
|
|
15
|
+
group?: Object3D | null;
|
|
16
|
+
mesh?: Object3D | null;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Sets opacity on every fadeable material under an entity's visual root.
|
|
20
|
+
*/
|
|
21
|
+
declare function resetEntityOpacity(entity: OpacityEntity, opacity?: number, transparent?: boolean): void;
|
|
22
|
+
interface MoveByOptions {
|
|
23
|
+
/** X displacement (default: 0) */
|
|
24
|
+
x?: number;
|
|
25
|
+
/** Y displacement (default: 0) */
|
|
26
|
+
y?: number;
|
|
27
|
+
/** Z displacement (default: 0) */
|
|
28
|
+
z?: number;
|
|
29
|
+
/** Duration in milliseconds */
|
|
30
|
+
duration: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Move an entity by a displacement over a duration.
|
|
34
|
+
* Distributes the movement as velocity each frame so physics stays in sync.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* entity.runAction(moveBy({ x: 10, duration: 500 }));
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare function moveBy(opts: MoveByOptions): Action;
|
|
42
|
+
interface MoveToOptions {
|
|
43
|
+
/** Target X position */
|
|
44
|
+
x: number;
|
|
45
|
+
/** Target Y position */
|
|
46
|
+
y: number;
|
|
47
|
+
/** Target Z position */
|
|
48
|
+
z: number;
|
|
49
|
+
/** Duration in milliseconds */
|
|
50
|
+
duration: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Move an entity to an absolute position over a duration.
|
|
54
|
+
* Calculates displacement from the entity's position on the first tick.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* entity.runAction(moveTo({ x: 0, y: 10, z: 0, duration: 2000 }));
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare function moveTo(opts: MoveToOptions): Action;
|
|
62
|
+
interface RotateByOptions {
|
|
63
|
+
/** X rotation in degrees (default: 0) */
|
|
64
|
+
x?: number;
|
|
65
|
+
/** Y rotation in degrees (default: 0) */
|
|
66
|
+
y?: number;
|
|
67
|
+
/** Z rotation in degrees (default: 0) */
|
|
68
|
+
z?: number;
|
|
69
|
+
/** Duration in milliseconds */
|
|
70
|
+
duration: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Rotate an entity by euler angles (degrees) over a duration.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* entity.runAction(rotateBy({ y: 360, duration: 2000 }));
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
declare function rotateBy(opts: RotateByOptions): Action;
|
|
81
|
+
/**
|
|
82
|
+
* Wait for a duration. Useful inside `sequence()`.
|
|
83
|
+
*
|
|
84
|
+
* @param ms Duration in milliseconds
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* entity.runAction(sequence(moveBy({ x: 5, duration: 1000 }), delay(500), moveBy({ y: 3, duration: 1000 })));
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare function delay(ms: number): Action;
|
|
91
|
+
/**
|
|
92
|
+
* Call a function immediately. Completes in one frame.
|
|
93
|
+
* Useful inside `sequence()` for side effects.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* entity.runAction(sequence(moveBy({ x: 5, duration: 1000 }), callFunc(() => console.log('done'))));
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
declare function callFunc(fn: () => void): Action;
|
|
101
|
+
interface FadeOpacityOptions {
|
|
102
|
+
/** Starting opacity (default: 1) */
|
|
103
|
+
from?: number;
|
|
104
|
+
/** Ending opacity (default: 0) */
|
|
105
|
+
to?: number;
|
|
106
|
+
/** Duration in milliseconds */
|
|
107
|
+
duration: number;
|
|
108
|
+
/** Optional Object3D roots to traverse; defaults to entity.group ?? entity.mesh */
|
|
109
|
+
targets?: Object3D[];
|
|
110
|
+
/** When complete and `to >= 1`, restore transparent=false on affected materials */
|
|
111
|
+
restoreOpaque?: boolean;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Fade material opacity on an entity (or explicit targets) over a duration.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* entity.runAction(fadeOpacity({ from: 0, to: 1, duration: 400, restoreOpaque: true }));
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
declare function fadeOpacity(opts: FadeOpacityOptions): Action;
|
|
122
|
+
|
|
123
|
+
interface ThrottleOptions {
|
|
124
|
+
/** Interval in milliseconds between ready cycles */
|
|
125
|
+
duration: number;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A repeating timer that becomes ready every N milliseconds.
|
|
129
|
+
* Register with `entity.action(throttle(...))`.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* const t = entity.action(throttle({ duration: 500 }));
|
|
134
|
+
* entity.onUpdate(() => {
|
|
135
|
+
* if (t.ready) { t.consume(); // do something every 500ms }
|
|
136
|
+
* });
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
declare function throttle(opts: ThrottleOptions): ThrottleAction;
|
|
140
|
+
declare class ThrottleAction implements Action {
|
|
141
|
+
readonly duration: number;
|
|
142
|
+
done: boolean;
|
|
143
|
+
persistent: boolean;
|
|
144
|
+
ready: boolean;
|
|
145
|
+
private elapsed;
|
|
146
|
+
/** @param durationMs Duration in milliseconds */
|
|
147
|
+
constructor(durationMs: number);
|
|
148
|
+
tick(_entity: GameEntity<any>, delta: number): void;
|
|
149
|
+
/** Consume the ready state and reset the timer */
|
|
150
|
+
consume(): void;
|
|
151
|
+
reset(): void;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Detects the rising edge of a boolean signal (press).
|
|
155
|
+
* Call `.check(isPressed)` each frame in your onUpdate; `.triggered` is
|
|
156
|
+
* true for one frame on press.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* const press = entity.action(onPress());
|
|
161
|
+
* entity.onUpdate(({ inputs }) => {
|
|
162
|
+
* press.check(inputs.p1.buttons.A.pressed);
|
|
163
|
+
* if (press.triggered) { // do something once on press }
|
|
164
|
+
* });
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare function onPress(): OnPressAction;
|
|
168
|
+
declare class OnPressAction implements Action {
|
|
169
|
+
readonly duration: number;
|
|
170
|
+
done: boolean;
|
|
171
|
+
persistent: boolean;
|
|
172
|
+
triggered: boolean;
|
|
173
|
+
private wasPressed;
|
|
174
|
+
tick(): void;
|
|
175
|
+
/**
|
|
176
|
+
* Feed the current pressed state. Sets `.triggered = true` on the
|
|
177
|
+
* frame where `isPressed` transitions from false to true.
|
|
178
|
+
*/
|
|
179
|
+
check(isPressed: boolean): void;
|
|
180
|
+
reset(): void;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Detects the falling edge of a boolean signal (release).
|
|
184
|
+
* Call `.check(isPressed)` each frame; `.triggered` is true for one frame
|
|
185
|
+
* on release.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* const release = entity.action(onRelease());
|
|
190
|
+
* entity.onUpdate(({ inputs }) => {
|
|
191
|
+
* release.check(inputs.p1.buttons.A.pressed);
|
|
192
|
+
* if (release.triggered) { // do something once on release }
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
declare function onRelease(): OnReleaseAction;
|
|
197
|
+
declare class OnReleaseAction implements Action {
|
|
198
|
+
readonly duration: number;
|
|
199
|
+
done: boolean;
|
|
200
|
+
persistent: boolean;
|
|
201
|
+
triggered: boolean;
|
|
202
|
+
private wasPressed;
|
|
203
|
+
tick(): void;
|
|
204
|
+
/**
|
|
205
|
+
* Feed the current pressed state. Sets `.triggered = true` on the
|
|
206
|
+
* frame where `isPressed` transitions from true to false.
|
|
207
|
+
*/
|
|
208
|
+
check(isPressed: boolean): void;
|
|
209
|
+
reset(): void;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Run actions in order, one after another.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* entity.runAction(sequence(
|
|
218
|
+
* moveBy({ x: 5, duration: 1000 }),
|
|
219
|
+
* delay(500),
|
|
220
|
+
* moveBy({ y: 3, duration: 1000 }),
|
|
221
|
+
* ));
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
declare function sequence(...actions: Action[]): Action;
|
|
225
|
+
/**
|
|
226
|
+
* Run all actions simultaneously. Done when all children are done.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* entity.runAction(parallel(
|
|
231
|
+
* moveBy({ x: 5, duration: 1000 }),
|
|
232
|
+
* rotateBy({ y: 360, duration: 1000 }),
|
|
233
|
+
* ));
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
declare function parallel(...actions: Action[]): Action;
|
|
237
|
+
/**
|
|
238
|
+
* Repeat an action a fixed number of times.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* entity.runAction(repeat(moveBy({ x: 2, duration: 500 }), 5));
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
declare function repeat(action: Action, times: number): Action;
|
|
246
|
+
/**
|
|
247
|
+
* Repeat an action forever. Never completes.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```ts
|
|
251
|
+
* enemy.runAction(repeatForever(
|
|
252
|
+
* sequence(moveBy({ x: 3, duration: 2000 }), moveBy({ x: -3, duration: 2000 })),
|
|
253
|
+
* ));
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
declare function repeatForever(action: Action): Action;
|
|
10
257
|
|
|
11
258
|
/**
|
|
12
259
|
* Entity that can have transformations applied from a store
|
|
@@ -31,4 +278,4 @@ interface TransformableEntity {
|
|
|
31
278
|
*/
|
|
32
279
|
declare function applyTransformChanges(entity: TransformableEntity, store: TransformState): void;
|
|
33
280
|
|
|
34
|
-
export {
|
|
281
|
+
export { Action, type FadeOpacityOptions, type MoveByOptions, type MoveToOptions, type OpacityEntity, type RotateByOptions, type ThrottleOptions, applyTransformChanges, callFunc, delay, fadeOpacity, moveBy, moveTo, onPress, onRelease, parallel, repeat, repeatForever, resetEntityOpacity, rotateBy, sequence, throttle };
|