made volume label scale independant; displaying area label
This commit is contained in:
parent
ae6642ea97
commit
7a8a661f74
@ -91,8 +91,8 @@
|
||||
var progressBar = new ProgressBar();
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa/cloud.js";
|
||||
//var pointcloudPath = "../../../../pointclouds/bruno_friedmann/vol_total/vol_total_bin/cloud.js";
|
||||
var pointcloudPath = "../../../../pointclouds/pix4d/matterhorn/cloud.js";
|
||||
var pointcloudPath = "../../../../pointclouds/bruno_friedmann/vol_total/vol_total_bin/cloud.js";
|
||||
//var pointcloudPath = "../../../../pointclouds/pix4d/matterhorn/cloud.js";
|
||||
|
||||
var elRenderArea = document.getElementById("renderArea");
|
||||
|
||||
|
||||
@ -1,4 +1,11 @@
|
||||
|
||||
//
|
||||
// calculating area of a polygon:
|
||||
// http://www.mathopenref.com/coordpolygonarea2.html
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
Potree.AreaTool = function(scene, camera, renderer){
|
||||
|
||||
var scope = this;
|
||||
@ -77,6 +84,13 @@ Potree.AreaTool = function(scene, camera, renderer){
|
||||
this.root = root;
|
||||
this.closed = true;
|
||||
|
||||
this.areaLabel = new Potree.TextSprite();
|
||||
this.areaLabel.setBorderColor({r:0, g:255, b:0, a:0.0});
|
||||
this.areaLabel.setBackgroundColor({r:0, g:255, b:0, a:0.0});
|
||||
this.areaLabel.material.depthTest = false;
|
||||
this.areaLabel.material.opacity = 1;
|
||||
root.add(this.areaLabel);
|
||||
|
||||
var sphereGeometry = new THREE.SphereGeometry(0.4, 10, 10);
|
||||
var lineColor = new THREE.Color( 0xff0000 );
|
||||
|
||||
@ -145,6 +159,23 @@ Potree.AreaTool = function(scene, camera, renderer){
|
||||
this.update();
|
||||
};
|
||||
|
||||
/**
|
||||
* see http://www.mathopenref.com/coordpolygonarea2.html
|
||||
*/
|
||||
this.getArea = function(){
|
||||
var area = 0;
|
||||
var j = this.points.length - 1;
|
||||
|
||||
for(var i = 0; i < this.points.length; i++){
|
||||
var p1 = this.points[i];
|
||||
var p2 = this.points[j];
|
||||
area += (p2.x + p1.x) * (p1.z - p2.z);
|
||||
j = i;
|
||||
}
|
||||
|
||||
return Math.abs(area / 2);
|
||||
};
|
||||
|
||||
this.setPosition = function(index, position){
|
||||
var point = this.points[index];
|
||||
point.copy(position);
|
||||
@ -159,6 +190,8 @@ Potree.AreaTool = function(scene, camera, renderer){
|
||||
};
|
||||
|
||||
this.update = function(){
|
||||
this.areaLabel.visible = this.points.length >= 3;
|
||||
|
||||
if(this.points.length === 1){
|
||||
var point = this.points[0];
|
||||
this.spheres[0].position.copy(point);
|
||||
@ -167,7 +200,9 @@ Potree.AreaTool = function(scene, camera, renderer){
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
var centroid = new THREE.Vector3();
|
||||
var lastIndex = this.points.length - 1;
|
||||
for(var i = 0; i <= lastIndex; i++){
|
||||
var point = this.points[i];
|
||||
@ -207,8 +242,14 @@ Potree.AreaTool = function(scene, camera, renderer){
|
||||
rightEdgeLabel.visible = true;
|
||||
}
|
||||
|
||||
|
||||
centroid.add(point);
|
||||
}
|
||||
centroid.multiplyScalar(1 / this.points.length);
|
||||
|
||||
|
||||
var msg = Potree.utils.addCommas(this.getArea().toFixed(1)) + "²";
|
||||
this.areaLabel.setText(msg);
|
||||
this.areaLabel.position.copy(centroid);
|
||||
};
|
||||
|
||||
|
||||
@ -441,6 +482,11 @@ Potree.AreaTool = function(scene, camera, renderer){
|
||||
var l = label.scale.length();
|
||||
label.scale.multiplyScalar(w / l);
|
||||
}
|
||||
|
||||
var wp = measurement.areaLabel.getWorldPosition().applyMatrix4(this.camera.matrixWorldInverse);
|
||||
var w = Math.abs(wp.z / 8);
|
||||
var l = measurement.areaLabel.scale.length();
|
||||
measurement.areaLabel.scale.multiplyScalar(w / l);
|
||||
}
|
||||
|
||||
this.light.position.copy(this.camera.position);
|
||||
|
||||
@ -140,7 +140,7 @@ Potree.TransformationTool = function(scene, camera, renderer){
|
||||
}
|
||||
|
||||
|
||||
console.log(mouseDiff);
|
||||
//console.log(mouseDiff);
|
||||
};
|
||||
|
||||
var dropEvent = function(event){
|
||||
@ -332,7 +332,7 @@ Potree.TransformationTool = function(scene, camera, renderer){
|
||||
for(var i = 0; i < scope.targets.length; i++){
|
||||
var target = scope.targets[i];
|
||||
var startScale = scope.dragstart.scales[i];
|
||||
target.scale.copy(startScale).multiply(diff);
|
||||
target.scale.copy(startScale).add(diff);
|
||||
target.scale.x = Math.max(target.scale.x, 0.01);
|
||||
target.scale.y = Math.max(target.scale.y, 0.01);
|
||||
target.scale.z = Math.max(target.scale.z, 0.01);
|
||||
|
||||
@ -152,28 +152,28 @@ Potree.VolumeTool = function(scene, camera, renderer){
|
||||
}
|
||||
}
|
||||
|
||||
var volumes = [];
|
||||
for(var i = 0; i < this.volumes.length; i++){
|
||||
volumes.push(this.volumes[i]);
|
||||
}
|
||||
if(this.activeVolume){
|
||||
volumes.push(this.activeVolume);
|
||||
}
|
||||
var volumes = [];
|
||||
for(var i = 0; i < this.volumes.length; i++){
|
||||
volumes.push(this.volumes[i]);
|
||||
}
|
||||
if(this.activeVolume){
|
||||
volumes.push(this.activeVolume);
|
||||
}
|
||||
|
||||
for(var i = 0; i < volumes.length; i++){
|
||||
var box = volumes[i].object;
|
||||
var label = volumes[i].label;
|
||||
|
||||
for(var i = 0; i < volumes.length; i++){
|
||||
var box = volumes[i].object;
|
||||
var label = volumes[i].label;
|
||||
|
||||
var volume = box.scale.x * box.scale.y * box.scale.z;
|
||||
var msg = volume.toFixed(1) + "³";
|
||||
|
||||
var wp = label.getWorldPosition().applyMatrix4(this.camera.matrixWorldInverse);
|
||||
var pp = new THREE.Vector4(wp.x, wp.y, wp.z).applyMatrix4(this.camera.projectionMatrix);
|
||||
var w = Math.abs((wp.z / 10));
|
||||
var l = label.scale.length();
|
||||
label.scale.multiplyScalar(w / l);
|
||||
label.setText(msg);
|
||||
}
|
||||
var volume = box.scale.x * box.scale.y * box.scale.z;
|
||||
var msg = Potree.utils.addCommas(volume.toFixed(1)) + "³";
|
||||
|
||||
var wp = label.getWorldPosition().applyMatrix4(this.camera.matrixWorldInverse);
|
||||
var pp = new THREE.Vector4(wp.x, wp.y, wp.z).applyMatrix4(this.camera.projectionMatrix);
|
||||
var w = Math.abs(wp.z / 5);
|
||||
label.setText(msg);
|
||||
var l = label.scale.length();
|
||||
label.scale.multiplyScalar(w / l);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user