Log inGet started
Package

water.module

This package holds more than this page lists. See all of its files in its world.

README.md

water

The one way to put any kind of water in a scene and ask it questions.

local Water = require("tidewater.modules.water")

-- a lake 60 x 40 m whose surface stands at y = 2
local lake = Water.create({ kind = "lake", look = "realistic", position = { 0, 2, 0 }, size = { 60, 40 } })
lake:setLook("cartoon")           -- same lake, cartoon look
Water.setKind(lake.entityId, "pond")

Water.heightAt(10, 4)             -- surface Y of the TOPMOST water at x=10, z=4 (nil where there is none)
Water.heightAt(10, 4, 0)          -- the water at height 0 instead (a lower one of stacked waters)
lake:heightAt(10, 4)              -- this lake's own surface there, nil off it (never another water)
Water.flowAt(10, 4)               -- { x, y, z } how the surface moves there (river current, waves)
Water.sample({ 10, 1, 4 })        -- the engine's full answer: surface, depth, normal, velocity, floor
Water.normalAt(10, 4)             -- unit { x, y, z } the surface faces there
Water.surfaceAt(10, 4)            -- Surface? { height, flow, normal, depth?, water? } in one typed answer
Water.tideAt(10, 4)               -- TideState? { offset, rising, high, low }, nil where that water has no tide
lake:surfaceAt(10, 4)             -- also lake:normalAt, lake:flowAt, lake:tideNow()
Water.presets("river")            -- the named varieties, default first; plain words resolve ("rapids", "lazy")
Water.setQuality("low")           -- the tier every `auto` water follows, for the whole game

Water.ripple({ 3, 2, 1 }, 0.6)    -- a ring
Water.splash("plop", { 3, 2, 1 }) -- plop | body | bow | spray | spindrift | mist | drips | bubbles
Water.setWeather({ rain = 0.7 })  -- rain rings everywhere, without a weather kit

kind (11 kinds): ocean, shoreline, lake, pond, pool, hotspring, river, stream, waterfall, puddles, underwater (pool is a swimming pool, hotspring a hot spring, puddles puddles and a wet street, underwater a basin made to swim in). look (7 looks): realistic, crystal, painted, cartoon, lowpoly, pixel, toy (crystal is tropical crystal clear, toy glossy moulded plastic).

Every kind declares its water to the engine (Physics.defineWater), so FluidForces, the tidewater.components.Buoyancy component, Physics.water and Physics.onWater work on all of them, and a river's current carries what floats in it. For water saved with a scene, use the WaterBody component: its fields are exactly Water.create's options.