Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Orient to Face Endpoint #612

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions modeling-cmds/src/def_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,22 @@
pub animated: bool,
}

/// Looks along the normal of the specified face (if it is planar!), and fits the view to it.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if it's not planar?

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]

Check warning on line 1138 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L1138

Added line #L1138 was not covered by tests
pub struct OrientToFace {
/// Which face to orient camera to.
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 a non-positive value, 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 {
Expand Down
7 changes: 7 additions & 0 deletions modeling-cmds/src/ok_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@
pub settings: CameraSettings
}

/// The response from the `OrientToFace` command.
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]

Check warning on line 415 in modeling-cmds/src/ok_response.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/ok_response.rs#L415

Added line #L415 was not covered by tests
pub struct OrientToFace {
/// Camera settings
pub settings: CameraSettings
}

/// The response from the `ViewIsometric` command.
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
pub struct ViewIsometric {
Expand Down
5 changes: 5 additions & 0 deletions modeling-cmds/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,11 @@
Self { settings }
}
}
impl From<CameraSettings> for crate::output::OrientToFace {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}

Check warning on line 675 in modeling-cmds/src/shared.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/shared.rs#L673-L675

Added lines #L673 - L675 were not covered by tests
}
impl From<CameraSettings> for crate::output::ViewIsometric {
fn from(settings: CameraSettings) -> Self {
Self { settings }
Expand Down
Loading