Move empire data to JS file

This commit is contained in:
roblevesque 2016-07-07 12:21:25 -04:00 committed by GitHub
parent 8de7e42835
commit 54c8cab4e8

View File

@ -1,36 +1,18 @@
if ( ! Detector.webgl ) Detector.addGetWebGLMessage(); if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
require(./empiredata.js)
var camera, controls, scene, renderer; var camera, controls, scene, renderer;
var jsonEmpire = [];
var canvas_t=[]; var canvas_t=[];
var context_t=[]; var context_t=[];
var clock = new THREE.Clock(); var clock = new THREE.Clock();
var WIDTH = window.innerWidth , HEIGHT = window.innerHeight var WIDTH = window.innerWidth , HEIGHT = window.innerHeight
window.onload = function() { window.onload = function() {
loadData(function() {
init(); init();
animate(); animate();
render(); render();
}); });
} }
function loadData(_callback) {
// Load Data (hopefully) before the rest of the place loads.
var xmlhttp = new XMLHttpRequest();
var url = "js/empiredata.json";
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
jsonEmpire = JSON.parse(xmlhttp.responseText);
_callback();
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
function init() { function init() {
scene = new THREE.Scene(); scene = new THREE.Scene();
//scene.fog = new THREE.FogExp2( 0xcccccc, 0.002 ); //scene.fog = new THREE.FogExp2( 0xcccccc, 0.002 );