Skip to content

xsploit/Vrmviewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

VRM Viewer Logo

VRM Animation Three.js WebSocket TTS

Real-time VRM avatar animation with intelligent TTS synchronization

VRM Viewer Screenshot

๐Ÿš€ Quick Start โ€ข โšก Features โ€ข ๐Ÿ› ๏ธ Setup โ€ข ๐Ÿ“š Documentation


๐ŸŒŸ Features

๐ŸŽจ VRM Avatar System

  • ๐Ÿค– Auto-loading: Default VRM model and animations on startup
  • ๐Ÿ”„ Real-time Animation: Seamless idle โ†” talking state switching
  • ๐Ÿ’ฌ Mouth Animation: Volume-based blend shapes with fine-tuned controls
  • ๐ŸŽฎ Interactive Controls: Full camera and avatar manipulation
  • ๐Ÿ“ Multi-format Support: VRM, FBX, VRMA, GLB, GLTF files

๐Ÿ—ฃ๏ธ TTS Integration

  • ๐ŸŒ WebSocket Communication: Zero-latency animation triggers
  • โšก Perfect Timing: Server-side synchronization for precise animation
  • ๐ŸŽฏ Smart Detection: Deterministic triggers, not audio guessing
  • ๐Ÿ”ง Optional Mode: Works standalone without TTS server

๐ŸŽฎ Controls & Interface

  • Movement: WASD (avatar), Arrow Keys (camera), Mouse (orbit)
  • Manipulation: Ctrl+WASD (rotation), Shift+Drag (positioning)
  • UI: H (toggle interface), organized accordion panels
  • Animation: Manual play/stop/reset controls

๐Ÿš€ Quick Start

โš ๏ธ Critical: Web Server Required

You CANNOT open room.html directly in browser. Use a web server:

๐ŸŽฏ VS Code Live Server (Recommended)

1. Install "Live Server" extension
2. Right-click room.html โ†’ "Open with Live Server"  
3. Opens at http://127.0.0.1:5500/room.html

๐Ÿ”„ Alternative Servers

# Python (built-in)
python -m http.server 8000
# โ†’ http://localhost:8000/room.html

# Node.js 
npx serve .
# โ†’ http://localhost:3000/room.html

# PHP
php -S localhost:8000
# โ†’ http://localhost:8000/room.html

Why? ES6 modules, CORS restrictions, and WebSocket context require HTTP protocol.


โšก Usage Modes

๐ŸŽญ Standalone Mode (No TTS Server)

  1. Start web server
  2. Open room.html
  3. Auto-loads:
    • Default VRM avatar (AvatarSample_H.vrm)
    • Idle animation (Happy Idle.fbx)
    • Talking animation (Talking.fbx)
  4. Use manual controls to trigger animations

๐Ÿ—ฃ๏ธ TTS Integration Mode

  1. Run TTS server: run_gpt_sovits.bat
  2. Start web server and open room.html
  3. Check "Enable TTS WebSocket Connection"
  4. Animations trigger automatically with TTS audio

๐Ÿ› ๏ธ Setup

๐Ÿ“ Project Structure

VRMViewer/
โ”œโ”€โ”€ room.html              # ๐ŸŽฏ Main application
โ”œโ”€โ”€ api_v3.py             # ๐Ÿ”Œ Modified TTS server  
โ”œโ”€โ”€ run_gpt_sovits.bat    # ๐Ÿš€ Server launcher
โ”œโ”€โ”€ assets/
โ”‚   โ”œโ”€โ”€ models/           # ๐Ÿค– VRM avatar files
โ”‚   โ”‚   โ”œโ”€โ”€ AvatarSample_H.vrm
โ”‚   โ”‚   โ””โ”€โ”€ *.vrm
โ”‚   โ””โ”€โ”€ animations/       # ๐ŸŽญ Animation files  
โ”‚       โ”œโ”€โ”€ Happy Idle.fbx
โ”‚       โ”œโ”€โ”€ Talking.fbx
โ”‚       โ””โ”€โ”€ *.fbx, *.vrma
โ”œโ”€โ”€ js/                   # ๐Ÿ“ฆ JavaScript modules
โ”‚   โ”œโ”€โ”€ three-vrm-core.module.js
โ”‚   โ”œโ”€โ”€ three-vrm-animation.module.js
โ”‚   โ””โ”€โ”€ loadMixamoAnimation.js
โ””โ”€โ”€ css/                  # ๐ŸŽจ Styling
    โ””โ”€โ”€ styles.css

