11 releases (6 breaking)

0.7.0 Dec 19, 2024
0.6.0 Aug 8, 2024
0.5.2 Apr 18, 2024
0.4.0 Jan 10, 2024
0.1.1 Nov 21, 2022

#38 in Rendering

Download history 105/week @ 2024-09-18 81/week @ 2024-09-25 74/week @ 2024-10-02 124/week @ 2024-10-09 63/week @ 2024-10-16 42/week @ 2024-10-23 58/week @ 2024-10-30 107/week @ 2024-11-06 67/week @ 2024-11-13 44/week @ 2024-11-20 52/week @ 2024-11-27 84/week @ 2024-12-04 103/week @ 2024-12-11 180/week @ 2024-12-18 1/week @ 2024-12-25 44/week @ 2025-01-01

353 downloads per month
Used in 2 crates

MIT license

29KB
298 lines

Bevy Points

crates.io

Points mesh plugin for Bevy.

Example

Usage

System setup

Add the plugin to your app:

use bevy::prelude::*;
use bevy_points::prelude::*;

fn main() {
    App::new()
        .add_plugin(PointsPlugin);
}

Apply a component to a MaterialMeshBundle

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((
        Mesh3d(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())
            })),
        )),
        MeshMaterial3d(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()
        })),
    ));

    commands.spawn((
        Mesh3d(meshes.add(
            // Mesh can be converted to PointsMesh & vice versa.
            PointsMesh::from(Mesh::from(Sphere {
                radius: 1.0
            }))
        )),
        MeshMaterial3d(materials.add(PointsMaterial {
            settings: PointsShaderSettings {
                color: Color::BLUE,
                opacity: 0.5,
                ..Default::default()
            },
            alpha_mode: AlphaMode::Blend,
            ..Default::default()
        })),
    ));
}

Compatibility

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
0.15 0.7

Dependencies

~41–78MB
~1.5M SLoC