(
path: &str,
glb_mesh_index: usize,
_glb_mat_index: usize,
)
| 810 | } |
| 811 | state.dirty = true; |
| 812 | state.sidebar_mode = "scene".to_string(); |
| 813 | state.activity_mode = "scene".to_string(); |
| 814 | if let Some(path) = state.open_paths.get(state.active_open).cloned() |
| 815 | && !state.dirty_scene_paths.iter().any(|item| item == &path) |
| 816 | { |
| 817 | state.dirty_scene_paths.push(path); |
| 818 | } |
| 819 | state.log = format!("make node\n{name}: {node_type_name}"); |
| 820 | true |
| 821 | }) |
| 822 | .unwrap_or(false); |
| 823 | if changed { |
| 824 | rebuild_preview(ctx); |
| 825 | } |
| 826 | refresh_all(ctx); |
| 827 | } |
| 828 | |
| 829 | pub fn asset_binding_for_node( |
| 830 | path: &str, |
| 831 | node_type: &str, |
| 832 | glb_mesh_index: usize, |
| 833 | _glb_mat_index: usize, |
| 834 | ) -> Option<(&'static str, String)> { |
| 835 | if path.ends_with(".rs") { |
| 836 | return Some(("script", path.to_string())); |
| 837 | } |
| 838 | if path.ends_with(".scn") { |
| 839 | return Some(("root_of", path.to_string())); |
| 840 | } |
| 841 | let node_type = perro_scene::NodeType::from_str(node_type).ok()?; |
| 842 | let path_kind = asset_kind_for_path(path)?; |
| 843 | for field in perro_scene::scene_node_asset_fields(node_type) { |
| 844 | let perro_scene::NodeFieldType::Asset(field_kind) = field.ty else { |
| 845 | continue; |
| 846 | }; |
| 847 | if field_kind == path_kind |
| 848 | || (path_kind == perro_scene::SceneAssetKind::Model |
| 849 | && field_kind == perro_scene::SceneAssetKind::Mesh) |
| 850 | { |
| 851 | return Some(( |
| 852 | field.name, |
| 853 | asset_field_value(path, field_kind, glb_mesh_index), |
| 854 | )); |
| 855 | } |
| 856 | } |
| 857 | None |
| 858 | } |
| 859 | |
| 860 | pub fn asset_node_template( |
| 861 | path: &str, |
| 862 | glb_mesh_index: usize, |
| 863 | _glb_mat_index: usize, |
no test coverage detected