From 871a0d4edc68f9a513dff0ad7c39d1e8fb6e28f3 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 11 Apr 2026 18:35:55 +0200 Subject: [PATCH] Add player shape signature tracking and update logic --- src/runtime-three/rapier-collision-world.ts | 23 +++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/runtime-three/rapier-collision-world.ts b/src/runtime-three/rapier-collision-world.ts index 59f33edd..fb339bfb 100644 --- a/src/runtime-three/rapier-collision-world.ts +++ b/src/runtime-three/rapier-collision-world.ts @@ -355,13 +355,21 @@ export class RapierCollisionWorld { world.step(); - return new RapierCollisionWorld(world, characterController, playerCollider); + return new RapierCollisionWorld( + world, + characterController, + playerCollider, + playerShape.mode === "none" + ? null + : getFirstPersonPlayerShapeSignature(playerShape) + ); } private constructor( private readonly world: RAPIER.World, private readonly characterController: RAPIER.KinematicCharacterController | null, - private readonly playerCollider: RAPIER.Collider | null + private readonly playerCollider: RAPIER.Collider | null, + private currentPlayerShapeSignature: string | null ) {} private syncPlayerColliderShape(shape: FirstPersonPlayerShape) { @@ -371,14 +379,7 @@ export class RapierCollisionWorld { const nextSignature = getFirstPersonPlayerShapeSignature(shape); - if ( - this.playerCollider.userData === nextSignature || - this.playerCollider.userData === undefined - ) { - if (this.playerCollider.userData === undefined) { - this.playerCollider.userData = nextSignature; - } - + if (this.currentPlayerShapeSignature === nextSignature) { return; } @@ -400,7 +401,7 @@ export class RapierCollisionWorld { break; } - this.playerCollider.userData = nextSignature; + this.currentPlayerShapeSignature = nextSignature; } resolveFirstPersonMotion(feetPosition: Vec3, motion: Vec3, shape: FirstPersonPlayerShape): ResolvedPlayerMotion {