fix: freeze chase-cam heading during rolls and kicks

The trunk tumbles through a roll (and shakes during kicks), so the yaw
extracted from its quaternion spins wildly and whipped the chase camera
around. The chase now lazily latches the last healthy yaw and holds it
for the whole one-shot; position/target easing still follows the trunk.
No timers: both one-shots deterministically hand back to walk, where
live yaw tracking resumes and the position lerp absorbs the small
heading correction. Measured over a full roll: 180 deg trunk-yaw
excursion, 0.2 deg camera azimuth swing.

Cache-buster bumped to 28.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
tfrere
2026-08-20 14:46:57 +02:00
parent 7b7c537426
commit 6b3d5da93a
2 changed files with 19 additions and 5 deletions
+1 -1
View File
@@ -476,7 +476,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 = "27"; // bump on rl.js changes to defeat heuristic caching
const V = "28"; // 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}`);
+18 -4
View File
@@ -627,13 +627,27 @@ const CHASE_PITCH = 0.42; // rad above horizontal, keeps the floor in view
const CHASE_EASE = 0.05; // exponential ease, cinematic on turns
const _chasePos = new THREE.Vector3();
const _chaseDir = new THREE.Vector3();
// During one-shot rolls and kicks the trunk tumbles, so the yaw read from
// its quaternion spins wildly and would whip the camera around. Lazily
// latch the last healthy yaw while walking/sitting and hold it for the
// whole one-shot; the position/target easing keeps following the trunk.
// No timers needed: both one-shots deterministically hand back to walk,
// and the camera position lerp absorbs the small heading correction when
// live tracking resumes (rolls end facing roughly the same way).
let chaseHeldYaw = 0;
function updateChaseCam() {
if (!chaseCam) return;
const qpos = data.qpos;
const yaw = Math.atan2(
2 * (qpos[3] * qpos[6] + qpos[4] * qpos[5]),
1 - 2 * (qpos[5] * qpos[5] + qpos[6] * qpos[6]),
);
let yaw;
if (mode === "roll" || isKick()) {
yaw = chaseHeldYaw;
} else {
yaw = Math.atan2(
2 * (qpos[3] * qpos[6] + qpos[4] * qpos[5]),
1 - 2 * (qpos[5] * qpos[5] + qpos[6] * qpos[6]),
);
chaseHeldYaw = yaw;
}
const dist = camera.position.distanceTo(controls.target);
const horiz = dist * Math.cos(CHASE_PITCH);
const vert = dist * Math.sin(CHASE_PITCH);