fix isse where profile requests would download too many nodes
This commit is contained in:
parent
5403d257f0
commit
735e933fee
@ -298,21 +298,14 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree {
|
||||
let bsWorld = bbWorld.getBoundingSphere();
|
||||
|
||||
for (let i = 0; i < profile.points.length - 1; i++) {
|
||||
//let start = new THREE.Vector3(profile.points[i].x, bsWorld.center.y, profile.points[i].z);
|
||||
//let end = new THREE.Vector3(profile.points[i + 1].x, bsWorld.center.y, profile.points[i + 1].z);
|
||||
|
||||
let start = new THREE.Vector3(profile.points[i + 0].x, profile.points[i + 0].y, bsWorld.center.z);
|
||||
let end = new THREE.Vector3(profile.points[i + 1].x, profile.points[i + 1].y, bsWorld.center.z);
|
||||
|
||||
let closest = new THREE.Line3(start, end).closestPointToPoint(bsWorld.center);
|
||||
let closest = new THREE.Line3(start, end).closestPointToPoint(bsWorld.center, true);
|
||||
let distance = closest.distanceTo(bsWorld.center);
|
||||
return distance < (bsWorld.radius + profile.width);
|
||||
|
||||
//let ray1 = new THREE.Ray(start, new THREE.Vector3().subVectors(end, start).normalize());
|
||||
//let ray2 = new THREE.Ray(end, new THREE.Vector3().subVectors(start, end).normalize());
|
||||
//if (ray1.intersectsSphere(bsWorld) && ray2.intersectsSphere(bsWorld)) {
|
||||
// return true;
|
||||
//}
|
||||
return distance < (bsWorld.radius + profile.width);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -427,14 +427,13 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){
|
||||
|
||||
if (pointcloud.showBoundingBox && !node.boundingBoxNode && node.getBoundingBox) {
|
||||
let boxHelper = new Potree.Box3Helper(node.getBoundingBox());
|
||||
// let boxHelper = new THREE.BoxHelper(node.sceneNode);
|
||||
pointcloud.add(boxHelper);
|
||||
boxHelper.matrixAutoUpdate = false;
|
||||
pointcloud.boundingBoxNodes.push(boxHelper);
|
||||
node.boundingBoxNode = boxHelper;
|
||||
node.boundingBoxNode.matrixWorld.copy(pointcloud.matrixWorld);
|
||||
node.boundingBoxNode.matrix.copy(pointcloud.matrixWorld);
|
||||
} else if (pointcloud.showBoundingBox) {
|
||||
node.boundingBoxNode.visible = true;
|
||||
node.boundingBoxNode.matrixWorld.copy(pointcloud.matrixWorld);
|
||||
node.boundingBoxNode.matrix.copy(pointcloud.matrixWorld);
|
||||
} else if (!pointcloud.showBoundingBox && node.boundingBoxNode) {
|
||||
node.boundingBoxNode.visible = false;
|
||||
}
|
||||
|
||||
@ -125,6 +125,7 @@ Potree.ProfileRequest = class ProfileRequest {
|
||||
}
|
||||
|
||||
if (intersectedNodes.length > 0) {
|
||||
|
||||
this.getPointsInsideProfile(intersectedNodes, this.temporaryResult);
|
||||
if (this.temporaryResult.size() > 100) {
|
||||
this.pointsServed += this.temporaryResult.size();
|
||||
@ -159,11 +160,18 @@ Potree.ProfileRequest = class ProfileRequest {
|
||||
let numPoints = node.numPoints;
|
||||
let buffer = node.buffer;
|
||||
let view = new DataView(buffer.data);
|
||||
|
||||
|
||||
if(!numPoints){
|
||||
continue;
|
||||
}
|
||||
|
||||
{// DEBUG
|
||||
let boxHelper = new Potree.Box3Helper(node.getBoundingBox());
|
||||
boxHelper.matrixAutoUpdate = false;
|
||||
boxHelper.matrix.copy(viewer.scene.pointclouds[0].matrixWorld);
|
||||
viewer.scene.scene.add(boxHelper);
|
||||
}
|
||||
|
||||
let sv = new THREE.Vector3().subVectors(segment.end, segment.start).setZ(0);
|
||||
let segmentDir = sv.clone().normalize();
|
||||
|
||||
@ -267,6 +275,8 @@ Potree.ProfileRequest = class ProfileRequest {
|
||||
points.data['mileage'] = new Float64Array(mileage);
|
||||
points.numPoints = accepted.length;
|
||||
|
||||
//console.log(`getPointsInsideProfile - ${node.name} - accepted: ${accepted.length}`);
|
||||
|
||||
segment.points.add(points);
|
||||
}
|
||||
|
||||
|
||||
@ -1566,6 +1566,28 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if(this.showBoundingBox){
|
||||
let bbRoot = this.scene.scene.getObjectByName("potree_bounding_box_root");
|
||||
if(!bbRoot){
|
||||
let node = new THREE.Object3D();
|
||||
node.name = "potree_bounding_box_root";
|
||||
this.scene.scene.add(node);
|
||||
bbRoot = node;
|
||||
}
|
||||
|
||||
let visibleBoxes = [];
|
||||
for(let pointcloud of this.scene.pointclouds){
|
||||
for(let node of pointcloud.visibleNodes){
|
||||
let box = node.boundingBoxNode;
|
||||
visibleBoxes.push(box);
|
||||
}
|
||||
}
|
||||
|
||||
bbRoot.children = visibleBoxes;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.freeze) {
|
||||
let result = Potree.updatePointClouds(scene.pointclouds, camera, this.renderer);
|
||||
camera.near = result.lowestSpacing * 10.0;
|
||||
|
||||
@ -267,13 +267,13 @@ function readUsingDataView(event) {
|
||||
|
||||
performance.mark("laslaz-end");
|
||||
|
||||
{ // print timings
|
||||
performance.measure("laslaz", "laslaz-start", "laslaz-end");
|
||||
let measure = performance.getEntriesByType("measure")[0];
|
||||
let dpp = 1000 * measure.duration / numPoints;
|
||||
let debugMessage = `${measure.duration.toFixed(3)} ms, ${numPoints} points, ${dpp.toFixed(3)} µs / point`;
|
||||
console.log(debugMessage);
|
||||
}
|
||||
//{ // print timings
|
||||
// performance.measure("laslaz", "laslaz-start", "laslaz-end");
|
||||
// let measure = performance.getEntriesByType("measure")[0];
|
||||
// let dpp = 1000 * measure.duration / numPoints;
|
||||
// let debugMessage = `${measure.duration.toFixed(3)} ms, ${numPoints} points, ${dpp.toFixed(3)} µs / point`;
|
||||
// console.log(debugMessage);
|
||||
//}
|
||||
performance.clearMarks();
|
||||
performance.clearMeasures();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user