298 lines
9.3 KiB
HTML
298 lines
9.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="description" content="">
|
|
<meta name="author" content="">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
|
<title>Potree Viewer</title>
|
|
|
|
<link rel="stylesheet" type="text/css" href="../build/potree/potree.css">
|
|
<link rel="stylesheet" type="text/css" href="../libs/jquery-ui/jquery-ui.min.css">
|
|
<link rel="stylesheet" type="text/css" href="../libs/perfect-scrollbar/css/perfect-scrollbar.css">
|
|
<link rel="stylesheet" type="text/css" href="../libs/openlayers3/ol.css">
|
|
<link rel="stylesheet" type="text/css" href="../libs/spectrum/spectrum.css">
|
|
<link rel="stylesheet" type="text/css" href="../libs/jstree/themes/mixed/style.css">
|
|
</head>
|
|
|
|
<body>
|
|
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
|
<script src="../libs/spectrum/spectrum.js"></script>
|
|
<script src="../libs/perfect-scrollbar/js/perfect-scrollbar.jquery.js"></script>
|
|
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
|
<script src="../libs/three.js/build/three.js"></script>
|
|
<script src="../libs/other/BinaryHeap.js"></script>
|
|
<script src="../libs/tween/tween.min.js"></script>
|
|
<script src="../libs/d3/d3.js"></script>
|
|
<script src="../libs/proj4/proj4.js"></script>
|
|
<script src="../libs/openlayers3/ol.js"></script>
|
|
<script src="../libs/i18next/i18next.js"></script>
|
|
<script src="../libs/jstree/jstree.js"></script>
|
|
<script src="../build/potree/potree.js"></script>
|
|
<script src="../libs/plasio/js/laslaz.js"></script>
|
|
|
|
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
|
|
<!-- INCLUDE SETTINGS HERE -->
|
|
|
|
<div class="potree_container" style="position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; ">
|
|
<div id="potree_render_area"></div>
|
|
<div id="potree_sidebar_container"> </div>
|
|
|
|
<input id="filterFrustum" type="button" value="Filter Frustum" />
|
|
<input id="filterBoxes" type="button" value="Filter Boxes" />
|
|
<input id="filterProfiles" type="button" value="Filter Profiles" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
let clipSpheres = [
|
|
{position: [0.032, -2.382, 4.279], scale: 3},
|
|
{position: [-1.787, 6.011, 1.711], scale: 1},
|
|
{position: [0.095, 7.636, 10.997], scale: 2},
|
|
];
|
|
|
|
|
|
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
|
|
|
viewer.setServer("http://localhost:3000");
|
|
viewer.setEDLEnabled(true);
|
|
viewer.setFOV(60);
|
|
viewer.setPointBudget(1*1000*1000);
|
|
viewer.setMinNodeSize(0);
|
|
viewer.loadSettingsFromURL();
|
|
|
|
viewer.setDescription("");
|
|
|
|
viewer.loadGUI(() => {
|
|
viewer.setLanguage('en');
|
|
$("#menu_appearance").next().show();
|
|
$("#menu_tools").next().show();
|
|
$("#menu_scene").next().show();
|
|
viewer.toggleSidebar();
|
|
});
|
|
|
|
//Potree.loadPointCloud("../pointclouds/C/dev/pointclouds/converted/CA13_morro_area/cloud.js", "CA13", function(e){
|
|
Potree.loadPointCloud("../pointclouds/D/converted/retz/cloud.js", "retz", function(e){
|
|
//Potree.loadPointCloud("http://5.9.65.151/mschuetz/potree/resources/pointclouds/archpro/heidentor/cloud.js", "Heidentor", function(e){
|
|
viewer.scene.addPointCloud(e.pointcloud);
|
|
|
|
e.pointcloud.position.x += 20;
|
|
|
|
//e.pointcloud.position.z = 0;
|
|
let material = e.pointcloud.material;
|
|
material.size = 1;
|
|
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
|
|
|
let volume = new Potree.BoxVolume();
|
|
volume.position.set(-10.315, 9.179, 31.711);
|
|
volume.rotation.set(0.000, 0.000, 0.000);
|
|
volume.scale.set(38.901, 38.901, 75.334);
|
|
volume.clip = true;
|
|
viewer.scene.addVolume(volume);
|
|
|
|
viewer.scene.view.position.set(92.486, -121.920, 115.704);
|
|
viewer.scene.view.lookAt(-0.500, 0.500, -0.707);
|
|
});
|
|
|
|
</script>
|
|
|
|
<script>
|
|
|
|
let elFrustum = $("#filterFrustum");
|
|
|
|
elFrustum.css("position", "absolute");
|
|
elFrustum.css("left", "400px");
|
|
elFrustum.css("bottom", "50px");
|
|
elFrustum.css("z-index", 10000);
|
|
|
|
elFrustum.click( (e) => {
|
|
|
|
let camera = viewer.scene.getActiveCamera();
|
|
let frustum = new THREE.Frustum();
|
|
frustum.setFromMatrix( new THREE.Matrix4().multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ) );
|
|
let planeQueryParts = [];
|
|
for(let plane of frustum.planes){
|
|
let part = [plane.normal.toArray(), plane.constant].join(",");
|
|
part = `[${part}]`;
|
|
planeQueryParts.push(part);
|
|
}
|
|
let planeQueryArg = "[" + planeQueryParts.join(",") + "]";
|
|
let url = `http://localhost:3000/clip?planes=${planeQueryArg}`;
|
|
console.log(url);
|
|
|
|
fetch(url);
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<script>
|
|
|
|
let elBoxes = $("#filterBoxes");
|
|
|
|
elBoxes.css("position", "absolute");
|
|
elBoxes.css("left", "500px");
|
|
elBoxes.css("bottom", "50px");
|
|
elBoxes.css("z-index", 10000);
|
|
|
|
elBoxes.click( (e) => {
|
|
|
|
let boxes = viewer.scene.volumes
|
|
.filter(volume => (volume instanceof Potree.BoxVolume) && volume.clip);
|
|
|
|
let regions = [];
|
|
for(let clipBox of boxes){
|
|
|
|
let toClip = clipBox.matrixWorld;
|
|
|
|
let px = new THREE.Vector3(+0.5, 0, 0).applyMatrix4(toClip);
|
|
let nx = new THREE.Vector3(-0.5, 0, 0).applyMatrix4(toClip);
|
|
let py = new THREE.Vector3(0, +0.5, 0).applyMatrix4(toClip);
|
|
let ny = new THREE.Vector3(0, -0.5, 0).applyMatrix4(toClip);
|
|
let pz = new THREE.Vector3(0, 0, +0.5).applyMatrix4(toClip);
|
|
let nz = new THREE.Vector3(0, 0, -0.5).applyMatrix4(toClip);
|
|
|
|
let pxN = new THREE.Vector3().subVectors(nx, px).normalize();
|
|
let nxN = pxN.clone().multiplyScalar(-1);
|
|
let pyN = new THREE.Vector3().subVectors(ny, py).normalize();
|
|
let nyN = pyN.clone().multiplyScalar(-1);
|
|
let pzN = new THREE.Vector3().subVectors(nz, pz).normalize();
|
|
let nzN = pzN.clone().multiplyScalar(-1);
|
|
|
|
let planes = [
|
|
new THREE.Plane().setFromNormalAndCoplanarPoint(pxN, px),
|
|
new THREE.Plane().setFromNormalAndCoplanarPoint(nxN, nx),
|
|
new THREE.Plane().setFromNormalAndCoplanarPoint(pyN, py),
|
|
new THREE.Plane().setFromNormalAndCoplanarPoint(nyN, ny),
|
|
new THREE.Plane().setFromNormalAndCoplanarPoint(pzN, pz),
|
|
new THREE.Plane().setFromNormalAndCoplanarPoint(nzN, nz),
|
|
];
|
|
|
|
let planeQueryParts = [];
|
|
for(let plane of planes){
|
|
let part = [plane.normal.toArray(), plane.constant].join(",");
|
|
part = `[${part}]`;
|
|
planeQueryParts.push(part);
|
|
}
|
|
let region = "[" + planeQueryParts.join(",") + "]";
|
|
regions.push(region);
|
|
}
|
|
|
|
let regionsArg = regions.join(",");
|
|
|
|
let pointcloudArgs = [];
|
|
for(let pointcloud of viewer.scene.pointclouds){
|
|
if(!pointcloud.visible){
|
|
continue;
|
|
}
|
|
|
|
let offset = pointcloud.pcoGeometry.offset.clone();
|
|
let negateOffset = new THREE.Matrix4().makeTranslation(...offset.multiplyScalar(-1).toArray());
|
|
let matrixWorld = pointcloud.matrixWorld;
|
|
|
|
let transform = new THREE.Matrix4().multiplyMatrices(matrixWorld, negateOffset);
|
|
|
|
let arg = {
|
|
path: "/examples/filter_WIP_2.html/../../pointclouds/C/dev/pointclouds/converted/CA13_morro_area/cloud.js",
|
|
transform: transform.elements,
|
|
//transform: pointcloud.matrixWorld.elements
|
|
};
|
|
let argString = JSON.stringify(arg);
|
|
|
|
console.log(transform);
|
|
|
|
pointcloudArgs.push(argString);
|
|
}
|
|
let pointcloudsArg = pointcloudArgs.join(",");
|
|
|
|
let url = `http://localhost:3000/create_regions_filter?pointclouds=[${pointcloudsArg}]®ions=[${regionsArg}]`;
|
|
|
|
console.log(url);
|
|
|
|
fetch(url);
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<script>
|
|
|
|
let elProfiles = $("#filterProfiles");
|
|
|
|
elProfiles.css("position", "absolute");
|
|
elProfiles.css("left", "600px");
|
|
elProfiles.css("bottom", "50px");
|
|
elProfiles.css("z-index", 10000);
|
|
|
|
elProfiles.click( (e) => {
|
|
let profiles = viewer.scene.profiles;
|
|
|
|
let regions = [];
|
|
|
|
for(let profile of profiles){
|
|
|
|
let segments = profile.getSegments();
|
|
let width = profile.width;
|
|
|
|
for(let segment of segments){
|
|
let start = segment.start.clone().multiply(new THREE.Vector3(1, 1, 0));
|
|
let end = segment.end.clone().multiply(new THREE.Vector3(1, 1, 0));
|
|
let center = new THREE.Vector3().addVectors(start, end).multiplyScalar(0.5);
|
|
|
|
let startEndDir = new THREE.Vector3().subVectors(end, start).normalize();
|
|
let endStartDir = new THREE.Vector3().subVectors(start, end).normalize();
|
|
let upDir = new THREE.Vector3(0, 0, 1);
|
|
let rightDir = new THREE.Vector3().crossVectors(startEndDir, upDir);
|
|
let leftDir = new THREE.Vector3().crossVectors(endStartDir, upDir);
|
|
|
|
console.log(leftDir);
|
|
|
|
let right = rightDir.clone().multiplyScalar(width * 0.5).add(center);
|
|
let left = leftDir.clone().multiplyScalar(width * 0.5).add(center);
|
|
|
|
let region = [
|
|
new THREE.Plane().setFromNormalAndCoplanarPoint(startEndDir, start),
|
|
new THREE.Plane().setFromNormalAndCoplanarPoint(endStartDir, end),
|
|
new THREE.Plane().setFromNormalAndCoplanarPoint(leftDir, right),
|
|
new THREE.Plane().setFromNormalAndCoplanarPoint(rightDir, left),
|
|
];
|
|
|
|
regions.push(region);
|
|
}
|
|
}
|
|
|
|
console.log(regions);
|
|
|
|
let regionQueryParts = [];
|
|
for(let region of regions){
|
|
let planeQueryParts = [];
|
|
|
|
for(let plane of region){
|
|
let part = [plane.normal.toArray(), plane.constant].join(",");
|
|
part = `[${part}]`;
|
|
planeQueryParts.push(part);
|
|
}
|
|
|
|
let reqionQueryPart = "[" + planeQueryParts.join(",") + "]";
|
|
regionQueryParts.push(reqionQueryPart);
|
|
}
|
|
|
|
let regionsArg = regionQueryParts.join(",");
|
|
let url = `http://localhost:3000/clip?regions=[${regionsArg}]`;
|
|
|
|
console.log(url);
|
|
|
|
fetch(url);
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|