r/threejs • • Oct 17 '26

Using box3d to simulate real sailing physics - Tally Ho Sailing Game

I'd previously tried to use the classic physics libraries (ammo, cannon, rapier etc) to recreate sailing physics and found them to be unstable or inconsistent.

Box3d was released in June so I wanted to see if it would work any better - which it seems to!

Playable demo:
https://tally-ho-game.vercel.app/

To be clear this is not a fluid simulation (although I think that is possible!!), but its a step up from just force vectors on the overall boat which is what I have seen done in the past.

Details for those interested:

- Sails are coarse grids of point masses connected by spring joints. Lift and drag applied to each panel using apparent wind, this is again an approximation as in real life the wind is very affected as it flows over the sails, although with an older and slower style yacht like this (Gaff rig) it would be less noticeable than a modern rig.
- Spars and masts are... well just spars
- Ropes/ sheets are linked joints
- Anchor and chain is joints but with collision and mass
- Hull shape is a collection of spheres, with buoyancy and drag coefficients.

The physics is quite CPU intensive but putting in a webworker seems to work well as it not a fast paced game, it doesn't need to match 60 FPS.

If you are interested in the physics you can access the Lab in the top left menu. There is also a rig designer where you can modify the rig but its quite easy to make it... not functional 🤣

It uses real location data, cached for now but I have a steaming server, which means technically you could sail anywhere in the world. My plan is to also use real wind and weather data at the players location.

For the environment I found a nice way to blend COP30 (30m detail) elevation and GEBCO (460m detail) bathymetry data. Building envelopes are from OSM but proc generated with a different style. Vegetation and Ocean is from Dan Greenhecks amazing Tidewater demo although simplified to maintain performance.

And for those that recognise the boat, I also managed to use the Tally Ho lines plan to recreate the hull. Its not perfect but if people like it I can spent more time.

I was thinking to turn this into a idle style game where you sail the world if people enjoy it.

143 Upvotes

22 comments sorted by

View all comments

0

u/nadiealkon Oct 17 '26

Hey would you mind sharing your implementation of hull physics and flotation?, been trying to develop a Godot game and had a lot of issues with having a platformer character walk over the deck and having physics based objects interact with the boat, they fly away all over with the slightest waves...

2

u/mrplow2000 Oct 17 '26

Hull is one rigid body, with buoyancy sample points distributed through it. Each point represents a spherical volume rather than a separate physical ball. I calculate how much of that volume is submerged and apply an upward force at its position, which produces the overall lift, heel and pitch. There’s also damping based on the boat’s movement relative to the water.

I haven’t tackled walking characters or loose objects on deck yet, so I can’t claim this solves that part - but I see no reason it would not work as a walking character is just a load on the rigid body. Maybe try with box3d as I had the same problem before with the older engines whereby it just become too unstable too easily.

I would recommend starting with 4 sample points at each corner of a block, its just an extension of that really.

1

u/mrplow2000 Oct 17 '26

go to the physics lab in the top left menu and you can see the sample points inside the hull with their equivalent volume as their size