Skip to content

Commit

Permalink
Merge pull request #70 from CecilHarvey/master
Browse files Browse the repository at this point in the history
Fix pcd exporting when using binary_compressed pcds.
  • Loading branch information
dmandrioli authored Dec 18, 2019
2 parents eba8160 + dd138fe commit 34411db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions imports/editor/3d/SsePCDLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ export default class SsePCDLoader {
sizeSum += PCDheader.size[i];
}
}
PCDheader.rowSize = sizeSum;
return PCDheader;
}

var textData = this.serverMode ? data : THREE.LoaderUtils.decodeText(data);
var textData = this.serverMode ? (new Buffer(data)).toString() : THREE.LoaderUtils.decodeText(data);

// parse header (always ascii format)
var PCDheader = parseHeader(textData);
Expand Down Expand Up @@ -197,11 +198,11 @@ export default class SsePCDLoader {
// binary compressed PCD files organize their data as structure of arrays: XXYYZZRGBRGB
// that requires a totally different parsing approach compared to non-compressed data
if ( PCDheader.data === 'binary_compressed' ) {
var sizes = new Uint32Array( data.slice( PCDheader.headerLen, PCDheader.headerLen + 8 ) );
var compressedSize = sizes[ 0 ];
var decompressedSize = sizes[ 1 ];
var dataview = new DataView( data.slice( PCDheader.headerLen, PCDheader.headerLen + 8 ) );
var compressedSize = dataview.getUint32( 0, true );
var decompressedSize = dataview.getUint32( 4, true );
var decompressed = decompressLZF( new Uint8Array( data, PCDheader.headerLen + 8, compressedSize ), decompressedSize );
var dataview = new DataView( decompressed.buffer );
dataview = new DataView( decompressed.buffer );

var offset = PCDheader.offset;
let pt, item;
Expand Down Expand Up @@ -329,4 +330,4 @@ export default class SsePCDLoader {
};

}
}
}
2 changes: 1 addition & 1 deletion server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function generatePCDOutput(req, res, next) {
}

const loader = new THREE.PCDLoader(true);
const pcdContent = loader.parse(content.toString(), "");
const pcdContent = loader.parse(content.buffer, "");

const head = pcdContent.header;
const count = parseInt(pcdContent.position.length / 3);
Expand Down

0 comments on commit 34411db

Please sign in to comment.