Skip to content

Commit 27e28ad

Browse files
committed
example: add atmosphere mars example.
1 parent 234a8ee commit 27e28ad

File tree

2 files changed

+96
-1
lines changed

2 files changed

+96
-1
lines changed

examples/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"Effects": {
4747
"effects_postprocessing": "Post processing",
4848
"effects_split": "Splitted rendering",
49-
"effects_stereo": "Stereo effects"
49+
"effects_stereo": "Stereo effects",
50+
"mars": "Mars atmosphere"
5051
},
5152

5253
"Miscellaneous": {

examples/mars.html

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<html>
2+
<head>
3+
<title>Itowns - Mars</title>
4+
5+
<meta charset="UTF-8">
6+
<link rel="stylesheet" type="text/css" href="css/example.css">
7+
<link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
8+
9+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
10+
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
11+
</head>
12+
<body>
13+
<div id="viewerDiv"></div>
14+
<span id="divScaleWidget"> Scale </span>
15+
<div id="miniDiv"></div>
16+
17+
<script src="js/GUI/GuiTools.js"></script>
18+
<script src="../dist/itowns.js"></script>
19+
<script src="js/GUI/LoadingScreen.js"></script>
20+
<script src="../dist/debug.js"></script>
21+
<script type="text/javascript">
22+
// # Simple Globe viewer
23+
// Define initial camera position
24+
// mars crs projection is EPSG:104905
25+
// Globe view could be use only 4326 and 3857
26+
// For the moment, the example uses earth to visualize Mars WMTS.
27+
// We keep 'EPSG:104905' in comment for the moment
28+
itowns.proj4.defs('EPSG:104905', '+proj=longlat +a=3396190 +rf=169.894447223612 +no_defs +type=crs');
29+
var placement = {
30+
coord: new itowns.Coordinates('EPSG:4326', 77.6, 18.2),
31+
range: 25000000,
32+
}
33+
34+
// `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
35+
var viewerDiv = document.getElementById('viewerDiv');
36+
37+
// Instanciate iTowns GlobeView*
38+
var view = new itowns.GlobeView(viewerDiv, placement, {
39+
atmosphere: {
40+
Kr: 0.0025,
41+
Km: 0.0015,
42+
ESun: 15.0,
43+
g: -0.950,
44+
innerRadius: 6400000,
45+
outerRadius: 6600000,
46+
wavelength: [0.350, 0.470, 0.575],
47+
scaleDepth: 0.38,
48+
}
49+
});
50+
setupLoadingScreen(viewerDiv, view);
51+
52+
// Add a tms imagery source
53+
var tmsMarsSource = new itowns.TMSSource({
54+
// crs: 'EPSG:104905',
55+
crs: 'EPSG:4326',
56+
url : 'https://api.nasa.gov/mars-wmts/catalog/Mars_Viking_MDIM21_ClrMosaic_global_232m/1.0.0//default/default028mm/${z}/${y}/${x}.jpg',
57+
zoom: { min: 0, max: 9 },
58+
})
59+
60+
// Add a imagery layer
61+
var tmsMarsLayer = new itowns.ColorLayer('wms_imagery', {
62+
source: tmsMarsSource,
63+
});
64+
65+
view.addLayer(tmsMarsLayer);
66+
67+
const demMars = new itowns.ElevationLayer('demMars', {
68+
useColorTextureElevation: true,
69+
colorTextureElevationMinZ: 0,
70+
colorTextureElevationMaxZ: 20000,
71+
crs: 'EPSG:4326',
72+
source: new itowns.TMSSource({
73+
// crs: 'EPSG:104905',
74+
crs: 'EPSG:4326',
75+
url : 'https://api.nasa.gov/mars-wmts/catalog/Mars_MGS_MOLA_DEM_mosaic_global_463m_8/1.0.0//default/default028mm/${z}/${y}/${x}.png',
76+
zoom: { min: 0, max: 5 },
77+
}),
78+
});
79+
// view.addLayer(demMars);
80+
81+
var menuGlobe = new GuiTools('menuDiv', view);
82+
83+
const atmosphere = view.getLayerById('atmosphere');
84+
atmosphere.setRealisticOn(true);
85+
86+
const cRL = menuGlobe.addGUI('RealisticLighting', true, function (v) {
87+
atmosphere.setRealisticOn(v);
88+
view.notifyChange(atmosphere);
89+
});
90+
91+
debug.createTileDebugUI(menuGlobe.gui, view);
92+
</script>
93+
</body>
94+
</html>

0 commit comments

Comments
 (0)