@@ -60,7 +60,7 @@ class DragModeSystem extends WorldSystem {
6060 // Precision and sensitivity
6161 MINIMUM_DISTANCE_THRESHOLD : 0.02 , // Minimum distance to apply forces (smaller = more precision)
6262 WHEEL_SCROLL_SENSITIVITY : - 0.01 , // Mouse wheel scroll sensitivity for Z-axis
63- ROTATION_SPEED : 200 .0, // speed of arrow key rotation. lower = more precise, higher = more
63+ ROTATION_SPEED : 1500 .0, // speed of arrow key rotation. lower = more precise, higher = more
6464 } as const
6565
6666 private _enabled : boolean = false
@@ -566,17 +566,22 @@ class DragModeSystem extends WorldSystem {
566566 const joltForce = convertThreeVector3ToJoltVec3 ( forceNeeded )
567567 body . AddForce ( joltForce )
568568
569+ const inertia = body . GetMotionProperties ( ) . GetInverseInertiaDiagonal ( )
570+ const moi = 1.0 / inertia . Length ( )
569571 const yawRotation = new JOLT . Vec3 (
570572 0 ,
571- DragModeSystem . DRAG_FORCE_CONSTANTS . ROTATION_SPEED *
573+ moi *
574+ DragModeSystem . DRAG_FORCE_CONSTANTS . ROTATION_SPEED *
572575 ( InputSystem . isKeyPressed ( "ArrowRight" ) ? 1 : 0 - ( InputSystem . isKeyPressed ( "ArrowLeft" ) ? 1 : 0 ) ) ,
573576 0
574577 )
575578 const cameraVector = World . sceneRenderer . mainCamera . getWorldDirection ( new THREE . Vector3 ( 0 , 0 , 0 ) )
576579 const pitchRotation = new JOLT . Vec3 ( cameraVector . z , 0 , - cameraVector . x ) . Mul (
577- DragModeSystem . DRAG_FORCE_CONSTANTS . ROTATION_SPEED *
580+ moi *
581+ DragModeSystem . DRAG_FORCE_CONSTANTS . ROTATION_SPEED *
578582 ( InputSystem . isKeyPressed ( "ArrowUp" ) ? 1 : 0 - ( InputSystem . isKeyPressed ( "ArrowDown" ) ? 1 : 0 ) )
579583 )
584+
580585 body . AddTorque ( yawRotation )
581586 body . AddTorque ( pitchRotation )
582587 } else {
0 commit comments