diff --git a/examples/gradient_colors.html b/examples/gradient_colors.html
new file mode 100644
index 00000000..281d3b32
--- /dev/null
+++ b/examples/gradient_colors.html
@@ -0,0 +1,143 @@
+
+
+
+
+
+
+
+ Potree Viewer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/lang/en/translation.json b/resources/lang/en/translation.json
index 601302b8..93dffdd5 100644
--- a/resources/lang/en/translation.json
+++ b/resources/lang/en/translation.json
@@ -52,6 +52,10 @@
"freeze": "Lock view",
"language": "Language"
},
+ "measurements": {
+ "clip": "clip",
+ "show": "show volume"
+ },
"annotations": {
"show3D": "show in 3D",
"showMap": "show on map"
diff --git a/src/Annotation.js b/src/Annotation.js
index 6466e1a8..8a079b15 100644
--- a/src/Annotation.js
+++ b/src/Annotation.js
@@ -303,7 +303,7 @@ Potree.Annotation = class extends THREE.EventDispatcher{
let view = this.scene.view;
- var animationDuration = 800;
+ var animationDuration = 300;
var easing = TWEEN.Easing.Quartic.Out;
diff --git a/src/PointCloudOctree.js b/src/PointCloudOctree.js
index 083a2834..59069f2c 100644
--- a/src/PointCloudOctree.js
+++ b/src/PointCloudOctree.js
@@ -276,7 +276,8 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{
if(j === 0){
let vArrayIndex = visibleNodes.indexOf(child);
- data[i*3 + 1] = vArrayIndex - i;
+ data[i*3 + 1] = (vArrayIndex - i) >> 8;
+ data[i*3 + 2] = (vArrayIndex - i) % 256;
}
}
diff --git a/src/materials/PointCloudMaterial.js b/src/materials/PointCloudMaterial.js
index f701fe17..84e6f2ec 100644
--- a/src/materials/PointCloudMaterial.js
+++ b/src/materials/PointCloudMaterial.js
@@ -8,6 +8,38 @@
// http://stackoverflow.com/questions/3717226/radius-of-projected-sphere
//
+//
+// to get a ready to use gradient array from a chroma.js gradient:
+// http://gka.github.io/chroma.js/
+//
+//var stops = [];
+//for(let i = 0; i <= 10; i++){
+// let range = chroma.scale(['yellow', 'navy']).mode('lch').domain([10,0])(i)._rgb
+// .slice(0, 3)
+// .map(v => (v / 255).toFixed(4))
+// .join(", ");
+//
+// let line = `[${i / 10}, new THREE.Color(${range})],`;
+//
+// stops.push(line);
+//}
+//stops.join("\n");
+
+
+// to get a ready to use gradient array from matplotlib:
+//import matplotlib.pyplot as plt
+//import matplotlib.colors as colors
+//
+//norm = colors.Normalize(vmin=0,vmax=1)
+//cmap = plt.cm.viridis
+//
+//for i in range(0,11):
+// u = i / 10
+// rgb = cmap(norm(u))[0:3]
+// rgb = ["{0:.3f}".format(v) for v in rgb]
+// rgb = "[" + str(u) + ", new THREE.Color(" + ", ".join(rgb) + ")],"
+// print(rgb)
+
Potree.Gradients = {
RAINBOW: [
[0, new THREE.Color(0.278, 0, 0.714)],
@@ -18,6 +50,72 @@ Potree.Gradients = {
[5/6, new THREE.Color(1, 0.64, 0)],
[1, new THREE.Color(1, 0, 0)]
],
+ // From chroma spectral http://gka.github.io/chroma.js/
+ SPECTRAL: [
+ [0, new THREE.Color(0.3686, 0.3098, 0.6353)],
+ [0.1, new THREE.Color(0.1961, 0.5333, 0.7412)],
+ [0.2, new THREE.Color(0.4000, 0.7608, 0.6471)],
+ [0.3, new THREE.Color(0.6706, 0.8667, 0.6431)],
+ [0.4, new THREE.Color(0.9020, 0.9608, 0.5961)],
+ [0.5, new THREE.Color(1.0000, 1.0000, 0.7490)],
+ [0.6, new THREE.Color(0.9961, 0.8784, 0.5451)],
+ [0.7, new THREE.Color(0.9922, 0.6824, 0.3804)],
+ [0.8, new THREE.Color(0.9569, 0.4275, 0.2627)],
+ [0.9, new THREE.Color(0.8353, 0.2431, 0.3098)],
+ [1, new THREE.Color(0.6196, 0.0039, 0.2588)],
+ ],
+ PLASMA: [
+ [0.0, new THREE.Color(0.241, 0.015, 0.610)],
+ [0.1, new THREE.Color(0.387, 0.001, 0.654)],
+ [0.2, new THREE.Color(0.524, 0.025, 0.653)],
+ [0.3, new THREE.Color(0.651, 0.125, 0.596)],
+ [0.4, new THREE.Color(0.752, 0.227, 0.513)],
+ [0.5, new THREE.Color(0.837, 0.329, 0.431)],
+ [0.6, new THREE.Color(0.907, 0.435, 0.353)],
+ [0.7, new THREE.Color(0.963, 0.554, 0.272)],
+ [0.8, new THREE.Color(0.992, 0.681, 0.195)],
+ [0.9, new THREE.Color(0.987, 0.822, 0.144)],
+ [1.0, new THREE.Color(0.940, 0.975, 0.131)],
+ ],
+ YELLOW_GREEN: [
+ [0, new THREE.Color(0.1647, 0.2824, 0.3451)],
+ [0.1, new THREE.Color(0.1338, 0.3555, 0.4227)],
+ [0.2, new THREE.Color(0.0610, 0.4319, 0.4864)],
+ [0.3, new THREE.Color(0.0000, 0.5099, 0.5319)],
+ [0.4, new THREE.Color(0.0000, 0.5881, 0.5569)],
+ [0.5, new THREE.Color(0.1370, 0.6650, 0.5614)],
+ [0.6, new THREE.Color(0.2906, 0.7395, 0.5477)],
+ [0.7, new THREE.Color(0.4453, 0.8099, 0.5201)],
+ [0.8, new THREE.Color(0.6102, 0.8748, 0.4850)],
+ [0.9, new THREE.Color(0.7883, 0.9323, 0.4514)],
+ [1, new THREE.Color(0.9804, 0.9804, 0.4314)],
+ ],
+ VIRIDIS: [
+ [0.0, new THREE.Color(0.267, 0.005, 0.329)],
+ [0.1, new THREE.Color(0.283, 0.141, 0.458)],
+ [0.2, new THREE.Color(0.254, 0.265, 0.530)],
+ [0.3, new THREE.Color(0.207, 0.372, 0.553)],
+ [0.4, new THREE.Color(0.164, 0.471, 0.558)],
+ [0.5, new THREE.Color(0.128, 0.567, 0.551)],
+ [0.6, new THREE.Color(0.135, 0.659, 0.518)],
+ [0.7, new THREE.Color(0.267, 0.749, 0.441)],
+ [0.8, new THREE.Color(0.478, 0.821, 0.318)],
+ [0.9, new THREE.Color(0.741, 0.873, 0.150)],
+ [1.0, new THREE.Color(0.993, 0.906, 0.144)],
+ ],
+ INFERNO: [
+ [0.0, new THREE.Color(0.077, 0.042, 0.206)],
+ [0.1, new THREE.Color(0.225, 0.036, 0.388)],
+ [0.2, new THREE.Color(0.373, 0.074, 0.432)],
+ [0.3, new THREE.Color(0.522, 0.128, 0.420)],
+ [0.4, new THREE.Color(0.665, 0.182, 0.370)],
+ [0.5, new THREE.Color(0.797, 0.255, 0.287)],
+ [0.6, new THREE.Color(0.902, 0.364, 0.184)],
+ [0.7, new THREE.Color(0.969, 0.516, 0.063)],
+ [0.8, new THREE.Color(0.988, 0.683, 0.072)],
+ [0.9, new THREE.Color(0.961, 0.859, 0.298)],
+ [1.0, new THREE.Color(0.988, 0.998, 0.645)],
+ ],
GRAYSCALE: [
[0, new THREE.Color(0,0,0)],
[1, new THREE.Color(1,1,1)]
@@ -109,7 +207,7 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate
this._clipMode = Potree.ClipMode.DISABLED;
this._weighted = false;
this._depthMap = null;
- this._gradient = Potree.Gradients.RAINBOW;
+ this._gradient = Potree.Gradients.SPECTRAL;
this._classification = Potree.Classification.DEFAULT;
this.gradientTexture = Potree.PointCloudMaterial.generateGradientTexture(this._gradient);
this.classificationTexture = Potree.PointCloudMaterial.generateClassificationTexture(this._classification);
@@ -201,11 +299,12 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate
this.transparent = false;
this.depthTest = true;
this.depthWrite = true;
- }else{
+ }else if(this.opacity < 1.0 && !this.useEDL){
this.blending = THREE.AdditiveBlending;
this.transparent = true;
this.depthTest = false;
this.depthWrite = true;
+ this.depthFunc = THREE.AlwaysDepth;
}
if(this.weighted){
diff --git a/src/materials/shaders/pointcloud.vs b/src/materials/shaders/pointcloud.vs
index 39a9879c..62260fdd 100644
--- a/src/materials/shaders/pointcloud.vs
+++ b/src/materials/shaders/pointcloud.vs
@@ -136,7 +136,7 @@ float getLOD(){
float mask = value.r * 255.0;
if(isBitSet(mask, index)){
// there are more visible child nodes at this position
- iOffset = iOffset + value.g * 255.0 + numberOfOnes(mask, index - 1.0);
+ iOffset = iOffset + value.g * 255.0 * 256.0 + value.b * 255.0 + numberOfOnes(mask, index - 1.0);
depth++;
}else{
// no more visible child nodes at this position
diff --git a/src/viewer/sidebar.html b/src/viewer/sidebar.html
index 45ae95f8..894f1191 100644
--- a/src/viewer/sidebar.html
+++ b/src/viewer/sidebar.html
@@ -126,7 +126,7 @@
+
+
+
@@ -1295,6 +1298,20 @@ function initMeasurementDetails(){
`);
this.elContentContainer.append(this.elContent);
+ this.elClip = this.elContent.find(`#chkClip_${this.measurement.id}`);
+ this.elVisible = this.elContent.find(`#chkVisible_${this.measurement.id}`);
+
+ this.elClip.click( () => {
+ this.measurement.clip = this.elClip.is(":checked");
+ });
+
+ this.elVisible.click( () => {
+ this.measurement.visible = this.elVisible.is(":checked");
+ });
+
+ this.elClip.prop('checked', this.measurement.clip);
+ this.elVisible.prop('checked', this.measurement.visible);
+
this.elX = this.elContent.find(`#volume_input_x_${this.measurement.id}`);
this.elY = this.elContent.find(`#volume_input_y_${this.measurement.id}`);
this.elZ = this.elContent.find(`#volume_input_z_${this.measurement.id}`);
@@ -1408,6 +1425,8 @@ function initMeasurementDetails(){
this.measurement.addEventListener("marker_removed", this._update);
this.measurement.addEventListener("marker_moved", this._update);
+ this.elContent.i18n();
+
this.update();
}
@@ -1757,9 +1776,10 @@ function initSceneList(){
let initUIElements = function(i) {
// scene panel in scene list
- let title = viewer.scene.pointclouds[i].name;
- let pcMaterial = viewer.scene.pointclouds[i].material;
- let checked = viewer.scene.pointclouds[i].visible ? "checked" : "";
+ let pointcloud = viewer.scene.pointclouds[i];
+ let title = pointcloud.name;
+ let pcMaterial = pointcloud.material;
+ let checked = pointcloud.visible ? "checked" : "";
let scenePanel = $(`
@@ -1974,7 +1994,7 @@ function initSceneList(){
let inputVis = scenePanel.find("input[type='checkbox']");
inputVis.click(function(event){
- viewer.scene.pointclouds[i].visible = event.target.checked;
+ pointcloud.visible = event.target.checked;
if(viewer.profileWindowController){
viewer.profileWindowController.recompute();
}
@@ -2189,13 +2209,16 @@ function initSceneList(){
});
let updateHeightRange = function(){
- let box = viewer.getBoundingBox();
+ let box = [pointcloud.pcoGeometry.tightBoundingBox, pointcloud.getBoundingBoxWorld()]
+ .find(v => v !== undefined);
+
+ pointcloud.updateMatrixWorld(true);
+ box = Potree.utils.computeTransformedBoundingBox(box, pointcloud.matrixWorld);
+
let bWidth = box.max.z - box.min.z;
bMin = box.min.z - 0.2 * bWidth;
bMax = box.max.z + 0.2 * bWidth;
- let hrWidth = pcMaterial.heightMax - pcMaterial.heightMin;
-
$( "#lblHeightRange" + i )[0].innerHTML = pcMaterial.heightMin.toFixed(2) + " to " + pcMaterial.heightMax.toFixed(2);
$( "#sldHeightRange" + i ).slider({
min: bMin,
@@ -2217,6 +2240,14 @@ function initSceneList(){
});
};
+ {
+ updateHeightRange();
+ let min = $(`#sldHeightRange${i}`).slider("option", "min");
+ let max = $(`#sldHeightRange${i}`).slider("option", "max");
+ pcMaterial.heightMin = 0.8 * min + 0.2 * max;
+ pcMaterial.heightMax = 0.2 * min + 0.8 * max;
+ }
+
viewer.addEventListener("height_range_changed" + i, updateHeightRange);
viewer.addEventListener("intensity_range_changed" + i, updateIntensityRange);
@@ -2415,9 +2446,10 @@ let initSettings = function(){
});
viewer.addEventListener("minnodesize_changed", function(event){
- $('#lblMinNodeSize')[0].innerHTML = parseInt(viewer.getMinNodeSize());
- $( "#lblMinNodeSize" ).slider({value: viewer.getMinNodeSize()});
+ $('#lblMinNodeSize').html(parseInt(viewer.getMinNodeSize()));
+ $("#sldMinNodeSize").slider({value: viewer.getMinNodeSize()});
});
+ $('#lblMinNodeSize').html(parseInt(viewer.getMinNodeSize()));
let toClipModeCode = function(string){
diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js
index dc7d7b89..9ada44fa 100644
--- a/src/viewer/viewer.js
+++ b/src/viewer/viewer.js
@@ -1621,191 +1621,6 @@ class PotreeRenderer{
viewer.renderer.setSize(width, height);
}
- /*
- if(Potree.framenumber > 20 && false){
-
- if(Potree.__dems === undefined){
- Potree.__dems = {};
- Potree.__dems.targetElevation = new THREE.WebGLRenderTarget( 128, 128, {
- minFilter: THREE.NearestFilter,
- magFilter: THREE.NearestFilter,
- format: THREE.RGBAFormat
- } );
-
- Potree.__dems.targetMedian = new THREE.WebGLRenderTarget( 128, 128, {
- minFilter: THREE.NearestFilter,
- magFilter: THREE.NearestFilter,
- format: THREE.RGBAFormat
- } );
-
- Potree.__dems.camera = new THREE.OrthographicCamera(0, 1, 1, 0, 0, 1);
-
- // VERTEX SHADER
- let vsElevation = `
- precision mediump float;
- precision mediump int;
-
- attribute vec3 position;
-
- uniform mat4 modelMatrix;
- uniform mat4 modelViewMatrix;
- uniform mat4 projectionMatrix;
-
- varying float vElevation;
-
- void main(){
- vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
- gl_Position = projectionMatrix * mvPosition;
- gl_PointSize = 1.0;
-
- vElevation = position.z;
- }
- `;
-
- // FRAGMENT SHADER
- let fsElevation = `
- precision mediump float;
- precision mediump int;
-
- varying float vElevation;
-
- void main(){
- gl_FragColor = vec4(vElevation / 50.0, 0.0, 0.0, 1.0);
- }
- `;
-
- let vsMedian = `
- precision mediump float;
- precision mediump int;
-
- attribute vec3 position;
- attribute vec2 uv;
-
- uniform mat4 modelMatrix;
- uniform mat4 modelViewMatrix;
- uniform mat4 projectionMatrix;
-
- varying vec2 vUV;
-
- void main() {
- vUV = uv;
-
- vec4 mvPosition = modelViewMatrix * vec4(position,1.0);
-
- gl_Position = projectionMatrix * mvPosition;
- }
- `;
-
- let fsMedian = `
-
- precision mediump float;
- precision mediump int;
-
- uniform float uWidth;
- uniform float uHeight;
- uniform sampler2D uTexture;
-
- varying vec2 vUV;
-
- void main(){
- vec2 uv = gl_FragCoord.xy / vec2(uWidth, uHeight);
-
- vec4 color = texture2D(uTexture, uv);
- gl_FragColor = color;
- if(color.a == 0.0){
-
- vec4 sum;
-
- float minVal = 1.0 / 0.0;
-
- float sumA = 0.0;
- for(int i = -1; i <= 1; i++){
- for(int j = -1; j <= 1; j++){
- vec2 n = gl_FragCoord.xy + vec2(i, j);
- vec2 uv = n / vec2(uWidth, uHeight);
- vec4 c = texture2D(uTexture, uv);
-
- if(c.a == 1.0){
- minVal = min(c.r, minVal);
- }
-
- sumA += c.a;
- }
- }
-
- if(sumA > 0.0){
- gl_FragColor = vec4(minVal, 0.0, 0.0, 1.0);
- }else{
- discard;
- }
- }else{
- //gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
- gl_FragColor = vec4(color.rgb, 1.0);
- }
-
-
- }
-
- `;
-
- Potree.__dems.elevationMaterial = new THREE.RawShaderMaterial( {
- vertexShader: vsElevation,
- fragmentShader: fsElevation,
- } );
-
- Potree.__dems.medianFilterMaterial = new THREE.RawShaderMaterial( {
- uniforms: {
- uWidth: {value: 1.0},
- uHeight: {value: 1.0},
- uTexture: {type: "t", value: Potree.__dems.targetElevation.texture}
- },
- vertexShader: vsMedian,
- fragmentShader: fsMedian,
- } );
-
- }
- let dems = Potree.__dems;
- let camera = dems.camera;
- viewer.renderer.setClearColor(0x0000FF, 0);
- viewer.renderer.clearTarget(dems.targetElevation, true, true, false );
- viewer.renderer.clearTarget(dems.targetMedian, true, true, false );
-
- let node = viewer.scene.pointclouds[0].root;
- if(node.geometryNode){
- let box = node.geometryNode.boundingBox;
-
-
- camera.up.set(0, 0, 1);
- //camera.rotation.x = Math.PI / 2;
- camera.left = box.min.x;
- camera.right = box.max.x;
- camera.top = box.max.y;
- camera.bottom = box.min.y;
- camera.near = -1000;
- camera.far = 1000;
- camera.updateProjectionMatrix();
-
- let scene = new THREE.Scene();
- //let material = new THREE.PointsMaterial({color: 0x00ff00, size: 0.0001});
- let material = dems.elevationMaterial;
- let pointcloud = new THREE.Points(node.geometryNode.geometry, material);
- scene.add(pointcloud);
-
- viewer.renderer.render(pointcloud, camera, dems.targetElevation);
-
- dems.medianFilterMaterial.uniforms.uWidth.value = dems.targetMedian.width;
- dems.medianFilterMaterial.uniforms.uHeight.value = dems.targetMedian.height;
- dems.medianFilterMaterial.uniforms.uTexture.value = dems.targetElevation.texture;
-
- Potree.utils.screenPass.render(viewer.renderer, dems.medianFilterMaterial, dems.targetMedian);
-
- plane.material = new THREE.MeshBasicMaterial({map: dems.targetMedian.texture});
- }
- }*/
-
-
- //var queryAll = Potree.startQuery("All", viewer.renderer.getContext());
-
// render skybox
if(viewer.background === "skybox"){
viewer.renderer.clear(true, true, false);
@@ -1825,6 +1640,10 @@ class PotreeRenderer{
viewer.renderer.clear(true, true, false);
}
+ for(let pointcloud of this.viewer.scene.pointclouds){
+ pointcloud.material.useEDL = false;
+ }
+
//var queryPC = Potree.startQuery("PointCloud", viewer.renderer.getContext());
viewer.renderer.render(viewer.scene.scenePointCloud, viewer.scene.camera);
//Potree.endQuery(queryPC, viewer.renderer.getContext());
@@ -1914,6 +1733,7 @@ class EDLRenderer{
if(viewer.background === "skybox"){
+ viewer.renderer.setClearColor(0x000000, 0);
viewer.renderer.clear();
viewer.skybox.camera.rotation.copy(viewer.scene.camera.rotation);
viewer.skybox.camera.fov = viewer.scene.camera.fov;
@@ -1921,6 +1741,7 @@ class EDLRenderer{
viewer.skybox.camera.updateProjectionMatrix();
viewer.renderer.render(viewer.skybox.scene, viewer.skybox.camera);
}else if(viewer.background === "gradient"){
+ viewer.renderer.setClearColor(0x000000, 0);
viewer.renderer.clear();
viewer.renderer.render(viewer.scene.sceneBG, viewer.scene.cameraBG);
}else if(viewer.background === "black"){