From 5769b912295cf9d660c669761898a0dc44cdf42c Mon Sep 17 00:00:00 2001 From: Tim Wundenberg Date: Tue, 10 Aug 2021 21:01:15 +0200 Subject: [PATCH] fix deletion of point cloud --- .../public/Potree/build/potree/potree.js | 4 ++++ .../public/Potree/examples/pcw.html | 23 +++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/PointCloudWeb.Web/public/Potree/build/potree/potree.js b/PointCloudWeb.Web/public/Potree/build/potree/potree.js index ea60370..55ab21d 100644 --- a/PointCloudWeb.Web/public/Potree/build/potree/potree.js +++ b/PointCloudWeb.Web/public/Potree/build/potree/potree.js @@ -79578,6 +79578,10 @@ ENDSEC tree.jstree('uncheck_node', node); } }); + pointcloud.addEventListener("remove", () => { + const nodeObj = tree.jstree(true).get_node(node); + tree.jstree(true).delete_node(nodeObj); + }); }; let onMeasurementAdded = (e) => { diff --git a/PointCloudWeb.Web/public/Potree/examples/pcw.html b/PointCloudWeb.Web/public/Potree/examples/pcw.html index d41b9b2..0e1bab0 100644 --- a/PointCloudWeb.Web/public/Potree/examples/pcw.html +++ b/PointCloudWeb.Web/public/Potree/examples/pcw.html @@ -88,10 +88,25 @@ loadByPc(pointClouds[i]) } } - let notFound = [...loadedPointClouds.filter(pc => pointClouds.find(ipc => ipc.id === pc.id) === null)]; - for (let entry in notFound) { - // entry.pointCloud - //TODO: Remove from Potree + + for (let entry in loadedPointClouds) { + if (pointClouds.find(ipc => ipc.id === loadedPointClouds[entry].id)) + continue; + + const index = viewer.scene.pointclouds.indexOf(loadedPointClouds[entry].pointCloud); + if (index > -1) { + window.viewer.scene.pointclouds.forEach(function (layer) { + if (layer === loadedPointClouds[entry].pointCloud) + window.viewer.scene.scenePointCloud.remove(layer); + }); + viewer.scene.pointclouds.splice(index, 1); + + loadedPointClouds[entry].pointCloud.dispatchEvent({ + type: "remove" + }); + + loadedPointClouds.splice(entry, 1); + } } }