Encapsulate construction

This commit is contained in:
Aaron Fenyes 2024-09-04 12:58:55 -07:00
parent a4236a34df
commit 121934c4c3

View File

@ -83,6 +83,22 @@ fn bind_vertex_attrib(
);
}
fn push_gen_test_construction(
sphere_vec: &mut Vec<DVector<f64>>,
construction_to_world: &DMatrix<f64>,
ctrl_x: f64,
ctrl_y: f64,
radius_x: f64,
radius_y: f64
) {
sphere_vec.push(construction_to_world * engine::sphere(0.5, 0.5, ctrl_x, radius_x));
sphere_vec.push(construction_to_world * engine::sphere(-0.5, -0.5, ctrl_y, radius_y));
sphere_vec.push(construction_to_world * engine::sphere(-0.5, 0.5, 0.0, 0.75));
sphere_vec.push(construction_to_world * engine::sphere(0.5, -0.5, 0.0, 0.5));
sphere_vec.push(construction_to_world * engine::sphere(0.0, 0.15, 1.0, 0.25));
sphere_vec.push(construction_to_world * engine::sphere(0.0, -0.15, -1.0, 0.25));
}
fn main() {
// set up a config option that forwards panic messages to `console.error`
#[cfg(feature = "console_error_panic_hook")]
@ -292,12 +308,12 @@ fn main() {
// update the construction
sphere_vec.clear();
sphere_vec.push(&construction_to_world * engine::sphere(0.5, 0.5, ctrl_x.get(), radius_x.get()));
sphere_vec.push(&construction_to_world * engine::sphere(-0.5, -0.5, ctrl_y.get(), radius_y.get()));
sphere_vec.push(&construction_to_world * engine::sphere(-0.5, 0.5, 0.0, 0.75));
sphere_vec.push(&construction_to_world * engine::sphere(0.5, -0.5, 0.0, 0.5));
sphere_vec.push(&construction_to_world * engine::sphere(0.0, 0.15, 1.0, 0.25));
sphere_vec.push(&construction_to_world * engine::sphere(0.0, -0.15, -1.0, 0.25));
push_gen_test_construction(
&mut sphere_vec,
&construction_to_world,
ctrl_x.get(), ctrl_y.get(),
radius_x.get(), radius_y.get()
);
// set the resolution
let width = canvas.width() as f32;