separate out renderer crate (#13)
* add keyboard handler * some cleanup * add l key binding * Fix WASM shared memory generation for Rust nightly 2025-10-20+ Add explicit linker flags for shared memory generation after Rust PR #147225 removed automatic flags with +atomics. This fixes DataCloneError when sharing memory with workers. Changes: - Add --shared-memory, --max-memory, --import-memory flags - Export TLS symbols: __wasm_init_tls, __tls_size, __tls_align, __tls_base - Update both Cargo.toml and package.json build scripts Amp-Thread-ID: https://ampcode.com/threads/T-41d99b69-5754-4fdf-b06e-a46343fa7485 Co-authored-by: Amp <amp@ampcode.com> * add a level-editor crate * remove redundant worker setup * simplify app setup * add SceneBuilder * separate out default scene implementation in a crate * define default method for MeshBuilder --------- Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
use wasm_bindgen::JsCast;
|
||||
|
||||
pub mod worker;
|
||||
|
||||
pub fn get_canvas_element(selectors: &str) -> web_sys::HtmlCanvasElement {
|
||||
let window = web_sys::window().unwrap();
|
||||
let document = window.document().unwrap();
|
||||
let element = document.query_selector(selectors).unwrap().unwrap();
|
||||
let canvas = element.dyn_into::<web_sys::HtmlCanvasElement>().unwrap();
|
||||
let scale_factor = window.device_pixel_ratio();
|
||||
let width = (canvas.client_width() as f64 * scale_factor) as u32;
|
||||
let height = (canvas.client_height() as f64 * scale_factor) as u32;
|
||||
canvas.set_width(width);
|
||||
canvas.set_height(height);
|
||||
canvas
|
||||
}
|
||||
Reference in New Issue
Block a user