@zylem/behaviors 0.3.1 → 0.4.1
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/behavior-system-y8SGrGWy.d.ts +580 -0
- package/dist/{chunk-ARJWUNRE.js → chunk-27UPCP5B.js} +10 -10
- package/dist/{chunk-ARJWUNRE.js.map → chunk-27UPCP5B.js.map} +1 -1
- package/dist/{chunk-YUO6SKJD.js → chunk-4L36OPY2.js} +33 -23
- package/dist/chunk-4L36OPY2.js.map +1 -0
- package/dist/{chunk-DYLH6K7B.js → chunk-4WH2ZN7P.js} +1 -1
- package/dist/{chunk-DYLH6K7B.js.map → chunk-4WH2ZN7P.js.map} +1 -1
- package/dist/{chunk-ZPSAXX73.js → chunk-5SM5SH5O.js} +26 -26
- package/dist/chunk-5SM5SH5O.js.map +1 -0
- package/dist/{chunk-STCCNLPC.js → chunk-5XZWTFGF.js} +5 -3
- package/dist/chunk-5XZWTFGF.js.map +1 -0
- package/dist/{chunk-JAN34G6S.js → chunk-67XLJ26X.js} +152 -168
- package/dist/chunk-67XLJ26X.js.map +1 -0
- package/dist/{chunk-2CLT36VB.js → chunk-75FJIUIG.js} +22 -23
- package/dist/chunk-75FJIUIG.js.map +1 -0
- package/dist/{chunk-OYWFPIHF.js → chunk-A4CA35DQ.js} +20 -17
- package/dist/chunk-A4CA35DQ.js.map +1 -0
- package/dist/{chunk-SS7ELMJ7.js → chunk-F72WX4MH.js} +49 -33
- package/dist/chunk-F72WX4MH.js.map +1 -0
- package/dist/{chunk-RTRVBEIB.js → chunk-FTDZAKZW.js} +5 -18
- package/dist/chunk-FTDZAKZW.js.map +1 -0
- package/dist/{chunk-XIJNE67Y.js → chunk-GFARAJV2.js} +3 -5
- package/dist/{chunk-XIJNE67Y.js.map → chunk-GFARAJV2.js.map} +1 -1
- package/dist/{chunk-VAN4WW3F.js → chunk-H4TJ7X4O.js} +4 -7
- package/dist/chunk-H4TJ7X4O.js.map +1 -0
- package/dist/{chunk-KS72RZHX.js → chunk-IZJFUAXB.js} +1 -1
- package/dist/{chunk-KS72RZHX.js.map → chunk-IZJFUAXB.js.map} +1 -1
- package/dist/{chunk-SVLNF434.js → chunk-JXMF4NUI.js} +51 -3
- package/dist/chunk-JXMF4NUI.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-RTVRUNYR.js → chunk-OTLSUYQQ.js} +2 -2
- package/dist/chunk-OTLSUYQQ.js.map +1 -0
- package/dist/{chunk-Y6UJOUE5.js → chunk-Q75LKHDF.js} +14 -2
- package/dist/chunk-Q75LKHDF.js.map +1 -0
- package/dist/{chunk-KOZUNIIE.js → chunk-QDCJLJUV.js} +10 -10
- package/dist/{chunk-KOZUNIIE.js.map → chunk-QDCJLJUV.js.map} +1 -1
- package/dist/{chunk-LD5SMIB3.js → chunk-QVCMJ4Q2.js} +1 -1
- package/dist/{chunk-LD5SMIB3.js.map → chunk-QVCMJ4Q2.js.map} +1 -1
- package/dist/{chunk-F3KRX2V4.js → chunk-RDHSHEZM.js} +46 -24
- package/dist/chunk-RDHSHEZM.js.map +1 -0
- package/dist/chunk-UIG7MWS2.js +518 -0
- package/dist/chunk-UIG7MWS2.js.map +1 -0
- package/dist/{chunk-6C6NXNEW.js → chunk-UL6Q5HDP.js} +25 -3
- package/dist/chunk-UL6Q5HDP.js.map +1 -0
- package/dist/{chunk-XG2YMCJW.js → chunk-VMQHNJJI.js} +6 -8
- package/dist/{chunk-XG2YMCJW.js.map → chunk-VMQHNJJI.js.map} +1 -1
- package/dist/{chunk-GCNRXAKH.js → chunk-XP3ASVGJ.js} +13 -10
- package/dist/chunk-XP3ASVGJ.js.map +1 -0
- package/dist/{chunk-ID5QJYF5.js → chunk-Y7YIAWPW.js} +11 -1
- package/dist/chunk-Y7YIAWPW.js.map +1 -0
- package/dist/{chunk-4I6E6DGV.js → chunk-Z72F2ENM.js} +6 -8
- package/dist/{chunk-4I6E6DGV.js.map → chunk-Z72F2ENM.js.map} +1 -1
- package/dist/{chunk-FPTWVCPN.js → chunk-ZA43LPRM.js} +4 -24
- package/dist/chunk-ZA43LPRM.js.map +1 -0
- package/dist/{chunk-K3UNLQ7W.js → chunk-ZRQWSURL.js} +2 -2
- package/dist/chunk-ZRQWSURL.js.map +1 -0
- package/dist/cooldown.d.ts +2 -1
- package/dist/cooldown.js +1 -1
- package/dist/coordinators/boundary-ricochet-3d.d.ts +12 -5
- package/dist/coordinators/boundary-ricochet-3d.js +2 -1
- package/dist/coordinators/boundary-ricochet.d.ts +9 -7
- package/dist/coordinators/boundary-ricochet.js +2 -1
- package/dist/coordinators/first-person-shooter.d.ts +9 -8
- package/dist/coordinators/first-person-shooter.js +3 -3
- package/dist/coordinators/multidirectional-space-shooter.d.ts +12 -9
- package/dist/coordinators/multidirectional-space-shooter.js +4 -4
- package/dist/coordinators/top-down-shooter.d.ts +9 -8
- package/dist/coordinators/top-down-shooter.js +3 -3
- package/dist/core.d.ts +4 -4
- package/dist/core.js +17 -39
- package/dist/core.js.map +1 -1
- package/dist/destructible-3d.d.ts +2 -1
- package/dist/first-person.d.ts +12 -12
- package/dist/first-person.js +9 -8
- package/dist/index.d.ts +37 -14
- package/dist/index.js +73 -44
- package/dist/jumper-2d.d.ts +7 -6
- package/dist/jumper-2d.js +6 -5
- package/dist/jumper-3d.d.ts +12 -11
- package/dist/jumper-3d.js +7 -6
- package/dist/{moveable-BCRpjAQb.d.ts → moveable-Cl9h-_w7.d.ts} +2 -78
- package/dist/particle-emitter.d.ts +1 -1
- package/dist/particle-emitter.js +1 -1
- package/dist/platformer-2d.d.ts +306 -0
- package/dist/platformer-2d.js +24 -0
- package/dist/platformer-3d.d.ts +74 -87
- package/dist/platformer-3d.js +5 -4
- package/dist/ricochet-2d.d.ts +1 -1
- package/dist/ricochet-2d.js +2 -2
- package/dist/ricochet-3d.d.ts +1 -1
- package/dist/ricochet-3d.js +2 -2
- package/dist/runtime-2d.d.ts +93 -2
- package/dist/runtime-2d.js +145 -22
- package/dist/runtime-2d.js.map +1 -1
- package/dist/screen-visibility.d.ts +2 -1
- package/dist/screen-wrap.d.ts +2 -1
- package/dist/screen-wrap.js +1 -1
- package/dist/shooter-2d.d.ts +5 -3
- package/dist/shooter-2d.js +2 -2
- package/dist/shooter-fire-DGripl0z.d.ts +55 -0
- package/dist/thruster.d.ts +8 -18
- package/dist/thruster.js +6 -6
- package/dist/top-down-movement.d.ts +7 -4
- package/dist/top-down-movement.js +5 -5
- package/dist/{use-behavior-D_82jAL3.d.ts → use-behavior-B85d5u7-.d.ts} +1 -1
- package/dist/world-boundary-2d.d.ts +2 -1
- package/dist/world-boundary-2d.js +2 -2
- package/dist/world-boundary-3d.d.ts +2 -1
- package/dist/world-boundary-3d.js +2 -2
- package/package.json +7 -5
- package/dist/behavior-system-DYbx-x_-.d.ts +0 -307
- package/dist/chunk-2C3Z5GE7.js +0 -176
- package/dist/chunk-2C3Z5GE7.js.map +0 -1
- package/dist/chunk-2CLT36VB.js.map +0 -1
- package/dist/chunk-3PYGRHAL.js +0 -35
- package/dist/chunk-3PYGRHAL.js.map +0 -1
- package/dist/chunk-6C6NXNEW.js.map +0 -1
- package/dist/chunk-F3KRX2V4.js.map +0 -1
- package/dist/chunk-FPTWVCPN.js.map +0 -1
- package/dist/chunk-GCNRXAKH.js.map +0 -1
- package/dist/chunk-ID5QJYF5.js.map +0 -1
- package/dist/chunk-JAN34G6S.js.map +0 -1
- package/dist/chunk-K3UNLQ7W.js.map +0 -1
- package/dist/chunk-OYWFPIHF.js.map +0 -1
- package/dist/chunk-RTRVBEIB.js.map +0 -1
- package/dist/chunk-RTVRUNYR.js.map +0 -1
- package/dist/chunk-SS7ELMJ7.js.map +0 -1
- package/dist/chunk-STCCNLPC.js.map +0 -1
- package/dist/chunk-SVLNF434.js.map +0 -1
- package/dist/chunk-VAN4WW3F.js.map +0 -1
- package/dist/chunk-Y6UJOUE5.js.map +0 -1
- package/dist/chunk-YUO6SKJD.js.map +0 -1
- package/dist/chunk-ZPSAXX73.js.map +0 -1
- package/dist/runtime-pong.d.ts +0 -92
- package/dist/runtime-pong.js +0 -38
- /package/dist/{runtime-pong.js.map → platformer-2d.js.map} +0 -0
|
@@ -2,6 +2,11 @@ import {
|
|
|
2
2
|
SyncStateMachine,
|
|
3
3
|
t
|
|
4
4
|
} from "./chunk-4URF65BR.js";
|
|
5
|
+
import {
|
|
6
|
+
STAGE_INPUT_BUTTON_JUMP,
|
|
7
|
+
STAGE_INPUT_BUTTON_RUN,
|
|
8
|
+
readBehaviorSnapshot
|
|
9
|
+
} from "./chunk-Q75LKHDF.js";
|
|
5
10
|
import {
|
|
6
11
|
defineBehavior
|
|
7
12
|
} from "./chunk-EZNCCO4L.js";
|
|
@@ -14,13 +19,16 @@ function createPlatformer3DMovementComponent(options = {}) {
|
|
|
14
19
|
jumpForce: options.jumpForce ?? 12,
|
|
15
20
|
maxJumps: options.maxJumps ?? 1,
|
|
16
21
|
gravity: options.gravity ?? 9.82,
|
|
17
|
-
groundRayLength: options.groundRayLength ?? 1,
|
|
18
22
|
coyoteTime: options.coyoteTime ?? 0.1,
|
|
19
23
|
jumpBufferTime: options.jumpBufferTime ?? 0.1,
|
|
20
24
|
jumpCutMultiplier: options.jumpCutMultiplier ?? 0.5,
|
|
21
25
|
multiJumpWindowTime: options.multiJumpWindowTime ?? 0.15,
|
|
22
26
|
// 150ms default
|
|
23
|
-
|
|
27
|
+
slopeClimbAngle: options.slopeClimbAngle ?? 50,
|
|
28
|
+
slopeSlideAngle: options.slopeSlideAngle ?? 40,
|
|
29
|
+
autostep: options.autostep ?? { maxHeight: 0.3, minWidth: 0.1 },
|
|
30
|
+
snapToGroundDistance: options.snapToGroundDistance ?? 0.3,
|
|
31
|
+
characterOffset: options.characterOffset ?? 0.05
|
|
24
32
|
};
|
|
25
33
|
}
|
|
26
34
|
function createPlatformer3DInputComponent() {
|
|
@@ -52,7 +60,7 @@ function createPlatformer3DStateComponent() {
|
|
|
52
60
|
timeSinceJump: 0,
|
|
53
61
|
jumpedThisFrame: false,
|
|
54
62
|
jumpCutRampTimer: 0,
|
|
55
|
-
|
|
63
|
+
verticalVelocity: 0
|
|
56
64
|
};
|
|
57
65
|
}
|
|
58
66
|
|
|
@@ -183,92 +191,52 @@ var Platformer3DFSM = class {
|
|
|
183
191
|
}
|
|
184
192
|
};
|
|
185
193
|
|
|
186
|
-
// src/lib/behaviors/platformer-3d/platformer-3d.
|
|
194
|
+
// src/lib/behaviors/platformer-3d/platformer-3d.system.ts
|
|
195
|
+
import { RigidBodyType, QueryFilterFlags } from "@dimforge/rapier3d-compat";
|
|
187
196
|
var JUMP_CUT_RAMP_DURATION = 0.05;
|
|
188
|
-
var
|
|
189
|
-
var
|
|
197
|
+
var GROUND_STICK_SPEED = 2;
|
|
198
|
+
var FALL_VELOCITY_THRESHOLD = -0.1;
|
|
199
|
+
var DEG_TO_RAD = Math.PI / 180;
|
|
200
|
+
var _desired = { x: 0, y: 0, z: 0 };
|
|
201
|
+
var Platformer3DSystem = class {
|
|
190
202
|
world;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
* `applyGravity` is the sole writer of vertical velocity. We do this
|
|
195
|
-
* lazily on the first update because the body isn't always available at
|
|
196
|
-
* construction time.
|
|
197
|
-
*/
|
|
198
|
-
gravityConfiguredUUIDs = /* @__PURE__ */ new Set();
|
|
199
|
-
constructor(world, scene) {
|
|
203
|
+
/** Per-entity character controllers, keyed by entity uuid. */
|
|
204
|
+
controllers = /* @__PURE__ */ new Map();
|
|
205
|
+
constructor(world) {
|
|
200
206
|
this.world = world;
|
|
201
|
-
this.scene = scene;
|
|
202
207
|
}
|
|
203
208
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* deliberately don't filter by normal direction: the contact point's
|
|
209
|
-
* position alone is robust against the various normal-flip conventions
|
|
210
|
-
* Rapier uses for `flipped` manifolds and against rolling-bottom edges
|
|
211
|
-
* on heightmap terrain.
|
|
212
|
-
*/
|
|
213
|
-
detectGroundedFromContacts(entity) {
|
|
214
|
-
const collider = entity.collider;
|
|
215
|
-
const physicsWorld = this.world?.world;
|
|
216
|
-
if (!collider || !physicsWorld?.contactsWith) {
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
let grounded = false;
|
|
220
|
-
physicsWorld.contactsWith(collider, (other) => {
|
|
221
|
-
if (grounded) return;
|
|
222
|
-
physicsWorld.contactPair(collider, other, (manifold, flipped) => {
|
|
223
|
-
if (grounded) return;
|
|
224
|
-
const num = manifold.numContacts();
|
|
225
|
-
for (let i = 0; i < num; i++) {
|
|
226
|
-
const local = flipped ? manifold.localContactPoint2(i) : manifold.localContactPoint1(i);
|
|
227
|
-
if (!local) continue;
|
|
228
|
-
if (local.y < 0) {
|
|
229
|
-
grounded = true;
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
return grounded;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* One-time per-entity physics setup: take over gravity from Rapier's
|
|
239
|
-
* world so that `applyGravity` controls the entire airborne fall curve.
|
|
240
|
-
* Without this, gravity was effectively doubled (Rapier's world gravity
|
|
241
|
-
* + this behavior's explicit gravity were both pulling the body down).
|
|
209
|
+
* One-time per-entity physics setup: convert the body to a
|
|
210
|
+
* position-based kinematic body and create its character controller.
|
|
211
|
+
* Done lazily on the first update because the body isn't always
|
|
212
|
+
* available at construction time.
|
|
242
213
|
*/
|
|
243
214
|
ensurePhysicsConfigured(entity) {
|
|
244
|
-
|
|
245
|
-
if (
|
|
246
|
-
|
|
215
|
+
const existing = this.controllers.get(entity.uuid);
|
|
216
|
+
if (existing) return existing;
|
|
217
|
+
const physicsWorld = this.world?.world;
|
|
218
|
+
if (!physicsWorld || !entity.body) return null;
|
|
219
|
+
if (entity.body.bodyType() !== RigidBodyType.KinematicPositionBased) {
|
|
220
|
+
entity.body.setBodyType(RigidBodyType.KinematicPositionBased, true);
|
|
247
221
|
}
|
|
248
|
-
this.gravityConfiguredUUIDs.add(entity.uuid);
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Apply horizontal movement based on input.
|
|
252
|
-
*
|
|
253
|
-
* Only writes X/Z axes — Y is left untouched so Rapier's contact resolution
|
|
254
|
-
* can damp vertical motion correctly while grounded. Jump and gravity are
|
|
255
|
-
* the sole writers of Y velocity (see handleJump / applyGravity).
|
|
256
|
-
*/
|
|
257
|
-
applyMovement(entity) {
|
|
258
|
-
const input = entity.$platformer;
|
|
259
222
|
const movement = entity.platformer;
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
223
|
+
const controller = physicsWorld.createCharacterController(movement.characterOffset);
|
|
224
|
+
controller.setUp({ x: 0, y: 1, z: 0 });
|
|
225
|
+
controller.setMaxSlopeClimbAngle(movement.slopeClimbAngle * DEG_TO_RAD);
|
|
226
|
+
controller.setMinSlopeSlideAngle(movement.slopeSlideAngle * DEG_TO_RAD);
|
|
227
|
+
if (movement.autostep) {
|
|
228
|
+
controller.enableAutostep(movement.autostep.maxHeight, movement.autostep.minWidth, true);
|
|
229
|
+
} else {
|
|
230
|
+
controller.disableAutostep();
|
|
231
|
+
}
|
|
232
|
+
controller.enableSnapToGround(movement.snapToGroundDistance);
|
|
233
|
+
controller.setApplyImpulsesToDynamicBodies(true);
|
|
234
|
+
this.controllers.set(entity.uuid, controller);
|
|
235
|
+
return controller;
|
|
269
236
|
}
|
|
270
237
|
/**
|
|
271
|
-
* Handle jump logic with multi-jump, coyote time, buffering, and jump-cut
|
|
238
|
+
* Handle jump logic with multi-jump, coyote time, buffering, and jump-cut
|
|
239
|
+
* ramp. All vertical motion is written to `state.verticalVelocity`.
|
|
272
240
|
*/
|
|
273
241
|
handleJump(entity, delta) {
|
|
274
242
|
const input = entity.$platformer;
|
|
@@ -299,12 +267,10 @@ var Platformer3DBehavior = class {
|
|
|
299
267
|
state.jumpCutRampTimer = JUMP_CUT_RAMP_DURATION;
|
|
300
268
|
}
|
|
301
269
|
if (state.jumpCutRampTimer > 0) {
|
|
302
|
-
|
|
303
|
-
if (velocity.y > 0) {
|
|
270
|
+
if (state.verticalVelocity > 0) {
|
|
304
271
|
const stepT = Math.min(delta / state.jumpCutRampTimer, 1);
|
|
305
|
-
const targetY =
|
|
306
|
-
|
|
307
|
-
entity.transformStore.dirty.velocityY = true;
|
|
272
|
+
const targetY = state.verticalVelocity * movement.jumpCutMultiplier;
|
|
273
|
+
state.verticalVelocity += (targetY - state.verticalVelocity) * stepT;
|
|
308
274
|
}
|
|
309
275
|
state.jumpCutRampTimer = Math.max(0, state.jumpCutRampTimer - delta);
|
|
310
276
|
}
|
|
@@ -325,19 +291,17 @@ var Platformer3DBehavior = class {
|
|
|
325
291
|
state.falling = false;
|
|
326
292
|
state.jumpCutApplied = false;
|
|
327
293
|
state.jumpCutRampTimer = 0;
|
|
328
|
-
state.
|
|
329
|
-
entity.transformStore.velocity.y = movement.jumpForce;
|
|
330
|
-
entity.transformStore.dirty.velocityY = true;
|
|
294
|
+
state.verticalVelocity = movement.jumpForce;
|
|
331
295
|
state.jumpedThisFrame = true;
|
|
332
296
|
}
|
|
333
297
|
}
|
|
334
298
|
/**
|
|
335
|
-
*
|
|
299
|
+
* Integrate gravity into `state.verticalVelocity`.
|
|
336
300
|
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
301
|
+
* While grounded (and not on the jump frame) vertical velocity is held at
|
|
302
|
+
* a small constant downward speed so the controller stays pressed into
|
|
303
|
+
* the ground. Skipped entirely on the frame a jump was applied — the
|
|
304
|
+
* grounded flag is still stale-true then and would clobber the jump.
|
|
341
305
|
*/
|
|
342
306
|
applyGravity(entity, delta) {
|
|
343
307
|
const movement = entity.platformer;
|
|
@@ -346,58 +310,27 @@ var Platformer3DBehavior = class {
|
|
|
346
310
|
state.jumpedThisFrame = false;
|
|
347
311
|
return;
|
|
348
312
|
}
|
|
349
|
-
if (state.grounded)
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
313
|
+
if (state.grounded) {
|
|
314
|
+
state.verticalVelocity = -GROUND_STICK_SPEED;
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
state.verticalVelocity -= movement.gravity * delta;
|
|
354
318
|
}
|
|
355
319
|
/**
|
|
356
|
-
* Update entity state
|
|
357
|
-
*
|
|
358
|
-
* Grounded is determined purely by Rapier's contact pairs on the entity's
|
|
359
|
-
* collider. This removes a whole class of slope/heightmap jitter caused
|
|
360
|
-
* by the previous shape probe disagreeing with the contact resolver — the
|
|
361
|
-
* probe could report grounded while a contact impulse had just nudged the
|
|
362
|
-
* body off the ground, producing visible micro-bouncing.
|
|
363
|
-
*
|
|
364
|
-
* While grounded, vertical velocity is held at 0 each frame. This stops
|
|
365
|
-
* residual upward kicks from slope-contact resolution from accumulating
|
|
366
|
-
* across frames (which previously caused the character to "ride up"
|
|
367
|
-
* slopes and lose contact briefly, then fall back, then re-contact, in a
|
|
368
|
-
* tight oscillation).
|
|
320
|
+
* Update entity state from the controller's grounded result.
|
|
369
321
|
*/
|
|
370
|
-
updateState(entity, delta) {
|
|
322
|
+
updateState(entity, delta, computedGrounded) {
|
|
371
323
|
const state = entity.platformerState;
|
|
372
324
|
const wasGrounded = state.grounded;
|
|
373
|
-
const velocity = entity.body.linvel();
|
|
374
|
-
const hasContact = this.detectGroundedFromContacts(entity);
|
|
375
325
|
const isAirborne = state.jumping || state.falling;
|
|
376
326
|
let isGrounded;
|
|
377
327
|
if (isAirborne) {
|
|
378
328
|
const canLand = state.falling && !state.jumping;
|
|
379
|
-
isGrounded =
|
|
329
|
+
isGrounded = computedGrounded && canLand;
|
|
380
330
|
} else {
|
|
381
|
-
isGrounded =
|
|
382
|
-
}
|
|
383
|
-
if (!isGrounded && wasGrounded) {
|
|
384
|
-
if (state.groundedGraceTimer <= 0) {
|
|
385
|
-
state.groundedGraceTimer = GROUNDED_GRACE_WINDOW;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
if (state.groundedGraceTimer > 0) {
|
|
389
|
-
if (!isGrounded && wasGrounded && !isAirborne) {
|
|
390
|
-
isGrounded = true;
|
|
391
|
-
state.groundedGraceTimer = Math.max(0, state.groundedGraceTimer - delta);
|
|
392
|
-
} else {
|
|
393
|
-
state.groundedGraceTimer = 0;
|
|
394
|
-
}
|
|
331
|
+
isGrounded = computedGrounded;
|
|
395
332
|
}
|
|
396
333
|
state.grounded = isGrounded;
|
|
397
|
-
if (state.grounded) {
|
|
398
|
-
entity.transformStore.velocity.y = 0;
|
|
399
|
-
entity.transformStore.dirty.velocityY = true;
|
|
400
|
-
}
|
|
401
334
|
if (state.grounded) {
|
|
402
335
|
state.timeSinceGrounded = 0;
|
|
403
336
|
state.lastGroundedY = entity.body.translation().y;
|
|
@@ -410,9 +343,12 @@ var Platformer3DBehavior = class {
|
|
|
410
343
|
state.falling = false;
|
|
411
344
|
state.jumpCutApplied = false;
|
|
412
345
|
state.jumpCutRampTimer = 0;
|
|
346
|
+
if (state.verticalVelocity < 0) {
|
|
347
|
+
state.verticalVelocity = 0;
|
|
348
|
+
}
|
|
413
349
|
}
|
|
414
|
-
if (
|
|
415
|
-
if (state.jumping
|
|
350
|
+
if (state.verticalVelocity < FALL_VELOCITY_THRESHOLD && !state.grounded) {
|
|
351
|
+
if (state.jumping) {
|
|
416
352
|
state.jumping = false;
|
|
417
353
|
state.falling = true;
|
|
418
354
|
} else if (!state.jumping) {
|
|
@@ -428,39 +364,71 @@ var Platformer3DBehavior = class {
|
|
|
428
364
|
if (!entity.platformer || !entity.$platformer || !entity.platformerState) {
|
|
429
365
|
return;
|
|
430
366
|
}
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
367
|
+
const controller = this.ensurePhysicsConfigured(entity);
|
|
368
|
+
const collider = entity.collider;
|
|
369
|
+
if (!controller || !collider) return;
|
|
370
|
+
const input = entity.$platformer;
|
|
371
|
+
const movement = entity.platformer;
|
|
372
|
+
const state = entity.platformerState;
|
|
373
|
+
this.handleJump(entity, delta);
|
|
374
|
+
this.applyGravity(entity, delta);
|
|
375
|
+
const speed = input.run ? movement.runSpeed : movement.walkSpeed;
|
|
376
|
+
state.currentSpeed = speed;
|
|
377
|
+
_desired.x = input.moveX * speed * delta;
|
|
378
|
+
_desired.y = state.verticalVelocity * delta;
|
|
379
|
+
_desired.z = input.moveZ * speed * delta;
|
|
380
|
+
controller.computeColliderMovement(collider, _desired, QueryFilterFlags.EXCLUDE_SENSORS);
|
|
381
|
+
const corrected = controller.computedMovement();
|
|
382
|
+
if (_desired.y > 1e-9 && corrected.y < _desired.y * 0.5) {
|
|
383
|
+
state.verticalVelocity = 0;
|
|
384
|
+
}
|
|
385
|
+
const translation = entity.body.translation();
|
|
386
|
+
entity.body.setNextKinematicTranslation({
|
|
387
|
+
x: translation.x + corrected.x,
|
|
388
|
+
y: translation.y + corrected.y,
|
|
389
|
+
z: translation.z + corrected.z
|
|
390
|
+
});
|
|
391
|
+
this.updateState(entity, delta, controller.computedGrounded());
|
|
437
392
|
}
|
|
438
393
|
destroy() {
|
|
439
|
-
this.
|
|
394
|
+
const physicsWorld = this.world?.world;
|
|
395
|
+
if (physicsWorld) {
|
|
396
|
+
for (const controller of this.controllers.values()) {
|
|
397
|
+
physicsWorld.removeCharacterController(controller);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
this.controllers.clear();
|
|
440
401
|
}
|
|
441
402
|
};
|
|
442
403
|
|
|
443
404
|
// src/lib/behaviors/platformer-3d/platformer-3d.descriptor.ts
|
|
405
|
+
var FSM_STATE_BY_INDEX = [
|
|
406
|
+
"idle" /* Idle */,
|
|
407
|
+
"walking" /* Walking */,
|
|
408
|
+
"running" /* Running */,
|
|
409
|
+
"jumping" /* Jumping */,
|
|
410
|
+
"falling" /* Falling */,
|
|
411
|
+
"landing" /* Landing */
|
|
412
|
+
];
|
|
444
413
|
var defaultOptions = {
|
|
445
414
|
walkSpeed: 12,
|
|
446
415
|
runSpeed: 24,
|
|
447
416
|
jumpForce: 12,
|
|
448
417
|
maxJumps: 1,
|
|
449
418
|
gravity: 9.82,
|
|
450
|
-
|
|
451
|
-
|
|
419
|
+
slopeClimbAngle: 50,
|
|
420
|
+
slopeSlideAngle: 40,
|
|
421
|
+
autostep: { maxHeight: 0.3, minWidth: 0.1 },
|
|
422
|
+
snapToGroundDistance: 0.3,
|
|
423
|
+
characterOffset: 0.05
|
|
452
424
|
};
|
|
453
425
|
var PLATFORMER_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:platformer-3d");
|
|
454
426
|
var Platformer3DBehaviorSystem = class {
|
|
455
|
-
constructor(world,
|
|
456
|
-
this.world = world;
|
|
457
|
-
this.scene = scene;
|
|
427
|
+
constructor(world, wasmStage, getBehaviorLinks) {
|
|
458
428
|
this.wasmStage = wasmStage;
|
|
459
429
|
this.getBehaviorLinks = getBehaviorLinks;
|
|
460
|
-
this.movementBehavior = new
|
|
430
|
+
this.movementBehavior = new Platformer3DSystem(world);
|
|
461
431
|
}
|
|
462
|
-
world;
|
|
463
|
-
scene;
|
|
464
432
|
wasmStage;
|
|
465
433
|
getBehaviorLinks;
|
|
466
434
|
movementBehavior;
|
|
@@ -481,6 +449,19 @@ var Platformer3DBehaviorSystem = class {
|
|
|
481
449
|
if (!gameEntity.platformerState) {
|
|
482
450
|
gameEntity.platformerState = createPlatformer3DStateComponent();
|
|
483
451
|
}
|
|
452
|
+
const handle = gameEntity.runtimeHandle ?? -1;
|
|
453
|
+
if (this.wasmStage && handle >= 0) {
|
|
454
|
+
this.ensureWasmAttached(handle, options);
|
|
455
|
+
platformerRef.__wasmStage = this.wasmStage;
|
|
456
|
+
platformerRef.__entity = gameEntity;
|
|
457
|
+
const input = gameEntity.$platformer;
|
|
458
|
+
if (input) {
|
|
459
|
+
this.wasmStage.writeInputAxes(handle, input.moveX ?? 0, input.moveZ ?? 0);
|
|
460
|
+
this.wasmStage.writeInputButton(handle, STAGE_INPUT_BUTTON_JUMP, !!input.jump);
|
|
461
|
+
this.wasmStage.writeInputButton(handle, STAGE_INPUT_BUTTON_RUN, !!input.run);
|
|
462
|
+
}
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
484
465
|
if (!platformerRef.fsm && gameEntity.$platformer && gameEntity.platformerState) {
|
|
485
466
|
platformerRef.fsm = new Platformer3DFSM({
|
|
486
467
|
input: gameEntity.$platformer,
|
|
@@ -490,22 +471,13 @@ var Platformer3DBehaviorSystem = class {
|
|
|
490
471
|
if (platformerRef.fsm && gameEntity.$platformer && gameEntity.platformerState) {
|
|
491
472
|
platformerRef.fsm.update(gameEntity.$platformer, gameEntity.platformerState);
|
|
492
473
|
}
|
|
493
|
-
const handle = gameEntity.runtimeHandle ?? -1;
|
|
494
|
-
if (this.wasmStage && handle >= 0) {
|
|
495
|
-
this.ensureWasmAttached(handle, options);
|
|
496
|
-
const input = gameEntity.$platformer;
|
|
497
|
-
if (input) {
|
|
498
|
-
this.wasmStage.setPlatformer3DInputAxes(handle, input.moveX ?? 0, input.moveZ ?? 0);
|
|
499
|
-
this.wasmStage.setPlatformer3DInputButtons(handle, !!input.jump, !!input.run);
|
|
500
|
-
}
|
|
501
|
-
continue;
|
|
502
|
-
}
|
|
503
474
|
if (!gameEntity.body) continue;
|
|
504
475
|
this.movementBehavior.updateEntity(gameEntity, delta);
|
|
505
476
|
}
|
|
506
477
|
}
|
|
507
478
|
ensureWasmAttached(handle, options) {
|
|
508
479
|
if (!this.wasmStage || this.attachedRuntimeSlots.has(handle)) return;
|
|
480
|
+
const autostep = options.autostep ?? defaultOptions.autostep;
|
|
509
481
|
this.wasmStage.attachPlatformer3D(handle, {
|
|
510
482
|
halfHeight: 0.9,
|
|
511
483
|
radius: 0.4,
|
|
@@ -513,7 +485,13 @@ var Platformer3DBehaviorSystem = class {
|
|
|
513
485
|
runSpeed: options.runSpeed ?? defaultOptions.runSpeed,
|
|
514
486
|
jumpForce: options.jumpForce ?? defaultOptions.jumpForce,
|
|
515
487
|
maxJumps: options.maxJumps ?? defaultOptions.maxJumps,
|
|
516
|
-
gravity: options.gravity ?? defaultOptions.gravity
|
|
488
|
+
gravity: options.gravity ?? defaultOptions.gravity,
|
|
489
|
+
slopeClimbAngle: options.slopeClimbAngle ?? defaultOptions.slopeClimbAngle,
|
|
490
|
+
slopeSlideAngle: options.slopeSlideAngle ?? defaultOptions.slopeSlideAngle,
|
|
491
|
+
autostepHeight: autostep ? autostep.maxHeight : 0,
|
|
492
|
+
autostepMinWidth: autostep ? autostep.minWidth : 0.1,
|
|
493
|
+
snapToGroundDistance: options.snapToGroundDistance ?? defaultOptions.snapToGroundDistance,
|
|
494
|
+
characterOffset: options.characterOffset ?? defaultOptions.characterOffset
|
|
517
495
|
});
|
|
518
496
|
this.attachedRuntimeSlots.add(handle);
|
|
519
497
|
}
|
|
@@ -522,19 +500,25 @@ var Platformer3DBehaviorSystem = class {
|
|
|
522
500
|
this.attachedRuntimeSlots.clear();
|
|
523
501
|
}
|
|
524
502
|
};
|
|
525
|
-
var
|
|
503
|
+
var Platformer3DBehavior = defineBehavior({
|
|
526
504
|
name: "platformer-3d",
|
|
527
505
|
defaultOptions,
|
|
528
506
|
systemFactory: (ctx) => new Platformer3DBehaviorSystem(
|
|
529
|
-
ctx.world,
|
|
530
|
-
ctx.scene,
|
|
507
|
+
ctx.world ?? null,
|
|
531
508
|
ctx.wasmStage ?? null,
|
|
532
509
|
ctx.getBehaviorLinks
|
|
533
510
|
),
|
|
511
|
+
// On the wasm fast path the handle reads the runtime snapshot buffer
|
|
512
|
+
// (values are from the end of the previous step — one-frame lag); the TS
|
|
513
|
+
// FSM only backs the no-wasm fallback path.
|
|
534
514
|
createHandle: (ref) => ({
|
|
535
|
-
getState: () =>
|
|
536
|
-
|
|
537
|
-
|
|
515
|
+
getState: () => {
|
|
516
|
+
const snapshot = readBehaviorSnapshot(ref);
|
|
517
|
+
if (snapshot) return FSM_STATE_BY_INDEX[snapshot.fsmState] ?? "idle" /* Idle */;
|
|
518
|
+
return ref.fsm?.getState() ?? "idle" /* Idle */;
|
|
519
|
+
},
|
|
520
|
+
isGrounded: () => readBehaviorSnapshot(ref)?.grounded ?? ref.fsm?.isGrounded() ?? false,
|
|
521
|
+
getJumpCount: () => readBehaviorSnapshot(ref)?.jumpCount ?? ref.fsm?.getJumpCount() ?? 0,
|
|
538
522
|
onPlatformCollision: (ctx) => ref.fsm?.handleCollision(ctx)
|
|
539
523
|
})
|
|
540
524
|
});
|
|
@@ -546,7 +530,7 @@ export {
|
|
|
546
530
|
Platformer3DState,
|
|
547
531
|
Platformer3DEvent,
|
|
548
532
|
Platformer3DFSM,
|
|
549
|
-
|
|
550
|
-
|
|
533
|
+
Platformer3DSystem,
|
|
534
|
+
Platformer3DBehavior
|
|
551
535
|
};
|
|
552
|
-
//# sourceMappingURL=chunk-
|
|
536
|
+
//# sourceMappingURL=chunk-67XLJ26X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/behaviors/platformer-3d/components.ts","../src/lib/behaviors/platformer-3d/platformer-3d-fsm.ts","../src/lib/behaviors/platformer-3d/platformer-3d.system.ts","../src/lib/behaviors/platformer-3d/platformer-3d.descriptor.ts"],"sourcesContent":["/**\n * Platformer 3D ECS Components\n * \n * Components for 3D platformer movement system including walking, running,\n * jumping with multi-jump support, and falling/landing states.\n */\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Platformer3DMovementComponent (capability / configuration)\n// Defines the movement capabilities and physics parameters\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface Platformer3DMovementComponent {\n\t/** Base walking speed */\n\twalkSpeed: number;\n\t/** Sprint/run speed */\n\trunSpeed: number;\n\t/** Initial jump force/velocity */\n\tjumpForce: number;\n\t/** Maximum number of jumps (1 = single jump, 2 = double jump, etc.) */\n\tmaxJumps: number;\n\t/** Gravity force (optional override) */\n\tgravity: number;\n\t/** Coyote time in seconds (grace period after leaving ground) */\n\tcoyoteTime: number;\n\t/** Jump buffer time in seconds (queue jump input before landing) */\n\tjumpBufferTime: number;\n\t/** Velocity multiplier when releasing jump button early (0-1) */\n\tjumpCutMultiplier: number;\n\t/** Time in seconds before multi-jump becomes available (0 = after button release) */\n\tmultiJumpWindowTime: number;\n\t/** Maximum slope angle (degrees) the character can walk up */\n\tslopeClimbAngle: number;\n\t/** Slope angle (degrees) past which the character slides down */\n\tslopeSlideAngle: number;\n\t/** Autostep configuration for small ledges, or false to disable */\n\tautostep: { maxHeight: number; minWidth: number } | false;\n\t/** Snap-to-ground distance (keeps the character glued going downhill) */\n\tsnapToGroundDistance: number;\n\t/** Character controller offset (small gap kept between collider and environment) */\n\tcharacterOffset: number;\n}\n\nexport function createPlatformer3DMovementComponent(\n\toptions: Partial<Platformer3DMovementComponent> = {}\n): Platformer3DMovementComponent {\n\treturn {\n\t\twalkSpeed: options.walkSpeed ?? 12,\n\t\trunSpeed: options.runSpeed ?? 24,\n\t\tjumpForce: options.jumpForce ?? 12,\n\t\tmaxJumps: options.maxJumps ?? 1,\n\t\tgravity: options.gravity ?? 9.82,\n\t\tcoyoteTime: options.coyoteTime ?? 0.1,\n\t\tjumpBufferTime: options.jumpBufferTime ?? 0.1,\n\t\tjumpCutMultiplier: options.jumpCutMultiplier ?? 0.5,\n\t\tmultiJumpWindowTime: options.multiJumpWindowTime ?? 0.15, // 150ms default\n\t\tslopeClimbAngle: options.slopeClimbAngle ?? 50,\n\t\tslopeSlideAngle: options.slopeSlideAngle ?? 40,\n\t\tautostep: options.autostep ?? { maxHeight: 0.3, minWidth: 0.1 },\n\t\tsnapToGroundDistance: options.snapToGroundDistance ?? 0.3,\n\t\tcharacterOffset: options.characterOffset ?? 0.05,\n\t};\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Platformer3DInputComponent (intent)\n// Written by: Player controller, AI controller\n// Read by: Platformer3DBehavior\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface Platformer3DInputComponent {\n\t/** Horizontal movement input (-1 to 1) */\n\tmoveX: number;\n\t/** Forward/backward movement input (-1 to 1) */\n\tmoveZ: number;\n\t/** Jump button pressed */\n\tjump: boolean;\n\t/** Run/sprint button held */\n\trun: boolean;\n}\n\nexport function createPlatformer3DInputComponent(): Platformer3DInputComponent {\n\treturn {\n\t\tmoveX: 0,\n\t\tmoveZ: 0,\n\t\tjump: false,\n\t\trun: false,\n\t};\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Platformer3DStateComponent (runtime state)\n// Tracks the current state of the platformer entity\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface Platformer3DStateComponent {\n\t/** Is the entity on the ground */\n\tgrounded: boolean;\n\t/** Is currently in a jump arc */\n\tjumping: boolean;\n\t/** Is falling (not jumping) */\n\tfalling: boolean;\n\t/** Current jump count (for multi-jump) */\n\tjumpCount: number;\n\t/** Y position when jump started */\n\tjumpStartHeight: number;\n\t/** Current movement speed being applied */\n\tcurrentSpeed: number;\n\t/** Last known ground Y position */\n\tlastGroundedY: number;\n\t/** Was jump button pressed last frame (for edge detection) */\n\tjumpPressedLastFrame: boolean;\n\t\n\t// -- New fields --\n\t/** Is currently colliding with ground (from physics collision callback) */\n\tcollisionGrounded: boolean;\n\t/** Timestamp of last ground collision */\n\tgroundedCollisionTime: number;\n\t/** Time in seconds since last grounded */\n\ttimeSinceGrounded: number;\n\t/** Is a jump allowed due to buffer? */\n\tjumpBuffered: boolean;\n\t/** Time remaining in jump buffer */\n\tjumpBufferTimer: number;\n\t/** Is jump button currently held */\n\tjumpHeld: boolean;\n\t/** Has the jump cut been applied for this jump? */\n\tjumpCutApplied: boolean;\n\t/** Has jump button been released since last jump (required for multi-jump) */\n\tjumpReleasedSinceLastJump: boolean;\n\t/** Time since current jump started (for multi-jump window) */\n\ttimeSinceJump: number;\n\t/** True for the single frame on which a jump impulse was applied; prevents gravity from clobbering jump velocity. */\n\tjumpedThisFrame: boolean;\n\t/** Remaining seconds of jump-cut velocity ramp; while > 0, verticalVelocity lerps toward verticalVelocity * jumpCutMultiplier. */\n\tjumpCutRampTimer: number;\n\t/**\n\t * Controller-owned vertical velocity (units/second).\n\t * The body is kinematic, so `linvel()` is meaningless — this field is the\n\t * single source of truth for jump/gravity motion on the Y axis.\n\t */\n\tverticalVelocity: number;\n}\n\nexport function createPlatformer3DStateComponent(): Platformer3DStateComponent {\n\treturn {\n\t\tgrounded: false,\n\t\tjumping: false,\n\t\tfalling: false,\n\t\tjumpCount: 0,\n\t\tjumpStartHeight: 0,\n\t\tcurrentSpeed: 0,\n\t\tlastGroundedY: 0,\n\t\tjumpPressedLastFrame: false,\n\t\tcollisionGrounded: false,\n\t\tgroundedCollisionTime: 0,\n\t\ttimeSinceGrounded: 0,\n\t\tjumpBuffered: false,\n\t\tjumpBufferTimer: 0,\n\t\tjumpHeld: false,\n\t\tjumpCutApplied: false,\n\t\tjumpReleasedSinceLastJump: true,\n\t\ttimeSinceJump: 0,\n\t\tjumpedThisFrame: false,\n\t\tjumpCutRampTimer: 0,\n\t\tverticalVelocity: 0,\n\t};\n}\n","/**\n * Platformer 3D Finite State Machine\n * \n * Manages state transitions for 3D platformer movement:\n * - Idle: Standing still on ground\n * - Walking: Moving on ground (slow)\n * - Running: Moving on ground (fast)\n * - Jumping: Ascending from jump\n * - Falling: Descending (gravity)\n * - Landing: Just touched ground\n */\n\nimport { SyncStateMachine, t } from '../../core/utility/sync-state-machine';\nimport type { Platformer3DInputComponent, Platformer3DStateComponent } from './components';\n\n/**\n * Simplified Collision Context interface\n */\nexport interface PlatformerCollisionContext {\n\tcontact: {\n\t\tnormal: { x: number; y: number; z?: number };\n\t};\n}\n\n/**\n * Platformer states\n */\nexport enum Platformer3DState {\n\tIdle = 'idle',\n\tWalking = 'walking',\n\tRunning = 'running',\n\tJumping = 'jumping',\n\tFalling = 'falling',\n\tLanding = 'landing',\n}\n\n/**\n * Events that trigger state transitions\n */\nexport enum Platformer3DEvent {\n\tWalk = 'walk',\n\tRun = 'run',\n\tJump = 'jump',\n\tFall = 'fall',\n\tLand = 'land',\n\tStop = 'stop',\n}\n\n/**\n * Context for the FSM\n */\nexport interface Platformer3DContext {\n\tinput: Platformer3DInputComponent;\n\tstate: Platformer3DStateComponent;\n}\n\n/**\n * Platformer 3D FSM\n */\nexport class Platformer3DFSM {\n\tmachine: SyncStateMachine<Platformer3DState, Platformer3DEvent, never>;\n\n\tconstructor(private ctx: Platformer3DContext) {\n\t\tthis.machine = new SyncStateMachine<Platformer3DState, Platformer3DEvent, never>(\n\t\t\tPlatformer3DState.Idle,\n\t\t\t[\n\t\t\t\t// Idle transitions\n\t\t\t\tt(Platformer3DState.Idle, Platformer3DEvent.Walk, Platformer3DState.Walking),\n\t\t\t\tt(Platformer3DState.Idle, Platformer3DEvent.Run, Platformer3DState.Running),\n\t\t\t\tt(Platformer3DState.Idle, Platformer3DEvent.Jump, Platformer3DState.Jumping),\n\t\t\t\tt(Platformer3DState.Idle, Platformer3DEvent.Fall, Platformer3DState.Falling),\n\t\t\t\t\n\t\t\t\t// Walking transitions\n\t\t\t\tt(Platformer3DState.Walking, Platformer3DEvent.Run, Platformer3DState.Running),\n\t\t\t\tt(Platformer3DState.Walking, Platformer3DEvent.Jump, Platformer3DState.Jumping),\n\t\t\t\tt(Platformer3DState.Walking, Platformer3DEvent.Stop, Platformer3DState.Idle),\n\t\t\t\tt(Platformer3DState.Walking, Platformer3DEvent.Fall, Platformer3DState.Falling),\n\t\t\t\t\n\t\t\t\t// Running transitions\n\t\t\t\tt(Platformer3DState.Running, Platformer3DEvent.Walk, Platformer3DState.Walking),\n\t\t\t\tt(Platformer3DState.Running, Platformer3DEvent.Jump, Platformer3DState.Jumping),\n\t\t\t\tt(Platformer3DState.Running, Platformer3DEvent.Stop, Platformer3DState.Idle),\n\t\t\t\tt(Platformer3DState.Running, Platformer3DEvent.Fall, Platformer3DState.Falling),\n\t\t\t\t\n\t\t\t\t// Jumping transitions\n\t\t\t\tt(Platformer3DState.Jumping, Platformer3DEvent.Fall, Platformer3DState.Falling),\n\t\t\t\tt(Platformer3DState.Jumping, Platformer3DEvent.Land, Platformer3DState.Landing),\n\t\t\t\tt(Platformer3DState.Jumping, Platformer3DEvent.Jump, Platformer3DState.Jumping), // Multi-jump\n\t\t\t\t\n\t\t\t\t// Falling transitions\n\t\t\t\tt(Platformer3DState.Falling, Platformer3DEvent.Land, Platformer3DState.Landing),\n\t\t\t\t\n\t\t\t\t// Landing transitions\n\t\t\t\tt(Platformer3DState.Landing, Platformer3DEvent.Walk, Platformer3DState.Walking),\n\t\t\t\tt(Platformer3DState.Landing, Platformer3DEvent.Run, Platformer3DState.Running),\n\t\t\t\tt(Platformer3DState.Landing, Platformer3DEvent.Stop, Platformer3DState.Idle),\n\t\t\t\t\n\t\t\t\t// Self-transitions (no-ops)\n\t\t\t\tt(Platformer3DState.Idle, Platformer3DEvent.Stop, Platformer3DState.Idle),\n\t\t\t]\n\t\t);\n\t}\n\n\t/**\n\t * Get the current state\n\t */\n\tgetState(): Platformer3DState {\n\t\treturn this.machine.getState();\n\t}\n\n\t/**\n\t * Dispatch an event to the FSM\n\t */\n\tdispatch(event: Platformer3DEvent): void {\n\t\tif (this.machine.can(event)) {\n\t\t\tthis.machine.syncDispatch(event);\n\t\t}\n\t}\n\n\t/**\n\t * Check if grounded\n\t */\n\tisGrounded(): boolean {\n\t\tconst state = this.getState();\n\t\treturn state === Platformer3DState.Idle || \n\t\t state === Platformer3DState.Walking || \n\t\t state === Platformer3DState.Running || \n\t\t state === Platformer3DState.Landing;\n\t}\n\n\t/**\n\t * Get current jump count from context\n\t */\n\tgetJumpCount(): number {\n\t\treturn this.ctx.state.jumpCount;\n\t}\n\n\t/**\n\t * Handle collision event to update ground state\n\t */\n\thandleCollision(ctx: PlatformerCollisionContext): void {\n\t\t// Check if collision is ground (normal pointing up)\n\t\t// Y normal > 0.5 means roughly within 60 degrees of up\n\t\tif (ctx.contact.normal.y > 0.5) {\n\t\t\tthis.ctx.state.collisionGrounded = true;\n\t\t\tthis.ctx.state.groundedCollisionTime = performance.now();\n\t\t}\n\t}\n\n\t/**\n\t * Update FSM based on current state\n\t */\n\tupdate(input: Platformer3DInputComponent, state: Platformer3DStateComponent): void {\n\t\t// Update context\n\t\tthis.ctx.input = input;\n\t\tthis.ctx.state = state;\n\n\t\t// Get current FSM state\n\t\tconst currentState = this.getState();\n\n\t\t// Determine movement state\n\t\tconst hasInput = Math.abs(input.moveX) > 0.1 || Math.abs(input.moveZ) > 0.1;\n\t\tconst isRunning = input.run;\n\n\t\t// Handle landing: if we're in falling state and now grounded, land\n\t\tif (currentState === Platformer3DState.Falling && state.grounded) {\n\t\t\tthis.dispatch(Platformer3DEvent.Land);\n\t\t\t// Don't return - allow immediate transition to movement state\n\t\t}\n\n\t\t// Send appropriate events based on state\n\t\tif (state.grounded) {\n\t\t\tif (hasInput) {\n\t\t\t\tif (isRunning) {\n\t\t\t\t\tthis.dispatch(Platformer3DEvent.Run);\n\t\t\t\t} else {\n\t\t\t\t\tthis.dispatch(Platformer3DEvent.Walk);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.dispatch(Platformer3DEvent.Stop);\n\t\t\t}\n\t\t} else {\n\t\t\t// Not grounded - check if we should be falling\n\t\t\t// Transition to falling if: We're in jumping state and now falling, \n\t\t\t// OR we walked off a ledge (idle/walking/running and now falling)\n\t\t\tif (state.falling) {\n\t\t\t\tthis.dispatch(Platformer3DEvent.Fall);\n\t\t\t}\n\t\t}\n\n\t\t// Handle jump input (edge detection handled in behavior)\n\t\tif (input.jump && !state.jumpPressedLastFrame) {\n\t\t\tthis.dispatch(Platformer3DEvent.Jump);\n\t\t}\n\t}\n}\n","/**\n * Platformer 3D System\n *\n * Kinematic character controller (N64-style): the controller owns all motion\n * and physics is only a collision database.\n *\n * - The entity's body is converted to `KinematicPositionBased` on first\n * update; Rapier never applies forces to it.\n * - Each tick, desired displacement (horizontal input + integrated vertical\n * velocity) is run through Rapier's `KinematicCharacterController`\n * (collide-and-slide with autostep, slope limits, and snap-to-ground) and\n * the corrected movement is applied via `setNextKinematicTranslation`.\n * - Grounded comes from `controller.computedGrounded()` — no contact-pair or\n * raycast probing.\n * - Vertical velocity lives in `state.verticalVelocity` (`linvel()` is\n * meaningless on kinematic bodies). Jump buffering, coyote time,\n * multi-jump, and the jump-cut ramp all operate on that field.\n */\n\nimport { RigidBodyType, QueryFilterFlags } from '@dimforge/rapier3d-compat';\nimport type { Collider, KinematicCharacterController, RigidBody } from '@dimforge/rapier3d-compat';\nimport type { ZylemWorld } from '../../collision/world';\nimport type {\n\tPlatformer3DMovementComponent,\n\tPlatformer3DInputComponent,\n\tPlatformer3DStateComponent,\n} from './components';\n\n/**\n * Duration of the jump-cut velocity ramp in seconds.\n * Instead of halving vertical velocity in a single frame (which produces a\n * visible camera pop), we lerp toward the cut velocity across roughly 3\n * physics steps at 60 Hz.\n */\nconst JUMP_CUT_RAMP_DURATION = 0.05;\n\n/**\n * Constant downward speed applied while grounded (units/second). Keeps the\n * controller pressed into the ground so `computedGrounded()` stays engaged on\n * flat ground and going downhill (snap-to-ground handles larger drops).\n */\nconst GROUND_STICK_SPEED = 2;\n\n/** Vertical speed below which the airborne state flips from jumping to falling. */\nconst FALL_VELOCITY_THRESHOLD = -0.1;\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Entity with platformer components\n */\nexport interface Platformer3DEntity {\n\tuuid: string;\n\tbody: RigidBody;\n\tcollider?: Collider | null;\n\tplatformer: Platformer3DMovementComponent;\n\t$platformer: Platformer3DInputComponent;\n\tplatformerState: Platformer3DStateComponent;\n}\n\n/** Scratch vector reused for the desired per-tick displacement. */\nconst _desired = { x: 0, y: 0, z: 0 };\n\n/**\n * Platformer 3D movement system.\n *\n * Core kinematic controller for 3D platformer movement. Requires a live\n * `ZylemWorld` with the raw Rapier `World` exposed on `.world` — without it\n * the system is a no-op (the WASM fast path handles that case upstream).\n */\nexport class Platformer3DSystem {\n\tprivate world: ZylemWorld | null;\n\t/** Per-entity character controllers, keyed by entity uuid. */\n\tprivate controllers = new Map<string, KinematicCharacterController>();\n\n\tconstructor(world: ZylemWorld | null) {\n\t\tthis.world = world;\n\t}\n\n\t/**\n\t * One-time per-entity physics setup: convert the body to a\n\t * position-based kinematic body and create its character controller.\n\t * Done lazily on the first update because the body isn't always\n\t * available at construction time.\n\t */\n\tprivate ensurePhysicsConfigured(entity: Platformer3DEntity): KinematicCharacterController | null {\n\t\tconst existing = this.controllers.get(entity.uuid);\n\t\tif (existing) return existing;\n\n\t\tconst physicsWorld = this.world?.world;\n\t\tif (!physicsWorld || !entity.body) return null;\n\n\t\tif (entity.body.bodyType() !== RigidBodyType.KinematicPositionBased) {\n\t\t\tentity.body.setBodyType(RigidBodyType.KinematicPositionBased, true);\n\t\t}\n\n\t\tconst movement = entity.platformer;\n\t\tconst controller = physicsWorld.createCharacterController(movement.characterOffset);\n\t\tcontroller.setUp({ x: 0, y: 1, z: 0 });\n\t\tcontroller.setMaxSlopeClimbAngle(movement.slopeClimbAngle * DEG_TO_RAD);\n\t\tcontroller.setMinSlopeSlideAngle(movement.slopeSlideAngle * DEG_TO_RAD);\n\t\tif (movement.autostep) {\n\t\t\tcontroller.enableAutostep(movement.autostep.maxHeight, movement.autostep.minWidth, true);\n\t\t} else {\n\t\t\tcontroller.disableAutostep();\n\t\t}\n\t\tcontroller.enableSnapToGround(movement.snapToGroundDistance);\n\t\tcontroller.setApplyImpulsesToDynamicBodies(true);\n\n\t\tthis.controllers.set(entity.uuid, controller);\n\t\treturn controller;\n\t}\n\n\t/**\n\t * Handle jump logic with multi-jump, coyote time, buffering, and jump-cut\n\t * ramp. All vertical motion is written to `state.verticalVelocity`.\n\t */\n\tprivate handleJump(entity: Platformer3DEntity, delta: number): void {\n\t\tconst input = entity.$platformer;\n\t\tconst movement = entity.platformer;\n\t\tconst state = entity.platformerState;\n\n\t\t// Track time since last jump (for multi-jump window)\n\t\tif (state.jumping || state.falling) {\n\t\t\tstate.timeSinceJump += delta;\n\t\t}\n\n\t\t// Track jump button release (required for multi-jump)\n\t\tif (!input.jump && state.jumpHeld) {\n\t\t\tstate.jumpReleasedSinceLastJump = true;\n\t\t}\n\n\t\t// 1. Jump Buffering - queue on new press\n\t\tif (input.jump && !state.jumpPressedLastFrame) {\n\t\t\tstate.jumpBuffered = true;\n\t\t\tstate.jumpBufferTimer = movement.jumpBufferTime;\n\t\t}\n\n\t\tstate.jumpPressedLastFrame = input.jump;\n\t\tstate.jumpHeld = input.jump;\n\n\t\t// Decrement buffer timer\n\t\tif (state.jumpBuffered) {\n\t\t\tstate.jumpBufferTimer -= delta;\n\t\t\tif (state.jumpBufferTimer <= 0) {\n\t\t\t\tstate.jumpBuffered = false;\n\t\t\t}\n\t\t}\n\n\t\t// 2. Variable Jump Height (Jump Cut)\n\t\t// Only trigger a cut if we've been jumping for a bit (prevents cutting multi-jump immediately).\n\t\tconst minTimeBeforeCut = 0.1;\n\t\tconst canApplyCut = state.timeSinceJump >= minTimeBeforeCut;\n\t\tif (!input.jump && state.jumping && !state.jumpCutApplied && canApplyCut) {\n\t\t\tstate.jumpCutApplied = true;\n\t\t\tstate.jumpCutRampTimer = JUMP_CUT_RAMP_DURATION;\n\t\t}\n\n\t\t// 2a. Ramp verticalVelocity toward verticalVelocity * jumpCutMultiplier\n\t\t// across the ramp window so the change isn't a single-frame discontinuity.\n\t\tif (state.jumpCutRampTimer > 0) {\n\t\t\tif (state.verticalVelocity > 0) {\n\t\t\t\tconst stepT = Math.min(delta / state.jumpCutRampTimer, 1);\n\t\t\t\tconst targetY = state.verticalVelocity * movement.jumpCutMultiplier;\n\t\t\t\tstate.verticalVelocity += (targetY - state.verticalVelocity) * stepT;\n\t\t\t}\n\t\t\tstate.jumpCutRampTimer = Math.max(0, state.jumpCutRampTimer - delta);\n\t\t}\n\n\t\t// Execute Jump (if buffered input exists)\n\t\tif (!state.jumpBuffered) return;\n\n\t\t// 3. Jump eligibility check\n\t\tconst inCoyoteWindow = !state.grounded && state.timeSinceGrounded <= movement.coyoteTime;\n\t\tconst isFirstJump = state.grounded || (inCoyoteWindow && state.jumpCount === 0);\n\n\t\t// Multi-jump requirements:\n\t\t// 1. Not grounded\n\t\t// 2. Have jumps remaining\n\t\t// 3. Button was released since last jump (no holding for double jump)\n\t\t// 4. Within the jump window (after multiJumpWindowTime has passed)\n\t\tconst hasJumpsRemaining = state.jumpCount < movement.maxJumps;\n\t\tconst buttonReleased = state.jumpReleasedSinceLastJump;\n\t\tconst inMultiJumpWindow = state.timeSinceJump >= movement.multiJumpWindowTime;\n\t\tconst canMultiJump = !state.grounded && hasJumpsRemaining && buttonReleased && inMultiJumpWindow;\n\n\t\tif (isFirstJump || canMultiJump) {\n\t\t\t// Consume buffered input\n\t\t\tstate.jumpBuffered = false;\n\n\t\t\t// Increment jump count and reset tracking\n\t\t\tstate.jumpCount++;\n\t\t\tstate.jumpReleasedSinceLastJump = false; // Must release again for next jump\n\t\t\tstate.timeSinceJump = 0; // Reset window timer\n\n\t\t\t// Record jump start height\n\t\t\tstate.jumpStartHeight = entity.body.translation().y;\n\n\t\t\t// Apply jump force\n\t\t\tstate.jumping = true;\n\t\t\tstate.falling = false;\n\t\t\tstate.jumpCutApplied = false;\n\t\t\tstate.jumpCutRampTimer = 0;\n\n\t\t\tstate.verticalVelocity = movement.jumpForce;\n\n\t\t\t// Flag this frame so applyGravity skips exactly one grounded\n\t\t\t// clamp/gravity step (the jump velocity is authoritative).\n\t\t\tstate.jumpedThisFrame = true;\n\t\t}\n\t}\n\n\t/**\n\t * Integrate gravity into `state.verticalVelocity`.\n\t *\n\t * While grounded (and not on the jump frame) vertical velocity is held at\n\t * a small constant downward speed so the controller stays pressed into\n\t * the ground. Skipped entirely on the frame a jump was applied — the\n\t * grounded flag is still stale-true then and would clobber the jump.\n\t */\n\tprivate applyGravity(entity: Platformer3DEntity, delta: number): void {\n\t\tconst movement = entity.platformer;\n\t\tconst state = entity.platformerState;\n\n\t\tif (state.jumpedThisFrame) {\n\t\t\tstate.jumpedThisFrame = false;\n\t\t\treturn;\n\t\t}\n\n\t\tif (state.grounded) {\n\t\t\tstate.verticalVelocity = -GROUND_STICK_SPEED;\n\t\t\treturn;\n\t\t}\n\n\t\tstate.verticalVelocity -= movement.gravity * delta;\n\t}\n\n\t/**\n\t * Update entity state from the controller's grounded result.\n\t */\n\tprivate updateState(entity: Platformer3DEntity, delta: number, computedGrounded: boolean): void {\n\t\tconst state = entity.platformerState;\n\t\tconst wasGrounded = state.grounded;\n\n\t\tconst isAirborne = state.jumping || state.falling;\n\t\tlet isGrounded: boolean;\n\t\tif (isAirborne) {\n\t\t\t// Never land while still moving upward in a jump arc.\n\t\t\tconst canLand = state.falling && !state.jumping;\n\t\t\tisGrounded = computedGrounded && canLand;\n\t\t} else {\n\t\t\tisGrounded = computedGrounded;\n\t\t}\n\n\t\tstate.grounded = isGrounded;\n\n\t\tif (state.grounded) {\n\t\t\tstate.timeSinceGrounded = 0;\n\t\t\tstate.lastGroundedY = entity.body.translation().y;\n\t\t} else {\n\t\t\tstate.timeSinceGrounded += delta;\n\t\t}\n\n\t\tif (!wasGrounded && state.grounded) {\n\t\t\tstate.jumpCount = 0;\n\t\t\tstate.jumping = false;\n\t\t\tstate.falling = false;\n\t\t\tstate.jumpCutApplied = false;\n\t\t\tstate.jumpCutRampTimer = 0;\n\t\t\tif (state.verticalVelocity < 0) {\n\t\t\t\tstate.verticalVelocity = 0;\n\t\t\t}\n\t\t}\n\n\t\tif (state.verticalVelocity < FALL_VELOCITY_THRESHOLD && !state.grounded) {\n\t\t\tif (state.jumping) {\n\t\t\t\tstate.jumping = false;\n\t\t\t\tstate.falling = true;\n\t\t\t} else if (!state.jumping) {\n\t\t\t\tstate.falling = true;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Update one platformer entity. Invoked per linked entity by the\n\t * Platformer3DBehaviorSystem adapter.\n\t */\n\tupdateEntity(entity: Platformer3DEntity, delta: number): void {\n\t\tif (!entity.platformer || !entity.$platformer || !entity.platformerState) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst controller = this.ensurePhysicsConfigured(entity);\n\t\tconst collider = entity.collider;\n\t\tif (!controller || !collider) return;\n\n\t\tconst input = entity.$platformer;\n\t\tconst movement = entity.platformer;\n\t\tconst state = entity.platformerState;\n\n\t\t// 1. Jump logic (may set verticalVelocity = jumpForce this frame)\n\t\tthis.handleJump(entity, delta);\n\n\t\t// 2. Gravity / grounded stick on verticalVelocity\n\t\tthis.applyGravity(entity, delta);\n\n\t\t// 3. Desired displacement for this tick\n\t\tconst speed = input.run ? movement.runSpeed : movement.walkSpeed;\n\t\tstate.currentSpeed = speed;\n\t\t_desired.x = input.moveX * speed * delta;\n\t\t_desired.y = state.verticalVelocity * delta;\n\t\t_desired.z = input.moveZ * speed * delta;\n\n\t\t// 4. Collide-and-slide\n\t\tcontroller.computeColliderMovement(collider, _desired, QueryFilterFlags.EXCLUDE_SENSORS);\n\t\tconst corrected = controller.computedMovement();\n\n\t\t// Head bump: upward motion was blocked, so kill the remaining ascent\n\t\t// instead of hanging under the ceiling for the rest of the arc.\n\t\tif (_desired.y > 1e-9 && corrected.y < _desired.y * 0.5) {\n\t\t\tstate.verticalVelocity = 0;\n\t\t}\n\n\t\tconst translation = entity.body.translation();\n\t\tentity.body.setNextKinematicTranslation({\n\t\t\tx: translation.x + corrected.x,\n\t\t\ty: translation.y + corrected.y,\n\t\t\tz: translation.z + corrected.z,\n\t\t});\n\n\t\t// 5. State transitions from the controller's grounded result\n\t\tthis.updateState(entity, delta, controller.computedGrounded());\n\t}\n\n\tdestroy(): void {\n\t\tconst physicsWorld = this.world?.world;\n\t\tif (physicsWorld) {\n\t\t\tfor (const controller of this.controllers.values()) {\n\t\t\t\tphysicsWorld.removeCharacterController(controller);\n\t\t\t}\n\t\t}\n\t\tthis.controllers.clear();\n\t}\n}\n","/**\n * Platformer 3D Behavior Descriptor\n * \n * Type-safe descriptor for the platformer 3D behavior system.\n * Provides entity.use() API for 3D platformer movement.\n */\n\nimport { defineBehavior } from '../behavior-descriptor';\nimport type { BehaviorEntityLink, BehaviorSystem } from '../behavior-system';\nimport { Platformer3DSystem, Platformer3DEntity } from './platformer-3d.system';\nimport type { ZylemWorld } from '../../collision/world';\nimport { Platformer3DFSM, Platformer3DState, PlatformerCollisionContext } from './platformer-3d-fsm';\nimport {\n\tcreatePlatformer3DMovementComponent,\n\tcreatePlatformer3DInputComponent,\n\tcreatePlatformer3DStateComponent,\n} from './components';\nimport {\n\tSTAGE_INPUT_BUTTON_JUMP,\n\tSTAGE_INPUT_BUTTON_RUN,\n\treadBehaviorSnapshot,\n\ttype WasmStageRuntime,\n} from '../../runtime/wasm-stage-runtime';\n\n/** Rust `Platformer3DFsmState` index → TS state (see `platformer_3d/fsm.rs`). */\nconst FSM_STATE_BY_INDEX: readonly Platformer3DState[] = [\n\tPlatformer3DState.Idle,\n\tPlatformer3DState.Walking,\n\tPlatformer3DState.Running,\n\tPlatformer3DState.Jumping,\n\tPlatformer3DState.Falling,\n\tPlatformer3DState.Landing,\n];\n\n/**\n * Platformer behavior options (typed for entity.use() autocomplete)\n */\nexport interface Platformer3DBehaviorOptions {\n\t/** Base walking speed (default: 12) */\n\twalkSpeed?: number;\n\t/** Sprint/run speed (default: 24) */\n\trunSpeed?: number;\n\t/** Initial jump force (default: 12) */\n\tjumpForce?: number;\n\t/** Maximum number of jumps (default: 1) */\n\tmaxJumps?: number;\n\t/** Gravity force (default: 9.82) */\n\tgravity?: number;\n\t/** Maximum slope angle in degrees the character can walk up (default: 50) */\n\tslopeClimbAngle?: number;\n\t/** Slope angle in degrees past which the character slides (default: 40) */\n\tslopeSlideAngle?: number;\n\t/** Autostep over small ledges, or false to disable (default: { maxHeight: 0.3, minWidth: 0.1 }) */\n\tautostep?: { maxHeight: number; minWidth: number } | false;\n\t/** Snap-to-ground distance for downhill/step-down stability (default: 0.3) */\n\tsnapToGroundDistance?: number;\n\t/** Character controller collision offset (default: 0.05) */\n\tcharacterOffset?: number;\n}\n\nconst defaultOptions: Platformer3DBehaviorOptions = {\n\twalkSpeed: 12,\n\trunSpeed: 24,\n\tjumpForce: 12,\n\tmaxJumps: 1,\n\tgravity: 9.82,\n\tslopeClimbAngle: 50,\n\tslopeSlideAngle: 40,\n\tautostep: { maxHeight: 0.3, minWidth: 0.1 },\n\tsnapToGroundDistance: 0.3,\n\tcharacterOffset: 0.05,\n};\n\nconst PLATFORMER_BEHAVIOR_KEY = Symbol.for('zylem:behavior:platformer-3d');\n\n/**\n * Adapter that wraps Platformer3DSystem as a BehaviorSystem\n */\nclass Platformer3DBehaviorSystem implements BehaviorSystem {\n\tprivate movementBehavior: Platformer3DSystem;\n\tprivate attachedRuntimeSlots = new Set<number>();\n\n\tconstructor(\n\t\tworld: ZylemWorld | null,\n\t\tprivate wasmStage: WasmStageRuntime | null,\n\t\tprivate getBehaviorLinks?: (key: symbol) => Iterable<BehaviorEntityLink>,\n\t) {\n\t\tthis.movementBehavior = new Platformer3DSystem(world);\n\t}\n\n\tupdate(_ecs: unknown, delta: number): void {\n\t\tconst links = this.getBehaviorLinks?.(PLATFORMER_BEHAVIOR_KEY);\n\t\tif (!links) return;\n\n\t\tfor (const link of links) {\n\t\t\tconst gameEntity = link.entity as any;\n\t\t\tconst platformerRef = link.ref as any;\n\n\t\t\tconst options = platformerRef.options as Platformer3DBehaviorOptions;\n\n\t\t\tif (!gameEntity.platformer) {\n\t\t\t\tgameEntity.platformer = createPlatformer3DMovementComponent(options);\n\t\t\t}\n\t\t\tif (!gameEntity.$platformer) {\n\t\t\t\tgameEntity.$platformer = createPlatformer3DInputComponent();\n\t\t\t}\n\t\t\tif (!gameEntity.platformerState) {\n\t\t\t\tgameEntity.platformerState = createPlatformer3DStateComponent();\n\t\t\t}\n\n\t\t\t// Wasm fast path: forward input into the batched buffer and let\n\t\t\t// handles read the Rust FSM via the snapshot buffer — the TS FSM\n\t\t\t// is never created (single source of truth in the runtime).\n\t\t\tconst handle = (gameEntity.runtimeHandle ?? -1) as number;\n\t\t\tif (this.wasmStage && handle >= 0) {\n\t\t\t\tthis.ensureWasmAttached(handle, options);\n\t\t\t\tplatformerRef.__wasmStage = this.wasmStage;\n\t\t\t\tplatformerRef.__entity = gameEntity;\n\t\t\t\tconst input = gameEntity.$platformer;\n\t\t\t\tif (input) {\n\t\t\t\t\tthis.wasmStage.writeInputAxes(handle, input.moveX ?? 0, input.moveZ ?? 0);\n\t\t\t\t\tthis.wasmStage.writeInputButton(handle, STAGE_INPUT_BUTTON_JUMP, !!input.jump);\n\t\t\t\t\tthis.wasmStage.writeInputButton(handle, STAGE_INPUT_BUTTON_RUN, !!input.run);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!platformerRef.fsm && gameEntity.$platformer && gameEntity.platformerState) {\n\t\t\t\tplatformerRef.fsm = new Platformer3DFSM({\n\t\t\t\t\tinput: gameEntity.$platformer,\n\t\t\t\t\tstate: gameEntity.platformerState,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (platformerRef.fsm && gameEntity.$platformer && gameEntity.platformerState) {\n\t\t\t\tplatformerRef.fsm.update(gameEntity.$platformer, gameEntity.platformerState);\n\t\t\t}\n\n\t\t\tif (!gameEntity.body) continue;\n\t\t\tthis.movementBehavior.updateEntity(gameEntity, delta);\n\t\t}\n\t}\n\n\tprivate ensureWasmAttached(handle: number, options: Platformer3DBehaviorOptions): void {\n\t\tif (!this.wasmStage || this.attachedRuntimeSlots.has(handle)) return;\n\t\tconst autostep = options.autostep ?? defaultOptions.autostep!;\n\t\tthis.wasmStage.attachPlatformer3D(handle, {\n\t\t\thalfHeight: 0.9,\n\t\t\tradius: 0.4,\n\t\t\twalkSpeed: options.walkSpeed ?? defaultOptions.walkSpeed!,\n\t\t\trunSpeed: options.runSpeed ?? defaultOptions.runSpeed!,\n\t\t\tjumpForce: options.jumpForce ?? defaultOptions.jumpForce!,\n\t\t\tmaxJumps: options.maxJumps ?? defaultOptions.maxJumps!,\n\t\t\tgravity: options.gravity ?? defaultOptions.gravity!,\n\t\t\tslopeClimbAngle: options.slopeClimbAngle ?? defaultOptions.slopeClimbAngle!,\n\t\t\tslopeSlideAngle: options.slopeSlideAngle ?? defaultOptions.slopeSlideAngle!,\n\t\t\tautostepHeight: autostep ? autostep.maxHeight : 0,\n\t\t\tautostepMinWidth: autostep ? autostep.minWidth : 0.1,\n\t\t\tsnapToGroundDistance: options.snapToGroundDistance ?? defaultOptions.snapToGroundDistance!,\n\t\t\tcharacterOffset: options.characterOffset ?? defaultOptions.characterOffset!,\n\t\t});\n\t\tthis.attachedRuntimeSlots.add(handle);\n\t}\n\n\tdestroy(_ecs: unknown): void {\n\t\tthis.movementBehavior.destroy();\n\t\tthis.attachedRuntimeSlots.clear();\n\t}\n}\n\n/**\n * Platformer3DBehavior - typed descriptor for 3D platformer movement\n * \n * Provides complete 3D platformer physics including:\n * - Walking and running\n * - Jumping with multi-jump support\n * - Gravity and falling\n * - Ground detection\n * \n * @example\n * ```typescript\n * import { Platformer3DBehavior } from \"@zylem/game-lib/behavior\";\n * \n * const player = await playgroundActor('player');\n * const platformer = player.use(Platformer3DBehavior, {\n * walkSpeed: 12,\n * runSpeed: 24,\n * jumpForce: 12,\n * maxJumps: 2, // Double jump!\n * });\n * \n * // In update loop\n * player.onUpdate(({ inputs }) => {\n * player.$platformer.moveX = inputs.p1.axes.Horizontal.value;\n * player.$platformer.moveZ = inputs.p1.axes.Vertical.value;\n * player.$platformer.jump = inputs.p1.buttons.A.held > 0;\n * player.$platformer.run = inputs.p1.shoulders.LTrigger.held > 0;\n * \n * const state = platformer.getState();\n * const grounded = platformer.isGrounded();\n * });\n * ```\n */\nexport const Platformer3DBehavior = defineBehavior<\n\tPlatformer3DBehaviorOptions,\n\t{\n\t\tgetState: () => Platformer3DState;\n\t\tisGrounded: () => boolean;\n\t\tgetJumpCount: () => number;\n\t\tonPlatformCollision: (ctx: PlatformerCollisionContext) => void;\n\t},\n\tPlatformer3DEntity\n>({\n\tname: 'platformer-3d',\n\tdefaultOptions,\n\tsystemFactory: (ctx) =>\n\t\tnew Platformer3DBehaviorSystem(\n\t\t\tctx.world ?? null,\n\t\t\tctx.wasmStage ?? null,\n\t\t\tctx.getBehaviorLinks,\n\t\t),\n\t// On the wasm fast path the handle reads the runtime snapshot buffer\n\t// (values are from the end of the previous step — one-frame lag); the TS\n\t// FSM only backs the no-wasm fallback path.\n\tcreateHandle: (ref) => ({\n\t\tgetState: () => {\n\t\t\tconst snapshot = readBehaviorSnapshot(ref);\n\t\t\tif (snapshot) return FSM_STATE_BY_INDEX[snapshot.fsmState] ?? Platformer3DState.Idle;\n\t\t\treturn ref.fsm?.getState() ?? Platformer3DState.Idle;\n\t\t},\n\t\tisGrounded: () =>\n\t\t\treadBehaviorSnapshot(ref)?.grounded ?? ref.fsm?.isGrounded() ?? false,\n\t\tgetJumpCount: () =>\n\t\t\treadBehaviorSnapshot(ref)?.jumpCount ?? ref.fsm?.getJumpCount() ?? 0,\n\t\tonPlatformCollision: (ctx) => ref.fsm?.handleCollision(ctx),\n\t}),\n});\n"],"mappings":";;;;;;;;;;;;;;AA2CO,SAAS,oCACf,UAAkD,CAAC,GACnB;AAChC,SAAO;AAAA,IACN,WAAW,QAAQ,aAAa;AAAA,IAChC,UAAU,QAAQ,YAAY;AAAA,IAC9B,WAAW,QAAQ,aAAa;AAAA,IAChC,UAAU,QAAQ,YAAY;AAAA,IAC9B,SAAS,QAAQ,WAAW;AAAA,IAC5B,YAAY,QAAQ,cAAc;AAAA,IAClC,gBAAgB,QAAQ,kBAAkB;AAAA,IAC1C,mBAAmB,QAAQ,qBAAqB;AAAA,IAChD,qBAAqB,QAAQ,uBAAuB;AAAA;AAAA,IAC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