-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from TDT4290-group-4/25-only-show-coordinates-…
…of-target-point refactor(#25): ♻️ Changed from canvas to text element, lat/lon…
- Loading branch information
Showing
6 changed files
with
97 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #coordinatesContainer { | ||
| position: absolute; | ||
| display: flex; | ||
| flex-direction: column; | ||
| right: 10px; | ||
| bottom: 10px; | ||
| padding: 10px; | ||
| border-radius: 5px; | ||
| z-index: 10; | ||
| background-color: #19282c; | ||
| width: auto; | ||
| height: auto; | ||
| } | ||
|
|
||
| #coordinatesHeader { | ||
| color: #cccccc; | ||
| font-family: Arial, Helvetica, sans-serif; | ||
| font-size: 20px; | ||
| line-height: 0.75; | ||
| position: relative; | ||
| height: min-content; | ||
| margin: 0; | ||
| padding-bottom: 20px; | ||
| font-weight: bold; | ||
| } | ||
| #latitude, | ||
| #longitude, | ||
| #elevation { | ||
| color: #cccccc; | ||
| font-family: Arial, Helvetica, sans-serif; | ||
| font-size: 18px; | ||
| position: relative; | ||
| margin: 0; | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { ecef } from '../config.js' | ||
| import { wgs84 } from '../config.js' | ||
|
|
||
| const latitudeText = document.getElementById('latitude') | ||
| const longitudeText = document.getElementById('longitude') | ||
| const elevationText = document.getElementById('elevation') | ||
| const coordinatesContainer = document.getElementById('coordinatesContainer') | ||
|
|
||
| let isRightClick = false | ||
|
|
||
| /** Sets up a right-click listener on the Potree viewer to toggle updates of coordinate display. | ||
| * Makes sure coordinates are only updated when not right-clicking. | ||
| * @param potreeViewer - The Potree viewer instance | ||
| */ | ||
| export function setupRightClickListener(potreeViewer) { | ||
| const viewerElement = potreeViewer.renderer.domElement | ||
|
|
||
| viewerElement.addEventListener('mousedown', (event) => { | ||
| if (event.button === 2) { | ||
| isRightClick = true | ||
| } | ||
| }) | ||
|
|
||
| viewerElement.addEventListener('dblclick', (event) => { | ||
| if (event.button === 0) { | ||
| isRightClick = false | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| /** | ||
| * Updates the displayed target point coordinates based on the point | ||
| */ | ||
| export function updateText() { | ||
| if (!isRightClick) { | ||
| const pivot = window.potreeViewer.scene.view.getPivot() | ||
| const controls = window.potreeViewer.getControls() | ||
| const [lon, lat, elevation] = proj4(ecef, wgs84, [ | ||
| pivot.x, | ||
| pivot.y, | ||
| pivot.z | ||
| ]) | ||
|
|
||
| if (controls === window.potreeViewer.orbitControls) { | ||
| coordinatesContainer.style.display = 'inline' | ||
| latitudeText.textContent = `Latitude = ${lat.toFixed(4)}˚` | ||
| longitudeText.textContent = `Longitude = ${lon.toFixed(4)}˚` | ||
| elevationText.textContent = `Elevation = ${elevation.toFixed(4)}m` | ||
| } else { | ||
| coordinatesContainer.style.display = 'none' | ||
| } | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters