diff --git a/Cargo.lock b/Cargo.lock index 7b6b6d2..3c880c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -264,7 +264,6 @@ dependencies = [ "histogram", "image", "indoc", - "instant", "log", "nanorand", "notify", @@ -280,6 +279,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "web-time", "webbrowser", "wgpu", "wgpu-profiler", @@ -1398,15 +1398,6 @@ dependencies = [ "libc", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - [[package]] name = "ipnet" version = "2.9.0" diff --git a/Cargo.toml b/Cargo.toml index cd157e3..b32aae4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ rend3-routine = { version = "^0.3.0",path = "rend3/rend3-routine" } webbrowser = "0.8.2" bytemuck = { version = "1.14.0", features = ["derive"] } -instant = "0.1.12" +web-time = "0.2.3" nanorand = { version = "0.7", default-features = false, features = ["wyrand"] } pico-args = "0.5" wgpu-profiler = "0.15.0" diff --git a/assets/LinacLab.blend b/assets/LinacLab.blend index 172c333..2d83f6c 100644 --- a/assets/LinacLab.blend +++ b/assets/LinacLab.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fca61e769e17bc29e8ba98b72e7be5aa42a636c74a5dd722050b5be59698303b -size 6043220 +oid sha256:5892b5432e6ed5c3173488577b62764c2e3cd09f3962b2e3d71d74801ea2e939 +size 6050496 diff --git a/assets/LinacLab.blend1 b/assets/LinacLab.blend1 index 07651ef..172c333 100644 --- a/assets/LinacLab.blend1 +++ b/assets/LinacLab.blend1 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:845613f9d16a7ea31f3128bef558a69485f6805105c24fcdab24c3b6b2bf3820 +oid sha256:fca61e769e17bc29e8ba98b72e7be5aa42a636c74a5dd722050b5be59698303b size 6043220 diff --git a/rend3 b/rend3 index c5120fb..aac3925 160000 --- a/rend3 +++ b/rend3 @@ -1 +1 @@ -Subproject commit c5120fbfe599ac3cdbb3a54adeab07cd47cf3cca +Subproject commit aac39251ae7c53fda4d0a90387b31a3197ffa47f diff --git a/src/brainworms.rs b/src/brainworms.rs index b76314b..78dd669 100644 --- a/src/brainworms.rs +++ b/src/brainworms.rs @@ -6,7 +6,6 @@ use backstage::pyrotechnics::kinetic_narrative::{Gay, KineticEffect, KineticLabe use egui::{Color32, TextStyle, Visuals}; use frame_rate::FrameRate; use glam::{DVec2, Mat3A, Mat4, Vec3, Vec3A}; -use instant::{Duration, Instant}; use log::info; use nanorand::{RandomGen, Rng}; use pico_args::Arguments; @@ -36,11 +35,14 @@ use winit::{event::WindowEvent, event_loop::EventLoopWindowTarget}; use crate::backstage::plumbing::platform_scancodes::Scancodes; use crate::play::stage3d::{button_pressed, load_gltf, load_skybox, spawn}; +#[cfg(not(wasm_platform))] +use std::time; +#[cfg(wasm_platform)] +use web_time as time; #[cfg(target_arch = "wasm32")] use winit::keyboard::PhysicalKey::Code; #[cfg(not(target_arch = "wasm32"))] use winit::platform::scancode::PhysicalKeyExtScancode; - struct GameProgrammeData { egui_routine: rend3_egui::EguiRenderRoutine, egui_ctx: egui::Context, @@ -48,8 +50,8 @@ struct GameProgrammeData { _test_text: String, test_lines: String, random_line_effects: Vec, - _start_time: instant::Instant, - last_update: instant::Instant, + _start_time: time::Instant, + last_update: time::Instant, frame_rate: FrameRate, elapsed: f32, } @@ -113,8 +115,8 @@ struct GameProgrammeSettings { camera_yaw: f32, camera_location: Vec3A, previous_profiling_stats: Option>, - timestamp_last_second: Instant, - timestamp_last_frame: Instant, + timestamp_last_second: time::Instant, + timestamp_last_frame: time::Instant, frame_times: histogram::Histogram, last_mouse_delta: Option, @@ -238,8 +240,8 @@ impl GameProgrammeSettings { camera_yaw: camera_info[4], camera_location: Vec3A::new(camera_info[0], camera_info[1], camera_info[2]), previous_profiling_stats: None, - timestamp_last_second: Instant::now(), - timestamp_last_frame: Instant::now(), + timestamp_last_second: time::Instant::now(), + timestamp_last_frame: time::Instant::now(), frame_times: histogram::Histogram::new(), last_mouse_delta: None, @@ -404,8 +406,8 @@ impl rend3_framework::App for GameProgramme { //Images self.data = Some(GameProgrammeData { - _start_time: instant::Instant::now(), - last_update: instant::Instant::now(), + _start_time: time::Instant::now(), + last_update: time::Instant::now(), frame_rate: FrameRate::new(100), elapsed: 0.0, egui_routine, @@ -465,7 +467,7 @@ impl rend3_framework::App for GameProgramme { let last_frame_duration = data.last_update.elapsed().as_secs_f32(); data.elapsed += last_frame_duration; data.frame_rate.update(last_frame_duration); - data.last_update = instant::Instant::now(); + data.last_update = time::Instant::now(); let view = Mat4::from_euler( glam::EulerRot::XYZ, -self.settings.camera_pitch, @@ -581,7 +583,7 @@ impl rend3_framework::App for GameProgramme { } rend3_framework::Event::AboutToWait => { profiling::scope!("MainEventsCleared"); - let now = Instant::now(); + let now = time::Instant::now(); let delta_time = now - self.settings.timestamp_last_frame; self.settings @@ -590,7 +592,7 @@ impl rend3_framework::App for GameProgramme { .unwrap(); let elapsed_since_second = now - self.settings.timestamp_last_second; - if elapsed_since_second > Duration::from_secs(1) { + if elapsed_since_second > time::Duration::from_secs(1) { let count = self.settings.frame_times.entries(); println!( "{:0>5} frames over {:0>5.2}s. \ diff --git a/src/play/stage3d.rs b/src/play/stage3d.rs index a21ddf1..9d37a3a 100644 --- a/src/play/stage3d.rs +++ b/src/play/stage3d.rs @@ -5,7 +5,6 @@ use std::{ }; use glam::{DVec2, Mat3A, Mat4, UVec2, Vec3, Vec3A}; -use instant::Instant; use pico_args::Arguments; use rend3::{ types::{ @@ -18,6 +17,10 @@ use rend3::{ use rend3_framework::{lock, AssetPath, Mutex, UserResizeEvent}; use rend3_gltf::GltfSceneInstance; use rend3_routine::{base::BaseRenderGraph, pbr::NormalTextureYDirection, skybox::SkyboxRoutine}; +#[cfg(not(wasm_platform))] +use std::time; +#[cfg(wasm_platform)] +use web_time as time; use wgpu_profiler::GpuTimerScopeResult; #[cfg(target_arch = "wasm32")] use winit::keyboard::PhysicalKey::Code; @@ -79,7 +82,7 @@ pub(crate) async fn load_gltf( location: AssetPath<'_>, ) -> Option<(rend3_gltf::LoadedGltfScene, GltfSceneInstance)> { // profiling::scope!("loading gltf"); - let gltf_start = Instant::now(); + let gltf_start = time::Instant::now(); let is_default_scene = matches!(location, AssetPath::Internal(_)); let path = loader.get_asset_path(location); let path = Path::new(&*path); @@ -120,7 +123,7 @@ pub(crate) async fn load_gltf( }; let gltf_elapsed = gltf_start.elapsed(); - let resources_start = Instant::now(); + let resources_start = time::Instant::now(); let (scene, instance) = rend3_gltf::load_gltf(renderer, &gltf_data, settings, |uri| async { if let Some(base64) = rend3_gltf::try_load_base64(&uri) { Ok(base64) @@ -315,8 +318,8 @@ struct SceneViewer { camera_yaw: f32, camera_location: Vec3A, previous_profiling_stats: Option>, - timestamp_last_second: Instant, - timestamp_last_frame: Instant, + timestamp_last_second: time::Instant, + timestamp_last_frame: time::Instant, frame_times: histogram::Histogram, last_mouse_delta: Option, @@ -441,8 +444,8 @@ impl SceneViewer { camera_yaw: camera_info[4], camera_location: Vec3A::new(camera_info[0], camera_info[1], camera_info[2]), previous_profiling_stats: None, - timestamp_last_second: Instant::now(), - timestamp_last_frame: Instant::now(), + timestamp_last_second: time::Instant::now(), + timestamp_last_frame: time::Instant::now(), frame_times: histogram::Histogram::new(), last_mouse_delta: None, @@ -552,7 +555,7 @@ impl rend3_framework::App for SceneViewer { match event { Event::AboutToWait => { profiling::scope!("MainEventsCleared"); - let now = Instant::now(); + let now = time::Instant::now(); let delta_time = now - self.timestamp_last_frame; self.frame_times