Skip to content

Commit 5e6eb16

Browse files
nicozinkgithub-actions[bot]
authored andcommitted
Reconcile procedural building styles (internal-8588)
GitOrigin-RevId: d834a094fc2fda5067bd8290008f70d46cd74d49
1 parent 7d122bd commit 5e6eb16

File tree

2 files changed

+78
-801
lines changed

2 files changed

+78
-801
lines changed

debug/procedural-buildings.html

Lines changed: 78 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,45 @@
2525
left: 10px;
2626
z-index: 1000;
2727
}
28+
29+
.tp-dfwv {
30+
position: absolute;
31+
left: 10px;
32+
top: 10px;
33+
z-index: 1000;
34+
}
2835
</style>
2936
</head>
3037

3138
<body>
3239
<div id="map"></div>
33-
<script src="../dist/mapbox-gl-dev.js"></script>
3440
<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';
3545
import {getAccessToken} from './access_token_generated.js';
3646

37-
mapboxgl.accessToken = getAccessToken();
47+
mapbox.accessToken = getAccessToken();
3848

39-
var map = window.map = new mapboxgl.Map({
49+
var map = window.map = new mapbox.Map({
4050
container: 'map',
4151
devtools: true,
4252
zoom: 18,
4353
center: [11.576073, 48.135578],
4454
pitch: 54,
4555
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+
},
4762
hash: true
4863
});
4964

50-
var dbgTrackedParams = map._tp;
65+
const buildingDebugPane = new Pane();
66+
buildingDebugPane.title = "Procedural Buildings";
5167

5268
var params = {
5369
ambientColor: [255, 255, 255],
@@ -58,9 +74,47 @@
5874
sunPolarAngle: 50,
5975
castShadows: true,
6076
shadowIntensity: 1.0,
61-
lightPreset: "day"
77+
lightPreset: "day",
78+
show3dObjects: true,
79+
show3dBuildings: true,
80+
show3dFacades: true,
81+
show3dLandmarks: true
6282
};
6383

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+
64118
function updateSunLight() {
65119
map.setLights([
66120
{
@@ -89,18 +143,30 @@
89143
map.triggerRepaint();
90144
};
91145

92-
map.on('load', () => {
93-
map.showTileBoundaries = true;
94-
});
95-
96146
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+
});
98164
});
99165

100166
let selectedBuilding = null;
101167
map.addInteraction('place-click', {
102168
type: 'click',
103-
target: { featuresetId: 'buildings', importId: 'procedural-buildings' },
169+
target: { featuresetId: 'buildings', importId: 'basemap' },
104170
handler: ({ feature }) => {
105171
console.log(feature.id);
106172

0 commit comments

Comments
 (0)