Skip to content

Commit 428c5f9

Browse files
committed
extract utility fns
1 parent 9a84686 commit 428c5f9

File tree

2 files changed

+9
-429
lines changed

2 files changed

+9
-429
lines changed

crates/app-web/src/frame.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use glam::{Vec3, Vec4};
55
use instant::Instant;
66
use std::cell::RefCell;
77
use std::rc::Rc;
8-
use web_sys as web;
9-
use wasm_bindgen::JsCast;
108
use wasm_bindgen::closure::Closure;
9+
use wasm_bindgen::JsCast;
10+
use web_sys as web;
1111

1212
const CAMERA_Z: f32 = 6.0;
1313

@@ -290,9 +290,7 @@ impl<'a> FrameContext<'a> {
290290
}
291291
}
292292

293-
pub async fn init_gpu(
294-
canvas: &web::HtmlCanvasElement,
295-
) -> Option<render::GpuState<'static>> {
293+
pub async fn init_gpu(canvas: &web::HtmlCanvasElement) -> Option<render::GpuState<'static>> {
296294
// leak a canvas clone to satisfy 'static lifetime for surface
297295
let leaked_canvas = Box::leak(Box::new(canvas.clone()));
298296
match render::GpuState::new(leaked_canvas, CAMERA_Z).await {
@@ -322,9 +320,7 @@ pub fn start_loop(frame_ctx: Rc<RefCell<FrameContext<'static>>>) {
322320
}
323321
}) as Box<dyn FnMut()>));
324322
if let Some(w) = web::window() {
325-
let _ = w.request_animation_frame(
326-
tick.borrow().as_ref().unwrap().as_ref().unchecked_ref(),
327-
);
323+
let _ = w.request_animation_frame(tick.borrow().as_ref().unwrap().as_ref().unchecked_ref());
328324
}
329325
}
330326

0 commit comments

Comments
 (0)