Skip to content

feat: Kaori 3D companion — interactive stage, live voice, trick demos - #4

Merged
wbaxterh merged 1 commit into
v2-rebuildfrom
feature/kaori-3d-companion
Jul 8, 2026
Merged

feat: Kaori 3D companion — interactive stage, live voice, trick demos#4
wbaxterh merged 1 commit into
v2-rebuildfrom
feature/kaori-3d-companion

Conversation

@wbaxterh

@wbaxterh wbaxterh commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Overview

Adds the app's first 3D capability: an interactive VRM companion stage where Kaori renders, talks, emotes, and physically demonstrates tricks. This is the Phase‑2 payoff of the 3D Companions PRD — the companion stops being a chat bubble and becomes a coach with a body. Reachable from the bot‑chat header and the home Companion widget (both Kaori‑gated).

Environment Variables

No environment variable changes in the app. (KITH_WS_URL is a derived constant in src/constants/api.ts; the Kith sidecar + ElevenLabs key live server‑side.)

Change Summary

  • Features:
    • KaoriStage — react‑three‑fiber (native) + expo‑gl + @pixiv/three-vrm VRM renderer; orbit/pinch camera; procedural idle; device‑only with a fallback card on simulators.
    • riderFundamentals — reusable rider motion vocabulary (stance, anatomical crouch + hip‑drop, wind‑up coil, arms, jump arc) shared across tricks.
    • trickAnimationsTRICKS timeline registry (frontside 360) + speech‑synced demo state machine (on‑board session, auto‑loop, phase cues).
    • Live voice: Kith WebSocket client, gapless streamed‑TTS player (react-native-audio-api), and expo-speech-recognition mic input. Same bot‑chat brain; replies stream back as ElevenLabs audio with mouth‑sync + gesture + emotion animation, and her sentences cue the trick choreography.
  • Fixes: resolved the repo's pre‑existing biome + TypeScript errors so CI is green (User._id/stats typing, a crashing couch‑API import, an expo‑video listener comparing an object to a string, null‑vs‑undefined, OsPermission export, Button style callback).
  • Refactors: trick motion split into riderFundamentals (shared primitives) + trickAnimations (per‑trick timelines).
  • Documentation: none in‑repo (docs live in the Docusaurus repo; release notes + a feature page are deploy‑time follow‑ups).
  • Dependency changes: three@0.170.0, @react-three/fiber@9.6.1, @pixiv/three-vrm@3.5.2, expo-gl, expo-asset, react-native-audio-api@0.13.1, expo-speech-recognition@3.1.3, @types/three; react-native-worklets pinned to 0.5.1 (Expo SDK 54). package-lock.json updated. New patches/react-native-audio-api+0.13.1.patch (iOS‑26 AVAudioSession constant).

Technical Impact

  • Affected areas: src/components/companion/* (new), src/hooks/* (new), src/lib/companion/* (new), app/(tabs)/homies/companion-stage/* (new), plus wiring in the home screen, homies layout, bot‑chat header, metro.config.js (vrm assetExt + single‑three resolver), app.config.js (speech‑recognition plugin + mic/speech permissions).
  • Database/schema: None (client‑only; reuses existing /bot-chat endpoints).
  • API/contract: None new on the client; sends the existing x-kith-session header (backend side handled separately).
  • Config/runtime: New native modules (three/expo‑gl/audio‑api/speech‑recognition) + new iOS/Android permissions ⇒ requires a fresh dev‑client / EAS build; a JS‑only OTA update is not sufficient.

Testing Evidence

  • Commands: npx biome check . (0 errors), npx tsc --noEmit (0 errors), bash scripts/check-prod-ready.sh (pass) — the exact gates CI runs.
  • Build: iOS (Release, simulator SDK) and Android (assembleRelease) compiled clean earlier this session with the full dependency set + patch.
  • Manual: verified on a physical iPhone through iterative testing — Kaori renders in full color, talks with lip‑sync in her ElevenLabs voice, and demonstrates the frontside 360 with correct crouch/stance/rotation while narrating.

Migration / Deployment Notes

  • New dev‑client build required before this runs on devices (two new native modules + permission strings). Existing installed clients will error until rebuilt.
  • Voice needs the Kith sidecar reachable (wss://api.thetrickbook.com/kith/ws in prod) — tracked separately in the Backend repo.
  • Bundles a ~14 MB assets/models/kaori.vrm binary. The repo isn't on git‑LFS; consider moving large model assets to LFS if more companions are added.

Screenshots / Examples

Verified live on device (screenshots shared during development): full‑color Kaori on the stage, and mid‑trick during a frontside‑360 demo.

Adds the app's first 3D capability: an interactive VRM companion stage where
Kaori renders, talks, emotes, and physically demonstrates tricks — the Phase-2
payoff of the 3D Companions PRD.

Rendering (src/components/companion/):
- KaoriStage: react-three-fiber (native) + expo-gl + @pixiv/three-vrm. three
  pinned to 0.170.0; navigator.userAgent shim for GLTFLoader on Hermes; MToon
  downgraded to unlit textured MeshBasicMaterial and textures re-baked through
  expo-gl's working localUri path (upstream fiber texture upload is a no-op on
  expo-gl); frustumCulled off; orbit/pinch camera; device-only (simulator GL
  can't compile the shaders — honest fallback card).
- riderFundamentals: reusable rider motion vocabulary (stance, anatomical
  crouch + hip-drop, wind-up coil, arms, jump arc) shared across tricks.
- trickAnimations: TRICKS timeline registry (frontside 360) + speech-synced
  demo state machine (on-board session, auto-loop, phase cues).

Voice (src/hooks, src/lib/companion/):
- Kith WebSocket client + gapless streamed-TTS player (react-native-audio-api
  AudioBufferQueueSourceNode) + expo-speech-recognition mic input. Same bot-chat
  brain; replies stream back as ElevenLabs audio with mouth-sync, gesture and
  emotion animation. Her spoken sentences cue the trick choreography.

Entry points: bot-chat header + home CompanionWidget (both Kaori-gated).

Also folds in this session's pre-existing WIP and fixes the repo's pre-existing
biome + TypeScript errors so CI (biome + tsc + check-prod-ready) is green.

New deps: three 0.170.0, @react-three/fiber 9.6.1, @pixiv/three-vrm 3.5.2,
expo-gl, expo-asset, react-native-audio-api 0.13.1, expo-speech-recognition
3.1.3, @types/three; react-native-worklets pinned to 0.5.1 (SDK 54). Adds mic +
speech-recognition permissions and a patch-package patch for audio-api's iOS 26
AVAudioSession constant. Requires a new dev-client build.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@wbaxterh
wbaxterh merged commit b7b94ce into v2-rebuild Jul 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant