janusweb 1.5.50 → 1.5.52

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.
package/scripts/portal.js CHANGED
@@ -124,6 +124,7 @@ elation.require(['janusweb.janusbase'], function() {
124
124
  if (asset) var thumb = asset.getInstance();
125
125
  if (thumb) {
126
126
  mat.map = thumb;
127
+ mat.map.encoding = THREE.sRGBEncoding;
127
128
  if (asset.loaded) {
128
129
  if (asset.hasalpha) {
129
130
  mat.transparent = true;
package/scripts/room.js CHANGED
@@ -81,7 +81,7 @@ elation.require([
81
81
  'server': { type: 'string' },
82
82
  'port': { type: 'int' },
83
83
  'rate': { type: 'int', default: 200 },
84
- 'voip': { type: 'string', default: 'none' },
84
+ 'voip': { type: 'string', default: 'janus' },
85
85
  'voipid': { type: 'string' },
86
86
  'voiprange': { type: 'float', default: 1 },
87
87
  'voipserver': { type: 'string', default: 'voip.janusxr.org' },
@@ -93,7 +93,10 @@ 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
+ 'players': { type: 'object', get: this.getRoomPlayers },
97
+ 'defaultview': { type: 'string' },
98
+ 'showavatar': { type: 'bool', default: true, set: this.updateAvatarVisibility },
99
+ 'spawnradius': { type: 'float', default: 0 },
97
100
  });
98
101
 
99
102
  if (!roomTranslators) {
@@ -229,6 +232,11 @@ elation.require([
229
232
  this.updateToneMapping();
230
233
  this.setNearFar();
231
234
  this.setPlayerPosition();
235
+ if (typeof player != 'undefined' && this.defaultview && this.defaultview != player.cameraview) {
236
+ player.setCameraView(this.defaultview);
237
+ }
238
+ this.updateAvatarVisibility();
239
+
232
240
  elation.events.fire({element: this, type: 'room_active', data: this});
233
241
  }
234
242
  this.setPlayerPosition = function(pos, orientation) {
@@ -258,14 +266,22 @@ elation.require([
258
266
  document.location.hash = hash;
259
267
  }
260
268
  let spawnpoint = this.getSpawnpoint();
261
- player.startposition.copy(spawnpoint.position);
262
- player.startorientation.copy(spawnpoint.orientation);
269
+ if (typeof player != 'undefined') {
270
+ player.startposition.copy(spawnpoint.position);
271
+ player.startorientation.copy(spawnpoint.orientation);
272
+ }
263
273
  }
264
274
  this.getSpawnpoint = function(referrer) {
265
275
  let spawnpoint = {
266
276
  position: this.spawnpoint.position,
267
277
  orientation: this.spawnpoint.quaternion,
268
278
  };
279
+ if (this.spawnradius) {
280
+ let dist = Math.random() * this.spawnradius,
281
+ angle = Math.random() * 2 * Math.PI;
282
+ spawnpoint.position.x += Math.sin(angle) * dist;
283
+ spawnpoint.position.z += Math.cos(angle) * dist;
284
+ }
269
285
  if (referrer) {
270
286
  let links = this.getObjectsByTagName('link');
271
287
  for (let i = 0; i < links.length; i++) {
@@ -981,6 +997,12 @@ elation.require([
981
997
  this.flying = elation.utils.any(room.flying, true);
982
998
  this.teleport = elation.utils.any(room.teleport, true);
983
999
  this.pointerlock = elation.utils.any(room.pointerlock, true);
1000
+ this.defaultview = elation.utils.any(room.defaultview, null);
1001
+ this.showavatar = elation.utils.any(room.showavatar, true);
1002
+ if ('spawnradius' in room) this.spawnradius = room.spawnradius;
1003
+ if (typeof player != 'undefined' && this.defaultview && this.defaultview != player.cameraview) {
1004
+ player.setCameraView(this.defaultview);
1005
+ }
984
1006
  //if (room.col) this.properties.col = room.col;
985
1007
 
986
1008
  this.properties.walk_speed = room.walk_speed || 1.8;
@@ -1374,7 +1396,7 @@ elation.require([
1374
1396
  if (this.jsobjects[objectargs.js_id]) {
1375
1397
  objectargs.js_id = objectargs.js_id + '_' + window.uniqueId();
1376
1398
  }
1377
- var object = parentobj.spawn(realtype, this.roomid + '_' + objectargs.js_id, objectargs),
1399
+ var object = parentobj.spawn(realtype, room.roomid + (parentobj.js_id ? '_' + parentobj.js_id : '') + '_' + objectargs.js_id, objectargs),
1378
1400
  proxyobj = object.getProxyObject(customElement);
1379
1401
  if (proxyobj && objectargs.js_id && !objectargs.isinternal && (parentobj == this || 'js_id' in args)) {
1380
1402
  this.jsobjects[objectargs.js_id] = proxyobj;
@@ -2131,6 +2153,8 @@ elation.require([
2131
2153
  voiprange: ['property', 'voiprange'],
2132
2154
  voipserver: ['property', 'voipserver'],
2133
2155
  players: ['property', 'players'],
2156
+ defaultview: ['property', 'defaultview'],
2157
+ showavatar: ['property', 'showavatar'],
2134
2158
 
2135
2159
  localToWorld: ['function', 'localToWorld'],
2136
2160
  worldToLocal: ['function', 'worldToLocal'],
@@ -2852,6 +2876,9 @@ console.log('dispatch to parent', event, this, event.target);
2852
2876
  gain.gain.cancelScheduledValues(ctx.currentTime);
2853
2877
  gain.gain.linearRampToValueAtTime(gain.gain.value, ctx.currentTime);
2854
2878
  gain.gain.linearRampToValueAtTime(value, ctx.currentTime + time);
2879
+ if (gain.gain.value == 0) {
2880
+ gain.gain.value = .01;
2881
+ }
2855
2882
  }
2856
2883
  }
2857
2884
  this.fadeAudioOut = function(time=4, value=0) {
@@ -3004,6 +3031,19 @@ console.log('unknown material', mat);
3004
3031
  }
3005
3032
  return players;
3006
3033
  }
3034
+ this.updateAvatarVisibility = function() {
3035
+ if (typeof player != 'undefined' && player.ghost) {
3036
+ if (this.showavatar) {
3037
+ player.ghost.visible = true;
3038
+ if (player.ghost.body) player.ghost.body.visible = true;
3039
+ if (player.ghost.head) player.ghost.head.visible = true;
3040
+ } else {
3041
+ player.ghost.visible = false;
3042
+ if (player.ghost.body) player.ghost.body.visible = false;
3043
+ if (player.ghost.head) player.ghost.head.visible = false;
3044
+ }
3045
+ }
3046
+ }
3007
3047
  }, elation.engine.things.generic);
3008
3048
  });
3009
3049