From e42d85b3aa3d426461dbb762701f2a7a76d1c38b Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 25 Sep 2026 09:50:08 -0700 Subject: [PATCH] Give the tide springs and neaps: its range swells and shrinks over twenty minutes, so some low waters lay the shelf bare, some high waters flood it deep, and at neaps the water barely moves. --- public/tide-pool-world.js | 6 +++++- public/tide-pool.js | 2 +- src/components/tide-pool.tsx | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/public/tide-pool-world.js b/public/tide-pool-world.js index a57c71e..c0ee361 100644 --- a/public/tide-pool-world.js +++ b/public/tide-pool-world.js @@ -36,7 +36,11 @@ const distance = (a, b) => Math.hypot(a.x - b.x, a.z - b.z); const TIDE_PHASE = -1.1; export const tideOf = t => .5 + .5 * Math.sin(t / TIDE_PERIOD * Math.PI * 2 + TIDE_PHASE); export const tideRising = t => Math.cos(t / TIDE_PERIOD * Math.PI * 2 + TIDE_PHASE) > 0; -export const waterLevel = world => lerp(TIDE_LOW, TIDE_HIGH, tideOf(world.time)); +// Springs and neaps: the range of the tide swells and shrinks over twenty minutes, so some low waters lay the shelf bare +// and some high waters flood it deep, while at neaps the water barely moves. The shelf opens at springs. +export const SPRING_PERIOD = 1200; +export const tideRange = t => 1 + .32 * Math.cos(t / SPRING_PERIOD * Math.PI * 2); +export const waterLevel = world => (TIDE_LOW + TIDE_HIGH) / 2 + (tideOf(world.time) - .5) * (TIDE_HIGH - TIDE_LOW) * tideRange(world.time); export const daylight = world => { const s = Math.sin(world.time / DAY_PERIOD * Math.PI * 2 + .45); const t = clamp((s + .25) / .6, 0, 1); diff --git a/public/tide-pool.js b/public/tide-pool.js index ee1ee46..306c464 100644 --- a/public/tide-pool.js +++ b/public/tide-pool.js @@ -1,7 +1,7 @@ import { createWorld, advanceWorld, offerObject, SPECIES, SPECIES_ORDER, CELL, COLS, ROWS, X0, Z0, X1, Z1, START_POOL, waterLevel, daylight, heightAt, surfaceAt, depthAt, onShelf, bodyAt, tideOf, tideRising, label, goalText, describeWorld, creatureById, MACHINES, BLOCK, BLOCK_Y0, blockKey, footAt, debrisAt, footing, -} from './tide-pool-world.js?v=30'; +} from './tide-pool-world.js?v=31'; const root = document.querySelector('[data-tide-pool]'); const status = document.querySelector('#tide-status'); diff --git a/src/components/tide-pool.tsx b/src/components/tide-pool.tsx index f615124..94344b8 100644 --- a/src/components/tide-pool.tsx +++ b/src/components/tide-pool.tsx @@ -141,7 +141,7 @@ export function TidePoolContent() { {/* Lets the three.js add-ons resolve the same pinned module the page already uses. */} + ); } -- 2.51.2