WebXR interactive fiction engine with physics-based narrative triggers
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vr_narrative_engine-0.1.0.tar.gz.
File metadata
- Download URL: vr_narrative_engine-0.1.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76fc2e4251d2382b2af6f89311812adfa2d274b683f8fce34843bf46d7fdaca2
|
|
| MD5 |
b131f175238c7e85aa3d13df04660e27
|
|
| BLAKE2b-256 |
9f4a85fb82f43c351aa9ae04355abfb16523c83155c08cb468f78b9531d87da1
|
File details
Details for the file vr_narrative_engine-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vr_narrative_engine-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf1fa679c13e7e7f486c19a53c97d8018d8dd5fa851dc09395c9e4a79322b1dc
|
|
| MD5 |
2c73054035da9a8d2b344a665c940ff4
|
|
| BLAKE2b-256 |
2ecf7ad36dbecfff0b44db6d41225436ea7f5cff2b1535674d13683dc33bad3d
|