janusweb 1.5.44 → 1.5.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -102,7 +102,7 @@ elation.elements.define('janus-comms-userlist', class extends elation.elements.u
102
102
  elation.events.add(this.janusweb, 'room_load_start', (ev) => { this.updateRoom(ev.data); });
103
103
  elation.events.add(this.janusweb.network, 'janusweb_user_joined,janusweb_user_left,janusweb_user_disconnected', (ev) => this.updateUsers());
104
104
  setTimeout(() => {
105
- this.updateUsers();
105
+ //this.updateUsers();
106
106
  this.updateRoom(room);
107
107
  }, 100);
108
108
  }
@@ -117,8 +117,10 @@ elation.elements.define('janus-comms-userlist', class extends elation.elements.u
117
117
  }
118
118
  updateRoom(room) {
119
119
  this.room = room;
120
- this.innerHTML = '';
121
- this.elements = elation.elements.fromTemplate('janus.comms.userlist', this);
120
+ //this.innerHTML = '';
121
+ if (!this.elements) {
122
+ this.elements = elation.elements.fromTemplate('janus.comms.userlist', this);
123
+ }
122
124
  this.userlist_room = this.userlist_room;
123
125
  this.userlist_online = this.userlist_online;
124
126
  this.userlist_friends = this.userlist_friends;
@@ -135,11 +137,12 @@ elation.elements.define('janus-comms-userlist', class extends elation.elements.u
135
137
  if (!janus.network) return;
136
138
  var remoteplayers = janus.network.remoteplayers;
137
139
  var users = Object.keys(remoteplayers);
138
- users.unshift(player.userid);
140
+ //users.unshift(player.userid);
139
141
 
140
142
  if (this.elements.roomusers) {
141
143
  this.elements.roomusers.value = users.length;
142
144
  }
145
+ this.userlist_room = this.querySelector('ui-list[name="userlist_room"]');
143
146
  if (this.userlist_room) {
144
147
  this.userlist_room.setItems(users);
145
148
  }
@@ -1235,7 +1235,7 @@ ui-spinner .loading-text {
1235
1235
  -webkit-animation: loading-text-opacity 2s linear 0s infinite normal;
1236
1236
  animation: loading-text-opacity 2s linear 0s infinite normal;
1237
1237
  color: #ffffff;
1238
- font-family: "Helvetica Neue, "Helvetica", ""arial";
1238
+ font-family: "Helvetica Neue", "Helvetica", "arial";
1239
1239
  font-size: 10px;
1240
1240
  font-weight: bold;
1241
1241
  margin-top: 45px;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "janusweb",
3
3
  "description": "Web client for JanusVR worlds",
4
- "version": "1.5.44",
4
+ "version": "1.5.47",
5
5
  "main": "scripts/janusweb.js",
6
6
  "author": "James Baicoianu",
7
7
  "license": "MIT",
@@ -69,6 +69,10 @@ elation.require(['janusweb.janusbase'], function() {
69
69
  },
70
70
  select(object) {
71
71
  this.selected = object;
72
+ if (!object) {
73
+ this.deselect();
74
+ return;
75
+ }
72
76
  let objmeshes = [], skinnedmeshes = [];
73
77
  object.traverseObjects(n => {
74
78
  if (n instanceof THREE.Mesh && n.material !== this.outlinematerial) {
@@ -336,8 +336,8 @@ JanusClientConnection.prototype.connect = function() {
336
336
  this._websocket.onclose = function() {
337
337
  this.status = 0;
338
338
  this.dispatchEvent({type: 'disconnect'});
339
- if (this.pendingReconnect) {
340
- this.connect();
339
+ if (!this.pendingReconnect) {
340
+ this.reconnect();
341
341
  }
342
342
  }.bind(this);
343
343
 
@@ -346,10 +346,10 @@ JanusClientConnection.prototype.connect = function() {
346
346
  JanusClientConnection.prototype.reconnect = function(force) {
347
347
  var now = new Date().getTime();
348
348
  if (force || this.lastattempt + this.reconnectdelay <= now) {
349
+ this.pendingReconnect = true;
349
350
  if (this._websocket.readyState == this._websocket.OPEN) {
350
351
  console.log('Socket already connected, disconnecting');
351
352
  this.disconnect();
352
- this.pendingReconnect = true;
353
353
  } else {
354
354
  console.log('Reconnecting...');
355
355
  this.connect();
@@ -392,12 +392,18 @@ JanusClientConnection.prototype.setUserId = function(userId) {
392
392
  };
393
393
 
394
394
  JanusClientConnection.prototype.send = function(msg) {
395
- try {
396
- this._websocket.send(JSON.stringify(msg) + '\r\n');
397
- } catch (e) {
395
+ if (this._websocket.readyState == 3) {
398
396
  this.msgQueue.push(msg);
397
+ if (!this.pendingReconnect) {
398
+ this.reconnect();
399
+ }
400
+ } else {
401
+ try {
402
+ this._websocket.send(JSON.stringify(msg) + '\r\n');
403
+ } catch (e) {
404
+ this.msgQueue.push(msg);
405
+ }
399
406
  }
400
- //this.reconnect();
401
407
  };
402
408
 
403
409
  JanusClientConnection.prototype.onMessage = function(msg) {
@@ -191,7 +191,8 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
191
191
  emissive: 0x444400,
192
192
  alphaTest: .01,
193
193
  depthTest: false,
194
- depthWrite: false
194
+ depthWrite: false,
195
+ side: this.cull_face == 'none' ? THREE.DoubleSide : n.material.side,
195
196
  });
196
197
  }
197
198
  n.userData.thing = this;
@@ -393,7 +393,6 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
393
393
  sourcecontainer.traverse(n => { /*console.log(' - ', n); */ if (n instanceof THREE.SkinnedMesh && n.skeleton) sourcemesh = n; });
394
394
  }
395
395
  this.objects['3d'].traverse(n => { if (n instanceof THREE.SkinnedMesh && n.skeleton) destmesh = n; });
396
- //console.log('RETARGET ANI*MATION', clip, sourcemesh, destmesh, sourcecontainer);
397
396
  let remove = [];
398
397
  if (this.body && this.body.modelasset && this.body.modelasset.vrm) {
399
398
  let vrm = this.body.modelasset.vrm;
@@ -432,7 +431,6 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
432
431
  let [name, property] = track.name.split('.');
433
432
  let srcbone = sourcemesh.skeleton.getBoneByName(name);
434
433
  let dstbone = destmesh.skeleton.getBoneByName(name);
435
- //console.log(' - fix track', name, property, track, srcbone, dstbone);
436
434
  if (dstbone) {
437
435
  let scale = srcbone.position.length() / dstbone.position.length();
438
436
  if (property == 'position') {
@@ -447,6 +445,41 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
447
445
  remove.push(track);
448
446
  }
449
447
  });
448
+ } else {
449
+ let armature = sourcecontainer.getObjectByName('Armature');
450
+ newclip.tracks.forEach(track => {
451
+ track.name = track.name.replace('mixamorig', '');
452
+ let p = track.name.split('.');
453
+ if (p[1] == 'position') {
454
+ for (let i = 0; i < track.values.length / 3; i++) {
455
+ track.values[i * 3] *= armature.scale.x;
456
+ track.values[i * 3 + 1] *= armature.scale.y;
457
+ track.values[i * 3 + 2] *= armature.scale.z;
458
+ }
459
+ }
460
+ if (p[0] == 'Hips') {
461
+ if (p[1] == 'position') {
462
+ let v = new THREE.Vector3();
463
+ for (let i = 0; i < track.values.length / 3; i++) {
464
+ v.set(track.values[i * 3], track.values[i * 3 + 1], track.values[i * 3 + 2]).applyQuaternion(armature.quaternion);
465
+ //console.log('position rotation', v, [track.values[i * 3], track.values[i * 3 + 1], track.values[i * 3 + 2]], track);
466
+ track.values[i * 3] = v.x;
467
+ track.values[i * 3 + 1] = v.y;
468
+ track.values[i * 3 + 2] = v.z;
469
+ }
470
+ } else if (p[1] == 'quaternion') {
471
+ //console.log('apply rotation', track);
472
+ let q = new THREE.Quaternion();
473
+ for (let i = 0; i < track.values.length / 4; i++) {
474
+ q.set(track.values[i * 4], track.values[i * 4 + 1], track.values[i * 4 + 2], track.values[i * 4 + 3]).premultiply(armature.quaternion);
475
+ track.values[i * 4] = q.x;
476
+ track.values[i * 4 + 1] = q.y;
477
+ track.values[i * 4 + 2] = q.z;
478
+ track.values[i * 4 + 3] = q.w;
479
+ }
480
+ }
481
+ }
482
+ });
450
483
  }
451
484
  remove.forEach(track => {
452
485
  let idx = newclip.tracks.indexOf(track);
@@ -313,7 +313,7 @@ elation.require(['engine.things.generic', 'janusweb.external.webxr-input-profile
313
313
  let visualResponse = component.visualResponses[k];
314
314
  // Find the topmost node in the visualization
315
315
  const valueNode = motionControllerRoot.getObjectByName(visualResponse.valueNodeName);
316
-
316
+ if (!valueNode) continue;
317
317
  // Calculate the new properties based on the weight supplied
318
318
  if (visualResponse.valueNodeProperty === 'visibility') {
319
319
  valueNode.visible = visualResponse.value;
@@ -103,7 +103,7 @@ elation.require(['janusweb.external.JanusClientConnection', 'janusweb.external.J
103
103
  }
104
104
  this.getServerForRoom = function(room) {
105
105
  var serverurl = this.getServerURLForRoom(room, true);
106
- if (serverurl && !this.servers[serverurl]) {
106
+ if (serverurl && !this.servers[serverurl] && !room.private) {
107
107
  var server = new JanusClientConnection({
108
108
  host: serverurl,
109
109
  userId: this.janusweb.userId,
package/scripts/object.js CHANGED
@@ -1018,10 +1018,10 @@ elation.require(['janusweb.janusbase', 'janusweb.websurface'], function() {
1018
1018
  m.opacity = (typeof oldmat.opacity != 'undefined' ? parseFloat(oldmat.opacity) : 1) * this.opacity;
1019
1019
  m.alphaTest = this.alphatest;
1020
1020
  m.aoMap = oldmat.aoMap;
1021
- m.normalMap = oldmat.normalMap;
1022
- m.bumpMap = oldmat.bumpMap;
1023
-
1024
1021
  if (!(m instanceof THREE.MeshBasicMaterial)) {
1022
+ m.normalMap = oldmat.normalMap;
1023
+ m.bumpMap = oldmat.bumpMap;
1024
+
1025
1025
  if (oldmat.emissiveMap) {
1026
1026
  m.emissiveMap = oldmat.emissiveMap;
1027
1027
  m.emissive.setRGB(1,1,1);
@@ -141,7 +141,7 @@ elation.component.add('engine.things.remoteplayer', function() {
141
141
  this.setVolume = async function(volume) {
142
142
  if (this.mouth) {
143
143
  if (!this.mouth.audio) {
144
- await this.mout.createAudio(null, listener);
144
+ await this.mouth.createAudio(null, listener);
145
145
  }
146
146
  this.mouth.audio.gain.gain.value = volume;
147
147
  }
package/scripts/room.js CHANGED
@@ -93,6 +93,7 @@ elation.require([
93
93
  'onload': { type: 'string' },
94
94
  'sync': { type: 'boolean', default: false },
95
95
  'pointerlock': { type: 'boolean', default: true, set: this.updatePointerLock },
96
+ 'players': { type: 'object', get: this.getRoomPlayers }
96
97
  });
97
98
 
98
99
  if (!roomTranslators) {
@@ -317,16 +318,26 @@ elation.require([
317
318
  var assets = [];
318
319
  if (this.skybox_equi) {
319
320
  let equi = this.getAsset('image', this.skybox_equi);
320
- elation.events.add(equi, 'asset_load', ev => {
321
- this.skyboxtexture = ev.target._texture;
321
+ if (equi.loaded) {
322
+ this.skyboxtexture = equi.getInstance();
322
323
  this.skyboxtexture.mapping = THREE.EquirectangularReflectionMapping;
323
324
  this.skyboxtexture.encoding = THREE.sRGBEncoding;
324
325
  if (this.janus.currentroom === this) {
325
326
  this.skyboxobj.setTexture(this.skyboxtexture);
326
327
  }
327
328
  elation.events.fire({element: this, type: 'skybox_update'});
328
- });
329
- equi.getInstance();
329
+ } else {
330
+ elation.events.add(equi, 'asset_load', ev => {
331
+ this.skyboxtexture = ev.target._texture;
332
+ this.skyboxtexture.mapping = THREE.EquirectangularReflectionMapping;
333
+ this.skyboxtexture.encoding = THREE.sRGBEncoding;
334
+ if (this.janus.currentroom === this) {
335
+ this.skyboxobj.setTexture(this.skyboxtexture);
336
+ }
337
+ elation.events.fire({element: this, type: 'skybox_update'});
338
+ });
339
+ equi.getInstance();
340
+ }
330
341
  } else if (hasSkybox) {
331
342
  assets = [
332
343
  this.getAsset('image', this.skybox_right_id || 'black'),
@@ -2049,7 +2060,7 @@ elation.require([
2049
2060
  var hashargs = elation.url();
2050
2061
  var host = elation.utils.any(this.server, hashargs['janus.server'], elation.config.get('janusweb.network.host')),
2051
2062
  port = elation.utils.any(this.port, hashargs['janus.port'], elation.config.get('janusweb.network.port'), 5567);
2052
- this._server = this.janusweb.getConnection(host, port, this.url);
2063
+ this._server = this.janus.network.getServerForRoom(this);
2053
2064
  }
2054
2065
  return this._server;
2055
2066
  }
@@ -2117,6 +2128,7 @@ elation.require([
2117
2128
  voipid: ['property', 'voipid'],
2118
2129
  voiprange: ['property', 'voiprange'],
2119
2130
  voipserver: ['property', 'voipserver'],
2131
+ players: ['property', 'players'],
2120
2132
 
2121
2133
  localToWorld: ['function', 'localToWorld'],
2122
2134
  worldToLocal: ['function', 'worldToLocal'],
@@ -2797,6 +2809,7 @@ console.log('dispatch to parent', event, this, event.target);
2797
2809
  child.die();
2798
2810
  }
2799
2811
  }
2812
+ elation.events.fire({type: 'janus_room_unload', element: this});
2800
2813
  }
2801
2814
  this.getAudioNodes = function() {
2802
2815
  return new Promise(async (resolve, reject) => {
@@ -2980,6 +2993,15 @@ console.log('unknown material', mat);
2980
2993
  }
2981
2994
  }
2982
2995
  }
2996
+ this.getRoomPlayers = function() {
2997
+ let players = {};
2998
+ for (let k in janus.network.remoteplayers) {
2999
+ if (this.janus.network.remoteplayers[k].room === this) {
3000
+ players[k] = this.janus.network.remoteplayers[k];
3001
+ }
3002
+ }
3003
+ return players;
3004
+ }
2983
3005
  }, elation.engine.things.generic);
2984
3006
  });
2985
3007