Skip to content

feat: add swimming down, an underwater view, a climb pose and wakes - #80

Merged
anistark merged 3 commits into
mainfrom
claude/recursing-dubinsky-b61096
Nov 15, 2026
Merged

anistark merged 3 commits into
mainfrom
claude/recursing-dubinsky-b61096

Conversation

@anistark

Copy link
Copy Markdown
Contributor

Swimming, second pass: going under on purpose, a view from below, a pose for climbing out, a camera that looks down at a swimmer, and marks on the water. Stacked on #76: merge after it.

Going under

  • New world control dive (default KeyC): hold to swim down, let go to float back up
  • PlayerMotion.swim gains 'under', with its own stroke on Person
  • player/Underwater.tsx swaps the world fog's values in place for the water's color and clarity and draws a backdrop sphere, so no material recompiles under either renderer; underwater={false} on Player opts out
  • Ocean and Lake draw their underside (UNDERSIDE in surfaces/water.ts, TSL twin in nodes/water.ts); Pool water is double sided
  • WaterBody gains color and clarity, and waterAt returns the body it sampled

Climbing out

  • swim gains 'climb' while a swimmer hauls out over a wall, and submerged then counts down the height left
  • Person reaches, presses up, brings a knee up and stands; banks and pool steps keep the plain lift
  • A wall haul is capped at 1.4 m/s (was 2.5), about a second, so the pose reads

Camera

  • The third-person boom tilts to at least about 20 degrees over an avatar afloat (raiseBoom in player/boom.ts): a tilt, not a lift, so the sweep still starts inside the capsule

Splash, ripples and wake

  • water/wake.ts (pure, seeded, two fixed pools) and water/trail.tsx (two instanced draws, textures drawn in code)
  • The Player draws its own, first person included, and every other Person draws its own
  • Player's seed now sets how its splashes scatter

Fixed on the way

  • Ocean and Lake waves stood still under WebGL and the Ocean horizon ignored the fog range: react-three-fiber copies the uniforms handed to <shaderMaterial>, so per-frame writes never reached the shader. Both now build their material themselves

Heads-up

  • KeyC is bound by default, so a world already using C for its own action also dives on it in water (move one, or bind dive: [])
  • Not here: ledges over 0.6 m and hull ladders, a touch or gamepad button for dive, a blend as the camera crosses the surface

Testing: just check passes on the rebased branch, with new tests beside player/boom.ts, player/swim.ts, person/swim.ts, water/wake.ts and the core water and keyboard changes. Walked in the workshop's play mode before the rebase: dive, swim down and back up, look up from below, climb onto a dock and over a pool rim, a treading Person with its own rings, first person, and a run under WebGPURenderer. just perf was within budget then.

Refs #76

- `Player` wades in open water, swims where it is over half its height, and rides the swell of an `Ocean` or `Lake`
- Leaving the ground over deep water is a dive: head first, a glide under the surface, then up
- Swimming into a bank, a step or a ledge up to 0.6 m over the water climbs out onto it
- `Person` treads water, swims breaststroke or a front crawl by speed, and dives with the avatar
- A `Person` placed in deep water treads at the surface, and a walker swims the wet stretch of its route
- New props: `swim`, `swimSpeed`, `swimSprintSpeed` on `Player` and `swim` on `Person`
- `useWater`, `waterAt`, `planeWater` and `useWorld().waters` in `@runek/core` let any water component join in
- BREAKING: a `Player` no longer walks the bed under an `Ocean`, `Lake` or `Pool`, and a `Person` in deep water floats up (`swim={false}` restores it)

[CONTRIBUTORS]
- Swim state and forces are plain numbers in `player/swim.ts`, run from `useBeforePhysicsStep` so they land after ecctrl's pushes
- Strokes are canonical humanoid poses in `person/swim.ts`, blended over the built-in posture with `applyPose`
- `surfaces/water.ts` is the JS twin of the water shaders' wave, read at the same `uTime`
- `PlayerMotion` gains `swim`, `immersion` and `submerged`, `PoseContext` gains `swim` and `submerged`, `PoseSource` an optional `swim()` method
- Migration notes for `player` and `person` assume the next release is 0.19.0
- Tests for the water registry, the swim step and the strokes
- Hold `KeyC` (the new `dive` control) to swim down, let go to float back up
- Under the surface the fog turns to water and `Ocean`, `Lake` and `Pool` show their underside, opt out with `underwater={false}` on `Player`
- The third-person camera rides higher over a swimmer instead of skimming the surface
- Climbing out over a wall plays a reach, press and step up, published as `swim: 'climb'` on `PlayerMotion`
- Swimmers leave rings, a wake and a splash on entry, for the `Player` and every `Person`
- `Ocean` and `Lake` waves move again under WebGL, and the `Ocean` horizon takes the fog range

[CONTRIBUTORS]
- `PlayerSwim` gains `'under'` and `'climb'`, `submerged` counts down the wall left while climbing
- `WaterBody` gains `color` and `clarity`, `waterAt` returns the `body` it sampled
- New `player/boom.ts`, `player/Underwater.tsx`, `water/wake.ts` and `water/trail.tsx`, with the `water` dir added to the `player` and `person` registry entries
- `Ocean` and `Lake` build their `ShaderMaterial` themselves, since react-three-fiber copies `<shaderMaterial>` uniforms
- `UNDERSIDE` GLSL in `surfaces/water.ts` with its TSL twin in `nodes/water.ts`
- Wall haul-outs are capped at 1.4 m/s (`HAUL`) so the pose reads

Refs #76
Base automatically changed from feat/swimming to main November 15, 2026 08:40
@anistark
anistark merged commit 735aa9b into main Nov 15, 2026
1 check passed
@anistark
anistark deleted the claude/recursing-dubinsky-b61096 branch November 15, 2026 09:46
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