diff --git a/public/index.html b/public/index.html
index 096ad42..f2bea15 100644
--- a/public/index.html
+++ b/public/index.html
@@ -7,7 +7,7 @@
-
+
@@ -22,13 +22,21 @@
// load map
let maps = [];
let markerManager = null;
+ let playerManager = null;
BlueMap.loadMaps("data/", bluemap.events).then(loadedMaps => {
maps = loadedMaps;
- bluemap.setMap(maps[0]);
- markerManager = maps[0].createMarkerFileManager(bluemap.markerScene);
+ markerManager = new BlueMap.MarkerFileManager(bluemap.markerScene, "data/markers.json", maps[0].id, bluemap.events);
markerManager.update();
markerManager.setAutoUpdateInterval(1000 * 10);
+
+ playerManager = new BlueMap.PlayerMarkerManager(bluemap.markerScene, "live/players", "", bluemap.events);
+ playerManager.update();
+ playerManager.setAutoUpdateInterval(1000);
+
+ bluemap.setMap(maps[0]).then(() => {
+ playerManager.worldId = maps[0].world;
+ });
});
diff --git a/public/live/players b/public/live/players
index a2c2260..6b701cd 100644
--- a/public/live/players
+++ b/public/live/players
@@ -1 +1 @@
-{"players":[{"uuid":"c61be8fb-0a66-4411-aae5-0c67bb4808d4","name":"TBlueF","world":"118a8ec2-ccb1-4e84-be88-1ff568e413ca","position":{"x":-130.62644738873905,"y":72.53260088333643,"z":138.27086962845027}}]}
\ No newline at end of file
+{"players":[{"uuid":"c61be8fb-0a66-4411-aae5-0c67bb4808d4","name":"TBlueF","world":"118a8ec2-ccb1-4e84-be88-1ff568e413ca","position":{"x":130.62644738873905,"y":82.53260088333643,"z":-138.27086962845027}}]}
\ No newline at end of file
diff --git a/src/BlueMap.js b/src/BlueMap.js
index 0e5030a..7d09856 100644
--- a/src/BlueMap.js
+++ b/src/BlueMap.js
@@ -3,6 +3,8 @@ import {Map} from "./map/Map";
export { MapViewer } from "./MapViewer";
export * from "./util/Utils";
+export { MarkerFileManager } from "./markers/MarkerFileManager";
+export { PlayerMarkerManager } from "./markers/PlayerMarkerManager";
/**
* Loads and returns a promise with an array of Maps loaded from that root-path.
diff --git a/src/MapViewer.js b/src/MapViewer.js
index 3a7a374..bbac473 100644
--- a/src/MapViewer.js
+++ b/src/MapViewer.js
@@ -287,6 +287,7 @@ export class MapViewer {
/**
* Changes / Sets the map that will be loaded and displayed
* @param map {Map}
+ * @returns Promise
*/
setMap(map = null) {
if (this.map && this.map.isMap) this.map.unload();
diff --git a/src/PlayerMarkerManager.js b/src/PlayerMarkerManager.js
deleted file mode 100644
index 42d68e6..0000000
--- a/src/PlayerMarkerManager.js
+++ /dev/null
@@ -1,116 +0,0 @@
-import {alert} from "../util/Utils";
-import {FileLoader} from "three";
-
-export class PlayerMarkerManager {
-
- constructor(mapViewer, events = null, livePlayerUrl = "/live/players") {
- this.mapViewer = mapViewer;
- this.events = events ? events : mapViewer.events;
- this.playerUrl = livePlayerUrl;
-
- this._playerData = {players:[]};
-
- this.events.addEventListener("bluemapMapChanged", this.onMapChange);
- }
-
- update(){
- return this.loadPlayerData()
- .then(playerData => {
- if (playerData && Array.isArray(playerData.players)) {
- this._playerData = playerData;
- this.updateMarkers();
- }
- })
- .catch(reason => {
- alert(this.events, reason, "warning");
- });
- }
-
- updateMarkers() {
- if (!this.mapViewer.map || !this.mapViewer.map.isLoaded) return;
- let markerset = this.getMarkerset();
-
- // map of uuid to playerdata
- let playerMap = {};
- this._playerData.players.forEach(player => {
- if (!player.uuid) return;
-
- // fill defaults
- player = {
- name: player.uuid,
- world: "",
- position: {},
- rotation: {},
- ...player
- };
-
- player.position = {
- x: 0,
- y: 0,
- z: 0,
- ...player.position
- };
-
- player.rotation = {
- yaw: 0,
- pitch: 0,
- roll: 0,
- ...player.rotation
- };
-
- playerMap[player.uuid] = player;
- });
-
- //update existing markers
- markerset.marker.forEach(marker => {
- if (!marker.isPlayerMarker) return;
- if (!playerMap[marker.playerUuid]) return;
- let player = playerMap[marker.playerUuid];
-
-
- });
- }
-
- getMarkerset() {
- //init markerset
- let markerset = this.mapViewer.map.markerManager.markerSets["bm-live-players"];
- if (!markerset || !markerset.isMarkerSet){
- markerset = this.mapViewer.map.markerManager.createMarkerSet("bm-live-players");
- }
-
- return markerset;
- }
-
- onMapChange = () => {
- this.updateMarkers();
- }
-
- dispose() {
- this.events.removeEventListener("bluemapMapChanged", this.onMapChange);
-
- this._playerData = {players:[]};
- this.updateMarkers();
- }
-
- /**
- * Loads the playerdata
- * @returns {Promise