Build renderer and material component foundations

Add dedicated skinned rendering, pose restoration, shared Material and Material Instance slots, registry-driven components, Surface/Solari integration, transactional schema upgrades, navigation authoring, documentation, and evaluation evidence.
This commit is contained in:
Rbanh committed 2026-07-12 00:24:06 -04:00
1 parent 0553a85220
commit 0798aa5d57
169 files changed
+27098 -3469

No files matched your search

+511 -8
View File
@@ -1,14 +1,20 @@
use std::collections::HashSet;
use bevy::ecs::reflect::ReflectComponent;
use bevy::prelude::*;
use bevy::reflect::serde::{TypedReflectDeserializer, TypedReflectSerializer};
use bevy::reflect::std_traits::ReflectDefault;
use bevy::world_serialization::WorldInstance;
use serde::de::DeserializeSeed;
use shared::{
infer_actor_kind, ActorId, ActorKind, ActorName, AnimationControllerDesc, AudioListenerDesc,
AudioSourceDesc, BrushDesc, ColliderDesc, EditorVisibility, HierarchySiblingIndex,
HydratedPrefabMember, HydratedPrefabReady, InspectorOrder, LevelObject, LightDesc,
MaterialDesc, MaterialOverride, ModelRef, ObjectiveMarker, PhysicsBody, PlayerSpawn,
AudioSourceDesc, AuthoringComponentStates, BrushDesc, ColliderDesc, EditorVisibility,
HierarchySiblingIndex, HydratedPrefabMember, HydratedPrefabReady, InspectorOrder, LevelObject,
LightDesc, MaterialDesc, MaterialOverride, ModelRef, NavigationArea, NavigationBounds,
NavigationLink, NavigationObstacle, ObjectiveMarker, PhysicsBody, PlayerSpawn,
PostProcessVolumeDesc, PrefabHydrationBlocked, PrefabInstance, PrefabRef, Primitive,
RigidBodyDesc, SceneComposition, StaticMeshRenderer, TeamSpawn, TriggerVolume, WeaponSpawn,
RigidBodyDesc, SceneComposition, SkinnedMeshRenderer, StaticMeshRenderer, TeamSpawn,
TriggerVolume, WeaponSpawn,
};
use crate::scene_io::{SceneIo, SceneIoRequest};
@@ -22,7 +28,10 @@ use crate::ui::selection_ops::is_mutable_level_object;
use crate::ui::{egui_captures_keyboard_from_world, UiState};
mod commands;
pub use commands::{EditorCommand, EditorEntitySnapshot, PrefabEditState, SiblingChange};
pub use commands::{
ComponentDelta, ComponentTransaction, EditorCommand, EditorEntitySnapshot,
NavigationComponentState, PrefabEditState, ReflectedComponentValue, SiblingChange,
};
#[derive(Resource, Debug, Default)]
pub struct EditorHistory {
@@ -138,6 +147,7 @@ pub fn snapshot_entity(world: &World, entity: Entity) -> Option<EditorEntitySnap
primitive: entity_ref.get::<Primitive>().cloned(),
brush: entity_ref.get::<BrushDesc>().cloned(),
static_mesh_renderer: entity_ref.get::<StaticMeshRenderer>().cloned(),
skinned_mesh_renderer: entity_ref.get::<SkinnedMeshRenderer>().cloned(),
material: entity_ref.get::<MaterialDesc>().cloned(),
material_override: entity_ref.get::<MaterialOverride>().cloned(),
rigid_body: entity_ref.get::<RigidBodyDesc>().cloned(),
@@ -156,6 +166,10 @@ pub fn snapshot_entity(world: &World, entity: Entity) -> Option<EditorEntitySnap
post_process_volume: entity_ref.get::<PostProcessVolumeDesc>().cloned(),
team_spawn: entity_ref.get::<TeamSpawn>().cloned(),
objective: entity_ref.get::<ObjectiveMarker>().cloned(),
navigation_bounds: entity_ref.get::<NavigationBounds>().cloned(),
navigation_obstacle: entity_ref.get::<NavigationObstacle>().cloned(),
navigation_area: entity_ref.get::<NavigationArea>().cloned(),
navigation_link: entity_ref.get::<NavigationLink>().cloned(),
hierarchy_sibling_index: entity_ref
.get::<HierarchySiblingIndex>()
.map(|index| index.0)
@@ -164,6 +178,8 @@ pub fn snapshot_entity(world: &World, entity: Entity) -> Option<EditorEntitySnap
.get::<EditorVisibility>()
.copied()
.unwrap_or_default(),
inspector_order: entity_ref.get::<InspectorOrder>().cloned(),
component_states: entity_ref.get::<AuthoringComponentStates>().cloned(),
children,
})
}
@@ -204,6 +220,9 @@ fn spawn_snapshot_with_parent(
if let Some(renderer) = &snapshot.static_mesh_renderer {
entity_mut.insert(renderer.clone());
}
if let Some(renderer) = &snapshot.skinned_mesh_renderer {
entity_mut.insert(renderer.clone());
}
if let Some(material) = &snapshot.material {
entity_mut.insert(material.clone());
}
@@ -258,8 +277,26 @@ fn spawn_snapshot_with_parent(
if let Some(objective) = &snapshot.objective {
entity_mut.insert(objective.clone());
}
if let Some(bounds) = &snapshot.navigation_bounds {
entity_mut.insert(bounds.clone());
}
if let Some(obstacle) = &snapshot.navigation_obstacle {
entity_mut.insert(obstacle.clone());
}
if let Some(area) = &snapshot.navigation_area {
entity_mut.insert(area.clone());
}
if let Some(link) = &snapshot.navigation_link {
entity_mut.insert(link.clone());
}
entity_mut.insert(HierarchySiblingIndex(snapshot.hierarchy_sibling_index));
entity_mut.insert(snapshot.editor_visibility);
if let Some(order) = &snapshot.inspector_order {
entity_mut.insert(order.clone());
}
if let Some(states) = &snapshot.component_states {
entity_mut.insert(states.clone());
}
if let Some(parent) = parent {
entity_mut.insert(ChildOf(parent));
}
@@ -561,6 +598,31 @@ pub fn set_post_process_volume_with_history(
);
}
pub fn navigation_component_state(world: &World, entity: Entity) -> NavigationComponentState {
NavigationComponentState {
bounds: world.get::<NavigationBounds>(entity).cloned(),
obstacle: world.get::<NavigationObstacle>(entity).cloned(),
area: world.get::<NavigationArea>(entity).cloned(),
link: world.get::<NavigationLink>(entity).cloned(),
}
}
pub fn set_navigation_with_history(
world: &mut World,
entity: Entity,
new: NavigationComponentState,
) {
if !is_mutable_level_object(world, entity) {
return;
}
let old = navigation_component_state(world, entity);
if old == new {
return;
}
apply_navigation_state(world, entity, &new);
push_history(world, EditorCommand::SetNavigation { entity, old, new });
}
pub fn set_physics_with_history(world: &mut World, entity: Entity, new: PhysicsBody) {
if !is_mutable_level_object(world, entity) {
return;
@@ -818,6 +880,7 @@ pub fn group_selection_with_history(world: &mut World, entities: &[Entity]) {
primitive: None,
brush: None,
static_mesh_renderer: None,
skinned_mesh_renderer: None,
material: None,
material_override: None,
rigid_body: None,
@@ -836,8 +899,18 @@ pub fn group_selection_with_history(world: &mut World, entities: &[Entity]) {
post_process_volume: None,
team_spawn: None,
objective: None,
navigation_bounds: None,
navigation_obstacle: None,
navigation_area: None,
navigation_link: None,
hierarchy_sibling_index: next_sibling_index(world, None),
editor_visibility: EditorVisibility::default(),
inspector_order: None,
component_states: None,
children: Vec::new(),
};
let group = spawn_snapshot(world, &snapshot);
@@ -868,6 +941,7 @@ pub fn create_empty_child_with_history(world: &mut World, parent: Entity) {
primitive: None,
brush: None,
static_mesh_renderer: None,
skinned_mesh_renderer: None,
material: None,
material_override: None,
rigid_body: None,
@@ -886,8 +960,18 @@ pub fn create_empty_child_with_history(world: &mut World, parent: Entity) {
post_process_volume: None,
team_spawn: None,
objective: None,
navigation_bounds: None,
navigation_obstacle: None,
navigation_area: None,
navigation_link: None,
hierarchy_sibling_index: next_sibling_index(world, Some(parent)),
editor_visibility: EditorVisibility::default(),
inspector_order: None,
component_states: None,
children: Vec::new(),
};
let entity = spawn_snapshot_with_parent(world, &snapshot, Some(parent));
@@ -1235,6 +1319,215 @@ pub fn apply_actor_kind(world: &mut World, entity: Entity, kind: ActorKind) {
}
}
pub const ACTOR_KIND_COMPONENT_ID: &str = "core.actor_kind";
pub const ACTOR_KIND_TYPE_PATH: &str = "shared::components::ActorKind";
/// Captures any reflected component without adding a typed history branch.
pub fn capture_reflected_component(
world: &World,
entity: Entity,
component_id: &str,
type_path: &str,
) -> Result<Option<ReflectedComponentValue>, String> {
let entity_ref = world
.get_entity(entity)
.map_err(|_| format!("entity {entity:?} no longer exists"))?;
let app_registry = world
.get_resource::<AppTypeRegistry>()
.ok_or_else(|| "AppTypeRegistry is unavailable".to_string())?;
let type_registry = app_registry.read();
let registration = type_registry
.get_with_type_path(type_path)
.ok_or_else(|| format!("component type `{type_path}` is not registered"))?;
let reflect_component = registration
.data::<ReflectComponent>()
.ok_or_else(|| format!("component `{type_path}` has no ReflectComponent adapter"))?;
let Some(value) = reflect_component.reflect(entity_ref) else {
return Ok(None);
};
let ron = ron::ser::to_string(&TypedReflectSerializer::new(value, &type_registry))
.map_err(|error| format!("could not serialize `{type_path}`: {error}"))?;
Ok(Some(ReflectedComponentValue {
component_id: component_id.to_string(),
type_path: type_path.to_string(),
ron,
}))
}
/// Applies or removes one reflected component value.
pub fn apply_reflected_component(
world: &mut World,
entity: Entity,
type_path: &str,
value: Option<&ReflectedComponentValue>,
) -> Result<(), String> {
if world.get_entity(entity).is_err() {
return Err(format!("entity {entity:?} no longer exists"));
}
world.resource_scope(|world, app_registry: Mut<AppTypeRegistry>| {
let type_registry = app_registry.read();
let registration = type_registry
.get_with_type_path(type_path)
.ok_or_else(|| format!("component type `{type_path}` is not registered"))?;
let reflect_component = registration
.data::<ReflectComponent>()
.cloned()
.ok_or_else(|| format!("component `{type_path}` has no ReflectComponent adapter"))?;
match value {
Some(value) => {
if value.type_path != type_path {
return Err(format!(
"clipboard type `{}` does not match `{type_path}`",
value.type_path
));
}
let mut deserializer = ron::de::Deserializer::from_str(&value.ron)
.map_err(|error| error.to_string())?;
let reflected = TypedReflectDeserializer::new(registration, &type_registry)
.deserialize(&mut deserializer)
.map_err(|error| error.to_string())?;
let exists = reflect_component.reflect(world.entity(entity)).is_some();
if exists {
reflect_component.apply(world.entity_mut(entity), reflected.as_ref());
} else {
reflect_component.insert(
&mut world.entity_mut(entity),
reflected.as_ref(),
&type_registry,
);
}
}
None => reflect_component.remove(&mut world.entity_mut(entity)),
}
Ok(())
})
}
/// Inserts the reflected `Default` for a registered authoring component.
pub fn apply_reflected_default(
world: &mut World,
entity: Entity,
type_path: &str,
) -> Result<(), String> {
world.resource_scope(|world, app_registry: Mut<AppTypeRegistry>| {
let type_registry = app_registry.read();
let registration = type_registry
.get_with_type_path(type_path)
.ok_or_else(|| format!("component type `{type_path}` is not registered"))?;
let reflect_component = registration
.data::<ReflectComponent>()
.cloned()
.ok_or_else(|| format!("component `{type_path}` has no ReflectComponent adapter"))?;
let default = registration
.data::<ReflectDefault>()
.ok_or_else(|| format!("component `{type_path}` has no reflected Default"))?
.default();
let exists = reflect_component.reflect(world.entity(entity)).is_some();
if exists {
reflect_component.apply(world.entity_mut(entity), default.as_ref());
} else {
reflect_component.insert(
&mut world.entity_mut(entity),
default.as_ref(),
&type_registry,
);
}
Ok(())
})
}
pub fn sync_actor_kind_hint(world: &mut World, entity: Entity) {
let kind = world
.get_entity(entity)
.ok()
.and_then(infer_actor_kind)
.unwrap_or(ActorKind::Empty);
if let Ok(mut entity_mut) = world.get_entity_mut(entity) {
entity_mut.insert(kind);
}
}
/// Executes one atomic reflected component edit and records all changed values,
/// including the derived ActorKind presentation hint, as a single history item.
pub fn reflected_component_transaction(
world: &mut World,
entity: Entity,
label: &'static str,
component_id: &str,
type_path: &str,
edit: impl FnOnce(&mut World, Entity) -> Result<(), String>,
) -> Result<(), String> {
if !is_mutable_level_object(world, entity) {
return Err("actor is not editable".to_string());
}
let tracked = [
(component_id, type_path),
(ACTOR_KIND_COMPONENT_ID, ACTOR_KIND_TYPE_PATH),
];
let before = tracked
.iter()
.map(|(id, path)| capture_reflected_component(world, entity, id, path))
.collect::<Result<Vec<_>, _>>()?;
if let Err(error) = edit(world, entity) {
for ((_, path), value) in tracked.iter().zip(before.iter()) {
let _ = apply_reflected_component(world, entity, path, value.as_ref());
}
return Err(error);
}
sync_actor_kind_hint(world, entity);
let after = tracked
.iter()
.map(|(id, path)| capture_reflected_component(world, entity, id, path))
.collect::<Result<Vec<_>, _>>()?;
let deltas = tracked
.iter()
.zip(before)
.zip(after)
.filter_map(|(((id, path), before), after)| {
(before != after).then(|| ComponentDelta {
component_id: (*id).to_string(),
type_path: (*path).to_string(),
before,
after,
})
})
.collect::<Vec<_>>();
if !deltas.is_empty() {
push_history(
world,
EditorCommand::ComponentTransaction(ComponentTransaction {
entity,
label,
deltas,
}),
);
}
Ok(())
}
fn apply_component_transaction(
world: &mut World,
transaction: &ComponentTransaction,
use_after: bool,
) {
for delta in &transaction.deltas {
let value = if use_after {
delta.after.as_ref()
} else {
delta.before.as_ref()
};
if let Err(error) =
apply_reflected_component(world, transaction.entity, &delta.type_path, value)
{
world.resource_mut::<EditorHistory>().status = format!(
"{} partially failed for {}: {error}",
transaction.label, delta.component_id
);
break;
}
}
}
pub fn set_scene_composition_with_history(world: &mut World, new: SceneComposition) {
let old = world.resource::<SceneComposition>().clone();
if old == new {
@@ -1372,6 +1665,9 @@ fn undo_command(world: &mut World, command: &mut EditorCommand) {
EditorCommand::SetPostProcessVolume { entity, old, .. } => {
apply_post_process_volume(world, *entity, old);
}
EditorCommand::SetNavigation { entity, old, .. } => {
apply_navigation_state(world, *entity, old);
}
EditorCommand::SetPhysics { entity, old, .. } => {
apply_physics(world, *entity, old);
}
@@ -1485,6 +1781,9 @@ fn undo_command(world: &mut World, command: &mut EditorCommand) {
EditorCommand::RemoveComponent { entity, snapshot } => {
apply_authored_components(world, *entity, snapshot);
}
EditorCommand::ComponentTransaction(transaction) => {
apply_component_transaction(world, transaction, false);
}
}
}
@@ -1573,6 +1872,9 @@ fn redo_command(world: &mut World, command: &mut EditorCommand) {
entity_mut.insert(new.clone());
}
}
EditorCommand::SetNavigation { entity, new, .. } => {
apply_navigation_state(world, *entity, new);
}
EditorCommand::SetPhysics { entity, new, .. } => {
if let Ok(mut entity_mut) = world.get_entity_mut(*entity) {
entity_mut.insert(new.clone());
@@ -1706,6 +2008,9 @@ fn redo_command(world: &mut World, command: &mut EditorCommand) {
EditorCommand::RemoveComponent { entity, snapshot } => {
remove_authored_components(world, *entity, snapshot);
}
EditorCommand::ComponentTransaction(transaction) => {
apply_component_transaction(world, transaction, true);
}
}
}
@@ -1862,6 +2167,45 @@ fn apply_post_process_volume(
}
}
fn apply_navigation_state(world: &mut World, entity: Entity, state: &NavigationComponentState) {
let has_navigation = state.bounds.is_some()
|| state.obstacle.is_some()
|| state.area.is_some()
|| state.link.is_some();
if let Ok(mut entity_mut) = world.get_entity_mut(entity) {
entity_mut
.remove::<NavigationBounds>()
.remove::<NavigationObstacle>()
.remove::<NavigationArea>()
.remove::<NavigationLink>();
if let Some(value) = &state.bounds {
entity_mut.insert(value.clone());
}
if let Some(value) = &state.obstacle {
entity_mut.insert(value.clone());
}
if let Some(value) = &state.area {
entity_mut.insert(value.clone());
}
if let Some(value) = &state.link {
entity_mut.insert(value.clone());
}
if has_navigation {
entity_mut.insert(ActorKind::Navigation);
}
}
if !has_navigation {
let fallback = world
.get_entity(entity)
.ok()
.and_then(infer_actor_kind)
.unwrap_or(ActorKind::Empty);
if let Ok(mut entity_mut) = world.get_entity_mut(entity) {
entity_mut.insert(fallback);
}
}
}
fn apply_physics(world: &mut World, entity: Entity, physics: &Option<PhysicsBody>) {
if let Ok(mut entity_mut) = world.get_entity_mut(entity) {
match physics {
@@ -1986,6 +2330,9 @@ fn apply_authored_components(world: &mut World, entity: Entity, snapshot: &Edito
if let Some(v) = &snapshot.static_mesh_renderer {
entity_mut.insert(v.clone());
}
if let Some(v) = &snapshot.skinned_mesh_renderer {
entity_mut.insert(v.clone());
}
if let Some(v) = &snapshot.material {
entity_mut.insert(v.clone());
}
@@ -2040,6 +2387,24 @@ fn apply_authored_components(world: &mut World, entity: Entity, snapshot: &Edito
if let Some(v) = &snapshot.objective {
entity_mut.insert(v.clone());
}
if let Some(v) = &snapshot.navigation_bounds {
entity_mut.insert(v.clone());
}
if let Some(v) = &snapshot.navigation_obstacle {
entity_mut.insert(v.clone());
}
if let Some(v) = &snapshot.navigation_area {
entity_mut.insert(v.clone());
}
if let Some(v) = &snapshot.navigation_link {
entity_mut.insert(v.clone());
}
if let Some(v) = &snapshot.inspector_order {
entity_mut.insert(v.clone());
}
if let Some(v) = &snapshot.component_states {
entity_mut.insert(v.clone());
}
}
}
@@ -2061,6 +2426,9 @@ fn remove_authored_components(world: &mut World, entity: Entity, snapshot: &Edit
if snapshot.static_mesh_renderer.is_some() {
entity_mut.remove::<StaticMeshRenderer>();
}
if snapshot.skinned_mesh_renderer.is_some() {
entity_mut.remove::<SkinnedMeshRenderer>();
}
if snapshot.material.is_some() {
entity_mut.remove::<MaterialDesc>();
}
@@ -2115,6 +2483,24 @@ fn remove_authored_components(world: &mut World, entity: Entity, snapshot: &Edit
if snapshot.objective.is_some() {
entity_mut.remove::<ObjectiveMarker>();
}
if snapshot.navigation_bounds.is_some() {
entity_mut.remove::<NavigationBounds>();
}
if snapshot.navigation_obstacle.is_some() {
entity_mut.remove::<NavigationObstacle>();
}
if snapshot.navigation_area.is_some() {
entity_mut.remove::<NavigationArea>();
}
if snapshot.navigation_link.is_some() {
entity_mut.remove::<NavigationLink>();
}
if snapshot.inspector_order.is_some() {
entity_mut.remove::<InspectorOrder>();
}
if snapshot.component_states.is_some() {
entity_mut.remove::<AuthoringComponentStates>();
}
}
if removed_dedicated_audio_kind {
let fallback = world
@@ -2383,6 +2769,88 @@ mod tests {
use crate::operators::test_harness::{assert_undo_redo_round_trip, OperatorInvariantHarness};
use crate::operators::{ActiveOperator, OperatorPhase, OperatorStatus};
#[derive(Component, Reflect, Default, Debug, Clone, PartialEq)]
#[reflect(Component, Default)]
struct StaticExtensionFixture {
value: u32,
}
#[test]
fn reflected_extension_component_transaction_round_trips_atomically() {
let mut app = App::new();
app.register_type::<ActorKind>()
.register_type::<StaticExtensionFixture>();
let world = app.world_mut();
world.init_resource::<EditorHistory>();
world.init_resource::<SceneIo>();
let entity = world
.spawn((LevelObject, ActorKind::Light, Transform::default()))
.id();
let type_path = std::any::type_name::<StaticExtensionFixture>();
reflected_component_transaction(
world,
entity,
"Add Fixture",
"game.static_extension_fixture",
type_path,
|world, entity| {
world
.entity_mut(entity)
.insert(StaticExtensionFixture { value: 42 });
Ok(())
},
)
.unwrap();
assert_eq!(
world.get::<StaticExtensionFixture>(entity).unwrap().value,
42
);
assert_eq!(world.get::<ActorKind>(entity), Some(&ActorKind::Empty));
assert_eq!(world.resource::<EditorHistory>().undo_depth(), 1);
apply_command_undo(world);
assert!(world.get::<StaticExtensionFixture>(entity).is_none());
assert_eq!(world.get::<ActorKind>(entity), Some(&ActorKind::Light));
apply_command_redo(world);
assert_eq!(
world.get::<StaticExtensionFixture>(entity).unwrap().value,
42
);
assert_eq!(world.get::<ActorKind>(entity), Some(&ActorKind::Empty));
}
#[test]
fn snapshots_preserve_component_order_and_independent_active_state() {
let mut world = World::new();
let mut order = InspectorOrder::default();
order.component_ids = vec![shared::AUTHORING_COMPONENT_LIGHT.to_string()];
let mut states = AuthoringComponentStates::default();
states.set_component_active(shared::COMPONENT_LIGHT_DESC, false);
let entity = world
.spawn((
LevelObject,
ActorKind::Light,
Transform::default(),
LightDesc::default(),
order.clone(),
states.clone(),
))
.id();
let snapshot = snapshot_entity(&world, entity).unwrap();
world.entity_mut(entity).despawn();
let restored = spawn_snapshot(&mut world, &snapshot);
assert_eq!(world.get::<InspectorOrder>(restored), Some(&order));
assert_eq!(
world.get::<AuthoringComponentStates>(restored),
Some(&states)
);
}
fn animation_controller(state_id: &str, crossfade_seconds: f32) -> AnimationControllerDesc {
AnimationControllerDesc {
skeleton: Some(
@@ -2420,7 +2888,7 @@ mod tests {
let entity = world
.spawn((
LevelObject,
ActorKind::ImportedModel,
ActorKind::SkinnedMesh,
Transform::IDENTITY,
old.clone(),
))
@@ -2439,6 +2907,36 @@ mod tests {
assert_eq!(world.get::<AnimationControllerDesc>(entity), Some(&new));
}
#[test]
fn navigation_component_history_round_trips_and_preserves_kind() {
let mut world = World::new();
world.init_resource::<EditorHistory>();
world.init_resource::<SceneIo>();
let entity = world
.spawn((LevelObject, ActorKind::Empty, Transform::IDENTITY))
.id();
let bounds = NavigationBounds::default();
set_navigation_with_history(
&mut world,
entity,
NavigationComponentState {
bounds: Some(bounds.clone()),
..Default::default()
},
);
assert_eq!(world.get::<NavigationBounds>(entity), Some(&bounds));
assert_eq!(world.get::<ActorKind>(entity), Some(&ActorKind::Navigation));
apply_command_undo(&mut world);
assert!(world.get::<NavigationBounds>(entity).is_none());
assert_eq!(world.get::<ActorKind>(entity), Some(&ActorKind::Empty));
apply_command_redo(&mut world);
assert_eq!(world.get::<NavigationBounds>(entity), Some(&bounds));
assert_eq!(world.get::<ActorKind>(entity), Some(&ActorKind::Navigation));
}
#[test]
fn undoing_a_new_animation_controller_removes_the_component() {
let mut world = World::new();
@@ -2446,7 +2944,7 @@ mod tests {
world.init_resource::<SceneIo>();
let controller = animation_controller("idle", 0.2);
let entity = world
.spawn((LevelObject, ActorKind::ImportedModel, Transform::IDENTITY))
.spawn((LevelObject, ActorKind::SkinnedMesh, Transform::IDENTITY))
.id();
set_animation_controller_with_history(&mut world, entity, controller.clone());
@@ -2467,9 +2965,10 @@ mod tests {
let source = world
.spawn((
LevelObject,
ActorKind::ImportedModel,
ActorKind::SkinnedMesh,
Name::new("Animated Robot"),
Transform::from_xyz(1.0, 2.0, 3.0),
SkinnedMeshRenderer::new("assets/models/robot.glb").with_asset_id("robot-asset"),
controller.clone(),
))
.id();
@@ -2486,6 +2985,10 @@ mod tests {
world.get::<Name>(respawned).map(Name::as_str),
Some("Animated Robot")
);
assert_eq!(
world.get::<SkinnedMeshRenderer>(respawned),
Some(&SkinnedMeshRenderer::new("assets/models/robot.glb").with_asset_id("robot-asset"))
);
}
#[test]