Crates.io | bevy_heightmap |
lib.rs | bevy_heightmap |
version | |
source | src |
created_at | 2024-07-15 06:19:17.945409 |
updated_at | 2024-07-15 06:49:03.870912 |
description | Create meshes from heightmap PNGs in the Bevy game engine. |
homepage | https://github.com/Katsutoshii/bevy_heightmap |
repository | https://github.com/Katsutoshii/bevy_heightmap |
max_upload_size | |
id | 1303528 |
size | 0 |
bevy_heightmap
Load height map PNGs as meshes in bevy
.
Height map | Generated |
---|---|
![]() |
![]() |
Create a height map from a value function:
use bevy::prelude::*;
use bevy_heightmap::*;
let heightmap = HeightMap {
size: UVec2::new(10, 10),
h: |p: Vec2| ((20. * p.x).sin() + (20. * p.y).sin()) / 2.
};
let mesh: Mesh = heightmap.into();
assert_eq!(mesh.count_vertices(), 4 * 10 * 10);
Load a height map as a mesh from an image (requires .hmp.png
extension):
use bevy::prelude::*;
use bevy_heightmap::*;
fn setup(asset_server: Res<AssetServer>) {
let mesh: Handle<Mesh> = asset_server.load("textures/terrain.hmp.png");
}
cargo run --example image
bevy | bevy_heightmap |
---|---|
0.14 | 0.2.0 |
0.13 | 0.1.0 |