Change morph_targets to use iter_instance_entities().

This commit is contained in:
Robin KAY 2023-10-30 21:37:37 +00:00
parent fd8e98f986
commit 3740766157
1 changed files with 17 additions and 12 deletions

View File

@ -7,7 +7,7 @@
//! - How to read morph target names in [`name_morphs`]. //! - How to read morph target names in [`name_morphs`].
//! - How to play morph target animations in [`setup_animations`]. //! - How to play morph target animations in [`setup_animations`].
use bevy::prelude::*; use bevy::{prelude::*, scene::SceneInstance};
use bevy_mod_outline::{ use bevy_mod_outline::{
AutoGenerateOutlineNormalsPlugin, OutlineBundle, OutlinePlugin, OutlineVolume, AutoGenerateOutlineNormalsPlugin, OutlineBundle, OutlinePlugin, OutlineVolume,
}; };
@ -69,12 +69,15 @@ fn setup(asset_server: Res<AssetServer>, mut commands: Commands) {
fn setup_outlines( fn setup_outlines(
mut commands: Commands, mut commands: Commands,
mut has_setup: Local<bool>, mut has_setup: Local<bool>,
meshes: Query<Entity, With<Handle<Mesh>>>, scene_query: Query<&SceneInstance>,
scene_manager: Res<SceneSpawner>,
) { ) {
if *has_setup { if *has_setup {
return; return;
} }
for entity in &meshes { if let Ok(scene) = scene_query.get_single() {
if scene_manager.instance_is_ready(**scene) {
for entity in scene_manager.iter_instance_entities(**scene) {
commands.entity(entity).insert(OutlineBundle { commands.entity(entity).insert(OutlineBundle {
outline: OutlineVolume { outline: OutlineVolume {
visible: true, visible: true,
@ -86,6 +89,8 @@ fn setup_outlines(
*has_setup = true; *has_setup = true;
} }
} }
}
}
/// Plays an [`AnimationClip`] from the loaded [`Gltf`] on the [`AnimationPlayer`] created by the spawned scene. /// Plays an [`AnimationClip`] from the loaded [`Gltf`] on the [`AnimationPlayer`] created by the spawned scene.
fn setup_animations( fn setup_animations(