mirror of
https://github.com/NASAWorldWind/WebWorldWind.git
synced 2026-01-18 15:12:57 +00:00
updated documentation, example and stars.json
extract ra, dec and vmag indexes from the metadata of the stars.json
This commit is contained in:
parent
01f90278b8
commit
d0d9ae1bb7
@ -1,5 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!--@version $Id: BasicExample.html 3314 2015-07-10 18:28:45Z dcollins $-->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!--NOTE: Most Web World Wind examples use jquery, Bootstrap and requirejs but those technologies are NOT-->
|
||||
@ -26,8 +25,8 @@
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<label for="sun-simulation">Simulate</label>
|
||||
<input id="sun-simulation" type="checkbox" />
|
||||
<label for="stars-simulation">Simulate</label>
|
||||
<input id="stars-simulation" type="checkbox" />
|
||||
</div>
|
||||
<br>
|
||||
<h4>Destination</h4>
|
||||
|
||||
@ -5,18 +5,15 @@
|
||||
|
||||
requirejs([
|
||||
'../src/WorldWind',
|
||||
'./LayerManager',
|
||||
'../thirdparty/sunCalculator'
|
||||
'./LayerManager'
|
||||
],
|
||||
function (ww,
|
||||
LayerManager,
|
||||
sunCalculator) {
|
||||
"use strict";
|
||||
LayerManager) {
|
||||
'use strict';
|
||||
|
||||
WorldWind.Logger.setLoggingLevel(WorldWind.Logger.LEVEL_WARNING);
|
||||
|
||||
var wwd = new WorldWind.WorldWindow("canvasOne");
|
||||
window.wwd = wwd;
|
||||
var wwd = new WorldWind.WorldWindow('canvasOne');
|
||||
|
||||
var BMNGLayer = new WorldWind.BMNGLayer();
|
||||
var starFieldLayer = new WorldWind.StarFieldLayer();
|
||||
@ -25,13 +22,12 @@ requirejs([
|
||||
wwd.addLayer(atmosphereLayer);
|
||||
wwd.addLayer(starFieldLayer);
|
||||
|
||||
atmosphereLayer.lightLocation = sunCalculator(new Date());
|
||||
var layerManger = new LayerManager(wwd);
|
||||
wwd.redraw();
|
||||
|
||||
wwd._redrawCallbacks.push(runSunSimulation);
|
||||
wwd.redrawCallbacks.push(runSunSimulation);
|
||||
|
||||
var sunSimulationCheckBox = document.getElementById('sun-simulation');
|
||||
var sunSimulationCheckBox = document.getElementById('stars-simulation');
|
||||
var doRunSimulation = false;
|
||||
var timeStamp = Date.now();
|
||||
var factor = 1;
|
||||
@ -41,9 +37,7 @@ requirejs([
|
||||
function onSunCheckBoxClick() {
|
||||
doRunSimulation = this.checked;
|
||||
if (!doRunSimulation) {
|
||||
var date = new Date();
|
||||
atmosphereLayer.lightLocation = sunCalculator(date);
|
||||
starFieldLayer.time = date;
|
||||
starFieldLayer.time = new Date();
|
||||
}
|
||||
wwd.redraw();
|
||||
}
|
||||
@ -51,9 +45,7 @@ requirejs([
|
||||
function runSunSimulation(wwd, stage) {
|
||||
if (stage === WorldWind.AFTER_REDRAW && doRunSimulation) {
|
||||
timeStamp += (factor * 60 * 1000);
|
||||
var date = new Date(timeStamp);
|
||||
atmosphereLayer.lightLocation = sunCalculator(date);
|
||||
starFieldLayer.time = date;
|
||||
starFieldLayer.time = new Date(timeStamp);
|
||||
wwd.redraw();
|
||||
}
|
||||
}
|
||||
|
||||
41966
examples/data/stars.json
41966
examples/data/stars.json
File diff suppressed because one or more lines are too long
@ -18,10 +18,20 @@ define([
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Constructs a layer showing bright stars visible from the Earth with the naked eye.
|
||||
* Constructs a layer showing stars around the Earth.
|
||||
*
|
||||
* If you want to use your own star data, the file provided must be .json
|
||||
* and the fields 'ra', 'dec' and 'vmag' must be present in the metadata.
|
||||
* ra and dec must be expressed in degrees.
|
||||
*
|
||||
* This layer uses J2000.0 as the ref epoch.
|
||||
*
|
||||
* If the star data .json file is too big, consider enabling gzip compression on your web server.
|
||||
* For more info about enabling gzip compression consult the configuration for your web server.
|
||||
*
|
||||
* @alias StarFieldLayer
|
||||
* @constructor
|
||||
* @classdesc Provides a layer showing bright stars visible from the Earth with the naked eye.
|
||||
* @classdesc Provides a layer showing stars.
|
||||
* @param {URL} starDataSource optional url for the stars data.
|
||||
* @augments Layer
|
||||
*/
|
||||
@ -204,6 +214,24 @@ define([
|
||||
|
||||
// Internal. Intentionally not documented.
|
||||
StarFieldLayer.prototype.createGeometry = function () {
|
||||
var indexes = this.parseMetadata(this._starData.metadata);
|
||||
|
||||
if (indexes.raIndex === -1) {
|
||||
throw new Error(
|
||||
Logger.logMessage(Logger.LEVEL_SEVERE, 'StarFieldLayer', 'createGeometry',
|
||||
'Missing ra field in star data.'));
|
||||
}
|
||||
if (indexes.decIndex === -1) {
|
||||
throw new Error(
|
||||
Logger.logMessage(Logger.LEVEL_SEVERE, 'StarFieldLayer', 'createGeometry',
|
||||
'Missing dec field in star data.'));
|
||||
}
|
||||
if (indexes.magIndex === -1) {
|
||||
throw new Error(
|
||||
Logger.logMessage(Logger.LEVEL_SEVERE, 'StarFieldLayer', 'createGeometry',
|
||||
'Missing vmag field in star data.'));
|
||||
}
|
||||
|
||||
var data = this._starData.data;
|
||||
var positions = [];
|
||||
|
||||
@ -212,9 +240,9 @@ define([
|
||||
|
||||
for (var i = 0, len = data.length; i < len; i++) {
|
||||
var starInfo = data[i];
|
||||
var declination = starInfo[2]; //for latitude
|
||||
var rightAscension = starInfo[1]; //for longitude
|
||||
var magnitude = starInfo[3];
|
||||
var declination = starInfo[indexes.decIndex]; //for latitude
|
||||
var rightAscension = starInfo[indexes.raIndex]; //for longitude
|
||||
var magnitude = starInfo[indexes.magIndex];
|
||||
var pointSize = magnitude < 4 ? 2 : 1;
|
||||
|
||||
positions.push(declination, rightAscension, pointSize, magnitude);
|
||||
@ -227,6 +255,30 @@ define([
|
||||
return positions;
|
||||
};
|
||||
|
||||
// Internal. Intentionally not documented.
|
||||
StarFieldLayer.prototype.parseMetadata = function (metadata) {
|
||||
var raIndex = -1,
|
||||
decIndex = -1,
|
||||
magIndex = -1;
|
||||
for (var i = 0, len = metadata.length; i < len; i++) {
|
||||
var starMetaInfo = metadata[i];
|
||||
if (starMetaInfo.name === 'ra') {
|
||||
raIndex = i;
|
||||
}
|
||||
if (starMetaInfo.name === 'dec') {
|
||||
decIndex = i;
|
||||
}
|
||||
if (starMetaInfo.name === 'vmag') {
|
||||
magIndex = i;
|
||||
}
|
||||
}
|
||||
return {
|
||||
raIndex: raIndex,
|
||||
decIndex: decIndex,
|
||||
magIndex: magIndex
|
||||
};
|
||||
};
|
||||
|
||||
// Internal. Intentionally not documented.
|
||||
StarFieldLayer.prototype.julianDate = function julianDate(date) {
|
||||
//http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html
|
||||
|
||||
@ -54,6 +54,7 @@ define([
|
||||
'}\n' +
|
||||
|
||||
//transforms declination and right ascension in cartesian coordinates
|
||||
//todo: dec/ra -> lat/lon may not be correct
|
||||
'vec3 computePosition(float dec, float ra) {\n' +
|
||||
' float GMST = normalizeAngle(280.46061837 + 360.98564736629 * numDays);\n' +
|
||||
//' float lon = 180.0 - normalizeAngle(GMST - ra);\n' +
|
||||
@ -164,7 +165,7 @@ define([
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads the specified number as the value of this program's 'numDays' uniform variable.
|
||||
* Loads the specified number as the value of this program's 'magnitudeRange' uniform variable.
|
||||
*
|
||||
* @param {WebGLRenderingContext} gl The current WebGL context.
|
||||
* @param {Number} minMag
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user