forked from MTSR/mapserver
cleanup
This commit is contained in:
parent
c6dfd017c3
commit
f44b34c6b6
2
static/js/.gitignore
vendored
2
static/js/.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
bundle.js
|
||||
bundle.js.map
|
||||
bundle-stats.js
|
||||
bundle-stats.js.map
|
||||
|
@ -1,104 +0,0 @@
|
||||
(function(f){typeof define==='function'&&define.amd?define(f):f();}((function(){'use strict';function WorldStats(info){
|
||||
|
||||
var timeIcon = m("span", { class: "fa fa-sun", style: "color: orange;" });
|
||||
|
||||
if (info.time < 5500 || info.time > 19000) //0 - 24'000
|
||||
timeIcon = m("span", { class: "fa fa-moon", style: "color: blue;" });
|
||||
|
||||
function getHour(){
|
||||
return Math.floor(info.time/1000);
|
||||
}
|
||||
|
||||
function getMinute(){
|
||||
var min = Math.floor((info.time % 1000) / 1000 * 60);
|
||||
return min > 10 ? min : "0" + min;
|
||||
}
|
||||
|
||||
function getLag(){
|
||||
var color = "green";
|
||||
if (info.max_lag > 0.8)
|
||||
color = "orange";
|
||||
else if (info.max_lag > 1.2)
|
||||
color = "red";
|
||||
|
||||
return [
|
||||
m("span", { class: "fa fa-wifi", style: "color: " + color }),
|
||||
parseInt(info.max_lag*1000),
|
||||
" ms"
|
||||
];
|
||||
}
|
||||
|
||||
function getPlayers(){
|
||||
return [
|
||||
m("span", { class: "fa fa-users" }),
|
||||
info.players ? info.players.length : "0"
|
||||
];
|
||||
}
|
||||
|
||||
return m("div", [
|
||||
getPlayers(),
|
||||
" ",
|
||||
getLag(),
|
||||
" ",
|
||||
m("span", { class: "fa fa-clock" }),
|
||||
timeIcon,
|
||||
getHour(), ":", getMinute()
|
||||
]);
|
||||
|
||||
}class WebSocketChannel {
|
||||
constructor(){
|
||||
this.wsUrl = window.location.protocol.replace("http", "ws") +
|
||||
"//" + window.location.host +
|
||||
window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/")) +
|
||||
"/api/ws";
|
||||
|
||||
this.listenerMap = {/* type -> [listeners] */};
|
||||
}
|
||||
|
||||
addListener(type, listener){
|
||||
var list = this.listenerMap[type];
|
||||
if (!list){
|
||||
list = [];
|
||||
this.listenerMap[type] = list;
|
||||
}
|
||||
|
||||
list.push(listener);
|
||||
}
|
||||
|
||||
removeListener(type, listener){
|
||||
var list = this.listenerMap[type];
|
||||
if (!list){
|
||||
return;
|
||||
}
|
||||
|
||||
this.listenerMap[type] = list.filter(l => l != listener);
|
||||
}
|
||||
|
||||
connect(){
|
||||
var ws = new WebSocket(this.wsUrl);
|
||||
var self = this;
|
||||
|
||||
ws.onmessage = function(e){
|
||||
var event = JSON.parse(e.data);
|
||||
//rendered-tile, mapobject-created, mapobjects-cleared
|
||||
|
||||
var listeners = self.listenerMap[event.type];
|
||||
if (listeners){
|
||||
listeners.forEach(function(listener){
|
||||
listener(event.data);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
ws.onerror = function(){
|
||||
//reconnect after some time
|
||||
setTimeout(self.connect.bind(self), 1000);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var wsChannel = new WebSocketChannel();wsChannel.connect();
|
||||
|
||||
wsChannel.addListener("minetest-info", function(info){
|
||||
m.render(document.getElementById("app"), WorldStats(info));
|
||||
});})));//# sourceMappingURL=bundle-stats.js.map
|
File diff suppressed because one or more lines are too long
@ -28,7 +28,7 @@ function getMaterial(nodeName){
|
||||
}
|
||||
|
||||
function isNodeHidden(mapblock,x,y,z){
|
||||
if (x==0 && x>=15 && y==0 && y>=15 && z==0 && z>=15){
|
||||
if (x==0 || x>=15 || y==0 || y>=15 || z==0 || z>=15){
|
||||
// not sure, may be visible
|
||||
return false;
|
||||
}
|
||||
@ -51,6 +51,7 @@ function isNodeHidden(mapblock,x,y,z){
|
||||
if (isTransparent(mapblock[getNodePos(x,y,z+1)]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function drawMapblock(posx,posy,posz){
|
||||
@ -75,9 +76,9 @@ function drawMapblock(posx,posy,posz){
|
||||
|
||||
if (material) {
|
||||
var mesh = new THREE.Mesh( geometry, material );
|
||||
mesh.position.x = (x*1) + (posx*1*16);
|
||||
mesh.position.y = (y*1) + (posy*1*16);
|
||||
mesh.position.z = (z*1) + (posz*1*16);
|
||||
mesh.position.x = x + (posx*16);
|
||||
mesh.position.y = y + (posy*16);
|
||||
mesh.position.z = z + (posz*16);
|
||||
scene.add( mesh );
|
||||
nodeCount++;
|
||||
}
|
||||
|
@ -6,8 +6,6 @@
|
||||
<title>3D View test</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="image-map"></div>
|
||||
<div id="search-content"></div>
|
||||
<script src="js/lib/mithril.min.js"></script>
|
||||
<script src="js/lib/three.min.js"></script>
|
||||
<script src="js/lib/TrackballControls.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user