feat: jukebox corner prop materializing with the ceremony
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -37,3 +37,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.wav filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.webp filter=lfs diff=lfs merge=lfs -text
|
||||
*.glb filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
BIN
Binary file not shown.
+65
@@ -38,6 +38,12 @@ export function createCeremony({
|
||||
|
||||
let fxRig = null;
|
||||
let fxPrev = null;
|
||||
// Decorative props (addPropFx): each owns a wireframe FX bound to its
|
||||
// own root. They cue whenever the duck's scan cues (entrance and every
|
||||
// respawn), offset by their stagger, and drive on their OWN clock so a
|
||||
// late-finishing prop never extends the input lock or the ceremony's
|
||||
// completion checks.
|
||||
const props = []; // { fx, delayS, at, started, prev }
|
||||
let entranceT0 = null;
|
||||
let entranceFxCued = false;
|
||||
let entranceDone = false;
|
||||
@@ -60,6 +66,54 @@ export function createCeremony({
|
||||
bind();
|
||||
fx.start();
|
||||
fxPrev = performance.now();
|
||||
propsCue();
|
||||
}
|
||||
function propsCue() {
|
||||
const now = performance.now();
|
||||
for (const p of props) {
|
||||
p.at = now + p.delayS * 1000;
|
||||
p.started = false;
|
||||
p.prev = null;
|
||||
}
|
||||
}
|
||||
function propsHide() {
|
||||
for (const p of props) {
|
||||
p.fx.setProgress(0);
|
||||
p.at = null;
|
||||
p.started = false;
|
||||
}
|
||||
}
|
||||
function propsFinish() {
|
||||
for (const p of props) {
|
||||
if (!p.started) p.fx.start();
|
||||
p.fx.update(1e3);
|
||||
p.at = null;
|
||||
}
|
||||
}
|
||||
// Deterministic screenshot/test hook (setFx): park every prop at the
|
||||
// same scan progress as the duck, detached from the timed driver.
|
||||
function propsSetProgress(v) {
|
||||
for (const p of props) {
|
||||
p.fx.setProgress(v);
|
||||
p.at = null;
|
||||
p.started = false;
|
||||
}
|
||||
}
|
||||
function driveProps() {
|
||||
const now = performance.now();
|
||||
for (const p of props) {
|
||||
if (p.at === null || now < p.at) continue;
|
||||
if (!p.started) {
|
||||
p.fx.start();
|
||||
p.started = true;
|
||||
p.prev = now;
|
||||
continue;
|
||||
}
|
||||
if (p.fx.isDone()) continue;
|
||||
const dt = Math.min((now - p.prev) / 1000, 0.25);
|
||||
p.prev = now;
|
||||
p.fx.update(dt);
|
||||
}
|
||||
}
|
||||
function fxDrive() {
|
||||
if (fxPrev === null || fx.isDone()) return;
|
||||
@@ -111,6 +165,7 @@ export function createCeremony({
|
||||
startCameraReset();
|
||||
syncRig();
|
||||
fx.setProgress(0);
|
||||
propsHide();
|
||||
respawn = { t0: performance.now(), scanCued: false };
|
||||
}
|
||||
|
||||
@@ -131,6 +186,7 @@ export function createCeremony({
|
||||
function drive() {
|
||||
driveEntrance();
|
||||
driveRespawn();
|
||||
driveProps();
|
||||
}
|
||||
|
||||
function setReveal(floor, wall = floor) {
|
||||
@@ -146,13 +202,21 @@ export function createCeremony({
|
||||
if (p >= 1) {
|
||||
fx.start();
|
||||
fxForceFinish();
|
||||
propsFinish();
|
||||
setLocked(false);
|
||||
entranceFinishedResolve();
|
||||
} else {
|
||||
fx.setProgress(p);
|
||||
propsSetProgress(p);
|
||||
}
|
||||
}
|
||||
|
||||
// Register a decorative prop's wireframe FX (already init'd on its own
|
||||
// root, hidden). It materializes delayS after each duck scan cue.
|
||||
function addPropFx(propFx, delayS = 0) {
|
||||
props.push({ fx: propFx, delayS, at: null, started: false, prev: null });
|
||||
}
|
||||
|
||||
// Boot hidden: clip parked below the feet from the first frame.
|
||||
bind();
|
||||
|
||||
@@ -164,6 +228,7 @@ export function createCeremony({
|
||||
bind,
|
||||
setReveal,
|
||||
setFx,
|
||||
addPropFx,
|
||||
entranceFinished,
|
||||
get entranceDone() { return entranceDone; },
|
||||
get respawnActive() { return respawn !== null; },
|
||||
|
||||
+1
-1
@@ -1376,7 +1376,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 = "68"; // bump on rl.js changes to defeat heuristic caching
|
||||
const V = "70"; // 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}`);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
import * as THREE from "three";
|
||||
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
||||
import { RoomEnvironment } from "three/addons/environments/RoomEnvironment.js";
|
||||
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
||||
import loadMujoco from "https://cdn.jsdelivr.net/npm/@mujoco/mujoco@3.11.0/mujoco.js";
|
||||
import * as ort from "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.27.0/dist/ort.min.mjs";
|
||||
|
||||
@@ -1359,6 +1360,50 @@ ball = createBallActor({
|
||||
THREE, scene, camera, renderer, fxModule: fx, mesh: ballMesh, group: ballGroup,
|
||||
});
|
||||
|
||||
// ── Jukebox prop (decorative corner dressing, no physics) ────────────────
|
||||
// assets/props/jukebox.glb carries two meshes exported from Blender: the
|
||||
// ~39k-tri render mesh and a 500-tri "jukebox_wire" stand-in used only by
|
||||
// the hologram pass (same fxWireGeometry escape hatch as the ball - the
|
||||
// full mesh reads as a solid glowing blob). It materializes with the
|
||||
// duck's ceremony, staggered a beat behind, and replays on every respawn.
|
||||
const JUKEBOX_H = 0.42; // target height, m: playground-prop scale next to the 0.25 m duck
|
||||
const JUKEBOX_MARGIN = 0.24; // center distance from each wall inner face
|
||||
let jukeboxGroup = null; // exposed on window.rl for placement tweaks
|
||||
try {
|
||||
const gltf = await new GLTFLoader().loadAsync(
|
||||
signed(`./assets/props/jukebox.glb?v=${SELF_V}`),
|
||||
);
|
||||
const jukebox = gltf.scene;
|
||||
const jukeWire = jukebox.getObjectByName("jukebox_wire");
|
||||
jukeWire.removeFromParent();
|
||||
// Normalize whatever scale/centering the export carries: JUKEBOX_H tall,
|
||||
// resting on the floor. The wire proxy shares the render mesh's local
|
||||
// space, so it needs no transform of its own.
|
||||
const jukeBox3 = new THREE.Box3().setFromObject(jukebox);
|
||||
const jukeScale = JUKEBOX_H / (jukeBox3.max.y - jukeBox3.min.y);
|
||||
jukebox.scale.setScalar(jukeScale);
|
||||
jukebox.position.y = -jukeBox3.min.y * jukeScale;
|
||||
jukebox.traverse((o) => {
|
||||
if (o.isMesh) o.userData.fxWireGeometry = jukeWire.geometry;
|
||||
});
|
||||
const jukeGroup = new THREE.Group();
|
||||
jukeGroup.add(jukebox);
|
||||
// Back corner, behind the spawn (the duck faces +X), angled toward the
|
||||
// center of the arena so the front panel reads from the play area.
|
||||
jukeGroup.position.set(
|
||||
-(ARENA_HALF - JUKEBOX_MARGIN), 0, -(ARENA_HALF - JUKEBOX_MARGIN),
|
||||
);
|
||||
jukeGroup.rotation.y = Math.PI / 4;
|
||||
scene.add(jukeGroup);
|
||||
jukeboxGroup = jukeGroup;
|
||||
const jukeFx = fx.createWireframeFx();
|
||||
jukeFx.init({ THREE, scene, root: jukeGroup, camera, renderer, hidden: true });
|
||||
ceremony.addPropFx(jukeFx, 0.25);
|
||||
} catch (err) {
|
||||
// Decorative only: a missing/broken GLB must never halt the boot.
|
||||
console.warn("[rl] jukebox prop disabled:", err);
|
||||
}
|
||||
|
||||
// Comic sticker popups on game events (kick / quack / roll / ball spawn /
|
||||
// ghost join). Fully self-contained DOM overlay: delete this import to
|
||||
// remove the feature (the `stickers?.pop` hooks then no-op).
|
||||
@@ -2129,6 +2174,7 @@ window.rl = {
|
||||
get ballQposAdr() { return ballQposAdr; },
|
||||
get chaseCam() { return chaseCam; },
|
||||
set chaseCam(v) { chaseCam = !!v; },
|
||||
get jukebox() { return jukeboxGroup; },
|
||||
get camResetActive() { return camResetT0 !== null; },
|
||||
get respawnActive() { return ceremony?.respawnActive ?? false; },
|
||||
get camPose() {
|
||||
|
||||
Reference in New Issue
Block a user