Crates.io | bevy_points |
lib.rs | bevy_points |
version | 0.6.0 |
source | src |
created_at | 2022-11-21 06:25:35.131148 |
updated_at | 2024-08-08 08:04:57.321577 |
description | Points mesh plugin for Bevy |
homepage | https://github.com/mattatz/bevy_points |
repository | https://github.com/mattatz/bevy_points |
max_upload_size | |
id | 719769 |
size | 105,324 |
Points mesh plugin for Bevy.
Add the plugin to your app:
use bevy::prelude::*;
use bevy_points::prelude::*;
fn main() {
App::new()
.add_plugin(PointsPlugin);
}
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<PointsMaterial>>,
) {
let n = 320; // # of points
let h = 3.0; // spiral height
commands.spawn(MaterialMeshBundle {
mesh: meshes.add(
PointsMesh::from_iter((0..n).map(|i| {
let t01 = (i as f32) / ((n - 1) as f32);
let r = t01 * TAU * 4.0; // spiral fineness
Vec3::new(r.cos(), (t01 - 0.5) * h, r.sin())
})),
),
material: materials.add(PointsMaterial {
settings: PointsShaderSettings {
point_size: 20., // Defines the size of the points.
..Default::default()
},
perspective: true, // Specify whether points' size is attenuated by the camera depth.
circle: true, // Specify whether the shape of points is circular or rectangular.
..Default::default()
}),
..Default::default()
});
commands.spawn(MaterialMeshBundle {
mesh: meshes.add(
// Mesh can be converted to PointsMesh & vice versa.
PointsMesh::from(Mesh::from(Sphere {
radius: 1.0
}))
),
material: materials.add(PointsMaterial {
settings: PointsShaderSettings {
color: Color::BLUE,
opacity: 0.5,
..Default::default()
},
alpha_mode: AlphaMode::Blend,
..Default::default()
}),
..Default::default()
});
}
bevy | bevy_points |
---|---|
0.9 | 0.1 |
0.10 | 0.2 |
0.11 | 0.3 |
0.12 | 0.4 |
0.13 | 0.5 |
0.14 | 0.6 |