forked from StudioInfinity/dyna3
feat: add final struts and dump the coordinates
This commit is contained in:
parent
c3c3e14a43
commit
d572231a71
2 changed files with 41 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
|||
use itertools::Itertools;
|
||||
use std::rc::Rc;
|
||||
use sycamore::prelude::*;
|
||||
use web_sys::{KeyboardEvent, MouseEvent, wasm_bindgen::JsCast};
|
||||
use web_sys::{KeyboardEvent, MouseEvent, wasm_bindgen::{JsCast,}};
|
||||
|
||||
use crate::{
|
||||
AppState,
|
||||
|
@ -261,6 +261,31 @@ pub fn Outline() -> View {
|
|||
on:click = {
|
||||
let state = use_context::<AppState>();
|
||||
move |_| state.selection.update(|sel| sel.clear())
|
||||
},
|
||||
on:keydown = {
|
||||
let rep_list = state.assembly.elements.map(
|
||||
|elts| elts
|
||||
.clone()
|
||||
.into_iter()
|
||||
.map(|elt| format!("{}: {}", elt.id(), elt.representation()))
|
||||
.collect::<Vec<_>>()
|
||||
);
|
||||
|
||||
move |event: KeyboardEvent| {
|
||||
match event.key().as_str() {
|
||||
"c" => {
|
||||
console_log!("Dumping all coordinates");
|
||||
rep_list.map(
|
||||
|reps| {
|
||||
for item in reps {
|
||||
console_log!("{}", item);
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
Keyed(
|
||||
|
|
|
@ -898,17 +898,17 @@ fn load_554aug2(assembly: &Assembly) {
|
|||
-0.5*(4. + 2.*SQRT_2)
|
||||
];
|
||||
// Now process the acron data
|
||||
for (id, v, pinned, l, _neighbors) in ACRON554_COMMON {
|
||||
for (id, v, pinned, l, neighbors) in ACRON554_COMMON {
|
||||
let pt = Point::new(id, id, LEVEL_COLORS[l], point(v[0], v[1], v[2]));
|
||||
assembly.try_insert_element(pt);
|
||||
// QUESTION: Would there be a way to insert an Rc<dyn Element> into
|
||||
// an assembly to avoid the need to re-lookup pt in the assembly
|
||||
// after just inserting it? Or could/should try_insert_element return
|
||||
// the Rc<dyn Element> ?
|
||||
let pt_rc = assembly.find_element(id);
|
||||
|
||||
if pinned { // regulate each coordinate to its given value
|
||||
let mut freeze = Vec::<Rc<dyn Regulator>>::new();
|
||||
// QUESTION: Would there be a way to insert an Rc<Element> into
|
||||
// an assembly to avoid the need to re-lookup pt in the assembly
|
||||
// after just inserting it?
|
||||
let pt_rc = assembly.elements_by_id.with_untracked(
|
||||
|elts| elts[id].clone()
|
||||
);
|
||||
// filter the three coordinate regulators into freeze
|
||||
pt_rc.regulators().with_untracked( |regs| {
|
||||
for reg in regs {
|
||||
|
@ -927,7 +927,6 @@ fn load_554aug2(assembly: &Assembly) {
|
|||
}
|
||||
// If part of the octagon, make incident to the plane:
|
||||
if l == 8 {
|
||||
let pt_rc = assembly.find_element(id);
|
||||
let oct_index = oct_verts.len();
|
||||
oct_verts.push(pt_rc.clone());
|
||||
let incidence = InversiveDistanceRegulator::new(
|
||||
|
@ -951,6 +950,14 @@ fn load_554aug2(assembly: &Assembly) {
|
|||
}
|
||||
}
|
||||
}
|
||||
// Finally, add any specified neighbors
|
||||
for id in neighbors.split(",") {
|
||||
if id.len() == 0 { continue; }
|
||||
let strut = InversiveDistanceRegulator::new(
|
||||
[assembly.find_element(id), pt_rc.clone()]);
|
||||
strut.set_to(-0.5);
|
||||
assembly.insert_regulator(Rc::new(strut));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue