move PointAttribute* classes to Potree namespace

This commit is contained in:
mschuetz 2015-07-13 21:17:02 +02:00
parent e40022d3fd
commit 24cd5457fb
8 changed files with 159 additions and 183 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

@ -326,18 +326,20 @@ void main() {
for(var i = 0; i < attributes.attributes.length; i++){
var attribute = attributes.attributes[i];
if(attribute === PointAttribute.COLOR_PACKED){
if(attribute === Potree.PointAttribute.COLOR_PACKED){
options.push("RGB");
}else if(attribute === PointAttribute.INTENSITY){
}else if(attribute === Potree.PointAttribute.INTENSITY){
options.push("Intensity");
options.push("Intensity Gradient");
}else if(attribute === PointAttribute.CLASSIFICATION){
}else if(attribute === Potree.PointAttribute.CLASSIFICATION){
options.push("Classification");
}else if(attribute === PointAttribute.NORMAL_SPHEREMAPPED || attribute === PointAttribute.NORMAL_OCT16){
options.push("Phong");
options.push("Normal");
}
}
if(attributes.hasNormals()){
options.push("Phong");
options.push("Normal");
}
options.push("Height");
options.push("Tree Depth");
}

View File

@ -68,19 +68,19 @@ Potree.BinaryLoader.prototype.parse = function(node, buffer){
var attribute = buffers[property].attribute;
var numElements = attribute.numElements;
if(parseInt(property) === PointAttributeNames.POSITION_CARTESIAN){
if(parseInt(property) === Potree.PointAttributeNames.POSITION_CARTESIAN){
geometry.addAttribute("position", new THREE.BufferAttribute(new Float32Array(buffer), 3));
}else if(parseInt(property) === PointAttributeNames.COLOR_PACKED){
}else if(parseInt(property) === Potree.PointAttributeNames.COLOR_PACKED){
geometry.addAttribute("color", new THREE.BufferAttribute(new Float32Array(buffer), 3));
}else if(parseInt(property) === PointAttributeNames.INTENSITY){
}else if(parseInt(property) === Potree.PointAttributeNames.INTENSITY){
geometry.addAttribute("intensity", new THREE.BufferAttribute(new Float32Array(buffer), 1));
}else if(parseInt(property) === PointAttributeNames.CLASSIFICATION){
}else if(parseInt(property) === Potree.PointAttributeNames.CLASSIFICATION){
geometry.addAttribute("classification", new THREE.BufferAttribute(new Float32Array(buffer), 1));
}else if(parseInt(property) === PointAttributeNames.NORMAL_SPHEREMAPPED){
}else if(parseInt(property) === Potree.PointAttributeNames.NORMAL_SPHEREMAPPED){
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3));
}else if(parseInt(property) === PointAttributeNames.NORMAL_OCT16){
}else if(parseInt(property) === Potree.PointAttributeNames.NORMAL_OCT16){
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3));
}else if(parseInt(property) === PointAttributeNames.NORMAL){
}else if(parseInt(property) === Potree.PointAttributeNames.NORMAL){
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3));
}
}

View File

