9 个不稳定版本 (4 个重大更改)
0.14.0 | 2024年7月13日 |
---|---|
0.13.0 | 2024年3月20日 |
0.12.0 | 2023年11月4日 |
0.2.5 | 2023年7月25日 |
0.2.1 | 2022年12月27日 |
在 渲染 中排名第 34
每月下载量 134
235KB
247 行
bevy-single-variable-function-mesh
由单变量函数 f(f32) -> f32
生成的 2D 或 3D 网格 (bevy::render::mesh::Mesh
)。
示例
我们有一个生成半椭圆的数学函数和一个生成半圆的函数。
fn squircle(x: f32) -> f32 {
(1.0 - (x).abs().powf(4.0)).powf(0.25)
}
fn circle(x: f32) -> f32 {
(1.0 - x.powf(2.0)).powf(0.5)
}

commands.spawn(PbrBundle {
mesh: meshes.add(
SingleVariableFunctionMesh {
f: squircle, // or circle
relative_height: 0.0,
..default()
}
.into(),
),
material: materials.add(StandardMaterial::default()),
transform: Transform::from_xyz(-2.5, 1.0, 0.0),
..default()
});
commands.spawn(PbrBundle {
mesh: meshes.add(
SingleVariableFunctionMesh {
f: squircle, // or circle
relative_height: 0.2,
..default()
}
.into(),
),
material: materials.add(StandardMaterial::default()),
transform: Transform::from_xyz(0.0, 1.0, 0.0),
..default()
});
commands.spawn(PbrBundle {
mesh: meshes.add(
SingleVariableFunctionMesh {
f: squircle, // or circle
relative_height: 1.0,
..default()
}
.into(),
),
material: materials.add(StandardMaterial::default()),
transform: Transform::from_xyz(2.5, 1.0, 0.0),
..default()
});


详细信息
- 请随时向错误跟踪器添加想法。
- 此包将自动通过比较输入函数
f
的斜率来寻找好的顶点。 - 渲染场景中的平面是由以下代码创建的:
f: |_x: f32| -> f32 { 20.0 },
.
兼容Bevy版本
bevy | bevy-single-variable-function-mesh |
---|---|
0.14 | 0.14 |
0.13 | 0.13 |
0.12 | 0.12 |
0.11 | 0.11 |
许可证
根据以下任一许可证授权
- Apache许可证2.0版本,(LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT许可证 (LICENSE-MIT 或 https://opensource.org/licenses/MIT)
贡献
除非您明确声明,否则根据Apache-2.0许可证定义,您有意提交以包含在作品中的任何贡献,应双授权如上所述,无需任何附加条款或条件。
依赖项
~33–71MB
~1M SLoC