<commit_before>VRPhoto = function() {
};

VRScene = function() {
  this.renderObjectList = [];
  
  this.addPhoto = function(photo) {
    this.renderObjectList.push(photo);
  };
};

VRStory = function() {
  this.storyElement = null;
  this.parentElement = null;
  this.renderer = null;
  this.scene = null;
  this.camera = null;
  this.controls = null;
  this.effect = null;
  
  this.sceneList = [];

  this.onResize = function() {
    var containerWidth = this.parentElement.clientWidth;
    var containerHeight = this.parentElement.clientHeight;
    
    if (this.effect != null) { 
      if (this.effect.isFullscreenMode()) {
        this.camera.aspect = window.innerWidth / window.innerHeight;
        this.camera.updateProjectionMatrix();
        this.effect.setSize(window.innerWidth, window.innerHeight);
      }
      else {
        this.camera.aspect = containerWidth/containerHeight;
        this.camera.updateProjectionMatrix();
        this.effect.setSize(containerWidth, containerHeight);
      }
    }
  };
  
  this.setupSceneRenderer = function() {
    var containerWidth = this.parentElement.clientWidth;
    var containerHeight = this.parentElement.clientHeight;

    this.renderer = new THREE.WebGLRenderer({ antialias: true });
    this.renderer.setPixelRatio(window.devicePixelRatio);
    this.renderer.setSize( containerWidth, containerHeight );

    // Append the canvas element created by the renderer to document body element.
    // document.body.appendChild(renderer.domElement);
    this.parentElement.appendChild( this.renderer.domElement );
    
    // Create a three.js scene.
    this.scene = new THREE.Scene();

    // Create a three.js camera.
    this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.3, 10000);

    // Apply VR headset positional data to camera.
    this.controls = new THREE.VRControls(this.camera);

    // Apply VR stereo rendering to renderer.
    this.effect = new THREE.VRViewerEffect(this.renderer, 0);
    // effect.setSize(window.innerWidth, window.innerHeight);
    this.effect.setSize(containerWidth, containerHeight);
  };
  
  this.init = function(storyElement) {
    this.storyElement = storyElement;
    this.parentElement = this.storyElement.parentNode;
    
    var scenes=storyElement.children;
    for(sceneit = 0;sceneit < scenes.length; sceneit++) {
      var scene = scenes[sceneit];
      if(scene.nodeName=="SCENE"){
        var sceneElements = scene.children;
        for(sceneelemit = 0; sceneelemit < sceneElements.length; sceneelemit++){
//           this.parseSceneElement(sceneElements[sceneelemit]);
        }
      }
    }
    
    this.setupSceneRenderer();

    //last
    this.onResize();
  };
  
  
  this.addScene = function(scene) {
    this.sceneList.push(scene);
  };
};

VRStoryManager = function() {
  this.storyList = [];
  this.activeStory = -1;
  
  this.addStory = function(story) {
    this.storyList.push(story);
  };  
  
  this.onResize = function() {
    for(i=0;i<this.storyList.length;i++){
      this.storyList[i].onResize();
    }
  };
};

THREE.StoryParser = function () {
  this.storyManager = new VRStoryManager();

  this.parseDocXML = function(topElement) {
    var stories=topElement.getElementsByTagName("story");
    for(storyit = 0;storyit < stories.length; storyit++) {
      var story = stories[storyit];
      var vrStory = new VRStory();
      vrStory.init(story);
      this.storyManager.addStory(vrStory);
    }
  };
  
  this.onResize = function() {
    this.storyManager.onResize();
  };
};

