use std::sync::{Arc, Mutex}; use bevy::{ecs::query::QueryItem, prelude::*, render::extract_component::ExtractComponent}; use crate::render_assets::HeadlessRenderSource; /// Headless render destination. Contains the image which the rendered frame is copied to. #[derive(Component, Default, Clone)] pub struct HeadlessRenderDestination(pub Arc>); impl ExtractComponent for HeadlessRenderDestination { type QueryData = (&'static Self, &'static Handle); type QueryFilter = (); type Out = (Self, Handle); fn extract_component( (destination, source_handle): QueryItem<'_, Self::QueryData>, ) -> Option { Some((destination.clone(), source_handle.clone())) } } /// Bundle containing both a source and destination for headless rendering. #[derive(Bundle)] pub struct HeadlessRenderBundle { /// Source pub source: Handle, /// Destination pub dest: HeadlessRenderDestination, }