<commit_before>elation.require(['engine.things.generic'], function() {
  elation.component.add('engine.things.janusxrplayer', function() {
    this.postinit = function() {
      elation.engine.things.janusxrplayer.extendclass.postinit.call(this);
      this.defineProperties({
        session: { type: 'object' }
      });
      if (this.session) {
        console.log('xr player gets a session', this.session);
        let sess = this.session;
        sess.addEventListener('inputsourceschange', (ev) => { this.processInputSources(this.session.inputSources);});
      }
      this.inputs = {};
      initJanusObjects();
      this.trackedobjects = {
        head: this.createObject('trackedplayer_head', { })
      };
      this.camera = this.spawn('camera', this.name + '_camera', { position: [0,0,0] } );
    }
    this.setSession = function(session) {
      this.session = session;
      console.log('xr player session changed', this.session);
      this.inputs = {};
      if (session) {
        session.addEventListener('inputsourceschange', (ev) => { this.processInputSources(this.session.inputSources);});
      } else {
        this.resetOrientation();
      }
    }
    this.resetOrientation = function() {
        player.pos.copy(this.position);
        //player.orientation.copy(this.orientation);
        player.head.orientation.set(0,0,0,1);
        player.head.position.set(0,0,0);
    }
    this.processInputSources = function(inputs) {
      for (let i = 0; i < inputs.length; i++) {
        let input = inputs[i];
        this.inputs[input.handedness] = input;
      }
    }
    this.updateXR = function(xrFrame) {
      if (!xrFrame) return;
      let xrReferenceFrame = this.getReferenceFrame();
      let viewerPose = xrFrame.getViewerPose(xrReferenceFrame);
      if (viewerPose) {
        this.trackedobjects['head'].updatePose(viewerPose);
      } else {
        // You've lost your head!  Should we do something about it?
      }
      for (let k in this.inputs) {
        let input = this.inputs[k];
        let id = 'hand_' + k;
        if (!this.trackedobjects[id]) {
          //this.trackedobjects[id] = this.spawn('janusxrplayer_trackedobject', null, { });
          this.trackedobjects[id] = this.createObject('trackedplayer_hand', { device: input });
        }
        let pose = xrFrame.getPose(input.gripSpace, xrReferenceFrame);
        if (pose) {
          this.trackedobjects[id].updatePose(pose);
          this.trackedobjects[id].visible = true;
        } else {
          this.trackedobjects[id].visible = false;
        }
      }
      player.pos.copy(this.position);
      //player.orientation.copy(this.orientation);
      player.head.orientation.copy(this.trackedobjects['head'].orientation);
      player.head.position.copy(this.trackedobjects['head'].position)<commit_msg>xrplayer follows player<commit_after>elation.require(['engine.things.generic'], function() {
  elation.component.add('engine.things.janusxrplayer', function() {
    this.postinit = function() {
      elation.engine.things.janusxrplayer.extendclass.postinit.call(this);
      this.defineProperties({
        session: { type: 'object' }
      });
      if (this.session) {
        console.log('xr player gets a session', this.session);
        let sess = this.session;
        sess.addEventListener('inputsourceschange', (ev) => { this.processInputSources(this.session.inputSources);});
      }
      this.inputs = {};
      initJanusObjects();
      this.trackedobjects = {
        head: this.createObject('trackedplayer_head', { })
      };
      this.camera = this.spawn('camera', this.name + '_camera', { position: [0,0,0] } );
    }
    this.setSession = function(session) {
      this.session = session;
      console.log('xr player session changed', this.session);
      this.inputs = {};
      if (session) {
        session.addEventListener('inputsourceschange', (ev) => { this.processInputSources(this.session.inputSources);});
      } else {
        this.resetOrientation();
      }
    }
    this.resetOrientation = function() {
        player.pos.copy(this.position);
        //player.orientation.copy(this.orientation);
        player.head.orientation.set(0,0,0,1);
        player.head.position.set(0,0,0);
    }
    this.processInputSources = function(inputs) {
      for (let i = 0; i < inputs.length; i++) {
        let input = inputs[i];
        this.inputs[input.handedness] = input;
      }
    }
    this.updateXR = function(xrFrame) {
      if (!xrFrame) return;
      let xrReferenceFrame = this.getReferenceFrame();
      let viewerPose = xrFrame.getViewerPose(xrReferenceFrame);
      if (viewerPose) {
        this.trackedobjects['head'].updatePose(viewerPose);
      } else {
        // You've lost your head!  Should we do something about it?
      }
      for (let k in this.inputs) {
        let input = this.inputs[k];
        let id = 'hand_' + k;
        if (!this.trackedobjects[id]) {
          //this.trackedobjects[id] = this.spawn('janusxrplayer_trackedobject', null, { });
          this.trackedobjects[id] = this.createObject('trackedplayer_hand', { device: input });
        }
        let pose = xrFrame.getPose(input.gripSpace, xrReferenceFrame);
        if (pose) {
          this.trackedobjects[id].updatePose(pose);
          this.trackedobjects[id].visible = true;
        } else {
          this.trackedobjects[id].visible = false;
        }
      }
      this.position.copy(player.pos);
      //player.orientation.copy(this.orientation);
      player.head.orientation.copy(this.trackedobjects['head'].orientation);
      player.head.position.copy(this.trackedobjects['head'].position)
{'fraction_non_alphanumeric': 0.14407079646017698, 'fraction_numerical': 0.0038938053097345134, 'mean_word_length': 2.686236138290933, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7357676', 'n_tokens_mistral': 1735, 'n_tokens_neox': 1701, 'n_words': 271}