UNPKG

itowns

Version:

A JS/WebGL framework for 3D geospatial data visualization

103 lines (88 loc) 3.98 kB
<html> <head> <title>Itowns - Orthographic Camera Example</title> <script type="importmap"> { "imports": { "itowns": "../dist/itowns.js", "debug": "../dist/debug.js", "dat": "https://unpkg.com/dat.gui@0.7.9/build/dat.gui.module.js", "GuiTools": "./jsm/GUI/GuiTools.js", "LoadingScreen": "./jsm/GUI/LoadingScreen.js", "itowns_widgets": "../dist/itowns_widgets.js", "three": "https://unpkg.com/three@0.170.0/build/three.module.js", "three/addons/": "https://unpkg.com/three@0.170.0/examples/jsm/" } } </script> <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="css/example.css"> <link rel="stylesheet" type="text/css" href="css/LoadingScreen.css"> <link rel="stylesheet" type="text/css" href="css/widgets.css"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div id="viewerDiv"></div> <script type="module"> import GuiTools from 'GuiTools'; import setupLoadingScreen from 'LoadingScreen'; import * as THREE from 'three'; import * as itowns from 'itowns'; import * as debug from 'debug'; import * as itowns_widgets from 'itowns_widgets'; // # Orthographic viewer // Define geographic extent: CRS, min/max X, min/max Y var extent = new itowns.Extent( 'EPSG:3857', -20026376.39, 20026376.39, -20048966.10, 20048966.10); // `viewerDiv` will contain iTowns' rendering area (`<canvas>`) var viewerDiv = document.getElementById('viewerDiv'); // Instanciate PlanarView // By default itowns' tiles geometry have a "skirt" (ie they have a height), // but in case of orthographic we don't need this feature, so disable it var view = new itowns.PlanarView(viewerDiv, extent, { disableSkirt: true, maxSubdivisionLevel: 10, camera: { type: itowns.CAMERA_TYPE.ORTHOGRAPHIC }, placement: new itowns.Extent('EPSG:3857', -20000000, 20000000, -8000000, 20000000), controls: { // Faster zoom in/out speed zoomFactor: 3, // prevent from zooming in too much maxResolution: 0.005 // a pixel shall not represent a metric size smaller than 5 mm }, }); setupLoadingScreen(viewerDiv, view); // Add a TMS imagery source var opensmSource = new itowns.TMSSource({ isInverted: true, // eslint-disable-next-line no-template-curly-in-string url: 'https://watercolormaps.collection.cooperhewitt.org/tile/watercolor/${z}/${x}/${y}.jpg', networkOptions: { crossOrigin: 'anonymous' }, extent, crs: 'EPSG:3857', attribution: { name: 'OpenStreetMap', url: 'http://www.openstreetmap.org/', }, }); // Add a TMS imagery layer var opensmLayer = new itowns.ColorLayer('OPENSM', { updateStrategy: { type: itowns.STRATEGY_DICHOTOMY, }, source: opensmSource, }); view.addLayer(opensmLayer); // Add a scale : const scale = new itowns_widgets.Scale(view, { position: 'bottom-right', translate: { x: -70 }, }); // Request redraw view.notifyChange(); window.view = view; window.itowns = itowns; window.THREE = THREE; </script> </body> </html>