|
2 | 2 | <head>
|
3 | 3 | <title>Itowns - Globe travel</title>
|
4 | 4 |
|
5 |
| - <style type="text/css"> |
6 |
| - #miniDiv { |
7 |
| - display: block; |
8 |
| - margin-bottom: 20px; |
9 |
| - margin-right: 20px; |
10 |
| - position: absolute; |
11 |
| - width:100px; |
12 |
| - height:100px; |
13 |
| - left: 20; |
14 |
| - bottom: 0; |
15 |
| - color: white; |
16 |
| - } |
17 |
| - </style> |
18 | 5 | <meta charset="UTF-8">
|
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 7 | + |
19 | 8 | <link rel="stylesheet" type="text/css" href="css/example.css">
|
20 | 9 | <link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
|
21 | 10 |
|
22 |
| - <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
23 | 11 | <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
|
24 | 12 | </head>
|
25 | 13 | <body>
|
26 | 14 | <div id="viewerDiv"></div>
|
27 |
| - <script src="js/GUI/GuiTools.js"></script> |
| 15 | + |
| 16 | + <!-- Import iTowns source code --> |
28 | 17 | <script src="../dist/itowns.js"></script>
|
| 18 | + <script src="js/GUI/LoadingScreen.js"></script> |
| 19 | + |
| 20 | + |
29 | 21 | <script type="text/javascript">
|
30 |
| - // # Simple Globe viewer |
31 |
| - /* global itowns, Promise */ |
32 |
| - // Define initial camera position |
33 |
| - var placement = { |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + // ---------- CREATE A GlobeView FOR SUPPORTING DATA VISUALIZATION : ---------- |
| 26 | + |
| 27 | + // Define camera initial position |
| 28 | + const placement = { |
34 | 29 | coord: new itowns.Coordinates('EPSG:4326', 2.351323, 48.856712),
|
35 | 30 | range: 25000000,
|
36 | 31 | }
|
37 | 32 |
|
38 | 33 | // `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
|
39 |
| - var viewerDiv = document.getElementById('viewerDiv'); |
| 34 | + const viewerDiv = document.getElementById('viewerDiv'); |
| 35 | + |
| 36 | + // Create a GlobeView |
| 37 | + const view = new itowns.GlobeView(viewerDiv, placement); |
| 38 | + |
| 39 | + // Setup loading screen and debug menu |
| 40 | + setupLoadingScreen(viewerDiv, view); |
| 41 | + |
| 42 | + // Display a realistic atmosphere |
| 43 | + view.getLayerById('atmosphere').setRealisticOn(true); |
| 44 | + |
| 45 | + |
| 46 | + // ---------- DISPLAY ORTHO-IMAGES : ---------- |
| 47 | + |
| 48 | + // Add one imagery layer to the scene. This layer's properties are defined in a json file, but it could be |
| 49 | + // defined as a plain js object. See `Layer` documentation for more info. |
| 50 | + itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(function _(config) { |
| 51 | + config.source = new itowns.WMTSSource(config.source); |
| 52 | + view.addLayer( |
| 53 | + new itowns.ColorLayer('Ortho', config), |
| 54 | + ); |
| 55 | + }); |
| 56 | + |
40 | 57 |
|
41 |
| - // Instanciate iTowns GlobeView* |
42 |
| - var view = new itowns.GlobeView(viewerDiv, placement); |
43 |
| - var time = 50000; |
44 |
| - var pathTravel = []; |
45 |
| - const atmosphere = view.getLayerById('atmosphere'); |
46 |
| - atmosphere.setRealisticOn(true); |
47 | 58 |
|
| 59 | + // ---------- DISPLAY A DIGITAL ELEVATION MODEL : ---------- |
| 60 | + |
| 61 | + // Add two elevation layers, each with a different level of detail. Here again, each layer's properties are |
| 62 | + // defined in a json file. |
| 63 | + function addElevationLayerFromConfig(config) { |
| 64 | + config.source = new itowns.WMTSSource(config.source); |
| 65 | + view.addLayer( |
| 66 | + new itowns.ElevationLayer(config.id, config), |
| 67 | + ); |
| 68 | + } |
| 69 | + itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig); |
| 70 | + itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig); |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + // ---------- ANIMATE CAMERA : ---------- |
| 75 | + |
| 76 | + const time = 50000; |
| 77 | + |
| 78 | + // Array containing CameraTransformOptions (see |
| 79 | + // http://www.itowns-project.org/itowns/docs/#api/Controls/CameraUtils) for each step of the animation. |
| 80 | + const pathTravel = []; |
48 | 81 | pathTravel.push({ coord: new itowns.Coordinates('EPSG:4326', 2.0889, 42.809), range: 100000, time: time * 0.2 });
|
49 | 82 | pathTravel.push({ range: 13932, time: time * 0.2, tilt: 7.59, heading: 110.9 });
|
50 | 83 | pathTravel.push({ tilt: 8, time: time * 0.2 });
|
|
56 | 89 | pathTravel.push({ coord: new itowns.Coordinates('EPSG:4326', 9.114, 41.973), tilt: 15.92, heading: 13.18, time: time });
|
57 | 90 | pathTravel.push({ range: 16601, time: time * 0.2 });
|
58 | 91 |
|
59 |
| - function addLayerCb(layer) { |
60 |
| - return view.addLayer(layer); |
61 |
| - } |
62 |
| - |
63 | 92 | function travel() {
|
64 |
| - var camera = view.camera.camera3D; |
65 | 93 | return itowns.CameraUtils
|
66 |
| - .sequenceAnimationsToLookAtTarget(view, camera, pathTravel); |
| 94 | + .sequenceAnimationsToLookAtTarget(view, view.camera.camera3D, pathTravel); |
67 | 95 | }
|
68 | 96 |
|
69 |
| - // Add one imagery layer to the scene |
70 |
| - // This layer is defined in a json file but it could be defined as a plain js |
71 |
| - // object. See Layer* for more info. |
72 |
| - itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(function _(config) { |
73 |
| - config.source = new itowns.WMTSSource(config.source); |
74 |
| - var layer = new itowns.ColorLayer('Ortho', config); |
75 |
| - view.addLayer(layer); |
76 |
| - }); |
77 |
| - // Add two elevation layers. |
78 |
| - // These will deform iTowns globe geometry to represent terrain elevation. |
79 |
| - function addElevationLayerFromConfig(config) { |
80 |
| - config.source = new itowns.WMTSSource(config.source); |
81 |
| - var layer = new itowns.ElevationLayer(config.id, config); |
82 |
| - view.addLayer(layer); |
83 |
| - } |
84 |
| - itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig); |
85 |
| - itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig); |
86 | 97 |
|
87 | 98 | // Listen for globe full initialisation event
|
88 | 99 | view.addEventListener(itowns.GLOBE_VIEW_EVENTS.GLOBE_INITIALIZED, function init() {
|
|
0 commit comments