diff --git a/Cargo.lock b/Cargo.lock
index bf2810c5..6f691a27 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -251,6 +251,16 @@ dependencies = [
"unicode-width",
]
+[[package]]
+name = "console_error_panic_hook"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
+dependencies = [
+ "cfg-if 1.0.0",
+ "wasm-bindgen",
+]
+
[[package]]
name = "copyless"
version = "0.1.5"
@@ -1479,9 +1489,9 @@ checksum = "f1382d1f0a252c4bf97dc20d979a2fdd05b024acd7c2ed0f7595d7817666a157"
[[package]]
name = "ron"
-version = "0.6.4"
+version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "064ea8613fb712a19faf920022ec8ddf134984f100090764a4e1d768f3827f1f"
+checksum = "86018df177b1beef6c7c8ef949969c4f7cb9a9344181b92486b23c79995bdaa4"
dependencies = [
"base64",
"bitflags",
@@ -1758,6 +1768,7 @@ dependencies = [
"bytemuck",
"byteorder",
"cgmath",
+ "console_error_panic_hook",
"env_logger",
"futures",
"getopts",
@@ -1777,6 +1788,8 @@ dependencies = [
"serde_scan",
"splay",
"tiff",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
"wgpu",
"winit",
]
@@ -2098,7 +2111,9 @@ dependencies = [
"raw-window-handle",
"scopeguard",
"smithay-client-toolkit",
+ "wasm-bindgen",
"wayland-client",
+ "web-sys",
"winapi",
"x11-dl",
]
diff --git a/Cargo.toml b/Cargo.toml
index 445ffe7c..17532ff9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -60,13 +60,17 @@ rust-ini = "0.17"
serde = "1.0"
serde_derive = "1.0"
serde_scan = "0.4"
-wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "5f6c067", features = [] }
+wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "5f6c067", features = ["webgl"] }
# binaries
env_logger = "0.8"
getopts = "0.2"
obj = "0.10"
png = "0.16"
-winit = "0.25"
+winit = { version = "0.25", features = ["web-sys"] }
+wasm-bindgen = "0.2.78"
+wasm-bindgen-futures = "0.4"
+console_error_panic_hook = { version = "0.1.7" }
+
[dev-dependencies]
naga = { git = "https://github.com/gfx-rs/naga", rev = "29571cc", features = ["wgsl-in"] }
diff --git a/README.md b/README.md
index 595b8fbe..6321778d 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,29 @@ Controls:
+### Web version
+
+Work in progress, stage matrix:
+
+ Stage | State |
+ -------------------- | ------------------ |
+ Support FS | :white_check_mark: |
+ WebGL Initialization | :white_check_mark: |
+ Loading worlds | :white_check_mark: |
+ Loading heights | :white_check_mark: |
+ Loading data | :white_check_mark: |
+ Loading flood | :white_check_mark: |
+ Render | :construction: |
+
+
+Build for web:
+
+```sh
+PATH=$PATH:/home/caiiiycuk/rust/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/bin/ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/caiiiycuk/rust/rust/build/x86_64-unknown-linux-gnu/stage0/lib/ cargo build --target wasm32-unknown-unknown --bin road --verbose && wasm-bindgen --out-dir html5/ --target web --keep-debug target/wasm32-unknown-unknown/debug/road.wasm
+```
+
+
+
### Mechous viewer/debugger
`car` binary allows to see the mechos with items selected by the configuration. It also shows the debug collision info.
```bash
diff --git a/bin/boilerplate.rs b/bin/boilerplate.rs
index 719570c6..d2b77c00 100644
--- a/bin/boilerplate.rs
+++ b/bin/boilerplate.rs
@@ -4,7 +4,7 @@ use vangers::{
render::{ScreenTargets, DEPTH_FORMAT},
};
-use futures::executor::{LocalPool, LocalSpawner};
+use futures::executor::{LocalPool, LocalSpawner, block_on};
use log::info;
use winit::{
event,
@@ -54,9 +54,10 @@ pub struct HarnessOptions {
impl Harness {
pub fn init(options: HarnessOptions) -> (Self, config::Settings) {
- env_logger::init();
- let mut task_pool = LocalPool::new();
+ block_on(Harness::init_async(options))
+ }
+ pub async fn init_async(options: HarnessOptions) -> (Self, config::Settings) {
info!("Loading the settings");
let settings = config::Settings::load("config/settings.ron");
let extent = wgpu::Extent3d {
@@ -76,19 +77,22 @@ impl Harness {
.unwrap();
let surface = unsafe { instance.create_surface(&window) };
- info!("Initializing the device");
- let adapter = task_pool
- .run_until(instance.request_adapter(&wgpu::RequestAdapterOptions {
+ info!("Initializing the device:adapter");
+ let adapter = instance.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::HighPerformance,
compatible_surface: Some(&surface),
force_fallback_adapter: false,
- }))
- .expect("Unable to initialize GPU via the selected backend.");
+ }).await.expect("Unable to initialize GPU via the selected backend (adapter).");
let downlevel_caps = adapter.get_downlevel_properties();
let adapter_limits = adapter.limits();
+ #[cfg(target_arch = "wasm32")]
+ let mut limits = wgpu::Limits::downlevel_webgl2_defaults();
+
+ #[cfg(not(target_arch = "wasm32"))]
let mut limits = wgpu::Limits::downlevel_defaults();
+
if options.uses_level {
let desired_height = 16 << 10;
limits.max_texture_dimension_2d =
@@ -102,8 +106,9 @@ impl Harness {
desired_height
};
}
- let (device, queue) = task_pool
- .run_until(adapter.request_device(
+
+ info!("Initializing the device:request");
+ let (device, queue) = adapter.request_device(
&wgpu::DeviceDescriptor {
label: None,
features: wgpu::Features::empty(),
@@ -114,8 +119,7 @@ impl Harness {
} else {
Some(std::path::Path::new(&settings.render.wgpu_trace_path))
},
- ))
- .unwrap();
+ ).await.expect("Unable to initialize GPU via the selected backend (request).");
let config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
@@ -141,7 +145,7 @@ impl Harness {
.create_view(&wgpu::TextureViewDescriptor::default());
let harness = Harness {
- task_pool,
+ task_pool: LocalPool::new(),
event_loop,
window,
device,
@@ -160,7 +164,9 @@ impl Harness {
pub fn main_loop(self, mut app: A) {
use std::time;
+ #[cfg(not(target_arch = "wasm32"))]
let mut last_time = time::Instant::now();
+
let mut needs_reload = false;
let Harness {
mut task_pool,
@@ -241,9 +247,14 @@ impl Harness {
},
event::Event::MainEventsCleared => {
let spawner = task_pool.spawner();
- let duration = time::Instant::now() - last_time;
- last_time += duration;
- let delta = duration.as_secs() as f32 + duration.subsec_nanos() as f32 * 1.0e-9;
+
+ let mut delta: f32 = 16.0;
+
+ #[cfg(not(target_arch = "wasm32"))] {
+ let duration = time::Instant::now() - last_time;
+ last_time += duration;
+ delta = duration.as_secs() as f32 + duration.subsec_nanos() as f32 * 1.0e-9;
+ }
let update_command_buffers = app.update(&device, delta, &spawner);
if !update_command_buffers.is_empty() {
diff --git a/bin/road/game.rs b/bin/road/game.rs
index 6409777a..41e67ff3 100644
--- a/bin/road/game.rs
+++ b/bin/road/game.rs
@@ -811,6 +811,7 @@ impl Application for Game {
}
{
+ #[cfg(not(target_arch = "wasm32"))]
use rayon::prelude::*;
let clipper = Clipper::new(&self.cam);
@@ -818,7 +819,13 @@ impl Application for Game {
let common = &self.db.common;
let level = &self.level;
- self.agents.par_iter_mut().for_each(|a| {
+ #[cfg(not(target_arch = "wasm32"))]
+ let agent_iter = self.agents.par_iter_mut();
+
+ #[cfg(target_arch = "wasm32")]
+ let agent_iter = self.agents.iter_mut();
+
+ agent_iter.for_each(|a| {
let mut dt = physics_dt;
a.cpu_apply_control(input_factor, common);
diff --git a/bin/road/main.rs b/bin/road/main.rs
index eb44185a..f36d30b8 100644
--- a/bin/road/main.rs
+++ b/bin/road/main.rs
@@ -2,18 +2,21 @@
use log::info;
+#[cfg(target_arch = "wasm32")]
+use wasm_bindgen::prelude::*;
+
+#[cfg(target_arch = "wasm32")]
+extern crate console_error_panic_hook;
+
#[path = "../boilerplate.rs"]
mod boilerplate;
mod game;
mod physics;
+#[cfg(not(target_arch = "wasm32"))]
fn main() {
use std::env;
-
- let (harness, settings) = boilerplate::Harness::init(boilerplate::HarnessOptions {
- title: "road",
- uses_level: true,
- });
+ env_logger::init();
info!("Parsing command line");
let args: Vec<_> = env::args().collect();
@@ -30,6 +33,11 @@ fn main() {
return;
}
+ let (harness, settings) = boilerplate::Harness::init(boilerplate::HarnessOptions {
+ title: "road",
+ uses_level: true,
+ });
+
let game = game::Game::new(
&settings,
harness.color_format,
@@ -41,3 +49,303 @@ fn main() {
harness.main_loop(game);
}
+
+#[cfg(target_arch = "wasm32")]
+fn main() {
+ use env_logger::{Builder};
+ use log::{LevelFilter};
+
+ console_error_panic_hook::set_once();
+
+ Builder::new()
+ .format(|_buf, record| {
+ let message = format!("{}: {}", record.level(), record.args());
+ log(&message);
+ Ok(())
+ })
+ .filter(None, LevelFilter::Info)
+ .init();
+
+ create_fs();
+
+ async fn run() {
+ let (harness, settings) = boilerplate::Harness::init_async(boilerplate::HarnessOptions {
+ title: "road",
+ uses_level: true,
+ }).await;
+
+ let game = game::Game::new(
+ &settings,
+ harness.extent,
+ &harness.device,
+ &harness.queue,
+ &harness.downlevel_caps,
+ );
+
+ harness.main_loop(game);
+ }
+
+ wasm_bindgen_futures::spawn_local(run());
+}
+
+#[cfg(target_arch = "wasm32")]
+#[wasm_bindgen]
+extern "C" {
+ #[wasm_bindgen(js_namespace = console, js_name = log)]
+ fn log(a: &str);
+}
+
+#[cfg(target_arch = "wasm32")]
+fn create_file(file: &str, buf: &[u8]) {
+ use std::{fs::File, io::Write};
+
+ info!("Creating file {}", file);
+ File::create(file).expect(&format!("Unable to create {}", file))
+ .write(buf)
+ .expect(&format!("Unable to write in {}", file));
+}
+
+#[cfg(target_arch = "wasm32")]
+fn create_fs() {
+ info!("Creating fs");
+
+ // vangers-rs resources
+ create_file("res/shader/quat.inc.glsl", include_bytes!("../../res/shader/quat.inc.glsl"));
+ create_file("res/shader/debug.wgsl", include_bytes!("../../res/shader/debug.wgsl"));
+ create_file("res/shader/object.wgsl", include_bytes!("../../res/shader/object.wgsl"));
+ create_file("res/shader/encode.inc.glsl", include_bytes!("../../res/shader/encode.inc.glsl"));
+ create_file("res/shader/quat.inc.wgsl", include_bytes!("../../res/shader/quat.inc.wgsl"));
+ create_file("res/shader/globals.inc.wgsl", include_bytes!("../../res/shader/globals.inc.wgsl"));
+ create_file("res/shader/downsample.glsl", include_bytes!("../../res/shader/downsample.glsl"));
+ create_file("res/shader/body.inc.wgsl", include_bytes!("../../res/shader/body.inc.wgsl"));
+ create_file("res/shader/shape.inc.glsl", include_bytes!("../../res/shader/shape.inc.glsl"));
+ create_file("res/shader/surface.inc.wgsl", include_bytes!("../../res/shader/surface.inc.wgsl"));
+ create_file("res/shader/body.inc.glsl", include_bytes!("../../res/shader/body.inc.glsl"));
+ create_file("res/shader/globals.inc.glsl", include_bytes!("../../res/shader/globals.inc.glsl"));
+ create_file("res/shader/debug_shape.glsl", include_bytes!("../../res/shader/debug_shape.glsl"));
+ create_file("res/shader/shadow.inc.wgsl", include_bytes!("../../res/shader/shadow.inc.wgsl"));
+ create_file("res/shader/surface.inc.glsl", include_bytes!("../../res/shader/surface.inc.glsl"));
+ create_file("res/shader/color.inc.wgsl", include_bytes!("../../res/shader/color.inc.wgsl"));
+ create_file("res/shader/terrain/locals.inc.wgsl", include_bytes!("../../res/shader/terrain/locals.inc.wgsl"));
+ create_file("res/shader/terrain/ray.wgsl", include_bytes!("../../res/shader/terrain/ray.wgsl"));
+ create_file("res/shader/terrain/paint.wgsl", include_bytes!("../../res/shader/terrain/paint.wgsl"));
+ create_file("res/shader/terrain/mip.wgsl", include_bytes!("../../res/shader/terrain/mip.wgsl"));
+ create_file("res/shader/terrain/scatter.wgsl", include_bytes!("../../res/shader/terrain/scatter.wgsl"));
+ create_file("res/shader/terrain/slice.wgsl", include_bytes!("../../res/shader/terrain/slice.wgsl"));
+ create_file("res/shader/physics/collision.inc.glsl", include_bytes!("../../res/shader/physics/collision.inc.glsl"));
+ create_file("res/shader/physics/collision_clear.glsl", include_bytes!("../../res/shader/physics/collision_clear.glsl"));
+ create_file("res/shader/physics/body_step.glsl", include_bytes!("../../res/shader/physics/body_step.glsl"));
+ create_file("res/shader/physics/collision_add.glsl", include_bytes!("../../res/shader/physics/collision_add.glsl"));
+ create_file("res/shader/physics/body_push.glsl", include_bytes!("../../res/shader/physics/body_push.glsl"));
+ create_file("res/shader/physics/pulse.inc.glsl", include_bytes!("../../res/shader/physics/pulse.inc.glsl"));
+ create_file("res/shader/physics/body_gather.glsl", include_bytes!("../../res/shader/physics/body_gather.glsl"));
+
+ // vangers resouces
+ create_file("config/settings.ron", include_bytes!("../../res_linux/config/settings.ron"));
+ // create_file("data/device.lst", include_bytes!("../../res_linux/data/device.lst"));
+ // create_file("data/jungle.lst", include_bytes!("../../res_linux/data/jungle.lst"));
+ // create_file("data/vangers.bmp", include_bytes!("../../res_linux/data/vangers.bmp"));
+ // create_file("data/logfile.txt", include_bytes!("../../res_linux/data/logfile.txt"));
+ // create_file("data/vangers.prm", include_bytes!("../../res_linux/data/vangers.prm"));
+ // create_file("data/vangers_mac.bmp", include_bytes!("../../res_linux/data/vangers_mac.bmp"));
+ // create_file("data/tmp_f1.txt", include_bytes!("../../res_linux/data/tmp_f1.txt"));
+ // create_file("data/item.prm", include_bytes!("../../res_linux/data/item.prm"));
+ // create_file("data/passages.prm", include_bytes!("../../res_linux/data/passages.prm"));
+ // create_file("data/diagen.text", include_bytes!("../../res_linux/data/diagen.text"));
+ // create_file("data/options.dat", include_bytes!("../../res_linux/data/options.dat"));
+ // create_file("data/hd_background.bmp", include_bytes!("../../res_linux/data/hd_background.bmp"));
+ // create_file("data/diagen_eng.text", include_bytes!("../../res_linux/data/diagen_eng.text"));
+ // create_file("data/price.prm", include_bytes!("../../res_linux/data/price.prm"));
+ // create_file("data/worlds.prm", include_bytes!("../../res_linux/data/worlds.prm"));
+ create_file("data/escaves.prm", include_bytes!("../../res_linux/data/escaves.prm"));
+ // create_file("data/tabutask.prm", include_bytes!("../../res_linux/data/tabutask.prm"));
+ // create_file("data/zfont.fnt", include_bytes!("../../res_linux/data/zfont.fnt"));
+ // create_file("data/road.fnt", include_bytes!("../../res_linux/data/road.fnt"));
+ // create_file("data/controls.dat", include_bytes!("../../res_linux/data/controls.dat"));
+ create_file("data/common.prm", include_bytes!("../../res_linux/data/common.prm"));
+ // create_file("data/vangers.ico", include_bytes!("../../res_linux/data/vangers.ico"));
+ create_file("data/bunches.prm", include_bytes!("../../res_linux/data/bunches.prm"));
+ // create_file("data/spots.prm", include_bytes!("../../res_linux/data/spots.prm"));
+ create_file("data/game.lst", include_bytes!("../../res_linux/data/game.lst"));
+ create_file("data/car.prm", include_bytes!("../../res_linux/data/car.prm"));
+ create_file("data/wrlds.dat", include_bytes!("../../res_linux/data/wrlds.dat"));
+
+ create_file("data/thechain/threall/world.ini", include_bytes!("../../res_linux/data/thechain/threall/world.ini"));
+ create_file("data/thechain/threall/output.vmc", include_bytes!("../../res_linux/data/thechain/threall/output.vmc"));
+ create_file("data/thechain/threall/output.vpr", include_bytes!("../../res_linux/data/thechain/threall/output.vpr"));
+ create_file("data/thechain/threall/harmony.pal", include_bytes!("../../res_linux/data/thechain/threall/harmony.pal"));
+
+ // create_file("data/resource/bml/fireball.bml", include_bytes!("../../res_linux/data/resource/bml/fireball.bml"));
+ // create_file("data/resource/bml/sign.fnt", include_bytes!("../../res_linux/data/resource/bml/sign.fnt"));
+ // create_file("data/resource/bml/explos.bml", include_bytes!("../../res_linux/data/resource/bml/explos.bml"));
+ // create_file("data/resource/bml/dust.bml", include_bytes!("../../res_linux/data/resource/bml/dust.bml"));
+ // create_file("data/resource/bml/compas.bml", include_bytes!("../../res_linux/data/resource/bml/compas.bml"));
+ // create_file("data/resource/bml/mole.bml", include_bytes!("../../res_linux/data/resource/bml/mole.bml"));
+ // create_file("data/resource/bml/tnt.bml", include_bytes!("../../res_linux/data/resource/bml/tnt.bml"));
+ // create_file("data/resource/mss/16x16.mss", include_bytes!("../../res_linux/data/resource/mss/16x16.mss"));
+ // create_file("data/resource/mss/128x128.mss", include_bytes!("../../res_linux/data/resource/mss/128x128.mss"));
+ // create_file("data/resource/mss/64x64st.mss", include_bytes!("../../res_linux/data/resource/mss/64x64st.mss"));
+ // create_file("data/resource/mss/tpmss.mss", include_bytes!("../../res_linux/data/resource/mss/tpmss.mss"));
+ // create_file("data/resource/mss/064x064.mss", include_bytes!("../../res_linux/data/resource/mss/064x064.mss"));
+ // create_file("data/resource/mss/out.mss", include_bytes!("../../res_linux/data/resource/mss/out.mss"));
+ // create_file("data/resource/mss/016x016.mss", include_bytes!("../../res_linux/data/resource/mss/016x016.mss"));
+ // create_file("data/resource/mss/rotor.mss", include_bytes!("../../res_linux/data/resource/mss/rotor.mss"));
+ // create_file("data/resource/mlvot/fgrib0.vot", include_bytes!("../../res_linux/data/resource/mlvot/fgrib0.vot"));
+ // create_file("data/resource/mlvot/bugtrl4.vot", include_bytes!("../../res_linux/data/resource/mlvot/bugtrl4.vot"));
+ // create_file("data/resource/mlvot/bugtrl3.vot", include_bytes!("../../res_linux/data/resource/mlvot/bugtrl3.vot"));
+ // create_file("data/resource/mlvot/fgrib1.vot", include_bytes!("../../res_linux/data/resource/mlvot/fgrib1.vot"));
+ // create_file("data/resource/mlvot/bugtrl6.vot", include_bytes!("../../res_linux/data/resource/mlvot/bugtrl6.vot"));
+ // create_file("data/resource/mlvot/bugtrl7.vot", include_bytes!("../../res_linux/data/resource/mlvot/bugtrl7.vot"));
+ // create_file("data/resource/mlvot/ngrib1.vot", include_bytes!("../../res_linux/data/resource/mlvot/ngrib1.vot"));
+ // create_file("data/resource/mlvot/exptrl2.vot", include_bytes!("../../res_linux/data/resource/mlvot/exptrl2.vot"));
+ // create_file("data/resource/mlvot/exptrl1.vot", include_bytes!("../../res_linux/data/resource/mlvot/exptrl1.vot"));
+ // create_file("data/resource/mlvot/bugtrl0.vot", include_bytes!("../../res_linux/data/resource/mlvot/bugtrl0.vot"));
+ // create_file("data/resource/mlvot/ggrib0.vot", include_bytes!("../../res_linux/data/resource/mlvot/ggrib0.vot"));
+ // create_file("data/resource/mlvot/exptrl0.vot", include_bytes!("../../res_linux/data/resource/mlvot/exptrl0.vot"));
+ // create_file("data/resource/mlvot/bugtrl1.vot", include_bytes!("../../res_linux/data/resource/mlvot/bugtrl1.vot"));
+ // create_file("data/resource/mlvot/bugtrl2.vot", include_bytes!("../../res_linux/data/resource/mlvot/bugtrl2.vot"));
+ // create_file("data/resource/mlvot/bugtrl5.vot", include_bytes!("../../res_linux/data/resource/mlvot/bugtrl5.vot"));
+ // create_file("data/resource/mlvot/ggrib1.vot", include_bytes!("../../res_linux/data/resource/mlvot/ggrib1.vot"));
+ // create_file("data/resource/mlvot/exptrl3.vot", include_bytes!("../../res_linux/data/resource/mlvot/exptrl3.vot"));
+ create_file("data/resource/pal/necross.pal", include_bytes!("../../res_linux/data/resource/pal/necross.pal"));
+ create_file("data/resource/pal/necross1.pal", include_bytes!("../../res_linux/data/resource/pal/necross1.pal"));
+ create_file("data/resource/pal/fostral2.pal", include_bytes!("../../res_linux/data/resource/pal/fostral2.pal"));
+ create_file("data/resource/pal/xplo.pal", include_bytes!("../../res_linux/data/resource/pal/xplo.pal"));
+ create_file("data/resource/pal/necross2.pal", include_bytes!("../../res_linux/data/resource/pal/necross2.pal"));
+ create_file("data/resource/pal/fostral1.pal", include_bytes!("../../res_linux/data/resource/pal/fostral1.pal"));
+ create_file("data/resource/pal/glorx1.pal", include_bytes!("../../res_linux/data/resource/pal/glorx1.pal"));
+ create_file("data/resource/pal/glorx2.pal", include_bytes!("../../res_linux/data/resource/pal/glorx2.pal"));
+ create_file("data/resource/pal/fostral.pal", include_bytes!("../../res_linux/data/resource/pal/fostral.pal"));
+ create_file("data/resource/pal/objects.pal", include_bytes!("../../res_linux/data/resource/pal/objects.pal"));
+ create_file("data/resource/pal/glorx.pal", include_bytes!("../../res_linux/data/resource/pal/glorx.pal"));
+ // create_file("data/resource/crypts/crypt9.vlc", include_bytes!("../../res_linux/data/resource/crypts/crypt9.vlc"));
+ // create_file("data/resource/crypts/crypt3.vlc", include_bytes!("../../res_linux/data/resource/crypts/crypt3.vlc"));
+ // create_file("data/resource/crypts/crypt4.vlc", include_bytes!("../../res_linux/data/resource/crypts/crypt4.vlc"));
+ // create_file("data/resource/crypts/crypt10.vlc", include_bytes!("../../res_linux/data/resource/crypts/crypt10.vlc"));
+ // create_file("data/resource/crypts/crypt1.vlc", include_bytes!("../../res_linux/data/resource/crypts/crypt1.vlc"));
+ // create_file("data/resource/crypts/crypt8.vlc", include_bytes!("../../res_linux/data/resource/crypts/crypt8.vlc"));
+ // create_file("data/resource/crypts/crypt7.vlc", include_bytes!("../../res_linux/data/resource/crypts/crypt7.vlc"));
+ // create_file("data/resource/crypts/crypt6.vlc", include_bytes!("../../res_linux/data/resource/crypts/crypt6.vlc"));
+ // create_file("data/resource/crypts/skyfarmer.vlc", include_bytes!("../../res_linux/data/resource/crypts/skyfarmer.vlc"));
+ // create_file("data/resource/crypts/crypt2.vlc", include_bytes!("../../res_linux/data/resource/crypts/crypt2.vlc"));
+ // create_file("data/resource/crypts/crypt0.vlc", include_bytes!("../../res_linux/data/resource/crypts/crypt0.vlc"));
+ // create_file("data/resource/crypts/crypt5.vlc", include_bytes!("../../res_linux/data/resource/crypts/crypt5.vlc"));
+ // create_file("data/resource/m3d/unique/u4a.m3d", include_bytes!("../../res_linux/data/resource/m3d/unique/u4a.m3d"));
+ // create_file("data/resource/m3d/unique/u2b.m3d", include_bytes!("../../res_linux/data/resource/m3d/unique/u2b.m3d"));
+ // create_file("data/resource/m3d/unique/u1b.m3d", include_bytes!("../../res_linux/data/resource/m3d/unique/u1b.m3d"));
+ // create_file("data/resource/m3d/unique/u2a.m3d", include_bytes!("../../res_linux/data/resource/m3d/unique/u2a.m3d"));
+ // create_file("data/resource/m3d/unique/u1a.m3d", include_bytes!("../../res_linux/data/resource/m3d/unique/u1a.m3d"));
+ // create_file("data/resource/m3d/unique/u3b.m3d", include_bytes!("../../res_linux/data/resource/m3d/unique/u3b.m3d"));
+ // create_file("data/resource/m3d/unique/u3a.m3d", include_bytes!("../../res_linux/data/resource/m3d/unique/u3a.m3d"));
+ // create_file("data/resource/m3d/unique/u4b.m3d", include_bytes!("../../res_linux/data/resource/m3d/unique/u4b.m3d"));
+ // create_file("data/resource/m3d/unique/u5a.m3d", include_bytes!("../../res_linux/data/resource/m3d/unique/u5a.m3d"));
+ // create_file("data/resource/m3d/unique/u5b.m3d", include_bytes!("../../res_linux/data/resource/m3d/unique/u5b.m3d"));
+ // create_file("data/resource/m3d/items/i6.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i6.m3d"));
+ // create_file("data/resource/m3d/items/i23.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i23.m3d"));
+ // create_file("data/resource/m3d/items/i34.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i34.m3d"));
+ // create_file("data/resource/m3d/items/i37.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i37.m3d"));
+ // create_file("data/resource/m3d/items/i39.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i39.m3d"));
+ // create_file("data/resource/m3d/items/i8.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i8.m3d"));
+ // create_file("data/resource/m3d/items/i2.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i2.m3d"));
+ // create_file("data/resource/m3d/items/i18.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i18.m3d"));
+ // create_file("data/resource/m3d/items/i11.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i11.m3d"));
+ // create_file("data/resource/m3d/items/i1.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i1.m3d"));
+ // create_file("data/resource/m3d/items/i7.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i7.m3d"));
+ // create_file("data/resource/m3d/items/i31.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i31.m3d"));
+ // create_file("data/resource/m3d/items/i30.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i30.m3d"));
+ // create_file("data/resource/m3d/items/i27.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i27.m3d"));
+ // create_file("data/resource/m3d/items/i5.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i5.m3d"));
+ // create_file("data/resource/m3d/items/i19.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i19.m3d"));
+ // create_file("data/resource/m3d/items/i25.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i25.m3d"));
+ // create_file("data/resource/m3d/items/i22.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i22.m3d"));
+ // create_file("data/resource/m3d/items/i40.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i40.m3d"));
+ // create_file("data/resource/m3d/items/i36.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i36.m3d"));
+ // create_file("data/resource/m3d/items/i26.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i26.m3d"));
+ // create_file("data/resource/m3d/items/i10.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i10.m3d"));
+ // create_file("data/resource/m3d/items/i29.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i29.m3d"));
+ // create_file("data/resource/m3d/items/i13.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i13.m3d"));
+ // create_file("data/resource/m3d/items/i33.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i33.m3d"));
+ // create_file("data/resource/m3d/items/i43.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i43.m3d"));
+ // create_file("data/resource/m3d/items/i42.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i42.m3d"));
+ // create_file("data/resource/m3d/items/i3.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i3.m3d"));
+ // create_file("data/resource/m3d/items/i17.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i17.m3d"));
+ // create_file("data/resource/m3d/items/i38.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i38.m3d"));
+ // create_file("data/resource/m3d/items/i21.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i21.m3d"));
+ // create_file("data/resource/m3d/items/i4.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i4.m3d"));
+ // create_file("data/resource/m3d/items/i28.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i28.m3d"));
+ // create_file("data/resource/m3d/items/i16.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i16.m3d"));
+ // create_file("data/resource/m3d/items/i32.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i32.m3d"));
+ // create_file("data/resource/m3d/items/i41.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i41.m3d"));
+ // create_file("data/resource/m3d/items/i14.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i14.m3d"));
+ // create_file("data/resource/m3d/items/i24.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i24.m3d"));
+ // create_file("data/resource/m3d/items/i20.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i20.m3d"));
+ // create_file("data/resource/m3d/items/i12.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i12.m3d"));
+ // create_file("data/resource/m3d/items/i35.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i35.m3d"));
+ // create_file("data/resource/m3d/items/i9.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i9.m3d"));
+ // create_file("data/resource/m3d/items/i15.m3d", include_bytes!("../../res_linux/data/resource/m3d/items/i15.m3d"));
+ // create_file("data/resource/m3d/fauna/f2.m3d", include_bytes!("../../res_linux/data/resource/m3d/fauna/f2.m3d"));
+ // create_file("data/resource/m3d/fauna/f1.m3d", include_bytes!("../../res_linux/data/resource/m3d/fauna/f1.m3d"));
+ // create_file("data/resource/m3d/weapon/w2h.m3d", include_bytes!("../../res_linux/data/resource/m3d/weapon/w2h.m3d"));
+ // create_file("data/resource/m3d/weapon/w5.m3d", include_bytes!("../../res_linux/data/resource/m3d/weapon/w5.m3d"));
+ // create_file("data/resource/m3d/weapon/w4.m3d", include_bytes!("../../res_linux/data/resource/m3d/weapon/w4.m3d"));
+ // create_file("data/resource/m3d/weapon/w6.m3d", include_bytes!("../../res_linux/data/resource/m3d/weapon/w6.m3d"));
+ // create_file("data/resource/m3d/weapon/w2l.m3d", include_bytes!("../../res_linux/data/resource/m3d/weapon/w2l.m3d"));
+ // create_file("data/resource/m3d/weapon/w1h.m3d", include_bytes!("../../res_linux/data/resource/m3d/weapon/w1h.m3d"));
+ // create_file("data/resource/m3d/weapon/w3l.m3d", include_bytes!("../../res_linux/data/resource/m3d/weapon/w3l.m3d"));
+ // create_file("data/resource/m3d/weapon/w1l.m3d", include_bytes!("../../res_linux/data/resource/m3d/weapon/w1l.m3d"));
+ // create_file("data/resource/m3d/weapon/w3h.m3d", include_bytes!("../../res_linux/data/resource/m3d/weapon/w3h.m3d"));
+ // create_file("data/resource/m3d/ammun/am1.m3d", include_bytes!("../../res_linux/data/resource/m3d/ammun/am1.m3d"));
+ // create_file("data/resource/m3d/ammun/am2.m3d", include_bytes!("../../res_linux/data/resource/m3d/ammun/am2.m3d"));
+ // create_file("data/resource/m3d/ammun/am3.m3d", include_bytes!("../../res_linux/data/resource/m3d/ammun/am3.m3d"));
+ // create_file("data/resource/m3d/animated/a2.a3d", include_bytes!("../../res_linux/data/resource/m3d/animated/a2.a3d"));
+ // create_file("data/resource/m3d/animated/a1.a3d", include_bytes!("../../res_linux/data/resource/m3d/animated/a1.a3d"));
+ create_file("data/resource/m3d/mechous/m13.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m13.m3d"));
+ create_file("data/resource/m3d/mechous/m10.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m10.m3d"));
+ create_file("data/resource/m3d/mechous/m5.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m5.prm"));
+ create_file("data/resource/m3d/mechous/m9.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m9.m3d"));
+ create_file("data/resource/m3d/mechous/u5.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/u5.prm"));
+ create_file("data/resource/m3d/mechous/m1.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m1.prm"));
+ create_file("data/resource/m3d/mechous/u3.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/u3.m3d"));
+ create_file("data/resource/m3d/mechous/m11.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m11.prm"));
+ create_file("data/resource/m3d/mechous/u2.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/u2.prm"));
+ create_file("data/resource/m3d/mechous/u1.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/u1.prm"));
+ create_file("data/resource/m3d/mechous/r2.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/r2.m3d"));
+ create_file("data/resource/m3d/mechous/r3.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/r3.m3d"));
+ create_file("data/resource/m3d/mechous/r4.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/r4.m3d"));
+ create_file("data/resource/m3d/mechous/m3.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m3.prm"));
+ create_file("data/resource/m3d/mechous/m14.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m14.m3d"));
+ create_file("data/resource/m3d/mechous/m9.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m9.prm"));
+ create_file("data/resource/m3d/mechous/m7.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m7.prm"));
+ create_file("data/resource/m3d/mechous/m10.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m10.prm"));
+ create_file("data/resource/m3d/mechous/default.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/default.prm"));
+ create_file("data/resource/m3d/mechous/r1.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/r1.m3d"));
+ create_file("data/resource/m3d/mechous/m13.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m13.prm"));
+ create_file("data/resource/m3d/mechous/m12.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m12.prm"));
+ create_file("data/resource/m3d/mechous/r4.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/r4.prm"));
+ create_file("data/resource/m3d/mechous/m11.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m11.m3d"));
+ create_file("data/resource/m3d/mechous/m2.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m2.prm"));
+ create_file("data/resource/m3d/mechous/m6.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m6.m3d"));
+ create_file("data/resource/m3d/mechous/m12.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m12.m3d"));
+ create_file("data/resource/m3d/mechous/u2.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/u2.m3d"));
+ create_file("data/resource/m3d/mechous/m1.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m1.m3d"));
+ create_file("data/resource/m3d/mechous/m4.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m4.prm"));
+ create_file("data/resource/m3d/mechous/m8.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m8.prm"));
+ create_file("data/resource/m3d/mechous/u1.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/u1.m3d"));
+ create_file("data/resource/m3d/mechous/m4.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m4.m3d"));
+ create_file("data/resource/m3d/mechous/m14.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m14.prm"));
+ create_file("data/resource/m3d/mechous/r5.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/r5.m3d"));
+ create_file("data/resource/m3d/mechous/r3.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/r3.prm"));
+ create_file("data/resource/m3d/mechous/m3.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m3.m3d"));
+ create_file("data/resource/m3d/mechous/r5.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/r5.prm"));
+ create_file("data/resource/m3d/mechous/u4.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/u4.m3d"));
+ create_file("data/resource/m3d/mechous/u4.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/u4.prm"));
+ create_file("data/resource/m3d/mechous/m6.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/m6.prm"));
+ create_file("data/resource/m3d/mechous/r2.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/r2.prm"));
+ create_file("data/resource/m3d/mechous/r1.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/r1.prm"));
+ create_file("data/resource/m3d/mechous/m5.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m5.m3d"));
+ create_file("data/resource/m3d/mechous/m7.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m7.m3d"));
+ create_file("data/resource/m3d/mechous/m8.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m8.m3d"));
+ create_file("data/resource/m3d/mechous/u5.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/u5.m3d"));
+ create_file("data/resource/m3d/mechous/m2.m3d", include_bytes!("../../res_linux/data/resource/m3d/mechous/m2.m3d"));
+ create_file("data/resource/m3d/mechous/u3.prm", include_bytes!("../../res_linux/data/resource/m3d/mechous/u3.prm"));
+}
diff --git a/gen.py b/gen.py
new file mode 100644
index 00000000..0674be9c
--- /dev/null
+++ b/gen.py
@@ -0,0 +1,22 @@
+import os
+import sys
+
+print("\t// vangers-rs resources")
+for root, subdirs, files in os.walk("res"):
+ for file in files:
+ path = os.path.join(root, file)
+ print("\tcreate_file(\"" + path + "\", include_bytes!(\"../../" + path + "\"));");
+
+print("\n\t// vangers resouces")
+for root, subdirs, files in os.walk("res_linux"):
+ for file in files:
+ path = os.path.join(root, file)
+ if ("/video/" in path or ".git/" in path or
+ "/sound/" in path or "/actint/" in path or
+ "/iscreen/" in path or "/music/" in path or
+ "/savegame/" in path or "/shader/" in path or
+ ".wgsl" in path or
+ ("/thechain/" in path and not("/threall/" in path))):
+ continue
+ print("\tcreate_file(\"" + path[len("res_linux/"):] + "\", include_bytes!(\"../../" + path + "\"));");
+
diff --git a/html5/index.html b/html5/index.html
new file mode 100644
index 00000000..f0eae37e
--- /dev/null
+++ b/html5/index.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/config/car.rs b/src/config/car.rs
index 3670ab78..97215d45 100644
--- a/src/config/car.rs
+++ b/src/config/car.rs
@@ -177,7 +177,13 @@ pub fn load_registry(
let (name, data) = fi.next_entry();
let mi = ®.model_infos[name];
let mut prm_path = settings.data_path.join(&mi.path).with_extension("prm");
+
+ #[cfg(target_arch = "wasm32")]
+ let is_default = false;
+
+ #[cfg(not(target_arch = "wasm32"))]
let is_default = !prm_path.exists();
+
if is_default {
warn!("Vehicle {} doesn't have parameters, using defaults", name);
prm_path.set_file_name("default");
diff --git a/src/config/settings.rs b/src/config/settings.rs
index 47730ad5..77c0c2cc 100644
--- a/src/config/settings.rs
+++ b/src/config/settings.rs
@@ -81,7 +81,7 @@ pub enum Backend {
impl Backend {
pub fn to_wgpu(&self) -> wgpu::Backends {
match *self {
- Backend::Auto => wgpu::Backends::PRIMARY,
+ Backend::Auto => wgpu::Backends::all(),
Backend::Metal => wgpu::Backends::METAL,
Backend::Vulkan => wgpu::Backends::VULKAN,
Backend::DX12 => wgpu::Backends::DX12,
@@ -194,6 +194,12 @@ impl Settings {
.unwrap_or_else(|_| panic!("Unable to open game file: {}", path))
}
+ #[cfg(target_arch = "wasm32")]
+ pub fn check_path(&self, _path: &str) -> bool {
+ true
+ }
+
+ #[cfg(not(target_arch = "wasm32"))]
pub fn check_path(&self, path: &str) -> bool {
self.data_path.join(path).exists()
}
diff --git a/src/level/config.rs b/src/level/config.rs
index 4e3d0c3d..ced23054 100644
--- a/src/level/config.rs
+++ b/src/level/config.rs
@@ -34,8 +34,8 @@ pub struct LevelConfig {
impl LevelConfig {
pub fn load(ini_path: &Path) -> Self {
- let ini = Ini::load_from_file(ini_path).unwrap_or_else(|_| {
- panic!("Unable to read the level's INI description: {:?}", ini_path)
+ let ini = Ini::load_from_file(ini_path).unwrap_or_else(|error| {
+ panic!("Unable to read the level's INI description: {:?} {:?}", ini_path, error)
});
let global = &ini["Global Parameters"];
let storage = &ini["Storage"];
diff --git a/src/level/mod.rs b/src/level/mod.rs
index 2ea5e72e..e942b61b 100644
--- a/src/level/mod.rs
+++ b/src/level/mod.rs
@@ -222,8 +222,12 @@ pub fn load_flood(config: &LevelConfig) -> Vec {
let flood_offset =
(2 * 4 + (1 + 4 + 4) * 4 + 2 * net_size + 2 * geo_pow * 4 + 2 * flood_size * geo_pow * 4)
as u64;
- let expected_file_size = flood_offset + (flood_size * 4) as u64;
- assert_eq!(vpr_file.metadata().unwrap().len(), expected_file_size,);
+
+ #[cfg(not(target_arch = "wasm32"))] {
+ let expected_file_size = flood_offset + (flood_size * 4) as u64;
+ assert_eq!(vpr_file.metadata().unwrap().len(), expected_file_size,);
+ }
+
let mut vpr = BufReader::new(vpr_file);
vpr.seek(SeekFrom::Start(flood_offset)).unwrap();
(0..flood_size)
@@ -324,6 +328,7 @@ impl LevelData {
}
pub fn load_vmc(path: &Path, size: (i32, i32)) -> LevelData {
+ #[cfg(not(target_arch = "wasm32"))]
use rayon::prelude::*;
use splay::Splay;
@@ -352,14 +357,20 @@ pub fn load_vmc(path: &Path, size: (i32, i32)) -> LevelData {
(splay, st_table, sz_table)
};
- level
+ let mut level_iter = level
.height
.chunks_mut(size.0 as _)
.zip(level.meta.chunks_mut(size.0 as _))
.zip(st_table.iter().zip(&sz_table))
- .collect::>()
- .par_chunks_mut(64)
- .for_each(|source_group| {
+ .collect::>();
+
+ #[cfg(not(target_arch = "wasm32"))]
+ let level_iter = level_iter.par_chunks_mut(64);
+
+ #[cfg(target_arch = "wasm32")]
+ let level_iter = level_iter.chunks_mut(64);
+
+ level_iter.for_each(|source_group| {
//Note: a separate file per group is required
let mut vmc = File::open(path).unwrap();
let data_size: i16 = source_group
diff --git a/src/render/mod.rs b/src/render/mod.rs
index 36bd546d..33a56db4 100644
--- a/src/render/mod.rs
+++ b/src/render/mod.rs
@@ -105,7 +105,7 @@ impl ShapeVertexDesc {
pub fn make_shader_code(name: &str) -> Result {
let base_path = PathBuf::from("res").join("shader");
let path = base_path.join(name).with_extension("wgsl");
- if !path.is_file() {
+ if !is_file(&path) {
panic!("Shader not found: {:?}", path);
}
@@ -172,7 +172,7 @@ impl Shaders {
let base_path = PathBuf::from("res").join("shader");
let path = base_path.join(name).with_extension("glsl");
- if !path.is_file() {
+ if !is_file(&path) {
panic!("Shader not found: {:?}", path);
}
@@ -263,7 +263,7 @@ impl Shaders {
let base_path = PathBuf::from("res").join("shader");
let path = base_path.join(name).with_extension("glsl");
- if !path.is_file() {
+ if !is_file(&path) {
panic!("Shader not found: {:?}", path);
}
@@ -737,3 +737,13 @@ impl Render {
self.terrain_data.out_color.clone()
}*/
}
+
+#[cfg(target_arch = "wasm32")]
+fn is_file(_path: &PathBuf) -> bool {
+ true
+}
+
+#[cfg(not(target_arch = "wasm32"))]
+fn is_file(path: &PathBuf) -> bool {
+ path.is_file()
+}