(ctx: &mut ScriptContext<'_, API>)
| 1376 | if !label.is_empty() { |
| 1377 | set_viewport_label(ctx, &label); |
| 1378 | } |
| 1379 | } |
| 1380 | |
| 1381 | pub fn reset_freecam(state: &mut EditorState) { |
| 1382 | state.cam_x = 0.0; |
| 1383 | state.cam_y = 3.0; |
| 1384 | state.cam_z = 8.0; |
| 1385 | state.cam_yaw = 0.0; |
| 1386 | state.cam_pitch = -0.25; |
| 1387 | } |
| 1388 | |
| 1389 | pub fn reset_freecam_2d(state: &mut EditorState) { |
| 1390 | state.cam2_x = 0.0; |
| 1391 | state.cam2_y = 0.0; |
| 1392 | state.cam2_zoom = 1.0; |
| 1393 | } |
| 1394 | |
| 1395 | pub fn apply_freecam<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>) { |
| 1396 | let camera = with_state!(ctx.run, EditorState, ctx.id, |state| { |
| 1397 | (state.preview_camera_3d != 0).then(|| NodeID::from_u64(state.preview_camera_3d)) |
| 1398 | }).unwrap_or_default() |
| 1399 | .or_else(|| find_named(ctx, "editor_camera_3d")); |
| 1400 | let Some(camera) = camera else { |
| 1401 | return; |
| 1402 | }; |
no test coverage detected