diff --git a/src/coordinateShowing/coordinateShowing.css b/src/coordinateShowing/coordinateShowing.css deleted file mode 100644 index 0a8ac75..0000000 --- a/src/coordinateShowing/coordinateShowing.css +++ /dev/null @@ -1,26 +0,0 @@ -#canvasContainer { - display: flex; - flex-direction: column; - position: absolute; - right: 10px; - bottom: 10px; -} - -#posCanvas { - position: relative; - width: 300px; - height: 50px; - background-color: #19282c; - z-index: 10; - border-radius: 5px; -} - -#elevationCanvas { - position: relative; - width: 300px; - height: 50px; - background-color: #19282c; - z-index: 10; - margin-bottom: 10px; - border-radius: 5px; -} diff --git a/src/coordinateShowing/coordinateShowing.js b/src/coordinateShowing/coordinateShowing.js deleted file mode 100644 index 8045cd0..0000000 --- a/src/coordinateShowing/coordinateShowing.js +++ /dev/null @@ -1,80 +0,0 @@ -import { ecef } from '../config.js' -import { wgs84 } from '../config.js' - -const posCanvas = document.getElementById('posCanvas') // lat/lon -const elevationCanvas = document.getElementById('elevationCanvas') - -export let posCtx -export let elevationCtx - -/** - * Initializes the canvases and their contexts. - */ -export function initCoordinateCanvases() { - posCtx = resizeCanvas(posCanvas) - elevationCtx = resizeCanvas(elevationCanvas) -} - -/** - * Resizes the canvas and its context to account for device pixel ratio. - * @param {*} canvas - The canvas element to resize. - * @returns {*} - The resized canvas context. - */ -function resizeCanvas(canvas) { - const dpr = window.devicePixelRatio || 1 - const ctx = canvas.getContext('2d') - - canvas.width = canvas.clientWidth * dpr - canvas.height = canvas.clientHeight * dpr - - // Scale context so drawing uses CSS pixels - ctx.setTransform(dpr, 0, 0, dpr, 0, 0) - return ctx -} - -/** - * Draw the text on a given canvas. - */ -function drawText(ctx, text, canvas) { - const centerX = canvas.clientWidth / 2 - const centerY = canvas.clientHeight / 2 - ctx.clearRect(0, 0, canvas.width, canvas.height) - ctx.fillStyle = '#cccccc' - ctx.font = '20px Arial' - ctx.textAlign = 'center' - ctx.textBaseline = 'middle' - ctx.fillText(text, centerX, centerY) -} - -/** - * Updates the lat/lon coordinates. - */ -export function updateCoordinateText() { - const cam = window.potreeViewer.scene.view.position - const [lon, lat] = proj4(ecef, wgs84, [cam.x, cam.y, cam.z]) - drawText( - posCtx, - `lat = ${lat.toFixed(5)}˚ lon = ${lon.toFixed(5)}˚`, - posCanvas - ) -} - -/** - * Shows target elevations if camera is in orbit mode. - */ -export function updateTargetElevation() { - const pivot = window.potreeViewer.scene.view.getPivot() - const controls = window.potreeViewer.getControls() - const height = proj4(ecef, wgs84, [pivot.x, pivot.y, pivot.z])[2] - - if (controls === window.potreeViewer.orbitControls) { - elevationCanvas.style.display = 'inline' - drawText( - elevationCtx, - `Target elevation = ${height.toFixed(4)}m`, - elevationCanvas - ) - } else { - elevationCanvas.style.display = 'none' - } -}