<commit_before>goog.provide('og.Globus');

goog.require('og.webgl.Handler');
goog.require('og.Renderer');
goog.require('og.node.Planet');
goog.require('og.ellipsoid.wgs84');

/**
 * var globe = new og.Globus({
 *   viewExtent: new og.Extent(new og.LonLat(-180,-90), new og.LonLat(180,90)),
 *   ellipsoid: og.ellipsoid.wgs84,
 *   layers: [
 *     new og.layers.XYZ()
 *   ],
 *   terrains: [
 *     new og.terrain
 *   ],
 *   controls: [
 *     new og.controls.LayerSwitcher({autoActivated:true})
 *   ],
 *   name: "Earth",
 *   target: 'globus'
 */

og.Globus = function (options) {

    //Canvas creation.
    var _canvasId = og.Globus.CANVAS_ID_PREFIX + og.Globus.__id;
    var _canvas = document.createElement("canvas");
    _canvas.id = _canvasId;
    _canvas.style.width = "100%";
    _canvas.style.height = "100%";
    _canvas.style.display = "block";

    /**
     * @public
     * @type {Element}
     */
    this.div = document.getElementById(options.target);
    this.div.appendChild(_canvas);
    this.div.classList.add("ogViewport");
    function _disableWheel() { return false; };
    function _enableWheel() { return true; };
    this.div.onmouseenter = function () { document.onmousewheel = _disableWheel };
    this.div.onmouseleave = function () { document.onmousewheel = _enableWheel };

    //WegGL handler creation
    var _handler = new og.webgl.Handler(_canvasId);
    _handler.init();

    /**
     * @public
     * @type {Element}
     */
    this.renderer = new og.Renderer(_handler);
    this.renderer.init();
    this.renderer.div = this.div;

    //Skybox
    if (options.skybox) {
        this.renderer.addRenderNode(options.skybox);
    }

    /**
     * Planet node name. Access by this.renderer.<name>
     * @private
     * @type {String}
     */
    this._planetName = options.name ? options.name : og.Globus.PLANET_NAME_PREFIX + og.Globus.__id;

    /**
     * Planet node
     * @public
     * @type {Object}
     */
    this.planet = new og.node.Planet(this._planetName, options.ellipsoid ? options.ellipsoid : og.ellipsoid.wgs84);
    if (options.layers) {
        this.planet.addLayers(options.layers);
    }
    this.renderer.addRenderNode(this.planet);

    //Attach terrain provider
    if (options.terrain) {
        this.planet.setTerrainProvider(options.terrain);
    }

    //Add controls
    if (options.controls) {
        this.renderer.addControls(options.controls)
    }

    og.Globus.__id++;

    if (options.viewExtent) {
        this.planet.viewToExtent(options.viewExtent);
    }

    //Run!
    if (isUndefined(options.autoActivate) || options.autoActivate)
        this.renderer.start();
};

/**
 * og.Globus static variables
 *
 */
og.Globus.__id = 1;
og.Globus.CANVAS_ID_PREFIX = "globus_viewport_";
og.Globus.PLANET_NAME_PREFIX = "globus_planet_";

function isUndefined(obj) {
    return obj === void 0;
};<commit_msg>Terrain provider initialized before planet node has created.<commit_after>goog.provide('og.Globus');

goog.require('og.webgl.Handler');
goog.require('og.Renderer');
goog.require('og.node.Planet');
goog.require('og.ellipsoid.wgs84');

/**
 * var globe = new og.Globus({
 *   viewExtent: new og.Extent(new og.LonLat(-180,-90), new og.LonLat(180,90)),
 *   ellipsoid: og.ellipsoid.wgs84,
 *   layers: [
 *     new og.layers.XYZ()
 *   ],
 *   terrains: [
 *     new og.terrain
 *   ],
 *   controls: [
 *     new og.controls.LayerSwitcher({autoActivated:true})
 *   ],
 *   name: "Earth",
 *   target: 'globus'
 */

og.Globus = function (options) {

    //Canvas creation.
    var _canvasId = og.Globus.CANVAS_ID_PREFIX + og.Globus.__id;
    var _canvas = document.createElement("canvas");
    _canvas.id = _canvasId;
    _canvas.style.width = "100%";
    _canvas.style.height = "100%";
    _canvas.style.display = "block";

    /**
     * @public
     * @type {Element}
     */
    this.div = document.getElementById(options.target);
    this.div.appendChild(_canvas);
    this.div.classList.add("ogViewport");
    function _disableWheel() { return false; };
    function _enableWheel() { return true; };
    this.div.onmouseenter = function () { document.onmousewheel = _disableWheel };
    this.div.onmouseleave = function () { document.onmousewheel = _enableWheel };

    //WegGL handler creation
    var _handler = new og.webgl.Handler(_canvasId);
    _handler.init();

    /**
     * @public
     * @type {Element}
     */
    this.renderer = new og.Renderer(_handler);
    this.renderer.init();
    this.renderer.div = this.div;

    //Skybox
    if (options.skybox) {
        this.renderer.addRenderNode(options.skybox);
    }

    /**
     * Planet node name. Access by this.renderer.<name>
     * @private
     * @type {String}
     */
    this._planetName = options.name ? options.name : og.Globus.PLANET_NAME_PREFIX + og.Globus.__id;

    /**
     * Planet node
     * @public
     * @type {Object}
     */
    this.planet = new og.node.Planet(this._planetName, options.ellipsoid ? options.ellipsoid : og.ellipsoid.wgs84);
    if (options.layers) {
        this.planet.addLayers(options.layers);
    }

    //Attach terrain provider
    if (options.terrain) {
        this.planet.setTerrainProvider(options.terrain);
    }

    this.renderer.addRenderNode(this.planet);

    //Add controls
    if (options.controls) {
        this.renderer.addControls(options.controls)
    }

    og.Globus.__id++;

    if (options.viewExtent) {
        this.planet.viewToExtent(options.viewExtent);
    }

    //Run!
    if (isUndefined(options.autoActivate) || options.autoActivate)
        this.renderer.start();
};

/**
 * og.Globus static variables
 *
 */
og.Globus.__id = 1;
og.Globus.CANVAS_ID_PREFIX = "globus_viewport_";
og.Globus.PLANET_NAME_PREFIX = "globus_planet_";

function isUndefined(obj) {
    return obj === void 0;
};
{'fraction_non_alphanumeric': 0.15158293186510668, 'fraction_numerical': 0.008258774948382657, 'mean_word_length': 2.8143044619422573, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6912598', 'n_tokens_mistral': 2101, 'n_tokens_neox': 2034, 'n_words': 323}