• Stars
    star
    585
  • Rank 75,871 (Top 2 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created almost 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Open, decentralised, immersive worlds built on Matrix
Third Room

Matrix

Third Room is a platform for shared virtual worlds built on top of Matrix. Third Room aims to make it easy to discover, create, and share 3D worlds with others.

Getting Started

Visit thirdroom.io

Homeserver Requirements

Your homeserver should be on Synapse version 1.62 or higher. This is due to Third Room's requirement of the Cross-Origin-Resource-Policy: cross-origin header for the media repository's download route. Third Room uses SharedArrayBuffers which require us to run in a secure-context.

You also should have a TURN server set up with your homeserver. More info on how to do that here.

About Third Room

Third Room enables people to discover and create virtual worlds while protecting their privacy and giving them ownership over their data. We use open standards to ensure that both the 3d content and social networking data is portable and interoperable with other platforms. We empower creators to design and program rich and interactive virtual worlds and avatars using a wide variety of 3D content creation tools and harnessing the power of the glTF file format.

The Third Room client developed in this repository is only one implementation of a possible Third Room client and we welcome additional web or native clients to implement the protocols we design together. Third Room itself is designed around the Matrix protocol, but pieces of this project can be utilized in other 3D web applications including other virtual world platforms. We intend to build the client in a modular fashion, improving the overall landscape for the 3D web ecosystem and being a good participant in the open source community that we are benefitting from.

We will be a good participant in the immersive web. Third Room is just one piece of the overall immersive web. We believe platforms that intend to create their own "metaverse" are missing the point of that term. There is only one metaverse just as there is only one internet. We will embrace and encourage interoperability instead of accepting fragmentation.

Third Room at its core is focused on creating spaces for people and communities to feel safe. We will foster an open community that is kind, respectful, and accepting of others. We will utilize Matrix's existing moderation tools and extend them to best protect our community members against trolls and harassment. We will put users in control of their own privacy and always design with a privacy and safety first mindset.

Problems

  • Virtual worlds are disconnected which makes multiplayer gaming and switching activities or applications difficult and clunky.
  • Some virtual world platforms are monetized with an ad based model that uses sensitive user data to recommend ads.
  • Other virtual world platforms are monetized via NFTs which can be inaccessible due to cryptocurrency transaction fees, some are built on proof of work chains that require vast amounts of electricity, and all operate on the concept of artificial scarcity which has been co-opted by many groups in various speculative schemes.
  • There is high demand from audiences for free user-generated content games on platforms where creators make next to nothing. The audiences and creators for these platforms heavily skew younger and are being exploited by platform operators.
  • The quality of these user-generated games can be high but most are not due to the platform restrictions especially around monetization opportunities. Creators cannot afford to create indie/AAA content.

The Pitch

  • Third Room will be built on top of the Matrix protocol allowing for decentralized hosting of virtual worlds.
  • Worlds can be traversed quickly by changing rooms.
  • Your identity, network, and other shared data will be brought with you between these worlds.
  • Worlds will have spatial voice chat and game networking that can be made end-to-end encrypted so that you know you are only sending data to the people in the room.
  • Creators of all skill levels will be able to create worlds using either a beginner-friendly in-world collaborative tool or industry-standard 3D tools.
  • Creators will be able to use the programming language of their choice compiled to WebAssembly to add interactivity to their worlds.
  • Creators will also be able to monetize their worlds through marketplaces for 3D content including avatars, environments, and props as well as scripts. They also can monetize room or server membership.

Matrix

Third Room is built on top of the Matrix group VoIP spec (MSC3401) where WebRTC connections for voice and game networking are established over Matrix. Matrix is also used for hosting the 3D assets for these virtual worlds and your avatars as well as providing decentralized identity, end to end encryption, text chat, room permissions, and more. We've also started work on a Matrix spec for virtual worlds (MSC3815).

Open Source / License

Third Room is completely open source under the Apache 2.0 license. You can check out this repository, fork it, and modify it as you please. The project is governed by the Matrix.org Foundation and all our work is done in the open. We're still getting the foundation of the project set up and don't have a streamlined flow of taking on external contributors right now. If you are interested in helping out you can join us in the #thirdroom-dev:matrix.org Matrix room.

Manifold Engine

Manifold, Third Room's engine, lives under the /src/engine directory of this project. It is developed with the bitECS and Three.js libraries. It is eventually intended to be published as a standalone project for use with or without Matrix, but it is currently under active development and not ready for a public release yet.

Entity Component System (ECS)

Manifold is built with bitECS, a high performance ECS library written in JavaScript. bitECS is built around Data Oriented Design and JavaScript's TypedArrays to improve CPU cache performance.

In addition to performance, ECS design lets us have predictable execution of systems and more easily debug issues that arise in our game loop.

We've also adopted bitECS's function programming patterns throughout our engine for simpler abstractions, better tree shaking, and faster design iteration.

Multithreading

Manifold is designed around a multithreaded architecture which allows us to fully utilize your system's hardware. As a result, the core of the engine is split across these different threads. We have carefully built out lock-free scene graph data structures backed by JavaScript's SharedArrayBuffers and Atomics. This allows us to split the renderer from the game thread and run each at different rates. With high refresh rate monitors becoming the norm, this is becoming increasingly important. You can now get smooth 120hz+ rendering while your game logic runs at a stable 60hz. Allowing for the renderer thread to submit draw calls as soon as possible in the frame and keep the GPU saturated while your game logic gets a full 16ms to run complex physics simulations and more. The render thread then uses interpolation to smoothly animate the transforms of objects in your scene.

Another short term option we are considering for reducing input latency is with a locking double buffered approach. Where the game simulation is ran at the same rate as your monitor's refresh rate. This approach has the game thread computing the state of the next frame and the render thread rendering the last frame's state. It requires the game simulation to complete within the time frame of your monitor's refresh rate or you will drop frames which may not be preferable when you are bound by your game's simulation. However, if your simulation is simple, this can be a good option for reducing input latency. It's also possible that we may be able to switch between these two approaches depending on the average execution time of your game thread on your particular device.

Browser limitations and API adoption of things like OffscreenCanvas and Atomics.waitAsync create design constraints that are fairly unique to the Web. Our current architecture lets us stay flexible and adapt to advancements in browser technology.

Rendering

Manifold uses Three.js as its rendering library. However, the Three.js API is not intended to be used directly by Third Room developers. We've built a multi-threaded scene graph API with a similar shape to the glTF data model. Our intention is for glTF content to be loaded on the game thread, passed to the render thread via the MessageChannel postMessage API, and then modifications to transforms or materials can be made synchronously on the game thread with data structures backed by SharedArrayBuffers. These rendering changes will be applied on the next render frame.

The renderer itself currently exists on either a dedicated WebWorker when OffscreenCanvas is available, or it shares the main browser thread when it's not.

Three.js is built around the WebGL API and recently switched over to WebGL2 as the default. There is also early support for the WebGPU support. We're currently focusing on the WebGL2 target as browser support is very good now and we can get some performance improvements over WebGL1 with features like Uniform Buffer Objects and Vertex Array Objects.

Most of our rendering features will be tied to the glTF specification and extensions.

Currently supported:

To Do:

Instead of the Three.js GLTFLoader, we've implemented our own glTF loader that works with our multithreaded architecture. However, the renderer is still using Three.js. This means as Three.js improves support for glTF rendering features we hope to add support as well. We may also be able to push support for certain glTF material features faster than Three.js in our own loader.

Aside for glTF material features, we hope to add support for various postprocessing effects such as motion blur, depth of field, bloom, and more.

For rendering performance we hope to make full use of Three's instanced mesh rendering, light maps, and light probes. We'll also be looking into cascaded shadow maps, reflection probes, and more.

Physics

Manifold uses Rapier.js for physics which is a WebAssembly port of the Rapier Rust physics engine. It's a fast and relatively light library with well-documented APIs and active development. We run our physics system on the game thread for synchronous access to the physics world.

We're helping standardize embedding of physics data in glTF in the Open Metaverse Interoperability Group with the following extensions:

Audio

Manifold uses the WebAudio API for spatialized audio from other users and environmental audio. We're still investigating how we might best use features such as AudioWorklet and third party libraries such as Oddio.

Networking

Manifold uses WebRTC DataChannels for game networking. Third Room establishes these DataChannels via Matrix (MSC3401), however Manifold has an interface to connect your own network interface. Currently we are working with ordered and reliable DataChannels, but we intend to utilize unreliable DataChannels for fast changing data like transforms.

We also intend to document our network protocol and hopefully standardize it as part of our virtual world Matrix spec (MSC3815). We've documented some of our progress so far in our network protocol document.

Currently our networking is peer-to-peer, however work is underway on a selective forwarding unit (SFU) and sfu-to-sfu protocol that will increase world capacity by lowering outbound bandwidth and interest management algorithms. Our start on this project can be seen in the sfu-to-sfu repository.

WebRTC is a fantastic technology, however it's also a very complex and fragile one. The new WebTransport API looks like it may be a possible alternative when communicating through a SFU. We're interested in exploring this area further in the future.

WebXR

Manifold currently doesn't have WebXR support. However, we plan to start work on it as soon as we have a feature complete product running on desktops. Our multithreading support will work a little differently when WebXR is involved due to the need for the lowest possible input latency to avoid motion sickness. We're still investigating this area and we'll have more to share as we get closer to starting this work.

Editor

The Manifold Editor will be built into the game engine and will be able to be launched at any time while in a scene. It is being designed from the start for collaborative world building. The editor will make use of glTF as both its authoring and runtime format. glTF was designed as a transmission format for real-time graphics, not an authoring format for DCC tools like Blender or Maya. However, we believe there is a middle ground where glTF can be the foundation for a format that enables composition of assets similar to how HTML allows you to embed images, video, iframes, and more.

User Generated Content and Sandboxed Scripting

Third Room worlds and avatars are owned by their creators. Worlds and avatars are published as glTF files hosted on the Matrix network or elsewhere. Creators will also be able to embed WebAssembly scripts inside their glTF content, enabling custom behaviors. Manifold's APIs are built around the ability to safely provide performant manipulation of a glTF scene graph from a WebAssembly module. This enables us to run partially untrusted scripts safely in your Third Room client as you navigate from world to world.

We hope to standardize this WebAssembly Scene Graph API as a member of the Open Metaverse Interoperability Group's Scripting Working Group.

UPDATE: There is a very early version of the Web Scene Graph API supported today. You can find more info about it in the WebSG Docs.

Creating Your Own Scenes

Third Room is built on top of the glTF standard 3D file format, you can technically use any tool that exports glTF to create Third Room scenes. However, not all of the glTF extensions Third Room uses are supported by every tool. We've created the Third Room Unity Exporter for easily creating Third Room scenes from Unity.

Learn more here.

Local Development

The Third Room client can be ran locally against any Matrix homeserver in development.

After you've installed node.js locally, run the following commands.

npm install -g yarn
yarn
yarn dev

NOTE: Vite does not transpile import statements in web workers and Chromium based browsers are the only browsers to support imports in Web Workers. In order to develop in non-chromium browsers, run the following command which will build the project after every change.

yarn preview

Open http://localhost:3000

Deployment

The Third Room client can be deployed to any static web host with the ability for wildcard routing for single page web apps and adding HTTP headers.

We currently deploy Third Room to Netlify via a custom GitHub actions deploy script. If you fork our repository and set the NETLIFY_AUTH_TOKEN and NETLIFY_SITE_ID secrets in your GitHub configuration, this setup should work for you as well. Every PR will be built and deployed as a preview deploy and every commit / merge to main will be deployed to your Netlify site.

When deploying to thirdroom.io, the testing procedure should be completed before deploying.

To setup OIDC login client configs needs to be added in config.json. Client configs includes client_id and uris issued by OIDC Provider.

More Repositories

1

synapse

Synapse: Matrix homeserver written in Python/Twisted.
Python
11,768
star
2

dendrite

Dendrite is a second-generation Matrix homeserver written in Go!
Go
4,696
star
3

matrix-js-sdk

Matrix Client-Server SDK for JavaScript
TypeScript
1,505
star
4

matrix-rust-sdk

Matrix Client-Server SDK for Rust
Rust
1,151
star
5

matrix-react-sdk

Matrix SDK for React Javascript
TypeScript
1,095
star
6

matrix-spec-proposals

Proposals for changes to the matrix specification
889
star
7

matrix-appservice-discord

A bridge between Matrix and Discord.
TypeScript
790
star
8

matrix.to

A simple stateless privacy-protecting URL redirecting service for Matrix
JavaScript
766
star
9

matrix-appservice-irc

Node.js IRC bridge for Matrix
TypeScript
457
star
10

matrix-ios-sdk

The Matrix SDK for iOS
Objective-C
433
star
11

pinecone

Peer-to-peer overlay routing for the Matrix ecosystem
Go
421
star
12

matrix.org

matrix.org public website
JavaScript
396
star
13

matrix-android-sdk

The Matrix SDK for Android - DEPRECATED
Java
376
star
14

mjolnir

A moderation tool for Matrix
TypeScript
301
star
15

go-neb

Extensible matrix bot written in Go
Go
281
star
16

pantalaimon

E2EE aware proxy daemon for matrix clients.
Python
279
star
17

matrix-appservice-slack

A Matrix <--> Slack bridge
TypeScript
271
star
18

gomatrix

A Golang Matrix client
Go
269
star
19

sydent

Sydent: Reference Matrix Identity Server
Python
259
star
20

matrix-python-sdk

Matrix Client-Server SDK for Python 2 and 3
Python
256
star
21

sliding-sync

Proxy implementation of MSC3575's sync protocol.
Go
230
star
22

purple-matrix

Libpurple protocol plugin for matrix
C
224
star
23

matrix-ircd

An IRCd implementation backed by Matrix.
Rust
224
star
24

matrix-android-sdk2

Matrix SDK for Android, extracted from the Element Android application
Kotlin
185
star
25

matrix-hookshot

A bridge between Matrix and multiple project management services, such as GitHub, GitLab and JIRA.
TypeScript
185
star
26

matrix-spec

The Matrix protocol specification
HTML
171
star
27

matrix-bifrost

General purpose bridging with a variety of backends including libpurple and xmpp.js
TypeScript
162
star
28

vodozemac

An implementation of Olm and Megolm in pure Rust.
Rust
145
star
29

matrix-appservice-bridge

Bridging infrastructure for Application Services
TypeScript
141
star
30

rust-synapse-compress-state

A tool to compress some state in a Synapse instance's database
Rust
141
star
31

matrix-ios-kit

Reusable UI interfaces to ease building of Matrix client apps
Objective-C
128
star
32

sygnal

Sygnal: reference Push Gateway for Matrix
Python
128
star
33

matrix-synapse-ldap3

An LDAP3 auth provider for Synapse
Python
107
star
34

matrix-authentication-service

OAuth2.0 + OpenID Provider for Matrix Homeservers
Rust
106
star
35

cerulean

An experimental Matrix client for playing with freestyle public threaded conversations
JavaScript
101
star
36

waterfall

A cascading stream forwarding unit for scalable, distributed voice and video conferencing over Matrix
Go
97
star
37

synapse-s3-storage-provider

Synapse storage provider to fetch and store media in Amazon S3
Python
92
star
38

meshsim

Matrix mesh simulator
Python
90
star
39

matrix-static

A static golang generated preview of public world readable Matrix rooms.
Go
87
star
40

seshat

A Matrix message database/indexer
Rust
86
star
41

matrix-rich-text-editor

Matrix Rich Text Editor
Rust
82
star
42

matrix-appservice-node

Matrix Application Service framework in Node.js
TypeScript
71
star
43

matrix-viewer

View the history of public and world readable Matrix rooms
JavaScript
71
star
44

sytest

Black-box integration testing for Matrix homeservers
Perl
66
star
45

matrix-federation-tester

Tester for matrix federation written in golang.
Go
61
star
46

complement

Matrix compliance test suite
Go
61
star
47

docker-jitsi

Docker files for building images and running jitsi-meet in Docker containers
Lua
58
star
48

matrix-widget-api

JavaScript/TypeScript API for widgets & web clients to communicate
TypeScript
57
star
49

gomatrixserverlib

Go library for matrix federation.
Go
56
star
50

olm

An implementation of the Double Ratchet cryptographic ratchet in C++/C
54
star
51

Matrix-NEB

N E Bot: Generic bot for Matrix with plugin support
Python
49
star
52

rust-opa-wasm

Open Policy Agent WebAssembly Rust SDK
Rust
46
star
53

naffka

Single in-process implementation of the sarama golang kafka APIs
Go
45
star
54

matrix-ios-console

The sample Matrix client for iOS
Objective-C
45
star
55

gsoc

JavaScript
43
star
56

conference-bot

The conductor for your orchestra^Wconference
TypeScript
43
star
57

matrix-appservice-gitter

Matrix <-> Gitter bridge
JavaScript
40
star
58

coap-proxy

HTTP<->CoAP proxy
Go
39
star
59

matrix-appservice-tg

Matrix<->Telegram user-puppeting portal
JavaScript
37
star
60

dendron

Dendron was an experimental Matrix homeserver, succeeded by Dendrite.
Go
35
star
61

matrix-vr-demo

Matrix.org Virtual Reality Demo
JavaScript
31
star
62

python-canonicaljson

Canonical JSON
Python
31
star
63

bullettime

An experimental golang Matrix homeserver
Go
31
star
64

matrix-angular-sdk

JavaScript
28
star
65

rageshake

Bug report server
Go
27
star
66

matrix-android-console

Java
26
star
67

fed-tester-ui

UI for the matrix federation tester (forked from https://git.lain.haus/f0x/fed-tester)
JavaScript
26
star
68

matrix-android-sdk2-sample

Example project for using the android sdk
Kotlin
25
star
69

lb

MSC3079 Low Bandwidth library for servers and clients
Go
24
star
70

voip-tester

Tests VoIP
JavaScript
23
star
71

prosody-mod-auth-matrix-user-verification

Matrix user verification auth for Prosody
Lua
23
star
72

thirdroom-unity-exporter

C#
23
star
73

matrix-search

A generic search engine daemon
Go
22
star
74

matrix-rust-components-swift

Swift package providing components from the matrix-rust-sdk
Swift
21
star
75

matrix-user-verification-service

Service to verify details of a user based on a Open ID token.
JavaScript
21
star
76

tardis

Time Agnostic Room DAG Inspection Service
JavaScript
20
star
77

libp2p-proxy

A p2p transport shim for p2p matrix.
Go
18
star
78

patience

Full stack integration testing for Matrix clients and servers
TypeScript
18
star
79

matrix-sentry-webhooks

Sentry webhooks integration bot for Matrix.
JavaScript
17
star
80

matrix-appservice-verto

A Matrix <--> Verto bridge, designed for conferencing
JavaScript
16
star
81

synapse-auto-accept-invite

Synapse module to automatically accept invites
Python
15
star
82

go-sqlite3-js

Go SQL driver for sqlite3 in browser (sql.js) from go-wasm
Go
15
star
83

matrix-appservice-rocketchat

JavaScript
15
star
84

matrix-content-scanner

[DEPRECATED] A web service for scanning media hosted by a Matrix media repository. Replaced by https://github.com/vector-im/matrix-content-scanner-python
JavaScript
13
star
85

docker-dehydrated

A docker image we use internally for managing certificates.
Shell
13
star
86

matrix-websockets-proxy

Websockets wrapper for matrix.org homeservers
Go
12
star
87

panopticon

panopticon records usage metrics from homeservers
Go
11
star
88

matrix-files-sdk

JS/TS SDK for working with files and folders in Matrix
TypeScript
11
star
89

remember-this-rs

A simple Rust crate to cache data both in-memory and on disk
Rust
11
star
90

matrix-rust-sdk-crypto-wasm

Rust
11
star
91

matrix-rust-components-kotlin

Kotlin
10
star
92

allchange

A multi-project changelog generator
TypeScript
10
star
93

python-unpaddedbase64

Unpadded Base64
Python
10
star
94

matrixmon

A small end-to-end prober and Prometheus stats exporter for a Matrix homeserver
Perl
10
star
95

matrix-synapse-saml-mozilla

Mozilla flavour of a Synapse SAML mapping provider
Python
9
star
96

vodozemac-bindings

Language bindings for vodozemac
Rust
9
star
97

synapse-config-generator

A web based synapse config generator
JavaScript
9
star
98

synapse-user-restrictions

This module allows restricting users from performing actions such as creating rooms or sending invites.
Python
9
star
99

eigen-server

Example server and development test client for Linearized Matrix
TypeScript
9
star
100

matrix-analytics-events

Cross-platform definitions of analytics events raised by matrix SDKs
Kotlin
8
star