use bevy::{ pbr::wireframe::{Wireframe, WireframeConfig, WireframePlugin}, prelude::*, render::{options::WgpuOptions, render_resource::WgpuFeatures}, }; use rand::{thread_rng, Rng}; use crate::{geometry::CyberSphere, lights::AnimateCyberLightWireframe}; fn wireframe_planet( mut commands: Commands, mut wireframe_config: ResMut, query: Query>, ) { let ent = query.single(); wireframe_config.global = false; commands.entity(ent).insert(Wireframe); } fn wireframify_lights( mut commands: Commands, no_wires: Query, Without)>, wires: Query, With)>, ) { let chance = 0.005; let rng = &mut thread_rng(); for e in no_wires.iter() { if rng.gen::() < chance { commands.entity(e).insert(Wireframe); } } for e in wires.iter() { if rng.gen::() < chance { commands.entity(e).remove::(); } } } // public plugin pub struct CyberGlamorPlugin; impl Plugin for CyberGlamorPlugin { fn build(&self, app: &mut App) { app.insert_resource(WgpuOptions { features: WgpuFeatures::POLYGON_MODE_LINE, ..Default::default() }) .add_startup_system_to_stage(StartupStage::PostStartup, wireframe_planet) .add_system(wireframify_lights) .add_plugin(WireframePlugin); } }