janusweb 1.5.48 → 1.5.50

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.
@@ -99,7 +99,7 @@ elation.elements.define('janus-comms-userlist', class extends elation.elements.u
99
99
  this.userlist_friends = this.elements.userlist_friends;
100
100
  this.usermarkers = {};
101
101
 
102
- elation.events.add(this.janusweb, 'room_load_start', (ev) => { this.updateRoom(ev.data); });
102
+ elation.events.add(this.janusweb, 'room_load_start', (ev) => { this.updateRoom(ev.data || ev.element); });
103
103
  elation.events.add(this.janusweb.network, 'janusweb_user_joined,janusweb_user_left,janusweb_user_disconnected', (ev) => this.updateUsers());
104
104
  setTimeout(() => {
105
105
  //this.updateUsers();
@@ -209,7 +209,7 @@ elation.elements.define('janus-comms-chat', class extends elation.elements.base
209
209
  }
210
210
  });
211
211
  elation.events.add(janus._target, 'clientprint', (ev) => this.handleClientPrint(ev.data));
212
- elation.events.add(this.janusweb, 'room_load_start', (ev) => { this.updateRoom(ev.data); });
212
+ elation.events.add(this.janusweb, 'room_load_start', (ev) => { this.updateRoom(ev.element); });
213
213
  // FIXME - first element with the current design is a <detail> element, but this is fragile if that changes
214
214
  this.elements[0].addEventListener('toggle', (ev) => this.elements.chatinput.focus());
215
215
  this.updateRoom(room);
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "janusweb",
3
3
  "description": "Web client for JanusVR worlds",
4
- "version": "1.5.48",
4
+ "version": "1.5.50",
5
5
  "main": "scripts/janusweb.js",
6
6
  "author": "James Baicoianu",
7
7
  "license": "MIT",
8
8
  "scripts": {
9
9
  "postinstall": "./utils/init.sh",
10
+ "clean": "./utils/clean-build.sh",
10
11
  "build": "./utils/build.sh",
11
12
  "postversion": "git push origin v`npm view janusweb version`",
12
13
  "test": "./utils/activate.sh && ./node_modules/.bin/karma start tests/karma.conf.js --single-run",
package/scripts/client.js CHANGED
@@ -9,9 +9,9 @@ elation.require(['elements.elements', 'elements', 'engine.engine', 'engine.asset
9
9
  var rootdir = elation.utils.any(args.rootdir, elation.config.get('dependencies.rootdir'), document.location.pathname);
10
10
  var path = elation.utils.any(args.path, elation.config.get('dependencies.path'), '/');
11
11
  var homepage = elation.utils.any(args.homepage, elation.config.get('janusweb.homepage'), document.location.href);
12
- var corsproxy = elation.utils.any(args.corsproxy, elation.config.get('engine.assets.corsproxy'), document.location.href);
12
+ var corsproxy = elation.utils.any(args.corsproxy && args.corsproxy != 'false', elation.config.get('engine.assets.corsproxy'), document.location.href);
13
13
  var container = elation.utils.any(args.container, document.body);
14
- var fullsize = elation.utils.any(args.fullsize, container == document.body);
14
+ var fullsize = elation.utils.any(args.fullsize && args.fullsize != 'false', container == document.body);
15
15
 
16
16
  if (elation.config.get('serviceworker.enabled') && 'serviceWorker' in navigator) {
17
17
  var workerscript = elation.config.get('serviceworker.script', 'service-worker.js');
@@ -65,11 +65,11 @@ elation.require(['elements.elements', 'elements', 'engine.engine', 'engine.asset
65
65
  append: container,
66
66
  homepage: homepage,
67
67
  corsproxy: corsproxy,
68
- showui: (args.showui && args.showui != "false"),
69
- shownavigation: (args.shownavigation && args.shownavigation != "false"),
68
+ showui: elation.utils.any(args.showui && args.showui != "false", true),
69
+ shownavigation: elation.utils.any(args.shownavigation && args.shownavigation != "false", true),
70
70
  uiconfig: args.uiconfig,
71
- showchat: elation.utils.any(args.showchat, true),
72
- usevoip: elation.utils.any(args.usevoip, false),
71
+ showchat: elation.utils.any(args.showchat && args.showchat != 'false', true),
72
+ usevoip: elation.utils.any(args.usevoip && args.usevoip != 'false', false),
73
73
  resolution: args.resolution,
74
74
  fullsize: fullsize,
75
75
  url: args.url,
@@ -52,6 +52,7 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
52
52
  hasposition: { type: 'boolean', default: true },
53
53
  gazetime: { type: 'float' },
54
54
  static: { type: 'boolean', default: false },
55
+ isinternal: { type: 'boolean', default: false },
55
56
  ongazeenter: { type: 'callback' },
56
57
  ongazeleave: { type: 'callback' },
57
58
  ongazeprogress: { type: 'callback' },
@@ -434,7 +435,7 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
434
435
  addForce: ['function', 'addForce'],
435
436
  removeForce: ['function', 'removeForce'],
436
437
  die: ['function', 'die'],
437
- refresh: [ 'function', 'refresh'],
438
+ refresh: ['function', 'refresh'],
438
439
  executeCallback: ['function', 'executeCallback'],
439
440
  isEqual: ['function', 'isEqual'],
440
441
  addClass: ['function', 'addClass'],
@@ -477,6 +478,8 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
477
478
  propertydefs[k] = {type: 'euler', default: v.clone() };
478
479
  } else if (typeof v == 'boolean') {
479
480
  propertydefs[k] = {type: 'boolean', default: v };
481
+ } else if (v instanceof CustomEvent) {
482
+ propertydefs[k] = {type: 'callback' };
480
483
  } else {
481
484
  propertydefs[k] = {type: 'object', default: v };
482
485
  }
@@ -38,6 +38,9 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
38
38
  if (dist < maxdist) {
39
39
  diffuseColor.a = clamp(((dist - mindist) / (maxdist - mindist)), 0., 1.);
40
40
  }
41
+ if (diffuseColor.a <= 1e-4) {
42
+ discard;
43
+ }
41
44
  `;
42
45
  }
43
46
  }
@@ -124,6 +127,7 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
124
127
  this.shoulders = this.createObject('object', {
125
128
  'js_id': this.properties.player_id + '_shoulders',
126
129
  'pos': V(0, 1.0, 0),
130
+ 'isinternal': true,
127
131
  });
128
132
  }
129
133
  this.setGhostAssets = function(assets) {
@@ -234,23 +238,13 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
234
238
  //pos: headpos.clone().negate(),
235
239
  //orientation: new THREE.Quaternion().setFromEuler(new THREE.Euler(0, Math.PI, 0)),
236
240
  //rotation: V(0, 180, 0),
237
- lighting: this.lighting,
238
- //cull_face: 'none'
239
- opacity: 0.9999,
240
- renderorder: this.renderorder || 100,
241
- shader_chunk_replace: (this.lighting ? {
242
- 'color_fragment': 'color_fragment_discard_close',
243
- } : {}),
244
241
  });
242
+ this.applyAvatarMaterial(this.face, 1);
245
243
  this.face.start();
246
244
  } else {
247
245
  this.face = headid;
248
246
  this.face.lighting = this.lighting;
249
- this.face.opacity = 0.9999;
250
- this.face.renderorder = this.renderorder || 100;
251
- this.face.shader_chunk_replace = (this.lighting ? {
252
- 'color_fragment': 'color_fragment_discard_close',
253
- } : {});
247
+ this.applyAvatarMaterial(this.face, 1);
254
248
  this.head.appendChild(headid);
255
249
  this.face.start();
256
250
  }
@@ -289,12 +283,9 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
289
283
  rotation: V(0, 180, 0),
290
284
  lighting: this.lighting,
291
285
  //cull_face: 'none'
292
- opacity: 0.9999,
293
- renderorder: this.renderorder || 100,
294
- shader_chunk_replace: (this.lighting ? {
295
- 'color_fragment': 'color_fragment_discard_close',
296
- } : {}),
286
+ isinternal: true,
297
287
  });
288
+ this.applyAvatarMaterial(this.body, 0);
298
289
  } else {
299
290
  this.body = bodyid;
300
291
  this.appendChild(bodyid);
@@ -448,7 +439,11 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
448
439
  } else {
449
440
  let armature = sourcecontainer.getObjectByName('Armature') || sourcecontainer;
450
441
  newclip.tracks.forEach(track => {
451
- track.name = track.name.replace('mixamorig', '');
442
+ //track.name = track.name.replace('mixamorig:', '');
443
+ let idx = track.name.indexOf(':');
444
+ if (idx > -1) {
445
+ track.name = track.name.substr(idx + 1);
446
+ }
452
447
  let p = track.name.split('.');
453
448
  if (p[1] == 'position') {
454
449
  for (let i = 0; i < track.values.length / 3; i++) {
@@ -701,19 +696,36 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
701
696
  this.setBody(false);
702
697
  }
703
698
  if (ghostdef._children) {
699
+ let potentialAttachments = [];
704
700
  for (var type in ghostdef._children) {
705
701
  for (var i = 0; i < ghostdef._children[type].length; i++) {
706
702
  let js_id = ghostdef._children[type][i].js_id;
707
- delete ghostdef._children[type][i].js_id;
703
+ //delete ghostdef._children[type][i].js_id;
704
+ ghostdef._children[type][i].isinternal = true;
708
705
  let childobj = this.createObject(type, ghostdef._children[type][i]);
709
706
  this.ghostchildren.push(childobj);
710
707
  if (js_id == 'head') {
711
708
  this.setHead(childobj, headpos, ghostdef.scale);
712
709
  } else if (js_id == 'body') {
713
710
  this.setBody(childobj, ghostdef.scale, ghostdef.pos);
711
+ } else {
712
+ potentialAttachments.push(childobj);
713
+ this.applyAvatarMaterial(childobj, 2);
714
+ childobj.traverse(obj => {
715
+ this.applyAvatarMaterial(obj, 3);
716
+ });
714
717
  }
715
718
  }
716
719
  }
720
+ this.body.addEventListener('load', ev => {
721
+ for (let i = 0; i < potentialAttachments.length; i++) {
722
+ let obj = potentialAttachments[i];
723
+ if (obj.js_id in this.body.parts) {
724
+ this.body.parts[obj.js_id].add(obj);
725
+ this.applyAvatarMaterial(obj, 3);
726
+ }
727
+ }
728
+ });
717
729
  }
718
730
  }
719
731
  }
@@ -723,7 +735,8 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
723
735
  'position': [0,1.0,0],
724
736
  'parent': this,
725
737
  'janus': this.janus,
726
- 'room': this.room
738
+ 'room': this.room,
739
+ 'isinternal': true,
727
740
  });
728
741
  }
729
742
  if (!this.hands) {
@@ -894,5 +907,13 @@ return;
894
907
  }
895
908
  return this._proxyobject;
896
909
  }
910
+ this.applyAvatarMaterial = function(obj, renderorderOffset=0) {
911
+ if (this.lighting && obj.lighting) {
912
+ obj.transparent = true;
913
+ if (obj.opacity == 1) obj.opacity = 0.9999;
914
+ if (!obj.renderorder) obj.renderorder = this.renderorder + renderorderOffset;
915
+ obj.shader_chunk_replace = { 'color_fragment': 'color_fragment_discard_close' };
916
+ }
917
+ }
897
918
  }, elation.engine.things.janusbase);
898
919
  });
@@ -147,6 +147,7 @@ document.body.dispatchEvent(click);
147
147
  this.currentavatar = '';
148
148
  this.getAvatarData().then(d => this.currentavatar = d);
149
149
  this.morphtargetchanges = {};
150
+ this.eventlistenerproxies = {};
150
151
  }
151
152
  this.createChildren = function() {
152
153
  elation.engine.things.janusplayer.extendclass.createChildren.call(this);
@@ -661,6 +662,9 @@ document.body.dispatchEvent(click);
661
662
  getSetting: ['function', 'getSetting'],
662
663
  setSetting: ['function', 'setSetting'],
663
664
  setAvatar: ['function', 'setAvatar'],
665
+ addEventListener: ['function', 'addEventListenerProxy'],
666
+ dispatchEvent: ['function', 'dispatchEvent'],
667
+ removeEventListener: ['function', 'removeEventListenerProxy'],
664
668
  });
665
669
  }
666
670
  return this._proxyobject;
@@ -1275,5 +1279,53 @@ document.body.dispatchEvent(click);
1275
1279
  }
1276
1280
  }
1277
1281
  }
1282
+ this.dispatchEvent = function(event, target) {
1283
+ if (!event.element) event.element = target || this;
1284
+ if (!event.target) {
1285
+ event.target = target || event.element;
1286
+ }
1287
+
1288
+ var handlerfn = 'on' + event.type;
1289
+ if (handlerfn in this) {
1290
+ this.executeCallback(this[handlerfn], event);
1291
+ }
1292
+
1293
+ // Bubble event up to parents, unless the event was thrown with bubbling disabled or an event handler called stopPropagation()
1294
+ let firedev = elation.events.fire(event);
1295
+ let returnValue = true;
1296
+ firedev.forEach(e => returnValue &= e.returnValue);
1297
+ if (event.bubbles !== false && returnValue && this.parent && this.parent.dispatchEvent) {
1298
+ event.element = this.parent;
1299
+ this.parent.dispatchEvent(event);
1300
+ }
1301
+ }
1302
+ this.addEventListenerProxy = function(name, handler, bubble) {
1303
+ var eventobj = {
1304
+ target: handler,
1305
+ fn: function(ev) {
1306
+ var proxyev = elation.events.clone(ev, {
1307
+ target: ev.target.getProxyObject(),
1308
+ });
1309
+ // Bind stopPropagation and preventDefault functions to the real event
1310
+ proxyev.stopPropagation = elation.bind(ev, ev.stopPropagation),
1311
+ proxyev.preventDefault = elation.bind(ev, ev.preventDefault),
1312
+ handler(proxyev);
1313
+ }
1314
+ };
1315
+ if (!this.eventlistenerproxies[name]) this.eventlistenerproxies[name] = [];
1316
+ this.eventlistenerproxies[name].push(eventobj);
1317
+
1318
+ elation.events.add(this, name, eventobj.fn, bubble);
1319
+ }
1320
+ this.removeEventListenerProxy = function(name, handler, bubble) {
1321
+ if (this.eventlistenerproxies[name]) {
1322
+ for (var i = 0; i < this.eventlistenerproxies[name].length; i++) {
1323
+ var evproxy = this.eventlistenerproxies[name][i];
1324
+ if (evproxy.target === handler) {
1325
+ elation.events.remove(this, name, evproxy.fn, bubble);
1326
+ }
1327
+ }
1328
+ }
1329
+ }
1278
1330
  }, elation.engine.things.player);
1279
1331
  });
package/scripts/object.js CHANGED
@@ -44,7 +44,7 @@ elation.require(['janusweb.janusbase', 'janusweb.websurface'], function() {
44
44
  lmap_id: { type: 'string', set: this.updateMaterial, comment: 'Lightmap texture ID' },
45
45
  video_id: { type: 'string', set: this.updateVideo, comment: 'Video texture ID' },
46
46
  shader_id: { type: 'string', set: this.updateMaterial, comment: 'Shader ID' },
47
- shader_chunk_replace: { type: 'object' },
47
+ shader_chunk_replace: { type: 'object', set: this.updateMaterial },
48
48
  url: { type: 'string', set: this.updateWebsurfaceURL },
49
49
  loop: { type: 'boolean' },
50
50
  websurface_id: { type: 'string', set: this.updateWebsurface, comment: 'WebSurface ID' },
package/scripts/room.js CHANGED
@@ -840,7 +840,7 @@ elation.require([
840
840
  }
841
841
  this.createLights();
842
842
  }
843
- this.createRoomObjects = function(roomdata, parent) {
843
+ this.createRoomObjects = function(roomdata, parent, isinternal) {
844
844
  var room = roomdata.room,
845
845
  assets = roomdata.assets || [];
846
846
 
@@ -853,6 +853,7 @@ elation.require([
853
853
  if (exclude.indexOf(k) == -1) {
854
854
  roomdata[k].forEach(elation.bind(this, function(n) {
855
855
  n.persist = true;
856
+ n.isinternal = isinternal;
856
857
  this.createObject(k, n, parent);
857
858
  }));
858
859
  }
@@ -1373,16 +1374,17 @@ elation.require([
1373
1374
  if (this.jsobjects[objectargs.js_id]) {
1374
1375
  objectargs.js_id = objectargs.js_id + '_' + window.uniqueId();
1375
1376
  }
1376
- var object = parentobj.spawn(realtype, this.roomid + '_' + objectargs.js_id, objectargs);
1377
- if (objectargs.js_id) {
1378
- this.jsobjects[objectargs.js_id] = object.getProxyObject(customElement);
1377
+ var object = parentobj.spawn(realtype, this.roomid + '_' + objectargs.js_id, objectargs),
1378
+ proxyobj = object.getProxyObject(customElement);
1379
+ if (proxyobj && objectargs.js_id && !objectargs.isinternal && (parentobj == this || 'js_id' in args)) {
1380
+ this.jsobjects[objectargs.js_id] = proxyobj;
1379
1381
  }
1380
1382
 
1381
1383
  if (realtype == 'janussound') {
1382
1384
  this.sounds[objectargs.sound_id] = object;
1383
1385
  this.sounds[objectargs.js_id] = object;
1384
1386
 
1385
- this.jsobjects[objectargs.js_id].addEventListener('sound_delayed', (ev) => this.handleDelayedSound(ev));
1387
+ proxyobj.addEventListener('sound_delayed', (ev) => this.handleDelayedSound(ev));
1386
1388
  }
1387
1389
  if (realtype == 'janusvideo') {
1388
1390
  this.videos[objectargs.video_id] = object;
@@ -1408,14 +1410,14 @@ elation.require([
1408
1410
  }
1409
1411
  children[k] = objs;
1410
1412
  }
1411
- this.createRoomObjects(children, this.jsobjects[objectargs.js_id]);
1413
+ this.createRoomObjects(children, proxyobj, objectargs.isinternal);
1412
1414
  }
1413
1415
 
1414
1416
  if (this.enabled && !skipstart) {
1415
1417
  object.start();
1416
1418
  }
1417
1419
 
1418
- return this.jsobjects[objectargs.js_id];
1420
+ return proxyobj;
1419
1421
  }
1420
1422
  this.appendChild = function(obj) {
1421
1423
  var proxyobj = obj
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+
3
+ [ -e elation ] && rm -r elation
4
+ [ -e node_modules ] && rm -r node_modules