Skip to content

Commit

Permalink
refactor(#8): 🩹 Adjusted to PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mariewah committed Oct 24, 2025
1 parent 2ea2c33 commit 8b54df5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
2 changes: 2 additions & 0 deletions cypress/e2e/filtering.cy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/**Testing whether the Accepted components excists or not */
describe('Accepted filtering', () => {
it('test accepted filter button', function () {
cy.visit('http://localhost:5173/#')
cy.get('#doAcceptedFilter').click()
})
})

/**Testing whether the Elevation components excists or not */
describe('Elevation Control', () => {
it('test elevation control', function () {
cy.visit('http://localhost:5173/#')
Expand Down
22 changes: 4 additions & 18 deletions src/AcceptedFiltering/threePanels.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* ---------- Buttons (shared look) ---------- */
/* Reuse your accepted button style for all four */
#btnDoElevationControl,
#doAcceptedHost,
#doAcceptedFiltering,
#btnTHU,
#btnTVU,
#btnTHUFilter {
Expand All @@ -22,15 +22,15 @@
}

#btnDoElevationControl:hover,
#doAcceptedHost:hover,
#doAcceptedFiltering:hover,
#btnTHU:hover,
#btnTVU:hover,
#btnTHUFilter:hover {
background-color: #8f8f8f;
}

#btnDoElevationControl:active,
#doAcceptedHost:active,
#doAcceptedFiltering:active,
#btnTHU:active,
#btnTVU:active,
#btnTHUFilter:active {
Expand All @@ -40,7 +40,7 @@

/* Optional: “active mode” outline if you toggle a class via JS */
#btnDoElevationControl.active,
#doAcceptedHost.active,
#doAcceptedFiltering.active,
#btnTHU.active,
#btnTVU.active,
#btnTHUFilter:active {
Expand Down Expand Up @@ -116,20 +116,6 @@
letter-spacing: 0.2px;
}

/* Row layout for THU / TVU buttons */
#thu_tvu_list .thu-tvu-row {
display: flex;
justify-content: space-between;
gap: 8px;
margin-bottom: 10px;
}

/* Each button takes up half the width nicely */
#thu_tvu_list .thu-tvu-row button {
flex: 1 1 50%;
margin: 0; /* override any global margin */
}

/* Legend container */
#accepted_legend {
margin-top: 10px;
Expand Down
13 changes: 7 additions & 6 deletions src/AcceptedFiltering/threePanels.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ function rebindElevationLabel() {

slider.slider({ min: -10000, max: 0, values: [-10000, 0] })
slider.off('slide.custom slidestop.custom change.custom')
slider.on('slide.custom', update)
slider.on('slidestop.custom change.custom', update)
slider.on('slide.custom', 'slidestop.custom change.custom', update)
update()
}

Expand Down Expand Up @@ -261,10 +260,10 @@ function createAcceptedPanel() {
*/
function ensureAcceptedButton(hooks) {
const { btns } = ensurePanelScaffold('accepted_list_host')
if (!btns || byId('doAcceptedHost')) return
if (!btns || byId('doAcceptedFiltering')) return

const btn = document.createElement('button')
btn.id = 'doAcceptedHost'
btn.id = 'doAcceptedFiltering'
btn.type = 'button'
btn.textContent = 'Activate accepted filter'
btn.addEventListener('click', () => {
Expand Down Expand Up @@ -312,7 +311,7 @@ export function toggleAcceptedLegend(show) {
}

/**
* Ensures a UL list host exists inside the Accepted section (Does appearnlty nor work without this).
* Ensures a UL list host exists inside the Accepted section (Does appearnlty not work without this).
* @returns {HTMLElement|null}
*/
function ensureAcceptedListUL() {
Expand Down Expand Up @@ -430,7 +429,9 @@ export function initThreePanels(viewer, hooks = {}) {
byId('btnDoElevationControl')?.addEventListener('click', () =>
setActive('elevation')
)
byId('doAcceptedHost')?.addEventListener('click', () => setActive('accepted'))
byId('doAcceptedFiltering')?.addEventListener('click', () =>
setActive('accepted')
)

attachSelfHealing(getActive)

Expand Down
9 changes: 5 additions & 4 deletions src/potreeViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ export async function createPotreeViewer(containerId, pointcloudUrl, settings) {
oc.removeEventListener('mousewheel', oc._listeners?.mousewheel?.[0])
oc.addEventListener('mousewheel', clampScrollRadius)

const e = await Potree.loadPointCloud(pointcloudUrl)
const pc = e.pointcloud
viewer.scene.addPointCloud(pc)

if (settings.edl) viewer.setEDLEnabled(true)
if (settings.fov) viewer.setFOV(settings.fov)
if (settings.pointBudget) viewer.setPointBudget(settings.pointBudget)
Expand Down Expand Up @@ -68,6 +64,10 @@ export async function createPotreeViewer(containerId, pointcloudUrl, settings) {
initMeasurementsPanel(viewer)
})

const e = await Potree.loadPointCloud(pointcloudUrl)
const pc = e.pointcloud
viewer.scene.addPointCloud(pc)

// Change name of default background from 'None' to 'Globe"'
$('#background_options_none')
.text('Globe')
Expand Down Expand Up @@ -162,6 +162,7 @@ function overrideShaderForGradient(pc) {

/**
* Freeze all scrollable ancestors of a given root during an action (e.g., jsTree select)
* Need this so that when Elevation control or Accepted filter is activated the sidebar doesn't scroll down to the Scene panel
*
* @param {*} action
*/
Expand Down

0 comments on commit 8b54df5

Please sign in to comment.