Tracking down the offset/scaling problems
This commit is contained in:
parent
553b775c11
commit
e8a22bff88
File diff suppressed because one or more lines are too long
14
build/potree/potree.min.js
vendored
14
build/potree/potree.min.js
vendored
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
@ -56,58 +56,54 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.getBoundingBox = function(){
|
||||
};
|
||||
|
||||
Potree.PointCloudGreyhoundGeometryNode.prototype.getURL = function(){
|
||||
|
||||
|
||||
//Determine what schema to ask the greyhound server for.
|
||||
var material = viewer.getMaterial();
|
||||
var availableAttributes = {};
|
||||
this.pcoGeometry.pointAttributes.forEach(function(item) {
|
||||
availableAttributes[item] = true;
|
||||
});
|
||||
|
||||
var schema = [{
|
||||
"name": "X",
|
||||
"size": 8,
|
||||
"type": "floating"
|
||||
"size": 4,
|
||||
"type": "signed"
|
||||
}, {
|
||||
"name": "Y",
|
||||
"size": 8,
|
||||
"type": "floating"
|
||||
"size": 4,
|
||||
"type": "signed"
|
||||
}, {
|
||||
"name": "Z",
|
||||
"size": 8,
|
||||
"type": "floating"
|
||||
"size": 4,
|
||||
"type": "signed"
|
||||
}];
|
||||
|
||||
if(material === Potree.PointColorType.RGB && availableAttributes.COLOR_PACKED){
|
||||
schema.push({
|
||||
"name": "Red",
|
||||
"size": 8,
|
||||
"type": "floating"
|
||||
});
|
||||
schema.push({
|
||||
"name": "Green",
|
||||
"size": 8,
|
||||
"type": "floating"
|
||||
});
|
||||
schema.push({
|
||||
"name": "Blue",
|
||||
"size": 8,
|
||||
"type": "floating"
|
||||
});
|
||||
} else if(material === Potree.PointColorType.INTENSITY && availableAttributes.INTENSITY){
|
||||
schema.push({
|
||||
"name": "Intensity",
|
||||
"size": 8,
|
||||
"type": "floating"
|
||||
});
|
||||
} else if(material === Potree.PointColorType.CLASSIFICATION && availableAttributes.CLASSIFICATION){
|
||||
schema.push({
|
||||
"name": "Classification",
|
||||
"size": 8,
|
||||
"type": "floating"
|
||||
});
|
||||
}
|
||||
this.pcoGeometry.pointAttributes.attributes.forEach(function(item) {
|
||||
if(material === Potree.PointColorType.RGB && item.name === Potree.PointAttributeNames.COLOR_PACKED) {
|
||||
schema.push({
|
||||
"name": "Red",
|
||||
"size": 1,
|
||||
"type": "unsigned"
|
||||
});
|
||||
schema.push({
|
||||
"name": "Green",
|
||||
"size": 1,
|
||||
"type": "unsigned"
|
||||
});
|
||||
schema.push({
|
||||
"name": "Blue",
|
||||
"size": 1,
|
||||
"type": "unsigned"
|
||||
});
|
||||
} else if(material === Potree.PointColorType.INTENSITY && item.name === Potree.PointAttributeNames.INTENSITY){
|
||||
schema.push({
|
||||
"name": "Intensity",
|
||||
"size": 2,
|
||||
"type": "unsigned"
|
||||
});
|
||||
} else if(material === Potree.PointColorType.CLASSIFICATION && item.name === Potree.PointAttributeNames.CLASSIFICATION){
|
||||
schema.push({
|
||||
"name": "Classification",
|
||||
"size": 1,
|
||||
"type": "unsigned"
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.pcoGeometry.pointAttributes.byteSize = 0;
|
||||
schema.forEach(function(entry) {
|
||||
@ -122,9 +118,10 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.getURL = function(){
|
||||
|
||||
var bb = this.boundingBox;
|
||||
var offset = this.pcoGeometry.offset;
|
||||
var boundsString = (bb.min.x-offset.x) + ',' + (bb.min.y-offset.y) + ',' + (bb.min.z-offset.z) + ',' + (bb.max.x-offset.x) + ',' + (bb.max.y-offset.y) + ',' + (bb.max.z-offset.z);
|
||||
//var boundsString = (bb.min.x-offset.x) + ',' + (bb.min.y-offset.y) + ',' + (bb.min.z-offset.z) + ',' + (bb.max.x-offset.x) + ',' + (bb.max.y-offset.y) + ',' + (bb.max.z-offset.z);
|
||||
var boundsString = (bb.min.x) + ',' + (bb.min.y) + ',' + (bb.min.z) + ',' + (bb.max.x) + ',' + (bb.max.y) + ',' + (bb.max.z);
|
||||
|
||||
var url = ''+this.pcoGeometry.serverURL + 'read?depth=' + this.level+this.pcoGeometry.baseDepth + '&bounds=[' + boundsString + ']' + '&schema='+JSON.stringify(schema);
|
||||
var url = ''+this.pcoGeometry.serverURL + 'read?depth=' + (this.level+this.pcoGeometry.baseDepth) + '&bounds=[' + boundsString + ']' + '&schema='+JSON.stringify(schema); //+'&scale=' +this.pcoGeometry.scale;
|
||||
|
||||
return url;
|
||||
};
|
||||
@ -262,7 +259,8 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.loadHierachyThenPoints = functi
|
||||
var depthEnd = depthBegin + node.pcoGeometry.hierarchyStepSize + 1;
|
||||
var bb = this.boundingBox;
|
||||
var offset = node.pcoGeometry.offset;
|
||||
var boundsString = (bb.min.x-offset.x) + ',' + (bb.min.y-offset.y) + ',' + (bb.min.z-offset.z) + ',' + (bb.max.x-offset.x) + ',' + (bb.max.y-offset.y) + ',' + (bb.max.z-offset.z);
|
||||
// var boundsString = (bb.min.x-offset.x) + ',' + (bb.min.y-offset.y) + ',' + (bb.min.z-offset.z) + ',' + (bb.max.x-offset.x) + ',' + (bb.max.y-offset.y) + ',' + (bb.max.z-offset.z);
|
||||
var boundsString = (bb.min.x) + ',' + (bb.min.y) + ',' + (bb.min.z) + ',' + (bb.max.x) + ',' + (bb.max.y) + ',' + (bb.max.z);
|
||||
|
||||
var hurl = ''+this.pcoGeometry.serverURL + 'hierarchy?bounds=[' + boundsString + ']' + '&depthBegin=' + depthBegin + '&depthEnd=' + depthEnd;
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
@ -107,6 +107,7 @@ Potree.GreyhoundBinaryLoader.prototype.parse = function(node, buffer){
|
||||
pointAttributes: pointAttributes,
|
||||
version: this.version.version,
|
||||
min: [ node.boundingBox.min.x, node.boundingBox.min.y, node.boundingBox.min.z ],
|
||||
max: [ node.boundingBox.max.x, node.boundingBox.max.y, node.boundingBox.max.z ],
|
||||
offset: [node.pcoGeometry.offset.x, node.pcoGeometry.offset.y, node.pcoGeometry.offset.z],
|
||||
scale: this.scale
|
||||
};
|
||||
|
||||
@ -44,7 +44,7 @@ Potree.GreyhoundLoader.load = function load(url, callback) {
|
||||
pgg.spacing = (bounds[3]-bounds[0])/2^baseDepth;
|
||||
pgg.baseDepth = baseDepth;
|
||||
pgg.hierarchyStepSize = HIERARCHY_STEP_SIZE;
|
||||
pgg.pointAttributes = ['POSITION_CARTESIAN'];
|
||||
var attributes = ['POSITION_CARTESIAN'];
|
||||
|
||||
var red = false;
|
||||
var green = false;
|
||||
@ -52,10 +52,10 @@ Potree.GreyhoundLoader.load = function load(url, callback) {
|
||||
|
||||
greyhoundInfo.schema.forEach(function(entry) {
|
||||
if (entry.name === 'Intensity') {
|
||||
pgg.pointAttributes.push('INTENSITY');
|
||||
attributes.push('INTENSITY');
|
||||
}
|
||||
if (entry.name === 'Classification') {
|
||||
pgg.pointAttributes.push('CLASSIFICATION');
|
||||
attributes.push('CLASSIFICATION');
|
||||
}
|
||||
|
||||
if (entry.name === 'Red') {
|
||||
@ -70,7 +70,7 @@ Potree.GreyhoundLoader.load = function load(url, callback) {
|
||||
});
|
||||
|
||||
if (red&&green&&blue) {
|
||||
pgg.pointAttributes.push('COLOR_PACKED');
|
||||
attributes.push('COLOR_PACKED');
|
||||
}
|
||||
|
||||
var min = new THREE.Vector3(bounds[0], bounds[1], bounds[2]);
|
||||
@ -82,11 +82,11 @@ Potree.GreyhoundLoader.load = function load(url, callback) {
|
||||
|
||||
offset.set(-min.x, -min.y, -min.z);
|
||||
|
||||
boundingBox.min.add(offset);
|
||||
boundingBox.max.add(offset);
|
||||
// boundingBox.min.add(offset);
|
||||
// boundingBox.max.add(offset);
|
||||
|
||||
tightBoundingBox.min.add(offset);
|
||||
tightBoundingBox.max.add(offset);
|
||||
// tightBoundingBox.min.add(offset);
|
||||
// tightBoundingBox.max.add(offset);
|
||||
|
||||
pgg.projection = greyhoundInfo.srs;
|
||||
pgg.boundingBox = boundingBox;
|
||||
@ -97,7 +97,7 @@ Potree.GreyhoundLoader.load = function load(url, callback) {
|
||||
pgg.scale = SCALE; //greyhoundInfo.scale;
|
||||
|
||||
pgg.loader = new Potree.GreyhoundBinaryLoader(version, boundingBox, pgg.scale);
|
||||
pgg.pointAttributes = new Potree.PointAttributes(pgg.pointAttributes);
|
||||
pgg.pointAttributes = new Potree.PointAttributes(attributes);
|
||||
|
||||
var nodes = {};
|
||||
|
||||
|
||||
@ -102,7 +102,6 @@ Potree.PointAttribute.NORMAL = new Potree.PointAttribute(
|
||||
*
|
||||
*/
|
||||
Potree.PointAttributes = function(pointAttributes){
|
||||
debugger;
|
||||
this.attributes = [];
|
||||
this.byteSize = 0;
|
||||
this.size = 0;
|
||||
@ -119,14 +118,12 @@ debugger;
|
||||
};
|
||||
|
||||
Potree.PointAttributes.prototype.add = function(pointAttribute){
|
||||
debugger;
|
||||
this.attributes.push(pointAttribute);
|
||||
this.byteSize += pointAttribute.byteSize;
|
||||
this.size++;
|
||||
};
|
||||
|
||||
Potree.PointAttributes.prototype.hasColors = function(){
|
||||
debugger;
|
||||
for(var name in this.attributes){
|
||||
var pointAttribute = this.attributes[name];
|
||||
if(pointAttribute.name === Potree.PointAttributeNames.COLOR_PACKED){
|
||||
@ -138,7 +135,6 @@ debugger;
|
||||
};
|
||||
|
||||
Potree.PointAttributes.prototype.hasNormals = function(){
|
||||
debugger;
|
||||
for(var name in this.attributes){
|
||||
var pointAttribute = this.attributes[name];
|
||||
if(
|
||||
|
||||
@ -46,6 +46,7 @@ onmessage = function(event){
|
||||
var tightBoxMax = [ Number.NEGATIVE_INFINITY , Number.NEGATIVE_INFINITY , Number.NEGATIVE_INFINITY ];
|
||||
|
||||
var attributeBuffers = {};
|
||||
debugger;
|
||||
|
||||
var offset = 0;
|
||||
for(var i = 0; i < pointAttributes.attributes.length; i++){
|
||||
@ -58,6 +59,8 @@ onmessage = function(event){
|
||||
|
||||
for(var j = 0; j < numPoints; j++){
|
||||
if(version.newerThan("1.3")){
|
||||
console.log(('x: ' + cv.getUint32(offset + j*pointAttributes.byteSize+0) * scale) + min[0]);
|
||||
|
||||
positions[3*j+0] = (cv.getUint32(offset + j*pointAttributes.byteSize+0) * scale) + min[0];
|
||||
positions[3*j+1] = (cv.getUint32(offset + j*pointAttributes.byteSize+4) * scale) + min[1];
|
||||
positions[3*j+2] = (cv.getUint32(offset + j*pointAttributes.byteSize+8) * scale) + min[2];
|
||||
|
||||
@ -35,6 +35,7 @@ Potree = {};
|
||||
|
||||
onmessage = function(event){
|
||||
var NUM_POINTS_BYTE_SIZE = 4;
|
||||
// debugger;
|
||||
|
||||
var buffer = event.data.buffer;
|
||||
var pointAttributes = event.data.pointAttributes;
|
||||
@ -42,15 +43,17 @@ onmessage = function(event){
|
||||
var cv = new CustomView(buffer);
|
||||
var version = new Potree.Version(event.data.version);
|
||||
var min = event.data.min;
|
||||
var max = event.data.max;
|
||||
var nodeOffset = event.data.offset;
|
||||
var scale = event.data.scale;
|
||||
var tightBoxMin = [ Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY];
|
||||
var tightBoxMax = [ Number.NEGATIVE_INFINITY , Number.NEGATIVE_INFINITY , Number.NEGATIVE_INFINITY ];
|
||||
|
||||
var extent = {'x': max[0] - min[0], 'y': max[1] - min[1], 'z': max[2] - min[2]};
|
||||
|
||||
var attributeBuffers = {};
|
||||
|
||||
var offset = 0;
|
||||
debugger;
|
||||
|
||||
for(var i = 0; i < pointAttributes.attributes.length; i++){
|
||||
var pointAttribute = pointAttributes.attributes[i];
|
||||
@ -61,15 +64,9 @@ onmessage = function(event){
|
||||
var positions = new Float32Array(buff);
|
||||
|
||||
for(var j = 0; j < numPoints; j++){
|
||||
if(version.newerThan("1.3")){
|
||||
positions[3*j+0] = (cv.getUint32(offset + j*pointAttributes.byteSize+0) * scale) + min[0];
|
||||
positions[3*j+1] = (cv.getUint32(offset + j*pointAttributes.byteSize+4) * scale) + min[1];
|
||||
positions[3*j+2] = (cv.getUint32(offset + j*pointAttributes.byteSize+8) * scale) + min[2];
|
||||
}else{
|
||||
positions[3*j+0] = cv.getFloat(j*pointAttributes.byteSize+0) + nodeOffset[0];
|
||||
positions[3*j+1] = cv.getFloat(j*pointAttributes.byteSize+4) + nodeOffset[1];
|
||||
positions[3*j+2] = cv.getFloat(j*pointAttributes.byteSize+8) + nodeOffset[2];
|
||||
}
|
||||
positions[3*j+0] = (cv.getUint32(offset + j*pointAttributes.byteSize+0) - min[0]) / extent.x;
|
||||
positions[3*j+1] = (cv.getUint32(offset + j*pointAttributes.byteSize+4) - min[1]) / extent.y;
|
||||
positions[3*j+2] = (cv.getUint32(offset + j*pointAttributes.byteSize+8) - min[2]) / extent.z;
|
||||
|
||||
tightBoxMin[0] = Math.min(tightBoxMin[0], positions[3*j+0]);
|
||||
tightBoxMin[1] = Math.min(tightBoxMin[1], positions[3*j+1]);
|
||||
@ -79,6 +76,7 @@ onmessage = function(event){
|
||||
tightBoxMax[1] = Math.max(tightBoxMax[1], positions[3*j+1]);
|
||||
tightBoxMax[2] = Math.max(tightBoxMax[2], positions[3*j+2]);
|
||||
}
|
||||
// debugger;
|
||||
|
||||
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user