VR Narrative Engine
Interactive fiction meets spatial interaction—craft branching stories in WebXR where physical gameplay drives the narrative.
What is this?
VR Narrative Engine is a WebXR-powered interactive fiction system that transforms narrative gameplay through embodied interaction. Instead of selecting dialogue from a menu, players physically pick up story objects, perform gesture sequences (like drum patterns), and use spatial positioning to unlock choices and trigger plot beats. It bridges physics-based VR experiences with branching narrative, enabling developers to build story-driven games where the how of interaction matters as much as the what.
Features
- Spatial Story Objects — Items in the VR environment that trigger narrative branches when picked up or manipulated
- Gesture-Based Plot Triggers — Rhythm patterns, hand movements, and physical sequences unlock story beats
- Position-Aware Dialogue — NPC responses and story paths change based on player location in the scene
- Branching Narrative Graph — Full support for complex story trees with multiple endings and convergence points
- WebXR Compatible — Works with Meta Quest, Apple Vision Pro, and WebXR-enabled browsers
- Physics Integration — Built to work seamlessly with existing physics engines (Phantom Rack, SplitScreen)
- Real-Time State Sync — Backend tracks narrative state, choices, and player progress
- Developer Tooling — Simple APIs for story authors and game developers
Quick Start
Installation
# Clone the repository
git clone <repo-url>
cd vr-narrative-engine
# Install dependencies
pip install -r pyproject.toml
npm install # if frontend dependencies exist
# Set up environment
cp .env.example .env
Running Locally
# Start backend (FastAPI)
python backend/main.py
# Start frontend (separate terminal)
cd frontend
npm run dev
# Run tests
pytest tests/
Docker Deployment
# Build and run with Docker Compose
docker-compose up --build
# Access at http://localhost:8000
Usage
Basic Story Definition
// Define a narrative node with spatial triggers
const storyNode = {
id: "cabin_discovery",
text: "You find an old journal on the shelf.",
triggers: {
spatial: { position: [1.5, 1.2, 0.8], radius: 0.5 },
gesture: "drum_pattern_abc",
item_pickup: "journal"
},
choices: [
{ text: "Read the journal", next: "journal_content" },
{ text: "Leave it", next: "cabin_exit" }
]
};
Connecting to Your VR Scene
// In your WebXR application
const engine = new NarrativeEngine("ws://localhost:8000/narrative");
engine.on("objectInteraction", (objectId, interactionType) => {
// Trigger story progression
engine.advancePlot(objectId);
});
engine.on("narrativeUpdate", (newState) => {
// Update UI, NPC behavior, environmental state
updateDialogueDisplay(newState.currentText);
triggerAudioNarration(newState.currentAudio);
});
Tech Stack
- Backend: Python FastAPI, WebSocket support for real-time state sync
- Frontend: JavaScript/WebXR (vanilla or framework-agnostic)
- Database: PostgreSQL for narrative state and user progress
- Deployment: Docker, Railway, Render (config files included)
- Testing: pytest for backend, Jest for frontend
- CI/CD: GitHub Actions for automated testing and deployment
Deployment
Pre-configured deployment files for:
- Railway:
railway.json— One-click deployment with auto-scaling - Render:
render.yaml— Full-stack hosting with managed databases - Docker:
Dockerfile+docker-compose.yml— Self-hosted option
License
MIT
Release files for vr-narrative-engine 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vr_narrative_engine-0.1.0.tar.gz | 14.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vr_narrative_engine-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.8 kB
Release files / vr_narrative_engine-0.1.0.tar.gz
| Download URL | vr_narrative_engine-0.1.0.tar.gz |
|---|---|
| Size | 14.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
76fc2e4251d2382b2af6f89311812adfa2d274b683f8fce34843bf46d7fdaca2
|
|
BLAKE2b-256 checksum How to use checksums |
9f4a85fb82f43c351aa9ae04355abfb16523c83155c08cb468f78b9531d87da1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / vr_narrative_engine-0.1.0-py3-none-any.whl
| Download URL | vr_narrative_engine-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf1fa679c13e7e7f486c19a53c97d8018d8dd5fa851dc09395c9e4a79322b1dc
|
|
BLAKE2b-256 checksum How to use checksums |
2ecf7ad36dbecfff0b44db6d41225436ea7f5cff2b1535674d13683dc33bad3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|