-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: janusweb
action: commit
revision:
path_from:
revision_from: 5d154af38d60f5a8bee67dd44bda915d8992a64f:
path_to:
revision_to:

git.thebackupbox.net

janusweb

git://git.thebackupbox.net/janusweb

commit 5d154af38d60f5a8bee67dd44bda915d8992a64f
Author: James Baicoianu <james_github@baicoianu.com>
Date:   Fri May 6 00:00:46 2016 -0700

    Added janusweb remoteplayer

diff --git a/scripts/remoteplayer.js b/scripts/remoteplayer.js
new file mode 100644
index 0000000000000000000000000000000000000000..5115030335997896f9f656c5772b41a1953ea1e9
--- /dev/null
+++ b/scripts/remoteplayer.js
@@ -0,0 +1,98 @@
+elation.require(['engine.things.generic', 'engine.things.maskgenerator', 'janusweb.external.JanusVOIP'], function() {
+elation.component.add('engine.things.remoteplayer', function() {
+  this.postinit = function() {
+    this.defineProperties({
+      startposition: {type: 'vector3', default: new THREE.Vector3()},
+      player_id: {type: 'string', default: 'UnknownPlayer'},
+      player_name: {type: 'string', default: 'UnknownPlayer'},
+    });
+  };
+
+/*
+  this.createObject3D = function() {
+    var geo = new THREE.CylinderGeometry(1, 1, 4, 8),
+        mat = new THREE.MeshPhongMaterial({ color: 0x000000, transparent: true, opacity: 0.7 }),
+        mesh = new THREE.Mesh(geo, mat);
+    return mesh;
+  };
+*/
+
+  this.createChildren = function() {
+    this.torso = this.spawn('generic', this.properties.player_name + '_torso', {
+      'position': [0,1,0],
+    });
+    this.neck = this.torso.spawn('generic', this.properties.player_name + '_neck', {
+      'position': [0,0.6,0]
+    });
+    this.head = this.neck.spawn('generic', this.properties.player_name + '_head', {
+      'position': [0,0,0],
+    });
+    this.face = this.head.spawn('maskgenerator', this.properties.player_name + '_mask', {
+      'seed': this.properties.player_name,
+      'position': [0,0,-0.125],
+      collidable: false,
+      'tilesize': 0.075,
+      'player_id': this.properties.player_name
+    });
+    this.label = this.face.spawn('label', this.properties.player_name + '_label', {
+      size: .1,
+      align: 'center',
+      collidable: false,
+      text: this.properties.player_name,
+      position: [0,0.35,0],
+      orientation: [0,1,0,0]
+    });
+    this.mouth = this.face.spawn('sound', this.properties.player_name + '_voice', {
+    });
+    this.mouth.createAudio();
+    var context = this.mouth.audio.context;
+    this.voip = new JanusVOIPPlayer();
+    this.voip.start(context);
+    this.audiobuffer = new THREE.AudioBuffer(this.mouth.audio.context);
+    this.audiobuffer.buffer = this.voip.rawbuffer;
+console.log(this.audiobuffer, this.voip.rawbuffer);
+
+elation.events.add(this.voip, 'voip_player_data', function(ev) { console.log('got voip data', ev); });
+    this.audiobuffer.ready = true;
+    for ( var i = 0; i < this.audiobuffer.readyCallbacks.length; i ++ ) {
+
+      this.audiobuffer.readyCallbacks[ i ]( this.voip.rawbuffer );
+
+    }
+
+    this.mouth.audio.setBuffer(this.audiobuffer);
+  };
+  this.speak = function(noise) {
+console.log('someone said something', noise);
+
+    this.voip.speak(noise);
+
+    if (!this.mouth.audio.playing) {
+      this.mouth.audio.play();
+    }
+    this.label.material.color.setHex(0x00ff00);
+    if (this.talktimer) {
+      clearTimeout(this.talktimer);
+    }
+    this.talktimer = setTimeout(elation.bind(this, this.shutup), this.bufferlength * 500);
+
+  }
+  this.shutup = function() {
+    this.voip.silence();
+/*
+    if (this.mouth.audio.playing) {
+      this.mouth.audio.stop();
+    }
+    var bufferLeft = this.rawbuffer.getChannelData(0);
+    var bufferRight = this.rawbuffer.getChannelData(1);
+    for (var i = 0; i < bufferLeft.length; i++) {
+      bufferLeft[i] = bufferRight[i] = 0;
+    }
+    this.bufferoffset = 0;
+*/
+    this.label.material.color.setHex(0xcccccc);
+  }
+}, elation.engine.things.generic);
+
+});
+

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 14:17:38 2024