Repository navigation
feat: add swimming down, an underwater view, a climb pose and wakes - #80
Merged
Merged
Conversation
- `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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
dive(defaultKeyC): hold to swim down, let go to float back upPlayerMotion.swimgains'under', with its own stroke onPersonplayer/Underwater.tsxswaps 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}onPlayeropts outOceanandLakedraw their underside (UNDERSIDEinsurfaces/water.ts, TSL twin innodes/water.ts);Poolwater is double sidedWaterBodygainscolorandclarity, andwaterAtreturns thebodyit sampledClimbing out
swimgains'climb'while a swimmer hauls out over a wall, andsubmergedthen counts down the height leftPersonreaches, presses up, brings a knee up and stands; banks and pool steps keep the plain liftCamera
raiseBoominplayer/boom.ts): a tilt, not a lift, so the sweep still starts inside the capsuleSplash, ripples and wake
water/wake.ts(pure, seeded, two fixed pools) andwater/trail.tsx(two instanced draws, textures drawn in code)Playerdraws its own, first person included, and every otherPersondraws its ownPlayer'sseednow sets how its splashes scatterFixed on the way
OceanandLakewaves stood still under WebGL and theOceanhorizon 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 themselvesHeads-up
KeyCis bound by default, so a world already using C for its own action also dives on it in water (move one, or binddive: [])dive, a blend as the camera crosses the surfaceTesting:
just checkpasses on the rebased branch, with new tests besideplayer/boom.ts,player/swim.ts,person/swim.ts,water/wake.tsand 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 treadingPersonwith its own rings, first person, and a run underWebGPURenderer.just perfwas within budget then.Refs #76