commit
86febd26a1
2
build/js/laslaz.js
Normal file
2
build/js/laslaz.js
Normal file
File diff suppressed because one or more lines are too long
1
build/js/laslaz.min.js
vendored
Normal file
1
build/js/laslaz.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
5
build/js/potree.min.js
vendored
5
build/js/potree.min.js
vendored
File diff suppressed because one or more lines are too long
@ -79,7 +79,7 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/vol_total/cloud.js";
|
||||
var defaultPointSize = 3;
|
||||
var defaultPointSize = 4;
|
||||
var defaultLOD = 17;
|
||||
|
||||
// add EPSG:21781 to the proj4 projection database
|
||||
@ -228,6 +228,8 @@
|
||||
controls.moveSpeed *= 10;
|
||||
|
||||
materials.rgb = new Potree.PointCloudRGBMaterial({ size: defaultPointSize});
|
||||
materials.rgbInterpolated = new Potree.PointCloudRGBInterpolationMaterial({ size: defaultPointSize});
|
||||
materials.height = new Potree.PointCloudHeightMaterial({size: defaultPointSize, min: 0, max: 60});
|
||||
|
||||
// load pointcloud
|
||||
var pco = POCLoader.load(pointcloudPath, {toOrigin: true});
|
||||
@ -275,7 +277,8 @@
|
||||
var params = {
|
||||
PointSize: defaultPointSize,
|
||||
LOD: defaultLOD,
|
||||
"bounding box" : false
|
||||
"show octree" : false,
|
||||
"Materials" : materials.rgb
|
||||
};
|
||||
|
||||
var pLOD = gui.add(params, 'LOD', 0.5,20);
|
||||
@ -283,16 +286,40 @@
|
||||
pointcloud.LOD = value;
|
||||
});
|
||||
|
||||
var pPointSize = gui.add(params, 'PointSize', 0.01, 4.0);
|
||||
var pPointSize = gui.add(params, 'PointSize', 0.01, 6.0);
|
||||
pPointSize.onChange(function(value){
|
||||
pointcloud.material.size = value;
|
||||
});
|
||||
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "RGB High Quality", "Height" ]);
|
||||
pMaterial.onChange(function(value){
|
||||
var size = pointcloud.material.size;
|
||||
if(value === "RGB"){
|
||||
pointcloud.material = materials.rgb;
|
||||
}else if(value === "RGB High Quality"){
|
||||
var frag_depth_ext = renderer.context.getExtension('EXT_frag_depth');
|
||||
if(!frag_depth_ext){
|
||||
var message = "failed to load EXT_frag_depth. This extension is required for the high quality shader.\n";
|
||||
message += "using standard RGB material instead";
|
||||
alert(message);
|
||||
pointcloud.material = materials.rgb;
|
||||
}else{
|
||||
pointcloud.material = materials.rgbInterpolated;
|
||||
}
|
||||
|
||||
}else if(value === "Height"){
|
||||
pointcloud.material = materials.height;
|
||||
}
|
||||
|
||||
pointcloud.material.size = size;
|
||||
|
||||
var pBoundingBox = gui.add(params, 'bounding box');
|
||||
console.log(value);
|
||||
});
|
||||
|
||||
var pBoundingBox = gui.add(params, 'show octree');
|
||||
pBoundingBox.onChange(function(value){
|
||||
pointcloud.showBoundingBox = value;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function update(){
|
||||
|
||||
@ -30,17 +30,21 @@
|
||||
<script src="../libs/other/stats.min.js"></script>
|
||||
<script src="../libs/other/dat.gui.min.js"></script>
|
||||
|
||||
<script src="../build/js/potree.min.js"></script>
|
||||
<script src="../build/js/potree.js"></script>
|
||||
|
||||
<div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px; color:white"></div>
|
||||
<div id="lblNumVisiblePoints" class="info" style="position: absolute; left: 10px; top: 100px; width: 400px; color:white"></div>
|
||||
|
||||
<div class="info" style="position: absolute; left: 300px; right: 300px; top: 10px; text-align: center;">
|
||||
<a href="http://potree.org" target="_blank">potree.org</a><br>
|
||||
<br>
|
||||
The RGB High Quality shader interpolates between points, rather than rendering the nearest one.
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var defaultPointSize = 0.04;
|
||||
var defaultPointSize = 0.07;
|
||||
var defaultBlendDepth = 0.01;
|
||||
var defaultLOD = 15;
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa/cloud_bin.js";
|
||||
|
||||
@ -62,8 +66,9 @@
|
||||
|
||||
var params = {
|
||||
PointSize: defaultPointSize,
|
||||
BlendDepth: defaultBlendDepth,
|
||||
LOD: defaultLOD,
|
||||
"show aabb" : false,
|
||||
"show octree" : false,
|
||||
"Materials" : materials.rgb
|
||||
};
|
||||
|
||||
@ -72,16 +77,27 @@
|
||||
pointcloud.LOD = value;
|
||||
});
|
||||
|
||||
var pPointSize = gui.add(params, 'PointSize', 0.01, 0.1);
|
||||
var pPointSize = gui.add(params, 'PointSize', 0.01, 0.2);
|
||||
pPointSize.onChange(function(value){
|
||||
pointcloud.material.size = value;
|
||||
});
|
||||
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "Color", "Height" ]);
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "RGB High Quality", "Color", "Height" ]);
|
||||
pMaterial.onChange(function(value){
|
||||
var size = pointcloud.material.size;
|
||||
if(value === "RGB"){
|
||||
pointcloud.material = materials.rgb;
|
||||
}else if(value === "RGB High Quality"){
|
||||
var frag_depth_ext = renderer.context.getExtension('EXT_frag_depth');
|
||||
if(!frag_depth_ext){
|
||||
var message = "failed to load EXT_frag_depth. This extension is required for the high quality shader.\n";
|
||||
message += "using standard RGB material instead";
|
||||
alert(message);
|
||||
pointcloud.material = materials.rgb;
|
||||
}else{
|
||||
pointcloud.material = materials.rgbInterpolated;
|
||||
}
|
||||
|
||||
}else if(value === "Color"){
|
||||
pointcloud.material = materials.color;
|
||||
}else if(value === "Height"){
|
||||
@ -93,7 +109,7 @@
|
||||
console.log(value);
|
||||
});
|
||||
|
||||
var pBoundingBox = gui.add(params, 'show aabb');
|
||||
var pBoundingBox = gui.add(params, 'show octree');
|
||||
pBoundingBox.onChange(function(value){
|
||||
pointcloud.showBoundingBox = value;
|
||||
});
|
||||
@ -118,16 +134,16 @@
|
||||
skybox = Potree.utils.loadSkybox("../resources/textures/skybox/");
|
||||
|
||||
// camera and controls
|
||||
camera.position.set(5, 10, 15);
|
||||
camera.position.set(3, 7, 6);
|
||||
controls = new THREE.OrbitControls(camera, renderer.domElement);
|
||||
controls.target.set( 0, 4, 0 );
|
||||
controls.target.set( 0, 5, 0 );
|
||||
camera.lookAt(controls.target);
|
||||
|
||||
// materials
|
||||
materials.rgb = new Potree.PointCloudRGBMaterial({ size: defaultPointSize});
|
||||
materials.rgbInterpolated = new Potree.PointCloudRGBInterpolationMaterial({ size: defaultPointSize});
|
||||
materials.color = new Potree.PointCloudColorMaterial({size: defaultPointSize});
|
||||
materials.height = new Potree.PointCloudHeightMaterial({size: defaultPointSize, min: 0, max: 10});
|
||||
materials.height = new Potree.PointCloudHeightMaterial({size: defaultPointSize, min: 0, max: 10});
|
||||
materials.height = new Potree.PointCloudHeightMaterial({size: defaultPointSize, min: 2, max: 8});
|
||||
|
||||
// load pointcloud
|
||||
var pco = POCLoader.load(pointcloudPath, {toOrigin: true});
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
<script src="../libs/other/dat.gui.min.js"></script>
|
||||
|
||||
<script src="../build/js/potree.js"></script>
|
||||
<script src="../build/js/laslaz.js"></script>
|
||||
|
||||
<div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px; color:white"></div>
|
||||
<div id="lblNumVisiblePoints" class="info" style="position: absolute; left: 10px; top: 100px; width: 400px; color:white"></div>
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
<script src="../libs/other/dat.gui.min.js"></script>
|
||||
|
||||
<script src="../build/js/potree.js"></script>
|
||||
<script src="../build/js/laslaz.js"></script>
|
||||
|
||||
<div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px; color:white"></div>
|
||||
<div id="lblNumVisiblePoints" class="info" style="position: absolute; left: 10px; top: 100px; width: 400px; color:white"></div>
|
||||
|
||||
17
gulpfile.js
17
gulpfile.js
@ -16,14 +16,13 @@ var paths = {
|
||||
potree : [
|
||||
"src/Potree.js",
|
||||
"src/WorkerManager.js",
|
||||
"build/workers/laslaz-worker.js",
|
||||
"build/workers/lasdecoder-worker.js",
|
||||
"src/extensions/PerspectiveCamera.js",
|
||||
"src/extensions/Ray.js",
|
||||
"src/loader/POCLoader.js",
|
||||
"src/loader/PointAttributes.js",
|
||||
"src/loader/LasLazLoader.js",
|
||||
"src/materials/PointCloudRGBMaterial.js",
|
||||
"src/materials/PointCloudRGBInterpolationMaterial.js",
|
||||
"src/materials/PointCloudIntensityMaterial.js",
|
||||
"src/materials/PointCloudHeightMaterial.js",
|
||||
"src/materials/PointCloudColorMaterial.js",
|
||||
@ -36,8 +35,11 @@ var paths = {
|
||||
"src/utils/MeasuringTool.js",
|
||||
"src/utils/ProfileTool.js",
|
||||
"src/utils/TranslationTool.js"
|
||||
],
|
||||
laslaz: [
|
||||
"build/workers/laslaz-worker.js",
|
||||
"build/workers/lasdecoder-worker.js",
|
||||
]
|
||||
|
||||
};
|
||||
|
||||
var workers = {
|
||||
@ -73,6 +75,15 @@ gulp.task("scripts", function(){
|
||||
.pipe(uglify({preserveComments: 'some'}))
|
||||
.pipe(size({showFiles: true}))
|
||||
.pipe(gulp.dest('build/js'));
|
||||
|
||||
gulp.src(paths.laslaz)
|
||||
.pipe(concat('laslaz.js'))
|
||||
.pipe(size({showFiles: true}))
|
||||
.pipe(gulp.dest('build/js'))
|
||||
.pipe(rename({suffix: '.min'}))
|
||||
.pipe(uglify({preserveComments: 'some'}))
|
||||
.pipe(size({showFiles: true}))
|
||||
.pipe(gulp.dest('build/js'));
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
@ -33,6 +33,15 @@ Object.defineProperty(Potree.PointCloudColorMaterial.prototype, "size", {
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Potree.PointCloudColorMaterial.prototype, "color", {
|
||||
get: function(){
|
||||
return this.uniforms.uCol.value;
|
||||
},
|
||||
set: function(value){
|
||||
this.uniforms.uCol.value.copy(value);
|
||||
}
|
||||
});
|
||||
|
||||
Potree.PointCloudColorMaterial.vs_points = [
|
||||
"uniform float size; ",
|
||||
"uniform vec3 uCol; ",
|
||||
|
||||
@ -5,13 +5,16 @@ Potree.PointCloudHeightMaterial = function(parameters){
|
||||
var size = parameters.size || 1.0;
|
||||
this.min = parameters.min || 0;
|
||||
this.max = parameters.max || 1;
|
||||
|
||||
var gradientTexture = Potree.PointCloudHeightMaterial.generateGradient();
|
||||
|
||||
var attributes = {};
|
||||
var uniforms = {
|
||||
uCol: { type: "c", value: new THREE.Color( 0xffffff ) },
|
||||
size: { type: "f", value: 1 },
|
||||
uMin: { type: "f", value: this.min },
|
||||
uMax: { type: "f", value: this.max }
|
||||
uMax: { type: "f", value: this.max },
|
||||
gradient: {type: "t", value: gradientTexture}
|
||||
};
|
||||
|
||||
this.setValues({
|
||||
@ -25,6 +28,39 @@ Potree.PointCloudHeightMaterial = function(parameters){
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Potree.PointCloudHeightMaterial.generateGradient = function() {
|
||||
var size = 64;
|
||||
|
||||
// create canvas
|
||||
canvas = document.createElement( 'canvas' );
|
||||
canvas.width = size;
|
||||
canvas.height = size;
|
||||
|
||||
// get context
|
||||
var context = canvas.getContext( '2d' );
|
||||
|
||||
// draw gradient
|
||||
context.rect( 0, 0, size, size );
|
||||
var gradient = context.createLinearGradient( 0, 0, size, size );
|
||||
gradient.addColorStop(0, 'blue');
|
||||
gradient.addColorStop(1/5, 'aqua');
|
||||
gradient.addColorStop(2/5, 'green')
|
||||
gradient.addColorStop(3/5, 'yellow');
|
||||
gradient.addColorStop(4/5, 'orange');
|
||||
gradient.addColorStop(1, 'red');
|
||||
|
||||
|
||||
context.fillStyle = gradient;
|
||||
context.fill();
|
||||
|
||||
var texture = new THREE.Texture( canvas );
|
||||
texture.needsUpdate = true;
|
||||
textureImage = texture.image;
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
Potree.PointCloudHeightMaterial.prototype = new THREE.ShaderMaterial();
|
||||
|
||||
Object.defineProperty(Potree.PointCloudHeightMaterial.prototype, "size", {
|
||||
@ -48,6 +84,7 @@ Potree.PointCloudHeightMaterial.vs_points = [
|
||||
"uniform float size; ",
|
||||
"uniform float uMin; ",
|
||||
"uniform float uMax; ",
|
||||
"uniform sampler2D gradient; ",
|
||||
" ",
|
||||
"varying vec3 vColor; ",
|
||||
" ",
|
||||
@ -55,8 +92,10 @@ Potree.PointCloudHeightMaterial.vs_points = [
|
||||
" vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); ",
|
||||
" vec4 world = modelMatrix * vec4( position, 1.0 ); ",
|
||||
" float w = (world.y - uMin) / (uMax-uMin); ",
|
||||
" w = clamp(w-0.1, 0.2, 1.0); ",
|
||||
" vColor = vec3(1.0, 0.0, 0.0) * (w) ; ",
|
||||
" ",
|
||||
" vec4 gCol = texture2D(gradient, vec2(w,1.0-w)); ",
|
||||
" vColor = gCol.rgb; ",
|
||||
" ",
|
||||
" ",
|
||||
" gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); ",
|
||||
" gl_PointSize = max(2.0, gl_PointSize); ",
|
||||
|
||||
104
src/materials/PointCloudRGBInterpolationMaterial.js
Normal file
104
src/materials/PointCloudRGBInterpolationMaterial.js
Normal file
@ -0,0 +1,104 @@
|
||||
|
||||
Potree.PointCloudRGBInterpolationMaterial = function(parameters){
|
||||
parameters = parameters || {};
|
||||
|
||||
var attributes = {};
|
||||
var uniforms = {
|
||||
color: { type: "c", value: new THREE.Color( 0xffffff ) },
|
||||
size: { type: "f", value: 10 },
|
||||
blendDepth: { type: "f", value: 0.01 }
|
||||
};
|
||||
|
||||
var pointSize = parameters.size || 1.0;
|
||||
|
||||
var vs;
|
||||
var fs;
|
||||
var frag_depth_ext = renderer.context.getExtension('EXT_frag_depth');
|
||||
if(!frag_depth_ext){
|
||||
vs = Potree.PointCloudRGBMaterial.vs_points.join("\n");
|
||||
fs = Potree.PointCloudRGBMaterial.fs_points_rgb.join("\n");
|
||||
}else{
|
||||
vs = Potree.PointCloudRGBInterpolationMaterial.vs_points.join("\n");
|
||||
fs = Potree.PointCloudRGBInterpolationMaterial.fs_points_rgb.join("\n");
|
||||
}
|
||||
|
||||
this.setValues({
|
||||
uniforms: uniforms,
|
||||
attributes: attributes,
|
||||
vertexShader: vs,
|
||||
fragmentShader: fs,
|
||||
vertexColors: THREE.VertexColors,
|
||||
size: pointSize,
|
||||
alphaTest: 0.9,
|
||||
});
|
||||
};
|
||||
|
||||
Potree.PointCloudRGBInterpolationMaterial.prototype = new THREE.ShaderMaterial();
|
||||
|
||||
Object.defineProperty(Potree.PointCloudRGBInterpolationMaterial.prototype, "size", {
|
||||
get: function(){
|
||||
return this.uniforms.size.value;
|
||||
},
|
||||
set: function(value){
|
||||
this.uniforms.size.value = value;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Potree.PointCloudRGBInterpolationMaterial.prototype, "blendDepth", {
|
||||
get: function(){
|
||||
return this.uniforms.blendDepth.value;
|
||||
},
|
||||
set: function(value){
|
||||
this.uniforms.blendDepth.value = value;
|
||||
}
|
||||
});
|
||||
|
||||
Potree.PointCloudRGBInterpolationMaterial.vs_points = [
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
"uniform float size; ",
|
||||
"varying vec3 vColor; ",
|
||||
" ",
|
||||
"void main() { ",
|
||||
" vColor = color; ",
|
||||
" vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); ",
|
||||
" ",
|
||||
" gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); ",
|
||||
" gl_PointSize = max(2.0, gl_PointSize); ",
|
||||
" gl_Position = projectionMatrix * mvPosition; ",
|
||||
"} "];
|
||||
|
||||
Potree.PointCloudRGBInterpolationMaterial.fs_points_rgb = [
|
||||
"#extension GL_EXT_frag_depth : enable ",
|
||||
"varying vec3 vColor; ",
|
||||
"uniform float blendDepth; ",
|
||||
" ",
|
||||
" ",
|
||||
"void main() { ",
|
||||
" ",
|
||||
" float a = pow(2.0*(gl_PointCoord.x - 0.5), 2.0); ",
|
||||
" float b = pow(2.0*(gl_PointCoord.y - 0.5), 2.0); ",
|
||||
" float c = 1.0 - (a + b); ",
|
||||
" ",
|
||||
" if(c < 0.0){ ",
|
||||
" discard; ",
|
||||
" } ",
|
||||
" ",
|
||||
" gl_FragColor = vec4(vColor, 1.0); ",
|
||||
" gl_FragDepthEXT = gl_FragCoord.z + blendDepth*(1.0-pow(c, 1.0)) * gl_FragCoord.w ; ",
|
||||
"} "];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user