Skip to content

Commit

Permalink
Merge pull request #2184 from hannobraun/all
Browse files Browse the repository at this point in the history
Add missing models to `all` model
  • Loading branch information
hannobraun authored Jan 30, 2024
2 parents 173d028 + aa29502 commit 1b8c84c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions models/all/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ edition = "2021"
[dependencies.fj]
path = "../../crates/fj"

[dependencies.color]
path = "../color"

[dependencies.cuboid]
path = "../cuboid"

Expand All @@ -20,3 +23,6 @@ path = "../split"

[dependencies.star]
path = "../star"

[dependencies.vertices-indices]
path = "../vertices-indices"
48 changes: 26 additions & 22 deletions models/all/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use fj::{
core::{
objects::Solid,
operations::{merge::Merge, transform::TransformObject},
operations::{
build::BuildSolid, merge::Merge, transform::TransformObject,
},
services::Services,
},
math::{Scalar, Vector},
Expand All @@ -16,25 +18,27 @@ pub fn model(services: &mut Services) -> Solid {
let axis = Vector::from([1., 1., 1.]).normalize();
let angle_rad = Scalar::PI / 6.;

let cuboid = cuboid::model([1., 2., 3.], services)
.translate(offset * 1., services)
.rotate(axis * angle_rad * 1., services);
let spacer = spacer::model(2., 1., 1., services)
.translate(offset * 2., services)
.rotate(axis * angle_rad * 2., services);
let star = star::model(5, 2., 1., 1., services)
.translate(offset * 3., services)
.rotate(axis * angle_rad * 3., services);
let split = split::model(1., 0.2, services)
.translate(offset * 4., services)
.rotate(axis * angle_rad * 4., services);
let holes = holes::model(0.5, services)
.translate(offset * 5., services)
.rotate(axis * angle_rad * 5., services);

cuboid
.merge(&spacer)
.merge(&star)
.merge(&split)
.merge(&holes)
let models = [
color::model(services),
cuboid::model([1., 2., 3.], services),
holes::model(0.5, services),
spacer::model(2., 1., 1., services),
split::model(1., 0.2, services),
star::model(5, 2., 1., 1., services),
vertices_indices::model(services),
];

let mut all = Solid::empty();

for (i, model) in models.into_iter().enumerate() {
let f = i as f64;

let model = model
.translate(offset * f, services)
.rotate(axis * angle_rad * f, services);

all = all.merge(&model);
}

all
}

0 comments on commit 1b8c84c

Please sign in to comment.