THREE.VRParser = function ( container, textureDescription ) {
  var containerWidth = container.clientWidth;
  var containerHeight = container.clientHeight;
  // alert(containerWidth +","+ containerHeight);

  //Setup three.js WebGL renderer
  var renderer = new THREE.WebGLRenderer({ antialias: true });
  renderer.setPixelRatio(window.devicePixelRatio);
  renderer.setSize( containerWidth, containerHeight );

  // Append the canvas element created by the renderer to document body element.
  // document.body.appendChild(renderer.domElement);
  container.appendChild( renderer.domElement );

  // Create a three.js scene.
  var scene = new THREE.Scene();
<commit_msg>porting to parser<commit_after>require('./VRState.js');

VRPhoto = function() {
};

VRScene = function() {
  this.renderObjectList = [];
  
  this.addPhoto = function(photo) {
    this.renderObjectList.push(photo);
  };
};

VRStory = function() {
  this.storyElement = null;
  this.parentElement = null;
  this.renderer = null;
  this.scene = null;
  this.camera = null;
  this.controls = null;
  this.effect = null;
  
  this.sceneList = [];

  this.onResize = function() {
    var containerWidth = this.parentElement.clientWidth;
    var containerHeight = this.parentElement.clientHeight;
    
    if (this.effect != null) { 
      if (this.effect.isFullscreenMode()) {
        this.camera.aspect = window.innerWidth / window.innerHeight;
        this.camera.updateProjectionMatrix();
        this.effect.setSize(window.innerWidth, window.innerHeight);
      }
      else {
        this.camera.aspect = containerWidth/containerHeight;
        this.camera.updateProjectionMatrix();
        this.effect.setSize(containerWidth, containerHeight);
      }
    }
  };
  
  this.setupSceneRenderer = function() {
    var containerWidth = this.parentElement.clientWidth;
    var containerHeight = this.parentElement.clientHeight;

    this.renderer = new THREE.WebGLRenderer({ antialias: true });
    this.renderer.setPixelRatio(window.devicePixelRatio);
    this.renderer.setSize( containerWidth, containerHeight );

    // Append the canvas element created by the renderer to document body element.
    // document.body.appendChild(renderer.domElement);
    this.parentElement.appendChild( this.renderer.domElement );
    
    // Create a three.js scene.
    this.scene = new THREE.Scene();

    // Create a three.js camera.
    this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.3, 10000);

    // Apply VR headset positional data to camera.
    this.controls = new THREE.VRControls(this.camera);

    // Apply VR stereo rendering to renderer.
    this.effect = new THREE.VRViewerEffect(this.renderer, 0);
    // effect.setSize(window.innerWidth, window.innerHeight);
    this.effect.setSize(containerWidth, containerHeight);
  };
  
  this.init = function(storyElement) {
    this.storyElement = storyElement;
    this.parentElement = this.storyElement.parentNode;
    
    var scenes=storyElement.children;
    for(sceneit = 0;sceneit < scenes.length; sceneit++) {
      var scene = scenes[sceneit];
      if(scene.nodeName=="SCENE"){
        var sceneElements = scene.children;
        for(sceneelemit = 0; sceneelemit < sceneElements.length; sceneelemit++){
//           this.parseSceneElement(sceneElements[sceneelemit]);
        }
      }
    }
    
    this.setupSceneRenderer();

    //last
    this.onResize();
  };
  
  
  this.addScene = function(scene) {
    this.sceneList.push(scene);
  };
};

VRStoryManager = function() {
  this.storyList = [];
  this.activeStory = -1;
  this.stateToggler = new THREE.VRStateToggler();
  this.stateToggler.setState(THREE.VRStates.WINDOWED);

  this.addStory = function(story) {
    this.storyList.push(story);
  };  
  
  this.onResize = function() {
    for(i=0;i<this.storyList.length;i++){
      this.storyList[i].onResize();
    }
  };
  
  this.setActiveStory = function(idx) {
    //TODO: teardown story at previous index
    this.activeStory = idx;
    var story = this.storyList[this.activeStory];
    story.storyElement.appendChild(this.stateToggler.buttonLeft);
    story.storyElement.appendChild(this.stateToggler.buttonMiddle);
    story.storyElement.appendChild(this.stateToggler.buttonRight);
  };
};

THREE.StoryParser = function () {
  this.storyManager = new VRStoryManager();

  this.parseDocXML = function(topElement) {
    var stories=topElement.getElementsByTagName("story");
    for(storyit = 0;storyit < stories.length; storyit++) {
      var story = stories[storyit];
      var vrStory = new VRStory();
      vrStory.init(story);
      this.storyManager.addStory(vrStory);
    }
    
    if (stories.length>0){
      this.storyManager.setActiveStory(0);
    }
  };
  
  this.onResize = function() {
    this.storyManager.onResize();
  };
};

THREE.VRParser = function ( container, textureDescription ) {
  var containerWidth = container.clientWidth;
  var containerHeight = container.clientHeight;
  // alert(containerWidth +","+ containerHeight);

  //Setup three.js WebGL renderer
  var renderer = new THREE.WebGLRenderer({ antialias: true });
  renderer.setPixelRatio(window.devicePixelRatio);
  renderer.setSize( containerWidth, containerHeight );

  // Append the canvas element created by the renderer to document body element.
  // document.body.appendChild(renderer.domElement);
  container.appendChild( renderer.domElement );

  // Create a three.js scene.
  var scene = new THREE.Scene();

{'fraction_non_alphanumeric': 0.1236154186973859, 'fraction_numerical': 0.003544528134692069, 'mean_word_length': 3.3015721772272513, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 4, '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': '791978', 'n_tokens_mistral': 2784, 'n_tokens_neox': 2713, 'n_words': 508}