@loaders.gl/pcd 3.4.0-alpha.1 → 3.4.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.min.js +82 -24
- package/dist/es5/index.js +6 -8
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/decompress-lzf.js +21 -7
- package/dist/es5/lib/decompress-lzf.js.map +1 -1
- package/dist/es5/lib/get-pcd-schema.js +6 -0
- package/dist/es5/lib/get-pcd-schema.js.map +1 -1
- package/dist/es5/lib/parse-pcd.js +58 -29
- package/dist/es5/lib/parse-pcd.js.map +1 -1
- package/dist/es5/lib/pcd-types.js.map +1 -1
- package/dist/es5/pcd-loader.js +1 -2
- package/dist/es5/pcd-loader.js.map +1 -1
- package/dist/es5/workers/pcd-worker.js.map +1 -1
- package/dist/esm/bundle.js +0 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/decompress-lzf.js +21 -8
- package/dist/esm/lib/decompress-lzf.js.map +1 -1
- package/dist/esm/lib/get-pcd-schema.js +7 -1
- package/dist/esm/lib/get-pcd-schema.js.map +1 -1
- package/dist/esm/lib/parse-pcd.js +58 -30
- package/dist/esm/lib/parse-pcd.js.map +1 -1
- package/dist/esm/lib/pcd-types.js.map +1 -1
- package/dist/esm/pcd-loader.js +1 -3
- package/dist/esm/pcd-loader.js.map +1 -1
- package/dist/lib/decompress-lzf.d.ts.map +1 -1
- package/dist/lib/decompress-lzf.js +14 -7
- package/dist/lib/get-pcd-schema.d.ts.map +1 -1
- package/dist/lib/get-pcd-schema.js +6 -0
- package/dist/lib/parse-pcd.js +60 -17
- package/dist/lib/pcd-types.d.ts +9 -9
- package/dist/lib/pcd-types.d.ts.map +1 -1
- package/dist/pcd-worker.js +82 -24
- package/package.json +4 -4
- package/src/lib/decompress-lzf.ts +21 -7
- package/src/lib/get-pcd-schema.ts +9 -1
- package/src/lib/parse-pcd.ts +79 -33
- package/src/lib/pcd-types.ts +9 -9
package/dist/dist.min.js
CHANGED
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
});
|
|
211
211
|
|
|
212
212
|
// ../schema/src/lib/schema/impl/type.ts
|
|
213
|
-
var DataType, Null, Bool, Int, Uint8, Precision, Float, Float32, Binary, Utf8, DateUnit, Date, TimeUnit, Time, Timestamp, IntervalUnit, Interval, FixedSizeList, Struct;
|
|
213
|
+
var DataType, Null, Bool, Int, Int32, Uint8, Precision, Float, Float32, Binary, Utf8, DateUnit, Date, TimeUnit, Time, Timestamp, IntervalUnit, Interval, FixedSizeList, Struct;
|
|
214
214
|
var init_type = __esm({
|
|
215
215
|
"../schema/src/lib/schema/impl/type.ts"() {
|
|
216
216
|
init_enum();
|
|
@@ -314,6 +314,11 @@
|
|
|
314
314
|
return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
|
+
Int32 = class extends Int {
|
|
318
|
+
constructor() {
|
|
319
|
+
super(true, 32);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
317
322
|
Uint8 = class extends Int {
|
|
318
323
|
constructor() {
|
|
319
324
|
super(false, 8);
|
|
@@ -515,30 +520,37 @@
|
|
|
515
520
|
ctrl = inData[inPtr++];
|
|
516
521
|
if (ctrl < 1 << 5) {
|
|
517
522
|
ctrl++;
|
|
518
|
-
if (outPtr + ctrl > outLength)
|
|
523
|
+
if (outPtr + ctrl > outLength) {
|
|
519
524
|
throw new Error("Output buffer is not large enough");
|
|
520
|
-
|
|
525
|
+
}
|
|
526
|
+
if (inPtr + ctrl > inLength) {
|
|
521
527
|
throw new Error("Invalid compressed data");
|
|
528
|
+
}
|
|
522
529
|
do {
|
|
523
530
|
outData[outPtr++] = inData[inPtr++];
|
|
524
531
|
} while (--ctrl);
|
|
525
532
|
} else {
|
|
526
533
|
len = ctrl >> 5;
|
|
527
534
|
ref = outPtr - ((ctrl & 31) << 8) - 1;
|
|
528
|
-
if (inPtr >= inLength)
|
|
535
|
+
if (inPtr >= inLength) {
|
|
529
536
|
throw new Error("Invalid compressed data");
|
|
537
|
+
}
|
|
530
538
|
if (len === 7) {
|
|
531
539
|
len += inData[inPtr++];
|
|
532
|
-
if (inPtr >= inLength)
|
|
540
|
+
if (inPtr >= inLength) {
|
|
533
541
|
throw new Error("Invalid compressed data");
|
|
542
|
+
}
|
|
534
543
|
}
|
|
535
544
|
ref -= inData[inPtr++];
|
|
536
|
-
if (outPtr + len + 2 > outLength)
|
|
545
|
+
if (outPtr + len + 2 > outLength) {
|
|
537
546
|
throw new Error("Output buffer is not large enough");
|
|
538
|
-
|
|
547
|
+
}
|
|
548
|
+
if (ref < 0) {
|
|
539
549
|
throw new Error("Invalid compressed data");
|
|
540
|
-
|
|
550
|
+
}
|
|
551
|
+
if (ref >= outPtr) {
|
|
541
552
|
throw new Error("Invalid compressed data");
|
|
553
|
+
}
|
|
542
554
|
do {
|
|
543
555
|
outData[outPtr++] = outData[ref++];
|
|
544
556
|
} while (--len + 2);
|
|
@@ -564,6 +576,12 @@
|
|
|
564
576
|
if (offset.rgb !== void 0) {
|
|
565
577
|
fields.push(new Field("COLOR_0", new FixedSizeList(3, new Field("rgb", new Uint8())), false));
|
|
566
578
|
}
|
|
579
|
+
if (offset.intensity !== void 0) {
|
|
580
|
+
fields.push(new Field("intensity", new Field("intensity", new Float32()), false));
|
|
581
|
+
}
|
|
582
|
+
if (offset.label !== void 0) {
|
|
583
|
+
fields.push(new Field("label", new Field("label", new Int32()), false));
|
|
584
|
+
}
|
|
567
585
|
return new Schema(fields, metadata);
|
|
568
586
|
}
|
|
569
587
|
var init_get_pcd_schema = __esm({
|
|
@@ -637,6 +655,18 @@
|
|
|
637
655
|
size: 3
|
|
638
656
|
};
|
|
639
657
|
}
|
|
658
|
+
if (attributes.intensity && attributes.intensity.length > 0) {
|
|
659
|
+
normalizedAttributes.COLOR_0 = {
|
|
660
|
+
value: new Uint8Array(attributes.color),
|
|
661
|
+
size: 3
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
if (attributes.label && attributes.label.length > 0) {
|
|
665
|
+
normalizedAttributes.COLOR_0 = {
|
|
666
|
+
value: new Uint8Array(attributes.label),
|
|
667
|
+
size: 3
|
|
668
|
+
};
|
|
669
|
+
}
|
|
640
670
|
return normalizedAttributes;
|
|
641
671
|
}
|
|
642
672
|
function parsePCDHeader(data) {
|
|
@@ -714,6 +744,8 @@
|
|
|
714
744
|
const position = [];
|
|
715
745
|
const normal = [];
|
|
716
746
|
const color = [];
|
|
747
|
+
const intensity = [];
|
|
748
|
+
const label = [];
|
|
717
749
|
const offset = pcdHeader.offset;
|
|
718
750
|
const pcdData = textData.substr(pcdHeader.headerLen);
|
|
719
751
|
const lines = pcdData.split("\n");
|
|
@@ -738,6 +770,12 @@
|
|
|
738
770
|
normal.push(parseFloat(line[offset.normal_y]));
|
|
739
771
|
normal.push(parseFloat(line[offset.normal_z]));
|
|
740
772
|
}
|
|
773
|
+
if (offset.intensity !== void 0) {
|
|
774
|
+
intensity.push(parseFloat(line[offset.intensity]));
|
|
775
|
+
}
|
|
776
|
+
if (offset.label !== void 0) {
|
|
777
|
+
label.push(parseInt(line[offset.label]));
|
|
778
|
+
}
|
|
741
779
|
}
|
|
742
780
|
}
|
|
743
781
|
return { position, normal, color };
|
|
@@ -746,6 +784,8 @@
|
|
|
746
784
|
const position = [];
|
|
747
785
|
const normal = [];
|
|
748
786
|
const color = [];
|
|
787
|
+
const intensity = [];
|
|
788
|
+
const label = [];
|
|
749
789
|
const dataview = new DataView(data, pcdHeader.headerLen);
|
|
750
790
|
const offset = pcdHeader.offset;
|
|
751
791
|
for (let i = 0, row = 0; i < pcdHeader.points; i++, row += pcdHeader.rowSize) {
|
|
@@ -764,40 +804,58 @@
|
|
|
764
804
|
normal.push(dataview.getFloat32(row + offset.normal_y, LITTLE_ENDIAN));
|
|
765
805
|
normal.push(dataview.getFloat32(row + offset.normal_z, LITTLE_ENDIAN));
|
|
766
806
|
}
|
|
807
|
+
if (offset.intensity !== void 0) {
|
|
808
|
+
intensity.push(dataview.getFloat32(row + offset.intensity, LITTLE_ENDIAN));
|
|
809
|
+
}
|
|
810
|
+
if (offset.label !== void 0) {
|
|
811
|
+
label.push(dataview.getInt32(row + offset.label, LITTLE_ENDIAN));
|
|
812
|
+
}
|
|
767
813
|
}
|
|
768
|
-
return { position, normal, color };
|
|
814
|
+
return { position, normal, color, intensity, label };
|
|
769
815
|
}
|
|
770
|
-
function parsePCDBinaryCompressed(
|
|
816
|
+
function parsePCDBinaryCompressed(pcdHeader, data) {
|
|
771
817
|
const position = [];
|
|
772
818
|
const normal = [];
|
|
773
819
|
const color = [];
|
|
774
|
-
const
|
|
820
|
+
const intensity = [];
|
|
821
|
+
const label = [];
|
|
822
|
+
const sizes = new Uint32Array(data.slice(pcdHeader.headerLen, pcdHeader.headerLen + 8));
|
|
775
823
|
const compressedSize = sizes[0];
|
|
776
824
|
const decompressedSize = sizes[1];
|
|
777
|
-
const decompressed = decompressLZF(new Uint8Array(data,
|
|
825
|
+
const decompressed = decompressLZF(new Uint8Array(data, pcdHeader.headerLen + 8, compressedSize), decompressedSize);
|
|
778
826
|
const dataview = new DataView(decompressed.buffer);
|
|
779
|
-
const offset =
|
|
780
|
-
for (let i = 0; i <
|
|
827
|
+
const offset = pcdHeader.offset;
|
|
828
|
+
for (let i = 0; i < pcdHeader.points; i++) {
|
|
781
829
|
if (offset.x !== void 0) {
|
|
782
|
-
position.push(dataview.getFloat32(
|
|
783
|
-
position.push(dataview.getFloat32(
|
|
784
|
-
position.push(dataview.getFloat32(
|
|
830
|
+
position.push(dataview.getFloat32(pcdHeader.points * offset.x + pcdHeader.size[0] * i, LITTLE_ENDIAN));
|
|
831
|
+
position.push(dataview.getFloat32(pcdHeader.points * offset.y + pcdHeader.size[1] * i, LITTLE_ENDIAN));
|
|
832
|
+
position.push(dataview.getFloat32(pcdHeader.points * offset.z + pcdHeader.size[2] * i, LITTLE_ENDIAN));
|
|
785
833
|
}
|
|
786
834
|
if (offset.rgb !== void 0) {
|
|
787
|
-
color.push(dataview.getUint8(
|
|
788
|
-
color.push(dataview.getUint8(
|
|
789
|
-
color.push(dataview.getUint8(
|
|
835
|
+
color.push(dataview.getUint8(pcdHeader.points * offset.rgb + pcdHeader.size[3] * i + 0) / 255);
|
|
836
|
+
color.push(dataview.getUint8(pcdHeader.points * offset.rgb + pcdHeader.size[3] * i + 1) / 255);
|
|
837
|
+
color.push(dataview.getUint8(pcdHeader.points * offset.rgb + pcdHeader.size[3] * i + 2) / 255);
|
|
790
838
|
}
|
|
791
839
|
if (offset.normal_x !== void 0) {
|
|
792
|
-
normal.push(dataview.getFloat32(
|
|
793
|
-
normal.push(dataview.getFloat32(
|
|
794
|
-
normal.push(dataview.getFloat32(
|
|
840
|
+
normal.push(dataview.getFloat32(pcdHeader.points * offset.normal_x + pcdHeader.size[4] * i, LITTLE_ENDIAN));
|
|
841
|
+
normal.push(dataview.getFloat32(pcdHeader.points * offset.normal_y + pcdHeader.size[5] * i, LITTLE_ENDIAN));
|
|
842
|
+
normal.push(dataview.getFloat32(pcdHeader.points * offset.normal_z + pcdHeader.size[6] * i, LITTLE_ENDIAN));
|
|
843
|
+
}
|
|
844
|
+
if (offset.intensity !== void 0) {
|
|
845
|
+
const intensityIndex = pcdHeader.fields.indexOf("intensity");
|
|
846
|
+
intensity.push(dataview.getFloat32(pcdHeader.points * offset.intensity + pcdHeader.size[intensityIndex] * i, LITTLE_ENDIAN));
|
|
847
|
+
}
|
|
848
|
+
if (offset.label !== void 0) {
|
|
849
|
+
const labelIndex = pcdHeader.fields.indexOf("label");
|
|
850
|
+
label.push(dataview.getInt32(pcdHeader.points * offset.label + pcdHeader.size[labelIndex] * i, LITTLE_ENDIAN));
|
|
795
851
|
}
|
|
796
852
|
}
|
|
797
853
|
return {
|
|
798
854
|
position,
|
|
799
855
|
normal,
|
|
800
|
-
color
|
|
856
|
+
color,
|
|
857
|
+
intensity,
|
|
858
|
+
label
|
|
801
859
|
};
|
|
802
860
|
}
|
|
803
861
|
var LITTLE_ENDIAN;
|
package/dist/es5/index.js
CHANGED
|
@@ -23,14 +23,12 @@ var PCDLoader = _objectSpread(_objectSpread({}, _pcdLoader.PCDLoader), {}, {
|
|
|
23
23
|
parse: function () {
|
|
24
24
|
var _parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer) {
|
|
25
25
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
26
|
-
while (1) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return _context.stop();
|
|
33
|
-
}
|
|
26
|
+
while (1) switch (_context.prev = _context.next) {
|
|
27
|
+
case 0:
|
|
28
|
+
return _context.abrupt("return", (0, _parsePcd.default)(arrayBuffer));
|
|
29
|
+
case 1:
|
|
30
|
+
case "end":
|
|
31
|
+
return _context.stop();
|
|
34
32
|
}
|
|
35
33
|
}, _callee);
|
|
36
34
|
}));
|
package/dist/es5/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["PCDLoader","PCDWorkerLoader","parse","arrayBuffer","parsePCDSync","parseSync","_typecheckPCDLoader"],"sources":["../../src/index.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport parsePCDSync from './lib/parse-pcd';\nimport {PCDLoader as PCDWorkerLoader} from './pcd-loader';\n\nexport {PCDWorkerLoader};\n\n/**\n * Loader for PCD - Point Cloud Data\n */\nexport const PCDLoader = {\n ...PCDWorkerLoader,\n parse: async (arrayBuffer) => parsePCDSync(arrayBuffer),\n parseSync: parsePCDSync\n};\n\nexport const _typecheckPCDLoader: LoaderWithParser = PCDLoader;\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;AACA;AAA0D;AAAA;AAOnD,
|
|
1
|
+
{"version":3,"file":"index.js","names":["_parsePcd","_interopRequireDefault","require","_pcdLoader","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","PCDLoader","PCDWorkerLoader","parse","_parse","_asyncToGenerator2","_regenerator","mark","_callee","arrayBuffer","wrap","_callee$","_context","prev","next","abrupt","parsePCDSync","stop","_x","parseSync","exports","_typecheckPCDLoader"],"sources":["../../src/index.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport parsePCDSync from './lib/parse-pcd';\nimport {PCDLoader as PCDWorkerLoader} from './pcd-loader';\n\nexport {PCDWorkerLoader};\n\n/**\n * Loader for PCD - Point Cloud Data\n */\nexport const PCDLoader = {\n ...PCDWorkerLoader,\n parse: async (arrayBuffer) => parsePCDSync(arrayBuffer),\n parseSync: parsePCDSync\n};\n\nexport const _typecheckPCDLoader: LoaderWithParser = PCDLoader;\n"],"mappings":";;;;;;;;;;;;;;;;;AACA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAA0D,SAAAE,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,CAAAC,OAAA,EAAAR,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAmB,yBAAA,GAAAnB,MAAA,CAAAoB,gBAAA,CAAAV,MAAA,EAAAV,MAAA,CAAAmB,yBAAA,CAAAL,MAAA,KAAAlB,OAAA,CAAAI,MAAA,CAAAc,MAAA,GAAAC,OAAA,WAAAC,GAAA,IAAAhB,MAAA,CAAAqB,cAAA,CAAAX,MAAA,EAAAM,GAAA,EAAAhB,MAAA,CAAAK,wBAAA,CAAAS,MAAA,EAAAE,GAAA,iBAAAN,MAAA;AAOnD,IAAMY,SAAS,GAAAb,aAAA,CAAAA,aAAA,KACjBc,oBAAe;EAClBC,KAAK;IAAA,IAAAC,MAAA,OAAAC,kBAAA,CAAAR,OAAA,EAAAS,YAAA,CAAAT,OAAA,CAAAU,IAAA,CAAE,SAAAC,QAAOC,WAAW;MAAA,OAAAH,YAAA,CAAAT,OAAA,CAAAa,IAAA,UAAAC,SAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YAAA,OAAAF,QAAA,CAAAG,MAAA,WAAK,IAAAC,iBAAY,EAACP,WAAW,CAAC;UAAA;UAAA;YAAA,OAAAG,QAAA,CAAAK,IAAA;QAAA;MAAA,GAAAT,OAAA;IAAA;IAAA,SAAAL,MAAAe,EAAA;MAAA,OAAAd,MAAA,CAAAjB,KAAA,OAAAI,SAAA;IAAA;IAAA,OAAAY,KAAA;EAAA;EACvDgB,SAAS,EAAEH;AAAY,EACxB;AAACI,OAAA,CAAAnB,SAAA,GAAAA,SAAA;AAEK,IAAMoB,mBAAqC,GAAGpB,SAAS;AAACmB,OAAA,CAAAC,mBAAA,GAAAA,mBAAA"}
|
|
@@ -16,23 +16,37 @@ function decompressLZF(inData, outLength) {
|
|
|
16
16
|
ctrl = inData[inPtr++];
|
|
17
17
|
if (ctrl < 1 << 5) {
|
|
18
18
|
ctrl++;
|
|
19
|
-
if (outPtr + ctrl > outLength)
|
|
20
|
-
|
|
19
|
+
if (outPtr + ctrl > outLength) {
|
|
20
|
+
throw new Error('Output buffer is not large enough');
|
|
21
|
+
}
|
|
22
|
+
if (inPtr + ctrl > inLength) {
|
|
23
|
+
throw new Error('Invalid compressed data');
|
|
24
|
+
}
|
|
21
25
|
do {
|
|
22
26
|
outData[outPtr++] = inData[inPtr++];
|
|
23
27
|
} while (--ctrl);
|
|
24
28
|
} else {
|
|
25
29
|
len = ctrl >> 5;
|
|
26
30
|
ref = outPtr - ((ctrl & 0x1f) << 8) - 1;
|
|
27
|
-
if (inPtr >= inLength)
|
|
31
|
+
if (inPtr >= inLength) {
|
|
32
|
+
throw new Error('Invalid compressed data');
|
|
33
|
+
}
|
|
28
34
|
if (len === 7) {
|
|
29
35
|
len += inData[inPtr++];
|
|
30
|
-
if (inPtr >= inLength)
|
|
36
|
+
if (inPtr >= inLength) {
|
|
37
|
+
throw new Error('Invalid compressed data');
|
|
38
|
+
}
|
|
31
39
|
}
|
|
32
40
|
ref -= inData[inPtr++];
|
|
33
|
-
if (outPtr + len + 2 > outLength)
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
if (outPtr + len + 2 > outLength) {
|
|
42
|
+
throw new Error('Output buffer is not large enough');
|
|
43
|
+
}
|
|
44
|
+
if (ref < 0) {
|
|
45
|
+
throw new Error('Invalid compressed data');
|
|
46
|
+
}
|
|
47
|
+
if (ref >= outPtr) {
|
|
48
|
+
throw new Error('Invalid compressed data');
|
|
49
|
+
}
|
|
36
50
|
do {
|
|
37
51
|
outData[outPtr++] = outData[ref++];
|
|
38
52
|
} while (--len + 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompress-lzf.js","names":["decompressLZF","inData","outLength","inLength","length","outData","Uint8Array","inPtr","outPtr","ctrl","len","ref","Error"],"sources":["../../../src/lib/decompress-lzf.ts"],"sourcesContent":["/* eslint-disable */\n/**\n * from https://gitlab.com/taketwo/three-pcd-loader/blob/master/decompress-lzf.js\n * @param inData\n * @param outLength\n * @returns\n */\nexport function decompressLZF(inData: Uint8Array, outLength: number): Uint8Array {\n const inLength = inData.length;\n const outData = new Uint8Array(outLength);\n let inPtr = 0;\n let outPtr = 0;\n let ctrl;\n let len;\n let ref;\n\n do {\n ctrl = inData[inPtr++];\n\n if (ctrl < 1 << 5) {\n ctrl++;\n if (outPtr + ctrl > outLength) throw new Error('Output buffer is not large enough');\n if (inPtr + ctrl > inLength) throw new Error('Invalid compressed data');\n\n do {\n outData[outPtr++] = inData[inPtr++];\n } while (--ctrl);\n } else {\n len = ctrl >> 5;\n ref = outPtr - ((ctrl & 0x1f) << 8) - 1;\n if (inPtr >= inLength) throw new Error('Invalid compressed data');\n\n if (len === 7) {\n len += inData[inPtr++];\n if (inPtr >= inLength) throw new Error('Invalid compressed data');\n }\n\n ref -= inData[inPtr++];\n if (outPtr + len + 2 > outLength) throw new Error('Output buffer is not large enough');\n if (ref < 0) throw new Error('Invalid compressed data');\n if (ref >= outPtr) throw new Error('Invalid compressed data');\n\n do {\n outData[outPtr++] = outData[ref++];\n } while (--len + 2);\n }\n } while (inPtr < inLength);\n\n return outData;\n}\n"],"mappings":";;;;;;AAOO,SAASA,
|
|
1
|
+
{"version":3,"file":"decompress-lzf.js","names":["decompressLZF","inData","outLength","inLength","length","outData","Uint8Array","inPtr","outPtr","ctrl","len","ref","Error"],"sources":["../../../src/lib/decompress-lzf.ts"],"sourcesContent":["/* eslint-disable */\n/**\n * from https://gitlab.com/taketwo/three-pcd-loader/blob/master/decompress-lzf.js\n * @param inData\n * @param outLength\n * @returns\n */\nexport function decompressLZF(inData: Uint8Array, outLength: number): Uint8Array {\n const inLength = inData.length;\n const outData = new Uint8Array(outLength);\n let inPtr = 0;\n let outPtr = 0;\n let ctrl;\n let len;\n let ref;\n\n do {\n ctrl = inData[inPtr++];\n\n if (ctrl < 1 << 5) {\n ctrl++;\n if (outPtr + ctrl > outLength) {\n throw new Error('Output buffer is not large enough');\n }\n if (inPtr + ctrl > inLength) {\n throw new Error('Invalid compressed data');\n }\n\n do {\n outData[outPtr++] = inData[inPtr++];\n } while (--ctrl);\n } else {\n len = ctrl >> 5;\n ref = outPtr - ((ctrl & 0x1f) << 8) - 1;\n if (inPtr >= inLength) {\n throw new Error('Invalid compressed data');\n }\n\n if (len === 7) {\n len += inData[inPtr++];\n if (inPtr >= inLength) {\n throw new Error('Invalid compressed data');\n }\n }\n\n ref -= inData[inPtr++];\n if (outPtr + len + 2 > outLength) {\n throw new Error('Output buffer is not large enough');\n }\n if (ref < 0) {\n throw new Error('Invalid compressed data');\n }\n if (ref >= outPtr) {\n throw new Error('Invalid compressed data');\n }\n\n do {\n outData[outPtr++] = outData[ref++];\n } while (--len + 2);\n }\n } while (inPtr < inLength);\n\n return outData;\n}\n"],"mappings":";;;;;;AAOO,SAASA,aAAaA,CAACC,MAAkB,EAAEC,SAAiB,EAAc;EAC/E,IAAMC,QAAQ,GAAGF,MAAM,CAACG,MAAM;EAC9B,IAAMC,OAAO,GAAG,IAAIC,UAAU,CAACJ,SAAS,CAAC;EACzC,IAAIK,KAAK,GAAG,CAAC;EACb,IAAIC,MAAM,GAAG,CAAC;EACd,IAAIC,IAAI;EACR,IAAIC,GAAG;EACP,IAAIC,GAAG;EAEP,GAAG;IACDF,IAAI,GAAGR,MAAM,CAACM,KAAK,EAAE,CAAC;IAEtB,IAAIE,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE;MACjBA,IAAI,EAAE;MACN,IAAID,MAAM,GAAGC,IAAI,GAAGP,SAAS,EAAE;QAC7B,MAAM,IAAIU,KAAK,CAAC,mCAAmC,CAAC;MACtD;MACA,IAAIL,KAAK,GAAGE,IAAI,GAAGN,QAAQ,EAAE;QAC3B,MAAM,IAAIS,KAAK,CAAC,yBAAyB,CAAC;MAC5C;MAEA,GAAG;QACDP,OAAO,CAACG,MAAM,EAAE,CAAC,GAAGP,MAAM,CAACM,KAAK,EAAE,CAAC;MACrC,CAAC,QAAQ,EAAEE,IAAI;IACjB,CAAC,MAAM;MACLC,GAAG,GAAGD,IAAI,IAAI,CAAC;MACfE,GAAG,GAAGH,MAAM,IAAI,CAACC,IAAI,GAAG,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC;MACvC,IAAIF,KAAK,IAAIJ,QAAQ,EAAE;QACrB,MAAM,IAAIS,KAAK,CAAC,yBAAyB,CAAC;MAC5C;MAEA,IAAIF,GAAG,KAAK,CAAC,EAAE;QACbA,GAAG,IAAIT,MAAM,CAACM,KAAK,EAAE,CAAC;QACtB,IAAIA,KAAK,IAAIJ,QAAQ,EAAE;UACrB,MAAM,IAAIS,KAAK,CAAC,yBAAyB,CAAC;QAC5C;MACF;MAEAD,GAAG,IAAIV,MAAM,CAACM,KAAK,EAAE,CAAC;MACtB,IAAIC,MAAM,GAAGE,GAAG,GAAG,CAAC,GAAGR,SAAS,EAAE;QAChC,MAAM,IAAIU,KAAK,CAAC,mCAAmC,CAAC;MACtD;MACA,IAAID,GAAG,GAAG,CAAC,EAAE;QACX,MAAM,IAAIC,KAAK,CAAC,yBAAyB,CAAC;MAC5C;MACA,IAAID,GAAG,IAAIH,MAAM,EAAE;QACjB,MAAM,IAAII,KAAK,CAAC,yBAAyB,CAAC;MAC5C;MAEA,GAAG;QACDP,OAAO,CAACG,MAAM,EAAE,CAAC,GAAGH,OAAO,CAACM,GAAG,EAAE,CAAC;MACpC,CAAC,QAAQ,EAAED,GAAG,GAAG,CAAC;IACpB;EACF,CAAC,QAAQH,KAAK,GAAGJ,QAAQ;EAEzB,OAAOE,OAAO;AAChB"}
|
|
@@ -17,6 +17,12 @@ function getPCDSchema(PCDheader, metadata) {
|
|
|
17
17
|
if (offset.rgb !== undefined) {
|
|
18
18
|
fields.push(new _schema.Field('COLOR_0', new _schema.FixedSizeList(3, new _schema.Field('rgb', new _schema.Uint8())), false));
|
|
19
19
|
}
|
|
20
|
+
if (offset.intensity !== undefined) {
|
|
21
|
+
fields.push(new _schema.Field('intensity', new _schema.Field('intensity', new _schema.Float32()), false));
|
|
22
|
+
}
|
|
23
|
+
if (offset.label !== undefined) {
|
|
24
|
+
fields.push(new _schema.Field('label', new _schema.Field('label', new _schema.Int32()), false));
|
|
25
|
+
}
|
|
20
26
|
return new _schema.Schema(fields, metadata);
|
|
21
27
|
}
|
|
22
28
|
//# sourceMappingURL=get-pcd-schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-pcd-schema.js","names":["getPCDSchema","PCDheader","metadata","offset","fields","x","undefined","push","Field","FixedSizeList","Float32","normal_x","rgb","Uint8","Schema"],"sources":["../../../src/lib/get-pcd-schema.ts"],"sourcesContent":["import {Schema, Field, Float32, Uint8, FixedSizeList} from '@loaders.gl/schema';\nimport type {PCDHeader} from './pcd-types';\n\ntype SchemaMetadata = Map<string, any>;\n\n/**\n * Gets schema from PCD header\n * @param PCDheader\n * @param metadata\n * @returns Schema\n */\nexport function getPCDSchema(PCDheader: PCDHeader, metadata: SchemaMetadata): Schema {\n const offset = PCDheader.offset;\n\n const fields: Field[] = [];\n\n if (offset.x !== undefined) {\n fields.push(\n new Field('POSITION', new FixedSizeList(3, new Field('xyz', new Float32())), false)\n );\n }\n\n if (offset.normal_x !== undefined) {\n fields.push(new Field('NORMAL', new FixedSizeList(3, new Field('xyz', new Float32())), false));\n }\n\n if (offset.rgb !== undefined) {\n fields.push(new Field('COLOR_0', new FixedSizeList(3, new Field('rgb', new Uint8())), false));\n }\n\n return new Schema(fields, metadata);\n}\n"],"mappings":";;;;;;AAAA;AAWO,
|
|
1
|
+
{"version":3,"file":"get-pcd-schema.js","names":["_schema","require","getPCDSchema","PCDheader","metadata","offset","fields","x","undefined","push","Field","FixedSizeList","Float32","normal_x","rgb","Uint8","intensity","label","Int32","Schema"],"sources":["../../../src/lib/get-pcd-schema.ts"],"sourcesContent":["import {Schema, Field, Float32, Int32, Uint8, FixedSizeList} from '@loaders.gl/schema';\nimport type {PCDHeader} from './pcd-types';\n\ntype SchemaMetadata = Map<string, any>;\n\n/**\n * Gets schema from PCD header\n * @param PCDheader\n * @param metadata\n * @returns Schema\n */\nexport function getPCDSchema(PCDheader: PCDHeader, metadata: SchemaMetadata): Schema {\n const offset = PCDheader.offset;\n\n const fields: Field[] = [];\n\n if (offset.x !== undefined) {\n fields.push(\n new Field('POSITION', new FixedSizeList(3, new Field('xyz', new Float32())), false)\n );\n }\n\n if (offset.normal_x !== undefined) {\n fields.push(new Field('NORMAL', new FixedSizeList(3, new Field('xyz', new Float32())), false));\n }\n\n if (offset.rgb !== undefined) {\n fields.push(new Field('COLOR_0', new FixedSizeList(3, new Field('rgb', new Uint8())), false));\n }\n\n if (offset.intensity !== undefined) {\n fields.push(new Field('intensity', new Field('intensity', new Float32()), false));\n }\n\n if (offset.label !== undefined) {\n fields.push(new Field('label', new Field('label', new Int32()), false));\n }\n\n return new Schema(fields, metadata);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAWO,SAASC,YAAYA,CAACC,SAAoB,EAAEC,QAAwB,EAAU;EACnF,IAAMC,MAAM,GAAGF,SAAS,CAACE,MAAM;EAE/B,IAAMC,MAAe,GAAG,EAAE;EAE1B,IAAID,MAAM,CAACE,CAAC,KAAKC,SAAS,EAAE;IAC1BF,MAAM,CAACG,IAAI,CACT,IAAIC,aAAK,CAAC,UAAU,EAAE,IAAIC,qBAAa,CAAC,CAAC,EAAE,IAAID,aAAK,CAAC,KAAK,EAAE,IAAIE,eAAO,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CACpF;EACH;EAEA,IAAIP,MAAM,CAACQ,QAAQ,KAAKL,SAAS,EAAE;IACjCF,MAAM,CAACG,IAAI,CAAC,IAAIC,aAAK,CAAC,QAAQ,EAAE,IAAIC,qBAAa,CAAC,CAAC,EAAE,IAAID,aAAK,CAAC,KAAK,EAAE,IAAIE,eAAO,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;EAChG;EAEA,IAAIP,MAAM,CAACS,GAAG,KAAKN,SAAS,EAAE;IAC5BF,MAAM,CAACG,IAAI,CAAC,IAAIC,aAAK,CAAC,SAAS,EAAE,IAAIC,qBAAa,CAAC,CAAC,EAAE,IAAID,aAAK,CAAC,KAAK,EAAE,IAAIK,aAAK,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;EAC/F;EAEA,IAAIV,MAAM,CAACW,SAAS,KAAKR,SAAS,EAAE;IAClCF,MAAM,CAACG,IAAI,CAAC,IAAIC,aAAK,CAAC,WAAW,EAAE,IAAIA,aAAK,CAAC,WAAW,EAAE,IAAIE,eAAO,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;EACnF;EAEA,IAAIP,MAAM,CAACY,KAAK,KAAKT,SAAS,EAAE;IAC9BF,MAAM,CAACG,IAAI,CAAC,IAAIC,aAAK,CAAC,OAAO,EAAE,IAAIA,aAAK,CAAC,OAAO,EAAE,IAAIQ,aAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;EACzE;EAEA,OAAO,IAAIC,cAAM,CAACb,MAAM,EAAEF,QAAQ,CAAC;AACrC"}
|
|
@@ -7,14 +7,11 @@ exports.default = parsePCD;
|
|
|
7
7
|
var _schema = require("@loaders.gl/schema");
|
|
8
8
|
var _decompressLzf = require("./decompress-lzf");
|
|
9
9
|
var _getPcdSchema = require("./get-pcd-schema");
|
|
10
|
-
|
|
11
10
|
var LITTLE_ENDIAN = true;
|
|
12
|
-
|
|
13
11
|
function parsePCD(data) {
|
|
14
12
|
var textData = new TextDecoder().decode(data);
|
|
15
13
|
var pcdHeader = parsePCDHeader(textData);
|
|
16
14
|
var attributes = {};
|
|
17
|
-
|
|
18
15
|
switch (pcdHeader.data) {
|
|
19
16
|
case 'ascii':
|
|
20
17
|
attributes = parsePCDASCII(pcdHeader, textData);
|
|
@@ -43,7 +40,6 @@ function parsePCD(data) {
|
|
|
43
40
|
attributes: attributes
|
|
44
41
|
};
|
|
45
42
|
}
|
|
46
|
-
|
|
47
43
|
function getMeshHeader(pcdHeader, attributes) {
|
|
48
44
|
if (typeof pcdHeader.width === 'number' && typeof pcdHeader.height === 'number') {
|
|
49
45
|
var pointCount = pcdHeader.width * pcdHeader.height;
|
|
@@ -54,7 +50,6 @@ function getMeshHeader(pcdHeader, attributes) {
|
|
|
54
50
|
}
|
|
55
51
|
return pcdHeader;
|
|
56
52
|
}
|
|
57
|
-
|
|
58
53
|
function getMeshAttributes(attributes) {
|
|
59
54
|
var normalizedAttributes = {
|
|
60
55
|
POSITION: {
|
|
@@ -74,9 +69,20 @@ function getMeshAttributes(attributes) {
|
|
|
74
69
|
size: 3
|
|
75
70
|
};
|
|
76
71
|
}
|
|
72
|
+
if (attributes.intensity && attributes.intensity.length > 0) {
|
|
73
|
+
normalizedAttributes.COLOR_0 = {
|
|
74
|
+
value: new Uint8Array(attributes.color),
|
|
75
|
+
size: 3
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (attributes.label && attributes.label.length > 0) {
|
|
79
|
+
normalizedAttributes.COLOR_0 = {
|
|
80
|
+
value: new Uint8Array(attributes.label),
|
|
81
|
+
size: 3
|
|
82
|
+
};
|
|
83
|
+
}
|
|
77
84
|
return normalizedAttributes;
|
|
78
85
|
}
|
|
79
|
-
|
|
80
86
|
function parsePCDHeader(data) {
|
|
81
87
|
var result1 = data.search(/[\r\n]DATA\s(\S*)\s/i);
|
|
82
88
|
var result2 = /[\r\n]DATA\s(\S*)\s/i.exec(data.substr(result1 - 1));
|
|
@@ -86,9 +92,7 @@ function parsePCDHeader(data) {
|
|
|
86
92
|
pcdHeader.headerLen = (result2 && result2[0].length) + result1;
|
|
87
93
|
}
|
|
88
94
|
pcdHeader.str = data.substr(0, pcdHeader.headerLen);
|
|
89
|
-
|
|
90
95
|
pcdHeader.str = pcdHeader.str.replace(/\#.*/gi, '');
|
|
91
|
-
|
|
92
96
|
pcdHeader.version = /VERSION (.*)/i.exec(pcdHeader.str);
|
|
93
97
|
pcdHeader.fields = /FIELDS (.*)/i.exec(pcdHeader.str);
|
|
94
98
|
pcdHeader.size = /SIZE (.*)/i.exec(pcdHeader.str);
|
|
@@ -98,7 +102,6 @@ function parsePCDHeader(data) {
|
|
|
98
102
|
pcdHeader.height = /HEIGHT (.*)/i.exec(pcdHeader.str);
|
|
99
103
|
pcdHeader.viewpoint = /VIEWPOINT (.*)/i.exec(pcdHeader.str);
|
|
100
104
|
pcdHeader.points = /POINTS (.*)/i.exec(pcdHeader.str);
|
|
101
|
-
|
|
102
105
|
if (pcdHeader.version !== null) {
|
|
103
106
|
pcdHeader.version = parseFloat(pcdHeader.version[1]);
|
|
104
107
|
}
|
|
@@ -152,15 +155,15 @@ function parsePCDHeader(data) {
|
|
|
152
155
|
}
|
|
153
156
|
}
|
|
154
157
|
}
|
|
155
|
-
|
|
156
158
|
pcdHeader.rowSize = sizeSum;
|
|
157
159
|
return pcdHeader;
|
|
158
160
|
}
|
|
159
|
-
|
|
160
161
|
function parsePCDASCII(pcdHeader, textData) {
|
|
161
162
|
var position = [];
|
|
162
163
|
var normal = [];
|
|
163
164
|
var color = [];
|
|
165
|
+
var intensity = [];
|
|
166
|
+
var label = [];
|
|
164
167
|
var offset = pcdHeader.offset;
|
|
165
168
|
var pcdData = textData.substr(pcdHeader.headerLen);
|
|
166
169
|
var lines = pcdData.split('\n');
|
|
@@ -180,12 +183,17 @@ function parsePCDASCII(pcdHeader, textData) {
|
|
|
180
183
|
color.push(dataview.getUint8(1));
|
|
181
184
|
color.push(dataview.getUint8(2));
|
|
182
185
|
}
|
|
183
|
-
|
|
184
186
|
if (offset.normal_x !== undefined) {
|
|
185
187
|
normal.push(parseFloat(line[offset.normal_x]));
|
|
186
188
|
normal.push(parseFloat(line[offset.normal_y]));
|
|
187
189
|
normal.push(parseFloat(line[offset.normal_z]));
|
|
188
190
|
}
|
|
191
|
+
if (offset.intensity !== undefined) {
|
|
192
|
+
intensity.push(parseFloat(line[offset.intensity]));
|
|
193
|
+
}
|
|
194
|
+
if (offset.label !== undefined) {
|
|
195
|
+
label.push(parseInt(line[offset.label]));
|
|
196
|
+
}
|
|
189
197
|
}
|
|
190
198
|
}
|
|
191
199
|
return {
|
|
@@ -194,11 +202,12 @@ function parsePCDASCII(pcdHeader, textData) {
|
|
|
194
202
|
color: color
|
|
195
203
|
};
|
|
196
204
|
}
|
|
197
|
-
|
|
198
205
|
function parsePCDBinary(pcdHeader, data) {
|
|
199
206
|
var position = [];
|
|
200
207
|
var normal = [];
|
|
201
208
|
var color = [];
|
|
209
|
+
var intensity = [];
|
|
210
|
+
var label = [];
|
|
202
211
|
var dataview = new DataView(data, pcdHeader.headerLen);
|
|
203
212
|
var offset = pcdHeader.offset;
|
|
204
213
|
for (var i = 0, row = 0; i < pcdHeader.points; i++, row += pcdHeader.rowSize) {
|
|
@@ -217,11 +226,19 @@ function parsePCDBinary(pcdHeader, data) {
|
|
|
217
226
|
normal.push(dataview.getFloat32(row + offset.normal_y, LITTLE_ENDIAN));
|
|
218
227
|
normal.push(dataview.getFloat32(row + offset.normal_z, LITTLE_ENDIAN));
|
|
219
228
|
}
|
|
229
|
+
if (offset.intensity !== undefined) {
|
|
230
|
+
intensity.push(dataview.getFloat32(row + offset.intensity, LITTLE_ENDIAN));
|
|
231
|
+
}
|
|
232
|
+
if (offset.label !== undefined) {
|
|
233
|
+
label.push(dataview.getInt32(row + offset.label, LITTLE_ENDIAN));
|
|
234
|
+
}
|
|
220
235
|
}
|
|
221
236
|
return {
|
|
222
237
|
position: position,
|
|
223
238
|
normal: normal,
|
|
224
|
-
color: color
|
|
239
|
+
color: color,
|
|
240
|
+
intensity: intensity,
|
|
241
|
+
label: label
|
|
225
242
|
};
|
|
226
243
|
}
|
|
227
244
|
|
|
@@ -232,37 +249,49 @@ function parsePCDBinary(pcdHeader, data) {
|
|
|
232
249
|
* @param data
|
|
233
250
|
* @returns [attributes]
|
|
234
251
|
*/
|
|
235
|
-
function parsePCDBinaryCompressed(
|
|
252
|
+
function parsePCDBinaryCompressed(pcdHeader, data) {
|
|
236
253
|
var position = [];
|
|
237
254
|
var normal = [];
|
|
238
255
|
var color = [];
|
|
239
|
-
var
|
|
256
|
+
var intensity = [];
|
|
257
|
+
var label = [];
|
|
258
|
+
var sizes = new Uint32Array(data.slice(pcdHeader.headerLen, pcdHeader.headerLen + 8));
|
|
240
259
|
var compressedSize = sizes[0];
|
|
241
260
|
var decompressedSize = sizes[1];
|
|
242
|
-
var decompressed = (0, _decompressLzf.decompressLZF)(new Uint8Array(data,
|
|
261
|
+
var decompressed = (0, _decompressLzf.decompressLZF)(new Uint8Array(data, pcdHeader.headerLen + 8, compressedSize), decompressedSize);
|
|
243
262
|
var dataview = new DataView(decompressed.buffer);
|
|
244
|
-
var offset =
|
|
245
|
-
for (var i = 0; i <
|
|
263
|
+
var offset = pcdHeader.offset;
|
|
264
|
+
for (var i = 0; i < pcdHeader.points; i++) {
|
|
246
265
|
if (offset.x !== undefined) {
|
|
247
|
-
position.push(dataview.getFloat32(
|
|
248
|
-
position.push(dataview.getFloat32(
|
|
249
|
-
position.push(dataview.getFloat32(
|
|
266
|
+
position.push(dataview.getFloat32(pcdHeader.points * offset.x + pcdHeader.size[0] * i, LITTLE_ENDIAN));
|
|
267
|
+
position.push(dataview.getFloat32(pcdHeader.points * offset.y + pcdHeader.size[1] * i, LITTLE_ENDIAN));
|
|
268
|
+
position.push(dataview.getFloat32(pcdHeader.points * offset.z + pcdHeader.size[2] * i, LITTLE_ENDIAN));
|
|
250
269
|
}
|
|
251
270
|
if (offset.rgb !== undefined) {
|
|
252
|
-
color.push(dataview.getUint8(
|
|
253
|
-
color.push(dataview.getUint8(
|
|
254
|
-
color.push(dataview.getUint8(
|
|
271
|
+
color.push(dataview.getUint8(pcdHeader.points * offset.rgb + pcdHeader.size[3] * i + 0) / 255.0);
|
|
272
|
+
color.push(dataview.getUint8(pcdHeader.points * offset.rgb + pcdHeader.size[3] * i + 1) / 255.0);
|
|
273
|
+
color.push(dataview.getUint8(pcdHeader.points * offset.rgb + pcdHeader.size[3] * i + 2) / 255.0);
|
|
255
274
|
}
|
|
256
275
|
if (offset.normal_x !== undefined) {
|
|
257
|
-
normal.push(dataview.getFloat32(
|
|
258
|
-
normal.push(dataview.getFloat32(
|
|
259
|
-
normal.push(dataview.getFloat32(
|
|
276
|
+
normal.push(dataview.getFloat32(pcdHeader.points * offset.normal_x + pcdHeader.size[4] * i, LITTLE_ENDIAN));
|
|
277
|
+
normal.push(dataview.getFloat32(pcdHeader.points * offset.normal_y + pcdHeader.size[5] * i, LITTLE_ENDIAN));
|
|
278
|
+
normal.push(dataview.getFloat32(pcdHeader.points * offset.normal_z + pcdHeader.size[6] * i, LITTLE_ENDIAN));
|
|
279
|
+
}
|
|
280
|
+
if (offset.intensity !== undefined) {
|
|
281
|
+
var intensityIndex = pcdHeader.fields.indexOf('intensity');
|
|
282
|
+
intensity.push(dataview.getFloat32(pcdHeader.points * offset.intensity + pcdHeader.size[intensityIndex] * i, LITTLE_ENDIAN));
|
|
283
|
+
}
|
|
284
|
+
if (offset.label !== undefined) {
|
|
285
|
+
var labelIndex = pcdHeader.fields.indexOf('label');
|
|
286
|
+
label.push(dataview.getInt32(pcdHeader.points * offset.label + pcdHeader.size[labelIndex] * i, LITTLE_ENDIAN));
|
|
260
287
|
}
|
|
261
288
|
}
|
|
262
289
|
return {
|
|
263
290
|
position: position,
|
|
264
291
|
normal: normal,
|
|
265
|
-
color: color
|
|
292
|
+
color: color,
|
|
293
|
+
intensity: intensity,
|
|
294
|
+
label: label
|
|
266
295
|
};
|
|
267
296
|
}
|
|
268
297
|
//# sourceMappingURL=parse-pcd.js.map
|