1
0
Fork 0

[WASM] Fix build error

This commit is contained in:
Florian RICHER 2022-06-22 20:24:40 +02:00
parent 94b59568b1
commit 1feca362a7
3 changed files with 8 additions and 11 deletions

View file

@ -9,7 +9,7 @@ use winit::{
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;
use crate::render::{DefaultState, Renderer, State};
use crate::render::{DefaultState, Renderer};
mod camera;
mod model;
@ -167,7 +167,7 @@ pub async fn run() {
}
let mut renderer = Arc::from(Renderer::new(&window).await);
let default_state = Box::from(DefaultState::new(renderer.deref()));
let default_state = Box::from(DefaultState::new(renderer.deref()).await);
Arc::get_mut(&mut renderer)
.unwrap()
.set_state(Some(default_state));

View file

@ -34,10 +34,8 @@ pub struct DefaultState {
pipelines: render::Pipelines,
}
impl super::State for DefaultState {
fn new(renderer: &Renderer) -> Self
where
Self: Sized,
impl DefaultState {
pub async fn new(renderer: &Renderer) -> Self
{
let global_bind_layout = render::GlobalBindLayout::new(&renderer.device);
let pipelines =
@ -119,12 +117,12 @@ impl super::State for DefaultState {
label: Some("camera_bind_group"),
});
let obj_model = async_std::task::block_on(resources::load_model(
let obj_model = resources::load_model(
"cube.obj",
&renderer.device,
&renderer.queue,
global_bind_layout.get_texture_bind_layout(),
)).unwrap();
).await.unwrap();
let light_uniform = LightUniform {
position: [2.0, 2.0, 2.0],
@ -208,7 +206,9 @@ impl super::State for DefaultState {
pipelines,
}
}
}
impl super::State for DefaultState {
fn resize(
&mut self,
device: &wgpu::Device,

View file

@ -9,9 +9,6 @@ use wgpu::{CommandEncoder, Queue, TextureView};
use winit::event::Event;
pub trait State {
fn new(renderer: &Renderer) -> Self
where
Self: Sized;
fn resize(
&mut self,
device: &wgpu::Device,