@ -72,7 +72,7 @@ Potree.POCLoader.load = function load(url, callback) {
pco.loader = new Potree.LasLazLoader(fMno.version);
}else{
pco.loader = new Potree.BinaryLoader(fMno.version, boundingBox, fMno.scale);
pco.pointAttributes = new PointAttributes(pco.pointAttributes);
pco.pointAttributes = new Potree.PointAttributes(pco.pointAttributes);
}
var nodes = {};
@ -128,10 +128,10 @@ Potree.POCLoader.load = function load(url, callback) {
Potree.POCLoader.loadPointAttributes = function(mno){
var fpa = mno.pointAttributes;
var pa = new PointAttributes();
var pa = new Potree.PointAttributes();
for(var i = 0; i < fpa.length; i++){
var pointAttribute = PointAttribute[fpa[i]];
var pointAttribute = Potree.PointAttribute[fpa[i]];
pa.add(pointAttribute);
}

View File

@ -1,30 +1,24 @@
Potree.PointAttributeNames = {};
//function PointAttributeNames(){
//
//}
var PointAttributeNames = {};
PointAttributeNames.POSITION_CARTESIAN = 0; // float x, y, z;
PointAttributeNames.COLOR_PACKED = 1; // byte r, g, b, a; I = [0,1]
PointAttributeNames.COLOR_FLOATS_1 = 2; // float r, g, b; I = [0,1]
PointAttributeNames.COLOR_FLOATS_255 = 3; // float r, g, b; I = [0,255]
PointAttributeNames.NORMAL_FLOATS = 4; // float x, y, z;
PointAttributeNames.FILLER = 5;
PointAttributeNames.INTENSITY = 6;
PointAttributeNames.CLASSIFICATION = 7;
PointAttributeNames.NORMAL_SPHEREMAPPED = 8;
PointAttributeNames.NORMAL_OCT16 = 9;
PointAttributeNames.NORMAL = 10;
Potree.PointAttributeNames.POSITION_CARTESIAN = 0; // float x, y, z;
Potree.PointAttributeNames.COLOR_PACKED = 1; // byte r, g, b, a; I = [0,1]
Potree.PointAttributeNames.COLOR_FLOATS_1 = 2; // float r, g, b; I = [0,1]
Potree.PointAttributeNames.COLOR_FLOATS_255 = 3; // float r, g, b; I = [0,255]
Potree.PointAttributeNames.NORMAL_FLOATS = 4; // float x, y, z;
Potree.PointAttributeNames.FILLER = 5;
Potree.PointAttributeNames.INTENSITY = 6;
Potree.PointAttributeNames.CLASSIFICATION = 7;
Potree.PointAttributeNames.NORMAL_SPHEREMAPPED = 8;
Potree.PointAttributeNames.NORMAL_OCT16 = 9;
Potree.PointAttributeNames.NORMAL = 10;
/**
* Some types of possible point attribute data formats
*
* @class
*/
var PointAttributeTypes = {
Potree.PointAttributeTypes = {
DATA_TYPE_DOUBLE : {ordinal : 0, size: 8},
DATA_TYPE_FLOAT : {ordinal : 1, size: 4},
DATA_TYPE_INT8 : {ordinal : 2, size: 1},
@ -38,8 +32,8 @@ var PointAttributeTypes = {
};
var i = 0;
for(var obj in PointAttributeTypes){
PointAttributeTypes[i] = PointAttributeTypes[obj];
for(var obj in Potree.PointAttributeTypes){
Potree.PointAttributeTypes[i] = Potree.PointAttributeTypes[obj];
i++;
}
@ -52,54 +46,54 @@ for(var obj in PointAttributeTypes){
* @param size
* @returns
*/
function PointAttribute(name, type, numElements){
Potree.PointAttribute = function(name, type, numElements){
this.name = name;
this.type = type;
this.numElements = numElements;
this.byteSize = this.numElements * this.type.size;
}
PointAttribute.POSITION_CARTESIAN = new PointAttribute(
PointAttributeNames.POSITION_CARTESIAN,
PointAttributeTypes.DATA_TYPE_FLOAT, 3);
Potree.PointAttribute.POSITION_CARTESIAN = new Potree.PointAttribute(
Potree.PointAttributeNames.POSITION_CARTESIAN,
Potree.PointAttributeTypes.DATA_TYPE_FLOAT, 3);
PointAttribute.RGBA_PACKED = new PointAttribute(
PointAttributeNames.COLOR_PACKED,
PointAttributeTypes.DATA_TYPE_INT8, 4);
Potree.PointAttribute.RGBA_PACKED = new Potree.PointAttribute(
Potree.PointAttributeNames.COLOR_PACKED,
Potree.PointAttributeTypes.DATA_TYPE_INT8, 4);
PointAttribute.COLOR_PACKED = PointAttribute.RGBA_PACKED;
Potree.PointAttribute.COLOR_PACKED = Potree.PointAttribute.RGBA_PACKED;
PointAttribute.RGB_PACKED = new PointAttribute(
PointAttributeNames.COLOR_PACKED,
PointAttributeTypes.DATA_TYPE_INT8, 3);
Potree.PointAttribute.RGB_PACKED = new Potree.PointAttribute(
Potree.PointAttributeNames.COLOR_PACKED,
Potree.PointAttributeTypes.DATA_TYPE_INT8, 3);
PointAttribute.NORMAL_FLOATS = new PointAttribute(
PointAttributeNames.NORMAL_FLOATS,
PointAttributeTypes.DATA_TYPE_FLOAT, 3);
Potree.PointAttribute.NORMAL_FLOATS = new Potree.PointAttribute(
Potree.PointAttributeNames.NORMAL_FLOATS,
Potree.PointAttributeTypes.DATA_TYPE_FLOAT, 3);
PointAttribute.FILLER_1B = new PointAttribute(
PointAttributeNames.FILLER,
PointAttributeTypes.DATA_TYPE_UINT8, 1);
Potree.PointAttribute.FILLER_1B = new Potree.PointAttribute(
Potree.PointAttributeNames.FILLER,
Potree.PointAttributeTypes.DATA_TYPE_UINT8, 1);
PointAttribute.INTENSITY = new PointAttribute(
PointAttributeNames.INTENSITY,
PointAttributeTypes.DATA_TYPE_UINT16, 1);
Potree.PointAttribute.INTENSITY = new Potree.PointAttribute(
Potree.PointAttributeNames.INTENSITY,
Potree.PointAttributeTypes.DATA_TYPE_UINT16, 1);
PointAttribute.CLASSIFICATION = new PointAttribute(
PointAttributeNames.CLASSIFICATION,
PointAttributeTypes.DATA_TYPE_UINT8, 1);
Potree.PointAttribute.CLASSIFICATION = new Potree.PointAttribute(
Potree.PointAttributeNames.CLASSIFICATION,
Potree.PointAttributeTypes.DATA_TYPE_UINT8, 1);
PointAttribute.NORMAL_SPHEREMAPPED = new PointAttribute(
PointAttributeNames.NORMAL_SPHEREMAPPED,
PointAttributeTypes.DATA_TYPE_UINT8, 2);
Potree.PointAttribute.NORMAL_SPHEREMAPPED = new Potree.PointAttribute(
Potree.PointAttributeNames.NORMAL_SPHEREMAPPED,
Potree.PointAttributeTypes.DATA_TYPE_UINT8, 2);
PointAttribute.NORMAL_OCT16 = new PointAttribute(
PointAttributeNames.NORMAL_OCT16,
PointAttributeTypes.DATA_TYPE_UINT8, 2);
Potree.PointAttribute.NORMAL_OCT16 = new Potree.PointAttribute(
Potree.PointAttributeNames.NORMAL_OCT16,
Potree.PointAttributeTypes.DATA_TYPE_UINT8, 2);
PointAttribute.NORMAL = new PointAttribute(
PointAttributeNames.NORMAL,
PointAttributeTypes.DATA_TYPE_FLOAT, 3);
Potree.PointAttribute.NORMAL = new Potree.PointAttribute(
Potree.PointAttributeNames.NORMAL,
Potree.PointAttributeTypes.DATA_TYPE_FLOAT, 3);
/**
* Ordered list of PointAttributes used to identify how points are aligned in a buffer.
@ -107,22 +101,15 @@ PointAttribute.NORMAL = new PointAttribute(
* @class
*
*/
function PointAttributes(pointAttributes){
Potree.PointAttributes = function(pointAttributes){
this.attributes = new Array();
this.byteSize = 0;
this.size = 0;
if(pointAttributes != null){
// does not work in chrome v24
// for(var pointAttribute of pointAttributes){
// this.attributes.push(pointAttribute);
// this.byteSize += pointAttribute.byteSize;
// this.size++;
// }
if(pointAttributes != null){
for(var i = 0; i < pointAttributes.length; i++){
var pointAttributeName = pointAttributes[i];
var pointAttribute = PointAttribute[pointAttributeName];
var pointAttribute = Potree.PointAttribute[pointAttributeName];
this.attributes.push(pointAttribute);
this.byteSize += pointAttribute.byteSize;
this.size++;
@ -130,16 +117,16 @@ function PointAttributes(pointAttributes){
}
}
PointAttributes.prototype.add = function(pointAttribute){
Potree.PointAttributes.prototype.add = function(pointAttribute){
this.attributes.push(pointAttribute);
this.byteSize += pointAttribute.byteSize;
this.size++;
};
PointAttributes.prototype.hasColors = function(){
Potree.PointAttributes.prototype.hasColors = function(){
for(var name in this.attributes){
var pointAttribute = this.attributes[name];
if(pointAttribute.name === PointAttributeNames.COLOR_PACKED){
if(pointAttribute.name === Potree.PointAttributeNames.COLOR_PACKED){
return true;
}
}
@ -147,14 +134,14 @@ PointAttributes.prototype.hasColors = function(){
return false;
};
PointAttributes.prototype.hasNormals = function(){
Potree.PointAttributes.prototype.hasNormals = function(){
for(var name in this.attributes){
var pointAttribute = this.attributes[name];
if(
pointAttribute === PointAttribute.NORMAL_SPHEREMAPPED ||
pointAttribute === PointAttribute.NORMAL_FLOATS ||
pointAttribute === PointAttribute.NORMAL ||
pointAttribute === PointAttribute.NORMAL_OCT16){
pointAttribute === Potree.PointAttribute.NORMAL_SPHEREMAPPED ||
pointAttribute === Potree.PointAttribute.NORMAL_FLOATS ||
pointAttribute === Potree.PointAttribute.NORMAL ||
pointAttribute === Potree.PointAttribute.NORMAL_OCT16){
return true;
}
}

View File

@ -49,7 +49,7 @@ onmessage = function(event){
for(var i = 0; i < pointAttributes.attributes.length; i++){
var pointAttribute = pointAttributes.attributes[i];
if(pointAttribute.name === PointAttribute.POSITION_CARTESIAN.name){
if(pointAttribute.name === Potree.PointAttribute.POSITION_CARTESIAN.name){
var buff = new ArrayBuffer(numPoints*4*3);
var positions = new Float32Array(buff);
@ -68,7 +68,7 @@ onmessage = function(event){
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}else if(pointAttribute.name === PointAttribute.COLOR_PACKED.name){
}else if(pointAttribute.name === Potree.PointAttribute.COLOR_PACKED.name){
var buff = new ArrayBuffer(numPoints*4*3);
var colors = new Float32Array(buff);
@ -81,7 +81,7 @@ onmessage = function(event){
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}else if(pointAttribute.name === PointAttribute.INTENSITY.name){
}else if(pointAttribute.name === Potree.PointAttribute.INTENSITY.name){
var buff = new ArrayBuffer(numPoints*4);
var intensities = new Float32Array(buff);
@ -93,7 +93,7 @@ onmessage = function(event){
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}else if(pointAttribute.name === PointAttribute.CLASSIFICATION.name){
}else if(pointAttribute.name === Potree.PointAttribute.CLASSIFICATION.name){
var buff = new ArrayBuffer(numPoints*4);
var classifications = new Float32Array(buff);
@ -105,7 +105,7 @@ onmessage = function(event){
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}else if(pointAttribute.name === PointAttribute.NORMAL_SPHEREMAPPED.name){
}else if(pointAttribute.name === Potree.PointAttribute.NORMAL_SPHEREMAPPED.name){
var buff = new ArrayBuffer(numPoints*4*3);
var normals = new Float32Array(buff);
@ -137,7 +137,7 @@ onmessage = function(event){
}
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}else if(pointAttribute.name === PointAttribute.NORMAL_OCT16.name){
}else if(pointAttribute.name === Potree.PointAttribute.NORMAL_OCT16.name){
var buff = new ArrayBuffer(numPoints*4*3);
var normals = new Float32Array(buff);
@ -168,7 +168,7 @@ onmessage = function(event){
normals[3*j + 2] = z;
}
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}else if(pointAttribute.name === PointAttribute.NORMAL.name){
}else if(pointAttribute.name === Potree.PointAttribute.NORMAL.name){
var buff = new ArrayBuffer(numPoints*4*3);
var normals = new Float32Array(buff);