@loaders.gl/pcd
Version:
Framework-independent loader for the PCD format
49 lines • 1.59 kB
JavaScript
// loaders.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
/**
* Gets schema from PCD header
* @param PCDheader
* @param metadata
* @returns Schema
*/
export function getPCDSchema(PCDheader, metadata) {
const fields = [];
for (const key of Object.keys(PCDheader.offset)) {
switch (key) {
case 'x':
fields.push({
name: 'POSITION',
type: { type: 'fixed-size-list', listSize: 3, children: [{ name: 'xyz', type: 'float32' }] },
metadata: { attribute: 'POSITION' }
});
break;
case 'y':
case 'z':
// ignore
break;
case 'normal_x':
fields.push({
name: 'NORMAL',
type: { type: 'fixed-size-list', listSize: 3, children: [{ name: 'xyz', type: 'float32' }] },
metadata: { attribute: 'NORMAL' }
});
break;
case 'normal_y':
case 'normal_z':
// ignore
break;
case 'rgb':
fields.push({
name: 'COLOR_0',
type: { type: 'fixed-size-list', listSize: 3, children: [{ name: 'rgb', type: 'uint8' }] },
metadata: { attribute: 'COLOR' }
});
break;
default:
// TODO - push fields
}
}
return { fields, metadata };
}
//# sourceMappingURL=get-pcd-schema.js.map