5 个版本
0.2.3 | 2024年8月5日 |
---|---|
0.2.2 | 2024年8月5日 |
0.2.1 | 2024年7月15日 |
0.2.0 | 2024年7月15日 |
0.1.0 | 2024年7月15日 |
#443 在 游戏开发
627 每月下载次数
3MB
203 代码行
bevy_heightmap
在 bevy
中将高度图 PNG 文件加载为网格。
高度图 | 生成 |
---|---|
![]() |
![]() |
使用
从值函数创建高度图
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);
从图像加载高度图作为网格(需要 .hmp.png
扩展名)
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 | bevy_heightmap |
---|---|
0.14 | 0.2.0 |
0.13 | 0.1.0 |
依赖
~24MB
~452K SLoC