janusweb 1.5.42 → 1.5.43

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.
@@ -3,6 +3,7 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
3
3
 
4
4
  elation.component.add('engine.things.janusplayer', function() {
5
5
  //this.defaultavatar = '<FireBoxRoom>\n <Assets>\n <AssetObject id="screen" src="https://web.janusxr.org/media/assets/hoverscreen.obj" mtl="https://web.janusxr.org/media/assets/hoverscreen.mtl" />\n </Assets>\n <Room>\n <Ghost id="januswebuser" col="#ffffff" lighting="true" head_pos="0 1.4 0" body_id="" eye_pos="0 1.6 0" userid_pos="0 0.5 0" cull_face="back" screen_name="screen_Cube.004">\n <Object id="screen" js_id="head" />\n </Ghost>\n </Room>\n</FireBoxRoom>'
6
+ //this.defaultavatar = '<FireBoxRoom>\n<Assets>\n<AssetObject id="screen" src="https://vesta.janusxr.org/avatars/static/janusweb/janusweb.obj.gz" mtl="https://vesta.janusxr.org/user_avatar/12689/janusweb.mtl" /></Assets>\n<Room>\n<Ghost id="januswebuser" head_id="screen" head_pos="0 1.4 0" body_id="" eye_pos="0 1.6 0" userid_pos="0 0.5 0" cull_face="back" />\n</Room>\n</FireBoxRoom>';
6
7
  this.defaultavatar = `
7
8
  <FireBoxRoom>
8
9
  <assets>
@@ -35,6 +36,8 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
35
36
  party_mode: { type: 'boolean', set: this.updatePartyMode },
36
37
  avatarsrc: { type: 'string' },
37
38
  cameraview: { type: 'string', default: 'firstperson' },
39
+ camerazoom: { type: 'float', default: 0 },
40
+ cameraangle: { type: 'float', default: 0 },
38
41
  decouplehead: { type: 'boolean', default: false },
39
42
  });
40
43
 
@@ -50,9 +53,9 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
50
53
  elation.events.add(this.engine.client.view.container, 'touchend', elation.bind(this, this.handleTouchEnd));
51
54
 
52
55
  this.controlstate2 = this.engine.systems.controls.addContext('janusplayer', {
53
- 'toggle_view': ['keyboard_v,keyboard_shift_v', elation.bind(this, this.toggleCamera)],
54
- 'zoom_out': ['mouse_wheel_down', ev => this.zoomView(-1)],
55
- 'zoom_in': ['mouse_wheel_up', ev => this.zoomView(1)],
56
+ 'toggle_view': ['keyboard_nomod_v,keyboard_shift_v', elation.bind(this, this.toggleCamera)],
57
+ 'zoom_out': ['mouse_wheel_down', ev => this.zoomView(-1, ev)],
58
+ 'zoom_in': ['mouse_wheel_up', ev => this.zoomView(1, ev)],
56
59
  //'browse_back': ['gamepad_any_button_4', elation.bind(this, this.browseBack)],
57
60
  //'browse_forward': ['gamepad_any_button_5', elation.bind(this, this.browseForward)],
58
61
  });
@@ -101,6 +104,17 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
101
104
  this.cursor_style = 'default';
102
105
  this.cursor_object = '';
103
106
  this.lookat_object = '';
107
+ window.addEventListener('blur', ev => {
108
+ if (document.pointerLockElement && document.activeElement instanceof HTMLIFrameElement) {
109
+ document.pointerLockElement.focus();
110
+ //this.disable();
111
+ this.engine.systems.controls.deactivateContext('janusplayer');
112
+ this.engine.systems.controls.activateContext('janusplayer');
113
+ let click = new MouseEvent('click', { });
114
+ document.body.dispatchEvent(click);
115
+ //setTimeout(() => this.enable(), 100);
116
+ }
117
+ });
104
118
 
105
119
  if (this.usevoip) {
106
120
  this.voip = new JanusVOIPRecorder({audioScale: 1024});
@@ -400,7 +414,7 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
400
414
  }
401
415
  if (this.controlstate.jump && !this.jumping) {
402
416
  let jumptime = 1;
403
- if (this.ghost && this.ghost.body.animations && this.ghost.body.animations.jump) {
417
+ if (this.ghost && this.ghost.body && this.ghost.body.animations && this.ghost.body.animations.jump) {
404
418
  let jumpanim = this.ghost.body.animations.jump;
405
419
  let jumpclip = jumpanim.getClip();
406
420
 
@@ -846,11 +860,18 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
846
860
  if (proxyobj) {
847
861
  //var realobj = this.room.getObjectFromProxy(proxyobj);
848
862
  if (proxyobj.parent) {
849
- proxyobj.parent.removeChild(proxyobj);
863
+ if (typeof proxyobj.parent.removeChild == 'function') {
864
+ proxyobj.parent.removeChild(proxyobj);
865
+ } else if (typeof proxyobj.parent.remove == 'function') {
866
+ proxyobj.parent.remove(proxyobj._target);
867
+ }
850
868
  }
851
869
  var realobj = proxyobj._target;
852
870
  if (realobj) {
853
871
  this.add(realobj);
872
+ if (typeof realobj.start == 'function') {
873
+ realobj.start();
874
+ }
854
875
  }
855
876
  }
856
877
  }
@@ -863,6 +884,9 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
863
884
  //var realobj = this.room.getObjectFromProxy(proxyobj);
864
885
  var realobj = proxyobj._target;
865
886
  if (realobj) {
887
+ if (typeof realobj.stop == 'function') {
888
+ realobj.stop();
889
+ }
866
890
  this.remove(realobj);
867
891
  }
868
892
  }
@@ -874,8 +898,9 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
874
898
  this.setCollider('sphere', {
875
899
  radius: this.collision_radius,
876
900
  });
877
- */
878
901
  this.pickable = false;
902
+ this.collidable = false;
903
+ */
879
904
  this.setCollider('capsule', {
880
905
  radius: this.collision_radius,
881
906
  length: 1,
@@ -951,6 +976,7 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
951
976
  }
952
977
  }
953
978
  this.handleTouchStart = function(ev) {
979
+ //if (!this.enabled) return;
954
980
  let halfscreenwidth = window.innerWidth / 2;
955
981
  this.enabled = true;
956
982
  for (let i = 0; i < ev.changedTouches.length; i++) {
@@ -1112,8 +1138,10 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
1112
1138
  elapsed = now - this.lookAtLERPstart,
1113
1139
  n = Math.min(1, Math.max(0, elapsed / this.lookAtLERPtime));
1114
1140
 
1115
- THREE.Quaternion.slerp(this.lookAtLERPq1body, this.lookAtLERPq2body, this.orientation, n);
1116
- THREE.Quaternion.slerp(this.lookAtLERPq1head, this.lookAtLERPq2head, this.head.orientation, n);
1141
+ //THREE.Quaternion.slerp(this.lookAtLERPq1body, this.lookAtLERPq2body, this.orientation, n);
1142
+ //THREE.Quaternion.slerp(this.lookAtLERPq1head, this.lookAtLERPq2head, this.head.orientation, n);
1143
+ this.orientation.slerpQuaternions(this.lookAtLERPq1body, this.lookAtLERPq2body, n);
1144
+ this.head.orientation.slerpQuaternions(this.lookAtLERPq1head, this.lookAtLERPq2head, n);
1117
1145
  if (n == 1) {
1118
1146
  this.lookAtLERPtime = 0;
1119
1147
  }
@@ -1136,16 +1164,35 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
1136
1164
  if (ev.value == 1) {
1137
1165
  if (this.cameraview == 'firstperson') {
1138
1166
  this.cameraview = 'thirdperson';
1139
- this.camera.position.z = 2;
1167
+ this.cameraangle = 0;
1168
+ this.camerazoom = 2;
1140
1169
  } else {
1141
1170
  this.cameraview = 'firstperson';
1142
- this.camera.position.z = 0;
1171
+ this.cameraangle = 0;
1172
+ this.camerazoom = 0;
1143
1173
  }
1174
+ this.updateCamera();
1144
1175
  }
1145
1176
  }
1146
- this.zoomView = function(amount) {
1177
+ this.zoomView = function(amount, ev) {
1147
1178
  if (this.cameraview == 'thirdperson') {
1148
- this.camera.position.z -= amount / 10;
1179
+ //this.camera.position.z -= amount / 10;
1180
+ //this.camera.position.z = Math.max(0.001, this.camera.position.z * (amount > 0 ? .95 : 1.05));
1181
+ let state = this.engine.systems.controls.state;
1182
+ if (state.keyboard_alt) {
1183
+ this.cameraangle += amount * Math.PI / 64;
1184
+ } else {
1185
+ this.camerazoom = Math.max(0.001, this.camerazoom * (amount > 0 ? .95 : 1.05));
1186
+ }
1187
+ this.updateCamera();
1188
+ }
1189
+ }
1190
+ this.updateCamera = function() {
1191
+ if (this.camera) {
1192
+ this.camera.fov = this.fov;
1193
+ this.camera.position.z = Math.cos(this.cameraangle) * this.camerazoom;
1194
+ this.camera.position.x = Math.sin(this.cameraangle) * this.camerazoom;
1195
+ this.camera.orientation.setFromEuler(new THREE.Euler(0, this.cameraangle, 0));
1149
1196
  }
1150
1197
  }
1151
1198
  this.setAnimationSequence = function(sequence) {
@@ -90,7 +90,7 @@ elation.require([
90
90
  this.engine.systems.controls.addContext('janus', {
91
91
  //'load_url': [ 'keyboard_tab', elation.bind(this, this.showLoadURL) ],
92
92
  'toggle_menu': [ 'keyboard_esc', elation.bind(this, this.toggleMenu) ],
93
- 'room_debug': [ 'keyboard_f6', elation.bind(this, this.showRoomDebug) ],
93
+ //'room_debug': [ 'keyboard_f6', elation.bind(this, this.showRoomDebug) ],
94
94
  'chat': [ 'keyboard_t', elation.bind(this, this.showChat) ],
95
95
  'bookmark': [ 'keyboard_ctrl_b', elation.bind(this, this.addBookmark) ],
96
96
  'mute': [ 'keyboard_ctrl_m', elation.bind(this, this.mute) ]
@@ -265,6 +265,10 @@ elation.require(['engine.things.generic', 'janusweb.external.webxr-input-profile
265
265
  pos: menupos,
266
266
  rotation: menurot,
267
267
  });
268
+ this.menupos = menupos;
269
+ this.menurot = menurot;
270
+ this.removeChild(this.menu);
271
+
268
272
  player.setHand(this.device.handedness, this.virtualskeleton);
269
273
  },
270
274
  updateDevice(device) {
@@ -390,10 +394,34 @@ elation.require(['engine.things.generic', 'janusweb.external.webxr-input-profile
390
394
  this.updateMotionControllerModel(this.motionController);
391
395
  }
392
396
  }
393
- if (this.pointer && raypose) {
394
- this.pointer.pos.copy(raypose.transform.position);
395
- this.pointer.orientation.copy(raypose.transform.orientation);
396
- this.pointer.updateCursorOpacity();
397
+ if (this.pointer) {
398
+ if (raypose) {
399
+ this.pointer.pos.copy(raypose.transform.position);
400
+ this.pointer.orientation.copy(raypose.transform.orientation);
401
+ this.pointer.updateCursorOpacity();
402
+ this.pointer.visible = this.visible && this.opacity > 0;
403
+ } else {
404
+ this.pointer.visible = false;
405
+ }
406
+ }
407
+ if (this.gamepad && this.gamepad.buttons && this.gamepad.buttons[4]) {
408
+ let button = this.gamepad.buttons[4];
409
+ if (button.pressed) {
410
+ this.buttonwaspressed = true;
411
+ } else if (this.buttonwaspressed && !button.pressed) {
412
+ this.buttonwaspressed = false;
413
+ if (!this.menu.parent || this.menu.parent === this) {
414
+ player.appendChild(this.menu);
415
+ player.worldToLocal(this.pointer.localToWorld(this.menu.pos.set(0,0,-.25)));
416
+ this.menu.billboard = 'y';
417
+ } else {
418
+ //this.appendChild(this.menu);
419
+ player.removeChild(this.menu);
420
+ this.menu.billboard = '';
421
+ this.menu.pos.copy(this.menupos);
422
+ //this.menu.visible = false;
423
+ }
424
+ }
397
425
  }
398
426
  },
399
427
  createButtons() {
@@ -587,6 +615,7 @@ elation.require(['engine.things.generic', 'janusweb.external.webxr-input-profile
587
615
  //this.cursor.zdir.copy(player.view_dir).multiplyScalar(-1);
588
616
  //this.cursor.zdir = normal;
589
617
  this.cursor.visible = true;
618
+ this.cursor.opacity = .8 * player.cursor_opacity;
590
619
  },
591
620
  updateCursorOpacity() {
592
621
  if (!this.activeobject) return;
@@ -605,6 +634,7 @@ elation.require(['engine.things.generic', 'janusweb.external.webxr-input-profile
605
634
  this.laser.updateColor();
606
635
  this.cursor.image_id = 'cursor_dot_active';
607
636
  this.cursor.opacity = player.cursor_opacity;
637
+ this.bonk.opacity = 0.2 * player.cursor_opacity;
608
638
  //this.laser.visible = false; // FIXME - hack to disable laser without breaking things
609
639
 
610
640
  /*
@@ -769,6 +799,34 @@ elation.require(['engine.things.generic', 'janusweb.external.webxr-input-profile
769
799
  fingernames: ['THUMB', 'INDEX', 'MIDDLE', 'RING', 'LITTLE'],
770
800
  phalanxnames: ['METACARPAL', 'PHALANX_PROXIMAL', 'PHALANX_DISTAL', 'PHALANX_TIP'],
771
801
 
802
+ jointnames: [
803
+ 'wrist',
804
+ 'thumb-metacarpal',
805
+ 'thumb-phalanx-proximal',
806
+ 'thumb-phalanx-distal',
807
+ 'thumb-tip',
808
+ 'index-finger-metacarpal',
809
+ 'index-finger-phalanx-proximal',
810
+ 'index-finger-phalanx-intermediate',
811
+ 'index-finger-phalanx-distal',
812
+ 'index-finger-tip',
813
+ 'middle-finger-metacarpal',
814
+ 'middle-finger-phalanx-proximal',
815
+ 'middle-finger-phalanx-intermediate',
816
+ 'middle-finger-phalanx-distal',
817
+ 'middle-finger-tip',
818
+ 'ring-finger-metacarpal',
819
+ 'ring-finger-phalanx-proximal',
820
+ 'ring-finger-phalanx-intermediate',
821
+ 'ring-finger-phalanx-distal',
822
+ 'ring-finger-tip',
823
+ 'pinky-finger-metacarpal',
824
+ 'pinky-finger-phalanx-proximal',
825
+ 'pinky-finger-phalanx-intermediate',
826
+ 'pinky-finger-phalanx-distal',
827
+ 'pinky-finger-tip',
828
+ ],
829
+
772
830
  isactive: true,
773
831
  handpos: null,
774
832
  p0: null,
@@ -781,11 +839,22 @@ elation.require(['engine.things.generic', 'janusweb.external.webxr-input-profile
781
839
  this.handmodel = this.parent.createObject('object', {
782
840
  id: 'cube',
783
841
  scale: V(.075, .025, .075),
784
- col: 'green'
842
+ col: 'green',
843
+ visible: false
785
844
  });
786
845
  this.tmpobj = new THREE.Object3D();
787
- this.joints = new THREE.InstancedMesh(new THREE.SphereBufferGeometry(1), new THREE.MeshPhysicalMaterial({color: 0xccffcc, metalness: .2, roughness: .5}), 26);
846
+ this.jointmaterial = new THREE.MeshPhysicalMaterial({color: 0xccffcc, metalness: 1, roughness: .5, emissive: 0xccffcc, transparent: true});
847
+ this.joints = new THREE.InstancedMesh(new THREE.SphereGeometry(1), this.jointmaterial, 26);
848
+ this.joints.frustumCulled = false;
788
849
  this.joints.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
850
+ let tmpobj = this.tmpobj;
851
+ for (let i = 0; i < 26; i++) {
852
+ tmpobj.position.set(Math.random(), Math.random(), Math.random());
853
+ tmpobj.scale.set(.0001, .0001, .0001);
854
+ tmpobj.updateMatrix();
855
+ this.joints.setMatrixAt(i, tmpobj.matrix);
856
+ }
857
+
789
858
  this.jointposes = {};
790
859
  this.objects['3d'].add(this.joints);
791
860
  this.handpos = new THREE.Vector3(0, 0, 0);
@@ -796,11 +865,14 @@ elation.require(['engine.things.generic', 'janusweb.external.webxr-input-profile
796
865
  this.p4 = new THREE.Vector3(0, 0, 0);
797
866
  },
798
867
  updatePose(xrFrame, xrReferenceFrame) {
799
- if (!this.hand || !this.joints || !this.hand[0]) return;
868
+ if (!this.hand || !this.joints || !this.tmpobj) {
869
+ return;
870
+ }
800
871
 
801
872
  let tmpobj = this.tmpobj,
802
873
  i = 0;
803
874
  let poses = this.jointposes;
875
+ /*
804
876
  let wristpose = xrFrame.getJointPose(this.hand[XRHand['WRIST']], xrReferenceFrame);
805
877
  this.jointposes['WRIST'] = wristpose;
806
878
  for (let fingernum = 0; fingernum < this.fingernames.length; fingernum++) {
@@ -820,15 +892,33 @@ elation.require(['engine.things.generic', 'janusweb.external.webxr-input-profile
820
892
  this.jointposes[jointname] = jointpose;
821
893
  }
822
894
  }
895
+ */
896
+ for ( const inputjoint of this.hand.values() ) {
897
+ const jointpose = xrFrame.getJointPose( inputjoint, xrReferenceFrame );
898
+ const jointname = inputjoint.jointName;
899
+ if (jointpose && jointpose.transform) {
900
+ let radius = Math.max(.002, jointpose.radius);
901
+ tmpobj.position.copy(jointpose.transform.position);
902
+ tmpobj.quaternion.copy(jointpose.transform.orientation);
903
+ tmpobj.scale.set(radius, radius, radius);
904
+ tmpobj.updateMatrix();
905
+ this.joints.setMatrixAt(i, tmpobj.matrix);
906
+ //FIVARSlog('xr.debug', 'update joint: ' + i + ', ' + jointname + ', ' + tmpobj.matrix.elements.join(', '));
907
+ }
908
+ i++;
909
+ this.jointposes[jointname] = jointpose;
910
+ }
823
911
  this.joints.instanceMatrix.needsUpdate = true;
824
-
825
- if (this.jointposes['WRIST']) this.localToWorld(this.handpos.copy(this.jointposes['WRIST'].transform.position));
826
- if (this.jointposes['THUMB_PHALANX_TIP']) this.localToWorld(this.p0.copy(this.jointposes['THUMB_PHALANX_TIP'].transform.position));
827
- if (this.jointposes['INDEX_PHALANX_TIP']) this.localToWorld(this.p1.copy(this.jointposes['INDEX_PHALANX_TIP'].transform.position));
828
- if (this.jointposes['MIDDLE_PHALANX_TIP']) this.localToWorld(this.p2.copy(this.jointposes['MIDDLE_PHALANX_TIP'].transform.position));
829
- if (this.jointposes['RING_PHALANX_TIP']) this.localToWorld(this.p3.copy(this.jointposes['RING_PHALANX_TIP'].transform.position));
830
- if (this.jointposes['LITTLE_PHALANX_TIP']) this.localToWorld(this.p4.copy(this.jointposes['LITTLE_PHALANX_TIP'].transform.position));
912
+ //this.joints.computeBoundingSphere();
913
+
914
+ if (this.jointposes['wrist']) this.localToWorld(this.handpos.copy(this.jointposes['wrist'].transform.position));
915
+ if (this.jointposes['thumb-tip']) this.localToWorld(this.p0.copy(this.jointposes['thumb-tip'].transform.position));
916
+ if (this.jointposes['index-finger-tip']) this.localToWorld(this.p1.copy(this.jointposes['index-finger-tip'].transform.position));
917
+ if (this.jointposes['middle-finger-tip']) this.localToWorld(this.p2.copy(this.jointposes['middle-finger-tip'].transform.position));
918
+ if (this.jointposes['ring-finger-tip']) this.localToWorld(this.p3.copy(this.jointposes['ring-finger-tip'].transform.position));
919
+ if (this.jointposes['pinky-finger-tip']) this.localToWorld(this.p4.copy(this.jointposes['pinky-finger-tip'].transform.position));
831
920
  this.isactive = true;
921
+ this.jointmaterial.opacity = player.cursor_opacity;
832
922
  }
833
923
  });
834
924
  janus.registerElement('trackedplayer_hand_virtualskeleton', {