Fix WASM build

This commit is contained in:
Pascal Engélibert 2022-08-24 11:31:17 +02:00
commit ce37ddd0bd
7 changed files with 38 additions and 203 deletions

View file

@ -1,23 +1,25 @@
// https://github.com/WeirdConstructor/HexoDSP/blob/master/examples/cpal_demo_node_api.rs
use crate::game::AudioMsg;
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use crossbeam_channel::Receiver;
use hexodsp::{matrix_repr::MatrixRepr, *};
use std::io::Read;
use ticktock::Clock;
pub enum AudioMsg {
Color([f32; 3]),
Jump,
}
pub fn setup(event_channel: Receiver<AudioMsg>) {
let mut buf = String::new();
std::fs::File::open("assets/init.hxy")
.unwrap()
.read_to_string(&mut buf)
.unwrap();
let matrix_repr: MatrixRepr = MatrixRepr::deserialize(&buf).unwrap();
#[cfg(not(target_arch = "wasm32"))]
let matrix_repr: MatrixRepr = {
let mut buf = String::new();
std::fs::File::open("assets/init.hxy")
.unwrap()
.read_to_string(&mut buf)
.unwrap();
MatrixRepr::deserialize(&buf).unwrap()
};
#[cfg(target_arch = "wasm32")]
let matrix_repr: MatrixRepr = MatrixRepr::deserialize(include_str!("../assets/init.hxy")).unwrap();
let (node_conf, node_exec) = new_node_engine();