added classification material

This commit is contained in:
mschuetz 2014-08-24 13:39:38 +02:00
parent a6ce3da850
commit 971ba6c5f6
7 changed files with 113 additions and 10 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -84,14 +84,14 @@ Potree.PointCloudOctree.prototype.update = function(camera){
var visible = true;
visible = visible && frustum.intersectsBox(box);
if(object.level > 1){
if(object.level > 3){
// cull detail nodes based in distance to camera
visible = visible && Math.pow(radius, 0.8) / distance > (1 / this.LOD);
visible = visible && (this.numVisiblePoints + object.numPoints < Potree.pointLoadLimit);
visible = visible && (this.numVisibleNodes <= this.maxVisibleNodes);
visible = visible && (this.numVisiblePoints <= this.maxVisiblePoints);
}else{
visible = true;
//visible = true;
}
// trying to skip higher detail nodes, if parents already cover all holes

View File

@ -145,6 +145,8 @@ Potree.LasLazBatcher = function(node, url){
var positions = e.data.position;
var colors = e.data.color;
var intensities = e.data.intensity;
var classifications = new Uint8Array(e.data.classification);
var classifications_f = new Float32Array(classifications.byteLength);
var box = new THREE.Box3();
@ -154,12 +156,15 @@ Potree.LasLazBatcher = function(node, url){
fPositions[3*i+1] += node.pcoGeometry.offset.y;
fPositions[3*i+2] += node.pcoGeometry.offset.z;
classifications_f[i] = classifications[i];
box.expandByPoint(new THREE.Vector3(fPositions[3*i+0], fPositions[3*i+1], fPositions[3*i+2]));
}
geometry.addAttribute('position', new THREE.Float32Attribute(positions, 3));
geometry.addAttribute('color', new THREE.Float32Attribute(colors, 3));
geometry.addAttribute('intensity', new THREE.Float32Attribute(intensities, 1));
geometry.addAttribute('classification', new THREE.Float32Attribute(classifications_f, 1));
//geometry.boundingBox = node.boundingBox;
geometry.boundingBox = new THREE.Box3(mins, maxs);
node.boundingBox = geometry.boundingBox;

View File

@ -0,0 +1,93 @@
Potree.PointCloudClassificationMaterial = function(parameters){
parameters = parameters || {};
var size = parameters.size || 1.0;
this.min = parameters.min || 0;
this.max = parameters.max || 1;
var attributes = {
classification: { type: "f", value: [] }
};
var uniforms = {
color: { type: "c", value: new THREE.Color( 0xffffff ) },
size: { type: "f", value: 1 }
};
this.setValues({
uniforms: uniforms,
attributes: attributes,
vertexShader: Potree.PointCloudClassificationMaterial.vs_points.join("\n"),
fragmentShader: Potree.PointCloudClassificationMaterial.fs_points_rgb.join("\n"),
vertexColors: THREE.VertexColors,
size: size,
alphaTest: 0.9
});
};
Potree.PointCloudClassificationMaterial.prototype = new THREE.ShaderMaterial();
Object.defineProperty(Potree.PointCloudClassificationMaterial.prototype, "size", {
get: function(){
return this.uniforms.size.value;
},
set: function(value){
this.uniforms.size.value = value;
}
});
Potree.PointCloudClassificationMaterial.vs_points = [
"attribute float classification; ",
"uniform float size; ",
"varying vec3 vColor; ",
" ",
"void main() { ",
" if(classification == 0.0){ ",
" vColor = vec3(0.5, 0.5, 0.5); ",
" }else if(classification == 1.0){ ",
" vColor = vec3(0.5, 0.5, 0.5); ",
" }else if(classification == 2.0){ ",
" vColor = vec3(1.0, 0.0, 0.0); ",
" }else if(classification == 3.0){ ",
" vColor = vec3(0.0, 1.0, 0.0); ",
" }else if(classification == 9.0){ ",
" vColor = vec3(0.0, 0.0, 1.0); ",
" }else{ ",
" vColor = vec3(0.0, 1.0, 0.0); ",
" } ",
" 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.PointCloudClassificationMaterial.fs_points_rgb = [
"varying vec3 vColor; ",
" ",
"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); ",
"} "];

View File

@ -120,7 +120,7 @@ onmessage = function(event){
// CLASSIFICATION
var classification = bufferView[i*pointSize+16];
var classification = bufferView[i*pointSize+15];
classifications[i] = classification;