feat: floating-stick mobile controls, always-on ball, lighter ball scan
- controls/touch.js: touch input source - floating analog stick (lower-left zone, base anchors under the finger), A = alternate kick, B = quack with held-beak jaw; shown on coarse-pointer devices only - touch mode strips the HUD to Back + thumbs (no quickbar/mode/telemetry) and the title menu shows a stick/A/B tutorial variant (gamepad still wins) - a ball is always in play: auto-spawned when the entrance or any respawn ceremony unlocks input; B now re-pops a fresh one - ball scan FX reads a coarse geodesic stand-in (fxWireGeometry override) instead of the dense render sphere, and plays a touch slower Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+2
-2
@@ -12,8 +12,8 @@
|
||||
// Appear/disappear speed. The shared wireframe FX timeline lasts
|
||||
// fx.TOTAL_S (0.9 s, tuned for the duck's ceremony); the ball plays the
|
||||
// same timeline time-scaled to these snappier durations.
|
||||
const BALL_APPEAR_S = 0.2; // spawn pop-in (scan up)
|
||||
const BALL_DISAPPEAR_S = 0.15; // despawn/park peel-away (reverse scan)
|
||||
const BALL_APPEAR_S = 0.35; // spawn pop-in (scan up)
|
||||
const BALL_DISAPPEAR_S = 0.25; // despawn/park peel-away (reverse scan)
|
||||
|
||||
export function createBallActor({ THREE, scene, camera, renderer, fxModule, mesh, group }) {
|
||||
const fx = fxModule.createWireframeFx();
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
// Touch input source (see controller.js for the source interface
|
||||
// contract). Game Boy layout, two thumbs:
|
||||
//
|
||||
// Left thumb FLOATING analog stick: the lower-left quadrant of the
|
||||
// screen (#touch-zone) is the grab area, and the stick base
|
||||
// (#touch-stick) re-anchors under the finger wherever it
|
||||
// lands - so the thumb never has to find a fixed circle -
|
||||
// then snaps back to its resting spot on release. Vertical
|
||||
// = vx (asymmetric fwd/back limits), horizontal = turn. The
|
||||
// nub tracks the finger clamped to the base circle; the
|
||||
// command is EMA-smoothed like the gamepad's so releases
|
||||
// don't snap.
|
||||
// Right thumb two round caps: A (#touch-a) fires alternateKick - the
|
||||
// game alternates feet; B (#touch-b) quacks on press and
|
||||
// holds the beak open (axes.jaw = 1) while held.
|
||||
//
|
||||
// The overlay DOM lives in index.html (#touch-ui); this module only wires
|
||||
// pointer events to it. `connected` mirrors (pointer: coarse) - rl.js
|
||||
// reflects it onto body.touch-mode, which is what actually shows the
|
||||
// overlay - so a desktop never sees the thumbs and a phone always does,
|
||||
// even before the first touch.
|
||||
|
||||
const TOUCH_ALPHA = 0.18; // EMA smoothing toward the stick target
|
||||
const TOUCH_DEADZONE = 0.12; // normalized deflection ignored around center
|
||||
|
||||
export class TouchSource {
|
||||
id = "touch";
|
||||
connected = false;
|
||||
command = new Float32Array(3); // [vx, 0, wz], EMA-smoothed
|
||||
axes = { jaw: 0, orbitX: 0, orbitY: 0 };
|
||||
pressed = { stick: false, a: false, b: false };
|
||||
onAction = () => {}; // assigned by the Controller at registration
|
||||
|
||||
#getVelocityLimits;
|
||||
#active = false; // owns twist authority (stick engaged, until EMA settles)
|
||||
#target = [0, 0]; // normalized deflection [x, right+] [y, up+]
|
||||
#mq = null;
|
||||
#onMq = null;
|
||||
#disposers = [];
|
||||
|
||||
constructor({ getVelocityLimits }) {
|
||||
this.#getVelocityLimits = getVelocityLimits;
|
||||
}
|
||||
|
||||
init() {
|
||||
this.#mq = window.matchMedia("(pointer: coarse)");
|
||||
this.#onMq = () => { this.connected = this.#mq.matches; };
|
||||
this.#mq.addEventListener("change", this.#onMq);
|
||||
this.#onMq();
|
||||
|
||||
const zone = document.getElementById("touch-zone");
|
||||
const stick = document.getElementById("touch-stick");
|
||||
const nub = stick?.querySelector(".nub");
|
||||
if (zone && stick && nub) this.#bindStick(zone, stick, nub);
|
||||
|
||||
this.#bindButton("touch-a", "a", () => this.onAction("alternateKick"));
|
||||
this.#bindButton("touch-b", "b", () => this.onAction("quack"));
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.#mq?.removeEventListener("change", this.#onMq);
|
||||
for (const off of this.#disposers) off();
|
||||
this.#disposers = [];
|
||||
}
|
||||
|
||||
isActive() {
|
||||
return this.#active;
|
||||
}
|
||||
|
||||
poll() {
|
||||
const [x, y] = this.#target;
|
||||
const [limF, limB, limA] = this.#getVelocityLimits();
|
||||
const tvx = y >= 0 ? y * limF : y * -limB;
|
||||
const twz = -x * limA;
|
||||
this.command[0] += TOUCH_ALPHA * (tvx - this.command[0]);
|
||||
this.command[2] += TOUCH_ALPHA * (twz - this.command[2]);
|
||||
// Same authority rule as the gamepad sticks: grab on input, release
|
||||
// once the smoothed command has settled back to ~zero.
|
||||
if (this.pressed.stick) this.#active = true;
|
||||
else if (this.#active && Math.abs(this.command[0]) + Math.abs(this.command[2]) < 0.01) {
|
||||
this.#active = false;
|
||||
this.command.fill(0);
|
||||
}
|
||||
// B holds the beak open; quack itself fired on the press edge.
|
||||
this.axes.jaw = this.pressed.b ? 1 : 0;
|
||||
}
|
||||
|
||||
#on(el, type, fn) {
|
||||
el.addEventListener(type, fn);
|
||||
this.#disposers.push(() => el.removeEventListener(type, fn));
|
||||
}
|
||||
|
||||
#bindStick(zone, stick, nub) {
|
||||
let pointerId = null;
|
||||
let center = null; // stick center while grabbed, zone-local px
|
||||
const setFrom = (e) => {
|
||||
const zr = zone.getBoundingClientRect();
|
||||
const R = stick.offsetWidth / 2;
|
||||
const travel = R * 0.62; // max nub travel inside the base circle
|
||||
let dx = e.clientX - zr.left - center.x;
|
||||
let dy = e.clientY - zr.top - center.y;
|
||||
const d = Math.hypot(dx, dy);
|
||||
if (d > travel) { dx *= travel / d; dy *= travel / d; }
|
||||
nub.style.transform = `translate(${dx}px, ${dy}px)`;
|
||||
const nx = dx / travel, ny = -dy / travel; // up is +y
|
||||
const mag = Math.hypot(nx, ny);
|
||||
const live = mag >= TOUCH_DEADZONE;
|
||||
this.#target[0] = live ? nx : 0;
|
||||
this.#target[1] = live ? ny : 0;
|
||||
};
|
||||
const release = () => {
|
||||
pointerId = null;
|
||||
center = null;
|
||||
this.pressed.stick = false;
|
||||
stick.classList.remove("live");
|
||||
nub.style.transform = "";
|
||||
// Back to the CSS resting spot until the next grab.
|
||||
stick.style.left = "";
|
||||
stick.style.top = "";
|
||||
stick.style.bottom = "";
|
||||
this.#target[0] = 0;
|
||||
this.#target[1] = 0;
|
||||
};
|
||||
this.#on(zone, "pointerdown", (e) => {
|
||||
e.preventDefault();
|
||||
pointerId = e.pointerId;
|
||||
// Anchor the base exactly under the finger - a clamped anchor would
|
||||
// start the stick with a phantom deflection near the zone edges. The
|
||||
// circle clipping off-screen there is the standard floating-stick
|
||||
// look, and it takes no pointer events anyway.
|
||||
const zr = zone.getBoundingClientRect();
|
||||
const R = stick.offsetWidth / 2;
|
||||
center = { x: e.clientX - zr.left, y: e.clientY - zr.top };
|
||||
stick.style.left = `${center.x - R}px`;
|
||||
stick.style.top = `${center.y - R}px`;
|
||||
stick.style.bottom = "auto";
|
||||
this.pressed.stick = true;
|
||||
stick.classList.add("live");
|
||||
setFrom(e); // zero deflection at grab
|
||||
// Last: capture can throw on exotic pointers and must not eat the
|
||||
// press state above.
|
||||
try { zone.setPointerCapture(e.pointerId); } catch {}
|
||||
});
|
||||
this.#on(zone, "pointermove", (e) => {
|
||||
if (e.pointerId === pointerId) setFrom(e);
|
||||
});
|
||||
this.#on(zone, "pointerup", (e) => {
|
||||
if (e.pointerId === pointerId) release();
|
||||
});
|
||||
this.#on(zone, "pointercancel", (e) => {
|
||||
if (e.pointerId === pointerId) release();
|
||||
});
|
||||
}
|
||||
|
||||
#bindButton(elId, key, fire) {
|
||||
const el = document.getElementById(elId);
|
||||
if (!el) return;
|
||||
this.#on(el, "pointerdown", (e) => {
|
||||
e.preventDefault();
|
||||
this.pressed[key] = true;
|
||||
el.classList.add("down");
|
||||
fire(); // on the press edge, not the release: arcade latency
|
||||
try { el.setPointerCapture(e.pointerId); } catch {}
|
||||
});
|
||||
const release = () => {
|
||||
this.pressed[key] = false;
|
||||
el.classList.remove("down");
|
||||
};
|
||||
this.#on(el, "pointerup", release);
|
||||
this.#on(el, "pointercancel", release);
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -175,7 +175,10 @@ gl_FragColor.rgb += fxEdge * vec3(0.95, 0.32, 0.05);`,
|
||||
if (!isTargetMesh(o)) return;
|
||||
// Child of the source mesh with identity transform so the overlay
|
||||
// follows whatever pose the caller writes (duck joints or ball qpos).
|
||||
const w = new THREE.Mesh(o.geometry, wireMat);
|
||||
// userData.fxWireGeometry substitutes a coarser geometry for the
|
||||
// wireframe pass only (the ball's render sphere is too dense to read
|
||||
// as a hologram); the solidify clip still runs on the real mesh.
|
||||
const w = new THREE.Mesh(o.userData.fxWireGeometry ?? o.geometry, wireMat);
|
||||
w.userData.fxOverlay = true;
|
||||
w.renderOrder = 5;
|
||||
w.visible = false;
|
||||
|
||||
+167
-13
@@ -405,6 +405,104 @@
|
||||
#quickbar .dots button .dot { width: 1.2rem; height: 1.2rem; }
|
||||
#quickbar .seg button { height: 2rem; padding: 0 0.8rem; font-size: 0.68rem; }
|
||||
}
|
||||
/* Touch overlay: Game Boy thumbs, coarse-pointer devices only
|
||||
(rl.js mirrors the touch source's connected flag onto
|
||||
body.touch-mode). Left thumb = virtual stick, right thumb = A/B
|
||||
caps on the classic diagonal (A up-right, B down-left). */
|
||||
#touch-ui { display: none; }
|
||||
body.touch-mode #touch-ui { display: block; }
|
||||
/* Touch mode strips the HUD down to the thumbs: no quickbar, no mode
|
||||
readout, no telemetry - the stick and caps own the bottom edge.
|
||||
Back stays (top-left) to reach the menu. */
|
||||
body.touch-mode #quickbar,
|
||||
body.touch-mode #mode-wrap,
|
||||
body.touch-mode #ctrl-hz { display: none !important; }
|
||||
/* Floating-stick zone: the whole lower-left quadrant grabs the stick,
|
||||
and the base re-anchors under the finger wherever it lands. Sits
|
||||
BELOW the quickbar/back button in z so their taps still land; the
|
||||
resting stick inside marks the zone when idle. */
|
||||
#touch-zone {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 50%;
|
||||
top: 30%;
|
||||
bottom: 0;
|
||||
z-index: 9;
|
||||
touch-action: none;
|
||||
}
|
||||
#touch-stick {
|
||||
position: absolute;
|
||||
left: 1.3rem;
|
||||
bottom: 2rem;
|
||||
width: 8.2rem;
|
||||
height: 8.2rem;
|
||||
border-radius: 50%;
|
||||
border: 1px solid rgba(255, 255, 255, 0.18);
|
||||
background: rgba(8, 8, 12, 0.4);
|
||||
pointer-events: none; /* the zone owns the pointer */
|
||||
}
|
||||
#touch-stick .nub {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
width: 3.6rem;
|
||||
height: 3.6rem;
|
||||
margin: -1.8rem 0 0 -1.8rem;
|
||||
border-radius: 50%;
|
||||
border: 1px solid rgba(255, 255, 255, 0.35);
|
||||
background: rgba(255, 255, 255, 0.14);
|
||||
pointer-events: none;
|
||||
}
|
||||
#touch-stick.live { border-color: rgba(255, 122, 47, 0.55); }
|
||||
#touch-stick.live .nub {
|
||||
background: rgba(255, 122, 47, 0.45);
|
||||
border-color: var(--orange);
|
||||
}
|
||||
#touch-btns {
|
||||
position: fixed;
|
||||
right: 1.3rem;
|
||||
bottom: 2.2rem;
|
||||
z-index: 12;
|
||||
width: 9.4rem;
|
||||
height: 8.4rem;
|
||||
}
|
||||
#touch-btns .capwrap {
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
}
|
||||
#touch-btns .cap-a { right: 0; top: 0; }
|
||||
#touch-btns .cap-b { left: 0; bottom: 0; }
|
||||
#touch-btns button {
|
||||
appearance: none;
|
||||
width: 4.2rem;
|
||||
height: 4.2rem;
|
||||
border-radius: 50%;
|
||||
border: 1px solid rgba(255, 255, 255, 0.22);
|
||||
background: rgba(8, 8, 12, 0.5);
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
font: inherit;
|
||||
font-size: 1.3rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
#touch-btns button.down {
|
||||
background: var(--orange);
|
||||
border-color: var(--orange);
|
||||
color: var(--ink);
|
||||
}
|
||||
#touch-btns .capwrap span {
|
||||
font-size: 0.55rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.18em;
|
||||
text-transform: uppercase;
|
||||
color: rgba(255, 255, 255, 0.45);
|
||||
}
|
||||
/* Colour swatches */
|
||||
#swatches { gap: 0.6rem; }
|
||||
#swatches button {
|
||||
@@ -602,6 +700,7 @@
|
||||
body.welcome-open #stats-wrap,
|
||||
body.welcome-open #back-btn,
|
||||
body.welcome-open #quickbar,
|
||||
body.welcome-open #touch-ui,
|
||||
body.welcome-open #ctrl-hz { display: none !important; }
|
||||
/* ── Title / pause overlay (full viewport, no card) ────────────── */
|
||||
#welcome[hidden] { display: none; }
|
||||
@@ -633,9 +732,11 @@
|
||||
from { transform: translateY(10px) scale(0.94); opacity: 0; }
|
||||
to { transform: none; opacity: 1; }
|
||||
}
|
||||
/* Wide enough for the two-line title; the controls grid below keeps
|
||||
its own 36rem cap so the tiles don't stretch. */
|
||||
#welcome .wstep {
|
||||
width: 100%;
|
||||
max-width: 36rem;
|
||||
max-width: min(48rem, 92vw);
|
||||
text-align: center;
|
||||
}
|
||||
#welcome .wstep[hidden] { display: none; }
|
||||
@@ -719,7 +820,7 @@
|
||||
(600, tight tracking, line-height 1), the loudest line on the page. */
|
||||
#welcome .title {
|
||||
margin: 0 auto;
|
||||
max-width: 20ch;
|
||||
max-width: 24ch;
|
||||
font-size: clamp(2.4rem, 5vw, 3.75rem);
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.03em;
|
||||
@@ -748,14 +849,26 @@
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 0.55rem;
|
||||
margin-top: 1.4rem;
|
||||
margin: 1.4rem auto 0;
|
||||
max-width: 36rem;
|
||||
}
|
||||
#welcome .grid-pad { display: none; }
|
||||
body.pad-connected #welcome .grid-kb { display: none; }
|
||||
body.pad-connected #welcome .grid-pad { display: grid; }
|
||||
/* Touch device: the tutorial shows the two thumbs instead of the
|
||||
keycaps. A plugged-in gamepad still wins (pad rules below). */
|
||||
#welcome .grid-touch { display: none; }
|
||||
#welcome .touch-hint { display: none; }
|
||||
body.touch-mode #welcome .grid-kb { display: none; }
|
||||
body.touch-mode #welcome .grid-touch { display: grid; }
|
||||
body.touch-mode #welcome .kb-hint { display: none; }
|
||||
body.touch-mode #welcome .touch-hint { display: block; }
|
||||
#welcome .grid-touch kbd.cap { border-radius: 50%; min-width: 1.9rem; }
|
||||
#welcome .kb-hint { display: block; }
|
||||
#welcome .pad-hint { display: none; }
|
||||
body.pad-connected #welcome .kb-hint { display: none; }
|
||||
body.pad-connected #welcome .grid-kb,
|
||||
body.pad-connected #welcome .grid-touch { display: none; }
|
||||
body.pad-connected #welcome .grid-pad { display: grid; }
|
||||
body.pad-connected #welcome .kb-hint,
|
||||
body.pad-connected #welcome .touch-hint { display: none; }
|
||||
body.pad-connected #welcome .pad-hint { display: block; }
|
||||
#welcome .tile {
|
||||
padding: 0.85rem 0.45rem 0.75rem;
|
||||
@@ -860,6 +973,8 @@
|
||||
#welcome .title { font-size: 2rem; }
|
||||
#welcome .tagline { font-size: 0.95rem; }
|
||||
#welcome .grid { grid-template-columns: repeat(2, 1fr); }
|
||||
/* Three touch tiles hold one line even on a phone */
|
||||
#welcome .grid-touch { grid-template-columns: repeat(3, 1fr); }
|
||||
#welcome .tile { padding: 0.65rem 0.35rem 0.6rem; }
|
||||
#welcome .caps { height: 2.8rem; }
|
||||
#welcome .wbtn { font-size: 0.95rem; padding: 0.75rem 1.5rem; }
|
||||
@@ -889,6 +1004,19 @@
|
||||
<button type="button" data-loco="rollers" aria-pressed="false">Rollers</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="touch-ui">
|
||||
<div id="touch-zone"><div id="touch-stick"><div class="nub"></div></div></div>
|
||||
<div id="touch-btns">
|
||||
<div class="capwrap cap-a">
|
||||
<button type="button" id="touch-a" aria-label="Kick">A</button>
|
||||
<span>Kick</span>
|
||||
</div>
|
||||
<div class="capwrap cap-b">
|
||||
<button type="button" id="touch-b" aria-label="Quack">B</button>
|
||||
<span>Quack</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mode-wrap">
|
||||
<span class="caption">Mode</span>
|
||||
<div class="mode" id="mode-label"><span class="mode-text">Run</span></div>
|
||||
@@ -952,11 +1080,11 @@
|
||||
<span class="wbrand-name">MicroDuck</span>
|
||||
</div>
|
||||
<div class="facts">
|
||||
<span>$399</span>
|
||||
<span>Ships before Christmas 2026</span>
|
||||
<span>MuJoCo physics</span>
|
||||
<span>ONNX policies at 50 Hz</span>
|
||||
</div>
|
||||
<h1 class="title">A tiny biped you drive in the browser</h1>
|
||||
<p class="tagline">Same body, same policies as the real robot.</p>
|
||||
<h1 class="title">The Microduck simulator, live in your browser</h1>
|
||||
<p class="tagline">The exact same trained policies that drive the real robot.</p>
|
||||
<div class="grid grid-kb">
|
||||
<div class="tile">
|
||||
<div class="caps cluster">
|
||||
@@ -979,7 +1107,7 @@
|
||||
<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 class="t-hint">pop a fresh one</div>
|
||||
</div>
|
||||
<div class="tile">
|
||||
<div class="caps"><kbd>C</kbd></div>
|
||||
@@ -1011,7 +1139,7 @@
|
||||
<div class="tile">
|
||||
<div class="caps"><kbd>Y</kbd></div>
|
||||
<div class="t-name">Ball</div>
|
||||
<div class="t-hint">pop one in</div>
|
||||
<div class="t-hint">pop a fresh one</div>
|
||||
</div>
|
||||
<div class="tile">
|
||||
<div class="caps"><kbd>RS</kbd></div>
|
||||
@@ -1024,8 +1152,26 @@
|
||||
<div class="t-hint">stand up</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-touch">
|
||||
<div class="tile">
|
||||
<div class="caps"><kbd>Stick</kbd></div>
|
||||
<div class="t-name">Move</div>
|
||||
<div class="t-hint">left thumb</div>
|
||||
</div>
|
||||
<div class="tile">
|
||||
<div class="caps"><kbd class="cap">A</kbd></div>
|
||||
<div class="t-name">Kick</div>
|
||||
<div class="t-hint">tap it</div>
|
||||
</div>
|
||||
<div class="tile">
|
||||
<div class="caps"><kbd class="cap">B</kbd></div>
|
||||
<div class="t-name">Quack</div>
|
||||
<div class="t-hint">hold for beak</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="orbit-hint kb-hint">drag to orbit · scroll to zoom</p>
|
||||
<p class="orbit-hint pad-hint">R3 chase · RT quack</p>
|
||||
<p class="orbit-hint touch-hint">drag to orbit · pinch to zoom</p>
|
||||
</div>
|
||||
|
||||
<div class="foot">
|
||||
@@ -1133,6 +1279,14 @@
|
||||
window.addEventListener("gamepaddisconnected", pollPad);
|
||||
pollPad();
|
||||
|
||||
// Touch tutorial variant needs the class before rl.js boots; the
|
||||
// game loop keeps mirroring the same media query afterwards.
|
||||
const coarse = matchMedia("(pointer: coarse)");
|
||||
const pollTouch = () =>
|
||||
document.body.classList.toggle("touch-mode", coarse.matches);
|
||||
coarse.addEventListener("change", pollTouch);
|
||||
pollTouch();
|
||||
|
||||
// ── Menu open / close ────────────────────────────────────────────
|
||||
const open = () => {
|
||||
modal.hidden = false;
|
||||
@@ -1214,7 +1368,7 @@
|
||||
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 = "65"; // bump on rl.js changes to defeat heuristic caching
|
||||
const V = "67"; // 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}`);
|
||||
|
||||
@@ -51,10 +51,11 @@ const { VARIANTS, VARIANT_NAMES, materialHookFor, DEFAULT_VARIANT, applyVariant,
|
||||
// Input stack: a video-game-style Controller aggregating pluggable sources
|
||||
// (keyboard + gamepad today, touch later). controller.js documents the
|
||||
// source interface contract and the action vocabulary.
|
||||
const [{ Controller }, { KeyboardSource }, { GamepadSource }] = await Promise.all([
|
||||
const [{ Controller }, { KeyboardSource }, { GamepadSource }, { TouchSource }] = await Promise.all([
|
||||
import(signed(`./controls/controller.js?v=${SELF_V}`)),
|
||||
import(signed(`./controls/keyboard.js?v=${SELF_V}`)),
|
||||
import(signed(`./controls/gamepad.js?v=${SELF_V}`)),
|
||||
import(signed(`./controls/touch.js?v=${SELF_V}`)),
|
||||
]);
|
||||
|
||||
ort.env.wasm.wasmPaths = "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.27.0/dist/";
|
||||
@@ -528,7 +529,9 @@ const cmd = new Float32Array(CMD_SIZE); // [vx, vy, wz, head(4), body(6)]
|
||||
// section below, where the raw listeners historically attached.
|
||||
const kbSource = new KeyboardSource({ getVelocityLimits: () => velLims() });
|
||||
const padSource = new GamepadSource({ getVelocityLimits: () => velLims() });
|
||||
const controller = new Controller({ sources: [padSource, kbSource] });
|
||||
const touchSource = new TouchSource({ getVelocityLimits: () => velLims() });
|
||||
// Keyboard last: it reads zero when idle, so it doubles as the fallback.
|
||||
const controller = new Controller({ sources: [padSource, touchSource, kbSource] });
|
||||
// Right-stick camera state, read by renderStats before the camera-orbit
|
||||
// section below has evaluated.
|
||||
let padOrbitLive = false; // HUD: RS keycap lit while deflected
|
||||
@@ -1199,7 +1202,14 @@ ceremony = createCeremony({
|
||||
getRig: () => rig,
|
||||
grid, wallMats,
|
||||
syncRig, startCameraReset,
|
||||
setLocked: (v) => { inputLocked = v; controller.setLocked(v); },
|
||||
setLocked: (v) => {
|
||||
inputLocked = v;
|
||||
controller.setLocked(v);
|
||||
// A ball is always in play: pop one the moment the entrance or a
|
||||
// respawn ceremony hands control back (resets park the previous
|
||||
// ball, so this re-pops it fresh in front of the duck).
|
||||
if (!v && ball && !ballActive) spawnBall({ fromQueue: true });
|
||||
},
|
||||
flashReset: () => { resetFlashAt = performance.now(); },
|
||||
});
|
||||
// Soccer-ball look computed per pixel on the sphere itself, so there is
|
||||
@@ -1336,6 +1346,10 @@ const ballMesh = new THREE.Mesh(
|
||||
}),
|
||||
);
|
||||
ballMesh.userData.meshName = "ball";
|
||||
// The 48x32 render sphere is far too dense for the wireframe scan (it
|
||||
// reads as a solid glowing blob); the FX overlay uses this geodesic
|
||||
// stand-in instead - 80 triangles, clean hologram lines.
|
||||
ballMesh.userData.fxWireGeometry = new THREE.IcosahedronGeometry(BALL_RADIUS, 1);
|
||||
ballMesh.visible = false;
|
||||
ballGroup.add(ballMesh);
|
||||
scene.add(ballGroup);
|
||||
@@ -1854,6 +1868,7 @@ function loop() {
|
||||
controller.update(dt);
|
||||
padJaw = controller.getAxes().jaw;
|
||||
document.body.classList.toggle("pad-connected", padSource.connected);
|
||||
document.body.classList.toggle("touch-mode", touchSource.connected);
|
||||
// Camera orbit runs every frame while a pad is present (the coasting
|
||||
// needs the zero-deflection frames too); without a pad, park the state.
|
||||
if (padSource.connected) {
|
||||
|
||||
Reference in New Issue
Block a user