Skip to content

Commit

Permalink
refactor(#40): move point cloud loading before loadGUI
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSolberg committed Oct 26, 2025
1 parent f19fd56 commit 8a0bd38
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/potreeViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ export async function createPotreeViewer(
viewer.setDescription('Molloy Explorer')

const pointclouds = []
for (const url of pointcloudUrls) {
const e = await Potree.loadPointCloud(url)
const pc = e.pointcloud
viewer.scene.addPointCloud(pc)

pc.material.pointSizeType = Potree.PointSizeType.ADAPTIVE
pc.material.shape = Potree.PointShape.CIRCLE
overrideShaderForGradient(pc)

//The default activeAttributeName is set to elevation and the color gradient to VIRIDIS for good visualization
pc.material.elevationRange = [-10000, 0]
pc.material.activeAttributeName = 'elevation'
pc.material.gradient = Potree.Gradients['VIRIDIS']

e.pointcloud.projection = ecef

pointclouds.push(pc)
}

viewer.loadGUI(() => {
viewer.setLanguage('en')
Expand Down Expand Up @@ -110,25 +128,6 @@ export async function createPotreeViewer(
initAnnotationsPanel(viewer)
})

for (const url of pointcloudUrls) {
const e = await Potree.loadPointCloud(url)
const pc = e.pointcloud
viewer.scene.addPointCloud(pc)

pc.material.pointSizeType = Potree.PointSizeType.ADAPTIVE
pc.material.shape = Potree.PointShape.CIRCLE
overrideShaderForGradient(pc)

//The default activeAttributeName is set to elevation and the color gradient to VIRIDIS for good visualization
pc.material.elevationRange = [-10000, 0]
pc.material.activeAttributeName = 'elevation'
pc.material.gradient = Potree.Gradients['VIRIDIS']

e.pointcloud.projection = ecef

pointclouds.push(pc)
}

// Initialize camera position and target point (manually chosen)
viewer.scene.view.setView(
[3961574.044, 1494736.334, 8348318.575], // Initial camera position
Expand Down

0 comments on commit 8a0bd38

Please sign in to comment.