fix picking on point clouds without normals

This commit is contained in:
mschuetz 2015-05-26 14:40:17 +02:00
parent a65e570a8a
commit 3abe4fde65
7 changed files with 20 additions and 32 deletions

View File

@ -1167,6 +1167,11 @@ Potree.BinaryLoader.prototype.parse = function(node, buffer){
}
geometry.addAttribute("indices", new THREE.BufferAttribute(new Float32Array(data.indices), 1));
if(!geometry.attributes.normal){
var buffer = new Float32Array(numPoints*3);
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3));
}
geometry.boundingBox = node.boundingBox;
node.geometry = geometry;
node.loaded = true;
@ -1387,7 +1392,8 @@ Potree.LasLazBatcher = function(node){
geometry.addAttribute('returnNumber', new THREE.BufferAttribute(new Float32Array(returnNumbers_f), 1));
geometry.addAttribute('pointSourceID', new THREE.BufferAttribute(new Float32Array(pointSourceIDs_f), 1));
geometry.addAttribute('indices', new THREE.BufferAttribute(indices, 1));
//geometry.boundingBox = node.boundingBox;
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3));
geometry.boundingBox = new THREE.Box3(mins, maxs);
node.boundingBox = geometry.boundingBox;
@ -4751,13 +4757,6 @@ Potree.PointCloudOctree.prototype.pick = function(renderer, camera, ray, params)
_gl.vertexAttribPointer( attributePointer, attributeSize, _gl.UNSIGNED_BYTE, true, 0, 0 );
_gl.uniform1f(material.program.uniforms.pcIndex, material.pcIndex);
// TODO: another ugly hack...disable normal attributes, if they're activated
var alNormal = _gl.getAttribLocation(program, "normal");
if(alNormal >= 0){
_gl.disableVertexAttribArray( alNormal );
}
}
renderer.renderBufferDirect(camera, [], null, material, geometry, object);
@ -8949,12 +8948,6 @@ Potree.PointCloudArena4D.prototype.pick = function(renderer, camera, ray, params
_gl.vertexAttribPointer( attributePointer, attributeSize, _gl.UNSIGNED_BYTE, true, 0, 0 );
_gl.uniform1f(material.program.uniforms.pcIndex, material.pcIndex);
// TODO: another ugly hack...disable normal attributes, if they're activated
var alNormal = _gl.getAttribLocation(program, "normal");
if(alNormal >= 0){
_gl.disableVertexAttribArray( alNormal );
}
}
renderer.renderBufferDirect(camera, [], null, material, geometry, object);
@ -9212,6 +9205,7 @@ Potree.PointCloudArena4DGeometryNode.prototype.load = function(){
geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
geometry.addAttribute("color", new THREE.BufferAttribute(colors, 3));
geometry.addAttribute("indices", new THREE.BufferAttribute(indices, 1));
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3));
scope.geometry = geometry;
scope.loaded = true;

File diff suppressed because one or more lines are too long

View File

@ -1067,13 +1067,6 @@ Potree.PointCloudOctree.prototype.pick = function(renderer, camera, ray, params)
_gl.vertexAttribPointer( attributePointer, attributeSize, _gl.UNSIGNED_BYTE, true, 0, 0 );
_gl.uniform1f(material.program.uniforms.pcIndex, material.pcIndex);
// TODO: another ugly hack...disable normal attributes, if they're activated
var alNormal = _gl.getAttribLocation(program, "normal");
if(alNormal >= 0){
_gl.disableVertexAttribArray( alNormal );
}
}
renderer.renderBufferDirect(camera, [], null, material, geometry, object);

View File

@ -579,12 +579,6 @@ Potree.PointCloudArena4D.prototype.pick = function(renderer, camera, ray, params
_gl.vertexAttribPointer( attributePointer, attributeSize, _gl.UNSIGNED_BYTE, true, 0, 0 );
_gl.uniform1f(material.program.uniforms.pcIndex, material.pcIndex);
// TODO: another ugly hack...disable normal attributes, if they're activated
var alNormal = _gl.getAttribLocation(program, "normal");
if(alNormal >= 0){
_gl.disableVertexAttribArray( alNormal );
}
}
renderer.renderBufferDirect(camera, [], null, material, geometry, object);

View File

@ -70,6 +70,7 @@ Potree.PointCloudArena4DGeometryNode.prototype.load = function(){
geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
geometry.addAttribute("color", new THREE.BufferAttribute(colors, 3));
geometry.addAttribute("indices", new THREE.BufferAttribute(indices, 1));
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3));
scope.geometry = geometry;
scope.loaded = true;

View File

@ -83,6 +83,11 @@ Potree.BinaryLoader.prototype.parse = function(node, buffer){
}
geometry.addAttribute("indices", new THREE.BufferAttribute(new Float32Array(data.indices), 1));
if(!geometry.attributes.normal){
var buffer = new Float32Array(numPoints*3);
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3));
}
geometry.boundingBox = node.boundingBox;
node.geometry = geometry;
node.loaded = true;

View File

@ -196,7 +196,8 @@ Potree.LasLazBatcher = function(node){
geometry.addAttribute('returnNumber', new THREE.BufferAttribute(new Float32Array(returnNumbers_f), 1));
geometry.addAttribute('pointSourceID', new THREE.BufferAttribute(new Float32Array(pointSourceIDs_f), 1));
geometry.addAttribute('indices', new THREE.BufferAttribute(indices, 1));
//geometry.boundingBox = node.boundingBox;
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3));
geometry.boundingBox = new THREE.Box3(mins, maxs);
node.boundingBox = geometry.boundingBox;