Skip to content

Commit

Permalink
Fix web build
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Aug 28, 2024
1 parent 6e1fce2 commit 489ab26
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions crates/viewer/re_viewer/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ impl WebHandle {
/// - `manifest_url` is an optional URL to an `examples_manifest.json` file over http.
/// - `force_wgpu_backend` is an optional string to force a specific backend, either `webgl` or `webgpu`.
#[wasm_bindgen]
pub async fn start(&self, canvas_id: String) -> Result<(), wasm_bindgen::JsValue> {
pub async fn start(
&self,
canvas: web_sys::HtmlCanvasElement,
) -> Result<(), wasm_bindgen::JsValue> {
let app_options = self.app_options.clone();
let web_options = eframe::WebOptions {
follow_system_theme: false,
default_theme: eframe::Theme::Dark,
wgpu_options: crate::wgpu_options(app_options.render_backend.clone()),
depth_buffer: 0,
dithering: true, // TODO: are we sure about this?
};

self.runner
.start(
&canvas_id,
canvas,
web_options,
Box::new(move |cc| Ok(Box::new(create_app(cc, app_options)?))),
)
Expand Down
2 changes: 1 addition & 1 deletion rerun_js/web-viewer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class WebViewer {

this.#handle = new WebHandle_class({ ...options, fullscreen });
try {
await this.#handle.start(this.#canvas.id);
await this.#handle.start(document.getElementById(this.#canvas.id));
} catch (e) {
this.stop();
throw e;
Expand Down
2 changes: 1 addition & 1 deletion web_viewer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@

check_for_panic();

handle.start("the_canvas_id").then(on_app_started).catch(on_wasm_error);
handle.start(document.getElementById("the_canvas_id")).then(on_app_started).catch(on_wasm_error);
}

function get_query_bool(
Expand Down

0 comments on commit 489ab26

Please sign in to comment.