Skip to main content

Module water

Module water 

Source
Expand description

Voxel water: an animated water surface built from wave functions, drawn either as stacked voxel columns (blocky, Minecraft-like) or as a smooth semi-realistic sheet.

The surface is one DynamicMesh rebuilt every frame from a handful of travelling waves plus noise ripples, so it costs a single draw call. Transparency, reflections and colour come from the entity’s MeshRenderer (set sensibly the first time the component is added).

use kvas_engine::{prelude::*, scene::Scene, water::VoxelWater};
let mut scene = Scene::default();
let lake = scene.spawn("Lake");
scene.world.insert(lake, VoxelWater::default());
kvas_engine::water::update_water(&mut scene.world, 1.0);
assert!(scene.world.has::<DynamicMesh>(lake));

Structs§

VoxelWater
An animated body of water centred on the entity.

Enums§

WaterStyle
How the water surface is shaped: stepped voxel columns, smooth, or smooth with sharp crests.

Functions§

apply_buoyancy
Floats rigid bodies in water: each dynamic body gets an upward force proportional to how much of it is under the moving surface, plus water drag. Call once per fixed physics step.
update_water
Rebuilds every water surface for time time (seconds). Cheap enough to run every frame.