|
25 | 25 | left: 10px; |
26 | 26 | z-index: 1000; |
27 | 27 | } |
| 28 | + |
| 29 | + .tp-dfwv { |
| 30 | + position: absolute; |
| 31 | + left: 10px; |
| 32 | + top: 10px; |
| 33 | + z-index: 1000; |
| 34 | + } |
28 | 35 | </style> |
29 | 36 | </head> |
30 | 37 |
|
31 | 38 | <body> |
32 | 39 | <div id="map"></div> |
33 | | - <script src="../dist/mapbox-gl-dev.js"></script> |
34 | 40 | <script type="module"> |
| 41 | + // This page uses the esm build of Mapbox GL JS, |
| 42 | + // so need to run 'npm run start-esm' to serve it. |
| 43 | + import mapbox from '../dist/esm-dev/mapbox-gl.js'; |
| 44 | + import {Pane} from 'https://cdn.jsdelivr.net/npm/[email protected]/dist/tweakpane.min.js'; |
35 | 45 | import {getAccessToken} from './access_token_generated.js'; |
36 | 46 |
|
37 | | - mapboxgl.accessToken = getAccessToken(); |
| 47 | + mapbox.accessToken = getAccessToken(); |
38 | 48 |
|
39 | | - var map = window.map = new mapboxgl.Map({ |
| 49 | + var map = window.map = new mapbox.Map({ |
40 | 50 | container: 'map', |
41 | 51 | devtools: true, |
42 | 52 | zoom: 18, |
43 | 53 | center: [11.576073, 48.135578], |
44 | 54 | pitch: 54, |
45 | 55 | bearing: -55.2, |
46 | | - style: 'mapbox://styles/mapbox/standard', |
| 56 | + style: 'mapbox://styles/mapbox-map-design/standard-rc', |
| 57 | + config: { |
| 58 | + basemap: { |
| 59 | + show3dFacades: true |
| 60 | + } |
| 61 | + }, |
47 | 62 | hash: true |
48 | 63 | }); |
49 | 64 |
|
50 | | - var dbgTrackedParams = map._tp; |
| 65 | + const buildingDebugPane = new Pane(); |
| 66 | + buildingDebugPane.title = "Procedural Buildings"; |
51 | 67 |
|
52 | 68 | var params = { |
53 | 69 | ambientColor: [255, 255, 255], |
|
58 | 74 | sunPolarAngle: 50, |
59 | 75 | castShadows: true, |
60 | 76 | shadowIntensity: 1.0, |
61 | | - lightPreset: "day" |
| 77 | + lightPreset: "day", |
| 78 | + show3dObjects: true, |
| 79 | + show3dBuildings: true, |
| 80 | + show3dFacades: true, |
| 81 | + show3dLandmarks: true |
62 | 82 | }; |
63 | 83 |
|
| 84 | + const lightFolder = buildingDebugPane.addFolder({ |
| 85 | + title: 'Sun', |
| 86 | + expanded: true, |
| 87 | + }); |
| 88 | + |
| 89 | + lightFolder.addBinding(params, "sunBearing", { label: "Bearing Angle", min: 0, max: 360 }).on('change', function (ev) { |
| 90 | + updateSunLight(); |
| 91 | + }); |
| 92 | + |
| 93 | + lightFolder.addBinding(params, "sunPolarAngle", { label: "Polar Angle", min: 0, max: 90 }).on('change', function (ev) { |
| 94 | + updateSunLight(); |
| 95 | + }); |
| 96 | + |
| 97 | + const buildingFolder = buildingDebugPane.addFolder({ |
| 98 | + title: 'Buildings', |
| 99 | + expanded: true, |
| 100 | + }); |
| 101 | + |
| 102 | + buildingFolder.addBinding(params, "show3dObjects", { label: "Show 3D Objects" }).on('change', function (ev) { |
| 103 | + map.setConfigProperty("basemap", "show3dObjects", params.show3dObjects); |
| 104 | + }); |
| 105 | + |
| 106 | + buildingFolder.addBinding(params, "show3dBuildings", { label: "Show 3D Buildings" }).on('change', function (ev) { |
| 107 | + map.setConfigProperty("basemap", "show3dBuildings", params.show3dBuildings); |
| 108 | + }); |
| 109 | + |
| 110 | + buildingFolder.addBinding(params, "show3dLandmarks", { label: "Show 3D Landmarks" }).on('change', function (ev) { |
| 111 | + map.setConfigProperty("basemap", "show3dLandmarks", params.show3dLandmarks); |
| 112 | + }); |
| 113 | + |
| 114 | + buildingFolder.addBinding(params, "show3dFacades", { label: "Show 3D Facades" }).on('change', function (ev) { |
| 115 | + map.setConfigProperty("basemap", "show3dFacades", params.show3dFacades); |
| 116 | + }); |
| 117 | + |
64 | 118 | function updateSunLight() { |
65 | 119 | map.setLights([ |
66 | 120 | { |
|
89 | 143 | map.triggerRepaint(); |
90 | 144 | }; |
91 | 145 |
|
92 | | - map.on('load', () => { |
93 | | - map.showTileBoundaries = true; |
94 | | - }); |
95 | | - |
96 | 146 | map.on('style.load', () => { |
97 | | - map.addImport({id: 'procedural-buildings', url: 'procedural-buildings.standard.fragment.json'}); |
| 147 | + // Store the original style so we can restore it - e.g. if someone |
| 148 | + // changed the lighting using one of the other debug options. |
| 149 | + let styleLights = map.getLights(); |
| 150 | + |
| 151 | + lightFolder.addBinding(params, "lightPreset", { |
| 152 | + label: "Light Preset", |
| 153 | + options: { |
| 154 | + Dawn: "dawn", |
| 155 | + Day: "day", |
| 156 | + Dusk: "dusk", |
| 157 | + Night: "night", |
| 158 | + } |
| 159 | + }, () => { |
| 160 | + }).on('change', function (ev) { |
| 161 | + map.setLights(styleLights); |
| 162 | + map.setConfigProperty("basemap", "lightPreset", params.lightPreset); |
| 163 | + }); |
98 | 164 | }); |
99 | 165 |
|
100 | 166 | let selectedBuilding = null; |
101 | 167 | map.addInteraction('place-click', { |
102 | 168 | type: 'click', |
103 | | - target: { featuresetId: 'buildings', importId: 'procedural-buildings' }, |
| 169 | + target: { featuresetId: 'buildings', importId: 'basemap' }, |
104 | 170 | handler: ({ feature }) => { |
105 | 171 | console.log(feature.id); |
106 | 172 |
|
|
0 commit comments