space-game/public/levels/rookie-training.json
Michael Mainguy e31e25f9e5 Fix physics issues: sleep behavior, center of mass, and input scaling
This commit resolves several physics-related issues that were causing
unexpected behavior in ship and asteroid movement:

**Physics Sleep System**
- Fixed abrupt stops by preventing Havok from putting bodies to sleep
- Added PhysicsActivationControl.ALWAYS_ACTIVE for ship and asteroids
- Made ship sleep behavior configurable via shipPhysics.alwaysActive
- Sleep was causing sudden velocity zeroing at low speeds

**Center of Mass Issues**
- Discovered mesh-based physics calculated offset CoM: (0, -0.38, 0.37)
- Override ship center of mass to (0, 0, 0) to prevent thrust torque
- Applying force at offset CoM was creating unwanted pitch rotation
- Added debug logging to track mass properties

**Input Deadzone Improvements**
- Implemented smooth deadzone scaling (0.1-0.15 range)
- Replaced hard threshold cliff with linear interpolation
- Prevents abrupt control cutoff during gentle inputs
- Added VR mode check to disable keyboard fallback in VR

**Configuration System**
- Added DEFAULT_SHIP_PHYSICS constant as single source of truth
- Added tunable parameters: linearDamping, angularDamping, alwaysActive
- Added fuel consumption rates: linearFuelConsumptionRate, angularFuelConsumptionRate
- Tuned for 1 minute linear thrust, 2 minutes angular thrust at 60Hz
- All physics parameters now persist to localStorage

**Other Fixes**
- Changed orbit center to STATIC motion type (was ANIMATED)
- Fixed linear force application point (removed offset)
- Added ship initial velocity support from level config
- Changed physics update from every 10 frames to every physics tick
- Increased linear input threshold from 0.1 to 0.15

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 14:03:32 -06:00

157 lines
3.0 KiB
JSON

{
"version": "1.1",
"difficulty": "recruit",
"timestamp": "2025-11-11T23:44:24.807Z",
"metadata": {
"author": "System",
"description": "Learn the basics of ship control and asteroid destruction in a calm sector of space.",
"estimatedTime": "3-5 minutes",
"type": "default"
},
"ship": {
"position": [
0,
2,
0
],
"rotation": [
0,
180,
0
],
"linearVelocity": [
0,
0,
0
],
"angularVelocity": [
0,
0,
0
]
},
"startBase": {
"position": [
0,
0,
0
],
"baseGlbPath": "base.glb"
},
"sun": {
"position": [
0,
0,
400
],
"diameter": 50,
"intensity": 1000000
},
"planets": [],
"asteroids": [
{
"id": "asteroid-0",
"position": [
-58.36428561508043,
-34.06637347343719,
-338.05090628315398
],
"scale": 10.625768191199857,
"linearVelocity": [
40.109444660495561,
20.469032555006988,
50.76122675780117
],
"angularVelocity": [
-0.9227568265038757,
0.8864368307279991,
0.2263811569998082
]
},
{
"id": "asteroid-1",
"position": [
-190.9219320499405,
-113.5286869174331,
109.66679494883233
],
"scale": 13.813320127774826,
"linearVelocity": [
50.192029331119596,
6.113911187593468,
-5.854367692424185
],
"angularVelocity": [
-0.13959509905525813,
-0.43731874553360095,
-0.7521225869488948
]
},
{
"id": "asteroid-2",
"position": [
-83.56705788144077,
64.21712690769468,
308.30902558008037
],
"scale": 11.275762178690638,
"linearVelocity": [
5.1248287379998665,
-3.8768500043399237,
-52.774747702523037
],
"angularVelocity": [
0.2651717231493369,
-0.7099071240513899,
0.1663263008032705
]
},
{
"id": "asteroid-3",
"position": [
217.1757715338133,
-61.659461955067925,
-44.39701192104106
],
"scale": 10.559754454640935,
"linearVelocity": [
-13.51279993073768,
3.8987073336340097,
2.7624073135533793
],
"angularVelocity": [
-0.11401525507789279,
-0.8495070152885558,
-0.14027260599293268
]
},
{
"id": "asteroid-4",
"position": [
-146.69138484095544,
-213.7144044815136,
-152.58815494515483
],
"scale": 14.914115364458254,
"linearVelocity": [
30.82941775132167,
-90.089462061108069,
12.30494231618762
],
"angularVelocity": [
-0.5051583421856027,
-0.2763521676136351,
-0.9366828390177142
]
}
],
"difficultyConfig": {
"rockCount": 5,
"forceMultiplier": 0.8,
"rockSizeMin": 10,
"rockSizeMax": 15,
"distanceMin": 220,
"distanceMax": 250
},
"useOrbitConstraints": true
}