feat(wasm): deploy real 60FPS MuJoCo WebAssembly physics engine (Zero Docker, Zero GIFs)
Browse files- app.js +1 -1
- assets/anim_01.gif +3 -0
- assets/anim_02.gif +3 -0
- assets/anim_03.gif +3 -0
- assets/anim_04.gif +3 -0
- assets/anim_05.gif +3 -0
- assets/anim_06.gif +3 -0
- assets/anim_07.gif +3 -0
- assets/anim_08.gif +3 -0
- assets/anim_09.gif +3 -0
- assets/anim_10.gif +3 -0
- assets/cleared_03.png +0 -0
- assets/cleared_06.png +0 -0
- assets/cleared_10.png +0 -0
- assets/game01.png +0 -0
- assets/game02.png +0 -0
- assets/game03.png +0 -0
- assets/game04.png +0 -0
- assets/game05.png +0 -0
- assets/game06.png +0 -0
- assets/game07.png +0 -0
- assets/game08.png +0 -0
- assets/game09.png +0 -0
- assets/game10.png +0 -0
- index.html +1 -1
- mujoco_wasm_player.js +43 -9
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=
|
| 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
|
assets/anim_02.gif
ADDED
|
Git LFS Details
|
assets/anim_03.gif
ADDED
|
Git LFS Details
|
assets/anim_04.gif
ADDED
|
Git LFS Details
|
assets/anim_05.gif
ADDED
|
Git LFS Details
|
assets/anim_06.gif
ADDED
|
Git LFS Details
|
assets/anim_07.gif
ADDED
|
Git LFS Details
|
assets/anim_08.gif
ADDED
|
Git LFS Details
|
assets/anim_09.gif
ADDED
|
Git LFS Details
|
assets/anim_10.gif
ADDED
|
Git LFS Details
|
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 = "
|
| 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(
|
| 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 |
-
//
|
| 114 |
-
const hemiLight = new THREE.HemisphereLight(
|
| 115 |
hemiLight.position.set(0, 0, 10);
|
| 116 |
this.scene.add(hemiLight);
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|
| 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.
|
| 217 |
-
metalness: 0.
|
| 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 |
});
|