<commit_before>;function Asterank3D(opts) {
  'use strict';

  var me = this;

  /** Options and defaults **/
  opts.static_prefix = typeof opts.static_prefix === 'undefined' ?
    '/static' : opts.static_prefix;
  opts.default_camera_position = opts.camera_position || [0, -136, 113];
  opts.camera_fly_around = typeof opts.camera_fly_around === 'undefined' ?
    true : opts.camera_fly_around;
  opts.jed_delta = opts.jed_delta || 0.25;
  opts.meteoroid_factor = opts.meteoroid_factor || 6;
  opts.custom_object_fn = opts.custom_object_fn || null;
  opts.object_texture_path = opts.object_texture_path ||
    opts.static_prefix + "img/cloud4.png";
  opts.not_supported_callback = opts.not_supported_callback || function() {};
  opts.sun_scale = opts.sun_scale || 50;
  opts.show_dat_gui = opts.show_dat_gui || false;
  opts.top_object_color = opts.top_object_color ?
      new THREE.Color(opts.top_object_color) : new THREE.Color(0xDBDB70);
  opts.milky_way_visible = opts.milky_way_visible || true;

  // requestAnimFrame polyfill
  window.requestAnimFrame = (function(){
    return  window.requestAnimationFrame       ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame    ||
            window.oRequestAnimationFrame      ||
            window.msRequestAnimationFrame     ||
            function( callback ){
              window.setTimeout(callback, 1000 / 60);
            };
  })();

  /** Constants **/
  var WEB_GL_ENABLED = true
    , MAX_NUM_ORBITS = 4000
    , NUM_BIG_PARTICLES = 25;   // show this many asteroids with orbits

  /** Other variables **/
  var stats, scene, renderer, composer
    , camera, cameraControls
    , pi = Math.PI
    , using_webgl = false
    , object_movement_on = true
    , last_hovered
    , added_objects = []
    , planets = []
    , planet_orbits_visible = true
    , comet_orbit = null
    , jed = toJED(new Date())
    , particle_system_geometry = null
    , asteroids_loaded = false
    , display_date_last_updated = 0
    , first_loaded = false
    , skyBox = null

  // Lock/feature stuff
  var feature_map = {}       // map from object full name to Orbit3D instance
    , locked_object = null
    , locked_object_ellipse = null
    , locked_object_idx = -1
    , locked_object_size = -1
    , locked_object_color = -1

  // glsl and webgl stuff
  var attributes
    , uniforms
    , particleSystem

  // Initialization
  init();
  if (opts.show_dat_gui) {
    initGUI();
  }

  $('#btn-toggle-movement').on('click', function() {
    object_movement_on = !object_movement_on;
  });

  function initGUI() {
    var ViewUI = function() {
      this['Display date'] = '12/26/2012';
      this['Speed'] = opts.jed_delta;
      //this['Meteoroid speed'] = opts.meteoroid_factor;
      this['Show orbits'] = planet_orbits_visible;
      this['Show Milky Way'] = opts.milky_way_visible;
    };

    window.onload = function() {
      var text = new ViewUI();
      var gui = new dat.GUI({width: 300});
      gui.add(text, 'Display date').onChange(function(val) {
        var newdate = new Date(Date.parse(val));
        if (newdate) {
          var newjed = toJED(newdate);
          changeJED(newjed);
          if (!object_movement_on) {
            render(true); // force rerender even if simulation isn't running
          }
        }
      }).listen();
      gui.add(text, 'Speed', 0, 30).onChange(function(val) {
        opts.jed_delta = val / 30;
        var was_moving = object_movement_on;
        object_movement_on = opts.jed_delta > 0;
      });
      /*
      gui.add(text, 'Meteoroid speed', 1, 30).onChange(function(val) {
        opts.meteoroid_factor = val;
        for (var i = 0; i < added_objects.length; i++) {
          if (i >= planets.length) {
            // Adjust artificial speed for comet particles.
            attributes.P.value[i] =
              attributes.realP.value[i] / opts.meteoroid_factor;
          }
        }
        attributes.P.needsUpdate = true;
      });
      */
      gui.add(text, 'Show orbits').onChange(function() {
        togglePlanetOrbits();
      });
      gui.add(text, 'Show Milky Way').onChange(function() {
        toggleMilkyWay();
      });
      window.datgui = text;
    }; // end window onload
  } // end initGUI

  function togglePlanetOrbits() {
    if (planet_orbits_visible) {
      for (var i=0; i < planets.length; i++) {
        scene.remove(planets[i].getEllipse());
      }
    }
    else {
      for (var i=0; i < planets.length; i++) {
        scene.add(planets[i].getEllipse());
      }
    }
    planet_orbits_visible = !planet_orbits_visible;
  }

  function toggleMilkyWay() {
    skyBox.visible = opts.milky_way_visible = !opts.milky_way_visible;
  }

  function isWebGLSupported() {
    return WEB_GL_ENABLED && Detector.webgl;
  }

  function init() {
    // Sets up the scene
    $('#loading-text').html('renderer');
    if (isWebGLSupported()){
      renderer = new THREE.WebGLRenderer({
        antialias		: true	// to get smoother output
        //preserveDrawingBuffer	: true	// to allow screenshot
      });
      renderer.setClearColor(0x000000, 1);
      using_webgl = true;
      window.gl = renderer.getContext();
    }
    else {
      opts.not_supported_callback();
      return;
    }
    var $container = $(opts.container);
    var containerHeight = $container.height();
    var containerWidth = $container.width();
    renderer.setSize(containerWidth, containerHeight);
    opts.container.appendChild(renderer.domElement);

    THREEx.WindowResize(renderer, camera);

    // create a scene
    scene = new THREE.Scene();

    // put a camera in the scene
    var cameraH	= 3;
    var cameraW	= cameraH / containerHeight * containerWidth;
    window.cam = camera = new THREE.PerspectiveCamera(75, containerWidth / containerHeight, 1, 5000);

    // TODO include libs for this
    /*
    THREEx.WindowResize(renderer, camera, opts.container);    // handle window resize
    // Fullscreen api
    if (THREEx.FullScreen && THREEx.FullScreen.available()) {
      THREEx.FullScreen.bindKey();
    }
   */

    setDefaultCameraPosition();
    camera.lookAt(new THREE.Vector3(0,0,0));
    scene.add(camera);

    cameraControls = new THREE.TrackballControls(camera, opts.container);
    cameraControls.staticMoving = true;
    cameraControls.panSpeed = 2;
    cameraControls.zoomSpeed = 3;
    cameraControls.rotateSpeed = 3;
    cameraControls.maxDistance = 2200;
    cameraControls.dynamicDampingFactor = 0.5;
    window.cc = cameraControls;

    // Rendering solar system

    // "sun" - 0,0 marker
    $('#loading-text').html('sun');
    var texture = loadTexture(opts.static_prefix + 'img/sunsprite.png');<commit_msg>Fix window resize<commit_after>;function Asterank3D(opts) {
  'use strict';

  var me = this;

  /** Options and defaults **/
  opts.static_prefix = typeof opts.static_prefix === 'undefined' ?
    '/static' : opts.static_prefix;
  opts.default_camera_position = opts.camera_position || [0, -136, 113];
  opts.camera_fly_around = typeof opts.camera_fly_around === 'undefined' ?
    true : opts.camera_fly_around;
  opts.jed_delta = opts.jed_delta || 0.25;
  opts.meteoroid_factor = opts.meteoroid_factor || 6;
  opts.custom_object_fn = opts.custom_object_fn || null;
  opts.object_texture_path = opts.object_texture_path ||
    opts.static_prefix + "img/cloud4.png";
  opts.not_supported_callback = opts.not_supported_callback || function() {};
  opts.sun_scale = opts.sun_scale || 50;
  opts.show_dat_gui = opts.show_dat_gui || false;
  opts.top_object_color = opts.top_object_color ?
      new THREE.Color(opts.top_object_color) : new THREE.Color(0xDBDB70);
  opts.milky_way_visible = opts.milky_way_visible || true;

  // requestAnimFrame polyfill
  window.requestAnimFrame = (function(){
    return  window.requestAnimationFrame       ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame    ||
            window.oRequestAnimationFrame      ||
            window.msRequestAnimationFrame     ||
            function( callback ){
              window.setTimeout(callback, 1000 / 60);
            };
  })();

  /** Constants **/
  var WEB_GL_ENABLED = true
    , MAX_NUM_ORBITS = 4000
    , NUM_BIG_PARTICLES = 25;   // show this many asteroids with orbits

  /** Other variables **/
  var stats, scene, renderer, composer
    , camera, cameraControls
    , pi = Math.PI
    , using_webgl = false
    , object_movement_on = true
    , last_hovered
    , added_objects = []
    , planets = []
    , planet_orbits_visible = true
    , comet_orbit = null
    , jed = toJED(new Date())
    , particle_system_geometry = null
    , asteroids_loaded = false
    , display_date_last_updated = 0
    , first_loaded = false
    , skyBox = null

  // Lock/feature stuff
  var feature_map = {}       // map from object full name to Orbit3D instance
    , locked_object = null
    , locked_object_ellipse = null
    , locked_object_idx = -1
    , locked_object_size = -1
    , locked_object_color = -1

  // glsl and webgl stuff
  var attributes
    , uniforms
    , particleSystem

  // Initialization
  init();
  if (opts.show_dat_gui) {
    initGUI();
  }

  $('#btn-toggle-movement').on('click', function() {
    object_movement_on = !object_movement_on;
  });

  function initGUI() {
    var ViewUI = function() {
      this['Display date'] = '12/26/2012';
      this['Speed'] = opts.jed_delta;
      //this['Meteoroid speed'] = opts.meteoroid_factor;
      this['Show orbits'] = planet_orbits_visible;
      this['Show Milky Way'] = opts.milky_way_visible;
    };

    window.onload = function() {
      var text = new ViewUI();
      var gui = new dat.GUI({width: 300});
      gui.add(text, 'Display date').onChange(function(val) {
        var newdate = new Date(Date.parse(val));
        if (newdate) {
          var newjed = toJED(newdate);
          changeJED(newjed);
          if (!object_movement_on) {
            render(true); // force rerender even if simulation isn't running
          }
        }
      }).listen();
      gui.add(text, 'Speed', 0, 30).onChange(function(val) {
        opts.jed_delta = val / 30;
        var was_moving = object_movement_on;
        object_movement_on = opts.jed_delta > 0;
      });
      /*
      gui.add(text, 'Meteoroid speed', 1, 30).onChange(function(val) {
        opts.meteoroid_factor = val;
        for (var i = 0; i < added_objects.length; i++) {
          if (i >= planets.length) {
            // Adjust artificial speed for comet particles.
            attributes.P.value[i] =
              attributes.realP.value[i] / opts.meteoroid_factor;
          }
        }
        attributes.P.needsUpdate = true;
      });
      */
      gui.add(text, 'Show orbits').onChange(function() {
        togglePlanetOrbits();
      });
      gui.add(text, 'Show Milky Way').onChange(function() {
        toggleMilkyWay();
      });
      window.datgui = text;
    }; // end window onload
  } // end initGUI

  function togglePlanetOrbits() {
    if (planet_orbits_visible) {
      for (var i=0; i < planets.length; i++) {
        scene.remove(planets[i].getEllipse());
      }
    }
    else {
      for (var i=0; i < planets.length; i++) {
        scene.add(planets[i].getEllipse());
      }
    }
    planet_orbits_visible = !planet_orbits_visible;
  }

  function toggleMilkyWay() {
    skyBox.visible = opts.milky_way_visible = !opts.milky_way_visible;
  }

  function isWebGLSupported() {
    return WEB_GL_ENABLED && Detector.webgl;
  }

  function init() {
    // Sets up the scene
    $('#loading-text').html('renderer');
    if (isWebGLSupported()){
      renderer = new THREE.WebGLRenderer({
        antialias		: true	// to get smoother output
        //preserveDrawingBuffer	: true	// to allow screenshot
      });
      renderer.setClearColor(0x000000, 1);
      using_webgl = true;
      window.gl = renderer.getContext();
    }
    else {
      opts.not_supported_callback();
      return;
    }
    var $container = $(opts.container);
    var containerHeight = $container.height();
    var containerWidth = $container.width();
    renderer.setSize(containerWidth, containerHeight);
    opts.container.appendChild(renderer.domElement);

    // create a scene
    scene = new THREE.Scene();

    // put a camera in the scene
    var cameraH	= 3;
    var cameraW	= cameraH / containerHeight * containerWidth;
    window.cam = camera = new THREE.PerspectiveCamera(75, containerWidth / containerHeight, 1, 5000);

    THREEx.WindowResize(renderer, camera, opts.container);

    setDefaultCameraPosition();
    camera.lookAt(new THREE.Vector3(0,0,0));
    scene.add(camera);

    cameraControls = new THREE.TrackballControls(camera, opts.container);
    cameraControls.staticMoving = true;
    cameraControls.panSpeed = 2;
    cameraControls.zoomSpeed = 3;
    cameraControls.rotateSpeed = 3;
    cameraControls.maxDistance = 2200;
    cameraControls.dynamicDampingFactor = 0.5;
    window.cc = cameraControls;

    // Rendering solar system

    // "sun" - 0,0 marker
    $('#loading-text').html('sun');
    var texture = loadTexture(opts.static_prefix + 'img/sunsprite.png');
{'fraction_non_alphanumeric': 0.1236808139093463, 'fraction_numerical': 0.013514539518639436, 'mean_word_length': 2.662958843159066, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2786774', 'n_tokens_mistral': 4341, 'n_tokens_neox': 4117, 'n_words': 841}