Application prototype #14

Merged
glen merged 101 commits from app-proto into main 2024-10-21 23:38:28 +00:00
Showing only changes of commit a40a110788 - Show all commits

View File

@ -108,6 +108,21 @@ fn main() {
// display
let display = create_node_ref();
// change listener
let scene_changed = create_signal(true);
create_effect(move || {
ctrl_x.track();
ctrl_y.track();
radius_x.track();
radius_y.track();
opacity.track();
highlight.track();
layer_threshold.track();
debug_mode.track();
scene_changed.set(true);
});
on_mount(move || {
// list construction elements
const SPHERE_MAX: usize = 12;
@ -216,7 +231,8 @@ fn main() {
bind_vertex_attrib(&ctx, position_index, 3, &positions);
// set up a repainting routine
let (_, start_updating_display, _) = create_raf(move || {
let (_, start_animation_loop, _) = create_raf(move || {
if scene_changed.get() {
/* INSTRUMENTS */
// measure frame time
frames_since_last_sample += 1;
@ -267,15 +283,15 @@ fn main() {
// draw the scene
ctx.draw_arrays(WebGl2RenderingContext::TRIANGLES, 0, VERTEX_CNT as i32);
});
/*
this wastes CPU time by running an animation loop, which updates the
display even when nothing has changed. there should be a way to make
Sycamore do single-frame updates in response to changes, but i
haven't found it yet
*/
start_updating_display();
// clear scene change flag
scene_changed.set(false);
} else {
frames_since_last_sample = 0;
frame_time.set(-1.0);
}
});
start_animation_loop();
});
view! {