Skip to content

Commit e47809d

Browse files
saran-tcopybara-github
authored andcommitted
Refactor MuJoCo Live to separate out HTML, CSS, and JS components.
PiperOrigin-RevId: 915340338 Change-Id: Ic62b9d640af9967a59a77fa59a3556b916d5a24c
1 parent c56d662 commit e47809d

9 files changed

Lines changed: 310 additions & 255 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ name: build
1414

1515
on:
1616
push:
17+
branches:
18+
- main
1719
paths-ignore:
1820
- "doc/**"
1921
- "**/README.md"

.github/workflows/build_steps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ build_mujoco_live() {
317317
-DMUJOCO_USE_FILAMENT=ON \
318318
-DMUJOCO_BUILD_TESTS_WASM=OFF \
319319
-DMUJOCO_NATIVE_BUILD_DIR=$(pwd)/build_host
320-
cmake --build build_wasm --target mujoco_live -j$(nproc)
320+
cmake --build build_wasm --target mujoco_studio -j$(nproc)
321321
}
322322

323323

.github/workflows/live.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ jobs:
3232
run: |
3333
mkdir -p dist/bin
3434
cp -r build_wasm/bin/* dist/bin/
35-
cp src/experimental/studio/index.html dist/index.html
35+
cp src/experimental/studio/live.html dist/index.html
36+
cp src/experimental/studio/live.css dist/live.css
37+
cp src/experimental/studio/live.js dist/live.js
3638
COMMIT_HASH=$(git rev-parse HEAD 2>/dev/null || true)
3739
if [ -n "$COMMIT_HASH" ]; then
3840
sed -i "s/__COMMIT_HASH_PLACEHOLDER__/$COMMIT_HASH/g" dist/index.html

src/experimental/studio/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,19 @@ endif()
9898

9999
# WASM Live target.
100100
if(EMSCRIPTEN)
101-
add_executable(mujoco_live)
102-
target_sources(mujoco_live PRIVATE wasm.cc)
103-
target_compile_options(mujoco_live PRIVATE -g)
104-
configure_studio_target(mujoco_live)
105-
target_link_libraries(mujoco_live PRIVATE mujoco::render_noop)
101+
add_executable(mujoco_studio)
102+
target_sources(mujoco_studio PRIVATE emscripten.cc)
103+
target_compile_options(mujoco_studio PRIVATE -g)
104+
configure_studio_target(mujoco_studio)
105+
target_link_libraries(mujoco_studio PRIVATE mujoco::render_noop)
106106

107107
# Ensure resource decoder plugins are linked into the WASM binary.
108-
target_link_options(mujoco_live PRIVATE
108+
target_link_options(mujoco_studio PRIVATE
109109
-Wl,--whole-archive $<TARGET_FILE:mujoco> -Wl,--no-whole-archive
110110
)
111111

112112
# Filament's OpenGL backend requires WebGL2 / full ES3 bindings.
113-
target_link_options(mujoco_live PRIVATE
113+
target_link_options(mujoco_studio PRIVATE
114114
--bind
115115
-sUSE_WEBGL2=1
116116
-sFULL_ES3

src/experimental/studio/index.html

Lines changed: 0 additions & 246 deletions
This file was deleted.

src/experimental/studio/live.css

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#loadingOverlay {
2+
position: fixed;
3+
top: 0;
4+
left: 0;
5+
width: 100%;
6+
height: 100%;
7+
background: rgba(0,0,0,0.6);
8+
z-index: 10000;
9+
display: none;
10+
align-items: center;
11+
justify-content: center;
12+
}
13+
.loading-container {
14+
color: #fff;
15+
font-size: 24px;
16+
font-family: sans-serif;
17+
text-align: center;
18+
}
19+
.loading-title {
20+
margin-bottom: 16px;
21+
}
22+
.loading-subtitle {
23+
font-size: 14px;
24+
opacity: 0.7;
25+
}
26+
#dropOverlay {
27+
position: fixed;
28+
top: 0;
29+
left: 0;
30+
width: 100%;
31+
height: 100%;
32+
background: rgba(0,0,0,0.5);
33+
z-index: 9999;
34+
display: none;
35+
pointer-events: none;
36+
align-items: center;
37+
justify-content: center;
38+
}
39+
.drop-message {
40+
color: #fff;
41+
font-size: 24px;
42+
font-family: sans-serif;
43+
padding: 32px 48px;
44+
border: 3px dashed #fff;
45+
border-radius: 16px;
46+
}
47+
#commitHash {
48+
position: absolute;
49+
top: 3px;
50+
right: 3px;
51+
z-index: 1;
52+
font-family: monospace;
53+
font-size: 7pt;
54+
color: #fff;
55+
mix-blend-mode: difference;
56+
user-select: all;
57+
}
58+
#canvas {
59+
width: 100vw;
60+
height: 100vh;
61+
display: block;
62+
}

src/experimental/studio/live.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="stylesheet" href="live.css">
6+
<title>MuJoCo Live</title>
7+
</head>
8+
<body style="margin: 0; overflow: hidden">
9+
<div id="loadingOverlay">
10+
<div class="loading-container">
11+
<div class="loading-title">Loading model&hellip;</div>
12+
<div class="loading-subtitle">This may take a moment for large models.</div>
13+
</div>
14+
</div>
15+
<div id="dropOverlay">
16+
<div class="drop-message">Drop model file here</div>
17+
</div>
18+
<div id="commitHash">__COMMIT_HASH_PLACEHOLDER__</div>
19+
<canvas id="canvas" class="emscripten" oncontextmenu="event.preventDefault()"></canvas>
20+
<script src="live.js"></script>
21+
<script async src="bin/mujoco_studio.js"></script>
22+
</body>
23+
</html>

0 commit comments

Comments
 (0)