Skip to content

Commit

Permalink
feat: laser disaper after 300 ms
Browse files Browse the repository at this point in the history
  • Loading branch information
owulveryck committed Nov 21, 2023
1 parent 69b6faa commit 12a81ac
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions client/workersHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,26 @@ eventWorker.postMessage({
wsURL: wsURL
});

let messageTimeout;

function clearLaser() {
// Function to call when no message is received for 300 ms
updateLaserPosition(-10,-10);
}
// Listen for updates from the worker
eventWorker.onmessage = (event) => {
// Reset the timer every time a message is received
clearTimeout(messageTimeout);
messageTimeout = setTimeout(clearLaser, 300);

// To hide the message (e.g., when you start drawing in WebGL again)
messageDiv.style.display = 'none';

const data = event.data;

switch (data.type) {
case 'clear':
updateLaserPosition(-10,-10);
//clearLaser();
break;
case 'update':
Expand Down

0 comments on commit 12a81ac

Please sign in to comment.