@zylem/behaviors 0.3.0 → 0.4.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/LICENSE +21 -0
- package/dist/{behavior-system-DYbx-x_-.d.ts → behavior-system-DSNek0W9.d.ts} +205 -29
- package/dist/{chunk-RER2IDPW.js → chunk-4URF65BR.js} +1 -0
- package/dist/chunk-4URF65BR.js.map +1 -0
- package/dist/{chunk-YYJP62QD.js → chunk-4V7TIRO2.js} +1 -0
- package/dist/chunk-4V7TIRO2.js.map +1 -0
- package/dist/{chunk-F7E23E26.js → chunk-4WH2ZN7P.js} +1 -0
- package/dist/chunk-4WH2ZN7P.js.map +1 -0
- package/dist/{chunk-VPZ32CCD.js → chunk-5SM5SH5O.js} +29 -28
- package/dist/chunk-5SM5SH5O.js.map +1 -0
- package/dist/{chunk-L76JG73P.js → chunk-5XZWTFGF.js} +7 -4
- package/dist/chunk-5XZWTFGF.js.map +1 -0
- package/dist/{chunk-HIBJDA5Z.js → chunk-64HKCSXD.js} +21 -17
- package/dist/chunk-64HKCSXD.js.map +1 -0
- package/dist/{chunk-WSKD7GY3.js → chunk-7JJEIADR.js} +1 -0
- package/dist/chunk-7JJEIADR.js.map +1 -0
- package/dist/{chunk-F6LFX4V3.js → chunk-BXP4K7RF.js} +3 -2
- package/dist/chunk-BXP4K7RF.js.map +1 -0
- package/dist/{chunk-2HKY6WF7.js → chunk-EIWQM6U3.js} +1 -0
- package/dist/chunk-EIWQM6U3.js.map +1 -0
- package/dist/{chunk-YDLO5M7S.js → chunk-EZNCCO4L.js} +1 -0
- package/dist/chunk-EZNCCO4L.js.map +1 -0
- package/dist/{chunk-T2P4JTQN.js → chunk-FRJDQM23.js} +110 -155
- package/dist/chunk-FRJDQM23.js.map +1 -0
- package/dist/{chunk-FHDYJ5WP.js → chunk-FTDZAKZW.js} +5 -17
- package/dist/chunk-FTDZAKZW.js.map +1 -0
- package/dist/{chunk-D53GNZXP.js → chunk-GFARAJV2.js} +6 -7
- package/dist/chunk-GFARAJV2.js.map +1 -0
- package/dist/{chunk-IQRG5BAZ.js → chunk-GTLA6LOJ.js} +18 -23
- package/dist/chunk-GTLA6LOJ.js.map +1 -0
- package/dist/{chunk-VO5J64DG.js → chunk-H4TJ7X4O.js} +4 -6
- package/dist/chunk-H4TJ7X4O.js.map +1 -0
- package/dist/{chunk-6UMC6BB5.js → chunk-HNESASBB.js} +7 -8
- package/dist/chunk-HNESASBB.js.map +1 -0
- package/dist/{chunk-4DVDFCVY.js → chunk-HZMY3TT4.js} +1 -0
- package/dist/chunk-HZMY3TT4.js.map +1 -0
- package/dist/{chunk-2HLZBWGD.js → chunk-IZJFUAXB.js} +1 -0
- package/dist/chunk-IZJFUAXB.js.map +1 -0
- package/dist/{chunk-UFHYR2LV.js → chunk-JXMF4NUI.js} +51 -2
- package/dist/chunk-JXMF4NUI.js.map +1 -0
- package/dist/{chunk-ZHBD65AZ.js → chunk-KDY5N6J4.js} +1 -0
- package/dist/chunk-KDY5N6J4.js.map +1 -0
- package/dist/chunk-KFFETUAL.js +40 -0
- package/dist/chunk-KFFETUAL.js.map +1 -0
- package/dist/chunk-LL4FLHIY.js +12 -0
- package/dist/chunk-LL4FLHIY.js.map +1 -0
- package/dist/{chunk-BC3IJYS7.js → chunk-MJFMNRMZ.js} +15 -15
- package/dist/chunk-MJFMNRMZ.js.map +1 -0
- package/dist/{chunk-WHKPWIQO.js → chunk-OHCPV2NT.js} +1 -0
- package/dist/chunk-OHCPV2NT.js.map +1 -0
- package/dist/{chunk-RQWWUML4.js → chunk-OTLSUYQQ.js} +2 -1
- package/dist/chunk-OTLSUYQQ.js.map +1 -0
- package/dist/{chunk-E4HTCQPK.js → chunk-PWF757B6.js} +7 -8
- package/dist/chunk-PWF757B6.js.map +1 -0
- package/dist/{chunk-4EWASZHB.js → chunk-QVCMJ4Q2.js} +1 -0
- package/dist/chunk-QVCMJ4Q2.js.map +1 -0
- package/dist/{chunk-FOOM42MK.js → chunk-RONH2KDI.js} +12 -13
- package/dist/chunk-RONH2KDI.js.map +1 -0
- package/dist/chunk-RTRFJVCZ.js +454 -0
- package/dist/chunk-RTRFJVCZ.js.map +1 -0
- package/dist/{chunk-IEA7F73P.js → chunk-UL6Q5HDP.js} +25 -2
- package/dist/chunk-UL6Q5HDP.js.map +1 -0
- package/dist/{chunk-K6CWKFHL.js → chunk-UYFOLI2X.js} +1 -0
- package/dist/chunk-UYFOLI2X.js.map +1 -0
- package/dist/{chunk-RD2YTTXY.js → chunk-V74N7D6Q.js} +9 -8
- package/dist/chunk-V74N7D6Q.js.map +1 -0
- package/dist/{chunk-ERS6SNA5.js → chunk-WOMHL23C.js} +2 -1
- package/dist/chunk-WOMHL23C.js.map +1 -0
- package/dist/{chunk-RHW3IDQX.js → chunk-WWVD5DR5.js} +1 -0
- package/dist/chunk-WWVD5DR5.js.map +1 -0
- package/dist/{chunk-SBACY5SU.js → chunk-WXXXJ22R.js} +14 -15
- package/dist/chunk-WXXXJ22R.js.map +1 -0
- package/dist/{chunk-6Y3GB76J.js → chunk-XLUJDKCT.js} +9 -8
- package/dist/chunk-XLUJDKCT.js.map +1 -0
- package/dist/{chunk-7Y6JVZ5H.js → chunk-XP3ASVGJ.js} +14 -10
- package/dist/chunk-XP3ASVGJ.js.map +1 -0
- package/dist/{chunk-7U4WFBWM.js → chunk-Y7YIAWPW.js} +11 -0
- package/dist/chunk-Y7YIAWPW.js.map +1 -0
- package/dist/{chunk-7IZ36Y5G.js → chunk-ZA43LPRM.js} +5 -24
- package/dist/chunk-ZA43LPRM.js.map +1 -0
- package/dist/{chunk-J5XLB24H.js → chunk-ZRQWSURL.js} +3 -2
- package/dist/chunk-ZRQWSURL.js.map +1 -0
- package/dist/cooldown.d.ts +2 -1
- package/dist/cooldown.js +3 -2
- package/dist/cooldown.js.map +1 -0
- package/dist/coordinators/boundary-ricochet-3d.d.ts +12 -5
- package/dist/coordinators/boundary-ricochet-3d.js +4 -2
- package/dist/coordinators/boundary-ricochet-3d.js.map +1 -0
- package/dist/coordinators/boundary-ricochet.d.ts +9 -7
- package/dist/coordinators/boundary-ricochet.js +4 -2
- package/dist/coordinators/boundary-ricochet.js.map +1 -0
- package/dist/coordinators/first-person-shooter.d.ts +9 -8
- package/dist/coordinators/first-person-shooter.js +4 -3
- package/dist/coordinators/first-person-shooter.js.map +1 -0
- package/dist/coordinators/multidirectional-space-shooter.d.ts +12 -9
- package/dist/coordinators/multidirectional-space-shooter.js +5 -4
- package/dist/coordinators/multidirectional-space-shooter.js.map +1 -0
- package/dist/coordinators/top-down-shooter.d.ts +9 -8
- package/dist/coordinators/top-down-shooter.js +5 -4
- package/dist/coordinators/top-down-shooter.js.map +1 -0
- package/dist/core.d.ts +4 -4
- package/dist/core.js +9 -36
- package/dist/core.js.map +1 -0
- package/dist/destructible-3d.d.ts +2 -1
- package/dist/destructible-3d.js +4 -3
- package/dist/destructible-3d.js.map +1 -0
- package/dist/destructible-prebake.js +2 -1
- package/dist/destructible-prebake.js.map +1 -0
- package/dist/first-person.d.ts +12 -12
- package/dist/first-person.js +12 -11
- package/dist/first-person.js.map +1 -0
- package/dist/index.d.ts +37 -14
- package/dist/index.js +85 -55
- package/dist/index.js.map +1 -0
- package/dist/jumper-2d.d.ts +7 -6
- package/dist/jumper-2d.js +8 -7
- package/dist/jumper-2d.js.map +1 -0
- package/dist/jumper-3d.d.ts +12 -11
- package/dist/jumper-3d.js +9 -8
- package/dist/jumper-3d.js.map +1 -0
- package/dist/{moveable-BCRpjAQb.d.ts → moveable-BLTHO7Jq.d.ts} +2 -78
- package/dist/particle-emitter/presets.js +2 -1
- package/dist/particle-emitter/presets.js.map +1 -0
- package/dist/particle-emitter.d.ts +1 -1
- package/dist/particle-emitter.js +5 -4
- package/dist/particle-emitter.js.map +1 -0
- package/dist/platformer-2d.d.ts +306 -0
- package/dist/platformer-2d.js +23 -0
- package/dist/platformer-2d.js.map +1 -0
- package/dist/platformer-3d.d.ts +74 -87
- package/dist/platformer-3d.js +7 -6
- package/dist/platformer-3d.js.map +1 -0
- package/dist/ricochet-2d.d.ts +1 -1
- package/dist/ricochet-2d.js +5 -4
- package/dist/ricochet-2d.js.map +1 -0
- package/dist/ricochet-3d.d.ts +1 -1
- package/dist/ricochet-3d.js +5 -4
- package/dist/ricochet-3d.js.map +1 -0
- package/dist/runtime-2d.d.ts +93 -2
- package/dist/runtime-2d.js +146 -22
- package/dist/runtime-2d.js.map +1 -0
- package/dist/screen-visibility.d.ts +2 -1
- package/dist/screen-visibility.js +3 -2
- package/dist/screen-visibility.js.map +1 -0
- package/dist/screen-wrap.d.ts +2 -1
- package/dist/screen-wrap.js +5 -4
- package/dist/screen-wrap.js.map +1 -0
- package/dist/shooter-2d.d.ts +5 -3
- package/dist/shooter-2d.js +5 -4
- package/dist/shooter-2d.js.map +1 -0
- package/dist/shooter-fire-DGripl0z.d.ts +55 -0
- package/dist/thruster.d.ts +8 -18
- package/dist/thruster.js +9 -8
- package/dist/thruster.js.map +1 -0
- package/dist/top-down-movement.d.ts +7 -4
- package/dist/top-down-movement.js +8 -7
- package/dist/top-down-movement.js.map +1 -0
- package/dist/{use-behavior-D_82jAL3.d.ts → use-behavior-h9-T5FSv.d.ts} +1 -1
- package/dist/world-boundary-2d.d.ts +2 -1
- package/dist/world-boundary-2d.js +6 -5
- package/dist/world-boundary-2d.js.map +1 -0
- package/dist/world-boundary-3d.d.ts +2 -1
- package/dist/world-boundary-3d.js +6 -5
- package/dist/world-boundary-3d.js.map +1 -0
- package/package.json +8 -7
- package/dist/chunk-23HQH3GJ.js +0 -34
- package/dist/chunk-K4UBXSZL.js +0 -175
- package/dist/runtime-pong.d.ts +0 -92
- package/dist/runtime-pong.js +0 -37
package/dist/platformer-3d.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { S as SyncStateMachine } from './sync-state-machine-CZyspBpj.js';
|
|
2
|
-
import {
|
|
2
|
+
import { RigidBody, Collider } from '@dimforge/rapier3d-compat';
|
|
3
|
+
import { Z as ZylemWorld, a as BehaviorDescriptor } from './behavior-system-DSNek0W9.js';
|
|
3
4
|
import 'typescript-fsm';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -19,8 +20,6 @@ interface Platformer3DMovementComponent {
|
|
|
19
20
|
maxJumps: number;
|
|
20
21
|
/** Gravity force (optional override) */
|
|
21
22
|
gravity: number;
|
|
22
|
-
/** Ray length for ground detection */
|
|
23
|
-
groundRayLength: number;
|
|
24
23
|
/** Coyote time in seconds (grace period after leaving ground) */
|
|
25
24
|
coyoteTime: number;
|
|
26
25
|
/** Jump buffer time in seconds (queue jump input before landing) */
|
|
@@ -29,8 +28,19 @@ interface Platformer3DMovementComponent {
|
|
|
29
28
|
jumpCutMultiplier: number;
|
|
30
29
|
/** Time in seconds before multi-jump becomes available (0 = after button release) */
|
|
31
30
|
multiJumpWindowTime: number;
|
|
32
|
-
/**
|
|
33
|
-
|
|
31
|
+
/** Maximum slope angle (degrees) the character can walk up */
|
|
32
|
+
slopeClimbAngle: number;
|
|
33
|
+
/** Slope angle (degrees) past which the character slides down */
|
|
34
|
+
slopeSlideAngle: number;
|
|
35
|
+
/** Autostep configuration for small ledges, or false to disable */
|
|
36
|
+
autostep: {
|
|
37
|
+
maxHeight: number;
|
|
38
|
+
minWidth: number;
|
|
39
|
+
} | false;
|
|
40
|
+
/** Snap-to-ground distance (keeps the character glued going downhill) */
|
|
41
|
+
snapToGroundDistance: number;
|
|
42
|
+
/** Character controller offset (small gap kept between collider and environment) */
|
|
43
|
+
characterOffset: number;
|
|
34
44
|
}
|
|
35
45
|
declare function createPlatformer3DMovementComponent(options?: Partial<Platformer3DMovementComponent>): Platformer3DMovementComponent;
|
|
36
46
|
interface Platformer3DInputComponent {
|
|
@@ -81,10 +91,14 @@ interface Platformer3DStateComponent {
|
|
|
81
91
|
timeSinceJump: number;
|
|
82
92
|
/** True for the single frame on which a jump impulse was applied; prevents gravity from clobbering jump velocity. */
|
|
83
93
|
jumpedThisFrame: boolean;
|
|
84
|
-
/** Remaining seconds of jump-cut velocity ramp; while > 0,
|
|
94
|
+
/** Remaining seconds of jump-cut velocity ramp; while > 0, verticalVelocity lerps toward verticalVelocity * jumpCutMultiplier. */
|
|
85
95
|
jumpCutRampTimer: number;
|
|
86
|
-
/**
|
|
87
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Controller-owned vertical velocity (units/second).
|
|
98
|
+
* The body is kinematic, so `linvel()` is meaningless — this field is the
|
|
99
|
+
* single source of truth for jump/gravity motion on the Y axis.
|
|
100
|
+
*/
|
|
101
|
+
verticalVelocity: number;
|
|
88
102
|
}
|
|
89
103
|
declare function createPlatformer3DStateComponent(): Platformer3DStateComponent;
|
|
90
104
|
|
|
@@ -175,18 +189,22 @@ declare class Platformer3DFSM {
|
|
|
175
189
|
}
|
|
176
190
|
|
|
177
191
|
/**
|
|
178
|
-
* Platformer 3D
|
|
192
|
+
* Platformer 3D System
|
|
179
193
|
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
* -
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* -
|
|
194
|
+
* Kinematic character controller (N64-style): the controller owns all motion
|
|
195
|
+
* and physics is only a collision database.
|
|
196
|
+
*
|
|
197
|
+
* - The entity's body is converted to `KinematicPositionBased` on first
|
|
198
|
+
* update; Rapier never applies forces to it.
|
|
199
|
+
* - Each tick, desired displacement (horizontal input + integrated vertical
|
|
200
|
+
* velocity) is run through Rapier's `KinematicCharacterController`
|
|
201
|
+
* (collide-and-slide with autostep, slope limits, and snap-to-ground) and
|
|
202
|
+
* the corrected movement is applied via `setNextKinematicTranslation`.
|
|
203
|
+
* - Grounded comes from `controller.computedGrounded()` — no contact-pair or
|
|
204
|
+
* raycast probing.
|
|
205
|
+
* - Vertical velocity lives in `state.verticalVelocity` (`linvel()` is
|
|
206
|
+
* meaningless on kinematic bodies). Jump buffering, coyote time,
|
|
207
|
+
* multi-jump, and the jump-cut ramp all operate on that field.
|
|
190
208
|
*/
|
|
191
209
|
|
|
192
210
|
/**
|
|
@@ -194,94 +212,54 @@ declare class Platformer3DFSM {
|
|
|
194
212
|
*/
|
|
195
213
|
interface Platformer3DEntity {
|
|
196
214
|
uuid: string;
|
|
197
|
-
body:
|
|
215
|
+
body: RigidBody;
|
|
216
|
+
collider?: Collider | null;
|
|
198
217
|
platformer: Platformer3DMovementComponent;
|
|
199
218
|
$platformer: Platformer3DInputComponent;
|
|
200
219
|
platformerState: Platformer3DStateComponent;
|
|
201
|
-
transformStore?: any;
|
|
202
220
|
}
|
|
203
221
|
/**
|
|
204
|
-
* Platformer 3D
|
|
222
|
+
* Platformer 3D movement system.
|
|
205
223
|
*
|
|
206
|
-
* Core
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* collider (`world.contactsWith` + `contactPair`). This eliminates the old
|
|
210
|
-
* shape/ray probe and aligns "grounded" with the same surface the body
|
|
211
|
-
* physically rests on, which removes the jitter that happened on heightmap
|
|
212
|
-
* terrain (the probe and the contact resolver could disagree by a frame).
|
|
224
|
+
* Core kinematic controller for 3D platformer movement. Requires a live
|
|
225
|
+
* `ZylemWorld` with the raw Rapier `World` exposed on `.world` — without it
|
|
226
|
+
* the system is a no-op (the WASM fast path handles that case upstream).
|
|
213
227
|
*/
|
|
214
|
-
declare class
|
|
228
|
+
declare class Platformer3DSystem {
|
|
215
229
|
private world;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
* `applyGravity` is the sole writer of vertical velocity. We do this
|
|
220
|
-
* lazily on the first update because the body isn't always available at
|
|
221
|
-
* construction time.
|
|
222
|
-
*/
|
|
223
|
-
private gravityConfiguredUUIDs;
|
|
224
|
-
constructor(world: any, scene: any);
|
|
230
|
+
/** Per-entity character controllers, keyed by entity uuid. */
|
|
231
|
+
private controllers;
|
|
232
|
+
constructor(world: ZylemWorld | null);
|
|
225
233
|
/**
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
* deliberately don't filter by normal direction: the contact point's
|
|
231
|
-
* position alone is robust against the various normal-flip conventions
|
|
232
|
-
* Rapier uses for `flipped` manifolds and against rolling-bottom edges
|
|
233
|
-
* on heightmap terrain.
|
|
234
|
-
*/
|
|
235
|
-
private detectGroundedFromContacts;
|
|
236
|
-
/**
|
|
237
|
-
* One-time per-entity physics setup: take over gravity from Rapier's
|
|
238
|
-
* world so that `applyGravity` controls the entire airborne fall curve.
|
|
239
|
-
* Without this, gravity was effectively doubled (Rapier's world gravity
|
|
240
|
-
* + this behavior's explicit gravity were both pulling the body down).
|
|
234
|
+
* One-time per-entity physics setup: convert the body to a
|
|
235
|
+
* position-based kinematic body and create its character controller.
|
|
236
|
+
* Done lazily on the first update because the body isn't always
|
|
237
|
+
* available at construction time.
|
|
241
238
|
*/
|
|
242
239
|
private ensurePhysicsConfigured;
|
|
243
240
|
/**
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
* Only writes X/Z axes — Y is left untouched so Rapier's contact resolution
|
|
247
|
-
* can damp vertical motion correctly while grounded. Jump and gravity are
|
|
248
|
-
* the sole writers of Y velocity (see handleJump / applyGravity).
|
|
249
|
-
*/
|
|
250
|
-
private applyMovement;
|
|
251
|
-
/**
|
|
252
|
-
* Handle jump logic with multi-jump, coyote time, buffering, and jump-cut ramp.
|
|
241
|
+
* Handle jump logic with multi-jump, coyote time, buffering, and jump-cut
|
|
242
|
+
* ramp. All vertical motion is written to `state.verticalVelocity`.
|
|
253
243
|
*/
|
|
254
244
|
private handleJump;
|
|
255
245
|
/**
|
|
256
|
-
*
|
|
246
|
+
* Integrate gravity into `state.verticalVelocity`.
|
|
257
247
|
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
248
|
+
* While grounded (and not on the jump frame) vertical velocity is held at
|
|
249
|
+
* a small constant downward speed so the controller stays pressed into
|
|
250
|
+
* the ground. Skipped entirely on the frame a jump was applied — the
|
|
251
|
+
* grounded flag is still stale-true then and would clobber the jump.
|
|
262
252
|
*/
|
|
263
253
|
private applyGravity;
|
|
264
254
|
/**
|
|
265
|
-
* Update entity state
|
|
266
|
-
*
|
|
267
|
-
* Grounded is determined purely by Rapier's contact pairs on the entity's
|
|
268
|
-
* collider. This removes a whole class of slope/heightmap jitter caused
|
|
269
|
-
* by the previous shape probe disagreeing with the contact resolver — the
|
|
270
|
-
* probe could report grounded while a contact impulse had just nudged the
|
|
271
|
-
* body off the ground, producing visible micro-bouncing.
|
|
272
|
-
*
|
|
273
|
-
* While grounded, vertical velocity is held at 0 each frame. This stops
|
|
274
|
-
* residual upward kicks from slope-contact resolution from accumulating
|
|
275
|
-
* across frames (which previously caused the character to "ride up"
|
|
276
|
-
* slopes and lose contact briefly, then fall back, then re-contact, in a
|
|
277
|
-
* tight oscillation).
|
|
255
|
+
* Update entity state from the controller's grounded result.
|
|
278
256
|
*/
|
|
279
257
|
private updateState;
|
|
280
258
|
/**
|
|
281
259
|
* Update one platformer entity. Invoked per linked entity by the
|
|
282
260
|
* Platformer3DBehaviorSystem adapter.
|
|
283
261
|
*/
|
|
284
|
-
updateEntity(entity:
|
|
262
|
+
updateEntity(entity: Platformer3DEntity, delta: number): void;
|
|
285
263
|
destroy(): void;
|
|
286
264
|
}
|
|
287
265
|
|
|
@@ -299,10 +277,19 @@ interface Platformer3DBehaviorOptions {
|
|
|
299
277
|
maxJumps?: number;
|
|
300
278
|
/** Gravity force (default: 9.82) */
|
|
301
279
|
gravity?: number;
|
|
302
|
-
/**
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
|
|
280
|
+
/** Maximum slope angle in degrees the character can walk up (default: 50) */
|
|
281
|
+
slopeClimbAngle?: number;
|
|
282
|
+
/** Slope angle in degrees past which the character slides (default: 40) */
|
|
283
|
+
slopeSlideAngle?: number;
|
|
284
|
+
/** Autostep over small ledges, or false to disable (default: { maxHeight: 0.3, minWidth: 0.1 }) */
|
|
285
|
+
autostep?: {
|
|
286
|
+
maxHeight: number;
|
|
287
|
+
minWidth: number;
|
|
288
|
+
} | false;
|
|
289
|
+
/** Snap-to-ground distance for downhill/step-down stability (default: 0.3) */
|
|
290
|
+
snapToGroundDistance?: number;
|
|
291
|
+
/** Character controller collision offset (default: 0.05) */
|
|
292
|
+
characterOffset?: number;
|
|
306
293
|
}
|
|
307
294
|
/**
|
|
308
295
|
* Platformer3DBehavior - typed descriptor for 3D platformer movement
|
|
@@ -344,4 +331,4 @@ declare const Platformer3DBehavior: BehaviorDescriptor<Platformer3DBehaviorOptio
|
|
|
344
331
|
onPlatformCollision: (ctx: PlatformerCollisionContext) => void;
|
|
345
332
|
}, Platformer3DEntity>;
|
|
346
333
|
|
|
347
|
-
export { Platformer3DBehavior, type Platformer3DBehaviorOptions, type Platformer3DContext, type Platformer3DEntity, Platformer3DEvent, Platformer3DFSM, type Platformer3DInputComponent,
|
|
334
|
+
export { Platformer3DBehavior, type Platformer3DBehaviorOptions, type Platformer3DContext, type Platformer3DEntity, Platformer3DEvent, Platformer3DFSM, type Platformer3DInputComponent, type Platformer3DMovementComponent, Platformer3DState, type Platformer3DStateComponent, Platformer3DSystem, type PlatformerCollisionContext, createPlatformer3DInputComponent, createPlatformer3DMovementComponent, createPlatformer3DStateComponent };
|
package/dist/platformer-3d.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Platformer3DBehavior,
|
|
3
|
-
Platformer3DBehavior2,
|
|
4
3
|
Platformer3DEvent,
|
|
5
4
|
Platformer3DFSM,
|
|
6
5
|
Platformer3DState,
|
|
6
|
+
Platformer3DSystem,
|
|
7
7
|
createPlatformer3DInputComponent,
|
|
8
8
|
createPlatformer3DMovementComponent,
|
|
9
9
|
createPlatformer3DStateComponent
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-FRJDQM23.js";
|
|
11
|
+
import "./chunk-4URF65BR.js";
|
|
12
|
+
import "./chunk-EZNCCO4L.js";
|
|
13
13
|
export {
|
|
14
|
-
|
|
14
|
+
Platformer3DBehavior,
|
|
15
15
|
Platformer3DEvent,
|
|
16
16
|
Platformer3DFSM,
|
|
17
|
-
Platformer3DBehavior as Platformer3DMovementBehavior,
|
|
18
17
|
Platformer3DState,
|
|
18
|
+
Platformer3DSystem,
|
|
19
19
|
createPlatformer3DInputComponent,
|
|
20
20
|
createPlatformer3DMovementComponent,
|
|
21
21
|
createPlatformer3DStateComponent
|
|
22
22
|
};
|
|
23
|
+
//# sourceMappingURL=platformer-3d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/ricochet-2d.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { B as BaseEntityInterface } from './entity-types-CmtQ-IBp.js';
|
|
2
2
|
import { S as SyncStateMachine } from './sync-state-machine-CZyspBpj.js';
|
|
3
|
-
import { a as BehaviorDescriptor } from './behavior-system-
|
|
3
|
+
import { a as BehaviorDescriptor } from './behavior-system-DSNek0W9.js';
|
|
4
4
|
import 'three';
|
|
5
5
|
import '@dimforge/rapier3d-compat';
|
|
6
6
|
import 'typescript-fsm';
|
package/dist/ricochet-2d.js
CHANGED
|
@@ -3,13 +3,14 @@ import {
|
|
|
3
3
|
Ricochet2DEvent,
|
|
4
4
|
Ricochet2DFSM,
|
|
5
5
|
Ricochet2DState
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-V74N7D6Q.js";
|
|
7
|
+
import "./chunk-4V7TIRO2.js";
|
|
8
|
+
import "./chunk-4URF65BR.js";
|
|
9
|
+
import "./chunk-EZNCCO4L.js";
|
|
10
10
|
export {
|
|
11
11
|
Ricochet2DBehavior,
|
|
12
12
|
Ricochet2DEvent,
|
|
13
13
|
Ricochet2DFSM,
|
|
14
14
|
Ricochet2DState
|
|
15
15
|
};
|
|
16
|
+
//# sourceMappingURL=ricochet-2d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/ricochet-3d.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S as SyncStateMachine } from './sync-state-machine-CZyspBpj.js';
|
|
2
2
|
import { B as BaseEntityInterface } from './entity-types-CmtQ-IBp.js';
|
|
3
|
-
import { a as BehaviorDescriptor } from './behavior-system-
|
|
3
|
+
import { a as BehaviorDescriptor } from './behavior-system-DSNek0W9.js';
|
|
4
4
|
import 'typescript-fsm';
|
|
5
5
|
import 'three';
|
|
6
6
|
import '@dimforge/rapier3d-compat';
|
package/dist/ricochet-3d.js
CHANGED
|
@@ -3,13 +3,14 @@ import {
|
|
|
3
3
|
Ricochet3DEvent,
|
|
4
4
|
Ricochet3DFSM,
|
|
5
5
|
Ricochet3DState
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-XLUJDKCT.js";
|
|
7
|
+
import "./chunk-4V7TIRO2.js";
|
|
8
|
+
import "./chunk-4URF65BR.js";
|
|
9
|
+
import "./chunk-EZNCCO4L.js";
|
|
10
10
|
export {
|
|
11
11
|
Ricochet3DBehavior,
|
|
12
12
|
Ricochet3DEvent,
|
|
13
13
|
Ricochet3DFSM,
|
|
14
14
|
Ricochet3DState
|
|
15
15
|
};
|
|
16
|
+
//# sourceMappingURL=ricochet-3d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/runtime-2d.d.ts
CHANGED
|
@@ -1,2 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
1
|
+
import { a as BehaviorDescriptor, d as BehaviorRef } from './behavior-system-DSNek0W9.js';
|
|
2
|
+
import '@dimforge/rapier3d-compat';
|
|
3
|
+
|
|
4
|
+
interface RuntimeDynamicCircleBody2DOptions {
|
|
5
|
+
initialVelocity: readonly [number, number];
|
|
6
|
+
}
|
|
7
|
+
interface RuntimeDynamicCircleBody2DHandle {
|
|
8
|
+
setRuntimePosition(x: number, y: number, z?: number): void;
|
|
9
|
+
setRuntimeVelocity(x: number, y: number): void;
|
|
10
|
+
getRuntimePosition(): {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
z: number;
|
|
14
|
+
} | null;
|
|
15
|
+
}
|
|
16
|
+
interface RuntimePlayerInput2DOptions {
|
|
17
|
+
player: 'p1' | 'p2';
|
|
18
|
+
speed: number;
|
|
19
|
+
}
|
|
20
|
+
interface RuntimeBoundary2DOptions {
|
|
21
|
+
boundaries: {
|
|
22
|
+
left: number;
|
|
23
|
+
right: number;
|
|
24
|
+
bottom: number;
|
|
25
|
+
top: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
interface RuntimeRicochet2DOptions {
|
|
29
|
+
minSpeed: number;
|
|
30
|
+
maxSpeed: number;
|
|
31
|
+
speedMultiplier: number;
|
|
32
|
+
reflectionMode: 'simple' | 'angled';
|
|
33
|
+
maxAngleDeg: number;
|
|
34
|
+
}
|
|
35
|
+
interface RuntimeRicochet2DEvent {
|
|
36
|
+
kind: 'wall' | 'paddle';
|
|
37
|
+
}
|
|
38
|
+
interface RuntimeRicochet2DHandle {
|
|
39
|
+
onRicochet(callback: (event: RuntimeRicochet2DEvent) => void): () => void;
|
|
40
|
+
}
|
|
41
|
+
/** Registers a gameplay2d trigger AABB (sensor); wasm reports overlap via {@link emitRuntimeTriggerRegionEnter}. */
|
|
42
|
+
interface RuntimeTriggerRegion2DOptions {
|
|
43
|
+
triggerId: number;
|
|
44
|
+
halfExtents: readonly [number, number];
|
|
45
|
+
}
|
|
46
|
+
interface RuntimeTriggerRegion2DEvent {
|
|
47
|
+
triggerId: number;
|
|
48
|
+
}
|
|
49
|
+
interface RuntimeTriggerRegion2DHandle {
|
|
50
|
+
onRegionEnter(callback: (event: RuntimeTriggerRegion2DEvent) => void): () => void;
|
|
51
|
+
}
|
|
52
|
+
interface RuntimeGoalZone2DOptions {
|
|
53
|
+
scorer: 'p1' | 'p2';
|
|
54
|
+
}
|
|
55
|
+
interface RuntimeGoalZone2DEvent {
|
|
56
|
+
scorer: 'p1' | 'p2';
|
|
57
|
+
}
|
|
58
|
+
interface RuntimeGoalZone2DHandle {
|
|
59
|
+
onGoal(callback: (event: RuntimeGoalZone2DEvent) => void): () => void;
|
|
60
|
+
}
|
|
61
|
+
declare const RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY: unique symbol;
|
|
62
|
+
declare const RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY: unique symbol;
|
|
63
|
+
declare const RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY: unique symbol;
|
|
64
|
+
declare const RUNTIME_RICOCHET_2D_BEHAVIOR_KEY: unique symbol;
|
|
65
|
+
declare const RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY: unique symbol;
|
|
66
|
+
declare const RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY: unique symbol;
|
|
67
|
+
declare const RuntimeDynamicCircleBody2DBehavior: BehaviorDescriptor<RuntimeDynamicCircleBody2DOptions, RuntimeDynamicCircleBody2DHandle, unknown>;
|
|
68
|
+
declare const RuntimePlayerInput2DBehavior: BehaviorDescriptor<RuntimePlayerInput2DOptions, Record<string, never>, unknown>;
|
|
69
|
+
declare const RuntimeBoundary2DBehavior: BehaviorDescriptor<{
|
|
70
|
+
boundaries: {
|
|
71
|
+
left: number;
|
|
72
|
+
right: number;
|
|
73
|
+
bottom: number;
|
|
74
|
+
top: number;
|
|
75
|
+
};
|
|
76
|
+
}, Record<string, never>, unknown>;
|
|
77
|
+
declare const RuntimeRicochet2DBehavior: BehaviorDescriptor<RuntimeRicochet2DOptions, RuntimeRicochet2DHandle, unknown>;
|
|
78
|
+
declare const RuntimeTriggerRegion2DBehavior: BehaviorDescriptor<RuntimeTriggerRegion2DOptions, RuntimeTriggerRegion2DHandle, unknown>;
|
|
79
|
+
declare const RuntimeGoalZone2DBehavior: BehaviorDescriptor<RuntimeGoalZone2DOptions, RuntimeGoalZone2DHandle, unknown>;
|
|
80
|
+
declare function emitRuntimeRicochet(ref: BehaviorRef<RuntimeRicochet2DOptions>, event: RuntimeRicochet2DEvent): void;
|
|
81
|
+
declare function emitRuntimeTriggerRegionEnter(ref: BehaviorRef<RuntimeTriggerRegion2DOptions>, event: RuntimeTriggerRegion2DEvent): void;
|
|
82
|
+
declare function emitRuntimeGoal(ref: BehaviorRef<RuntimeGoalZone2DOptions>, event: RuntimeGoalZone2DEvent): void;
|
|
83
|
+
declare function bindRuntimeDynamicCircleBody2DHandle(ref: BehaviorRef<RuntimeDynamicCircleBody2DOptions>, controls: {
|
|
84
|
+
setPosition: (x: number, y: number, z: number) => void;
|
|
85
|
+
setVelocity: (x: number, y: number) => void;
|
|
86
|
+
getPosition: () => {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
z: number;
|
|
90
|
+
} | null;
|
|
91
|
+
}): void;
|
|
92
|
+
|
|
93
|
+
export { RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY, RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY, RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY, RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY, RUNTIME_RICOCHET_2D_BEHAVIOR_KEY, RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY, RuntimeBoundary2DBehavior, type RuntimeBoundary2DOptions, RuntimeDynamicCircleBody2DBehavior, type RuntimeDynamicCircleBody2DHandle, type RuntimeDynamicCircleBody2DOptions, RuntimeGoalZone2DBehavior, type RuntimeGoalZone2DEvent, type RuntimeGoalZone2DHandle, type RuntimeGoalZone2DOptions, RuntimePlayerInput2DBehavior, type RuntimePlayerInput2DOptions, RuntimeRicochet2DBehavior, type RuntimeRicochet2DEvent, type RuntimeRicochet2DHandle, type RuntimeRicochet2DOptions, RuntimeTriggerRegion2DBehavior, type RuntimeTriggerRegion2DEvent, type RuntimeTriggerRegion2DHandle, type RuntimeTriggerRegion2DOptions, bindRuntimeDynamicCircleBody2DHandle, emitRuntimeGoal, emitRuntimeRicochet, emitRuntimeTriggerRegionEnter };
|
package/dist/runtime-2d.js
CHANGED
|
@@ -1,31 +1,155 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
defineBehavior
|
|
3
|
+
} from "./chunk-EZNCCO4L.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/behaviors/runtime-2d/runtime-2d.descriptor.ts
|
|
6
|
+
var runtimeNoopSystemFactory = () => ({
|
|
7
|
+
update(_ecs, _delta) {
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
var RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-dynamic-circle-body-2d");
|
|
11
|
+
var RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-player-input-2d");
|
|
12
|
+
var RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-boundary-2d");
|
|
13
|
+
var RUNTIME_RICOCHET_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-ricochet-2d");
|
|
14
|
+
var RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-trigger-region-2d");
|
|
15
|
+
var RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-goal-zone-2d");
|
|
16
|
+
var RICOCHET_LISTENERS = /* @__PURE__ */ Symbol("runtime-ricochet-listeners");
|
|
17
|
+
var TRIGGER_REGION_LISTENERS = /* @__PURE__ */ Symbol("runtime-trigger-region-listeners");
|
|
18
|
+
var GOAL_LISTENERS = /* @__PURE__ */ Symbol("runtime-goal-listeners");
|
|
19
|
+
var CIRCLE_BODY_SET_POSITION = /* @__PURE__ */ Symbol("runtime-circle-body-set-position");
|
|
20
|
+
var CIRCLE_BODY_SET_VELOCITY = /* @__PURE__ */ Symbol("runtime-circle-body-set-velocity");
|
|
21
|
+
var CIRCLE_BODY_GET_POSITION = /* @__PURE__ */ Symbol("runtime-circle-body-get-position");
|
|
22
|
+
function getListeners(ref, slot) {
|
|
23
|
+
let listeners = ref[slot];
|
|
24
|
+
if (!listeners) {
|
|
25
|
+
listeners = [];
|
|
26
|
+
ref[slot] = listeners;
|
|
27
|
+
}
|
|
28
|
+
return listeners;
|
|
29
|
+
}
|
|
30
|
+
function addListener(ref, slot, callback) {
|
|
31
|
+
const listeners = getListeners(ref, slot);
|
|
32
|
+
listeners.push(callback);
|
|
33
|
+
return () => {
|
|
34
|
+
const index = listeners.indexOf(callback);
|
|
35
|
+
if (index >= 0) {
|
|
36
|
+
listeners.splice(index, 1);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function emit(ref, slot, event) {
|
|
41
|
+
const listeners = ref[slot];
|
|
42
|
+
if (!listeners) return;
|
|
43
|
+
for (const listener of listeners) {
|
|
44
|
+
listener(event);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
var RuntimeDynamicCircleBody2DBehavior = defineBehavior({
|
|
48
|
+
name: "runtime-dynamic-circle-body-2d",
|
|
49
|
+
defaultOptions: {
|
|
50
|
+
initialVelocity: [0, 0]
|
|
51
|
+
},
|
|
52
|
+
systemFactory: runtimeNoopSystemFactory,
|
|
53
|
+
createHandle: (ref) => ({
|
|
54
|
+
setRuntimePosition(x, y, z = 0) {
|
|
55
|
+
const callback = ref[CIRCLE_BODY_SET_POSITION];
|
|
56
|
+
callback?.(x, y, z);
|
|
57
|
+
},
|
|
58
|
+
setRuntimeVelocity(x, y) {
|
|
59
|
+
const callback = ref[CIRCLE_BODY_SET_VELOCITY];
|
|
60
|
+
callback?.(x, y);
|
|
61
|
+
},
|
|
62
|
+
getRuntimePosition() {
|
|
63
|
+
const callback = ref[CIRCLE_BODY_GET_POSITION];
|
|
64
|
+
return callback?.() ?? null;
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
var RuntimePlayerInput2DBehavior = defineBehavior({
|
|
69
|
+
name: "runtime-player-input-2d",
|
|
70
|
+
defaultOptions: {
|
|
71
|
+
player: "p1",
|
|
72
|
+
speed: 5
|
|
73
|
+
},
|
|
74
|
+
systemFactory: runtimeNoopSystemFactory
|
|
75
|
+
});
|
|
76
|
+
var RuntimeBoundary2DBehavior = defineBehavior({
|
|
77
|
+
name: "runtime-boundary-2d",
|
|
78
|
+
defaultOptions: {
|
|
79
|
+
boundaries: {
|
|
80
|
+
left: 0,
|
|
81
|
+
right: 0,
|
|
82
|
+
bottom: 0,
|
|
83
|
+
top: 0
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
systemFactory: runtimeNoopSystemFactory
|
|
87
|
+
});
|
|
88
|
+
var RuntimeRicochet2DBehavior = defineBehavior({
|
|
89
|
+
name: "runtime-ricochet-2d",
|
|
90
|
+
defaultOptions: {
|
|
91
|
+
minSpeed: 2,
|
|
92
|
+
maxSpeed: 20,
|
|
93
|
+
speedMultiplier: 1.05,
|
|
94
|
+
reflectionMode: "angled",
|
|
95
|
+
maxAngleDeg: 60
|
|
96
|
+
},
|
|
97
|
+
systemFactory: runtimeNoopSystemFactory,
|
|
98
|
+
createHandle: (ref) => ({
|
|
99
|
+
onRicochet: (callback) => addListener(ref, RICOCHET_LISTENERS, callback)
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
var RuntimeTriggerRegion2DBehavior = defineBehavior({
|
|
103
|
+
name: "runtime-trigger-region-2d",
|
|
104
|
+
defaultOptions: {
|
|
105
|
+
triggerId: 0,
|
|
106
|
+
halfExtents: [0.5, 2.5]
|
|
107
|
+
},
|
|
108
|
+
systemFactory: runtimeNoopSystemFactory,
|
|
109
|
+
createHandle: (ref) => ({
|
|
110
|
+
onRegionEnter: (callback) => addListener(ref, TRIGGER_REGION_LISTENERS, callback)
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
var RuntimeGoalZone2DBehavior = defineBehavior({
|
|
114
|
+
name: "runtime-goal-zone-2d",
|
|
115
|
+
defaultOptions: {
|
|
116
|
+
scorer: "p1"
|
|
117
|
+
},
|
|
118
|
+
systemFactory: runtimeNoopSystemFactory,
|
|
119
|
+
createHandle: (ref) => ({
|
|
120
|
+
onGoal: (callback) => addListener(ref, GOAL_LISTENERS, callback)
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
function emitRuntimeRicochet(ref, event) {
|
|
124
|
+
emit(ref, RICOCHET_LISTENERS, event);
|
|
125
|
+
}
|
|
126
|
+
function emitRuntimeTriggerRegionEnter(ref, event) {
|
|
127
|
+
emit(ref, TRIGGER_REGION_LISTENERS, event);
|
|
128
|
+
}
|
|
129
|
+
function emitRuntimeGoal(ref, event) {
|
|
130
|
+
emit(ref, GOAL_LISTENERS, event);
|
|
131
|
+
}
|
|
132
|
+
function bindRuntimeDynamicCircleBody2DHandle(ref, controls) {
|
|
133
|
+
ref[CIRCLE_BODY_SET_POSITION] = controls.setPosition;
|
|
134
|
+
ref[CIRCLE_BODY_SET_VELOCITY] = controls.setVelocity;
|
|
135
|
+
ref[CIRCLE_BODY_GET_POSITION] = controls.getPosition;
|
|
136
|
+
}
|
|
17
137
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
138
|
+
RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY,
|
|
139
|
+
RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY,
|
|
140
|
+
RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY,
|
|
141
|
+
RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY,
|
|
21
142
|
RUNTIME_RICOCHET_2D_BEHAVIOR_KEY,
|
|
22
143
|
RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
144
|
+
RuntimeBoundary2DBehavior,
|
|
145
|
+
RuntimeDynamicCircleBody2DBehavior,
|
|
146
|
+
RuntimeGoalZone2DBehavior,
|
|
147
|
+
RuntimePlayerInput2DBehavior,
|
|
26
148
|
RuntimeRicochet2DBehavior,
|
|
27
149
|
RuntimeTriggerRegion2DBehavior,
|
|
28
|
-
|
|
150
|
+
bindRuntimeDynamicCircleBody2DHandle,
|
|
151
|
+
emitRuntimeGoal,
|
|
29
152
|
emitRuntimeRicochet,
|
|
30
153
|
emitRuntimeTriggerRegionEnter
|
|
31
154
|
};
|
|
155
|
+
//# sourceMappingURL=runtime-2d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/behaviors/runtime-2d/runtime-2d.descriptor.ts"],"sourcesContent":["/**\n * Runtime 2D Behavior Descriptors\n *\n * Marker descriptors for entities managed entirely by the wasm gameplay-2d\n * runtime (paddle-and-ball style games, boundaries, trigger regions, goal\n * zones). The descriptors carry configuration and event wiring only — all\n * per-frame simulation happens inside the wasm runtime, so their systems are\n * no-ops. The host runtime binds concrete callbacks onto the behavior refs\n * (see {@link bindRuntimeDynamicCircleBody2DHandle} and the emit helpers).\n */\n\nimport {\n\tdefineBehavior,\n\ttype BehaviorRef,\n} from '../behavior-descriptor';\nimport type { BehaviorSystem } from '../behavior-system';\n\nexport interface RuntimeDynamicCircleBody2DOptions {\n\tinitialVelocity: readonly [number, number];\n}\n\nexport interface RuntimeDynamicCircleBody2DHandle {\n\tsetRuntimePosition(x: number, y: number, z?: number): void;\n\tsetRuntimeVelocity(x: number, y: number): void;\n\tgetRuntimePosition(): { x: number; y: number; z: number } | null;\n}\n\nexport interface RuntimePlayerInput2DOptions {\n\tplayer: 'p1' | 'p2';\n\tspeed: number;\n}\n\nexport interface RuntimeBoundary2DOptions {\n\tboundaries: {\n\t\tleft: number;\n\t\tright: number;\n\t\tbottom: number;\n\t\ttop: number;\n\t};\n}\n\nexport interface RuntimeRicochet2DOptions {\n\tminSpeed: number;\n\tmaxSpeed: number;\n\tspeedMultiplier: number;\n\treflectionMode: 'simple' | 'angled';\n\tmaxAngleDeg: number;\n}\n\nexport interface RuntimeRicochet2DEvent {\n\tkind: 'wall' | 'paddle';\n}\n\nexport interface RuntimeRicochet2DHandle {\n\tonRicochet(callback: (event: RuntimeRicochet2DEvent) => void): () => void;\n}\n\n/** Registers a gameplay2d trigger AABB (sensor); wasm reports overlap via {@link emitRuntimeTriggerRegionEnter}. */\nexport interface RuntimeTriggerRegion2DOptions {\n\ttriggerId: number;\n\thalfExtents: readonly [number, number];\n}\n\nexport interface RuntimeTriggerRegion2DEvent {\n\ttriggerId: number;\n}\n\nexport interface RuntimeTriggerRegion2DHandle {\n\tonRegionEnter(callback: (event: RuntimeTriggerRegion2DEvent) => void): () => void;\n}\n\nexport interface RuntimeGoalZone2DOptions {\n\tscorer: 'p1' | 'p2';\n}\n\nexport interface RuntimeGoalZone2DEvent {\n\tscorer: 'p1' | 'p2';\n}\n\nexport interface RuntimeGoalZone2DHandle {\n\tonGoal(callback: (event: RuntimeGoalZone2DEvent) => void): () => void;\n}\n\nconst runtimeNoopSystemFactory = (): BehaviorSystem => ({\n\tupdate(_ecs: unknown, _delta: number) {},\n});\n\nexport const RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-dynamic-circle-body-2d');\nexport const RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-player-input-2d');\nexport const RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-boundary-2d');\nexport const RUNTIME_RICOCHET_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-ricochet-2d');\nexport const RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-trigger-region-2d');\nexport const RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-goal-zone-2d');\n\nconst RICOCHET_LISTENERS = Symbol('runtime-ricochet-listeners');\nconst TRIGGER_REGION_LISTENERS = Symbol('runtime-trigger-region-listeners');\nconst GOAL_LISTENERS = Symbol('runtime-goal-listeners');\nconst CIRCLE_BODY_SET_POSITION = Symbol('runtime-circle-body-set-position');\nconst CIRCLE_BODY_SET_VELOCITY = Symbol('runtime-circle-body-set-velocity');\nconst CIRCLE_BODY_GET_POSITION = Symbol('runtime-circle-body-get-position');\n\nfunction getListeners<E>(ref: BehaviorRef<any>, slot: symbol): Array<(event: E) => void> {\n\tlet listeners = (ref as any)[slot] as Array<(event: E) => void> | undefined;\n\tif (!listeners) {\n\t\tlisteners = [];\n\t\t(ref as any)[slot] = listeners;\n\t}\n\treturn listeners;\n}\n\nfunction addListener<E>(ref: BehaviorRef<any>, slot: symbol, callback: (event: E) => void): () => void {\n\tconst listeners = getListeners<E>(ref, slot);\n\tlisteners.push(callback);\n\treturn () => {\n\t\tconst index = listeners.indexOf(callback);\n\t\tif (index >= 0) {\n\t\t\tlisteners.splice(index, 1);\n\t\t}\n\t};\n}\n\nfunction emit<E>(ref: BehaviorRef<any>, slot: symbol, event: E): void {\n\tconst listeners = (ref as any)[slot] as Array<(event: E) => void> | undefined;\n\tif (!listeners) return;\n\tfor (const listener of listeners) {\n\t\tlistener(event);\n\t}\n}\n\nexport const RuntimeDynamicCircleBody2DBehavior = defineBehavior<\n\tRuntimeDynamicCircleBody2DOptions,\n\tRuntimeDynamicCircleBody2DHandle\n>({\n\tname: 'runtime-dynamic-circle-body-2d',\n\tdefaultOptions: {\n\t\tinitialVelocity: [0, 0] as [number, number],\n\t},\n\tsystemFactory: runtimeNoopSystemFactory,\n\tcreateHandle: (ref: BehaviorRef<RuntimeDynamicCircleBody2DOptions>) => ({\n\t\tsetRuntimePosition(x: number, y: number, z: number = 0): void {\n\t\t\tconst callback = (ref as any)[CIRCLE_BODY_SET_POSITION] as\n\t\t\t\t| ((x: number, y: number, z: number) => void)\n\t\t\t\t| undefined;\n\t\t\tcallback?.(x, y, z);\n\t\t},\n\t\tsetRuntimeVelocity(x: number, y: number): void {\n\t\t\tconst callback = (ref as any)[CIRCLE_BODY_SET_VELOCITY] as\n\t\t\t\t| ((x: number, y: number) => void)\n\t\t\t\t| undefined;\n\t\t\tcallback?.(x, y);\n\t\t},\n\t\tgetRuntimePosition(): { x: number; y: number; z: number } | null {\n\t\t\tconst callback = (ref as any)[CIRCLE_BODY_GET_POSITION] as\n\t\t\t\t| (() => { x: number; y: number; z: number } | null)\n\t\t\t\t| undefined;\n\t\t\treturn callback?.() ?? null;\n\t\t},\n\t}),\n});\n\nexport const RuntimePlayerInput2DBehavior = defineBehavior<RuntimePlayerInput2DOptions>({\n\tname: 'runtime-player-input-2d',\n\tdefaultOptions: {\n\t\tplayer: 'p1',\n\t\tspeed: 5,\n\t} as RuntimePlayerInput2DOptions,\n\tsystemFactory: runtimeNoopSystemFactory,\n});\n\nexport const RuntimeBoundary2DBehavior = defineBehavior({\n\tname: 'runtime-boundary-2d',\n\tdefaultOptions: {\n\t\tboundaries: {\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\tbottom: 0,\n\t\t\ttop: 0,\n\t\t},\n\t},\n\tsystemFactory: runtimeNoopSystemFactory,\n});\n\nexport const RuntimeRicochet2DBehavior = defineBehavior<\n\tRuntimeRicochet2DOptions,\n\tRuntimeRicochet2DHandle\n>({\n\tname: 'runtime-ricochet-2d',\n\tdefaultOptions: {\n\t\tminSpeed: 2,\n\t\tmaxSpeed: 20,\n\t\tspeedMultiplier: 1.05,\n\t\treflectionMode: 'angled' as const,\n\t\tmaxAngleDeg: 60,\n\t},\n\tsystemFactory: runtimeNoopSystemFactory,\n\tcreateHandle: (ref: BehaviorRef<RuntimeRicochet2DOptions>) => ({\n\t\tonRicochet: (callback: (event: RuntimeRicochet2DEvent) => void) =>\n\t\t\taddListener(ref, RICOCHET_LISTENERS, callback),\n\t}),\n});\n\nexport const RuntimeTriggerRegion2DBehavior = defineBehavior<\n\tRuntimeTriggerRegion2DOptions,\n\tRuntimeTriggerRegion2DHandle\n>({\n\tname: 'runtime-trigger-region-2d',\n\tdefaultOptions: {\n\t\ttriggerId: 0,\n\t\thalfExtents: [0.5, 2.5] as [number, number],\n\t},\n\tsystemFactory: runtimeNoopSystemFactory,\n\tcreateHandle: (ref: BehaviorRef<RuntimeTriggerRegion2DOptions>) => ({\n\t\tonRegionEnter: (callback: (event: RuntimeTriggerRegion2DEvent) => void) =>\n\t\t\taddListener(ref, TRIGGER_REGION_LISTENERS, callback),\n\t}),\n});\n\nexport const RuntimeGoalZone2DBehavior = defineBehavior<\n\tRuntimeGoalZone2DOptions,\n\tRuntimeGoalZone2DHandle\n>({\n\tname: 'runtime-goal-zone-2d',\n\tdefaultOptions: {\n\t\tscorer: 'p1',\n\t} as RuntimeGoalZone2DOptions,\n\tsystemFactory: runtimeNoopSystemFactory,\n\tcreateHandle: (ref: BehaviorRef<RuntimeGoalZone2DOptions>) => ({\n\t\tonGoal: (callback: (event: RuntimeGoalZone2DEvent) => void) =>\n\t\t\taddListener(ref, GOAL_LISTENERS, callback),\n\t}),\n});\n\nexport function emitRuntimeRicochet(\n\tref: BehaviorRef<RuntimeRicochet2DOptions>,\n\tevent: RuntimeRicochet2DEvent,\n): void {\n\temit(ref, RICOCHET_LISTENERS, event);\n}\n\nexport function emitRuntimeTriggerRegionEnter(\n\tref: BehaviorRef<RuntimeTriggerRegion2DOptions>,\n\tevent: RuntimeTriggerRegion2DEvent,\n): void {\n\temit(ref, TRIGGER_REGION_LISTENERS, event);\n}\n\nexport function emitRuntimeGoal(\n\tref: BehaviorRef<RuntimeGoalZone2DOptions>,\n\tevent: RuntimeGoalZone2DEvent,\n): void {\n\temit(ref, GOAL_LISTENERS, event);\n}\n\nexport function bindRuntimeDynamicCircleBody2DHandle(\n\tref: BehaviorRef<RuntimeDynamicCircleBody2DOptions>,\n\tcontrols: {\n\t\tsetPosition: (x: number, y: number, z: number) => void;\n\t\tsetVelocity: (x: number, y: number) => void;\n\t\tgetPosition: () => { x: number; y: number; z: number } | null;\n\t},\n): void {\n\t(ref as any)[CIRCLE_BODY_SET_POSITION] = controls.setPosition;\n\t(ref as any)[CIRCLE_BODY_SET_VELOCITY] = controls.setVelocity;\n\t(ref as any)[CIRCLE_BODY_GET_POSITION] = controls.getPosition;\n}\n"],"mappings":"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","names":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as BehaviorDescriptor, G as GameEntity } from './behavior-system-
|
|
1
|
+
import { a as BehaviorDescriptor, G as GameEntity } from './behavior-system-DSNek0W9.js';
|
|
2
|
+
import '@dimforge/rapier3d-compat';
|
|
2
3
|
|
|
3
4
|
interface ScreenVisibilitySnapshot {
|
|
4
5
|
initialized: boolean;
|