Skip to content

Commit

Permalink
Simplified Stompy STL mesh files, added better error handling, deboun…
Browse files Browse the repository at this point in the history
…ce, and cache busting

- Simplified the STL mesh files for Stompy to improve performance.
- Implemented debounce for resize events to prevent excessive calls and added logging for debounce execution.
- Added cache busting by appending a version string based on a hash to the URL for XML files and logged the full URL with the version string.
  • Loading branch information
vrtnis committed Jun 5, 2024
1 parent 2255bf4 commit fd46d83
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions examples/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ import {
} from './mujocoUtils.js';
import load_mujoco from '../dist/mujoco_wasm.js';

// Generate a version string based on a hash (for simplicity using Date.now)
const version = Date.now().toString(36);

const mujoco = await load_mujoco();
const version = '1.0.0'; // You can automate this based on your build process

var initialScene = `humanoid.xml?v=${version}`;
console.log(`Full URL with version string for cache busting: ./examples/scenes/${initialScene}`);

mujoco.FS.mkdir('/working');
mujoco.FS.mount(mujoco.MEMFS, { root: '.' }, '/working');
mujoco.FS.writeFile(`/working/${initialScene}`, await (await fetch(`./examples/scenes/${initialScene}`)).text());
Expand Down Expand Up @@ -107,7 +103,6 @@ export class MuJoCoDemo {
}

onWindowResize() {
console.log('Window resize event triggered');
this.camera.aspect = window.innerWidth / window.innerHeight;
this.camera.updateProjectionMatrix();
this.renderer.setSize(window.innerWidth, window.innerHeight);
Expand Down Expand Up @@ -260,9 +255,6 @@ function debounce(func, wait) {
return function (...args) {
const context = this;
clearTimeout(timeout);
timeout = setTimeout(() => {
console.log(`Debounced function executed after ${wait}ms`);
func.apply(context, args);
}, wait);
timeout = setTimeout(() => func.apply(context, args), wait);
};
}

0 comments on commit fd46d83

Please sign in to comment.