compute mean for each node
This commit is contained in:
parent
8c779f32e2
commit
86f4f0157f
@ -132,11 +132,20 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{
|
||||
material.program.getUniforms().map.pcIndex.setValue(_this.getContext(), node.pcIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
//{ // DEBUG
|
||||
// let sg = new THREE.SphereGeometry(1, 16, 16);
|
||||
// let sm = new THREE.MeshNormalMaterial();
|
||||
// let s = new THREE.Mesh(sg, sm);
|
||||
// s.scale.set(5, 5, 5);
|
||||
// s.position.copy(geometryNode.mean)
|
||||
// .add(this.position)
|
||||
// .add(geometryNode.boundingBox.min);
|
||||
//
|
||||
// viewer.scene.scene.add(s);
|
||||
//}
|
||||
|
||||
node.geometryNode = geometryNode;
|
||||
node.sceneNode = sceneNode;
|
||||
node.pointcloud = this;
|
||||
|
||||
@ -101,10 +101,8 @@ Potree.BinaryLoader.prototype.parse = function(node, buffer){
|
||||
}
|
||||
|
||||
geometry.boundingBox = node.boundingBox;
|
||||
//geometry.boundingBox = tightBoundingBox;
|
||||
node.geometry = geometry;
|
||||
//node.boundingBox = tightBoundingBox;
|
||||
//node.position.copy(node.boundingBox.min);
|
||||
node.mean = new THREE.Vector3(...data.mean);
|
||||
node.tightBoundingBox = tightBoundingBox;
|
||||
node.loaded = true;
|
||||
node.loading = false;
|
||||
|
||||
@ -174,14 +174,12 @@ Potree.LasLazBatcher = class LasLazBatcher{
|
||||
//let indices = new ArrayBuffer(numPoints*4);
|
||||
//let iIndices = new Uint32Array(indices);
|
||||
|
||||
let box = new THREE.Box3();
|
||||
|
||||
let fPositions = new Float32Array(positions);
|
||||
for(let i = 0; i < numPoints; i++){
|
||||
//iIndices[i] = i;
|
||||
|
||||
box.expandByPoint(new THREE.Vector3(fPositions[3*i+0], fPositions[3*i+1], fPositions[3*i+2]));
|
||||
}
|
||||
//let box = new THREE.Box3();
|
||||
//
|
||||
//let fPositions = new Float32Array(positions);
|
||||
//for(let i = 0; i < numPoints; i++){
|
||||
// box.expandByPoint(new THREE.Vector3(fPositions[3*i+0], fPositions[3*i+1], fPositions[3*i+2]));
|
||||
//}
|
||||
|
||||
geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(positions), 3));
|
||||
geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true));
|
||||
@ -190,7 +188,6 @@ Potree.LasLazBatcher = class LasLazBatcher{
|
||||
geometry.addAttribute('returnNumber', new THREE.BufferAttribute(returnNumbers, 1));
|
||||
geometry.addAttribute('numberOfReturns', new THREE.BufferAttribute(numberOfReturns, 1));
|
||||
geometry.addAttribute('pointSourceID', new THREE.BufferAttribute(pointSourceIDs, 1));
|
||||
//geometry.addAttribute('indices', new THREE.BufferAttribute(indices, 1));
|
||||
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3));
|
||||
|
||||
let indicesAttribute = new THREE.Uint8BufferAttribute(e.data.indices, 4);
|
||||
@ -209,6 +206,7 @@ Potree.LasLazBatcher = class LasLazBatcher{
|
||||
this.node.loaded = true;
|
||||
this.node.loading = false;
|
||||
this.node.pcoGeometry.numNodesLoading--;
|
||||
this.node.mean = new THREE.Vector3(...e.data.mean);
|
||||
|
||||
Potree.workerPool.returnWorker(workerPath, worker);
|
||||
};
|
||||
|
||||
@ -50,6 +50,8 @@ onmessage = function(event){
|
||||
let tightBoxMax = [ Number.NEGATIVE_INFINITY , Number.NEGATIVE_INFINITY , Number.NEGATIVE_INFINITY ];
|
||||
|
||||
let attributeBuffers = {};
|
||||
|
||||
let mean = [0, 0, 0];
|
||||
|
||||
let offset = 0;
|
||||
for(let i = 0; i < pointAttributes.attributes.length; i++){
|
||||
@ -62,15 +64,26 @@ onmessage = function(event){
|
||||
|
||||
let startPos = new Date().getTime();
|
||||
for(let j = 0; j < numPoints; j++){
|
||||
|
||||
let x, y, z;
|
||||
|
||||
if(version.newerThan("1.3")){
|
||||
positions[3*j+0] = (cv.getUint32(offset + j*pointAttributes.byteSize+0, true) * scale);
|
||||
positions[3*j+1] = (cv.getUint32(offset + j*pointAttributes.byteSize+4, true) * scale);
|
||||
positions[3*j+2] = (cv.getUint32(offset + j*pointAttributes.byteSize+8, true) * scale);
|
||||
x = (cv.getUint32(offset + j*pointAttributes.byteSize+0, true) * scale);
|
||||
y = (cv.getUint32(offset + j*pointAttributes.byteSize+4, true) * scale);
|
||||
z = (cv.getUint32(offset + j*pointAttributes.byteSize+8, true) * scale);
|
||||
}else{
|
||||
positions[3*j+0] = cv.getFloat32(j*pointAttributes.byteSize+0, true) + nodeOffset[0];
|
||||
positions[3*j+1] = cv.getFloat32(j*pointAttributes.byteSize+4, true) + nodeOffset[1];
|
||||
positions[3*j+2] = cv.getFloat32(j*pointAttributes.byteSize+8, true) + nodeOffset[2];
|
||||
x = cv.getFloat32(j*pointAttributes.byteSize+0, true) + nodeOffset[0];
|
||||
y = cv.getFloat32(j*pointAttributes.byteSize+4, true) + nodeOffset[1];
|
||||
z = cv.getFloat32(j*pointAttributes.byteSize+8, true) + nodeOffset[2];
|
||||
}
|
||||
|
||||
positions[3*j+0] = x;
|
||||
positions[3*j+1] = y;
|
||||
positions[3*j+2] = z;
|
||||
|
||||
mean[0] += x / numPoints;
|
||||
mean[1] += y / numPoints;
|
||||
mean[2] += z / numPoints;
|
||||
|
||||
tightBoxMin[0] = Math.min(tightBoxMin[0], positions[3*j+0]);
|
||||
tightBoxMin[1] = Math.min(tightBoxMin[1], positions[3*j+1]);
|
||||
@ -224,6 +237,7 @@ onmessage = function(event){
|
||||
}
|
||||
|
||||
let message = {
|
||||
mean: mean,
|
||||
attributeBuffers: attributeBuffers,
|
||||
tightBoundingBox: { min: tightBoxMin, max: tightBoxMax },
|
||||
indices: indices
|
||||
|
||||
@ -98,6 +98,8 @@ onmessage = function(event){
|
||||
var attributeBuffers = {};
|
||||
var offset = 0;
|
||||
var pointSize = pointAttributes.byteSize;
|
||||
|
||||
let mean = [0, 0, 0];
|
||||
|
||||
var logged = 0;
|
||||
|
||||
@ -121,11 +123,10 @@ onmessage = function(event){
|
||||
positions[3*j+0] = x;
|
||||
positions[3*j+1] = y;
|
||||
positions[3*j+2] = z;
|
||||
|
||||
//if(j < 2){
|
||||
// console.log("u:" + ux + ", " + uy + ", " + uz);
|
||||
// console.log("f:" + x + ", " + y + ", " + z);
|
||||
//}
|
||||
|
||||
mean[0] += x / numPoints;
|
||||
mean[1] += y / numPoints;
|
||||
mean[2] += z / numPoints;
|
||||
|
||||
tightBoxMin[0] = Math.min(tightBoxMin[0], positions[3*j+0]);
|
||||
tightBoxMin[1] = Math.min(tightBoxMin[1], positions[3*j+1]);
|
||||
@ -271,6 +272,7 @@ onmessage = function(event){
|
||||
}
|
||||
|
||||
var message = {
|
||||
mean: mean,
|
||||
attributeBuffers: attributeBuffers,
|
||||
tightBoundingBox: { min: tightBoxMin, max: tightBoxMax },
|
||||
indices: indices
|
||||
|
||||
@ -90,6 +90,8 @@ onmessage = function(event){
|
||||
max: [ Number.NEGATIVE_INFINITY , Number.NEGATIVE_INFINITY , Number.NEGATIVE_INFINITY ]
|
||||
};
|
||||
|
||||
let mean = [0, 0, 0];
|
||||
|
||||
|
||||
// temp arrays seem to be significantly faster than DataViews
|
||||
// at the moment: http://jsperf.com/dataview-vs-temporary-float64array
|
||||
@ -114,9 +116,17 @@ onmessage = function(event){
|
||||
tempUint8[3] = bufferView[i*pointSize+11];
|
||||
var z = tempInt32[0];
|
||||
|
||||
positions[3*i+0] = x * scale[0] + offset[0] - event.data.mins[0];
|
||||
positions[3*i+1] = y * scale[1] + offset[1] - event.data.mins[1];
|
||||
positions[3*i+2] = z * scale[2] + offset[2] - event.data.mins[2];
|
||||
x = x * scale[0] + offset[0] - event.data.mins[0];
|
||||
y = y * scale[1] + offset[1] - event.data.mins[1];
|
||||
z = z * scale[2] + offset[2] - event.data.mins[2];
|
||||
|
||||
positions[3*i+0] = x;
|
||||
positions[3*i+1] = y;
|
||||
positions[3*i+2] = z;
|
||||
|
||||
mean[0] += x / numPoints;
|
||||
mean[1] += y / numPoints;
|
||||
mean[2] += z / numPoints;
|
||||
|
||||
tightBoundingBox.min[0] = Math.min(tightBoundingBox.min[0], positions[3*i+0]);
|
||||
tightBoundingBox.min[1] = Math.min(tightBoundingBox.min[1], positions[3*i+1]);
|
||||
@ -176,6 +186,7 @@ onmessage = function(event){
|
||||
}
|
||||
|
||||
var message = {
|
||||
mean: mean,
|
||||
position: pBuff,
|
||||
color: cBuff,
|
||||
intensity: iBuff,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user