UNPKG

itowns

Version:

A JS/WebGL framework for 3D geospatial data visualization

107 lines (77 loc) 4.45 kB
<html> <head> <title>Itowns - Globe travel</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="css/example.css"> <link rel="stylesheet" type="text/css" href="css/LoadingScreen.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script> </head> <body> <div id="viewerDiv"></div> <!-- Import iTowns source code --> <script src="../dist/itowns.js"></script> <script src="js/GUI/LoadingScreen.js"></script> <script type="text/javascript"> // ---------- CREATE A GlobeView FOR SUPPORTING DATA VISUALIZATION : ---------- // Define camera initial position const placement = { coord: new itowns.Coordinates('EPSG:4326', 2.351323, 48.856712), range: 25000000, } // `viewerDiv` will contain iTowns' rendering area (`<canvas>`) const viewerDiv = document.getElementById('viewerDiv'); // Create a GlobeView const view = new itowns.GlobeView(viewerDiv, placement); // Setup loading screen and debug menu setupLoadingScreen(viewerDiv, view); // Display a realistic atmosphere view.getLayerById('atmosphere').setRealisticOn(true); // ---------- DISPLAY ORTHO-IMAGES : ---------- // Add one imagery layer to the scene. This layer's properties are defined in a json file, but it could be // defined as a plain js object. See `Layer` documentation for more info. itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(function _(config) { config.source = new itowns.WMTSSource(config.source); view.addLayer( new itowns.ColorLayer('Ortho', config), ); }); // ---------- DISPLAY A DIGITAL ELEVATION MODEL : ---------- // Add two elevation layers, each with a different level of detail. Here again, each layer's properties are // defined in a json file. function addElevationLayerFromConfig(config) { config.source = new itowns.WMTSSource(config.source); view.addLayer( new itowns.ElevationLayer(config.id, config), ); } itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig); itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig); // ---------- ANIMATE CAMERA : ---------- const time = 50000; // Array containing CameraTransformOptions (see // http://www.itowns-project.org/itowns/docs/#api/Controls/CameraUtils) for each step of the animation. const pathTravel = []; pathTravel.push({ coord: new itowns.Coordinates('EPSG:4326', 2.0889, 42.809), range: 100000, time: time * 0.2 }); pathTravel.push({ range: 13932, time: time * 0.2, tilt: 7.59, heading: 110.9 }); pathTravel.push({ tilt: 8, time: time * 0.2 }); pathTravel.push({ range: 70000, time: time * 0.2, tilt: 5, heading: 90 }); pathTravel.push({ coord: new itowns.Coordinates('EPSG:4326', 7.0193, 43.991), tilt: 11.5, heading: 127.211, time: time }); pathTravel.push({ range: 10414, time: time * 0.2 }); pathTravel.push({ tilt: 8, time: time * 0.2 }); pathTravel.push({ range: 60000, heading: -40, time: time * 0.2 }); pathTravel.push({ coord: new itowns.Coordinates('EPSG:4326', 9.114, 41.973), tilt: 15.92, heading: 13.18, time: time }); pathTravel.push({ range: 16601, time: time * 0.2 }); function travel() { return itowns.CameraUtils .sequenceAnimationsToLookAtTarget(view, view.camera3D, pathTravel); } // Listen for globe full initialisation event view.addEventListener(itowns.GLOBE_VIEW_EVENTS.GLOBE_INITIALIZED, function init() { // eslint-disable-next-line no-console console.info('Globe initialized'); travel().then(travel).catch(console.error); }); </script> </body> </html>