Spaces:
Runtime error
Runtime error
da03
commited on
Commit
·
f096c36
1
Parent(s):
e7ad005
- static/index.html +14 -3
static/index.html
CHANGED
|
@@ -135,7 +135,7 @@
|
|
| 135 |
<li>Use your keyboard to type within the simulated environment</li>
|
| 136 |
<li>Adjust sampling steps to control quality/speed tradeoff</li>
|
| 137 |
<li>Toggle "Use RNN" to switch between RNN and diffusion mode</li>
|
| 138 |
-
<li>Toggle "Auto Input" to enable automatic frame generation (starts after
|
| 139 |
</ul>
|
| 140 |
</div>
|
| 141 |
</div>
|
|
@@ -175,7 +175,7 @@
|
|
| 175 |
socket.onopen = function(event) {
|
| 176 |
console.log("WebSocket connection established");
|
| 177 |
isConnected = true;
|
| 178 |
-
reconnectAttempts = 0;
|
| 179 |
|
| 180 |
// Start auto-input mechanism
|
| 181 |
startAutoInput();
|
|
@@ -230,6 +230,10 @@
|
|
| 230 |
console.log("Simulation reset confirmed by server");
|
| 231 |
// Clear the canvas and reset to initial state
|
| 232 |
drawInitialCanvas();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
} else if (data.type === "rnn_updated") {
|
| 234 |
console.log(`USE_RNN setting updated to: ${data.use_rnn}`);
|
| 235 |
// Update the toggle to match the server state
|
|
@@ -289,6 +293,7 @@
|
|
| 289 |
const INITIAL_AUTO_INPUT_DELAY = 2000; // Start auto-input after 2 seconds of no user input
|
| 290 |
const AUTO_INPUT_INTERVAL = 500; // Send auto-input every 0.5 second once active
|
| 291 |
let autoInputEnabled = true; // Default to enabled
|
|
|
|
| 292 |
|
| 293 |
// Timeout countdown mechanism
|
| 294 |
let timeoutCountdownInterval = null;
|
|
@@ -306,7 +311,7 @@
|
|
| 306 |
autoInputInterval = setInterval(() => {
|
| 307 |
const currentTime = Date.now();
|
| 308 |
|
| 309 |
-
if (!autoInputEnabled || !lastSentPosition || !isConnected || socket.readyState !== WebSocket.OPEN) {
|
| 310 |
return;
|
| 311 |
}
|
| 312 |
|
|
@@ -467,6 +472,12 @@
|
|
| 467 |
lastSentPosition = { x, y };
|
| 468 |
lastSentTime = currentTime;
|
| 469 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
// Update last user input time for auto-input mechanism
|
| 471 |
updateLastUserInputTime();
|
| 472 |
|
|
|
|
| 135 |
<li>Use your keyboard to type within the simulated environment</li>
|
| 136 |
<li>Adjust sampling steps to control quality/speed tradeoff</li>
|
| 137 |
<li>Toggle "Use RNN" to switch between RNN and diffusion mode</li>
|
| 138 |
+
<li>Toggle "Auto Input" to enable automatic frame generation (starts after 2s idle once you move mouse inside canvas, then runs every 0.5s)</li>
|
| 139 |
</ul>
|
| 140 |
</div>
|
| 141 |
</div>
|
|
|
|
| 175 |
socket.onopen = function(event) {
|
| 176 |
console.log("WebSocket connection established");
|
| 177 |
isConnected = true;
|
| 178 |
+
//reconnectAttempts = 0;
|
| 179 |
|
| 180 |
// Start auto-input mechanism
|
| 181 |
startAutoInput();
|
|
|
|
| 230 |
console.log("Simulation reset confirmed by server");
|
| 231 |
// Clear the canvas and reset to initial state
|
| 232 |
drawInitialCanvas();
|
| 233 |
+
// Reset user interaction state
|
| 234 |
+
userHasInteracted = false;
|
| 235 |
+
lastSentPosition = null;
|
| 236 |
+
console.log("Reset user interaction state - waiting for user to move mouse inside canvas");
|
| 237 |
} else if (data.type === "rnn_updated") {
|
| 238 |
console.log(`USE_RNN setting updated to: ${data.use_rnn}`);
|
| 239 |
// Update the toggle to match the server state
|
|
|
|
| 293 |
const INITIAL_AUTO_INPUT_DELAY = 2000; // Start auto-input after 2 seconds of no user input
|
| 294 |
const AUTO_INPUT_INTERVAL = 500; // Send auto-input every 0.5 second once active
|
| 295 |
let autoInputEnabled = true; // Default to enabled
|
| 296 |
+
let userHasInteracted = false; // Track if user has moved mouse inside canvas
|
| 297 |
|
| 298 |
// Timeout countdown mechanism
|
| 299 |
let timeoutCountdownInterval = null;
|
|
|
|
| 311 |
autoInputInterval = setInterval(() => {
|
| 312 |
const currentTime = Date.now();
|
| 313 |
|
| 314 |
+
if (!autoInputEnabled || !lastSentPosition || !isConnected || socket.readyState !== WebSocket.OPEN || !userHasInteracted) {
|
| 315 |
return;
|
| 316 |
}
|
| 317 |
|
|
|
|
| 472 |
lastSentPosition = { x, y };
|
| 473 |
lastSentTime = currentTime;
|
| 474 |
|
| 475 |
+
// Mark that user has interacted with the canvas
|
| 476 |
+
if (!userHasInteracted) {
|
| 477 |
+
userHasInteracted = true;
|
| 478 |
+
console.log("User has interacted with canvas for the first time");
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
// Update last user input time for auto-input mechanism
|
| 482 |
updateLastUserInputTime();
|
| 483 |
|