From f44b34c6b60ba64643d3da062931186ab110da3a Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Fri, 14 Feb 2020 09:45:45 +0100 Subject: [PATCH] cleanup --- static/js/.gitignore | 2 + static/js/bundle-stats.js | 104 ---------------------------------- static/js/bundle-stats.js.map | 1 - static/js/test.js | 9 +-- static/test.html | 2 - 5 files changed, 7 insertions(+), 111 deletions(-) delete mode 100644 static/js/bundle-stats.js delete mode 100644 static/js/bundle-stats.js.map diff --git a/static/js/.gitignore b/static/js/.gitignore index 98e2724..ee236d8 100644 --- a/static/js/.gitignore +++ b/static/js/.gitignore @@ -1,2 +1,4 @@ bundle.js bundle.js.map +bundle-stats.js +bundle-stats.js.map diff --git a/static/js/bundle-stats.js b/static/js/bundle-stats.js deleted file mode 100644 index dbc7ce2..0000000 --- a/static/js/bundle-stats.js +++ /dev/null @@ -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 diff --git a/static/js/bundle-stats.js.map b/static/js/bundle-stats.js.map deleted file mode 100644 index d98b2d8..0000000 --- a/static/js/bundle-stats.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bundle-stats.js","sources":["components/WorldStats.js","WebSocketChannel.js","stats.js"],"sourcesContent":["\nexport default function(info){\n\n var timeIcon = m(\"span\", { class: \"fa fa-sun\", style: \"color: orange;\" });\n\n if (info.time < 5500 || info.time > 19000) //0 - 24'000\n timeIcon = m(\"span\", { class: \"fa fa-moon\", style: \"color: blue;\" });\n\n function getHour(){\n return Math.floor(info.time/1000);\n }\n\n function getMinute(){\n var min = Math.floor((info.time % 1000) / 1000 * 60);\n return min > 10 ? min : \"0\" + min;\n }\n\n function getLag(){\n var color = \"green\";\n if (info.max_lag > 0.8)\n color = \"orange\";\n else if (info.max_lag > 1.2)\n color = \"red\";\n\n return [\n m(\"span\", { class: \"fa fa-wifi\", style: \"color: \" + color }),\n parseInt(info.max_lag*1000),\n \" ms\"\n ];\n }\n\n function getPlayers(){\n return [\n m(\"span\", { class: \"fa fa-users\" }),\n info.players ? info.players.length : \"0\"\n ];\n }\n\n return m(\"div\", [\n getPlayers(),\n \" \",\n getLag(),\n \" \",\n m(\"span\", { class: \"fa fa-clock\" }),\n timeIcon,\n getHour(), \":\", getMinute()\n ]);\n\n};\n","\nclass WebSocketChannel {\n constructor(){\n this.wsUrl = window.location.protocol.replace(\"http\", \"ws\") +\n \"//\" + window.location.host +\n window.location.pathname.substring(0, window.location.pathname.lastIndexOf(\"/\")) +\n \"/api/ws\";\n\n this.listenerMap = {/* type -> [listeners] */};\n }\n\n addListener(type, listener){\n var list = this.listenerMap[type];\n if (!list){\n list = [];\n this.listenerMap[type] = list;\n }\n\n list.push(listener);\n }\n\n removeListener(type, listener){\n var list = this.listenerMap[type];\n if (!list){\n return;\n }\n\n this.listenerMap[type] = list.filter(l => l != listener);\n }\n\n connect(){\n var ws = new WebSocket(this.wsUrl);\n var self = this;\n\n ws.onmessage = function(e){\n var event = JSON.parse(e.data);\n //rendered-tile, mapobject-created, mapobjects-cleared\n\n var listeners = self.listenerMap[event.type];\n if (listeners){\n listeners.forEach(function(listener){\n listener(event.data);\n });\n }\n };\n\n ws.onerror = function(){\n //reconnect after some time\n setTimeout(self.connect.bind(self), 1000);\n };\n }\n}\n\nexport default new WebSocketChannel();\n","\nimport WorldStats from './components/WorldStats.js';\nimport wsChannel from './WebSocketChannel.js';\n\nwsChannel.connect();\n\nwsChannel.addListener(\"minetest-info\", function(info){\n\tm.render(document.getElementById(\"app\"), WorldStats(info));\n});\n"],"names":[],"mappings":"6FACe,mBAAQ,CAAC,IAAI,CAAC;;EAE3B,IAAI,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAC;;EAE1E,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,IAAI,GAAG,KAAK;IACvC,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,KA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MAG/B,IAAI,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;MAC7C,IAAI,SAAS,CAAC;QACZ,SAAS,CAAC,OAAO,CAAC,SAAS,QAAQ,CAAC;UAClC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACtB,CAAC,CAAC;OACJ;KACF,CAAC;;IAEF,EAAE,CAAC,OAAO,GAAG,UAAU;;MAErB,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;KAC3C,CAAC;GACH;CACF;;AAED,gBAAe,IAAI,gBAAgB,EAAE,CAAC,ACjDtC,SAAS,CAAC,OAAO,EAAE,CAAC;;AAEpB,SAAS,CAAC,WAAW,CAAC,eAAe,EAAE,SAAS,IAAI,CAAC;CACpD,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;CAC3D,CAAC,CAAC"} \ No newline at end of file diff --git a/static/js/test.js b/static/js/test.js index f81bd98..297428d 100644 --- a/static/js/test.js +++ b/static/js/test.js @@ -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++; } diff --git a/static/test.html b/static/test.html index 96eec23..5ef29c9 100644 --- a/static/test.html +++ b/static/test.html @@ -6,8 +6,6 @@ 3D View test -
-