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