-
Notifications
You must be signed in to change notification settings - Fork 0
7 elevation range control #20
Merged
81d2c465c1e79b17ea5c062ba02f7c65d24ab30
merged 4 commits into
dev
from
7-elevation-range-control
Oct 1, 2025
+115
−3
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
07a8eff
feat(#7): :sparkles: Created "Evelation Control" section with belongi…
2f4ec32
refactor(#7): :truck: Moved paths for evelation control in index.html
2b66727
refactor(#7): :recycle: Updated code for consistensy in the sidebar s…
5a328f8
refactor(#7): :fire: Remove link to css not in use
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,11 @@ | ||
| /* making sure that the divider span the whole sidebar (as the original code) */ | ||
| #customised_list > .divider { | ||
| margin: 0; | ||
| padding: 0; | ||
| } | ||
|
|
||
| /* Padding of list items in the elevation control section as the original code*/ | ||
| #customised_list li { | ||
| list-style-type: none; | ||
| padding: 0 20px; | ||
| } |
This file contains hidden or 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,138 @@ | ||
| /** | ||
| * Creating and inserting a new customised "Elevation Range" section in the sidebar above Apperance | ||
| * with the same css style features as Apperance | ||
| */ | ||
| (function () { | ||
|
|
||
| //Insert new the sidebar above Apperance | ||
| function insertCustomisedAboveAppearance() { | ||
| const appearanceHeader = document.querySelector('#menu_appearance'); | ||
| if (!appearanceHeader) return false; | ||
| if (document.querySelector('#menu_customised_header')) return true; | ||
|
|
||
| //Clone the header for identical style to apperance | ||
| const customHeader = appearanceHeader.cloneNode(true); | ||
| customHeader.removeAttribute('id'); | ||
| customHeader.id = 'menu_customised_header'; | ||
| customHeader.textContent = 'Elevation Control'; | ||
| customHeader.style.cursor = 'pointer'; | ||
| customHeader.setAttribute('tabindex', '0'); | ||
|
|
||
| //Creating a new "div" in the customised section similar to the Apperance div | ||
| const appearanceBody = appearanceHeader.nextElementSibling; | ||
| const bodyClass = appearanceBody ? appearanceBody.className : 'pv-menu-list'; | ||
| const customBody = document.createElement('div'); | ||
| customBody.className = bodyClass; | ||
| customBody.id = 'customised_list'; | ||
| customBody.style.display = ''; // start expanded | ||
|
|
||
| //Insert both right before Appearance | ||
| appearanceHeader.parentElement.insertBefore(customHeader, appearanceHeader); | ||
| appearanceHeader.parentElement.insertBefore(customBody, appearanceHeader); | ||
|
|
||
| //collapse/expand | ||
| const toggle = () => { | ||
| const hidden = customBody.style.display === 'none'; | ||
| customBody.style.display = hidden ? '' : 'none'; | ||
| }; | ||
| customHeader.addEventListener('click', toggle); | ||
| customHeader.addEventListener('keydown', (e) => { | ||
| if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); toggle(); } | ||
| }); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| function init() { | ||
| if (insertCustomisedAboveAppearance()) return; | ||
| let tries = 0; | ||
| const t = setInterval(() => { | ||
| tries++; | ||
| if (insertCustomisedAboveAppearance() || tries > 50) clearInterval(t); | ||
| }, 200); | ||
| } | ||
|
|
||
| if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init); | ||
| else init(); | ||
| })(); | ||
|
|
||
|
|
||
|
|
||
| /** | ||
| * A function that: | ||
| * - Autoselects the first pointcloud | ||
| * - Move the Elevation block from the Scene section into the custimosed Elevation Control section | ||
| * | ||
| * Nice to know: In the oroginal code the Elevation section in the Properties panel is only built when the pointcloud is clicked on | ||
| */ | ||
| (function () { | ||
| const $ = (sel, root = document) => root.querySelector(sel); | ||
|
|
||
| //Select the fist pointcloud in the sidebar so that the Elevation section is built | ||
| function autoSelectFirstPointCloud() { | ||
| const cloudIcon = document.querySelector('#scene_objects i.jstree-themeicon-custom'); | ||
| if (cloudIcon) { | ||
| cloudIcon.dispatchEvent(new MouseEvent('click', { bubbles: true })); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| //(re)connect the elevation labels to the slider after the container is moved (was not handled by default) | ||
| function rebindElevationLabel() { | ||
| const slider = window.jQuery ? window.jQuery("#sldHeightRange") : null; | ||
| const label = document.getElementById("lblHeightRange"); | ||
| if (!slider || !slider.length || !label) return; | ||
|
|
||
| const update = () => { | ||
| const low = $slider.slider("values", 0); | ||
| const high = $slider.slider("values", 1); | ||
| label.textContent = `${low.toFixed(2)} to ${high.toFixed(2)}`; | ||
| }; | ||
|
|
||
| //clear any old namespaced handlers and attach fresh ones | ||
| slider.off("slide.custom slidestop.custom change.custom"); | ||
| slider.on("slide.custom", update); | ||
| slider.on("slidestop.custom change.custom", update); | ||
| update(); | ||
| } | ||
|
|
||
| //Move the elevation range section to the customised "Elevation Control" section | ||
| function moveElevationContainer() { | ||
| const target = $('#customised_list'); | ||
| const elevationContainer = document.querySelector('#materials\\.elevation_container'); | ||
| if (!elevationContainer) return false; | ||
| target.appendChild(elevationContainer); | ||
| rebindElevationLabel(); | ||
| return true; | ||
|
|
||
| } | ||
|
|
||
| function init() { | ||
| let tries = 0; | ||
| const t = setInterval(() => { | ||
| const hasCloud = !!(window.viewer?.scene?.pointclouds?.length); | ||
| if (hasCloud) { | ||
| autoSelectFirstPointCloud(); | ||
| // Wait until potree builds the Properties, then move the container | ||
| let innerTries = 0; | ||
| const t2 = setInterval(() => { | ||
| const movedElevation = moveElevationContainer(); | ||
| if (movedElevation || ++innerTries > 100) clearInterval(t2); | ||
| }, 100); | ||
|
|
||
| clearInterval(t); | ||
| } | ||
| if (++tries > 30) clearInterval(t); | ||
| }, 100); | ||
| } | ||
|
|
||
| if (document.readyState === 'loading') { | ||
| document.addEventListener('DOMContentLoaded', init); | ||
| } else { | ||
| init(); | ||
| } | ||
| })(); | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +0,0 @@ | ||
| /* Empty for now, add logic later */ | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +0,0 @@ | ||
| /* Empty for now, add styles later */ | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.