Spaces:
Running
Running
Swap in your own VRM (drag and drop or file picker; kept in the browser)
Browse files- README.md +2 -0
- viewer/live.html +34 -2
README.md
CHANGED
|
@@ -16,6 +16,8 @@ A VRM character driven by the arrow keys / WASD. Every move is generated on the
|
|
| 16 |
NVIDIA MotionBricks: running, vaulting over boxes and walls, picking up stars, sitting, kicking a ball, pushing a big
|
| 17 |
ball, tripping and falling on her bottom.
|
| 18 |
|
|
|
|
|
|
|
| 19 |
- Needs a browser with WebGPU (recent desktop Chrome or Edge). The first visit downloads the model (about 380 MB).
|
| 20 |
- Model: [monoradio/motionbricks-soma-fp16-onnx](https://huggingface.co/monoradio/motionbricks-soma-fp16-onnx), licensed by NVIDIA Corporation under the NVIDIA Open Model Agreement.
|
| 21 |
- Target poses generated with NVIDIA Kimodo and ARDY; no NVIDIA sample motion data is included. See NOTICE.txt.
|
|
|
|
| 16 |
NVIDIA MotionBricks: running, vaulting over boxes and walls, picking up stars, sitting, kicking a ball, pushing a big
|
| 17 |
ball, tripping and falling on her bottom.
|
| 18 |
|
| 19 |
+
- Drop your own VRM onto the page (or pick one with the button) to play with it. It stays in your browser; nothing is uploaded.
|
| 20 |
+
|
| 21 |
- Needs a browser with WebGPU (recent desktop Chrome or Edge). The first visit downloads the model (about 380 MB).
|
| 22 |
- Model: [monoradio/motionbricks-soma-fp16-onnx](https://huggingface.co/monoradio/motionbricks-soma-fp16-onnx), licensed by NVIDIA Corporation under the NVIDIA Open Model Agreement.
|
| 23 |
- Target poses generated with NVIDIA Kimodo and ARDY; no NVIDIA sample motion data is included. See NOTICE.txt.
|
viewer/live.html
CHANGED
|
@@ -14,6 +14,9 @@
|
|
| 14 |
#hud .k { color: var(--muted); }
|
| 15 |
#stat { color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 6px; }
|
| 16 |
#hud .credit { color: var(--muted); font-size: 11px; line-height: 1.5; margin-top: 6px; }
|
|
|
|
|
|
|
|
|
|
| 17 |
#hud .credit a { color: var(--muted); }
|
| 18 |
#load { position: fixed; inset: 0; display: grid; place-items: center; font-size: 16px; background: var(--bg); }
|
| 19 |
</style>
|
|
@@ -25,6 +28,7 @@
|
|
| 25 |
<div><span class="k">矢印 / WASD</span> ダッシュ(カメラ基準)</div>
|
| 26 |
<div><span class="k">C</span> しゃがむ/立つ <span class="k">H</span> この表示を隠す</div>
|
| 27 |
<div>箱や低い壁は自動で飛び越え、星は拾って掲げ、ボールは蹴る・押す、椅子には座ります(座ったら、矢印キーを押し直すと立ちます)。黄黒の高い壁にぶつかると尻もち、黄黒の段差ではつまずきます</div>
|
|
|
|
| 28 |
<div id="stat"></div>
|
| 29 |
<div class="credit">動きの生成:NVIDIA MotionBricks(ブラウザの WebGPU で実行)。目標の姿勢は NVIDIA Kimodo と ARDY で生成。<a href="../NOTICE.txt" target="_blank">ライセンス表示</a></div>
|
| 30 |
</div>
|
|
@@ -46,7 +50,32 @@ const BUILD = Date.now();
|
|
| 46 |
const mb = await import(`./mb_runtime.js?v=${BUILD}`);
|
| 47 |
|
| 48 |
const params = new URLSearchParams(location.search);
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
const MODEL_URL = params.get('model') || 'https://huggingface.co/monoradio/motionbricks-soma-fp16-onnx/resolve/main/mmm_v6_soma_fp16.onnx';
|
| 51 |
// passes of the [1,2,1] time filter against fp16 trembling (0 = off). Measured while standing: hand/arm jitter
|
| 52 |
// 0.27/0.20 deg per frame with none, 0.12/0.07 with 2 passes, about what the fp32 model gives (0.15/0.08).
|
|
@@ -91,7 +120,10 @@ addEventListener('resize', () => {
|
|
| 91 |
status('VRM と動きのデータを読み込み中…');
|
| 92 |
const loader = new GLTFLoader();
|
| 93 |
loader.register(p => new VRMLoaderPlugin(p));
|
| 94 |
-
const [gltf, rt] = await Promise.all([
|
|
|
|
|
|
|
|
|
|
| 95 |
const vrm = gltf.userData.vrm;
|
| 96 |
VRMUtils.removeUnnecessaryVertices(gltf.scene);
|
| 97 |
VRMUtils.rotateVRM0(vrm);
|
|
|
|
| 14 |
#hud .k { color: var(--muted); }
|
| 15 |
#stat { color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 6px; }
|
| 16 |
#hud .credit { color: var(--muted); font-size: 11px; line-height: 1.5; margin-top: 6px; }
|
| 17 |
+
#hud .vrm { margin-top: 6px; }
|
| 18 |
+
#hud .vrm label { color: var(--accent); cursor: pointer; text-decoration: underline; }
|
| 19 |
+
#hud .vrm a { color: var(--muted); }
|
| 20 |
#hud .credit a { color: var(--muted); }
|
| 21 |
#load { position: fixed; inset: 0; display: grid; place-items: center; font-size: 16px; background: var(--bg); }
|
| 22 |
</style>
|
|
|
|
| 28 |
<div><span class="k">矢印 / WASD</span> ダッシュ(カメラ基準)</div>
|
| 29 |
<div><span class="k">C</span> しゃがむ/立つ <span class="k">H</span> この表示を隠す</div>
|
| 30 |
<div>箱や低い壁は自動で飛び越え、星は拾って掲げ、ボールは蹴る・押す、椅子には座ります(座ったら、矢印キーを押し直すと立ちます)。黄黒の高い壁にぶつかると尻もち、黄黒の段差ではつまずきます</div>
|
| 31 |
+
<div class="vrm">VRM をドラッグ&ドロップ、または <label>ファイルを選ぶ<input type="file" id="vrmFile" accept=".vrm" hidden></label> で差し替え(このブラウザの中だけで使います) <a href="#" id="vrmReset">元に戻す</a></div>
|
| 32 |
<div id="stat"></div>
|
| 33 |
<div class="credit">動きの生成:NVIDIA MotionBricks(ブラウザの WebGPU で実行)。目標の姿勢は NVIDIA Kimodo と ARDY で生成。<a href="../NOTICE.txt" target="_blank">ライセンス表示</a></div>
|
| 34 |
</div>
|
|
|
|
| 50 |
const mb = await import(`./mb_runtime.js?v=${BUILD}`);
|
| 51 |
|
| 52 |
const params = new URLSearchParams(location.search);
|
| 53 |
+
// The character: ?vrm=<url>, or ?vrm=local for a VRM dropped on the page (or picked with the button), which is kept only
|
| 54 |
+
// in this browser (IndexedDB) and loaded on the reload that follows the drop, so everything set up from the character
|
| 55 |
+
// (bone mapping, her scale, the obstacles drawn at it) starts over from it. Nothing is sent anywhere.
|
| 56 |
+
const DEFAULT_VRM = '../mecha_girl02_v2.vrm';
|
| 57 |
+
const vrmStore = {
|
| 58 |
+
db: () => new Promise((ok, ng) => {
|
| 59 |
+
const r = indexedDB.open('motionbricks-live', 1);
|
| 60 |
+
r.onupgradeneeded = () => r.result.createObjectStore('vrm');
|
| 61 |
+
r.onsuccess = () => ok(r.result); r.onerror = () => ng(r.error);
|
| 62 |
+
}),
|
| 63 |
+
async get() { const db = await this.db(); return new Promise((ok, ng) => { const q = db.transaction('vrm').objectStore('vrm').get('file'); q.onsuccess = () => ok(q.result); q.onerror = () => ng(q.error); }); },
|
| 64 |
+
async put(file) { const db = await this.db(); return new Promise((ok, ng) => { const t = db.transaction('vrm', 'readwrite'); t.objectStore('vrm').put(file, 'file'); t.oncomplete = ok; t.onerror = () => ng(t.error); }); },
|
| 65 |
+
};
|
| 66 |
+
let VRM_URL = params.get('vrm') || DEFAULT_VRM;
|
| 67 |
+
if (VRM_URL === 'local') {
|
| 68 |
+
try { const f = await vrmStore.get(); VRM_URL = f ? URL.createObjectURL(f) : DEFAULT_VRM; } catch { VRM_URL = DEFAULT_VRM; }
|
| 69 |
+
}
|
| 70 |
+
async function useVrmFile(file) {
|
| 71 |
+
if (!file || !/\.vrm$/i.test(file.name)) return;
|
| 72 |
+
try { await vrmStore.put(file); } catch (e) { alert('このブラウザでは VRM を保存できませんでした: ' + e.message); return; }
|
| 73 |
+
const q = new URLSearchParams(location.search); q.set('vrm', 'local'); location.search = q.toString();
|
| 74 |
+
}
|
| 75 |
+
addEventListener('dragover', (e) => { e.preventDefault(); });
|
| 76 |
+
addEventListener('drop', (e) => { e.preventDefault(); useVrmFile(e.dataTransfer.files[0]); });
|
| 77 |
+
document.getElementById('vrmFile').addEventListener('change', (e) => useVrmFile(e.target.files[0]));
|
| 78 |
+
document.getElementById('vrmReset').addEventListener('click', (e) => { e.preventDefault(); const q = new URLSearchParams(location.search); q.delete('vrm'); location.search = q.toString(); });
|
| 79 |
const MODEL_URL = params.get('model') || 'https://huggingface.co/monoradio/motionbricks-soma-fp16-onnx/resolve/main/mmm_v6_soma_fp16.onnx';
|
| 80 |
// passes of the [1,2,1] time filter against fp16 trembling (0 = off). Measured while standing: hand/arm jitter
|
| 81 |
// 0.27/0.20 deg per frame with none, 0.12/0.07 with 2 passes, about what the fp32 model gives (0.15/0.08).
|
|
|
|
| 120 |
status('VRM と動きのデータを読み込み中…');
|
| 121 |
const loader = new GLTFLoader();
|
| 122 |
loader.register(p => new VRMLoaderPlugin(p));
|
| 123 |
+
const [gltf, rt] = await Promise.all([
|
| 124 |
+
loader.loadAsync(VRM_URL).catch((e) => { status(`VRM を読み込めませんでした(${e.message})。別のファイルをドロップするか、元のキャラクターに戻してください。`); document.getElementById('hud').hidden = false; throw e; }),
|
| 125 |
+
fetch('../runtime_data/soma_runtime.json').then(r => r.json())]);
|
| 126 |
+
if (!gltf.userData.vrm) { status('VRM ではないファイルでした。VRM(.vrm)をドロップしてください��'); document.getElementById('hud').hidden = false; throw new Error('not a VRM'); }
|
| 127 |
const vrm = gltf.userData.vrm;
|
| 128 |
VRMUtils.removeUnnecessaryVertices(gltf.scene);
|
| 129 |
VRMUtils.rotateVRM0(vrm);
|