fix key_up bug in ludus.js
This commit is contained in:
parent
fc81f1149d
commit
dc16420545
|
@ -85,7 +85,7 @@ function io_poller () {
|
|||
outbox = []
|
||||
}
|
||||
if (ready && running) {
|
||||
if (keys_down.size > 0) bundle_keys()
|
||||
bundle_keys()
|
||||
worker.postMessage(outbox)
|
||||
outbox = []
|
||||
}
|
||||
|
|
BIN
pkg/rudus_bg.wasm
(Stored with Git LFS)
BIN
pkg/rudus_bg.wasm
(Stored with Git LFS)
Binary file not shown.
|
@ -18,7 +18,7 @@ export function io (out) {
|
|||
resolve(JSON.stringify(e.data))
|
||||
}
|
||||
// cancel the response if it takes too long
|
||||
setTimeout(() => reject("io took too long"), 1000)
|
||||
setTimeout(() => reject(`io took too long to respond to ${out}`), 1000)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -86,14 +86,14 @@ pub async fn do_io (msgs: Vec<MsgOut>) -> Vec<MsgIn> {
|
|||
let inbox = match inbox {
|
||||
Ok(msgs) => msgs,
|
||||
Err(errs) => {
|
||||
console_log!("error receiving messages in io; {:?}", errs);
|
||||
// console_log!("error receiving messages in io; {:?}", errs);
|
||||
return vec![];
|
||||
}
|
||||
};
|
||||
let inbox = inbox.as_string().expect("response should be a string");
|
||||
let inbox: Vec<MsgIn> = serde_json::from_str(inbox.as_str()).expect("response from js should be valid");
|
||||
if !inbox.is_empty() {
|
||||
console_log!("ludus received messages");
|
||||
// console_log!("ludus received messages");
|
||||
for msg in inbox.iter() {
|
||||
console_log!("{}", msg);
|
||||
}
|
||||
|
|
|
@ -472,6 +472,7 @@ impl World {
|
|||
}
|
||||
|
||||
fn register_keys(&mut self, keys: Value) {
|
||||
// console_log!("New keys: {keys}");
|
||||
let keys_down_rc = self.buffers.keys_down();
|
||||
keys_down_rc.replace(keys);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user