Skip to content

Commit

Permalink
fix: web build
Browse files Browse the repository at this point in the history
  • Loading branch information
mosure committed May 15, 2024
1 parent 42f4ddb commit b09764c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: deploy github pages

on:
Expand Down Expand Up @@ -41,10 +40,13 @@ jobs:
- name: generate bindings with wasm-bindgen
run: wasm-bindgen --out-dir ./www/out/ --target web ./target/wasm32-unknown-unknown/release/viewer.wasm

- name: copy assets
run: mkdir -p ./www/assets && cp -r ./assets/* ./www/assets/

- name: upload artifact for github pages
uses: actions/upload-pages-artifact@v1
with:
path: ./www/out/
path: ./www

deploy:
needs: build
Expand All @@ -57,5 +59,5 @@ jobs:
- name: deploy to github pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./www/out
folder: ./www
branch: www
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ sort_radix = []
sort_rayon = ["rayon"]
sort_std = []

testing = []
tooling = ["byte-unit"]

perftest = []
Expand Down Expand Up @@ -121,6 +122,7 @@ web = [
"buffer_texture",
"f16",
"io_flexbuffers",
"io_ply",
"planar",
"precompute_covariance_3d",
"sort_std",
Expand All @@ -136,7 +138,7 @@ webgpu = ["bevy/webgpu"]
bevy_args = { version = "1.3.0", optional = true }
bevy-inspector-egui = { version = "0.24", optional = true }
bevy_mod_picking = { version = "0.18", optional = true }
bevy_panorbit_camera = { version = "0.17", optional = true }
bevy_panorbit_camera = { version = "0.18", optional = true }
bevy_transform_gizmo = { version = "0.11", optional = true }
bincode2 = { version = "2.0", optional = true }
byte-unit = { version = "5.0", optional = true }
Expand Down Expand Up @@ -225,15 +227,17 @@ required-features = ["io_ply", "tooling"]
[[bin]]
name = "compare_aabb_obb"
path = "tools/compare_aabb_obb.rs"
required-features = ["tooling"]

[[bin]]
name = "test_gaussian"
path = "tests/gpu/gaussian.rs"
required-features = ["testing"]

[[bin]]
name = "test_radix"
path = "tests/gpu/radix.rs"
required-features = ["debug_gpu", "sort_radix"]
required-features = ["debug_gpu", "sort_radix", "testing"]

[[example]]
name = "minimal"
Expand Down
5 changes: 0 additions & 5 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// #[cfg(target_arch = "wasm32")]
// pub use wasm_bindgen_rayon::init_thread_pool;

#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;
#[cfg(target_arch = "wasm32")]
use std::collections::HashMap;

use bevy::prelude::*;
use bevy_args::{
Expand Down
4 changes: 2 additions & 2 deletions viewer/viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ fn example_app() {

#[cfg(target_arch = "wasm32")]
let primary_window = Some(Window {
fit_canvas_to_parent: true,
// fit_canvas_to_parent: true,
canvas: Some("#bevy".to_string()),
mode: bevy::window::WindowMode::Windowed,
prevent_default_event_handling: true,
title: config.name.clone(),
Expand All @@ -195,7 +196,6 @@ fn example_app() {

#[cfg(not(target_arch = "wasm32"))]
let primary_window = Some(Window {
canvas: Some("#bevy".to_string()),
mode: bevy::window::WindowMode::Windowed,
prevent_default_event_handling: false,
resolution: (config.width, config.height).into(),
Expand Down
18 changes: 16 additions & 2 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,24 @@
init()
</script>
<script>
// Disable right-click context menu
// disable right-click context menu
document.addEventListener('contextmenu', event => event.preventDefault());
</script>
<style>
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}

.full-size {
width: 100% !important;
height: 100% !important;
}
</style>
<body>
<canvas id="bevy" style="width: 100%; height: 100%;"></canvas>
<canvas id="bevy" class="full-size"></canvas>
</body>
</html>

0 comments on commit b09764c

Please sign in to comment.