From 9be5dc76ae7c068b5eb1bd893f8f241e6be0ed4a Mon Sep 17 00:00:00 2001 From: gserena Date: Thu, 24 Oct 2024 11:43:23 -0400 Subject: [PATCH 1/5] add orient to face --- modeling-cmds/src/def_enum.rs | 16 ++++++++++++++++ modeling-cmds/src/ok_response.rs | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/modeling-cmds/src/def_enum.rs b/modeling-cmds/src/def_enum.rs index 2d5e5aea..9412dc49 100644 --- a/modeling-cmds/src/def_enum.rs +++ b/modeling-cmds/src/def_enum.rs @@ -1092,6 +1092,22 @@ define_modeling_cmd_enum! { pub animated: bool, } + /// Looks along the normal of the specified face (if it is flat!), and fits the view to it. + #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + pub struct OrientToFace { + /// Which face to orient camera to. + pub face_id: Vec, + /// 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, + /// How many seconds the animation should take. If set to zero, no animation will occur. + #[serde(default = "default_animation_seconds")] + pub duration_seconds: f32, + } + /// Fit the view to the scene with an isometric view. #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] pub struct ViewIsometric { diff --git a/modeling-cmds/src/ok_response.rs b/modeling-cmds/src/ok_response.rs index 9bc0ac0d..1ffd86f3 100644 --- a/modeling-cmds/src/ok_response.rs +++ b/modeling-cmds/src/ok_response.rs @@ -401,6 +401,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 { From bae982a3aa6e12bb8eb6809d1233af9c4be375fe Mon Sep 17 00:00:00 2001 From: gserena Date: Thu, 24 Oct 2024 16:57:22 -0400 Subject: [PATCH 2/5] use one face only --- modeling-cmds/src/def_enum.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modeling-cmds/src/def_enum.rs b/modeling-cmds/src/def_enum.rs index 9412dc49..353c4ab6 100644 --- a/modeling-cmds/src/def_enum.rs +++ b/modeling-cmds/src/def_enum.rs @@ -1092,18 +1092,18 @@ define_modeling_cmd_enum! { pub animated: bool, } - /// Looks along the normal of the specified face (if it is flat!), and fits the view to it. + /// Looks along the normal of the specified face (if it is planar!), and fits the view to it. #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] pub struct OrientToFace { /// Which face to orient camera to. - pub face_id: Vec, + 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, - /// How many seconds the animation should take. If set to zero, no animation will occur. + /// How many seconds the animation should take. If set to a non-positive value, no animation will occur. #[serde(default = "default_animation_seconds")] pub duration_seconds: f32, } From 8eeba0d5ff183a7ac942e347b9f6d553dfc8c9dc Mon Sep 17 00:00:00 2001 From: gserena Date: Fri, 25 Oct 2024 09:25:04 -0400 Subject: [PATCH 3/5] add from for camera settings --- modeling-cmds/src/shared.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modeling-cmds/src/shared.rs b/modeling-cmds/src/shared.rs index 2b7ef6a2..67c139e8 100644 --- a/modeling-cmds/src/shared.rs +++ b/modeling-cmds/src/shared.rs @@ -647,6 +647,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 } From 1929a3cbe1c37c8b9ad6a582c43d74dd525be6f9 Mon Sep 17 00:00:00 2001 From: gserena Date: Fri, 24 Jan 2025 09:31:00 -0500 Subject: [PATCH 4/5] add partialeq tsrs --- modeling-cmds/src/def_enum.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modeling-cmds/src/def_enum.rs b/modeling-cmds/src/def_enum.rs index 46a68211..65db2685 100644 --- a/modeling-cmds/src/def_enum.rs +++ b/modeling-cmds/src/def_enum.rs @@ -1396,7 +1396,9 @@ define_modeling_cmd_enum! { } /// Looks along the normal of the specified face (if it is planar!), and fits the view to it. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[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. pub face_id: Uuid, From 9de39f37302e112d9095c553e5975c0c713a16f2 Mon Sep 17 00:00:00 2001 From: gserena Date: Tue, 28 Jan 2025 09:53:49 -0500 Subject: [PATCH 5/5] update docs, make animation bool --- modeling-cmds/src/def_enum.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modeling-cmds/src/def_enum.rs b/modeling-cmds/src/def_enum.rs index 65db2685..76ef6e6c 100644 --- a/modeling-cmds/src/def_enum.rs +++ b/modeling-cmds/src/def_enum.rs @@ -1400,7 +1400,7 @@ define_modeling_cmd_enum! { #[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. + /// 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. @@ -1408,9 +1408,9 @@ define_modeling_cmd_enum! { /// and padding = -0.2 means the view will span 80% of the face bounding box. #[serde(default)] pub padding: f32, - /// How many seconds the animation should take. If set to a non-positive value, no animation will occur. - #[serde(default = "default_animation_seconds")] - pub duration_seconds: 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.