mirror of
https://github.com/NASAWorldWind/WebWorldWind.git
synced 2026-01-18 15:12:57 +00:00
60 lines
2.0 KiB
JavaScript
60 lines
2.0 KiB
JavaScript
/*
|
|
* Copyright (C) 2014 United States Government as represented by the Administrator of the
|
|
* National Aeronautics and Space Administration. All Rights Reserved.
|
|
*/
|
|
|
|
requirejs([
|
|
'../src/WorldWind',
|
|
'./LayerManager'
|
|
],
|
|
function (ww,
|
|
LayerManager) {
|
|
'use strict';
|
|
|
|
WorldWind.Logger.setLoggingLevel(WorldWind.Logger.LEVEL_WARNING);
|
|
|
|
var wwd = new WorldWind.WorldWindow('canvasOne');
|
|
|
|
var BMNGLayer = new WorldWind.BMNGLayer();
|
|
var starFieldLayer = new WorldWind.StarFieldLayer();
|
|
var atmosphereLayer = new WorldWind.AtmosphereLayer();
|
|
wwd.addLayer(BMNGLayer);
|
|
|
|
//IMPORTANT: add the starFieldLayer before the atmosphereLayer
|
|
wwd.addLayer(starFieldLayer);
|
|
wwd.addLayer(atmosphereLayer);
|
|
|
|
starFieldLayer.time = new Date();
|
|
atmosphereLayer.lightLocation = WorldWind.SunPosition.getAsGeographicLocation(starFieldLayer.time);
|
|
|
|
var layerManger = new LayerManager(wwd);
|
|
wwd.redraw();
|
|
|
|
wwd.redrawCallbacks.push(runSunSimulation);
|
|
|
|
var sunSimulationCheckBox = document.getElementById('stars-simulation');
|
|
var doRunSimulation = false;
|
|
var timeStamp = Date.now();
|
|
var factor = 1;
|
|
|
|
sunSimulationCheckBox.addEventListener('change', onSunCheckBoxClick, false);
|
|
|
|
function onSunCheckBoxClick() {
|
|
doRunSimulation = this.checked;
|
|
if (!doRunSimulation) {
|
|
starFieldLayer.time = new Date();
|
|
atmosphereLayer.lightLocation = WorldWind.SunPosition.getAsGeographicLocation(starFieldLayer.time);
|
|
}
|
|
wwd.redraw();
|
|
}
|
|
|
|
function runSunSimulation(wwd, stage) {
|
|
if (stage === WorldWind.AFTER_REDRAW && doRunSimulation) {
|
|
timeStamp += (factor * 60 * 1000);
|
|
starFieldLayer.time = new Date(timeStamp);
|
|
atmosphereLayer.lightLocation = WorldWind.SunPosition.getAsGeographicLocation(starFieldLayer.time);
|
|
wwd.redraw();
|
|
}
|
|
}
|
|
|
|
}); |