|
3 | 3 | <title>Itowns - collada</title>
|
4 | 4 |
|
5 | 5 | <meta charset="UTF-8">
|
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 7 | + |
6 | 8 | <link rel="stylesheet" type="text/css" href="css/example.css">
|
7 | 9 | <link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
|
8 | 10 |
|
9 |
| - <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
10 | 11 | <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
|
11 | 12 | </head>
|
12 | 13 | <body>
|
13 | 14 | <div id="viewerDiv"></div>
|
14 |
| - <script src="js/GUI/GuiTools.js"></script> |
| 15 | + |
| 16 | + <!-- Import iTowns source code --> |
15 | 17 | <script src="../dist/itowns.js"></script>
|
16 |
| - <script src="js/ThreeLoader.js"></script> |
17 |
| - <script src="js/GUI/LoadingScreen.js"></script> |
18 | 18 | <script src="../dist/debug.js"></script>
|
| 19 | + |
| 20 | + <!-- Import iTowns LoadingScreen and GuiTools plugins --> |
| 21 | + <script src="js/GUI/GuiTools.js"></script> |
| 22 | + <script src="js/GUI/LoadingScreen.js"></script> |
| 23 | + |
| 24 | + <!-- Import ThreeLoader plugin to get ColladaLoader from three.js --> |
| 25 | + <script src="js/ThreeLoader.js"></script> |
| 26 | + |
19 | 27 | <script type="text/javascript">
|
20 |
| - // # Simple Globe viewer |
21 | 28 |
|
22 |
| - // Define initial camera position |
23 |
| - // Coordinate can be found on https://www.geoportail.gouv.fr/carte |
24 |
| - // setting is "coordonnée geographiques en degres decimaux" |
25 | 29 |
|
26 |
| - // Position near Gerbier mountain. |
27 |
| - var placement = { |
| 30 | + |
| 31 | + |
| 32 | + // ---------- CREATE A GlobeView FOR SUPPORTING DATA VISUALIZATION : ---------- |
| 33 | + |
| 34 | + // Define camera initial position |
| 35 | + const placement = { |
28 | 36 | coord: new itowns.Coordinates('EPSG:4326', 4.21655, 44.84415),
|
29 | 37 | range: 500,
|
30 | 38 | heading: 180,
|
31 | 39 | tilt: 60,
|
32 |
| - } |
| 40 | + }; |
33 | 41 |
|
34 | 42 | // `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
|
35 |
| - var viewerDiv = document.getElementById('viewerDiv'); |
| 43 | + const viewerDiv = document.getElementById('viewerDiv'); |
36 | 44 |
|
37 |
| - // Instanciate iTowns GlobeView* |
38 |
| - var view = new itowns.GlobeView(viewerDiv, placement); |
39 |
| - |
40 |
| - var menuGlobe = new GuiTools('menuDiv', view); |
| 45 | + // Create a GlobeView |
| 46 | + const view = new itowns.GlobeView(viewerDiv, placement); |
41 | 47 |
|
| 48 | + // Setup loading screen and debug menu |
42 | 49 | setupLoadingScreen(viewerDiv, view);
|
| 50 | + const debugMenu = new GuiTools('menuDiv', view); |
43 | 51 |
|
44 |
| - function addLayerCb(layer) { |
45 |
| - view.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe)); |
46 |
| - } |
47 | 52 |
|
48 |
| - // Add one imagery layer to the scene |
49 |
| - // This layer is defined in a json file but it could be defined as a plain js |
50 |
| - // object. See Layer* for more info. |
51 |
| - itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(function _(config) { |
52 |
| - config.source = new itowns.WMTSSource(config.source); |
53 |
| - var layer = new itowns.ColorLayer(config.id, config); |
54 |
| - view.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe)); |
55 |
| - }); |
56 |
| - // Add two elevation layers. |
57 |
| - // These will deform iTowns globe geometry to represent terrain elevation. |
| 53 | + |
| 54 | + // ---------- DISPLAY CONTEXTUAL DATA : ---------- |
| 55 | + |
| 56 | + // Display ortho-images |
| 57 | + itowns.Fetcher.json('./layers/JSONLayers/Ortho.json') |
| 58 | + .then(function _(config) { |
| 59 | + config.source = new itowns.WMTSSource(config.source); |
| 60 | + view.addLayer( |
| 61 | + new itowns.ColorLayer('Ortho', config), |
| 62 | + ).then(debugMenu.addLayerGUI.bind(debugMenu)); |
| 63 | + }); |
| 64 | + |
| 65 | + // Display elevation data |
58 | 66 | function addElevationLayerFromConfig(config) {
|
59 | 67 | config.source = new itowns.WMTSSource(config.source);
|
60 |
| - var layer = new itowns.ElevationLayer(config.id, config); |
61 |
| - view.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe)); |
| 68 | + view.addLayer( |
| 69 | + new itowns.ElevationLayer(config.id, config), |
| 70 | + ).then(debugMenu.addLayerGUI.bind(debugMenu)); |
62 | 71 | }
|
63 |
| - itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig); |
64 |
| - itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig); |
| 72 | + itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json') |
| 73 | + .then(addElevationLayerFromConfig); |
| 74 | + itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json') |
| 75 | + .then(addElevationLayerFromConfig); |
| 76 | + |
| 77 | + |
65 | 78 |
|
66 |
| - // ThreeLoader can load each format proposed in ThreeJs examples loaders : https://github.com/mrdoob/three.js/tree/dev/examples/js/loaders |
67 |
| - var promiseCollada = ThreeLoader.load('Collada', 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/models/collada/building.dae') |
68 |
| - .then(collada => { |
69 |
| - var model = collada.scene; |
| 79 | + |
| 80 | + // ---------- DISPLAY COLLADA DATA : ---------- |
| 81 | + |
| 82 | + // ThreeLoader can load each format proposed in ThreeJs examples loaders : |
| 83 | + // https://github.com/mrdoob/three.js/tree/dev/examples/js/loaders |
| 84 | + // Note : As this previous folder has been removed in three r148, |
| 85 | + // TheeLoader will only use loaders from three r147 version. This |
| 86 | + // is a temporary solution and shall be updated. |
| 87 | + const promiseCollada = ThreeLoader.load( |
| 88 | + 'Collada', |
| 89 | + 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/models/collada/building.dae', |
| 90 | + ).then(collada => { |
| 91 | + const model = collada.scene; |
70 | 92 |
|
71 | 93 | // building coordinate
|
72 |
| - var coord = new itowns.Coordinates('EPSG:4326', 4.2165, 44.844, 1417); |
| 94 | + const coord = new itowns.Coordinates( |
| 95 | + 'EPSG:4326', 4.2165, 44.844, 1417, |
| 96 | + ); |
73 | 97 |
|
74 | 98 | model.position.copy(coord.as(view.referenceCrs));
|
75 | 99 | // align up vector with geodesic normal
|
|
84 | 108 | view.scene.add(model);
|
85 | 109 | view.notifyChange();
|
86 | 110 | });
|
| 111 | + |
87 | 112 | </script>
|
88 | 113 | </body>
|
89 | 114 | </html>
|
0 commit comments