Simplify sphere data passing

This commit is contained in:
Aaron Fenyes 2025-04-22 15:58:24 -07:00
parent cedb1d5b83
commit 68abc2ad44

View file

@ -517,7 +517,7 @@ pub fn Display() -> View {
// write the spheres in world coordinates // write the spheres in world coordinates
let sphere_reps_world: Vec<_> = scene.spheres.representations.into_iter().map( let sphere_reps_world: Vec<_> = scene.spheres.representations.into_iter().map(
|rep| &asm_to_world * rep |rep| (&asm_to_world * rep).cast::<f32>()
).collect(); ).collect();
/* SCAFFOLDING */ /* SCAFFOLDING */
@ -554,17 +554,17 @@ pub fn Display() -> View {
ctx.uniform2f(resolution_loc.as_ref(), width, height); ctx.uniform2f(resolution_loc.as_ref(), width, height);
ctx.uniform1f(shortdim_loc.as_ref(), width.min(height)); ctx.uniform1f(shortdim_loc.as_ref(), width.min(height));
// pass the assembly data // pass the scene data
ctx.uniform1i(sphere_cnt_loc.as_ref(), sphere_cnt); ctx.uniform1i(sphere_cnt_loc.as_ref(), sphere_cnt);
for n in 0..sphere_reps_world.len() { for n in 0..sphere_reps_world.len() {
let v = &sphere_reps_world[n]; let v = &sphere_reps_world[n];
ctx.uniform3f( ctx.uniform3fv_with_f32_array(
sphere_sp_locs[n].as_ref(), sphere_sp_locs[n].as_ref(),
v[0] as f32, v[1] as f32, v[2] as f32 v.rows(0, 3).as_slice()
); );
ctx.uniform2f( ctx.uniform2fv_with_f32_array(
sphere_lt_locs[n].as_ref(), sphere_lt_locs[n].as_ref(),
v[3] as f32, v[4] as f32 v.rows(3, 2).as_slice()
); );
ctx.uniform3fv_with_f32_array( ctx.uniform3fv_with_f32_array(
sphere_color_locs[n].as_ref(), sphere_color_locs[n].as_ref(),