MCPcopy Create free account
hub / github.com/PerroEngine/Perro / open_gltf_path

Function open_gltf_path

perro_editor/res/scripts/assets/editor_assets.rs:651–690  ·  view source on GitHub ↗
(ctx: &mut ScriptContext<'_, API>, gltf_path: &str)

Source from the content-addressed store, hash-verified

649pub fn open_animation_path<API: ScriptAPI + ?Sized>(
650 ctx: &mut ScriptContext<'_, API>,
651 anim_path: &str,
652) {
653 let root = with_state!(ctx.run, EditorState, ctx.id, |state| {
654 state.project_root.clone()
655 }).unwrap_or_default();
656 let abs = res_to_abs(&root, anim_path);
657 match FileMod::load_string(&abs) {
658 Ok(text) => {
659 let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
660 state.activity_mode = "scene".to_string();
661 state.anim_drawer_open = true;
662 state.bottom_dock_open = true;
663 state.active_anim_player_key = None;
664 state.active_anim_path = anim_path.to_string();
665 state.active_asset_path = anim_path.to_string();
666 state.active_glb_path.clear();
667 state.active_glb_summary.clear();
668 crate::scripts::scene::editor_animation::load_anim_text_into_state(
669 state, anim_path, text,
670 );
671 state.log = format!(
672 "open animation\n{}",
673 editor_files::rel_label(anim_path)
674 );
675 });
676 refresh_all(ctx);
677 }
678 Err(err) => set_log(ctx, &format!("open animation fail\n{anim_path}\n{err}")),
679 }
680}
681
682pub fn open_gltf_path<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>, gltf_path: &str) {
683 let Some(info) = ctx.res.Glbs().inspect(gltf_path) else {
684 set_log(ctx, &format!("open glb fail\n{gltf_path}"));
685 return;
686 };
687 let summary = gltf_summary(
688 gltf_path,
689 info.mesh_count,
690 info.material_count,
691 info.animation_count,
692 info.skeleton_count,
693 info.texture_count,

Callers 3

open_asset_ref_pathFunction · 0.85
open_file_slotFunction · 0.85
open_active_assetFunction · 0.85

Calls 5

set_logFunction · 0.85
gltf_summaryFunction · 0.85
refresh_allFunction · 0.85
inspectMethod · 0.80
GlbsMethod · 0.80

Tested by

no test coverage detected