2021-01-18 16:51:03 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
2021-01-28 02:56:26 +01:00
|
|
|
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
|
2021-01-18 16:51:03 +01:00
|
|
|
<title>BlueMap Lib Test</title>
|
|
|
|
<link rel="shortcut icon" href="favicon.png">
|
|
|
|
</head>
|
|
|
|
<body style="margin: 0; padding: 0;">
|
2021-01-28 19:57:54 +01:00
|
|
|
<div id="map-container" style="position: absolute; width: 100%; height: 100%;"></div>
|
2021-01-18 16:51:03 +01:00
|
|
|
|
|
|
|
<script type="text/javascript" src="js/three.js"></script>
|
|
|
|
<script type="text/javascript" src="js/hammer.js"></script>
|
|
|
|
<script type="text/javascript" src="js/bluemap.js"></script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
let bluemap = new BlueMap.MapViewer(document.getElementById("map-container"));
|
|
|
|
|
|
|
|
// show stats panel
|
|
|
|
bluemap.stats.showPanel(1);
|
|
|
|
|
2021-02-19 16:06:47 +01:00
|
|
|
let mapControls = new BlueMap.MapControls(bluemap.rootElement);
|
2021-02-17 15:48:27 +01:00
|
|
|
let freeControls = new BlueMap.FreeFlightControls(bluemap.rootElement);
|
2021-02-19 16:06:47 +01:00
|
|
|
bluemap.controlsManager.controls = mapControls;
|
2021-02-17 15:48:27 +01:00
|
|
|
|
2021-01-18 16:51:03 +01:00
|
|
|
// load map
|
2021-02-19 16:06:47 +01:00
|
|
|
const loadMaps = (dataUrl, events = null) => {
|
|
|
|
function loadSettings() {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
let loader = new THREE.FileLoader();
|
|
|
|
loader.setResponseType("json");
|
|
|
|
loader.load(dataUrl + "settings.json",
|
|
|
|
resolve,
|
|
|
|
() => {},
|
|
|
|
() => reject("Failed to load the settings.json!")
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return loadSettings().then(settings => {
|
|
|
|
let maps = [];
|
|
|
|
|
|
|
|
// create maps
|
|
|
|
if (settings.maps !== undefined){
|
|
|
|
for (let mapId in settings.maps) {
|
|
|
|
if (!settings.maps.hasOwnProperty(mapId)) continue;
|
|
|
|
|
|
|
|
let mapSettings = settings.maps[mapId];
|
|
|
|
if (mapSettings.enabled)
|
|
|
|
maps.push(new BlueMap.Map(mapId, dataUrl + mapId + "/", dataUrl + "settings.json", dataUrl + "textures.json", events));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// sort maps
|
|
|
|
maps.sort((map1, map2) => {
|
|
|
|
let sort = settings.maps[map1.id].ordinal - settings.maps[map2.id].ordinal;
|
|
|
|
if (isNaN(sort)) return 0;
|
|
|
|
return sort;
|
|
|
|
});
|
|
|
|
|
|
|
|
return maps;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-01-18 16:51:03 +01:00
|
|
|
let maps = [];
|
2021-01-28 02:56:26 +01:00
|
|
|
let markerManager = null;
|
2021-01-28 19:57:54 +01:00
|
|
|
let playerManager = null;
|
2021-02-19 16:06:47 +01:00
|
|
|
loadMaps("data/", bluemap.events).then(loadedMaps => {
|
2021-01-18 16:51:03 +01:00
|
|
|
maps = loadedMaps;
|
2021-01-28 02:56:26 +01:00
|
|
|
|
2021-01-28 19:57:54 +01:00
|
|
|
markerManager = new BlueMap.MarkerFileManager(bluemap.markerScene, "data/markers.json", maps[0].id, bluemap.events);
|
2021-01-28 02:56:26 +01:00
|
|
|
markerManager.update();
|
|
|
|
markerManager.setAutoUpdateInterval(1000 * 10);
|
2021-01-28 19:57:54 +01:00
|
|
|
|
|
|
|
playerManager = new BlueMap.PlayerMarkerManager(bluemap.markerScene, "live/players", "", bluemap.events);
|
|
|
|
playerManager.update();
|
|
|
|
playerManager.setAutoUpdateInterval(1000);
|
|
|
|
|
2021-02-19 16:06:47 +01:00
|
|
|
bluemap.switchMap(maps[0]).then(() => {
|
2021-01-28 19:57:54 +01:00
|
|
|
playerManager.worldId = maps[0].world;
|
|
|
|
});
|
2021-01-18 16:51:03 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|