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

Function cycle_active_glb_ref

perro_editor/res/scripts/assets/editor_assets.rs:692–751  ·  view source on GitHub ↗
(
    ctx: &mut ScriptContext<'_, API>,
    kind: &str,
    dir: isize,
)

Source from the content-addressed store, hash-verified

690 info.material_count,
691 info.animation_count,
692 info.skeleton_count,
693 info.texture_count,
694 0,
695 0,
696 0,
697 );
698 let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
699 state.activity_mode = "glb".to_string();
700 state.sidebar_mode = "files".to_string();
701 state.anim_drawer_open = false;
702 state.active_anim_player_key = None;
703 state.active_anim_path.clear();
704 state.active_asset_path = gltf_path.to_string();
705 state.active_glb_path = gltf_path.to_string();
706 state.active_glb_summary = summary;
707 state.active_glb_mesh_index = 0;
708 state.active_glb_mat_index = 0;
709 state.active_glb_anim_index = 0;
710 state.glb_viewer_isolate = false;
711 state.viewport_mode = "3D".to_string();
712 reset_freecam(state);
713 state.log = format!(
714 "open glb\n{}\nmesh={} mat={} anim={}",
715 editor_files::rel_label(gltf_path),
716 info.mesh_count,
717 info.material_count,
718 info.animation_count
719 );
720 });
721 rebuild_preview(ctx);
722 auto_frame_glb_camera(ctx, gltf_path, info.mesh_count);
723 refresh_all(ctx);
724}
725
726pub fn cycle_active_glb_ref<API: ScriptAPI + ?Sized>(
727 ctx: &mut ScriptContext<'_, API>,
728 kind: &str,
729 dir: isize,
730) {
731 let path = with_state!(ctx.run, EditorState, ctx.id, |state| {
732 if state.active_glb_path.is_empty() {
733 None
734 } else {
735 Some(state.active_glb_path.clone())
736 }
737 }).unwrap_or_default();
738 let Some(path) = path else {
739 return;
740 };
741 let Some(info) = ctx.res.Glbs().inspect(&path) else {
742 set_log(ctx, &format!("glb ref fail\n{path}"));
743 return;
744 };
745 let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
746 let count = match kind {
747 "mesh" => info.mesh_count,
748 "mat" => info.material_count,
749 "animation" => info.animation_count,

Callers 1

update_editor_shortcutsFunction · 0.85

Calls 4

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

Tested by

no test coverage detected