Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
render CyberCity's explore-mode player with the bundled RobotExpressive GLB
[._.]/ Adam Eivy6bc806e5a9f2
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdnew file mode 100644index 0000000000..65fe197544--- /dev/null+++ b/.changelog/NEXT.md@@ -0,0 +1,6 @@+# Unreleased Changes++## Changed++- CyberCity exploration mode now renders the player character using the bundled rigged GLB avatar (three.js's RobotExpressive, the same `data/avatar/model.glb` the CoS "Cyber Muse" avatar uses) instead of the hand-built procedural cyber-runner. Skeletal clips crossfade off the movement rig's state: `idle` → Idle, `walk` → Walking, `run` → Running, `hover` → Jump. Walking/Running are routed to their neutralized "in place" treadmill variants (the rig owns world position), and the runner keeps its own textures with a themed accent ground-glow footprint. The GLB avatar is Suspense- and error-boundary-wrapped so a streaming or missing model degrades to "no visible runner" instead of blanking or crashing the city canvas.+- CyberCity exploration mode now supports jumping with the Space bar — a gravity-based hop (E/Q free-fly still takes precedence). In exploration mode Space is captured before it reaches the global voice push-to-talk hotkey, so jumping no longer toggles the voice agent.diff --git a/PLAN.md b/PLAN.mdindex d35965d2b0..100ab035c0 100644--- a/PLAN.md+++ b/PLAN.md@@ -205,6 +205,8 @@ by `/do:replan --issues`:- [ ] **Unify `MUSE_STATE_ANIMATIONS` (single-clip base loops) and `MUSE_STATE_SEQUENCES` (montages) into one `state → ordered steps` map.** Today `client/src/components/cos/constants.js` keeps two parallel maps: a single base-clip per state (`MUSE_STATE_ANIMATIONS`, step shape `{clip,timeScale,once}`) and an optional montage (`MUSE_STATE_SEQUENCES`, step shape `{clip,timeScale,reps}`). `MuseCoSAvatar.jsx` then forks base-vs-sequence in the state effect (`resumeMotion`), the `finished` listener, and `sequenceSteps`/`baseClip` resolution. A single looping clip is just a length-1 montage, so the two could collapse to one map `state → [{ clip, timeScale, loop: 'infinite' | 'once' | {reps: N} }]`: single-clip states become length-1 lists (`loop:'infinite'`), `coding` is a longer list, and the "montage's fallback is the base clip" relationship becomes structural (filter steps to present clips; if only one survives, play it looping) instead of prose-enforced (the current comment in constants.js says "keep every entry mapped… also the graceful fallback"). This would delete `MUSE_STATE_SEQUENCES` as a separate concept and remove the base-vs-sequence forks in the driver. Deferred from the `/simplify` pass on the avatar montage PR: it's a redesign of a state machine that was already visually verified (montage cycling + speaking-gesture defer/restore + fallback), so it warrants its own PR + a re-verification pass rather than riding on the cleanup. Consumers to update: `MuseCoSAvatar.jsx`, `constants.test.js`, `data.reference/avatar/README.md` (only in-repo references).+- [ ] **Extract the shared rigged-GLB avatar boilerplate now that there are three consumers.** `client/src/components/cos/MuseCoSAvatar.jsx`, `client/src/components/cos/MiniCharacterCoSAvatar.jsx`, and (as of the CyberCity player swap) `client/src/components/city/PlayerAvatar.jsx` each independently: (a) `useGLTF(url)` + `useMemo(() => SkeletonUtils.clone(gltf.scene), [gltf.scene])` with the identical copy-pasted "rebind SkinnedMeshes" rationale comment; (b) fit the model to a target height via `Box3().setFromObject → getSize/getCenter → scale = TARGET_HEIGHT / Math.max(size.y, 1e-3)` (Muse centers vertically `-center.y*scale+0.05`; Mini and Player rest feet on ground via `-box.min.y*scale` — already drifting); (c) run a `fadeTo` crossfade (`reset/enabled/setEffectiveTimeScale/setEffectiveWeight/setLoop/fadeIn` + `prev.fadeOut`, guard `prev !== next`). Fix shape: a `useRiggedGLTF(url)` hook (load + clone + `withInPlaceClips` + `useAnimations`, returning `{ scene, actions, names, mixer }`) in `client/src/hooks`, and a pure `fitModelToHeight(scene, { targetHeight, feetOnGround })` helper in `client/src/utils` returning `{ scale, x, y, z }`; a low-level `crossfade(actions, activeRef, name, { timeScale, fade })` primitive is a weaker candidate (Muse's version carries montage `once`/`reps` branching the others don't want). Deferred from the `/simplify` pass on the CyberCity player swap: touches two CoS avatar components well outside that diff, and each new public module needs its barrel + README row + index-test coverage (the `client/src/hooks`/`utils` maintenance rule). The one cheap piece was done in-diff — PlayerAvatar imports the shared `MUSE_ROOT_MOTION_CLIPS`/`MUSE_IN_PLACE_SUFFIX` rather than redeclaring them.+### Creative Director agents should not push code (deferred — needs a distinct completion contract)- [ ] **Suppress `/simplify` + `/do:push` + PR in CD agent completions WITHOUT breaking their API output contract.** CD plan/treatment/evaluation agents persist their real output via an HTTP call in the task BODY (e.g. `PATCH http://localhost:5555/api/creative-director/{id}/plan` — see the plan prompt), and use the `.agent-done` sentinel only as a *done-signal* (a short markdown summary that PortOS's 2s poll consumes to finalize the run). They run on `main` (`useWorktree:false`, `configCodingOnMain:true`) and make no repo changes, so the trailing `/simplify` → `/do:push` completion is both pointless and dangerous (a `/do:push` on main could commit stray working-tree files). The fix must remove `/simplify`+`/do:push`+PR from the CD completion while KEEPING (a) the sentinel done-signal handshake and (b) the task-body PATCH as the output channel. **Do NOT reuse `discardWorktree`** — codex review (2026-07-16) correctly flagged that it routes to `buildProgrammaticOutputCompletionSection`, whose wording ("your *only* output channel is the `.agent-done` sentinel; write your result there in the payload format from your instructions") directly contradicts the PATCH and could make the agent write the plan to the sentinel instead of PATCHing → plan never persists → project stalls/re-enqueues. `readOnly:true` is also wrong ("read data and report findings only" contradicts the PATCH, and the CLI read-only path emits no sentinel). The correct fix is a NEW completion contract (e.g. a `apiOutput`/`noRepoOutput` metadata flag) that emits: "This task persists its output via the API/tool calls described above and makes no repo changes — do NOT run `/simplify`, `/do:push`, `/do:pr`, `git commit/push`, or open a PR; when done write a short summary to the sentinel to signal completion." Thread the flag through the completion selection in `server/services/agentPromptBuilder.js` (lines ~1137-1160 light path + the full-context path ~790, and whichever of `buildTuiCompletionSection`/`buildCliCompletionSection` CD actually reaches — confirm via a regenerated CD prompt fixture) and add a test asserting the CD prompt contains the sentinel step but NO `/do:push`/`/do:pr`/`/simplify`. Deferred from this PR because it needs a carefully-designed prompt-contract change + fixture test, not a rushed flag reuse.diff --git a/client/src/components/city/PlayerAvatar.jsx b/client/src/components/city/PlayerAvatar.jsxindex 64e076cee8..b9478d3ca1 100644--- a/client/src/components/city/PlayerAvatar.jsx+++ b/client/src/components/city/PlayerAvatar.jsx@@ -1,231 +1,184 @@-import { useRef, useMemo, useEffect } from 'react';+import { useRef, useMemo, useEffect, useCallback } from 'react';import { useFrame } from '@react-three/fiber';+import { useGLTF, useAnimations } from '@react-three/drei';import * as THREE from 'three';+import { SkeletonUtils } from 'three-stdlib';import { useCityPalette } from './CityPaletteContext';-import { dampFactor, dampAngle, EYE_HEIGHT } from '../../utils/cityPlayerRig';--// The exploration-mode cyber-runner: a stylized articulated character (~1.7 units tall)-// rendered in third person. Reads the PlayerController's mutable rig every frame — no-// React state on the hot path — and animates by rig.state:-// idle — soft bob, visor breathing, slow head scan-// walk — opposing hip/shoulder swing with elbow/knee follow-through-// run — faster phase, bigger amplitude, torso pitched into the sprint-// hover — flyover: legs tuck, jet vents flare, glow disc brightens (a flying runner,-// not a mid-air walker)-// Body color tracks the theme's structural dark; visor/trim/soles glow the theme accent.-// Geometry is shared at module scope; materials are per-mount (theme-tinted).--const EYE_COLOR = '#ff3366'; // semantic sensor red — not themed--const GEO = {- helmet: new THREE.IcosahedronGeometry(0.16, 1),- visor: new THREE.BoxGeometry(0.26, 0.07, 0.08),- sensor: new THREE.BoxGeometry(0.05, 0.02, 0.02),- torso: new THREE.BoxGeometry(0.42, 0.5, 0.26),- core: new THREE.CylinderGeometry(0.09, 0.09, 0.03, 6),- pauldron: new THREE.OctahedronGeometry(0.12, 0),- upperArm: new THREE.CylinderGeometry(0.05, 0.045, 0.28, 6),- forearm: new THREE.CylinderGeometry(0.045, 0.04, 0.26, 6),- fist: new THREE.SphereGeometry(0.055, 6, 6),- pelvis: new THREE.BoxGeometry(0.3, 0.16, 0.2),- thigh: new THREE.CylinderGeometry(0.06, 0.055, 0.32, 6),- shin: new THREE.CylinderGeometry(0.05, 0.045, 0.3, 6),- boot: new THREE.BoxGeometry(0.11, 0.08, 0.22),- sole: new THREE.BoxGeometry(0.11, 0.02, 0.22),- backUnit: new THREE.BoxGeometry(0.22, 0.28, 0.1),- vent: new THREE.CylinderGeometry(0.035, 0.05, 0.1, 6),- disc: new THREE.CircleGeometry(0.45, 18),+import { dampFactor, EYE_HEIGHT } from '../../utils/cityPlayerRig';+import { withInPlaceClips, inPlaceClipName } from '../../utils/animationClips';+// The root-motion clip set + treadmill suffix are model-level facts about the bundled+// RobotExpressive GLB, so import the single source of truth rather than redeclaring it —+// a divergent copy would silently break in-place routing in one avatar and not the other.+import { MUSE_ROOT_MOTION_CLIPS as ROOT_MOTION_CLIPS, MUSE_IN_PLACE_SUFFIX as IN_PLACE_SUFFIX } from '../cos/constants';++// The exploration-mode player, rendered in third person with the bundled rigged GLB+// (three.js's RobotExpressive by default — data/avatar/model.glb, the same model the CoS+// "Cyber Muse" avatar uses). The character keeps its own textures/colors; the only city+// tint is a themed ground-glow disc under its feet so it still reads as "our runner."+//+// It reads the PlayerController's mutable rig every frame (no React state on the hot path)+// and crossfades the GLB's skeletal clips by rig.state:+// idle → Idle+// walk → Walking (in place)+// run → Running (in place)+// hover → Jump (flyover: legs off the ground, body floated toward the camera anchor)+// Walking/Running carry root translation (they'd walk the model out from under the rig,+// which OWNS world position); we route them to the synthesized "in place" treadmill+// variants (see withInPlaceClips) so the gait animates while the rig drives movement.++const MODEL_URL = '/api/avatar/model.glb';+const TARGET_HEIGHT = 1.7; // world units, matches the old procedural runner+const FADE = 0.25; // crossfade seconds between state clips+// The bundled RobotExpressive model is authored facing +Z; the rig's forward is -Z+// (rig.facing 0 → -z), so we add a 180° yaw so the runner faces its travel direction.+// If a user swaps in a GLB with a different forward axis, the runner would face the wrong+// way — this offset is the one model-orientation assumption, called out so it's greppable.+const MODEL_FACING_OFFSET = Math.PI;++// rig.state → { desired GLB clip, playback rate }. The clip is auto-routed to its+// in-place variant when it's a root-motion clip. Rates lean a touch fast so the gait+// reads energetic and foot-skate against the rig's move speed stays subtle.+const STATE_CLIP = {+ idle: { clip: 'Idle', timeScale: 1.0 },+ walk: { clip: 'Walking', timeScale: 1.3 },+ run: { clip: 'Running', timeScale: 1.5 },+ hover: { clip: 'Jump', timeScale: 1.0 },};-GEO.helmet.computeVertexNormals();--// Joint heights (feet at 0): knee 0.31, hip 0.76, torso center 1.08, shoulder 1.3, head 1.55.-const HIP_Y = 0.76;-const SHOULDER_Y = 1.3;export default function PlayerAvatar({ rigRef }) {- const { accent, buildingBody, tintStructure } = useCityPalette();-- // Theme-tinted materials. Trim/visor glow the accent; the animated ones (visor, vents,- // disc) are separate instances so per-frame intensity writes don't bleed across parts.- const mats = useMemo(() => {- const body = new THREE.MeshStandardMaterial({- color: buildingBody, roughness: 0.45, metalness: 0.5, flatShading: true,- });- const dark = new THREE.MeshStandardMaterial({- color: tintStructure('#0b101e'), roughness: 0.6, metalness: 0.4,- });- const trim = new THREE.MeshStandardMaterial({- color: accent, emissive: accent, emissiveIntensity: 0.55, toneMapped: false,- roughness: 0.3, metalness: 0.3,- });- const visor = trim.clone();- const vents = new THREE.MeshStandardMaterial({- color: accent, emissive: accent, emissiveIntensity: 0.0, toneMapped: false,- });- const sensor = new THREE.MeshBasicMaterial({ color: EYE_COLOR, toneMapped: false });- const disc = new THREE.MeshBasicMaterial({- color: accent, transparent: true, opacity: 0.16,- blending: THREE.AdditiveBlending, depthWrite: false, side: THREE.DoubleSide,- });- return { body, dark, trim, visor, vents, sensor, disc };- }, [accent, buildingBody, tintStructure]);-- // R3F doesn't dispose materials handed in via the `material` prop — free the prior- // set when a theme switch rebuilds them, and on unmount.- useEffect(() => () => { Object.values(mats).forEach((m) => m.dispose()); }, [mats]);+ const { accent } = useCityPalette();+ const gltf = useGLTF(MODEL_URL);++ // SkeletonUtils.clone rebinds SkinnedMeshes to the cloned skeleton so the mixer+ // actually deforms the visible mesh (a plain scene.clone would animate bones the+ // rendered mesh no longer references). Memoized on the source scene.+ const scene = useMemo(() => SkeletonUtils.clone(gltf.scene), [gltf.scene]);++ // Append neutralized in-place variants of the root-motion clips so walk/run cycle+ // the legs without translating the model off the rig-driven position.+ const animations = useMemo(+ () => withInPlaceClips(gltf.animations, ROOT_MOTION_CLIPS, IN_PLACE_SUFFIX),+ [gltf.animations]+ );+ const { actions, names } = useAnimations(animations, scene);+ const hasClips = names.length > 0;const rootRef = useRef();- const headRef = useRef();- const torsoRef = useRef();- const hipL = useRef();- const hipR = useRef();- const kneeL = useRef();- const kneeR = useRef();- const shoulderL = useRef();- const shoulderR = useRef();- const elbowL = useRef();- const elbowR = useRef();- const phaseRef = useRef(0);const groundOffsetRef = useRef(-EYE_HEIGHT);+ const activeClipRef = useRef(null);+ const discMatRef = useRef();++ // Fit the model to TARGET_HEIGHT with feet at y=0 and centered on x/z, mutating the+ // scene directly. This MUST run in an effect (not a render-time useMemo): the bounding+ // box is only correct after useAnimations has set up the skeleton/mixer — measuring+ // during render sees an unposed rig and yields a wildly wrong (≈34×) size, shrinking the+ // model to an invisible speck. Frustum culling is off because animated poses (jump, arms+ // out) exceed the bind-pose box; shadows off to match the CoS avatar. Runs once per+ // loaded scene (absolute transform — re-running on state changes would pop the size).+ useEffect(() => {+ scene.traverse((obj) => {+ if (!obj.isMesh) return;+ obj.frustumCulled = false;+ obj.castShadow = false;+ obj.receiveShadow = false;+ });+ const box = new THREE.Box3().setFromObject(scene);+ const size = box.getSize(new THREE.Vector3());+ const center = box.getCenter(new THREE.Vector3());+ const scale = TARGET_HEIGHT / Math.max(size.y, 1e-3);+ scene.scale.setScalar(scale);+ scene.position.set(-center.x * scale, -box.min.y * scale, -center.z * scale);+ }, [scene]);++ // Precompute each rig.state → the concrete clip present on the loaded GLB (root-motion →+ // in-place variant; fall back through the routed name → Idle → first clip). This only+ // depends on the loaded clip set, so resolving it once here keeps the per-frame loop to a+ // single object lookup instead of re-scanning `names` every frame.+ const clipByState = useMemo(() => {+ if (!hasClips) return null;+ const resolve = (state) => {+ const wanted = (STATE_CLIP[state] || STATE_CLIP.idle).clip;+ const routed = inPlaceClipName(wanted, ROOT_MOTION_CLIPS, IN_PLACE_SUFFIX);+ if (names.includes(routed)) return routed;+ if (names.includes('Idle')) return 'Idle';+ return names[0] || null;+ };+ return Object.fromEntries(Object.keys(STATE_CLIP).map((s) => [s, resolve(s)]));+ }, [hasClips, names]);++ // Crossfade to `clipName` at the given rate. No-op if it's already the active clip,+ // so this is safe to call every frame.+ const fadeTo = useCallback((clipName, timeScale) => {+ if (!clipName || clipName === activeClipRef.current) return;+ const next = actions[clipName];+ if (!next) return;+ const prev = actions[activeClipRef.current];+ next.reset();+ next.enabled = true;+ next.setEffectiveTimeScale(timeScale ?? 1);+ next.setEffectiveWeight(1);+ next.setLoop(THREE.LoopRepeat, Infinity);+ next.fadeIn(FADE).play();+ if (prev && prev !== next) prev.fadeOut(FADE);+ activeClipRef.current = clipName;+ }, [actions]);useFrame(({ clock }, delta) => {const root = rootRef.current;const rig = rigRef?.current;if (!root || !rig) return;- const t = clock.getElapsedTime();const f = dampFactor(8, delta);const state = rig.state;const hovering = state === 'hover';- const running = state === 'run';- const moving = state === 'walk' || running;- // Root follows the rig: feet on the ground normally; in hover the body floats- // closer to the camera anchor with legs tucked.+ // Root follows the rig: feet on the ground normally (rig.position.y is eye height, so+ // subtract EYE_HEIGHT to drop the feet to the plane); in hover the body floats up+ // toward the camera anchor with a gentle bob so a flyover reads as airborne.+ const t = clock.getElapsedTime();const targetOffset = hovering ? -1.05 : -EYE_HEIGHT;groundOffsetRef.current += (targetOffset - groundOffsetRef.current) * f;- const bob = state === 'idle' ? Math.sin(t * 1.6) * 0.03 : hovering ? Math.sin(t * 2.2) * 0.06 : 0;+ const bob = hovering ? Math.sin(t * 2.2) * 0.06 : 0;root.position.set(rig.position.x, rig.position.y + groundOffsetRef.current + bob, rig.position.z);- // The avatar geometry is modeled facing +Z (visor/chest/toes at +z, jet vents at -z),- // but the rig's forward convention is -Z (rig.facing's 0 points toward -z). Bridge the- // model-vs-rig 180° with a +π yaw offset so the runner faces its direction of travel- // instead of walking backward toward the camera.- root.rotation.y = rig.facing + Math.PI;- root.rotation.z = rig.bank;-- // Gait phase advances while moving, settles to neutral at rest.- if (moving) phaseRef.current += delta * (running ? 14 : 9);- else phaseRef.current *= 1 - Math.min(1, f * 1.4);- const amp = running ? 0.9 : 0.55;- const swing = moving ? Math.sin(phaseRef.current) * amp : 0;- const counter = -swing;-- const lerpRot = (ref, x) => {- if (ref.current) ref.current.rotation.x += (x - ref.current.rotation.x) * f;- };- if (hovering) {- // Tuck: thighs forward, knees folded, arms slightly out and back.- lerpRot(hipL, 0.65);- lerpRot(hipR, 0.65);- lerpRot(kneeL, -1.2);- lerpRot(kneeR, -1.2);- lerpRot(shoulderL, -0.35);- lerpRot(shoulderR, -0.35);- lerpRot(elbowL, -0.5);- lerpRot(elbowR, -0.5);- } else {- // Gait: hips/shoulders oppose; knees and elbows follow through a half-beat later.- const follow = moving ? Math.max(0, Math.sin(phaseRef.current + 0.5)) * amp * 0.9 : 0;- const followR = moving ? Math.max(0, Math.sin(phaseRef.current + Math.PI + 0.5)) * amp * 0.9 : 0;- const elbowBase = running ? -0.8 : moving ? -0.3 : -0.12;- lerpRot(hipL, swing);- lerpRot(hipR, counter);- lerpRot(kneeL, -follow);- lerpRot(kneeR, -followR);- lerpRot(shoulderL, counter * 0.8);- lerpRot(shoulderR, swing * 0.8);- lerpRot(elbowL, elbowBase - Math.max(0, counter) * 0.4);- lerpRot(elbowR, elbowBase - Math.max(0, swing) * 0.4);- }+ // Face the travel direction (see MODEL_FACING_OFFSET); bank leans into turns.+ root.rotation.y = rig.facing + MODEL_FACING_OFFSET;+ root.rotation.z = rig.bank;- // Torso pitches into a sprint; head scans slowly at idle.- if (torsoRef.current) {- torsoRef.current.rotation.x += ((running ? 0.18 : hovering ? -0.1 : 0) - torsoRef.current.rotation.x) * f;- }- if (headRef.current) {- const scan = state === 'idle' ? Math.sin(t * 0.4) * 0.22 : 0;- headRef.current.rotation.y = dampAngle(headRef.current.rotation.y, scan, f);+ // Drive the skeleton from the mutable rig state (crossfades only on change).+ if (clipByState) {+ const cfg = STATE_CLIP[state] || STATE_CLIP.idle;+ fadeTo(clipByState[state] || clipByState.idle, cfg.timeScale);}- // Emissive life: visor breathes at idle, vents flare in hover, disc brightens in hover.- mats.visor.emissiveIntensity = 0.55 + (state === 'idle' ? (Math.sin(t * 1.8) + 1) * 0.12 : 0.15);- const ventTarget = hovering ? 0.9 + (Math.sin(t * 6) + 1) * 0.25 : moving ? 0.25 : 0.05;- mats.vents.emissiveIntensity += (ventTarget - mats.vents.emissiveIntensity) * f;- mats.disc.opacity = hovering ? 0.3 : 0.16;+ // Brighten the footprint disc slightly while flying.+ if (discMatRef.current) discMatRef.current.opacity = hovering ? 0.3 : 0.16;});return (<group ref={rootRef}>- <group ref={torsoRef} position={[0, HIP_Y + 0.08, 0]}>- {/* Torso + chest core */}- <mesh geometry={GEO.torso} material={mats.body} position={[0, 0.26, 0]} />- <mesh geometry={GEO.core} material={mats.trim} rotation={[Math.PI / 2, 0, 0]} position={[0, 0.3, 0.14]} />- {/* Back unit + jet vents */}- <mesh geometry={GEO.backUnit} material={mats.dark} position={[0, 0.28, -0.17]} />- <mesh geometry={GEO.vent} material={mats.vents} position={[-0.07, 0.12, -0.18]} />- <mesh geometry={GEO.vent} material={mats.vents} position={[0.07, 0.12, -0.18]} />-- {/* Head */}- <group ref={headRef} position={[0, SHOULDER_Y - HIP_Y + 0.17, 0]}>- <mesh geometry={GEO.helmet} material={mats.body} />- <mesh geometry={GEO.visor} material={mats.visor} position={[0, 0.01, 0.12]} />- <mesh geometry={GEO.sensor} material={mats.sensor} position={[0, -0.07, 0.14]} />- </group>-- {/* Pauldrons */}- <mesh geometry={GEO.pauldron} material={mats.trim} position={[-0.27, 0.48, 0]} scale={[1, 0.7, 1]} />- <mesh geometry={GEO.pauldron} material={mats.trim} position={[0.27, 0.48, 0]} scale={[1, 0.7, 1]} />-- {/* Arms: shoulder → elbow, two segments each */}- <group ref={shoulderL} position={[-0.3, 0.44, 0]}>- <mesh geometry={GEO.upperArm} material={mats.body} position={[0, -0.14, 0]} />- <group ref={elbowL} position={[0, -0.28, 0]}>- <mesh geometry={GEO.forearm} material={mats.dark} position={[0, -0.13, 0]} />- <mesh geometry={GEO.fist} material={mats.dark} position={[0, -0.28, 0]} />- </group>- </group>- <group ref={shoulderR} position={[0.3, 0.44, 0]}>- <mesh geometry={GEO.upperArm} material={mats.body} position={[0, -0.14, 0]} />- <group ref={elbowR} position={[0, -0.28, 0]}>- <mesh geometry={GEO.forearm} material={mats.dark} position={[0, -0.13, 0]} />- <mesh geometry={GEO.fist} material={mats.dark} position={[0, -0.28, 0]} />- </group>- </group>- </group>-- {/* Pelvis */}- <mesh geometry={GEO.pelvis} material={mats.dark} position={[0, HIP_Y, 0]} />-- {/* Legs: hip → knee, two segments each, boots with glowing soles */}- <group ref={hipL} position={[-0.1, HIP_Y - 0.04, 0]}>- <mesh geometry={GEO.thigh} material={mats.body} position={[0, -0.16, 0]} />- <group ref={kneeL} position={[0, -0.32, 0]}>- <mesh geometry={GEO.shin} material={mats.dark} position={[0, -0.15, 0]} />- <mesh geometry={GEO.boot} material={mats.dark} position={[0, -0.32, 0.04]} />- <mesh geometry={GEO.sole} material={mats.trim} position={[0, -0.37, 0.04]} />- </group>- </group>- <group ref={hipR} position={[0.1, HIP_Y - 0.04, 0]}>- <mesh geometry={GEO.thigh} material={mats.body} position={[0, -0.16, 0]} />- <group ref={kneeR} position={[0, -0.32, 0]}>- <mesh geometry={GEO.shin} material={mats.dark} position={[0, -0.15, 0]} />- <mesh geometry={GEO.boot} material={mats.dark} position={[0, -0.32, 0.04]} />- <mesh geometry={GEO.sole} material={mats.trim} position={[0, -0.37, 0.04]} />- </group>- </group>-- {/* Ground glow disc */}- <mesh geometry={GEO.disc} material={mats.disc} rotation={[-Math.PI / 2, 0, 0]} position={[0, 0.02, 0]} />+ {/* scene carries its own fit scale/position (applied in the effect above).+ dispose={null}: the clone shares geometry/material refs with the useGLTF cache+ (SkeletonUtils.clone is shallow for those), so letting r3f dispose them on unmount+ would corrupt the cache for the next mount / the CoS Muse avatar. */}+ <primitive object={scene} dispose={null} />+ {/* Accent-tinted ground glow — the runner's neon footprint. Declared as JSX so R3F+ owns the geometry/material lifecycle; `color` tracks the theme reactively and the+ per-frame opacity write goes through discMatRef. */}+ <mesh rotation={[-Math.PI / 2, 0, 0]} position={[0, 0.02, 0]}>+ <circleGeometry args={[0.45, 18]} />+ <meshBasicMaterial+ ref={discMatRef}+ color={accent}+ transparent+ opacity={0.16}+ blending={THREE.AdditiveBlending}+ depthWrite={false}+ side={THREE.DoubleSide}+ />+ </mesh></group>);}++// Warm the loader cache once the URL is known (matches MuseCoSAvatar).+useGLTF.preload(MODEL_URL);diff --git a/client/src/components/city/PlayerController.jsx b/client/src/components/city/PlayerController.jsxindex 2bddf3e557..d44bdf378a 100644--- a/client/src/components/city/PlayerController.jsx+++ b/client/src/components/city/PlayerController.jsx@@ -1,7 +1,8 @@-import { useRef, useEffect, useCallback, useMemo } from 'react';+import { useRef, useEffect, useCallback, useMemo, Suspense } from 'react';import { useThree, useFrame } from '@react-three/fiber';import * as THREE from 'three';import PlayerAvatar from './PlayerAvatar';+import ErrorBoundary from '../ErrorBoundary';import {THIRD_PERSON, EYE_HEIGHT, BUILDING_COLLISION_RADIUS,thirdPersonCamera, resolveBoom,@@ -12,6 +13,8 @@ import { isWalkable, WORLD } from '../../utils/cityPlan';const WALK_SPEED = 10;const SPRINT_SPEED = 20;const VERTICAL_SPEED = 8;+const JUMP_SPEED = 10; // initial upward velocity of a Space jump (units/s)+const GRAVITY = -26; // downward acceleration applied through the jump arc (units/s²)const PROXIMITY_DISTANCE = 6;const MAX_CAMERA_HEIGHT = 160;const BUILDING_FLYOVER_HEIGHT = 12; // above this the player clears rooftops, so skip collision@@ -55,6 +58,7 @@ export default function PlayerController({pitch: 0,facing: 0, // the character's body heading (damped toward movement direction)bank: 0, // lean into turns+ vy: 0, // vertical velocity for the Space jump arc (E/Q free-fly zeroes it)state: 'idle',});// Stable array view of the positions Map for the per-frame boom collision test —@@ -151,6 +155,39 @@ export default function PlayerController({return () => window.removeEventListener('keydown', handleKeyDown);}, [active, onBuildingClick, onToggleCameraView]);+ // In exploration mode, Space is the jump key — capture it before it bubbles to the+ // global voice push-to-talk hotkey (VoiceWidget listens for the same key on `window`).+ // A CAPTURE-phase listener runs ahead of that bubble listener, so stopImmediatePropagation+ // suppresses the voice toggle (and the page's default space-scroll). Because that also+ // stops useKeyboardControls' own keydown, we record Space into keysRef here ourselves so+ // the jump still reads it in the frame loop. Skipped while typing so a focused field keeps+ // its spaces (matches VoiceWidget's own guard).+ useEffect(() => {+ if (!active) return undefined;+ const isTypingTarget = (el) => {+ if (!el) return false;+ const tag = el.tagName;+ return tag === 'INPUT' || tag === 'TEXTAREA' || el.isContentEditable;+ };+ const onKeyDownCapture = (e) => {+ if (e.code !== 'Space' || isTypingTarget(document.activeElement)) return;+ e.preventDefault();+ e.stopImmediatePropagation();+ keysRef.current.add(' ');+ };+ const onKeyUpCapture = (e) => {+ if (e.code !== 'Space') return;+ keysRef.current.delete(' ');+ };+ window.addEventListener('keydown', onKeyDownCapture, true);+ window.addEventListener('keyup', onKeyUpCapture, true);+ return () => {+ window.removeEventListener('keydown', onKeyDownCapture, true);+ window.removeEventListener('keyup', onKeyUpCapture, true);+ keysRef.current.delete(' ');+ };+ }, [active, keysRef]);+useFrame((_, delta) => {if (!active) return;const rig = rigRef.current;@@ -173,13 +210,32 @@ export default function PlayerController({.addScaledVector(right, strafeInput);const hasHorizontal = moveDir.lengthSq() > 0;- const verticalDir = (keys.has('e') ? 1 : 0) - (keys.has('q') ? 1 : 0);- const moving = hasHorizontal || verticalDir !== 0;++ // Vertical: E/Q is direct free-fly and takes precedence (zeroing any jump arc);+ // otherwise Space launches a gravity-based jump from the ground. The arc integrates+ // rig.vy so the runner hops and lands rather than floating; landing (clamp to+ // EYE_HEIGHT below) resets rig.vy. Holding Space re-jumps on touchdown.+ const flyDir = (keys.has('e') ? 1 : 0) - (keys.has('q') ? 1 : 0);+ const grounded = rig.position.y <= EYE_HEIGHT + 1e-3;+ let dy = 0;+ if (flyDir !== 0) {+ rig.vy = 0;+ dy = flyDir * verticalSpeed;+ } else {+ if (keys.has(' ') && grounded && rig.vy <= 0) rig.vy = JUMP_SPEED; // launch+ if (!grounded || rig.vy > 0) {+ rig.vy += GRAVITY * delta; // gravity through the arc+ dy = rig.vy * delta;+ } else {+ rig.vy = 0;+ }+ }+ const moving = hasHorizontal || dy !== 0;if (moving) {if (hasHorizontal) moveDir.normalize().multiplyScalar(speed);const nextPos = _nextPos.copy(rig.position).add(moveDir);- nextPos.y += verticalDir * verticalSpeed;+ nextPos.y += dy;// Collision detection with buildings — skipped above rooftop height so the// player can fly over the city.@@ -217,6 +273,8 @@ export default function PlayerController({nextPos.x = Math.max(-WORLD.bound, Math.min(WORLD.bound, nextPos.x));nextPos.y = Math.max(EYE_HEIGHT, Math.min(MAX_CAMERA_HEIGHT, nextPos.y));nextPos.z = Math.max(-WORLD.bound, Math.min(WORLD.bound, nextPos.z));+ // Landed (or hit the ceiling): kill the jump's vertical velocity.+ if (nextPos.y <= EYE_HEIGHT + 1e-3 || nextPos.y >= MAX_CAMERA_HEIGHT) rig.vy = 0;rig.position.copy(nextPos);}}@@ -294,6 +352,17 @@ export default function PlayerController({if (!active) return null;// The visible character exists only in third person — first person stays the- // classic invisible camera (and can't self-clip).- return cameraView === 'third' ? <PlayerAvatar rigRef={rigRef} /> : null;+ // classic invisible camera (and can't self-clip). PlayerAvatar loads a rigged GLB+ // (useGLTF suspends), so it's wrapped: Suspense keeps the streaming model from+ // blanking the whole city canvas, and the error boundary degrades to "no visible+ // runner" if the GLB is missing/corrupt (e.g. a checkout without `npm run setup:data`)+ // rather than crashing the scene.+ if (cameraView !== 'third') return null;+ return (+ <ErrorBoundary fallback={null}>+ <Suspense fallback={null}>+ <PlayerAvatar rigRef={rigRef} />+ </Suspense>+ </ErrorBoundary>+ );}