Networking module for Whitestorm.js [Alpha]
const app = new WHS.App({
// ...
new NETWORK.Connection({
host: 'localhost',
port: 3000,
protocol: 'http'
})
});
app.start();
const box = new WHS.Box({
geometry: {
width: 2,
height: 2,
depth: 2
},
modules: [
new NETWORK.Identity()
],
material: new THREE.MeshBasicMaterial({color: 0xff0000})
});
box.addTo(app);
const box = new WHS.Box({
geometry: {
width: 2,
height: 2,
depth: 4
},
modules: [
new NETWORK.Transform({
position: true,
rotation: true,
scale: false,
animation: true
})
],
material: new THREE.MeshBasicMaterial({color: 0xff0000})
});
box.addTo(app);
You can use this to allow for special events to be fired on objects. This is easy to do, and allows for great control over different objects.
const box = new WHS.Box({
geometry: {
width: 2,
height: 2,
depth: 4
},
modules: [
new NETWORK.Event({
name: 'myCustomEvent'
id: 0,
handler: (data) => {
doSomething();
};
})
],
material: new THREE.MeshBasicMaterial({color: 0xff0000})
});
box.addTo(app);