polishing and fixing

This commit is contained in:
mschuetz 2017-02-11 14:44:15 +01:00
parent dac3bf1833
commit 7992f12f54
16 changed files with 394 additions and 132 deletions

View File

@ -2269,7 +2269,8 @@ Potree.GreyhoundBinaryLoader.prototype.parse = function(node, buffer){
//console.log(fb);
break;
case pointAttributes.COLOR_PACKED:
addAttribute('color', buffer, 3);
geometry.addAttribute("color",
new THREE.BufferAttribute(new Uint8Array(buffer), 3, true));
break;
case pointAttributes.INTENSITY:
addAttribute('intensity', buffer, 1);
@ -6008,8 +6009,10 @@ Potree.Annotation = function(scene, args = {}){
this.view = args.view || null;
this.keepOpen = false;
this.descriptionVisible = false;
this.showDescription = true;
this.actions = args.actions || [];
this.appearance = args.appearance || null;
this.isHighlighted = false;
this.domElement = document.createElement("div");
this.domElement.style.position = "absolute";
@ -6101,19 +6104,52 @@ Potree.Annotation = function(scene, args = {}){
}
}
this.elDescriptionText = document.createElement("span");
this.elDescriptionText.style.color = "#ffffff";
this.elDescriptionText.innerHTML = this.description;
this.domDescription.appendChild(this.elDescriptionText);
{
let icon = Potree.resourcePath + "/icons/close.svg";
let close = $(`<span><img src="${icon}" width="16px"></span>`);
close.css("filter", "invert(100%)");
close.css("float", "right");
close.css("opacity", "0.5");
close.css("margin", "0px 0px 8px 8px");
close.hover(e => {
close.css("opacity", "1");
},e => {
close.css("opacity", "0.5");
});
close.click(e => {
this.setHighlighted(false);
});
$(this.domDescription).append(close);
this.elDescriptionText = document.createElement("span");
this.elDescriptionText.style.color = "#ffffff";
this.elDescriptionText.innerHTML = this.description;
this.domDescription.appendChild(this.elDescriptionText);
}
this.domElement.onmouseenter = () => {
this.setHighlighted(true);
};
$(this.domElement).on("touchstart", e => {
this.setHighlighted(!this.isHighlighted);
});
this.domElement.onmouseleave = () => {
this.setHighlighted(false);
};
//$(this.domElement).click(e => {
// this.showDescription = !this.showDescription;
//
// if(this.showDescription){
// $(this.domElement).append($(this.domDescription));
// }else{
// $(this.domDescription).remove();
// }
//});
this.setHighlighted = function(highlighted){
if(highlighted){
this.domElement.style.opacity = "0.8";
@ -6130,9 +6166,11 @@ Potree.Annotation = function(scene, args = {}){
this.domElement.style.opacity = "0.5";
this.elOrdinal.style.boxShadow = "";
this.domElement.style.zIndex = "100";
this.descriptionVisible = true;
this.descriptionVisible = false;
this.domDescription.style.display = "none";
}
this.isHighlighted = highlighted;
};
this.hasView = function(){
@ -6351,6 +6389,7 @@ Potree.ProfileRequest = function(pointcloud, profile, maxDepth, callback){
this.traverse(node);
}
}else{
console.log("loading " + node.name);
node.load();
this.priorityQueue.push(element);
}
@ -8539,7 +8578,7 @@ Potree.Features = function(){
var supported = true;
//supported = supported && gl.getExtension("EXT_frag_depth");
supported = supported && gl.getExtension("EXT_frag_depth");
supported = supported && gl.getExtension("OES_texture_float");
supported = supported && gl.getParameter(gl.MAX_VARYING_VECTORS) >= 8;
@ -13475,17 +13514,13 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
return box;
};
fitToScreen(){
fitToScreen(factor = 1){
var box = this.getBoundingBox(this.scene.pointclouds);
//if(this.transformationTool && this.transformationTool.selection.length > 0){
// box = this.transformationTool.getBoundingBox();
//}
var node = new THREE.Object3D();
node.boundingBox = box;
this.zoomTo(node, 1);
this.zoomTo(node, factor);
};
setTopView(){
@ -13909,6 +13944,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
visiblePoints = result.numVisiblePoints;
camera.near = result.lowestSpacing * 10.0;
camera.far = -this.getBoundingBox().applyMatrix4(camera.matrixWorldInverse).min.z;
camera.far = Math.max(camera.far * 1.5, 1000);
}
@ -14843,6 +14879,8 @@ Potree.Viewer.Profile = class ProfileWindow{
this.maximized = false;
this.threshold = 20*1000;
this.scheduledDraw = null;
$('#closeProfileContainer').click(() => {
this.hide();
this.enabled = false;
@ -14858,21 +14896,17 @@ Potree.Viewer.Profile = class ProfileWindow{
}
});
this.drawOnChange = (event) => {
this.redraw();
//this.drawOnChange = (event) => {
// this.redraw();
//};
this.redraw = () => {
if(this.currentProfile){
this.draw(this.currentProfile);
}
};
//viewer.scene.addEventListener("marker_moved"))
//viewer.profileTool.addEventListener("marker_moved", drawOnChange);
//viewer.profileTool.addEventListener("width_changed", drawOnChange);
//viewer.addEventListener("material_changed", function(){
// drawOnChange({profile: this.currentProfile});
//});
//
//viewer.addEventListener("height_range_changed", function(){
// drawOnChange({profile: this.currentProfile});
//});
viewer.addEventListener("height_range_changed", this.redraw);
let width = document.getElementById('profile_window').clientWidth;
let height = document.getElementById('profile_window').clientHeight;
@ -14883,7 +14917,7 @@ Potree.Viewer.Profile = class ProfileWindow{
let newHeight = document.getElementById('profile_window').clientHeight;
if(newWidth !== width || newHeight !== height){
setTimeout(this.drawOnChange, 50, {profile: this.currentProfile});
setTimeout(this.redraw, 50, {profile: this.currentProfile});
}
width = newWidth;
@ -15078,11 +15112,14 @@ Potree.Viewer.Profile = class ProfileWindow{
strokeColor(d){
let material = this.viewer.getMaterial();
if (material === Potree.PointColorType.RGB) {
//return d.color;
return 'rgb(' + (d.color[0] * 100 / 255) + '%,' + (d.color[1] * 100 / 255) + '%,' + (d.color[2] * 100 / 255) + '%)';
let [r, g, b] = d.color.map(e => parseInt(e));
return `rgb( ${r}, ${g}, ${b})`;
} else if (material === Potree.PointColorType.INTENSITY) {
//return d.intensity;
return 'rgb(' + d.intensity + '%,' + d.intensity + '%,' + d.intensity + '%)';
let irange = viewer.getIntensityRange();
let i = parseInt(255 * (d.intensity - irange[0]) / (irange[1] - irange[0]));
return `rgb(${i}, ${i}, ${i})`;
} else if (material === Potree.PointColorType.CLASSIFICATION) {
let classif = this.viewer.scene.pointclouds[0].material.classification;
if (typeof classif[d.classification] != 'undefined'){
@ -15114,14 +15151,8 @@ Potree.Viewer.Profile = class ProfileWindow{
return d.color;
}
}
redraw(){
this.draw(this.currentProfile);
}
draw(profile){
// TODO are the used closures safe for garbage collection?
if(!this.enabled){
return;
}
@ -15133,6 +15164,22 @@ Potree.Viewer.Profile = class ProfileWindow{
if(this.viewer.scene.pointclouds.length === 0){
return;
}
// avoid too many expensive draws/redraws
// 2d profile draws don't need frame-by-frame granularity, it's
// fine to handle a redraw once every 100ms
let executeScheduledDraw = () => {
this.actuallyDraw(this.scheduledDraw);
this.scheduledDraw = null;
};
if(!this.scheduledDraw){
setTimeout(executeScheduledDraw, 100);
}
this.scheduledDraw = profile;
}
actuallyDraw(profile){
if(this.context){
let containerWidth = this.element.clientWidth;
@ -15144,36 +15191,26 @@ Potree.Viewer.Profile = class ProfileWindow{
}
if(this.currentProfile){
this.currentProfile.removeEventListener("marker_moved", this.drawOnChange);
this.currentProfile.removeEventListener("marker_added", this.drawOnChange);
this.currentProfile.removeEventListener("marker_removed", this.drawOnChange);
this.currentProfile.removeEventListener("width_changed", this.drawOnChange);
viewer.removeEventListener("material_changed", this.drawOnChange);
//viewer.addEventListener("material_changed", function(){
// drawOnChange({profile: this.currentProfile});
//});
//viewer.profileTool.addEventListener("marker_moved", drawOnChange);
//viewer.profileTool.addEventListener("width_changed", drawOnChange);
//viewer.addEventListener("material_changed", function(){
// drawOnChange({profile: this.currentProfile});
//});
//
//viewer.addEventListener("height_range_changed", function(){
// drawOnChange({profile: this.currentProfile});
//});
this.currentProfile.removeEventListener("marker_moved", this.redraw);
this.currentProfile.removeEventListener("marker_added", this.redraw);
this.currentProfile.removeEventListener("marker_removed", this.redraw);
this.currentProfile.removeEventListener("width_changed", this.redraw);
viewer.removeEventListener("material_changed", this.redraw);
viewer.removeEventListener("height_range_changed", this.redraw);
viewer.removeEventListener("intensity_range_changed", this.redraw);
}
this.currentProfile = profile;
{
this.currentProfile.addEventListener("marker_moved", this.drawOnChange);
this.currentProfile.addEventListener("marker_added", this.drawOnChange);
this.currentProfile.addEventListener("marker_removed", this.drawOnChange);
this.currentProfile.addEventListener("width_changed", this.drawOnChange);
viewer.addEventListener("material_changed", this.drawOnChange);
this.currentProfile.addEventListener("marker_moved", this.redraw);
this.currentProfile.addEventListener("marker_added", this.redraw);
this.currentProfile.addEventListener("marker_removed", this.redraw);
this.currentProfile.addEventListener("width_changed", this.redraw);
viewer.addEventListener("material_changed", this.redraw);
viewer.addEventListener("height_range_changed", this.redraw);
viewer.addEventListener("intensity_range_changed", this.redraw);
}
if(!this.__drawData){

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32px"
height="32px"
id="svg3797"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="close.svg">
<defs
id="defs3799" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.395604"
inkscape:cx="9.4629706"
inkscape:cy="16.706715"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:window-width="1920"
inkscape:window-height="1018"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid3805" />
</sodipodi:namedview>
<metadata
id="metadata3802">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
style="fill:none;stroke:#000000;stroke-width:8;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="M 7,25 25,7"
id="path2986"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:8;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="M 7,7 25,25"
id="path2988"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -171,10 +171,10 @@ onmessage = function(event){
}else if(pointAttribute.name === Potree.PointAttribute.COLOR_PACKED.name){
var buff = new ArrayBuffer(numPoints*4*3);
var colors = new Float32Array(buff);
var buff = new ArrayBuffer(numPoints*3);
var colors = new Uint8Array(buff);
var div = event.data.normalize.color ? 65535 : 255;
var div = event.data.normalize.color ? 255 : 1;
for(var j = 0; j < numPoints; ++j){
colors[3*j+0] = cv.getUint16(offset + j*pointSize + 0) / div;

View File

@ -103,7 +103,33 @@
st-helens
vanuatu-village
*/
var resource = "red-rocks";
var resource = "autzen";
//
// Some recommended configurations:
//
//var resource = "iowa-bridge";
//viewer.setMaterial("Intensity");
//viewer.setIntensityRange(0, 65536);
//viewer.setIntensityBrightness(0.2);
//var resource = "iowa-city";
//viewer.setMaterial("Intensity");
//var resource = "lake-isabella";
//viewer.setMaterial("Intensity");
//viewer.setIntensityGamma(0.5);
//var resource = "space-shuttle";
//viewer.setMaterial("Intensity");
//viewer.setIntensityRange(0, 4500);
//viewer.setIntensityGamma(1.5);
if (getQueryParam("server")) {
server = getQueryParam("server");
@ -114,8 +140,7 @@
Potree.loadPointCloud(server + resource + "/", "autzen", (e) => {
viewer.scene.addPointCloud(e.pointcloud);
viewer.fitToScreen();
viewer.scene.camera.near = 10;
viewer.fitToScreen(0.5);
});
}

15
examples/index.html Normal file
View File

@ -0,0 +1,15 @@
<a href="./annotations.html" >annotations.html </a><br>
<a href="./arena4d.html" >arena4d.html" </a><br>
<a href="./clipping_volume.html" >clipping_volume.html </a><br>
<a href="./elevation_profile.html" >elevation_profile.html </a><br>
<a href="./entwine_greyhound.html" >entwine_greyhound.html </a><br>
<a href="./lasmap.html" >lasmap.html </a><br>
<a href="./lines.html" >lines.html </a><br>
<a href="./lion.html" >lion.html </a><br>
<a href="./lion_las.html" >lion_las.html </a><br>
<a href="./lion_laz.html" >lion_laz.html </a><br>
<a href="./measurements.html" >measurements.html </a><br>
<a href="./meshes.html" >meshes.html </a><br>
<a href="./multiple_pointclouds.html">multiple_pointclouds.html</a><br>
<a href="./viewer.html" >viewer.html </a><br>

View File

@ -69,7 +69,7 @@
viewer.setWeightClassification(1);
viewer.loadSettingsFromURL();
viewer.setDescription("Point cloud courtesy of <a target='_blank' href='https://www.sigeom.ch/'>sigeom sa</a>");
viewer.setDescription("");
viewer.loadGUI(() => {
viewer.setLanguage('en');

View File

@ -81,6 +81,10 @@
Potree.loadPointCloud("../pointclouds/lion_takanawa_las/cloud.js", "lion", function(e){
viewer.scene.addPointCloud(e.pointcloud);
e.pointcloud.position.x += 3;
e.pointcloud.position.y -= 3;
e.pointcloud.position.z += 4;
viewer.fitToScreen();
});

View File

@ -80,6 +80,10 @@
Potree.loadPointCloud("../pointclouds/lion_takanawa_laz/cloud.js", "lion", function(e){
viewer.scene.addPointCloud(e.pointcloud);
e.pointcloud.position.x += 3;
e.pointcloud.position.y -= 3;
e.pointcloud.position.z += 4;
viewer.fitToScreen();
});

70
resources/icons/close.svg Normal file
View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32px"
height="32px"
id="svg3797"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="close.svg">
<defs
id="defs3799" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.395604"
inkscape:cx="9.4629706"
inkscape:cy="16.706715"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:window-width="1920"
inkscape:window-height="1018"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid3805" />
</sodipodi:namedview>
<metadata
id="metadata3802">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
style="fill:none;stroke:#000000;stroke-width:8;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="M 7,25 25,7"
id="path2986"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:8;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="M 7,7 25,25"
id="path2988"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -13,8 +13,10 @@ Potree.Annotation = function(scene, args = {}){
this.view = args.view || null;
this.keepOpen = false;
this.descriptionVisible = false;
this.showDescription = true;
this.actions = args.actions || [];
this.appearance = args.appearance || null;
this.isHighlighted = false;
this.domElement = document.createElement("div");
this.domElement.style.position = "absolute";
@ -106,19 +108,52 @@ Potree.Annotation = function(scene, args = {}){
}
}
this.elDescriptionText = document.createElement("span");
this.elDescriptionText.style.color = "#ffffff";
this.elDescriptionText.innerHTML = this.description;
this.domDescription.appendChild(this.elDescriptionText);
{
let icon = Potree.resourcePath + "/icons/close.svg";
let close = $(`<span><img src="${icon}" width="16px"></span>`);
close.css("filter", "invert(100%)");
close.css("float", "right");
close.css("opacity", "0.5");
close.css("margin", "0px 0px 8px 8px");
close.hover(e => {
close.css("opacity", "1");
},e => {
close.css("opacity", "0.5");
});
close.click(e => {
this.setHighlighted(false);
});
$(this.domDescription).append(close);
this.elDescriptionText = document.createElement("span");
this.elDescriptionText.style.color = "#ffffff";
this.elDescriptionText.innerHTML = this.description;
this.domDescription.appendChild(this.elDescriptionText);
}
this.domElement.onmouseenter = () => {
this.setHighlighted(true);
};
$(this.domElement).on("touchstart", e => {
this.setHighlighted(!this.isHighlighted);
});
this.domElement.onmouseleave = () => {
this.setHighlighted(false);
};
//$(this.domElement).click(e => {
// this.showDescription = !this.showDescription;
//
// if(this.showDescription){
// $(this.domElement).append($(this.domDescription));
// }else{
// $(this.domDescription).remove();
// }
//});
this.setHighlighted = function(highlighted){
if(highlighted){
this.domElement.style.opacity = "0.8";
@ -135,9 +170,11 @@ Potree.Annotation = function(scene, args = {}){
this.domElement.style.opacity = "0.5";
this.elOrdinal.style.boxShadow = "";
this.domElement.style.zIndex = "100";
this.descriptionVisible = true;
this.descriptionVisible = false;
this.domDescription.style.display = "none";
}
this.isHighlighted = highlighted;
};
this.hasView = function(){

View File

@ -59,7 +59,7 @@ Potree.Features = function(){
var supported = true;
//supported = supported && gl.getExtension("EXT_frag_depth");
supported = supported && gl.getExtension("EXT_frag_depth");
supported = supported && gl.getExtension("OES_texture_float");
supported = supported && gl.getParameter(gl.MAX_VARYING_VECTORS) >= 8;

View File

@ -154,6 +154,7 @@ Potree.ProfileRequest = function(pointcloud, profile, maxDepth, callback){
this.traverse(node);
}
}else{
console.log("loading " + node.name);
node.load();
this.priorityQueue.push(element);
}

View File

@ -96,7 +96,8 @@ Potree.GreyhoundBinaryLoader.prototype.parse = function(node, buffer){
//console.log(fb);
break;
case pointAttributes.COLOR_PACKED:
addAttribute('color', buffer, 3);
geometry.addAttribute("color",
new THREE.BufferAttribute(new Uint8Array(buffer), 3, true));
break;
case pointAttributes.INTENSITY:
addAttribute('intensity', buffer, 1);

View File

@ -12,6 +12,8 @@ Potree.Viewer.Profile = class ProfileWindow{
this.maximized = false;
this.threshold = 20*1000;
this.scheduledDraw = null;
$('#closeProfileContainer').click(() => {
this.hide();
this.enabled = false;
@ -27,21 +29,17 @@ Potree.Viewer.Profile = class ProfileWindow{
}
});
this.drawOnChange = (event) => {
this.redraw();
//this.drawOnChange = (event) => {
// this.redraw();
//};
this.redraw = () => {
if(this.currentProfile){
this.draw(this.currentProfile);
}
};
//viewer.scene.addEventListener("marker_moved"))
//viewer.profileTool.addEventListener("marker_moved", drawOnChange);
//viewer.profileTool.addEventListener("width_changed", drawOnChange);
//viewer.addEventListener("material_changed", function(){
// drawOnChange({profile: this.currentProfile});
//});
//
//viewer.addEventListener("height_range_changed", function(){
// drawOnChange({profile: this.currentProfile});
//});
viewer.addEventListener("height_range_changed", this.redraw);
let width = document.getElementById('profile_window').clientWidth;
let height = document.getElementById('profile_window').clientHeight;
@ -52,7 +50,7 @@ Potree.Viewer.Profile = class ProfileWindow{
let newHeight = document.getElementById('profile_window').clientHeight;
if(newWidth !== width || newHeight !== height){
setTimeout(this.drawOnChange, 50, {profile: this.currentProfile});
setTimeout(this.redraw, 50, {profile: this.currentProfile});
}
width = newWidth;
@ -247,11 +245,14 @@ Potree.Viewer.Profile = class ProfileWindow{
strokeColor(d){
let material = this.viewer.getMaterial();
if (material === Potree.PointColorType.RGB) {
//return d.color;
return 'rgb(' + (d.color[0] * 100 / 255) + '%,' + (d.color[1] * 100 / 255) + '%,' + (d.color[2] * 100 / 255) + '%)';
let [r, g, b] = d.color.map(e => parseInt(e));
return `rgb( ${r}, ${g}, ${b})`;
} else if (material === Potree.PointColorType.INTENSITY) {
//return d.intensity;
return 'rgb(' + d.intensity + '%,' + d.intensity + '%,' + d.intensity + '%)';
let irange = viewer.getIntensityRange();
let i = parseInt(255 * (d.intensity - irange[0]) / (irange[1] - irange[0]));
return `rgb(${i}, ${i}, ${i})`;
} else if (material === Potree.PointColorType.CLASSIFICATION) {
let classif = this.viewer.scene.pointclouds[0].material.classification;
if (typeof classif[d.classification] != 'undefined'){
@ -283,14 +284,8 @@ Potree.Viewer.Profile = class ProfileWindow{
return d.color;
}
}
redraw(){
this.draw(this.currentProfile);
}
draw(profile){
// TODO are the used closures safe for garbage collection?
if(!this.enabled){
return;
}
@ -302,6 +297,22 @@ Potree.Viewer.Profile = class ProfileWindow{
if(this.viewer.scene.pointclouds.length === 0){
return;
}
// avoid too many expensive draws/redraws
// 2d profile draws don't need frame-by-frame granularity, it's
// fine to handle a redraw once every 100ms
let executeScheduledDraw = () => {
this.actuallyDraw(this.scheduledDraw);
this.scheduledDraw = null;
};
if(!this.scheduledDraw){
setTimeout(executeScheduledDraw, 100);
}
this.scheduledDraw = profile;
}
actuallyDraw(profile){
if(this.context){
let containerWidth = this.element.clientWidth;
@ -313,36 +324,26 @@ Potree.Viewer.Profile = class ProfileWindow{
}
if(this.currentProfile){
this.currentProfile.removeEventListener("marker_moved", this.drawOnChange);
this.currentProfile.removeEventListener("marker_added", this.drawOnChange);
this.currentProfile.removeEventListener("marker_removed", this.drawOnChange);
this.currentProfile.removeEventListener("width_changed", this.drawOnChange);
viewer.removeEventListener("material_changed", this.drawOnChange);
//viewer.addEventListener("material_changed", function(){
// drawOnChange({profile: this.currentProfile});
//});
//viewer.profileTool.addEventListener("marker_moved", drawOnChange);
//viewer.profileTool.addEventListener("width_changed", drawOnChange);
//viewer.addEventListener("material_changed", function(){
// drawOnChange({profile: this.currentProfile});
//});
//
//viewer.addEventListener("height_range_changed", function(){
// drawOnChange({profile: this.currentProfile});
//});
this.currentProfile.removeEventListener("marker_moved", this.redraw);
this.currentProfile.removeEventListener("marker_added", this.redraw);
this.currentProfile.removeEventListener("marker_removed", this.redraw);
this.currentProfile.removeEventListener("width_changed", this.redraw);
viewer.removeEventListener("material_changed", this.redraw);
viewer.removeEventListener("height_range_changed", this.redraw);
viewer.removeEventListener("intensity_range_changed", this.redraw);
}
this.currentProfile = profile;
{
this.currentProfile.addEventListener("marker_moved", this.drawOnChange);
this.currentProfile.addEventListener("marker_added", this.drawOnChange);
this.currentProfile.addEventListener("marker_removed", this.drawOnChange);
this.currentProfile.addEventListener("width_changed", this.drawOnChange);
viewer.addEventListener("material_changed", this.drawOnChange);
this.currentProfile.addEventListener("marker_moved", this.redraw);
this.currentProfile.addEventListener("marker_added", this.redraw);
this.currentProfile.addEventListener("marker_removed", this.redraw);
this.currentProfile.addEventListener("width_changed", this.redraw);
viewer.addEventListener("material_changed", this.redraw);
viewer.addEventListener("height_range_changed", this.redraw);
viewer.addEventListener("intensity_range_changed", this.redraw);
}
if(!this.__drawData){

View File

@ -1191,17 +1191,13 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
return box;
};
fitToScreen(){
fitToScreen(factor = 1){
var box = this.getBoundingBox(this.scene.pointclouds);
//if(this.transformationTool && this.transformationTool.selection.length > 0){
// box = this.transformationTool.getBoundingBox();
//}
var node = new THREE.Object3D();
node.boundingBox = box;
this.zoomTo(node, 1);
this.zoomTo(node, factor);
};
setTopView(){
@ -1625,6 +1621,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
visiblePoints = result.numVisiblePoints;
camera.near = result.lowestSpacing * 10.0;
camera.far = -this.getBoundingBox().applyMatrix4(camera.matrixWorldInverse).min.z;
camera.far = Math.max(camera.far * 1.5, 1000);
}

View File

@ -140,10 +140,10 @@ onmessage = function(event){
}else if(pointAttribute.name === Potree.PointAttribute.COLOR_PACKED.name){
var buff = new ArrayBuffer(numPoints*4*3);
var colors = new Float32Array(buff);
var buff = new ArrayBuffer(numPoints*3);
var colors = new Uint8Array(buff);
var div = event.data.normalize.color ? 65535 : 255;
var div = event.data.normalize.color ? 256 : 1;
for(var j = 0; j < numPoints; ++j){
colors[3*j+0] = cv.getUint16(offset + j*pointSize + 0) / div;