bevy_render::extract_component

Trait ExtractComponent

Source
pub trait ExtractComponent: Component {
    type QueryData: ReadOnlyQueryData;
    type QueryFilter: QueryFilter;
    type Out: Bundle;

    // Required method
    fn extract_component(
        item: QueryItem<'_, Self::QueryData>,
    ) -> Option<Self::Out>;
}
Expand description

Describes how a component gets extracted for rendering.

Therefore the component is transferred from the “app world” into the “render world” in the ExtractSchedule step.

Required Associated Types§

Source

type QueryData: ReadOnlyQueryData

ECS ReadOnlyQueryData to fetch the components to extract.

Source

type QueryFilter: QueryFilter

Filters the entities with additional constraints.

Source

type Out: Bundle

The output from extraction.

Returning None based on the queried item can allow early optimization, for example if there is an enabled: bool field on Self, or by only accepting values within certain thresholds.

The output may be different from the queried component. This can be useful for example if only a subset of the fields are useful in the render world.

Out has a Bundle trait bound instead of a Component trait bound in order to allow use cases such as tuples of components as output.

Required Methods§

Source

fn extract_component(item: QueryItem<'_, Self::QueryData>) -> Option<Self::Out>

Defines how the component is transferred into the “render world”.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: Asset> ExtractComponent for Handle<T>

Source§

type QueryData = &'static Handle<T>

Source§

type QueryFilter = ()

Source§

type Out = Handle<T>

Source§

fn extract_component( handle: QueryItem<'_, Self::QueryData>, ) -> Option<Self::Out>

Implementors§