# Three.js Ocean Sailing

> Build depth-colored water, shoreline swash and a buoyant boat with steering, braking and a persistent wake.

- Type: Lab Skill (downloadable Agent Skill)
- Category: [Game creation](https://www.sandbase.ai/skills/games)
- Version: 0.1.0
- Page: https://www.sandbase.ai/skills/games/threejs-ocean-sailing

## What you get

A standalone coastal sailing scene with a small island. Rapier boat physics, depth-dependent water, shoreline swash and boat wake. An orbit camera, keyboard steering and targeted regression tests.

## Install

Download the Skill package from https://www.sandbase.ai/skills/games/threejs-ocean-sailing (sign-in required), unzip it into your agent's skills folder, then ask your agent to use it:

```text
/threejs-ocean-sailing build a small coastal sailing scene with clear shallows, blue deep water and a buoyant wooden boat
```

## How it works

1. **Launch the island and boat** Three.js Ocean Sailing creates a project with node scripts/new-project.mjs --out ./my-ocean-sailing, followed by npm ci, npm test, npm run dev and npm run build. A small grass-and-sand island has a fishing boat that sails into deeper water: W and S drive, A and D steer, Shift boosts, Space brakes and dragging orbits the camera.
2. **Tune water, waves and islands** Edit the island list and boat spawn in sources/demo.js, ocean colours in art-direction.js and wave parameters in ocean.js. The boat pitches and rolls on the same wave spectrum as the water shader, so keep heightAt, minimumHeightAt, depth attenuation and GPU displacement consistent. Move shoreline geometry and collision together, and reset wake particles after a teleport.
3. **Keep physics stable and verify** Preserve the fixed-step Rapier update with its bounded substeps. The sailing area is bounded to x from -210 to 210 and z from -230 to 120, so widen bounds and recovery targets deliberately for a bigger world. Run the affected tests, then sail in the browser at the requested viewport and record measured frame rate with device and browser.

## FAQ

### What does Three.js Ocean Sailing simulate?

Three.js Ocean Sailing simulates depth-dependent water colour, shoreline swash, a persistent wake and a drivable buoyant boat on a bounded stylized wave model. It is a coastal sailing scene and boat physics prototype, and its physics keeps a home-port convention with harbour helpers.

### Does Three.js Ocean Sailing call any AI model?

No. Three.js Ocean Sailing is a Three.js and Rapier project that runs in your browser, with no model calls and no API keys, so sailing and editing it is not billed. npm fetches its pinned dependencies once at install time.

### What must stay in sync in Three.js Ocean Sailing?

Three.js Ocean Sailing needs heightAt, minimumHeightAt, depth attenuation and the GPU displacement to stay consistent, because the boat floats on the same wave spectrum the shader draws. Check them together after changing anything in ocean.js.

### Can I make the Three.js Ocean Sailing world bigger?

Yes, deliberately. Three.js Ocean Sailing inherits a sailing area bounded to x from -210 to 210 and z from -230 to 120. Expand those bounds and the recovery targets together when integrating a larger world, and move shoreline geometry with its collision so the boat cannot pass through land.

### What browser does Three.js Ocean Sailing need?

Three.js Ocean Sailing needs a current GPU-capable browser, plus Node.js 22.12 or later to build. Open the loopback URL that Vite prints. A selector in the demo toggles Chinese and English, and the deliverables are the project and its built dist folder.

### Does the Three.js Ocean Sailing preview save anything?

Three.js Ocean Sailing's sandboxed preview holds its state for the current session, so a reload begins again from the start. Downloaded projects keep their state in local browser storage.

## Examples

- Three.js Ocean Sailing (html)
- Ocean & sailing (video)
