Skip to content

Commit

Permalink
chore: Enable both lazperf and laz-rs-wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
alekzvik authored and ibgreen committed Dec 2, 2024
1 parent 2d13ec2 commit 99b1b05
Show file tree
Hide file tree
Showing 16 changed files with 21,397 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ examples/experimental/gltf-with-raw-webgl/

modules/potree/test/data/**/cloud.js

modules/las/src/lib/libs
modules/las/src/libs

modules/flatgeobuf/src/lib/binary-geometries.ts

Expand Down
9 changes: 8 additions & 1 deletion modules/las/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@
export {LASFormat} from './las-format';

export type {LASLoaderOptions} from './las-loader';
export {LASWorkerLoader, LASLoader} from './las-loader';
export {LASWorkerLoader} from './las-loader';

// Export the laz-perf based loader as default LASLoader until we have done more testing
export {LAZPerfLoader as LASLoader} from './lazperf-loader';
export {LASArrowLoader} from './las-arrow-loader';

// Implementation specific loaders, for bench marking and testing
export {LAZPerfLoader} from './lazperf-loader';
export {LAZRsLoader} from './laz-rs-loader';
10 changes: 6 additions & 4 deletions modules/las/src/las-arrow-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@

import type {LoaderWithParser} from '@loaders.gl/loader-utils';
import type {ArrowTable} from '@loaders.gl/schema';

import {LASLoaderOptions, LASLoader} from './las-loader';
import {convertMeshToTable} from '@loaders.gl/schema-utils';

import type {LASLoaderOptions} from './las-loader';
import {LAZPerfLoader} from './lazperf-loader';

/**
* Worker loader for LAS - Point Cloud Data
*/
export const LASArrowLoader = {
...LASLoader,
...LAZPerfLoader,
dataType: null as unknown as ArrowTable,
batchType: null as never,
worker: false,
parse: async (arrayBuffer: ArrayBuffer) => {
const mesh = await LASLoader.parse(arrayBuffer);
const mesh = await LAZPerfLoader.parse(arrayBuffer);
const arrowTable = convertMeshToTable(mesh, 'arrow-table');
return arrowTable;
}
// @ts-expect-error parseSync
} as const satisfies LoaderWithParser<ArrowTable, never, LASLoaderOptions>;
15 changes: 1 addition & 14 deletions modules/las/src/las-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
// Copyright (c) vis.gl contributors

// LASER (LAS) FILE FORMAT
import type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';
import type {LASMesh} from './lib/las-types';
import {LASFormat} from './las-format';
import {parseLAS} from './lib/parse-las';
import initLazRsWasm from './lib/libs/laz_rs_wasm';

// __VERSION__ is injected by babel-plugin-version-inline
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
Expand Down Expand Up @@ -45,14 +43,3 @@ export const LASWorkerLoader = {
}
}
} as const satisfies Loader<LASMesh, never, LASLoaderOptions>;

/**
* Loader for the LAS (LASer) point cloud format
*/
export const LASLoader = {
...LASWorkerLoader,
parse: async (arrayBuffer: ArrayBuffer, options?: LASLoaderOptions) => {
await initLazRsWasm();
return parseLAS(arrayBuffer, {...options});
}
} as const satisfies LoaderWithParser<LASMesh, never, LASLoaderOptions>;
22 changes: 22 additions & 0 deletions modules/las/src/laz-rs-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// loaders.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors

// LASER (LAS) FILE FORMAT
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
import type {LASLoaderOptions} from './las-loader';
import {LASWorkerLoader} from './las-loader';
import type {LASMesh} from './lib/las-types';
import {parseLAS} from './lib/laz-rs-wasm/parse-las';
import initLazRsWasm from './libs/laz-rs-wasm/laz_rs_wasm';

/**
* Loader for the LAS (LASer) point cloud format
*/
export const LAZRsLoader = {
...LASWorkerLoader,
parse: async (arrayBuffer: ArrayBuffer, options?: LASLoaderOptions) => {
await initLazRsWasm();
return parseLAS(arrayBuffer, {...options});
}
} as const satisfies LoaderWithParser<LASMesh, never, LASLoaderOptions>;
22 changes: 22 additions & 0 deletions modules/las/src/lazperf-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// loaders.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors

// LASER (LAS) FILE FORMAT
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
import type {LASLoaderOptions} from './las-loader';
import {LASWorkerLoader} from './las-loader';
import type {LASMesh} from './lib/las-types';
import {parseLAS} from './lib/laz-perf/parse-las';

/**
* Loader for the LAS (LASer) point cloud format
* @note Does not support LAS v1.4
*/
export const LAZPerfLoader = {
...LASWorkerLoader,
parse: async (arrayBuffer: ArrayBuffer, options?: LASLoaderOptions) =>
parseLAS(arrayBuffer, options),
parseSync: (arrayBuffer: ArrayBuffer, options?: LASLoaderOptions) =>
parseLAS(arrayBuffer, options)
} as const satisfies LoaderWithParser<LASMesh, never, LASLoaderOptions>;
Loading

0 comments on commit 99b1b05

Please sign in to comment.