meta-client
Version:
redefining space
129 lines (85 loc) • 2.29 kB
Markdown

# The Meta Library
This library's goal is to provide the easiest possible and most accessible way to create shared virtual spaces.
On.Any.Possible.Device.
[](http://www.youtube.com/watch?v=cndRSDZwDBo)
# Installation
```
npm install meta-server
npm install meta-client
npm install
```
```
mkdir 'peopleslaguna'
cd 'peopleslaguna'
touch index.js
```
# Usage
# Server
```javascript
import * as META from 'meta-server'
const SERVER = new META.Server()
const SOCKET = new META.Socket(SERVER);
const DATABASE = new META.Database();
SERVER.start();
SOCKET.on('connection', (CLIENT) => {
CLIENT.emit('connected', { message: 'Welcome Human #', id: CLIENT.id });
DATABASE.get({}, (object) => {
CLIENT.emit('create', object);
});
CLIENT.on('receive', (data) => {
if(typeof data.object.id != undefined){
CLIENT.broadcast.to(data.space).emit('update', data);
DATABASE.update(data);
}else{
DATABASE.insert(data, (object) => {
SOCKET.to(data.space).emit('create', object);
});
}
});
});
```
# Client
```javascript
mkdir 'public'
cd 'public'
touch index.js
```
```javascript
import * as THREE from 'three'
import * as META from 'meta';
const SPACE = new META.Space();
const WORLD = new META.Space(SPACE);
const HUMAN = new META.Human(WORLD);
VOID.live( () => { SPACE.live(); });
VOID.live( () => { HUMAN.live(); });
HUMAN.on('touch', (data) => {
if(typeof data == undefined) return;
let object = new META.Materia();
if(HUMAN.device.vr){
object.position = data.position;
}else if(data.object.name == 'ground'){
object.position = data.point;
}
SPACE.emit(object);
});
HUMAN.on('grab', (data) => {
if(object.parent instanceof SPACE){
data.object.position.set(data.position.x,data.position.y,data.position.z)
SPACE.emit(data);
}
})
SPACE.on('receive', (data) => {
SPACE.add(new META.Materia(data));
})
```
# Run
```
npm run build && npm run bundle & npm run start
```
# Credits
All machines and humans of the space and the void.
# License
MIT
# Manifesto
This age of the old distribution of space will soon come to an end by technology.