Files
VibemakerSandbox/index.html
T
tfrere 2d0c5588ed feat: right-stick camera orbit with inertia, subtle Tron glow on grid
- Gamepad right stick orbits the camera around the duck through a
  smoothed angular velocity (exponential ramp in, ~0.3 s coast out), so
  motion eases instead of stopping dead. Vertical is flight-style
  inverted. Any deflection detaches the chase cam; R3 toggles it back,
  mirroring the C key. New RS/R3 HUD hints, README gamepad section
  updated.
- Grid lines (floor and arena walls) get a thicker antialiased core and
  a faint wide halo for a restrained Tron look, plus slightly brighter
  line color and opacity.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-20 16:46:11 +02:00

683 lines
24 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Microduck RL playground</title>
<style>
:root {
--ink: #08080c;
--yellow: #ffd23f;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
background: var(--ink);
color: rgba(255, 255, 255, 0.85);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
overflow: hidden;
}
#scene { position: fixed; inset: 0; }
#scene canvas { display: block; }
.halftone {
position: fixed;
inset: 0;
pointer-events: none;
background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1.5px);
background-size: 21px 21px;
mask-image: linear-gradient(to bottom, transparent 30%, black 100%);
-webkit-mask-image: linear-gradient(to bottom, transparent 30%, black 100%);
}
/* Top-left corner: what this is */
#brand {
position: fixed;
top: 1.4rem;
left: 1.6rem;
z-index: 10;
font-size: 0.72rem;
font-weight: 600;
letter-spacing: 0.14em;
text-transform: uppercase;
color: rgba(255, 255, 255, 0.55);
line-height: 1.8;
}
#brand b { color: var(--yellow); font-weight: 600; }
#loading {
position: fixed;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.8rem;
letter-spacing: 0.14em;
text-transform: uppercase;
color: rgba(255, 255, 255, 0.45);
text-align: center;
padding: 0 2rem;
z-index: 20;
}
/* Bottom edges: controls left, key hints right */
#hud {
position: fixed;
bottom: 1.4rem;
left: 1.6rem;
right: 1.6rem;
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 1rem;
z-index: 10;
pointer-events: none;
}
#hud .stack {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 0.45rem;
pointer-events: auto;
}
#hud .row {
display: flex;
align-items: center;
gap: 0.5rem;
}
#hud button {
appearance: none;
border: 1px solid rgba(255, 255, 255, 0.14);
background: rgba(255, 255, 255, 0.04);
color: rgba(255, 255, 255, 0.8);
font: inherit;
font-size: 0.72rem;
font-weight: 600;
letter-spacing: 0.1em;
text-transform: uppercase;
padding: 0.5rem 1rem;
border-radius: 999px;
cursor: pointer;
transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
#hud button:hover { background: rgba(255, 255, 255, 0.1); }
#hud button.on {
background: #ffc61e;
border-color: #ffc61e;
color: #08080c;
}
/* Current-state label: quiet line above the telemetry, slot-machine
roll on change */
.mode {
position: relative;
overflow: hidden;
height: 1.2em;
min-width: 8ch;
font-size: 0.72rem;
font-weight: 600;
letter-spacing: 0.2em;
text-transform: uppercase;
color: rgba(255, 210, 63, 0.8);
text-align: right;
}
.mode .mode-text {
position: absolute;
left: 0;
top: 0;
width: 100%;
line-height: 1.2;
transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
}
.mode .mode-text.in { transform: translateY(130%); opacity: 0; }
.mode .mode-text.out { transform: translateY(-130%); opacity: 0; }
/* Colour swatches */
#swatches { gap: 0.6rem; }
#swatches button {
width: 1.5rem;
height: 1.5rem;
padding: 0;
border-radius: 50%;
border: 2px solid rgba(255, 255, 255, 0.18);
}
#swatches button:hover { transform: scale(1.15); }
#swatches button.on {
border-color: #fff;
transform: scale(1.15);
}
#hud .keys {
font-size: 0.7rem;
letter-spacing: 0.08em;
color: rgba(255, 255, 255, 0.4);
text-align: right;
line-height: 1.9;
pointer-events: auto;
}
/* Corner group captions */
#hud .caption {
display: block;
font-size: 0.55rem;
font-weight: 600;
letter-spacing: 0.2em;
text-transform: uppercase;
color: rgba(255, 255, 255, 0.28);
}
#hud .keys .caption { margin-bottom: 0.45rem; }
/* Keycap chips in the hints */
#hud .keys .key {
display: inline-block;
min-width: 1.5em;
padding: 0.12em 0.4em;
border: 1px solid rgba(255, 255, 255, 0.2);
border-bottom-width: 2px;
border-radius: 5px;
background: rgba(255, 255, 255, 0.05);
color: rgba(255, 255, 255, 0.75);
font-size: 0.62rem;
font-weight: 600;
line-height: 1.35;
text-align: center;
transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
#hud .keys .key.lit {
background: var(--yellow);
border-color: var(--yellow);
color: var(--ink);
}
#pad-hint { display: none; }
body.pad-connected #pad-hint { display: inline; }
/* Mini command sticks: dot = the twist the policy actually receives */
#sticks {
display: flex;
gap: 0.7rem;
justify-content: flex-end;
margin-bottom: 0.5rem;
}
.stickwrap {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.15rem;
}
.stickwrap span {
font-size: 0.55rem;
letter-spacing: 0.14em;
text-transform: uppercase;
color: rgba(255, 255, 255, 0.3);
line-height: 1;
}
.stickbox {
position: relative;
width: 46px;
height: 46px;
border-radius: 50%;
border: 1px solid rgba(255, 255, 255, 0.16);
background: rgba(255, 255, 255, 0.03);
}
.stickdot {
position: absolute;
left: 50%;
top: 50%;
width: 12px;
height: 12px;
margin: -6px 0 0 -6px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.35);
transition: background 0.15s ease;
}
.stickbox.live .stickdot { background: var(--yellow); }
#stats-wrap {
position: fixed;
top: 1.4rem;
right: 1.6rem;
z-index: 10;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 0.15rem;
}
#stats {
font-size: 0.68rem;
letter-spacing: 0.08em;
text-align: right;
color: rgba(255, 255, 255, 0.4);
line-height: 1.7;
font-variant-numeric: tabular-nums;
}
@media (max-width: 700px) {
#hud { flex-direction: column; align-items: flex-start; }
#hud .keys { display: none; }
#brand .sub { display: none; }
}
/* ── Welcome modal ─────────────────────────────────────────────── */
/* display:flex would override the hidden attribute's UA display:none,
so hidden must win explicitly. */
#welcome[hidden] { display: none; }
#welcome {
position: fixed;
inset: 0;
z-index: 30;
display: flex;
padding: 1.25rem;
overflow-y: auto;
background: rgba(8, 8, 12, 0.5);
backdrop-filter: blur(18px) saturate(1.3);
-webkit-backdrop-filter: blur(18px) saturate(1.3);
opacity: 1;
transition: opacity 0.35s ease;
}
#welcome.closing { opacity: 0; pointer-events: none; }
#welcome .card {
position: relative;
/* Auto margins center the card and degrade to scroll on overflow */
margin: auto;
width: 100%;
max-width: 480px;
padding: 2.3rem 2.4rem 1.8rem;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 24px;
background:
radial-gradient(130% 80% at 50% 0%, rgba(255, 210, 63, 0.06), transparent 55%),
rgba(13, 13, 19, 0.94);
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.06),
0 24px 60px rgba(0, 0, 0, 0.55),
0 80px 160px rgba(0, 0, 0, 0.4);
text-align: center;
animation: card-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes card-in {
from { transform: translateY(14px) scale(0.965); opacity: 0; }
to { transform: none; opacity: 1; }
}
/* Rows fade in with a gentle stagger; no bounce anywhere. */
#welcome .card > * {
animation: row-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
#welcome .card > :nth-child(1) { animation-delay: 0.05s; }
#welcome .card > :nth-child(2) { animation-delay: 0.11s; }
#welcome .card > :nth-child(3) { animation-delay: 0.17s; }
#welcome .card > :nth-child(4) { animation-delay: 0.23s; }
#welcome .card > :nth-child(5) { animation-delay: 0.27s; }
@keyframes row-in {
from { transform: translateY(8px); opacity: 0; }
to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
#welcome .card, #welcome .card > * { animation: none; }
}
/* Header: duck-head mark (closed by default, open on hover - same
swap as the site) over a clean typographic identity. */
#welcome .logo-head {
position: relative;
width: 5.8rem;
margin: 0 auto;
filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.45));
}
#welcome .logo-head img { display: block; width: 100%; }
#welcome .logo-head .open { position: absolute; inset: 0; opacity: 0; }
#welcome .logo-head:hover .open { opacity: 1; }
#welcome .logo-head:hover .closed { opacity: 0; }
#welcome .title {
margin-top: 0.8rem;
font-size: 1.4rem;
font-weight: 700;
letter-spacing: -0.01em;
color: rgba(255, 255, 255, 0.95);
}
#welcome .subtitle {
margin-top: 0.35rem;
font-size: 0.6rem;
font-weight: 700;
letter-spacing: 0.34em;
text-indent: 0.34em; /* recenter: tracking pads the right edge only */
text-transform: uppercase;
color: rgba(255, 210, 63, 0.8);
}
#welcome .tagline {
margin: 0.8rem auto 0;
max-width: 42ch;
font-size: 0.78rem;
line-height: 1.6;
color: rgba(255, 255, 255, 0.58);
text-wrap: balance;
}
/* Section label with hairlines on both sides */
#welcome .section-label {
display: flex;
align-items: center;
gap: 0.9rem;
margin: 1.5rem 0 0.8rem;
font-size: 0.56rem;
font-weight: 700;
letter-spacing: 0.28em;
text-indent: 0.28em;
text-transform: uppercase;
color: rgba(255, 255, 255, 0.35);
}
#welcome .section-label::before,
#welcome .section-label::after {
content: "";
flex: 1;
height: 1px;
background: rgba(255, 255, 255, 0.08);
}
/* Controls: six keycap tiles on a tidy grid */
#welcome .grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.5rem;
}
#welcome .tile {
padding: 0.75rem 0.4rem 0.7rem;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 14px;
background: rgba(255, 255, 255, 0.03);
}
/* Fixed-height keycap area so every tile's label sits on the same
baseline whether it holds one cap or the arrow cluster. */
#welcome .caps {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0.2rem;
height: 3.3rem;
}
#welcome .caps .krow {
display: flex;
gap: 0.2rem;
justify-content: center;
}
#welcome kbd {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 1.55rem;
height: 1.55rem;
padding: 0 0.45rem;
font: inherit;
font-size: 0.68rem;
font-weight: 600;
color: rgba(255, 255, 255, 0.88);
background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 6px;
box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
/* The arrow cluster packs six caps in two rows, so its caps shrink a
notch; every other tile keeps the full-size cap. */
#welcome .caps.cluster kbd { min-width: 1.4rem; height: 1.4rem; padding: 0 0.3rem; font-size: 0.62rem; }
#welcome .t-name {
margin-top: 0.55rem;
font-size: 0.62rem;
font-weight: 700;
letter-spacing: 0.18em;
text-indent: 0.18em;
text-transform: uppercase;
color: rgba(255, 255, 255, 0.85);
}
#welcome .t-hint {
margin-top: 0.2rem;
font-size: 0.6rem;
color: rgba(255, 255, 255, 0.38);
}
#welcome .orbit-hint {
margin-top: 0.7rem;
font-size: 0.62rem;
letter-spacing: 0.08em;
color: rgba(255, 255, 255, 0.35);
}
/* Secondary row: gamepad + live ghosts */
#welcome .extras {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1.2rem;
margin-top: 1.3rem;
padding-top: 1.1rem;
border-top: 1px solid rgba(255, 255, 255, 0.07);
}
#welcome .x-label {
display: block;
margin-bottom: 0.3rem;
font-size: 0.56rem;
font-weight: 700;
letter-spacing: 0.24em;
text-indent: 0.24em;
text-transform: uppercase;
color: rgba(255, 210, 63, 0.7);
}
#welcome .x-item {
font-size: 0.68rem;
line-height: 1.5;
color: rgba(255, 255, 255, 0.5);
text-wrap: balance;
}
#welcome .cta {
margin-top: 1.5rem;
}
#welcome-go {
appearance: none;
border: none;
background: var(--yellow);
color: var(--ink);
font: inherit;
font-size: 0.75rem;
font-weight: 700;
letter-spacing: 0.14em;
text-indent: 0.14em;
text-transform: uppercase;
padding: 0.8rem 2.6rem;
border-radius: 999px;
cursor: pointer;
transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#welcome-go:hover {
transform: translateY(-1px);
box-shadow: 0 8px 28px rgba(255, 210, 63, 0.3);
}
#welcome-go:focus-visible {
outline: 2px solid rgba(255, 255, 255, 0.85);
outline-offset: 3px;
}
#welcome .fineprint {
margin-top: 0.9rem;
font-size: 0.58rem;
letter-spacing: 0.1em;
text-transform: uppercase;
color: rgba(255, 255, 255, 0.28);
}
/* Narrow screens: stack the grid two-up, tighten the whole rhythm so
the card still fits a small phone viewport without scrolling */
@media (max-width: 480px) {
#welcome .card { padding: 1.6rem 1.3rem 1.4rem; border-radius: 20px; }
#welcome .logo-head { width: 4.3rem; }
#welcome .title { margin-top: 0.6rem; font-size: 1.2rem; }
#welcome .tagline { margin-top: 0.55rem; font-size: 0.73rem; }
#welcome .section-label { margin: 1.1rem 0 0.7rem; }
#welcome .grid { grid-template-columns: repeat(2, 1fr); gap: 0.45rem; }
#welcome .tile { padding: 0.6rem 0.4rem 0.55rem; }
#welcome .caps { height: 2.7rem; }
#welcome .t-name { margin-top: 0.4rem; }
#welcome .orbit-hint { margin-top: 0.55rem; }
#welcome .extras { grid-template-columns: 1fr; gap: 0.5rem; margin-top: 1rem; padding-top: 0.9rem; }
#welcome .x-label { display: inline; margin-right: 0.45rem; }
#welcome .cta { margin-top: 1.1rem; }
}
/* Short laptop viewports: shave vertical rhythm so it never scrolls */
@media (max-height: 760px) {
#welcome .logo-head { width: 4.8rem; }
#welcome .card { padding-top: 1.7rem; }
#welcome .title { margin-top: 0.6rem; font-size: 1.25rem; }
#welcome .tagline { margin-top: 0.6rem; }
#welcome .section-label { margin: 1.1rem 0 0.7rem; }
#welcome .extras { margin-top: 1rem; padding-top: 0.9rem; }
#welcome .cta { margin-top: 1.1rem; }
}
#brand { cursor: pointer; }
</style>
</head>
<body>
<div id="scene"></div>
<div class="halftone"></div>
<div id="brand">
<b>Microduck</b> &middot; real trained policies<br />
<span class="sub">MuJoCo + ONNX, live in your browser</span>
</div>
<div id="stats-wrap">
<div class="mode" id="mode-label"><span class="mode-text">Run</span></div>
<div id="stats"></div>
</div>
<div id="hud" hidden>
<div class="stack">
<span class="caption">Colour</span>
<div class="row" id="swatches"></div>
</div>
<div class="keys">
<span class="caption">Controls</span>
<div id="sticks">
<div class="stickwrap">
<div class="stickbox"><div class="stickdot" id="dot-move"></div></div>
<span>move</span>
</div>
<div class="stickwrap">
<div class="stickbox"><div class="stickdot" id="dot-turn"></div></div>
<span>turn</span>
</div>
</div>
<span class="hint"><span class="key" id="key-fwd">&uarr;</span><span class="key" id="key-back">&darr;</span> move</span> &nbsp;
<span class="hint"><span class="key" id="key-turnl">&larr;</span><span class="key" id="key-turnr">&rarr;</span> turn</span><br />
<span class="hint"><span class="key" id="key-roll">R</span> roll</span> &nbsp;
<span class="hint"><span class="key" id="key-kickl">A</span><span class="key" id="key-kickr">E</span> kick</span> &nbsp;
<span class="hint"><span class="key" id="key-ball">B</span> ball</span> &nbsp;
<span class="hint"><span class="key" id="key-cam">C</span> camera</span> &nbsp;
<span class="hint"><span class="key" id="key-reset">Space</span> reset</span> &nbsp;
drag to orbit &middot; scroll to zoom<br />
<span id="pad-hint">gamepad:
<span class="hint"><span class="key" id="key-pad-x">X</span> roll</span> &nbsp;
<span class="hint"><span class="key" id="key-pad-y">Y</span> ball</span> &nbsp;
<span class="hint"><span class="key" id="key-pad-rb">RB</span><span class="key" id="key-pad-lb">LB</span> kick</span> &nbsp;
<span class="hint"><span class="key" id="key-pad-rs">RS</span> camera</span> &nbsp;
<span class="hint"><span class="key" id="key-pad-r3">R3</span> chase</span> &nbsp;
<span class="hint"><span class="key" id="key-pad-sit">&dArr;</span> sit</span> &nbsp;
<span class="hint"><span class="key" id="key-pad-run">&uArr;</span> run</span> &nbsp;
<span class="hint"><span class="key" id="key-pad-rt">RT</span> quack</span>
</span>
</div>
</div>
<div id="loading">Compiling physics&hellip;</div>
<div id="welcome" hidden>
<div class="card" role="dialog" aria-modal="true" aria-label="Microduck playground">
<header>
<div class="logo-head">
<img class="closed" id="logo-head-closed" alt="Microduck" />
<img class="open" id="logo-head-open" alt="" aria-hidden="true" />
</div>
<h1 class="title">Microduck</h1>
<div class="subtitle">RL playground</div>
<p class="tagline">
Real physics, real trained neural policies, running live in
your browser fifty times a second.
</p>
</header>
<section aria-label="Controls">
<div class="section-label">Controls</div>
<div class="grid">
<div class="tile">
<div class="caps cluster">
<span class="krow"><kbd>&uarr;</kbd></span>
<span class="krow"><kbd>&larr;</kbd><kbd>&darr;</kbd><kbd>&rarr;</kbd></span>
</div>
<div class="t-name">Move</div>
<div class="t-hint">arrows or ZQSD</div>
</div>
<div class="tile">
<div class="caps"><span class="krow"><kbd>A</kbd><kbd>E</kbd></span></div>
<div class="t-name">Kick</div>
<div class="t-hint">left / right</div>
</div>
<div class="tile">
<div class="caps"><kbd>R</kbd></div>
<div class="t-name">Roll</div>
<div class="t-hint">barrel roll</div>
</div>
<div class="tile">
<div class="caps"><kbd>B</kbd></div>
<div class="t-name">Ball</div>
<div class="t-hint">pop one in</div>
</div>
<div class="tile">
<div class="caps"><kbd>C</kbd></div>
<div class="t-name">Camera</div>
<div class="t-hint">toggle chase</div>
</div>
<div class="tile">
<div class="caps"><kbd>Space</kbd></div>
<div class="t-name">Reset</div>
<div class="t-hint">fresh start</div>
</div>
</div>
<div class="orbit-hint">drag to orbit &middot; scroll to zoom</div>
</section>
<section class="extras">
<div class="x-item">
<span class="x-label">Gamepad</span>
Plug one in, same mapping as the real robot.
</div>
<div class="x-item">
<span class="x-label">Live ghosts</span>
Other visitors appear as translucent ducks.
</div>
</section>
<div class="cta">
<button id="welcome-go">Waddle in</button>
</div>
<div class="fineprint">click the title anytime to see this again</div>
</div>
</div>
<script>
// Welcome modal: shown on every load, dismissible by button, Escape
// or clicking the blurred backdrop. The top-left brand reopens it.
(() => {
const modal = document.getElementById("welcome");
// Logo images need the same ?__sign JWT as every other subresource
// on the private Space (rl.js hasn't installed its signer yet).
const sign = new URLSearchParams(location.search).get("__sign");
const signedUrl = (u) => (sign ? `${u}?__sign=${encodeURIComponent(sign)}` : u);
document.getElementById("logo-head-closed").src = signedUrl("./assets/duck-head-mark.webp");
document.getElementById("logo-head-open").src = signedUrl("./assets/duck-head-mark-open.webp");
const open = () => {
modal.hidden = false;
modal.classList.remove("closing");
};
const close = () => {
modal.classList.add("closing");
setTimeout(() => { modal.hidden = true; }, 380);
};
open();
document.getElementById("welcome-go").addEventListener("click", close);
modal.addEventListener("click", (e) => { if (e.target === modal) close(); });
window.addEventListener("keydown", (e) => {
if (e.code === "Escape" && !modal.hidden) close();
});
document.getElementById("brand").addEventListener("click", open);
})();
</script>
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.164.1/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.164.1/examples/jsm/"
}
}
</script>
<!-- rl.js is imported dynamically with the private-space ?__sign JWT
appended: a plain src attribute can 401 when the browser blocks the
*.static.hf.space auth cookie inside the hub iframe. -->
<script type="module">
const V = "30"; // bump on rl.js changes to defeat heuristic caching
const sign = new URLSearchParams(location.search).get("__sign");
const suffix = sign ? `&__sign=${encodeURIComponent(sign)}` : "";
import(`./rl.js?v=${V}${suffix}`);
</script>
</body>
</html>