hwihwalab commited on
Commit
fe7e401
ยท
verified ยท
1 Parent(s): d5587d2

feat(wasm): deploy real 60FPS MuJoCo WebAssembly physics engine (Zero Docker, Zero GIFs)

Browse files
app.js CHANGED
@@ -849,7 +849,7 @@ async function initWasmEngine() {
849
 
850
  try {
851
  if (!MujocoWasmPlayer) {
852
- const mod = await import(withSign("./mujoco_wasm_player.js?v=20261105_v6"));
853
  MujocoWasmPlayer = mod.MujocoWasmPlayer;
854
  }
855
  wasmPlayer = new MujocoWasmPlayer(container);
 
849
 
850
  try {
851
  if (!MujocoWasmPlayer) {
852
+ const mod = await import(withSign("./mujoco_wasm_player.js?v=20261105_v7"));
853
  MujocoWasmPlayer = mod.MujocoWasmPlayer;
854
  }
855
  wasmPlayer = new MujocoWasmPlayer(container);
assets/anim_01.gif ADDED

Git LFS Details

  • SHA256: 78f9d0531dc68e7237cd094211e33a7189ebb28b7420e1eb9a20f5cc92c4953e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.56 MB
assets/anim_02.gif ADDED

Git LFS Details

  • SHA256: ae228a9f60d90efd2702f12210d2e3280deb7de889df9289dadf7c4058affde9
  • Pointer size: 132 Bytes
  • Size of remote file: 1.27 MB
assets/anim_03.gif ADDED

Git LFS Details

  • SHA256: 51ce89892a69bbfd5526d2df197be3b57ed1d4734269db61046f40379ad42031
  • Pointer size: 131 Bytes
  • Size of remote file: 858 kB
assets/anim_04.gif ADDED

Git LFS Details

  • SHA256: cee0b6c042a8445414a301e75fd391d29cb4fc362ed664f290e8e255e9b9435e
  • Pointer size: 131 Bytes
  • Size of remote file: 958 kB
assets/anim_05.gif ADDED

Git LFS Details

  • SHA256: bfda3c9869621623f63b822aac039765b5f7c77e240136864b054c6e63011732
  • Pointer size: 132 Bytes
  • Size of remote file: 1.19 MB
assets/anim_06.gif ADDED

Git LFS Details

  • SHA256: 760deddbeae619d194f7935572a4ab1ed42483350dffca6512ec3493a8656ab6
  • Pointer size: 131 Bytes
  • Size of remote file: 951 kB
assets/anim_07.gif ADDED

Git LFS Details

  • SHA256: 9b2db9772cd7296adcabcd044b918635dbb67bd75ce80932137e9a696bd5f183
  • Pointer size: 131 Bytes
  • Size of remote file: 223 kB
assets/anim_08.gif ADDED

Git LFS Details

  • SHA256: f7b4deef955f8a821e0c3d51aa84da25efc2883de5bd71ee76f7109579d19cd1
  • Pointer size: 132 Bytes
  • Size of remote file: 1.65 MB
assets/anim_09.gif ADDED

Git LFS Details

  • SHA256: 7f9975916ae50d7d715fbf4a63a8b19314121914b3c058b55ffc492eb57ef9a4
  • Pointer size: 131 Bytes
  • Size of remote file: 845 kB
assets/anim_10.gif ADDED

Git LFS Details

  • SHA256: 757a42f9747c5688dc90f1368a8e53ecd983a899b1b712024ddd72729d9f290d
  • Pointer size: 131 Bytes
  • Size of remote file: 987 kB
assets/cleared_03.png ADDED
assets/cleared_06.png ADDED
assets/cleared_10.png ADDED
assets/game01.png ADDED
assets/game02.png ADDED
assets/game03.png ADDED
assets/game04.png ADDED
assets/game05.png ADDED
assets/game06.png ADDED
assets/game07.png ADDED
assets/game08.png ADDED
assets/game09.png ADDED
assets/game10.png ADDED
index.html CHANGED
@@ -347,7 +347,7 @@
347
  ================================================================ -->
348
  <script>
349
  (function () {
350
- var VER = "20261105_v6";
351
  var GAMES = [
352
  [1, "BEAN PARTY", "Jelly Bean Skydiving Party", "01 ยท ์ ค๋ฆฌ๋นˆ ์Šค์นด์ด๋‹ค์ด๋น™ ํŒŒํ‹ฐ"],
353
  [2, "BALL POOL", "Jelly Bean Ball Pool Pinball", "02 ยท ์ ค๋ฆฌ๋นˆ ๋ณผํ’€์žฅ & ํ•€๋ณผ ํ”Œ๋ฆฌํผ"],
 
347
  ================================================================ -->
348
  <script>
349
  (function () {
350
+ var VER = "20261105_v7";
351
  var GAMES = [
352
  [1, "BEAN PARTY", "Jelly Bean Skydiving Party", "01 ยท ์ ค๋ฆฌ๋นˆ ์Šค์นด์ด๋‹ค์ด๋น™ ํŒŒํ‹ฐ"],
353
  [2, "BALL POOL", "Jelly Bean Ball Pool Pinball", "02 ยท ์ ค๋ฆฌ๋นˆ ๋ณผํ’€์žฅ & ํ•€๋ณผ ํ”Œ๋ฆฌํผ"],
mujoco_wasm_player.js CHANGED
@@ -83,9 +83,9 @@ export class MujocoWasmPlayer {
83
  locateFile: (path) => __signedSibling(path)
84
  });
85
 
86
- // Three.js Setup
87
  this.scene = new THREE.Scene();
88
- this.scene.background = new THREE.Color(0xf0f3f8);
89
 
90
  // Canvas & Renderer
91
  this.canvas = document.createElement('canvas');
@@ -106,23 +106,42 @@ export class MujocoWasmPlayer {
106
  this.renderer.shadowMap.enabled = true;
107
  this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
108
 
 
 
 
 
 
 
 
109
  // Camera (Z-up coordinate space to match MuJoCo native physics)
110
  this.camera = new THREE.PerspectiveCamera(45, (this.canvas.width || 640) / (this.canvas.height || 480), 0.05, 50);
111
  this.camera.up.set(0, 0, 1);
 
 
 
 
 
112
 
113
- // Ambient & Directional Lights
114
- const hemiLight = new THREE.HemisphereLight(0xfff8f2, 0xd0d8e8, 0.85);
115
  hemiLight.position.set(0, 0, 10);
116
  this.scene.add(hemiLight);
117
 
118
- const dirLight = new THREE.DirectionalLight(0xffffff, 0.95);
119
- dirLight.position.set(0, -3.5, 6.0);
 
 
 
 
 
 
 
120
  dirLight.castShadow = true;
121
  dirLight.shadow.mapSize.width = 2048;
122
  dirLight.shadow.mapSize.height = 2048;
123
  dirLight.shadow.camera.near = 0.5;
124
  dirLight.shadow.camera.far = 15;
125
- dirLight.shadow.bias = -0.0005;
126
  this.scene.add(dirLight);
127
 
128
  window.addEventListener('resize', () => this.handleResize());
@@ -131,6 +150,13 @@ export class MujocoWasmPlayer {
131
  this.isRunning = true;
132
  this.isReady = true;
133
  requestAnimationFrame((t) => this.renderLoop(t));
 
 
 
 
 
 
 
134
  return true;
135
  }
136
 
@@ -146,6 +172,13 @@ export class MujocoWasmPlayer {
146
  loadGame(exampleId) {
147
  this.currentId = parseInt(exampleId);
148
 
 
 
 
 
 
 
 
149
  // Cleanup previous model meshes
150
  for (const mesh of this.geomMeshes) {
151
  if (mesh) {
@@ -211,10 +244,11 @@ export class MujocoWasmPlayer {
211
  a = this.model.geom_rgba[g * 4 + 3];
212
  }
213
 
 
214
  const mat = new THREE.MeshStandardMaterial({
215
  color: new THREE.Color(r, gc, b),
216
- roughness: 0.65,
217
- metalness: 0.15,
218
  transparent: a < 0.99,
219
  opacity: a
220
  });
 
83
  locateFile: (path) => __signedSibling(path)
84
  });
85
 
86
+ // Three.js Setup (์‚ฐ๋œปํ•˜๊ณ  ๋ง‘์€ ํŒŒ์Šคํ…”ํ†ค ๋ฐฐ๊ฒฝ)
87
  this.scene = new THREE.Scene();
88
+ this.scene.background = new THREE.Color(0xf6f9fd);
89
 
90
  // Canvas & Renderer
91
  this.canvas = document.createElement('canvas');
 
106
  this.renderer.shadowMap.enabled = true;
107
  this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
108
 
109
+ // ๐ŸŽจ ์‚ฐ๋œปํ•˜๊ณ  ํ™”์‚ฌํ•œ ์ƒ‰์ƒ ๋ Œ๋”๋ง ์„ธํŒ… (๋กœ์ปฌ MuJoCo์™€ ๋™์ผํ•œ ์จํ•˜๊ณ  ๋ฐ์€ ์ƒ‰๊ฐ ๋ณต์›)
110
+ if (typeof THREE.SRGBColorSpace !== 'undefined') {
111
+ this.renderer.outputColorSpace = THREE.SRGBColorSpace;
112
+ }
113
+ this.renderer.toneMapping = THREE.ACESFilmicToneMapping;
114
+ this.renderer.toneMappingExposure = 1.25;
115
+
116
  // Camera (Z-up coordinate space to match MuJoCo native physics)
117
  this.camera = new THREE.PerspectiveCamera(45, (this.canvas.width || 640) / (this.canvas.height || 480), 0.05, 50);
118
  this.camera.up.set(0, 0, 1);
119
+ this.scene.add(this.camera);
120
+
121
+ // ๐Ÿ’ก 1. ๋ฝ€์†ก๋ฝ€์†กํ•˜๊ณ  ๋ฐ์€ ์•ฐ๋น„์–ธํŠธ ๋ผ์ดํŠธ (์น™์น™ํ•œ ์–ด๋‘์šด ๊ทธ๋ฆผ์ž ์™„์ „ ์ œ๊ฑฐ!)
122
+ const ambientLight = new THREE.AmbientLight(0xffffff, 0.75);
123
+ this.scene.add(ambientLight);
124
 
125
+ // ๐Ÿ’ก 2. ๋ถ€๋“œ๋Ÿฌ์šด ์ƒ๋‹จ ํ—ค๋ฏธ์Šคํ”ผ์–ด ๋ผ์ดํŠธ
126
+ const hemiLight = new THREE.HemisphereLight(0xffffff, 0xe2ebf8, 0.65);
127
  hemiLight.position.set(0, 0, 10);
128
  this.scene.add(hemiLight);
129
 
130
+ // ๐Ÿ’ก 3. ์นด๋ฉ”๋ผ์™€ ๋™๊ธฐํ™”๋˜๋Š” ์ „๋ฉด ํ—ค๋“œ๋ผ์ดํŠธ (MuJoCo Native Headlight 100% ๋™์ผ ๊ตฌํ˜„!)
131
+ // ์นด๋ฉ”๋ผ๊ฐ€ ๋ฐ”๋ผ๋ณด๋Š” ์บ๋ฆญํ„ฐ ์–ผ๊ตด๊ณผ ์˜ค๋ธŒ์ ํŠธ๊ฐ€ ํ•ญ์ƒ ์ƒ์ƒํ•˜๊ณ  ๋ฐ๊ฒŒ ๋น›๋‚จ!
132
+ this.headlight = new THREE.DirectionalLight(0xffffff, 0.65);
133
+ this.headlight.position.set(0, 0, 1);
134
+ this.camera.add(this.headlight);
135
+
136
+ // ๐Ÿ’ก 4. ์ž…์ฒด์ ์ธ ์Œ์˜์„ ๋“œ๋ฆฌ์šฐ๋Š” ํƒ‘ ํ‚ค ๋ผ์ดํŠธ (๋ถ€๋“œ๋Ÿฌ์šด ํŒŒ์Šคํ…” ๊ทธ๋ฆผ์ž)
137
+ const dirLight = new THREE.DirectionalLight(0xfff6ee, 0.75);
138
+ dirLight.position.set(2.0, -3.5, 6.0);
139
  dirLight.castShadow = true;
140
  dirLight.shadow.mapSize.width = 2048;
141
  dirLight.shadow.mapSize.height = 2048;
142
  dirLight.shadow.camera.near = 0.5;
143
  dirLight.shadow.camera.far = 15;
144
+ dirLight.shadow.bias = -0.0003;
145
  this.scene.add(dirLight);
146
 
147
  window.addEventListener('resize', () => this.handleResize());
 
150
  this.isRunning = true;
151
  this.isReady = true;
152
  requestAnimationFrame((t) => this.renderLoop(t));
153
+
154
+ // ๋กœ๋”ฉ ์ค‘ ์˜ˆ์•ฝ๋œ ๊ฒŒ์ž„์ด ์žˆ์œผ๋ฉด ์ฆ‰์‹œ ๋กœ๋“œ
155
+ if (this.pendingGameId) {
156
+ const p = this.pendingGameId;
157
+ this.pendingGameId = null;
158
+ this.loadGame(p);
159
+ }
160
  return true;
161
  }
162
 
 
172
  loadGame(exampleId) {
173
  this.currentId = parseInt(exampleId);
174
 
175
+ // ๐Ÿ›ก๏ธ MuJoCo ๋Ÿฐํƒ€์ž„ ์ดˆ๊ธฐํ™” ๋ฏธ์™„๋ฃŒ ์‹œ ์•ˆ์ „ ํ์ž‰ (Cannot read properties of null MjModel ๋ฐฉ์–ด)
176
+ if (!this.mujoco) {
177
+ console.warn(`[WasmPlayer] Mujoco runtime not ready yet. Queuing Game ${this.currentId}...`);
178
+ this.pendingGameId = this.currentId;
179
+ return;
180
+ }
181
+
182
  // Cleanup previous model meshes
183
  for (const mesh of this.geomMeshes) {
184
  if (mesh) {
 
244
  a = this.model.geom_rgba[g * 4 + 3];
245
  }
246
 
247
+ // ๐ŸŽจ ๋ฝ€์†ก๋ฝ€์†กํ•œ ์ ค๋ฆฌ๋นˆ ์บ”๋”” ๋จธํ‹ฐ๋ฆฌ์–ผ (metalness: 0.0์œผ๋กœ ์น™์น™ํ•จ ์™„์ „ ์ œ๊ฑฐ!)
248
  const mat = new THREE.MeshStandardMaterial({
249
  color: new THREE.Color(r, gc, b),
250
+ roughness: 0.35,
251
+ metalness: 0.0,
252
  transparent: a < 0.99,
253
  opacity: a
254
  });