๐Ÿ”Œ TTS Server Integration (Optional)

Our modified api_v3.py extends GPT-SoVITS with WebSocket animation signals:

Key Modifications

# Real-time VRM communication
vrm_websocket = None

async def notify_vrm(message_type, text=None):
    if vrm_websocket:
        message = {"type": message_type}
        await vrm_websocket.send(json.dumps(message))

# Perfect timing integration
await notify_vrm("tts_start")  # Animation begins
await notify_vrm("tts_end")    # Return to idle

Signal Protocol

{"type": "tts_start"}  // ๐Ÿ—ฃ๏ธ Start talking animation
{"type": "tts_end"}    // ๐Ÿ˜ด Return to idle animation  

๐Ÿ“‹ Requirements

  • Browser: Chrome/Firefox/Edge with WebGL support
  • TTS Server: GPT-SoVITS v2 Pro (optional)
  • Dependencies: websockets, asyncio (for TTS integration)

๐ŸŽฏ Manual Animation Control

๐ŸŽฎ Without TTS Server

// Browser console commands:
startIdleAnimation();           // ๐Ÿ˜ด Start idle 
startTalkingAnimationFromTTS(); // ๐Ÿ—ฃ๏ธ Start talking
stopAnimation();                // โน๏ธ Stop current
resetAnimation();               // ๐Ÿ”„ Reset to idle

๐Ÿ“ Custom Assets

  • VRM Models: Drop into assets/models/ folder
  • Animations: Support FBX (Mixamo) and VRMA formats
  • Environments: GLB/GLTF room files supported
  • Auto-retargeting: Mixamo animations automatically fit VRM skeleton

๐Ÿ”ง Advanced Configuration

๐ŸŽ›๏ธ Animation Controls

  • Mouth Gain: Adjust lip-sync intensity (0.1 - 2.0)
  • Body Threshold: Set talking animation trigger sensitivity
  • Blend Shapes: Utilizes VRM visemes (aa, ih, ou, ee, oh)

๐ŸŒ WebSocket Settings

  • Port: 8765 (configurable in api_v3.py)
  • Auto-reconnect: 5-second intervals on connection loss
  • Status Indicators: Real-time connection status display

๐ŸŽฅ Streaming Optimization

  • OBS Compatible: Optimized for broadcast software
  • Performance: Hardware acceleration recommended
  • Audio Routing: Support for virtual audio cables

๐Ÿ› Troubleshooting

Problem Solution
๐Ÿšซ Modules not loading Use HTTP server, not file:// protocol
๐Ÿ”‡ Audio not working Check browser permissions & device selection
๐Ÿ‘ป VRM not visible Verify valid VRM file, check console errors
๐ŸŽญ Animations not playing Confirm FBX/VRMA format, check VRM compatibility
๐Ÿ”Œ TTS connection failed Verify api_v3.py server running on port 8765

๐Ÿš€ Performance Tips

  • โœ… Enable hardware acceleration in browser settings
  • โœ… Use Chrome/Edge for best WebGL performance
  • โœ… Disable unused features (spring bones, etc.) if lag occurs
  • โœ… Local server recommended over network drives
  • โœ… Close unused browser tabs for optimal performance

๐ŸŽ“ Technical Architecture

๐Ÿ—๏ธ Built With

  • Three.js r169: 3D rendering engine
  • VRM 3.0: Avatar standard support
  • WebSocket: Real-time communication
  • ES6 Modules: Clean import system
  • Web Audio API: Advanced audio processing

โšก Why This Approach Works

  • Deterministic Timing: TTS server knows exact audio timing
  • Zero Latency: No audio detection delays
  • Universal Compatibility: Works regardless of user audio setup
  • Reliable Synchronization: No false positives or missed triggers

๐Ÿ“„ License & Credits

Built with:

  • ๐ŸŽฏ Three.js + VRM Libraries
  • ๐Ÿค– VRM Consortium sample assets
  • ๐ŸŽญ Mixamo animation library
  • ๐Ÿ—ฃ๏ธ GPT-SoVITS TTS framework

๐ŸŽญ Professional VRM Animation System

Real-time โ€ข Deterministic โ€ข Production-Ready

Made with Three.js WebSocket Integration

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published