Skip to content

feat: per-level physics config with gravity and simulation step knobs#251

Merged
marco-ponds merged 4 commits into
masterfrom
feat/per-level-physics-config
May 31, 2026
Merged

feat: per-level physics config with gravity and simulation step knobs#251
marco-ponds merged 4 commits into
masterfrom
feat/per-level-physics-config

Conversation

@marco-ponds

Copy link
Copy Markdown
Collaborator

Reshape Config storage to { common, levels } so any config block (today just physics) can be overridden per level, mirroring how Assets already handles common vs per-level state. Router pushes the current level into Config alongside Assets, so getters resolve common merged with the current level's overrides. Because each level switch already disposes and re-inits the physics worker, per-level physics flows through the existing LOAD.AMMO message without extra plumbing.

Physics gains fixedTimeStep (1/60) and maxSubSteps (3) alongside gravity (default bumped to -30 for game-feel parity with the third-person controller, which now reads gravity from Config). stepSimulation now uses Ammo's full signature instead of relying on Bullet defaults that silently dropped time on long frames.

Drive-by: setConfig was shallow with a buggy else-branch that lost nested defaults on partial overrides; it now deep-merges, so calls like setConfig({ physics: { enabled: true } }) preserve path/gravity instead of clobbering them.

marco-ponds and others added 4 commits May 19, 2026 14:44
Reshape Config storage to { common, levels } so any config block (today
just physics) can be overridden per level, mirroring how Assets already
handles common vs per-level state. Router pushes the current level into
Config alongside Assets, so getters resolve common merged with the
current level's overrides. Because each level switch already disposes
and re-inits the physics worker, per-level physics flows through the
existing LOAD.AMMO message without extra plumbing.

Physics gains fixedTimeStep (1/60) and maxSubSteps (3) alongside gravity
(default bumped to -30 for game-feel parity with the third-person
controller, which now reads gravity from Config). stepSimulation now
uses Ammo's full signature instead of relying on Bullet defaults that
silently dropped time on long frames.

Drive-by: setConfig was shallow with a buggy else-branch that lost
nested defaults on partial overrides; it now deep-merges, so calls like
setConfig({ physics: { enabled: true } }) preserve path/gravity instead
of clobbering them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
speed was read in the acceleration/braking branches but declared with
const further down the function, so pressing accelerate/brake threw
"Cannot access 'speed' before initialization" and crashed the physics
worker. Read getCurrentSpeedKmHour() once, above the branches that use it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Camera.getPosition() returns a plain {x,y,z}, which has no lerpVectors,
so SmoothCarFollow threw every frame and the follow camera never tracked
the car. Build a real Vector3 from the camera position and lerp it toward
the desired position.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collapse isPlainObject arrow function onto a single line to satisfy
prettier/prettier eslint rule.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@marco-ponds marco-ponds merged commit 504aa4b into master May 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant