Expand description
A bevy plugin to track your entities in spatial indices and query them.
Quickstart using the kdtree feature:
use bevy_spatial::{AutomaticUpdate, KDTree3, TransformMode, SpatialAccess};
#[derive(Component, Default)]
struct TrackedByKDTree;
fn main() {
   App::new()
       .add_plugin(AutomaticUpdate::<TrackedByKDTree>::new()
            .with_frequency(Duration::from_secs_f32(0.3))
            .with_transform(TransformMode::GlobalTransform))
       .add_system(use_neighbour);
   // ...
}
type NNTree = KDTree3<TrackedByKDTree>; // type alias for later
// spawn some entities with the TrackedByKDTree component
fn use_neighbour(tree: Res<NNTree>){
    if let Some((pos, entity)) = tree.nearest_neighbour(Vec3::ZERO) {
        // pos: Vec3
        // do something with the nearest entity here
    }
}For more details see Examples
Modules§
- kdtree
 - implementations to use 
kd_treetrees as a spatial datastructure inbevy_spatial. - point
 - The different point Traits and Types used by 
bevy_spatial 
Structs§
- Automatic
Update  - Plugin struct for setting up a spatial datastructure with automatic updating.
 - Spatial
Set  - Default set for spatial datastructure updates. Can be overridden using 
AutomaticUpdate::with_set() - Timestep
Length  - Resource used for fixed timestep without repeats in the same frame (builtin timestep may run the system multiple times per frame).
 
Enums§
- Spatial
Structure  - Enum containing the different types of spatial datastructure compatible with 
AutomaticUpdate - Transform
Mode  - Select which Transform to use when automatically updating the Spatial Datastructure.
 
Traits§
- Spatial
Access  - Trait for accessing point-based spatial datastructures.
 - TComp
 - automatically implemented trait for all components which can be used as markers for automatic updates?