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

Function update_preview_pick

perro_editor/res/scripts/scene/editor_viewport.rs:2090–2142  ·  view source on GitHub ↗
(ctx: &mut ScriptContext<'_, API>)

Source from the content-addressed store, hash-verified

2088 Quaternion::IDENTITY,
2089 );
2090 add_gizmo_ring(ctx, root, red, "yz");
2091 add_gizmo_ring(ctx, root, green, "xz");
2092 add_gizmo_ring(ctx, root, blue, "xy");
2093 let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
2094 state.preview_selected_gizmo = root.as_u64();
2095 state.preview_selected_gizmo_key = Some(key);
2096 });
2097}
2098
2099fn create_editor_mesh_child<API: ScriptAPI + ?Sized>(
2100 ctx: &mut ScriptContext<'_, API>,
2101 parent: NodeID,
2102 name: &str,
2103 source: &str,
2104 material: MaterialID,
2105 transform: Transform3D,
2106) -> Option<NodeID> {
2107 let id = create_node!(ctx.run, MeshInstance3D, name.to_string(), tags![], parent);
2108 let mesh = ctx.res.Meshes().load(source);
2109 let _ = with_node_mut!(ctx.run, MeshInstance3D, id, |node| {
2110 node.mesh = mesh;
2111 node.set_material(material);
2112 node.transform = transform;
2113 node.cast_shadows = false;
2114 node.receive_shadows = false;
2115 node.meshlet_override = Some(false);
2116 });
2117 Some(id)
2118}
2119
2120fn editor_gizmo_material<API: ScriptAPI + ?Sized>(
2121 ctx: &mut ScriptContext<'_, API>,
2122 color: [f32; 4],
2123) -> MaterialID {
2124 let mut mat = Material3D::default();
2125 if let Material3D::Standard(params) = &mut mat {
2126 params.base_color_factor = color;
2127 params.emissive_factor = [color[0] * 0.35, color[1] * 0.35, color[2] * 0.35];
2128 params.alpha_mode = if color[3] < 0.99 { 2 } else { 0 };
2129 params.double_sided = true;
2130 params.roughness_factor = 0.85;
2131 params.metallic_factor = 0.0;
2132 }
2133 ctx.res.Materials().create(mat)
2134}
2135
2136fn preview_collision_shape_3d<API: ScriptAPI + ?Sized>(
2137 ctx: &mut ScriptContext<'_, API>,
2138 id: NodeID,
2139) -> Option<Shape3D> {
2140 Some(with_node!(ctx.run, CollisionShape3D, id, |node| node
2141 .shape
2142 .clone()).unwrap_or_default())
2143}
2144
2145fn collision_shape_mesh(shape: Shape3D) -> Option<(&'static str, Transform3D)> {

Callers

nothing calls this directly

Calls 6

viewport_pointerFunction · 0.85
pick_resize_handleFunction · 0.85
refresh_allFunction · 0.85
pick_rotation_zoneFunction · 0.85
pick_preview_uiFunction · 0.85
deselect_viewport_nodeFunction · 0.85

Tested by

no test coverage detected