diff --git a/modeling-cmds/src/def_enum.rs b/modeling-cmds/src/def_enum.rs index b70751d4..4092a9ea 100644 --- a/modeling-cmds/src/def_enum.rs +++ b/modeling-cmds/src/def_enum.rs @@ -1425,6 +1425,24 @@ define_modeling_cmd_enum! { pub animated: bool, } + /// Looks along the normal of the specified face (if it is planar!), and fits the view to it. + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct OrientToFace { + /// Which face to orient camera to. If the face is not planar, no action will occur. + pub face_id: Uuid, + /// How much to pad the view frame by, as a fraction of the face bounding box size. + /// Negative padding will crop the view of the face proportionally. + /// e.g. padding = 0.2 means the view will span 120% of the face bounding box, + /// and padding = -0.2 means the view will span 80% of the face bounding box. + #[serde(default)] + pub padding: f32, + /// Whether or not to animate the camera movement. (Animation is currently not supported.) + #[serde(default)] + pub animated: bool, + } + /// Fit the view to the scene with an isometric view. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] diff --git a/modeling-cmds/src/ok_response.rs b/modeling-cmds/src/ok_response.rs index b51d1096..06a2e677 100644 --- a/modeling-cmds/src/ok_response.rs +++ b/modeling-cmds/src/ok_response.rs @@ -396,6 +396,13 @@ define_ok_modeling_cmd_response_enum! { pub settings: CameraSettings } + /// The response from the `OrientToFace` command. + #[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)] + pub struct OrientToFace { + /// Camera settings + pub settings: CameraSettings + } + /// The response from the `ViewIsometric` command. #[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)] pub struct ViewIsometric { diff --git a/modeling-cmds/src/shared.rs b/modeling-cmds/src/shared.rs index bdf0fced..f680568c 100644 --- a/modeling-cmds/src/shared.rs +++ b/modeling-cmds/src/shared.rs @@ -751,6 +751,11 @@ impl From for crate::output::ZoomToFit { Self { settings } } } +impl From for crate::output::OrientToFace { + fn from(settings: CameraSettings) -> Self { + Self { settings } + } +} impl From for crate::output::ViewIsometric { fn from(settings: CameraSettings) -> Self { Self { settings }