new gradients; volume gui; adaptive sizes w. >255 nodes; default elevation range;
This commit is contained in:
parent
9ed1c5f1de
commit
470ba25cbd
143
examples/gradient_colors.html
Normal file
143
examples/gradient_colors.html
Normal file
@ -0,0 +1,143 @@
|
||||
<!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" href="../libs/openlayers3/ol.css" type="text/css">
|
||||
<link rel="stylesheet" href="../libs/spectrum/spectrum.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<script src="../libs/jquery/jquery-3.1.1.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/stats.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="../build/potree/potree.js"></script>
|
||||
<!--<script src="../src/viewer/sidebar.js"></script>-->
|
||||
|
||||
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
|
||||
<!-- INCLUDE SETTINGS HERE -->
|
||||
|
||||
<script src="../libs/plasio/js/laslaz.js"></script>
|
||||
<script src="../libs/plasio/vendor/bluebird.js"></script>
|
||||
|
||||
<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(1*1000*1000);
|
||||
viewer.setMinNodeSize(10);
|
||||
viewer.loadSettingsFromURL();
|
||||
|
||||
viewer.setDescription(`Available gradient color schemes.<br>
|
||||
Set scheme with 'pointcloud.material.gradient = Potree.Gradients.<name>'`);
|
||||
|
||||
viewer.loadGUI(() => {
|
||||
viewer.setLanguage('en');
|
||||
$("#menu_scene").next().show();
|
||||
viewer.toggleSidebar();
|
||||
});
|
||||
|
||||
viewer.scene.view.position.set(-520.67, 934.77, 884.23);
|
||||
viewer.scene.view.lookAt(new THREE.Vector3(0, 0, 0));
|
||||
|
||||
let gradientNames = Object.keys(Potree.Gradients);
|
||||
let radius = 520;
|
||||
for(let i = 0; i < gradientNames.length; i++){
|
||||
let gradientName = gradientNames[i];
|
||||
let gradient = Potree.Gradients[gradientName];
|
||||
|
||||
let u = 2 * Math.PI * i / gradientNames.length;
|
||||
|
||||
let x = Math.cos(u) * radius + 2.5;
|
||||
let y = Math.sin(u) * radius + 0.8;
|
||||
let z = 0;
|
||||
|
||||
Potree.loadPointCloud("../pointclouds/vol_total/cloud.js", gradientName, e => {
|
||||
viewer.scene.addPointCloud(e.pointcloud);
|
||||
|
||||
let material = e.pointcloud.material;
|
||||
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
material.pointColorType = Potree.PointColorType.ELEVATION;
|
||||
material.gradient = gradient;
|
||||
|
||||
e.pointcloud.position.set(x, y, z);
|
||||
e.pointcloud.rotation.set(0, 0, u + 1.2);
|
||||
|
||||
e.pointcloud.updateMatrixWorld();
|
||||
let box = e.pointcloud.pcoGeometry.tightBoundingBox;
|
||||
box.applyMatrix4(e.pointcloud.matrixWorld);
|
||||
let center = box.getCenter();
|
||||
|
||||
|
||||
let annotation = new Potree.Annotation({
|
||||
title: gradientName,
|
||||
radius: 600
|
||||
});
|
||||
annotation.position = center;
|
||||
annotation.position.z += 30;
|
||||
viewer.scene.annotations.add(annotation);
|
||||
});
|
||||
}
|
||||
|
||||
Potree.loadPointCloud("../pointclouds/vol_total/cloud.js", "custom", e => {
|
||||
viewer.scene.addPointCloud(e.pointcloud);
|
||||
|
||||
let material = e.pointcloud.material;
|
||||
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
material.pointColorType = Potree.PointColorType.ELEVATION;
|
||||
material.gradient = [
|
||||
[0.0, new THREE.Color(0.090, 0.545, 0.400)],
|
||||
[0.1, new THREE.Color(0.180, 0.590, 0.400)],
|
||||
[0.2, new THREE.Color(0.271, 0.635, 0.400)],
|
||||
[0.3, new THREE.Color(0.365, 0.682, 0.400)],
|
||||
[0.4, new THREE.Color(0.455, 0.727, 0.400)],
|
||||
[0.5, new THREE.Color(0.545, 0.773, 0.400)],
|
||||
[0.6, new THREE.Color(0.635, 0.818, 0.400)],
|
||||
[0.7, new THREE.Color(0.729, 0.865, 0.400)],
|
||||
[0.8, new THREE.Color(0.820, 0.910, 0.400)],
|
||||
[0.9, new THREE.Color(0.910, 0.955, 0.400)],
|
||||
[1.0, new THREE.Color(1.000, 1.000, 0.400)],
|
||||
];
|
||||
|
||||
e.pointcloud.position.set(300, -100, 0);
|
||||
e.pointcloud.rotation.set(0, 0, 0.8 * Math.PI);
|
||||
|
||||
let annotation = new Potree.Annotation({
|
||||
title: "custom",
|
||||
radius: 600
|
||||
});
|
||||
annotation.position = new THREE.Vector3(0, 0, 5);
|
||||
viewer.scene.annotations.add(annotation);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -52,6 +52,10 @@
|
||||
"freeze": "Lock view",
|
||||
"language": "Language"
|
||||
},
|
||||
"measurements": {
|
||||
"clip": "clip",
|
||||
"show": "show volume"
|
||||
},
|
||||
"annotations": {
|
||||
"show3D": "show in 3D",
|
||||
"showMap": "show on map"
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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){
|
||||
|
||||
@ -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
|
||||
|
||||
@ -126,7 +126,7 @@
|
||||
<h3 id="menu_other_settings"><span data-i18n="tb.parameters_opt"></span></h3>
|
||||
<div>
|
||||
<ul class="pv-menu-list">
|
||||
<li><span data-i18n="appearance.min_node_size"></span><span id="lblMinNodeSize"></span><div id="sldMinNodeSize"></div> </li>
|
||||
<li><span data-i18n="appearance.min_node_size"></span>:<span id="lblMinNodeSize"></span><div id="sldMinNodeSize"></div> </li>
|
||||
<li>
|
||||
<label for="optClipMode" class="pv-select-label"><span data-i18n="appearance.clip_mode"></span></label>
|
||||
<select id="optClipMode" name="optClipMode">
|
||||
|
||||
@ -1280,6 +1280,9 @@ function initMeasurementDetails(){
|
||||
<span class="input-grid-cell"><input type="text" id="volume_input_gamma_${measurement.id}"/></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label><input type="checkbox" id="chkClip_${this.measurement.id}"/><span data-i18n="measurements.clip"></span></label>
|
||||
<label><input type="checkbox" id="chkVisible_${this.measurement.id}"/><span data-i18n="measurements.show"></span></label>
|
||||
|
||||
|
||||
<input type="button" value="Prepare Download" id="download_volume_${this.id}"/>
|
||||
@ -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 = $(`
|
||||
<span class="scene_item">
|
||||
@ -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){
|
||||
|
||||
@ -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"){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user