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 --straight flag to take model screenshots from head-on #49

Merged
merged 2 commits into from
Aug 16, 2018
Merged
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
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ pub fn main() {
.arg(Arg::with_name("headless")
.long("headless")
.help("Use real headless rendering for screenshots (default is a hidden window) [EXPERIMENTAL - see README for details]"))
.arg(Arg::with_name("straight")
.long("straight")
.help("Position camera in front of model if using default camera (i.e. glTF doesn't contain a camera or `--cam-index -1` is passed."))
.arg(Arg::with_name("scene")
.long("scene")
.default_value("0")
Expand Down Expand Up @@ -130,6 +133,7 @@ pub fn main() {
position: args.value_of("CAM-POS").map(|v| parse_vec3(v).unwrap()),
target: args.value_of("CAM-TARGET").map(|v| parse_vec3(v).unwrap()),
fovy: args.value_of("CAM-FOVY").map(|n| Deg(n.parse().unwrap())).unwrap(),
straight: args.is_present("straight"),
};

let log_level = match args.occurrences_of("verbose") {
Expand Down
3 changes: 2 additions & 1 deletion src/viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub struct CameraOptions {
pub position: Option<Vector3>,
pub target: Option<Vector3>,
pub fovy: Deg<f32>,
pub straight: bool,
}

pub struct GltfViewer {
Expand Down Expand Up @@ -202,7 +203,7 @@ impl GltfViewer {
}
} else {
info!("Determining camera view from bounding box");
viewer.set_camera_from_bounds(false);
viewer.set_camera_from_bounds(camera_options.straight);

if let Some(p) = camera_options.position {
viewer.orbit_controls.position = Point3::from_vec(p)
Expand Down