| Crates.io | bevy_hourglass |
| lib.rs | bevy_hourglass |
| version | 0.3.1 |
| created_at | 2025-05-17 16:42:30.475094+00 |
| updated_at | 2025-08-21 23:15:09.168732+00 |
| description | A flexible hourglass plugin for Bevy applications |
| homepage | |
| repository | https://github.com/edouardpoitras/bevy_hourglass |
| max_upload_size | |
| id | 1677988 |
| size | 3,770,277 |
A flexible hourglass plugin for Bevy applications.
Website: https://edouardpoitras.github.io/bevy_hourglass/

Run the basic 2D mesh hourglass example:
cargo run --example 2d_mesh_hourglass
See multiple hourglasses with random configurations and auto-flipping:
cargo run --example auto_flip_mayhem
Control hourglass flipping with keyboard input:
cargo run --example flip_demo
Explore different hourglass shapes and styles:
cargo run --example curve_styles_demo
This project includes WebAssembly support, allowing you to run hourglasses in a web browser.
Make the build script executable (if not already):
chmod +x build_wasm.sh
Run the build script:
./build_wasm.sh
This script will:
2d_mesh_hourglass and auto_flip_mayhem)After building, you can serve the WASM files with a local HTTP server:
Using Python's built-in HTTP server:
cd wasm && python -m http.server 8080
Then open http://localhost:8080 in your web browser to access the available examples.
use bevy::prelude::*;
use bevy_hourglass::{
BulbStyle, HourglassMeshBodyConfig, HourglassMeshBuilder, HourglassMeshPlatesConfig,
HourglassMeshSandConfig, HourglassPlugin, NeckStyle,
};
use std::time::Duration;
fn main() {
App::new()
.add_plugins((DefaultPlugins, HourglassPlugin))
.add_systems(Startup, setup)
.run();
}
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
commands.spawn(Camera2d::default());
// Create a 2D mesh hourglass with detailed geometry using the new builder pattern
HourglassMeshBuilder::new(Transform::from_xyz(0.0, 0.0, 0.0))
.with_body(HourglassMeshBodyConfig {
total_height: 200.0,
bulb_style: BulbStyle::Circular {
curvature: 1.0,
width_factor: 0.75,
curve_resolution: 20,
},
neck_style: NeckStyle::Curved {
curvature: 0.2,
width: 12.0,
height: 8.0,
curve_resolution: 5,
},
color: Color::srgba(0.85, 0.95, 1.0, 0.2),
})
.with_plates(HourglassMeshPlatesConfig {
width: 165.0,
height: 10.0,
color: Color::srgb(0.6, 0.4, 0.2),
})
.with_sand(HourglassMeshSandConfig {
color: Color::srgb(0.9, 0.8, 0.6),
fill_percent: 1.0, // Start with full top bulb
wall_offset: 8.0, // Distance from glass walls
})
.with_timing(Duration::from_secs(30)) // 30-second timer for automatic animation
.with_auto_flip(true) // Enable auto-flipping when empty
.with_flip_duration(0.5) // 0.5 second flip animation
.build(&mut commands, &mut meshes, &mut materials);
}
| bevy | bevy_hourglass |
|---|---|
| 0.16 | 0.3 |
MIT OR Apache-2.0