forked from StudioInfinity/dyna3
App: store selection in hash map
Switch `Assembly.elements` to a hash map too, since that's probably closer to what we'll want in the future.
This commit is contained in:
parent
96afad0c97
commit
96f8b6b5f3
5 changed files with 89 additions and 53 deletions
|
@ -102,8 +102,7 @@ pub fn Display() -> View {
|
|||
// change listener
|
||||
let scene_changed = create_signal(true);
|
||||
create_effect(move || {
|
||||
let elements = state.assembly.elements.get_clone();
|
||||
for elt in elements { elt.selected.track(); }
|
||||
state.selection.track();
|
||||
scene_changed.set(true);
|
||||
});
|
||||
|
||||
|
@ -289,17 +288,21 @@ pub fn Display() -> View {
|
|||
|
||||
// get the assembly
|
||||
let elements = state.assembly.elements.get_clone();
|
||||
let element_iter = (&elements).into_iter();
|
||||
let element_iter = (&elements).values();
|
||||
let reps_world: Vec<_> = element_iter.clone().map(|elt| &assembly_to_world * &elt.rep).collect();
|
||||
let colors: Vec<_> = element_iter.clone().map(|elt|
|
||||
if elt.selected.get() {
|
||||
if state.selection.with(|sel| sel.contains(&elt.id)) {
|
||||
elt.color.map(|ch| 0.2 + 0.8*ch)
|
||||
} else {
|
||||
elt.color
|
||||
}
|
||||
).collect();
|
||||
let highlights: Vec<_> = element_iter.map(|elt|
|
||||
if elt.selected.get() { 1.0_f32 } else { HIGHLIGHT }
|
||||
if state.selection.with(|sel| sel.contains(&elt.id)) {
|
||||
1.0_f32
|
||||
} else {
|
||||
HIGHLIGHT
|
||||
}
|
||||
).collect();
|
||||
|
||||
// set the resolution
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue