diff --git a/src/core/client_state.rs b/src/core/client_state.rs index dd7c22b..36bfc56 100644 --- a/src/core/client_state.rs +++ b/src/core/client_state.rs @@ -78,7 +78,7 @@ impl ClientState { .iter() .map(|(k, v)| { (k.clone(), { - let node = Node::create(client, "/spatial/anchor", k, true) + let node = Node::create_parent_name(client, "/spatial/anchor", k, true) .add_to_scenegraph() .unwrap(); Spatial::add_to(&node, None, *v, false).unwrap(); diff --git a/src/core/idl_utils.rs b/src/core/idl_utils.rs new file mode 100644 index 0000000..df881ea --- /dev/null +++ b/src/core/idl_utils.rs @@ -0,0 +1,11 @@ +#[macro_export] +macro_rules! create_interface { + ($iface:ident, $aspect:ident, $path:expr) => { + pub fn create_interface(client: &Arc) -> Result<()> { + let node = Node::create_path(client, $path, false); + <$iface as $aspect>::add_node_members(&node); + node.add_to_scenegraph()?; + Ok(()) + } + }; +} diff --git a/src/core/mod.rs b/src/core/mod.rs index 71862d3..e42ebf5 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -3,6 +3,7 @@ pub mod client_state; pub mod delta; pub mod destroy_queue; pub mod eventloop; +pub mod idl_utils; pub mod node_collections; pub mod registry; pub mod resource; diff --git a/src/nodes/alias.rs b/src/nodes/alias.rs index 66aab1f..b07505b 100644 --- a/src/nodes/alias.rs +++ b/src/nodes/alias.rs @@ -35,7 +35,7 @@ impl Alias { "Node already exists" ); - let node = Node::create(client, parent, name, true).add_to_scenegraph()?; + let node = Node::create_parent_name(client, parent, name, true).add_to_scenegraph()?; let alias = Alias { enabled: Arc::new(AtomicBool::new(true)), node: Arc::downgrade(&node), diff --git a/src/nodes/audio.rs b/src/nodes/audio.rs index f0da82e..f487e96 100644 --- a/src/nodes/audio.rs +++ b/src/nodes/audio.rs @@ -107,7 +107,7 @@ pub fn update(sk: &impl StereoKitDraw) { } pub fn create_interface(client: &Arc) -> Result<()> { - let node = Node::create(client, "", "audio", false); + let node = Node::create_parent_name(client, "", "audio", false); node.add_local_signal("create_sound", create_flex); node.add_to_scenegraph().map(|_| ()) } @@ -121,7 +121,7 @@ pub fn create_flex(_node: Arc, calling_client: Arc, message: Messa resource: ResourceID, } let info: CreateSoundInfo = deserialize(message.as_ref())?; - let node = Node::create(&calling_client, "/audio/sound", info.name, true); + let node = Node::create_parent_name(&calling_client, "/audio/sound", info.name, true); let parent = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, true); let node = node.add_to_scenegraph()?; diff --git a/src/nodes/data.rs b/src/nodes/data.rs index b89d1f0..26c29aa 100644 --- a/src/nodes/data.rs +++ b/src/nodes/data.rs @@ -266,7 +266,7 @@ impl Drop for PulseReceiver { } pub fn create_interface(client: &Arc) -> Result<()> { - let node = Node::create(client, "", "data", false); + let node = Node::create_parent_name(client, "", "data", false); node.add_local_signal("create_pulse_sender", create_pulse_sender_flex); node.add_local_signal("create_pulse_receiver", create_pulse_receiver_flex); node.add_local_method("register_keymap", register_keymap_flex); @@ -287,7 +287,7 @@ pub fn create_pulse_sender_flex( mask: Vec, } let info: CreatePulseSenderInfo = deserialize(message.as_ref())?; - let node = Node::create(&calling_client, "/data/sender", info.name, true); + let node = Node::create_parent_name(&calling_client, "/data/sender", info.name, true); let parent = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, false); @@ -314,7 +314,7 @@ pub fn create_pulse_receiver_flex( mask: Vec, } let info: CreatePulseReceiverInfo = deserialize(message.as_ref())?; - let node = Node::create(&calling_client, "/data/receiver", info.name, true); + let node = Node::create_parent_name(&calling_client, "/data/receiver", info.name, true); let parent = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, false); let field = find_field(&calling_client, info.field_path)?; diff --git a/src/nodes/drawable/lines.rs b/src/nodes/drawable/lines.rs index 50381f1..e16794f 100644 --- a/src/nodes/drawable/lines.rs +++ b/src/nodes/drawable/lines.rs @@ -158,7 +158,7 @@ pub fn create_flex(_node: Arc, calling_client: Arc, message: Messa lines: Vec, } let mut info: CreateLinesInfo = deserialize(message.as_ref())?; - let node = Node::create(&calling_client, "/drawable/lines", info.name, true); + let node = Node::create_parent_name(&calling_client, "/drawable/lines", info.name, true); let parent = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, true); diff --git a/src/nodes/drawable/mod.rs b/src/nodes/drawable/mod.rs index c035c3f..5c65872 100644 --- a/src/nodes/drawable/mod.rs +++ b/src/nodes/drawable/mod.rs @@ -20,7 +20,7 @@ use stereokit::StereoKitDraw; use tracing::instrument; pub fn create_interface(client: &Arc) -> Result<()> { - let node = Node::create(client, "", "drawable", false); + let node = Node::create_parent_name(client, "", "drawable", false); node.add_local_signal("create_lines", lines::create_flex); node.add_local_signal("create_model", model::create_flex); node.add_local_signal("create_text", text::create_flex); diff --git a/src/nodes/drawable/model.rs b/src/nodes/drawable/model.rs index ed833f0..d7b731c 100644 --- a/src/nodes/drawable/model.rs +++ b/src/nodes/drawable/model.rs @@ -186,7 +186,7 @@ impl ModelPart { let client = stardust_model_part.get_client()?; let mut part_path = parent_part.map(|n| n.path.clone()).unwrap_or_default(); part_path.push(sk.model_node_get_name(sk_model, id)?); - let node = client.scenegraph.add_node(Node::create( + let node = client.scenegraph.add_node(Node::create_parent_name( &client, stardust_model_part.get_path(), part_path.to_str()?, @@ -412,7 +412,7 @@ pub fn create_flex(_node: Arc, calling_client: Arc, message: Messa resource: ResourceID, } let info: CreateModelInfo = deserialize(message.as_ref())?; - let node = Node::create(&calling_client, "/drawable/model", info.name, true); + let node = Node::create_parent_name(&calling_client, "/drawable/model", info.name, true); let parent = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, true); let node = node.add_to_scenegraph()?; diff --git a/src/nodes/drawable/text.rs b/src/nodes/drawable/text.rs index 7990e18..e904581 100644 --- a/src/nodes/drawable/text.rs +++ b/src/nodes/drawable/text.rs @@ -204,7 +204,7 @@ pub fn create_flex(_node: Arc, calling_client: Arc, message: Messa color: [f32; 4], } let info: CreateTextInfo = deserialize(message.as_ref())?; - let node = Node::create(&calling_client, "/drawable/text", info.name, true); + let node = Node::create_parent_name(&calling_client, "/drawable/text", info.name, true); let parent = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, true); let color = Rgba::from_slice(&info.color); diff --git a/src/nodes/fields/box.rs b/src/nodes/fields/box.rs index fac9a81..6662b61 100644 --- a/src/nodes/fields/box.rs +++ b/src/nodes/fields/box.rs @@ -84,7 +84,7 @@ pub fn create_box_field_flex( size: Vector3, } let info: CreateFieldInfo = deserialize(message.as_ref())?; - let node = Node::create(&calling_client, "/field", info.name, true); + let node = Node::create_parent_name(&calling_client, "/field", info.name, true); let parent = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, false); let node = node.add_to_scenegraph()?; diff --git a/src/nodes/fields/cylinder.rs b/src/nodes/fields/cylinder.rs index 4427c22..e2b55cc 100644 --- a/src/nodes/fields/cylinder.rs +++ b/src/nodes/fields/cylinder.rs @@ -84,7 +84,7 @@ pub fn create_cylinder_field_flex( radius: f32, } let info: CreateFieldInfo = deserialize(message.as_ref())?; - let node = Node::create(&calling_client, "/field", info.name, true); + let node = Node::create_parent_name(&calling_client, "/field", info.name, true); let parent = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, false); let node = node.add_to_scenegraph()?; diff --git a/src/nodes/fields/mod.rs b/src/nodes/fields/mod.rs index 45d5960..eb0c2f9 100644 --- a/src/nodes/fields/mod.rs +++ b/src/nodes/fields/mod.rs @@ -250,7 +250,7 @@ impl Deref for Field { } pub fn create_interface(client: &Arc) -> Result<()> { - let node = Node::create(client, "", "field", false); + let node = Node::create_parent_name(client, "", "field", false); node.add_local_signal("create_box_field", create_box_field_flex); node.add_local_signal("create_cylinder_field", create_cylinder_field_flex); node.add_local_signal("create_sphere_field", create_sphere_field_flex); diff --git a/src/nodes/fields/sphere.rs b/src/nodes/fields/sphere.rs index b87de24..0dcb447 100644 --- a/src/nodes/fields/sphere.rs +++ b/src/nodes/fields/sphere.rs @@ -81,7 +81,7 @@ pub fn create_sphere_field_flex( radius: f32, } let info: CreateFieldInfo = deserialize(message.as_ref())?; - let node = Node::create(&calling_client, "/field", info.name, true); + let node = Node::create_parent_name(&calling_client, "/field", info.name, true); let parent = find_spatial_parent(&calling_client, info.parent_path)?; let transform = Mat4::from_translation( info.origin diff --git a/src/nodes/fields/torus.rs b/src/nodes/fields/torus.rs index b491702..9ffab4a 100644 --- a/src/nodes/fields/torus.rs +++ b/src/nodes/fields/torus.rs @@ -84,7 +84,7 @@ pub fn create_torus_field_flex( radius_b: f32, } let info: CreateFieldInfo = deserialize(message.as_ref())?; - let node = Node::create(&calling_client, "/field", info.name, true); + let node = Node::create_parent_name(&calling_client, "/field", info.name, true); let parent = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, false); let node = node.add_to_scenegraph()?; diff --git a/src/nodes/hmd.rs b/src/nodes/hmd.rs index 62d20cf..55bf7d8 100644 --- a/src/nodes/hmd.rs +++ b/src/nodes/hmd.rs @@ -13,7 +13,7 @@ lazy_static::lazy_static! { } fn create() -> Arc { - let node = Arc::new(Node::create(&INTERNAL_CLIENT, "", "hmd", false)); + let node = Arc::new(Node::create_parent_name(&INTERNAL_CLIENT, "", "hmd", false)); Spatial::add_to(&node, None, Mat4::IDENTITY, false).expect("Unable to make spatial for HMD"); node diff --git a/src/nodes/input/mod.rs b/src/nodes/input/mod.rs index 2b781ed..be3a6ff 100644 --- a/src/nodes/input/mod.rs +++ b/src/nodes/input/mod.rs @@ -352,7 +352,7 @@ impl Drop for InputHandler { } pub fn create_interface(client: &Arc) -> Result<()> { - let node = Node::create(client, "", "input", false); + let node = Node::create_parent_name(client, "", "input", false); node.add_local_signal("create_input_handler", create_input_handler_flex); node.add_local_signal("create_input_method_pointer", pointer::create_pointer_flex); node.add_local_signal("create_input_method_tip", tip::create_tip_flex); @@ -376,8 +376,8 @@ pub fn create_input_handler_flex( let transform = parse_transform(info.transform, true, true, true); let field = find_field(&calling_client, info.field_path)?; - let node = - Node::create(&calling_client, "/input/handler", info.name, true).add_to_scenegraph()?; + let node = Node::create_parent_name(&calling_client, "/input/handler", info.name, true) + .add_to_scenegraph()?; Spatial::add_to(&node, Some(parent), transform, false)?; InputHandler::add_to(&node, &field)?; Ok(()) diff --git a/src/nodes/input/pointer.rs b/src/nodes/input/pointer.rs index 7f8dbac..334a1e5 100644 --- a/src/nodes/input/pointer.rs +++ b/src/nodes/input/pointer.rs @@ -78,7 +78,7 @@ pub fn create_pointer_flex( datamap: Option>, } let info: CreatePointerInfo = deserialize(message.as_ref())?; - let node = Node::create(&calling_client, "/input/method/pointer", info.name, true); + let node = Node::create_parent_name(&calling_client, "/input/method/pointer", info.name, true); let parent = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, false); diff --git a/src/nodes/input/tip.rs b/src/nodes/input/tip.rs index 6679628..cdcf418 100644 --- a/src/nodes/input/tip.rs +++ b/src/nodes/input/tip.rs @@ -60,7 +60,7 @@ pub fn create_tip_flex( datamap: Option>, } let info: CreateTipInfo = deserialize(message.as_ref())?; - let node = Node::create(&calling_client, "/input/method/tip", info.name, true); + let node = Node::create_parent_name(&calling_client, "/input/method/tip", info.name, true); let parent = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, false); diff --git a/src/nodes/items/camera.rs b/src/nodes/items/camera.rs index 01171f7..bbd969f 100644 --- a/src/nodes/items/camera.rs +++ b/src/nodes/items/camera.rs @@ -181,8 +181,8 @@ pub(super) fn create_camera_item_flex( let space = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, false); - let node = - Node::create(&INTERNAL_CLIENT, &parent_name, info.name, false).add_to_scenegraph()?; + let node = Node::create_parent_name(&INTERNAL_CLIENT, &parent_name, info.name, false) + .add_to_scenegraph()?; Spatial::add_to(&node, None, transform * space.global_transform(), false)?; CameraItem::add_to(&node, info.proj_matrix.into(), info.px_size); node.item diff --git a/src/nodes/items/environment.rs b/src/nodes/items/environment.rs index 9cb0ff4..b7df92a 100644 --- a/src/nodes/items/environment.rs +++ b/src/nodes/items/environment.rs @@ -81,8 +81,8 @@ pub(super) fn create_environment_item_flex( let space = find_spatial_parent(&calling_client, info.parent_path)?; let transform = parse_transform(info.transform, true, true, false); - let node = - Node::create(&INTERNAL_CLIENT, &parent_name, info.name, false).add_to_scenegraph()?; + let node = Node::create_parent_name(&INTERNAL_CLIENT, &parent_name, info.name, false) + .add_to_scenegraph()?; Spatial::add_to(&node, None, transform * space.global_transform(), false)?; EnvironmentItem::add_to(&node, info.item_data); node.item diff --git a/src/nodes/items/mod.rs b/src/nodes/items/mod.rs index 1e77e76..2a26517 100644 --- a/src/nodes/items/mod.rs +++ b/src/nodes/items/mod.rs @@ -426,7 +426,7 @@ impl Drop for ItemAcceptor { } pub fn create_interface(client: &Arc) -> Result<()> { - let node = Node::create(client, "", "item", false); + let node = Node::create_parent_name(client, "", "item", false); node.add_local_signal("create_camera_item", camera::create_camera_item_flex); node.add_local_signal( "create_environment_item", @@ -457,8 +457,8 @@ pub fn register_item_ui_flex( } let info: RegisterItemUIInfo = deserialize(message.as_ref())?; let type_info = type_info(info.item_type)?; - let ui = - Node::create(&calling_client, "/item", type_info.type_name, true).add_to_scenegraph()?; + let ui = Node::create_parent_name(&calling_client, "/item", type_info.type_name, true) + .add_to_scenegraph()?; ItemUI::add_to(&ui, type_info)?; Ok(()) } @@ -482,7 +482,7 @@ fn create_item_acceptor_flex( let field = find_field(&calling_client, info.field_path)?; let type_info = type_info(info.item_type)?; - let node = Node::create( + let node = Node::create_parent_name( &calling_client, &format!("/item/{}/acceptor", type_info.type_name), info.name, diff --git a/src/nodes/items/panel.rs b/src/nodes/items/panel.rs index 7bb381f..fd91fbf 100644 --- a/src/nodes/items/panel.rs +++ b/src/nodes/items/panel.rs @@ -228,7 +228,7 @@ impl PanelItem { .and_then(|env| state(&env)); let uid = nanoid!(); - let node = Node::create(&INTERNAL_CLIENT, "/item/panel/item", &uid, true) + let node = Node::create_parent_name(&INTERNAL_CLIENT, "/item/panel/item", &uid, true) .add_to_scenegraph() .unwrap(); let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false).unwrap(); diff --git a/src/nodes/mod.rs b/src/nodes/mod.rs index 4d31ffb..bb47aa8 100644 --- a/src/nodes/mod.rs +++ b/src/nodes/mod.rs @@ -109,16 +109,24 @@ impl Node { self.path.as_str() } - pub fn create(client: &Arc, parent: &str, name: &str, destroyable: bool) -> Self { + pub fn create_parent_name( + client: &Arc, + parent: &str, + name: &str, + destroyable: bool, + ) -> Self { let mut path = parent.to_string(); path.push('/'); path.push_str(name); + Self::create_path(client, path, destroyable) + } + pub fn create_path(client: &Arc, path: impl ToString, destroyable: bool) -> Self { let node = Node { enabled: Arc::new(AtomicBool::new(true)), uid: nanoid!(), client: Arc::downgrade(client), message_sender_handle: client.message_sender_handle.clone(), - path, + path: path.to_string(), // trailing_slash_pos: parent.len(), local_signals: Default::default(), local_methods: Default::default(), diff --git a/src/nodes/root.rs b/src/nodes/root.rs index 26bcbef..2421095 100644 --- a/src/nodes/root.rs +++ b/src/nodes/root.rs @@ -25,7 +25,7 @@ pub struct Root { } impl Root { pub fn create(client: &Arc) -> Result> { - let node = Node::create(client, "", "", false); + let node = Node::create_parent_name(client, "", "", false); node.add_local_signal("subscribe_frame", Root::subscribe_frame_flex); node.add_local_signal("set_base_prefixes", Root::set_base_prefixes_flex); node.add_local_method("state_token", Root::state_token_flex); diff --git a/src/nodes/spatial/mod.rs b/src/nodes/spatial/mod.rs index 8d12bf5..9e0e101 100644 --- a/src/nodes/spatial/mod.rs +++ b/src/nodes/spatial/mod.rs @@ -5,6 +5,7 @@ use super::fields::get_field; use super::Node; use crate::core::client::Client; use crate::core::registry::Registry; +use crate::create_interface; use color_eyre::eyre::{ensure, eyre, Result}; use glam::{vec3a, Mat4, Quat}; use mint::Vector3; @@ -478,8 +479,8 @@ impl SpatialInterfaceAspect for SpatialInterface { ) -> Result<()> { let parent = get_spatial(&parent, "Spatial parent")?; let transform = parse_transform(transform, true, true, true); - let node = - Node::create(&calling_client, "/spatial/spatial", &name, true).add_to_scenegraph()?; + let node = Node::create_parent_name(&calling_client, "/spatial/spatial", &name, true) + .add_to_scenegraph()?; Spatial::add_to(&node, Some(parent), transform, zoneable)?; Ok(()) } @@ -496,16 +497,12 @@ impl SpatialInterfaceAspect for SpatialInterface { let transform = parse_transform(transform, true, true, false); let field = get_field(&field)?; - let node = - Node::create(&calling_client, "/spatial/zone", &name, true).add_to_scenegraph()?; + let node = Node::create_parent_name(&calling_client, "/spatial/zone", &name, true) + .add_to_scenegraph()?; let space = Spatial::add_to(&node, Some(parent), transform, false)?; Zone::add_to(&node, space, &field); Ok(()) } } -pub fn create_interface(client: &Arc) -> Result<()> { - let node = Node::create(client, "", "spatial", false); - ::add_node_members(&node); - node.add_to_scenegraph().map(|_| ()) -} +create_interface!(SpatialInterface, SpatialInterfaceAspect, "/spatial"); diff --git a/src/objects/input/eye_pointer.rs b/src/objects/input/eye_pointer.rs index 5627fb2..0da135b 100644 --- a/src/objects/input/eye_pointer.rs +++ b/src/objects/input/eye_pointer.rs @@ -28,7 +28,8 @@ pub struct EyePointer { } impl EyePointer { pub fn new() -> Result { - let node = Node::create(&INTERNAL_CLIENT, "", &nanoid!(), false).add_to_scenegraph()?; + let node = Node::create_parent_name(&INTERNAL_CLIENT, "", &nanoid!(), false) + .add_to_scenegraph()?; let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false).unwrap(); let pointer = InputMethod::add_to(&node, InputType::Pointer(Pointer::default()), None).unwrap(); diff --git a/src/objects/input/mouse_pointer.rs b/src/objects/input/mouse_pointer.rs index 248e023..6efa091 100644 --- a/src/objects/input/mouse_pointer.rs +++ b/src/objects/input/mouse_pointer.rs @@ -56,7 +56,8 @@ pub struct MousePointer { } impl MousePointer { pub fn new() -> Result { - let node = Node::create(&INTERNAL_CLIENT, "", &nanoid!(), false).add_to_scenegraph()?; + let node = Node::create_parent_name(&INTERNAL_CLIENT, "", &nanoid!(), false) + .add_to_scenegraph()?; let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false).unwrap(); let pointer = InputMethod::add_to(&node, InputType::Pointer(Pointer::default()), None).unwrap(); diff --git a/src/objects/input/sk_controller.rs b/src/objects/input/sk_controller.rs index cd3674a..e6a691f 100644 --- a/src/objects/input/sk_controller.rs +++ b/src/objects/input/sk_controller.rs @@ -32,7 +32,7 @@ pub struct SkController { } impl SkController { pub fn new(sk: &impl StereoKitMultiThread, handed: Handed) -> Result { - let _node = Node::create( + let _node = Node::create_parent_name( &INTERNAL_CLIENT, "", if handed == Handed::Left { diff --git a/src/objects/input/sk_hand.rs b/src/objects/input/sk_hand.rs index e6f1a7c..4f3ddda 100644 --- a/src/objects/input/sk_hand.rs +++ b/src/objects/input/sk_hand.rs @@ -40,7 +40,8 @@ pub struct SkHand { } impl SkHand { pub fn new(handed: Handed) -> Result { - let _node = Node::create(&INTERNAL_CLIENT, "", &nanoid!(), false).add_to_scenegraph()?; + let _node = Node::create_parent_name(&INTERNAL_CLIENT, "", &nanoid!(), false) + .add_to_scenegraph()?; Spatial::add_to(&_node, None, Mat4::IDENTITY, false)?; let hand = InputType::Hand(Box::new(Hand { base: FlatHand { diff --git a/src/objects/play_space.rs b/src/objects/play_space.rs index 664a1d3..c47a011 100644 --- a/src/objects/play_space.rs +++ b/src/objects/play_space.rs @@ -39,7 +39,8 @@ pub struct PlaySpace { } impl PlaySpace { pub fn new() -> Result { - let node = Node::create(&INTERNAL_CLIENT, "", &nanoid!(), false).add_to_scenegraph()?; + let node = Node::create_parent_name(&INTERNAL_CLIENT, "", &nanoid!(), false) + .add_to_scenegraph()?; let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false)?; let field = BoxField::add_to(&node, [0.0; 3].into())?; @@ -60,7 +61,9 @@ impl PlaySpace { pose.orientation, pose.position, )); - let Field::Box(box_field) = self.field.as_ref() else {return}; + let Field::Box(box_field) = self.field.as_ref() else { + return; + }; box_field.set_size( [ sk.world_get_bounds_size().x,