fix & improve annotations; + annotation perf test
This commit is contained in:
parent
d364ccfea8
commit
f43db5e543
146
examples/testing/annotations_performance.html
Normal file
146
examples/testing/annotations_performance.html
Normal file
@ -0,0 +1,146 @@
|
||||
<!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.min.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>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
viewer.setEDLEnabled(true);
|
||||
viewer.setFOV(60);
|
||||
viewer.setPointBudget(5 * 1000 * 1000);
|
||||
viewer.setPointBudget(10 * 1000);
|
||||
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("http://5.9.65.151/mschuetz/potree/resources/pointclouds/opentopography/CA13/cloud.js", "CA13", function(e){
|
||||
viewer.scene.addPointCloud(e.pointcloud);
|
||||
e.pointcloud.position.z = 0;
|
||||
let material = e.pointcloud.material;
|
||||
material.size = 1;
|
||||
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
|
||||
//viewer.useHQ = true;
|
||||
|
||||
viewer.scene.view.position.set(696157.527, 3893615.854, 20555.340);
|
||||
viewer.scene.view.lookAt(684138.227, 3925253.922, 1557.003);
|
||||
});
|
||||
|
||||
{ // ANNOTATIONS
|
||||
|
||||
//let n = 12;
|
||||
let depth = 3;
|
||||
let min = new THREE.Vector3(673062.820, 3915768.540, 10);
|
||||
let max = new THREE.Vector3(693697.110, 3938754.740, 10);
|
||||
|
||||
let map = new Map();
|
||||
|
||||
for(let level = 0; level < depth; level++){
|
||||
let n = 3 ** level;
|
||||
|
||||
for(let i = 0; i < n; i++){
|
||||
for(let j = 0; j < n; j++){
|
||||
|
||||
let u = i / (n) + 0.5 / n;
|
||||
let v = j / (n) + 0.5 / n;
|
||||
|
||||
let x = (1-u) * min.x + u * max.x;
|
||||
let y = (1-v) * min.y + v * max.y;
|
||||
let z = 10000 - level * 3000;
|
||||
|
||||
let annotation = new Potree.Annotation({
|
||||
title: `${i} / ${j}`,
|
||||
position: [x, y, z],
|
||||
radius: min.distanceTo(max) / n,
|
||||
});
|
||||
//viewer.scene.annotations.add(annotation);
|
||||
|
||||
let id = `${level}_${i}_${j}`;
|
||||
map.set(id, annotation);
|
||||
|
||||
if(level === 0){
|
||||
viewer.scene.annotations.add(annotation);
|
||||
}else{
|
||||
let parentI = parseInt(i / 3);
|
||||
let parentJ = parseInt(j / 3);
|
||||
let parentID = `${level-1}_${parentI}_${parentJ}`;
|
||||
let parent = map.get(parentID);
|
||||
|
||||
parent.add(annotation);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//for(let i = 0; i < n; i++){
|
||||
// for(let j = 0; j < n; j++){
|
||||
// let u = i / (n-1);
|
||||
// let v = j / (n-1);
|
||||
|
||||
// let x = (1-u) * min.x + u * max.x;
|
||||
// let y = (1-v) * min.y + v * max.y;
|
||||
// let z = 10;
|
||||
|
||||
// let annotation = new Potree.Annotation({
|
||||
// title: `${i} / ${j}`,
|
||||
// position: [x, y, z],
|
||||
// radius: 1000,
|
||||
// });
|
||||
// viewer.scene.annotations.add(annotation);
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -111,6 +111,8 @@ Potree.Annotation = class extends THREE.EventDispatcher {
|
||||
});
|
||||
|
||||
this.display = false;
|
||||
//this.display = true;
|
||||
|
||||
}
|
||||
|
||||
get visible () {
|
||||
@ -124,9 +126,9 @@ Potree.Annotation = class extends THREE.EventDispatcher {
|
||||
|
||||
this._visible = value;
|
||||
|
||||
this.traverse(node => {
|
||||
node.display = value;
|
||||
});
|
||||
//this.traverse(node => {
|
||||
// node.display = value;
|
||||
//});
|
||||
|
||||
this.dispatchEvent({
|
||||
type: 'visibility_changed',
|
||||
|
||||
@ -183,6 +183,7 @@ a:hover, a:visited, a:link, a:active{
|
||||
padding: 10px;
|
||||
opacity: 0.5;
|
||||
transform: translate(-50%, -30px);
|
||||
will-change: left, top;
|
||||
}
|
||||
|
||||
.annotation-titlebar{
|
||||
|
||||
@ -33,6 +33,13 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
let potreeDescription = $(`<div id="potree_description" class="potree_info_text"></div>`);
|
||||
$(domElement).append(potreeDescription);
|
||||
}
|
||||
|
||||
if ($(domElement).find('#potree_annotations').length === 0) {
|
||||
let potreeAnnotationContainer = $(`
|
||||
<div id="potree_annotation_container"
|
||||
style="position: absolute; z-index: 100000; width: 100%; height: 100%; pointer-events: none;"></div>`);
|
||||
$(domElement).append(potreeAnnotationContainer);
|
||||
}
|
||||
}
|
||||
|
||||
this.pointCloudLoadedCallback = args.onPointCloudLoaded || function () {};
|
||||
@ -277,7 +284,9 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
// console.log("annotation added: " + e.annotation.title);
|
||||
|
||||
e.annotation.traverse(node => {
|
||||
this.renderArea.appendChild(node.domElement[0]);
|
||||
|
||||
$("#potree_annotation_container").append(node.domElement);
|
||||
//this.renderArea.appendChild(node.domElement[0]);
|
||||
node.scene = this.scene;
|
||||
});
|
||||
};
|
||||
@ -969,12 +978,9 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
}
|
||||
|
||||
updateAnnotations () {
|
||||
if (!this.getShowAnnotations()) {
|
||||
this.scene.annotations.traverseDescendants(descendant => {
|
||||
descendant.display = false;
|
||||
});
|
||||
|
||||
return;
|
||||
if(!this.visibleAnnotations){
|
||||
this.visibleAnnotations = new Set();
|
||||
}
|
||||
|
||||
this.scene.annotations.updateBounds();
|
||||
@ -987,9 +993,11 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
let renderAreaHeight = this.renderer.getSize().height;
|
||||
|
||||
let viewer = this;
|
||||
|
||||
let visibleNow = [];
|
||||
this.scene.annotations.traverse(annotation => {
|
||||
|
||||
if (annotation === this.scene.annotations) {
|
||||
annotation.display = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1007,13 +1015,11 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
}
|
||||
|
||||
let distance = viewer.scene.cameraP.position.distanceTo(position);
|
||||
|
||||
let radius = annotation.boundingBox.getBoundingSphere().radius;
|
||||
|
||||
let screenPos = new THREE.Vector3();
|
||||
let screenSize = 0;
|
||||
|
||||
/* eslint-disable no-lone-blocks */
|
||||
{
|
||||
// SCREEN POS
|
||||
screenPos.copy(position).project(this.scene.getActiveCamera());
|
||||
@ -1029,30 +1035,54 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
screenSize = radius * projFactor;
|
||||
} else {
|
||||
screenSize = Potree.utils.projectedRadiusOrtho(radius, viewer.scene.cameraO.projectionMatrix, renderAreaWidth, renderAreaHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
element[0].style.left = screenPos.x + "px";
|
||||
element[0].style.top = screenPos.y + "px";
|
||||
|
||||
element.css("left", screenPos.x + "px");
|
||||
element.css("top", screenPos.y + "px");
|
||||
//element.css("display", "block");
|
||||
|
||||
let zIndex = 10000000 - distance * (10000000 / this.scene.cameraP.far);
|
||||
if(annotation.descriptionVisible){
|
||||
zIndex += 10000000;
|
||||
}
|
||||
element.css("z-index", parseInt(zIndex));
|
||||
|
||||
if(annotation.children.length > 0){
|
||||
let expand = screenSize > annotation.collapseThreshold || annotation.boundingBox.containsPoint(this.scene.getActiveCamera().position);
|
||||
annotation.expand = expand;
|
||||
|
||||
if (!expand) {
|
||||
annotation.display = (screenPos.z >= -1 && screenPos.z <= 1);
|
||||
//annotation.display = (screenPos.z >= -1 && screenPos.z <= 1);
|
||||
let inFrustum = (screenPos.z >= -1 && screenPos.z <= 1);
|
||||
if(inFrustum){
|
||||
visibleNow.push(annotation);
|
||||
}
|
||||
}
|
||||
|
||||
return expand;
|
||||
} else {
|
||||
annotation.display = (screenPos.z >= -1 && screenPos.z <= 1);
|
||||
//annotation.display = (screenPos.z >= -1 && screenPos.z <= 1);
|
||||
let inFrustum = (screenPos.z >= -1 && screenPos.z <= 1);
|
||||
if(inFrustum){
|
||||
visibleNow.push(annotation);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
let notVisibleAnymore = new Set(this.visibleAnnotations);
|
||||
for(let annotation of visibleNow){
|
||||
annotation.display = true;
|
||||
|
||||
notVisibleAnymore.delete(annotation);
|
||||
}
|
||||
this.visibleAnnotations = visibleNow;
|
||||
|
||||
for(let annotation of notVisibleAnymore){
|
||||
annotation.display = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
update(delta, timestamp){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user