@loaders.gl/pcd 4.3.2 → 4.4.0-alpha.2
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.dev.js +12031 -35
- package/dist/dist.min.js +11 -2
- package/dist/index.cjs +72 -37
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -11
- package/dist/lib/decompress-lzf.d.ts +0 -1
- package/dist/lib/decompress-lzf.d.ts.map +1 -1
- package/dist/lib/decompress-lzf.js +4 -1
- package/dist/lib/get-pcd-schema.d.ts.map +1 -1
- package/dist/lib/get-pcd-schema.js +37 -18
- package/dist/lib/parse-pcd.d.ts +1 -1
- package/dist/lib/parse-pcd.d.ts.map +1 -1
- package/dist/lib/parse-pcd.js +9 -12
- package/dist/lib/pcd-types.d.ts.map +1 -1
- package/dist/lib/pcd-types.js +3 -0
- package/dist/pcd-arrow-loader.d.ts +23 -0
- package/dist/pcd-arrow-loader.d.ts.map +1 -0
- package/dist/pcd-arrow-loader.js +20 -0
- package/dist/pcd-format.d.ts +14 -0
- package/dist/pcd-format.d.ts.map +1 -0
- package/dist/pcd-format.js +16 -0
- package/dist/pcd-loader.d.ts +30 -4
- package/dist/pcd-loader.d.ts.map +1 -1
- package/dist/pcd-loader.js +13 -7
- package/dist/pcd-worker.js +55 -35
- package/dist/workers/pcd-worker.js +3 -0
- package/package.json +6 -5
- package/src/index.ts +2 -16
- package/src/lib/decompress-lzf.ts +5 -1
- package/src/lib/get-pcd-schema.ts +39 -19
- package/src/lib/parse-pcd.ts +11 -5
- package/src/lib/pcd-types.ts +4 -0
- package/src/pcd-arrow-loader.ts +25 -0
- package/src/pcd-format.ts +19 -0
- package/src/pcd-loader.ts +15 -9
- package/src/workers/pcd-worker.ts +4 -0
package/dist/pcd-loader.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
-
import { PCDMesh } from "./lib/pcd-types.js";
|
|
2
|
+
import type { PCDMesh } from "./lib/pcd-types.js";
|
|
3
|
+
import { parsePCD } from "./lib/parse-pcd.js";
|
|
3
4
|
export type PCDLoaderOptions = LoaderOptions & {
|
|
4
5
|
pcd?: {
|
|
5
6
|
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
@@ -9,18 +10,43 @@ export type PCDLoaderOptions = LoaderOptions & {
|
|
|
9
10
|
/**
|
|
10
11
|
* Worker loader for PCD - Point Cloud Data
|
|
11
12
|
*/
|
|
12
|
-
export declare const
|
|
13
|
+
export declare const PCDWorkerLoader: {
|
|
13
14
|
readonly dataType: PCDMesh;
|
|
14
15
|
readonly batchType: never;
|
|
16
|
+
readonly version: any;
|
|
17
|
+
readonly worker: true;
|
|
18
|
+
readonly options: {
|
|
19
|
+
readonly pcd: {};
|
|
20
|
+
};
|
|
15
21
|
readonly name: "PCD (Point Cloud Data)";
|
|
16
22
|
readonly id: "pcd";
|
|
17
23
|
readonly module: "pcd";
|
|
18
|
-
readonly version: any;
|
|
19
|
-
readonly worker: true;
|
|
20
24
|
readonly extensions: ["pcd"];
|
|
21
25
|
readonly mimeTypes: ["text/plain"];
|
|
26
|
+
readonly category: "pointcloud";
|
|
27
|
+
readonly text: true;
|
|
28
|
+
readonly binary: true;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Loader for PCD - Point Cloud Data
|
|
32
|
+
*/
|
|
33
|
+
export declare const PCDLoader: {
|
|
34
|
+
readonly parse: (arrayBuffer: ArrayBuffer) => Promise<PCDMesh>;
|
|
35
|
+
readonly parseSync: typeof parsePCD;
|
|
36
|
+
readonly dataType: PCDMesh;
|
|
37
|
+
readonly batchType: never;
|
|
38
|
+
readonly version: any;
|
|
39
|
+
readonly worker: true;
|
|
22
40
|
readonly options: {
|
|
23
41
|
readonly pcd: {};
|
|
24
42
|
};
|
|
43
|
+
readonly name: "PCD (Point Cloud Data)";
|
|
44
|
+
readonly id: "pcd";
|
|
45
|
+
readonly module: "pcd";
|
|
46
|
+
readonly extensions: ["pcd"];
|
|
47
|
+
readonly mimeTypes: ["text/plain"];
|
|
48
|
+
readonly category: "pointcloud";
|
|
49
|
+
readonly text: true;
|
|
50
|
+
readonly binary: true;
|
|
25
51
|
};
|
|
26
52
|
//# sourceMappingURL=pcd-loader.d.ts.map
|
package/dist/pcd-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pcd-loader.d.ts","sourceRoot":"","sources":["../src/pcd-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,aAAa,
|
|
1
|
+
{"version":3,"file":"pcd-loader.d.ts","sourceRoot":"","sources":["../src/pcd-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,aAAa,EAAmB,MAAM,0BAA0B,CAAC;AACtF,OAAO,KAAK,EAAC,OAAO,EAAC,2BAAwB;AAC7C,OAAO,EAAC,QAAQ,EAAC,2BAAwB;AAOzC,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE;QACJ,8EAA8E;QAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;uBAEG,OAAO;wBACjB,KAAK;;;;;;;;;;;;;;CAMmC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,SAAS;;;uBAZS,OAAO;wBACjB,KAAK;;;;;;;;;;;;;;CAe0C,CAAC"}
|
package/dist/pcd-loader.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
// loaders.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { parsePCD } from "./lib/parse-pcd.js";
|
|
5
|
+
import { PCDFormat } from "./pcd-format.js";
|
|
4
6
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
5
7
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
|
-
const VERSION = typeof "4.
|
|
8
|
+
const VERSION = typeof "4.4.0-alpha.1" !== 'undefined' ? "4.4.0-alpha.1" : 'latest';
|
|
7
9
|
/**
|
|
8
10
|
* Worker loader for PCD - Point Cloud Data
|
|
9
11
|
*/
|
|
10
|
-
export const
|
|
12
|
+
export const PCDWorkerLoader = {
|
|
13
|
+
...PCDFormat,
|
|
11
14
|
dataType: null,
|
|
12
15
|
batchType: null,
|
|
13
|
-
name: 'PCD (Point Cloud Data)',
|
|
14
|
-
id: 'pcd',
|
|
15
|
-
module: 'pcd',
|
|
16
16
|
version: VERSION,
|
|
17
17
|
worker: true,
|
|
18
|
-
extensions: ['pcd'],
|
|
19
|
-
mimeTypes: ['text/plain'],
|
|
20
18
|
options: {
|
|
21
19
|
pcd: {}
|
|
22
20
|
}
|
|
23
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Loader for PCD - Point Cloud Data
|
|
24
|
+
*/
|
|
25
|
+
export const PCDLoader = {
|
|
26
|
+
...PCDWorkerLoader,
|
|
27
|
+
parse: async (arrayBuffer) => parsePCD(arrayBuffer),
|
|
28
|
+
parseSync: parsePCD
|
|
29
|
+
};
|
package/dist/pcd-worker.js
CHANGED
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
return await parser(data, { ...options }, context, loader);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
// ../schema/src/lib/mesh/mesh-utils.ts
|
|
202
|
+
// ../schema-utils/src/lib/mesh/mesh-utils.ts
|
|
203
203
|
function getMeshBoundingBox(attributes) {
|
|
204
204
|
let minX = Infinity;
|
|
205
205
|
let minY = Infinity;
|
|
@@ -280,25 +280,38 @@
|
|
|
280
280
|
|
|
281
281
|
// src/lib/get-pcd-schema.ts
|
|
282
282
|
function getPCDSchema(PCDheader, metadata) {
|
|
283
|
-
const offset = PCDheader.offset;
|
|
284
283
|
const fields = [];
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
284
|
+
for (const key of Object.keys(PCDheader.offset)) {
|
|
285
|
+
switch (key) {
|
|
286
|
+
case "x":
|
|
287
|
+
fields.push({
|
|
288
|
+
name: "POSITION",
|
|
289
|
+
type: { type: "fixed-size-list", listSize: 3, children: [{ name: "xyz", type: "float32" }] },
|
|
290
|
+
metadata: { attribute: "POSITION" }
|
|
291
|
+
});
|
|
292
|
+
break;
|
|
293
|
+
case "y":
|
|
294
|
+
case "z":
|
|
295
|
+
break;
|
|
296
|
+
case "normal_x":
|
|
297
|
+
fields.push({
|
|
298
|
+
name: "NORMAL",
|
|
299
|
+
type: { type: "fixed-size-list", listSize: 3, children: [{ name: "xyz", type: "float32" }] },
|
|
300
|
+
metadata: { attribute: "NORMAL" }
|
|
301
|
+
});
|
|
302
|
+
break;
|
|
303
|
+
case "normal_y":
|
|
304
|
+
case "normal_z":
|
|
305
|
+
break;
|
|
306
|
+
case "rgb":
|
|
307
|
+
fields.push({
|
|
308
|
+
name: "COLOR_0",
|
|
309
|
+
type: { type: "fixed-size-list", listSize: 3, children: [{ name: "rgb", type: "uint8" }] },
|
|
310
|
+
metadata: { attribute: "COLOR" }
|
|
311
|
+
});
|
|
312
|
+
break;
|
|
313
|
+
default:
|
|
314
|
+
}
|
|
302
315
|
}
|
|
303
316
|
return { fields, metadata };
|
|
304
317
|
}
|
|
@@ -324,19 +337,20 @@
|
|
|
324
337
|
}
|
|
325
338
|
attributes = getMeshAttributes(attributes);
|
|
326
339
|
const header = getMeshHeader(pcdHeader, attributes);
|
|
327
|
-
const
|
|
340
|
+
const schemaMetadata = Object.fromEntries([
|
|
341
|
+
["topology", "point-list"],
|
|
328
342
|
["mode", "0"],
|
|
329
343
|
["boundingBox", JSON.stringify(header.boundingBox)]
|
|
330
344
|
]);
|
|
331
|
-
const schema = getPCDSchema(pcdHeader,
|
|
345
|
+
const schema = getPCDSchema(pcdHeader, schemaMetadata);
|
|
332
346
|
return {
|
|
333
347
|
loader: "pcd",
|
|
334
348
|
loaderData: pcdHeader,
|
|
335
349
|
header,
|
|
336
350
|
schema,
|
|
337
|
-
mode: 0,
|
|
338
|
-
// POINTS
|
|
339
351
|
topology: "point-list",
|
|
352
|
+
mode: 0,
|
|
353
|
+
// POINTS (deprecated)
|
|
340
354
|
attributes
|
|
341
355
|
};
|
|
342
356
|
}
|
|
@@ -617,32 +631,38 @@
|
|
|
617
631
|
};
|
|
618
632
|
}
|
|
619
633
|
|
|
620
|
-
// src/pcd-
|
|
621
|
-
var
|
|
622
|
-
var PCDLoader = {
|
|
623
|
-
dataType: null,
|
|
624
|
-
batchType: null,
|
|
634
|
+
// src/pcd-format.ts
|
|
635
|
+
var PCDFormat = {
|
|
625
636
|
name: "PCD (Point Cloud Data)",
|
|
626
637
|
id: "pcd",
|
|
627
638
|
module: "pcd",
|
|
628
|
-
version: VERSION,
|
|
629
|
-
worker: true,
|
|
630
639
|
extensions: ["pcd"],
|
|
631
640
|
mimeTypes: ["text/plain"],
|
|
641
|
+
category: "pointcloud",
|
|
642
|
+
text: true,
|
|
643
|
+
binary: true
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
// src/pcd-loader.ts
|
|
647
|
+
var VERSION = true ? "4.4.0-alpha.1" : "latest";
|
|
648
|
+
var PCDWorkerLoader = {
|
|
649
|
+
...PCDFormat,
|
|
650
|
+
dataType: null,
|
|
651
|
+
batchType: null,
|
|
652
|
+
version: VERSION,
|
|
653
|
+
worker: true,
|
|
632
654
|
options: {
|
|
633
655
|
pcd: {}
|
|
634
656
|
}
|
|
635
657
|
};
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
var PCDLoader2 = {
|
|
639
|
-
...PCDLoader,
|
|
658
|
+
var PCDLoader = {
|
|
659
|
+
...PCDWorkerLoader,
|
|
640
660
|
parse: async (arrayBuffer) => parsePCD(arrayBuffer),
|
|
641
661
|
parseSync: parsePCD
|
|
642
662
|
};
|
|
643
663
|
|
|
644
664
|
// src/workers/pcd-worker.ts
|
|
645
|
-
createLoaderWorker(
|
|
665
|
+
createLoaderWorker(PCDLoader);
|
|
646
666
|
})();
|
|
647
667
|
/** Parse compressed PCD data in in binary_compressed form ( https://pointclouds.org/documentation/tutorials/pcd_file_format.html)
|
|
648
668
|
* from https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PCDLoader.js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/pcd",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0-alpha.2",
|
|
4
4
|
"description": "Framework-independent loader for the PCD format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -42,11 +42,12 @@
|
|
|
42
42
|
"build-worker": "esbuild src/workers/pcd-worker.ts --bundle --outfile=dist/pcd-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@loaders.gl/loader-utils": "4.
|
|
46
|
-
"@loaders.gl/schema": "4.
|
|
45
|
+
"@loaders.gl/loader-utils": "4.4.0-alpha.2",
|
|
46
|
+
"@loaders.gl/schema": "4.4.0-alpha.2",
|
|
47
|
+
"@loaders.gl/schema-utils": "4.4.0-alpha.2"
|
|
47
48
|
},
|
|
48
49
|
"peerDependencies": {
|
|
49
|
-
"@loaders.gl/core": "
|
|
50
|
+
"@loaders.gl/core": "4.4.0-alpha.1"
|
|
50
51
|
},
|
|
51
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "3d9fed050eabdc0812ddf2f4d5fb9914a34ee0c2"
|
|
52
53
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,20 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
6
|
-
import parsePCDSync from './lib/parse-pcd';
|
|
7
|
-
import {PCDLoader as PCDWorkerLoader} from './pcd-loader';
|
|
8
|
-
import {PCDMesh} from './lib/pcd-types';
|
|
9
|
-
|
|
10
5
|
export type {PCDLoaderOptions} from './pcd-loader';
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Loader for PCD - Point Cloud Data
|
|
16
|
-
*/
|
|
17
|
-
export const PCDLoader = {
|
|
18
|
-
...PCDWorkerLoader,
|
|
19
|
-
parse: async (arrayBuffer) => parsePCDSync(arrayBuffer),
|
|
20
|
-
parseSync: parsePCDSync
|
|
21
|
-
} as const satisfies LoaderWithParser<PCDMesh, never, LoaderOptions>;
|
|
6
|
+
export {PCDWorkerLoader, PCDLoader} from './pcd-loader';
|
|
7
|
+
export {PCDArrowLoader} from './pcd-arrow-loader';
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// Forked from https://gitlab.com/taketwo/three-pcd-loader/blob/master/decompress-lzf.js
|
|
5
|
+
|
|
1
6
|
/* eslint-disable */
|
|
2
7
|
/**
|
|
3
|
-
* from https://gitlab.com/taketwo/three-pcd-loader/blob/master/decompress-lzf.js
|
|
4
8
|
* @param inData
|
|
5
9
|
* @param outLength
|
|
6
10
|
* @returns
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {Schema, Field} from '@loaders.gl/schema';
|
|
2
6
|
import type {PCDHeader} from './pcd-types';
|
|
3
7
|
|
|
@@ -8,29 +12,45 @@ import type {PCDHeader} from './pcd-types';
|
|
|
8
12
|
* @returns Schema
|
|
9
13
|
*/
|
|
10
14
|
export function getPCDSchema(PCDheader: PCDHeader, metadata: Record<string, string>): Schema {
|
|
11
|
-
const offset = PCDheader.offset;
|
|
12
|
-
|
|
13
15
|
const fields: Field[] = [];
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
for (const key of Object.keys(PCDheader.offset)) {
|
|
18
|
+
switch (key) {
|
|
19
|
+
case 'x':
|
|
20
|
+
fields.push({
|
|
21
|
+
name: 'POSITION',
|
|
22
|
+
type: {type: 'fixed-size-list', listSize: 3, children: [{name: 'xyz', type: 'float32'}]},
|
|
23
|
+
metadata: {attribute: 'POSITION'}
|
|
24
|
+
});
|
|
25
|
+
break;
|
|
26
|
+
case 'y':
|
|
27
|
+
case 'z':
|
|
28
|
+
// ignore
|
|
29
|
+
break;
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
case 'normal_x':
|
|
32
|
+
fields.push({
|
|
33
|
+
name: 'NORMAL',
|
|
34
|
+
type: {type: 'fixed-size-list', listSize: 3, children: [{name: 'xyz', type: 'float32'}]},
|
|
35
|
+
metadata: {attribute: 'NORMAL'}
|
|
36
|
+
});
|
|
37
|
+
break;
|
|
38
|
+
case 'normal_y':
|
|
39
|
+
case 'normal_z':
|
|
40
|
+
// ignore
|
|
41
|
+
break;
|
|
42
|
+
|
|
43
|
+
case 'rgb':
|
|
44
|
+
fields.push({
|
|
45
|
+
name: 'COLOR_0',
|
|
46
|
+
type: {type: 'fixed-size-list', listSize: 3, children: [{name: 'rgb', type: 'uint8'}]},
|
|
47
|
+
metadata: {attribute: 'COLOR'}
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
28
50
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type: {type: 'fixed-size-list', listSize: 3, children: [{name: 'rgb', type: 'uint8'}]}
|
|
33
|
-
});
|
|
51
|
+
default:
|
|
52
|
+
// TODO - push fields
|
|
53
|
+
}
|
|
34
54
|
}
|
|
35
55
|
|
|
36
56
|
return {fields, metadata};
|
package/src/lib/parse-pcd.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
// PCD Loader, adapted from THREE.js (MIT license)
|
|
2
6
|
// Description: A loader for PCD ascii and binary files.
|
|
3
7
|
// Limitations: Compressed binary files are not supported.
|
|
@@ -6,7 +10,8 @@
|
|
|
6
10
|
// @author Filipe Caixeta / http://filipecaixeta.com.br
|
|
7
11
|
// @author Mugen87 / https://github.com/Mugen87
|
|
8
12
|
|
|
9
|
-
import {MeshAttribute, MeshAttributes
|
|
13
|
+
import {MeshAttribute, MeshAttributes} from '@loaders.gl/schema';
|
|
14
|
+
import {getMeshBoundingBox} from '@loaders.gl/schema-utils';
|
|
10
15
|
import {decompressLZF} from './decompress-lzf';
|
|
11
16
|
import {getPCDSchema} from './get-pcd-schema';
|
|
12
17
|
import type {PCDHeader, PCDMesh} from './pcd-types';
|
|
@@ -42,7 +47,7 @@ const LITTLE_ENDIAN: boolean = true;
|
|
|
42
47
|
* @param data
|
|
43
48
|
* @returns
|
|
44
49
|
*/
|
|
45
|
-
export
|
|
50
|
+
export function parsePCD(data: ArrayBufferLike): PCDMesh {
|
|
46
51
|
// parse header (always ascii format)
|
|
47
52
|
const textData = new TextDecoder().decode(data);
|
|
48
53
|
const pcdHeader = parsePCDHeader(textData);
|
|
@@ -71,20 +76,21 @@ export default function parsePCD(data: ArrayBufferLike): PCDMesh {
|
|
|
71
76
|
|
|
72
77
|
const header = getMeshHeader(pcdHeader, attributes);
|
|
73
78
|
|
|
74
|
-
const
|
|
79
|
+
const schemaMetadata = Object.fromEntries([
|
|
80
|
+
['topology', 'point-list'],
|
|
75
81
|
['mode', '0'],
|
|
76
82
|
['boundingBox', JSON.stringify(header.boundingBox)]
|
|
77
83
|
]);
|
|
78
84
|
|
|
79
|
-
const schema = getPCDSchema(pcdHeader,
|
|
85
|
+
const schema = getPCDSchema(pcdHeader, schemaMetadata);
|
|
80
86
|
|
|
81
87
|
return {
|
|
82
88
|
loader: 'pcd',
|
|
83
89
|
loaderData: pcdHeader,
|
|
84
90
|
header,
|
|
85
91
|
schema,
|
|
86
|
-
mode: 0, // POINTS
|
|
87
92
|
topology: 'point-list',
|
|
93
|
+
mode: 0, // POINTS (deprecated)
|
|
88
94
|
attributes
|
|
89
95
|
};
|
|
90
96
|
}
|
package/src/lib/pcd-types.ts
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {ArrowTable} from '@loaders.gl/schema';
|
|
7
|
+
|
|
8
|
+
import {PCDLoaderOptions, PCDWorkerLoader} from './pcd-loader';
|
|
9
|
+
import {convertMeshToTable} from '@loaders.gl/schema-utils';
|
|
10
|
+
import {parsePCD} from './lib/parse-pcd';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Worker loader for PCD - Point Cloud Data
|
|
14
|
+
*/
|
|
15
|
+
export const PCDArrowLoader = {
|
|
16
|
+
...PCDWorkerLoader,
|
|
17
|
+
dataType: null as unknown as ArrowTable,
|
|
18
|
+
batchType: null as never,
|
|
19
|
+
worker: false,
|
|
20
|
+
parse: async (arrayBuffer: ArrayBuffer) => {
|
|
21
|
+
const mesh = parsePCD(arrayBuffer);
|
|
22
|
+
const arrowTable = convertMeshToTable(mesh, 'arrow-table');
|
|
23
|
+
return arrowTable;
|
|
24
|
+
}
|
|
25
|
+
} as const satisfies LoaderWithParser<ArrowTable, never, PCDLoaderOptions>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Format} from '@loaders.gl/loader-utils';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* PCD (Point Cloud Data) file format
|
|
9
|
+
*/
|
|
10
|
+
export const PCDFormat = {
|
|
11
|
+
name: 'PCD (Point Cloud Data)',
|
|
12
|
+
id: 'pcd',
|
|
13
|
+
module: 'pcd',
|
|
14
|
+
extensions: ['pcd'],
|
|
15
|
+
mimeTypes: ['text/plain'],
|
|
16
|
+
category: 'pointcloud',
|
|
17
|
+
text: true,
|
|
18
|
+
binary: true
|
|
19
|
+
} as const satisfies Format;
|
package/src/pcd-loader.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
6
|
-
import {PCDMesh} from './lib/pcd-types';
|
|
5
|
+
import type {Loader, LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {PCDMesh} from './lib/pcd-types';
|
|
7
|
+
import {parsePCD} from './lib/parse-pcd';
|
|
8
|
+
import {PCDFormat} from './pcd-format';
|
|
7
9
|
|
|
8
10
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
9
11
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
@@ -19,18 +21,22 @@ export type PCDLoaderOptions = LoaderOptions & {
|
|
|
19
21
|
/**
|
|
20
22
|
* Worker loader for PCD - Point Cloud Data
|
|
21
23
|
*/
|
|
22
|
-
export const
|
|
24
|
+
export const PCDWorkerLoader = {
|
|
25
|
+
...PCDFormat,
|
|
23
26
|
dataType: null as unknown as PCDMesh,
|
|
24
27
|
batchType: null as never,
|
|
25
|
-
|
|
26
|
-
name: 'PCD (Point Cloud Data)',
|
|
27
|
-
id: 'pcd',
|
|
28
|
-
module: 'pcd',
|
|
29
28
|
version: VERSION,
|
|
30
29
|
worker: true,
|
|
31
|
-
extensions: ['pcd'],
|
|
32
|
-
mimeTypes: ['text/plain'],
|
|
33
30
|
options: {
|
|
34
31
|
pcd: {}
|
|
35
32
|
}
|
|
36
33
|
} as const satisfies Loader<PCDMesh, never, PCDLoaderOptions>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Loader for PCD - Point Cloud Data
|
|
37
|
+
*/
|
|
38
|
+
export const PCDLoader = {
|
|
39
|
+
...PCDWorkerLoader,
|
|
40
|
+
parse: async (arrayBuffer) => parsePCD(arrayBuffer),
|
|
41
|
+
parseSync: parsePCD
|
|
42
|
+
} as const satisfies LoaderWithParser<PCDMesh, never, LoaderOptions>;
|