From 25f32088cf22fe6ca9cdc1939e0ac612cd289f67 Mon Sep 17 00:00:00 2001 From: Rune Harlyk Date: Sun, 14 May 2023 20:42:11 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=BC=20Removes=20unused=20static=20webs?= =?UTF-8?q?ite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/index.html | 90 --------------------------------- data/script.js | 129 ------------------------------------------------ 2 files changed, 219 deletions(-) delete mode 100644 data/index.html delete mode 100644 data/script.js diff --git a/data/index.html b/data/index.html deleted file mode 100644 index 8cbd6e3..0000000 --- a/data/index.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - Spot Micro - - - - -

Spot Micro Controller

-
-
-
-
-
-
-
-
-
-
-
- -
-
- -
-
-
-
- - - \ No newline at end of file diff --git a/data/script.js b/data/script.js deleted file mode 100644 index 1da8fad..0000000 --- a/data/script.js +++ /dev/null @@ -1,129 +0,0 @@ -let websocket, scene, camera, rendered, cube; - -function lerp (start, end, amt){ - return (1-amt)*start+amt*end -} - -let floats = new Float32Array(12); -let x, y, z; -const init = () => { - - websocket = new WebSocket(`ws://leika.local/`) //${location.hostname} - websocket.binaryType = "arraybuffer"; - websocket.onopen = (event) => { - console.log(event); - }; - websocket.onmessage = (event) => { - if (event.data instanceof ArrayBuffer) { - let data = new Uint8Array(event.data); - floats = new Float32Array(data.buffer); - - var toDeg = (Math.PI/180); - - cube.rotation.x = lerp (x, floats[5]*toDeg, 0.5); - cube.rotation.z = lerp (x, floats[6]*toDeg, 0.5); - cube.rotation.y = lerp (x, floats[7]*toDeg, 0.5); - - x = floats[5]*toDeg; - y = floats[6]*toDeg; - z = floats[7]*toDeg; - - document.querySelector(".rssi").innerHTML = "RSSI: " + floats[0] + "db"; - document.querySelector(".mpu_temp").innerHTML = "Temp: :" + Math.floor(floats[1]) + "°"; - document.querySelector(".x").innerHTML = "X: " + x; - document.querySelector(".y").innerHTML = "Y: " + y; - document.querySelector(".z").innerHTML = "Z: " + z; - document.querySelector(".temp").innerHTML = "Cpu temp: " + Math.floor(floats[8]) + "°"; - document.querySelector(".uss_r").innerHTML = "USS R: " + floats[9]+ "cm"; - document.querySelector(".uss_l").innerHTML = "USS L: " + floats[10] + "cm"; - document.querySelector(".heap").innerHTML = "Heap: " + humanFileSize(floats[11]); - document.querySelector(".psram").innerHTML = "psram: " + humanFileSize(floats[12]); - console.log(x,y,z); - renderer.render(scene, camera); - } else { - console.log(event.data); - } - } - - document.getElementById("stream").src = `//leika.local/stream` -} - -function parentWidth(elem) { - return elem.parentElement.clientWidth; -} - -function parentHeight(elem) { - return elem.parentElement.clientHeight; -} - -function init3D(){ - scene = new THREE.Scene(); - //scene.background = new THREE.Color(0xffffff00); - - camera = new THREE.PerspectiveCamera(75, parentWidth(document.getElementById("3Dcube")) / parentHeight(document.getElementById("3Dcube")), 0.1, 1000); - - renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); - renderer.setClearColor( 0x000000, 0 ); - renderer.setSize(parentWidth(document.getElementById("3Dcube")), parentHeight(document.getElementById("3Dcube"))); - - document.getElementById('3Dcube').appendChild(renderer.domElement); - - // Create a geometry - const geometry = new THREE.BoxGeometry(2, 1, 6); - - // Materials of each face - var cubeMaterials = [ - new THREE.MeshBasicMaterial({color:0x03045e}), - new THREE.MeshBasicMaterial({color:0x023e8a}), - new THREE.MeshBasicMaterial({color:0x0077b6}), - new THREE.MeshBasicMaterial({color:0x03045e}), - new THREE.MeshBasicMaterial({color:0x023e8a}), - new THREE.MeshBasicMaterial({color:0x0077b6}), - ]; - - const material = new THREE.MeshFaceMaterial(cubeMaterials); - - cube = new THREE.Mesh(geometry, material); - scene.add(cube); - camera.position.z = 5; - renderer.render(scene, camera); -} - -// Resize the 3D object when the browser window changes size -function onWindowResize(){ - camera.aspect = parentWidth(document.getElementById("3Dcube")) / parentHeight(document.getElementById("3Dcube")); - //camera.aspect = window.innerWidth / window.innerHeight; - camera.updateProjectionMatrix(); - //renderer.setSize(window.innerWidth, window.innerHeight); - renderer.setSize(parentWidth(document.getElementById("3Dcube")), parentHeight(document.getElementById("3Dcube"))); - -} - -window.addEventListener('resize', onWindowResize, false); - -// Create the 3D representation -init3D(); -init(); - - -function humanFileSize(bytes, si=false, dp=1) { - const thresh = si ? 1000 : 1024; - - if (Math.abs(bytes) < thresh) { - return bytes + ' B'; - } - - const units = si - ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] - : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; - let u = -1; - const r = 10**dp; - - do { - bytes /= thresh; - ++u; - } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1); - - - return bytes.toFixed(dp) + ' ' + units[u]; - } \ No newline at end of file