@loaders.gl/pointclouds 0.0.0-stage → 5.0.0-beta.1
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/LAS-README.md +12 -0
- package/LICENSE +24 -0
- package/PCD-README.md +12 -0
- package/PLY-README.md +38 -0
- package/README.md +7 -2
- package/THIRD-PARTY-NOTICES.md +27 -0
- package/dist/dist.dev.js +30141 -0
- package/dist/dist.min.js +54 -0
- package/dist/index.cjs +61 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/las/bundled.cjs +72 -0
- package/dist/las/bundled.cjs.map +7 -0
- package/dist/las/bundled.d.ts +12 -0
- package/dist/las/bundled.d.ts.map +1 -0
- package/dist/las/bundled.js +12 -0
- package/dist/las/bundled.js.map +1 -0
- package/dist/las/index.cjs +78 -0
- package/dist/las/index.cjs.map +7 -0
- package/dist/las/index.d.ts +17 -0
- package/dist/las/index.d.ts.map +1 -0
- package/dist/las/index.js +15 -0
- package/dist/las/index.js.map +1 -0
- package/dist/las/las-copc-loader-types.cjs +49 -0
- package/dist/las/las-copc-loader-types.cjs.map +7 -0
- package/dist/las/las-copc-loader-types.d.ts +63 -0
- package/dist/las/las-copc-loader-types.d.ts.map +1 -0
- package/dist/las/las-copc-loader-types.js +14 -0
- package/dist/las/las-copc-loader-types.js.map +1 -0
- package/dist/las/las-copc-loader.cjs +57 -0
- package/dist/las/las-copc-loader.cjs.map +7 -0
- package/dist/las/las-copc-loader.d.ts +37 -0
- package/dist/las/las-copc-loader.d.ts.map +1 -0
- package/dist/las/las-copc-loader.js +40 -0
- package/dist/las/las-copc-loader.js.map +1 -0
- package/dist/las/las-format.cjs +44 -0
- package/dist/las/las-format.cjs.map +7 -0
- package/dist/las/las-format.d.ts +16 -0
- package/dist/las/las-format.d.ts.map +1 -0
- package/dist/las/las-format.js +19 -0
- package/dist/las/las-format.js.map +1 -0
- package/dist/las/las-loader-shared.cjs +82 -0
- package/dist/las/las-loader-shared.cjs.map +7 -0
- package/dist/las/las-loader-shared.d.ts +66 -0
- package/dist/las/las-loader-shared.d.ts.map +1 -0
- package/dist/las/las-loader-shared.js +58 -0
- package/dist/las/las-loader-shared.js.map +1 -0
- package/dist/las/las-loader-types.cjs +54 -0
- package/dist/las/las-loader-types.cjs.map +7 -0
- package/dist/las/las-loader-types.d.ts +104 -0
- package/dist/las/las-loader-types.d.ts.map +1 -0
- package/dist/las/las-loader-types.js +19 -0
- package/dist/las/las-loader-types.js.map +1 -0
- package/dist/las/las-loader.cjs +80 -0
- package/dist/las/las-loader.cjs.map +7 -0
- package/dist/las/las-loader.d.ts +45 -0
- package/dist/las/las-loader.d.ts.map +1 -0
- package/dist/las/las-loader.js +58 -0
- package/dist/las/las-loader.js.map +1 -0
- package/dist/las/las-writer.cjs +1054 -0
- package/dist/las/las-writer.cjs.map +7 -0
- package/dist/las/las-writer.d.ts +69 -0
- package/dist/las/las-writer.d.ts.map +1 -0
- package/dist/las/las-writer.js +994 -0
- package/dist/las/las-writer.js.map +1 -0
- package/dist/las/laz-rs-loader-types.cjs +49 -0
- package/dist/las/laz-rs-loader-types.cjs.map +7 -0
- package/dist/las/laz-rs-loader-types.d.ts +65 -0
- package/dist/las/laz-rs-loader-types.d.ts.map +1 -0
- package/dist/las/laz-rs-loader-types.js +16 -0
- package/dist/las/laz-rs-loader-types.js.map +1 -0
- package/dist/las/laz-rs-loader.cjs +272 -0
- package/dist/las/laz-rs-loader.cjs.map +7 -0
- package/dist/las/laz-rs-loader.d.ts +37 -0
- package/dist/las/laz-rs-loader.d.ts.map +1 -0
- package/dist/las/laz-rs-loader.js +38 -0
- package/dist/las/laz-rs-loader.js.map +1 -0
- package/dist/las/lazperf-loader-types.cjs +49 -0
- package/dist/las/lazperf-loader-types.cjs.map +7 -0
- package/dist/las/lazperf-loader-types.d.ts +67 -0
- package/dist/las/lazperf-loader-types.d.ts.map +1 -0
- package/dist/las/lazperf-loader-types.js +17 -0
- package/dist/las/lazperf-loader-types.js.map +1 -0
- package/dist/las/lazperf-loader.cjs +60 -0
- package/dist/las/lazperf-loader.cjs.map +7 -0
- package/dist/las/lazperf-loader.d.ts +39 -0
- package/dist/las/lazperf-loader.d.ts.map +1 -0
- package/dist/las/lazperf-loader.js +44 -0
- package/dist/las/lazperf-loader.js.map +1 -0
- package/dist/las/lib/copc/parse-las.cjs +177 -0
- package/dist/las/lib/copc/parse-las.cjs.map +7 -0
- package/dist/las/lib/copc/parse-las.d.ts +17 -0
- package/dist/las/lib/copc/parse-las.d.ts.map +1 -0
- package/dist/las/lib/copc/parse-las.js +215 -0
- package/dist/las/lib/copc/parse-las.js.map +1 -0
- package/dist/las/lib/get-las-schema.cjs +62 -0
- package/dist/las/lib/get-las-schema.cjs.map +7 -0
- package/dist/las/lib/get-las-schema.d.ts +16 -0
- package/dist/las/lib/get-las-schema.d.ts.map +1 -0
- package/dist/las/lib/get-las-schema.js +46 -0
- package/dist/las/lib/get-las-schema.js.map +1 -0
- package/dist/las/lib/las-compatibility.cjs +110 -0
- package/dist/las/lib/las-compatibility.cjs.map +7 -0
- package/dist/las/lib/las-compatibility.d.ts +40 -0
- package/dist/las/lib/las-compatibility.d.ts.map +1 -0
- package/dist/las/lib/las-compatibility.js +115 -0
- package/dist/las/lib/las-compatibility.js.map +1 -0
- package/dist/las/lib/las-extra-bytes.cjs +223 -0
- package/dist/las/lib/las-extra-bytes.cjs.map +7 -0
- package/dist/las/lib/las-extra-bytes.d.ts +35 -0
- package/dist/las/lib/las-extra-bytes.d.ts.map +1 -0
- package/dist/las/lib/las-extra-bytes.js +195 -0
- package/dist/las/lib/las-extra-bytes.js.map +1 -0
- package/dist/las/lib/las-types.cjs +19 -0
- package/dist/las/lib/las-types.cjs.map +7 -0
- package/dist/las/lib/las-types.d.ts +194 -0
- package/dist/las/lib/las-types.d.ts.map +1 -0
- package/dist/las/lib/las-types.js +5 -0
- package/dist/las/lib/las-types.js.map +1 -0
- package/dist/las/lib/las-waveform.cjs +196 -0
- package/dist/las/lib/las-waveform.cjs.map +7 -0
- package/dist/las/lib/las-waveform.d.ts +89 -0
- package/dist/las/lib/las-waveform.d.ts.map +1 -0
- package/dist/las/lib/las-waveform.js +193 -0
- package/dist/las/lib/las-waveform.js.map +1 -0
- package/dist/las/lib/laz-perf/laslaz-decoder.cjs +382 -0
- package/dist/las/lib/laz-perf/laslaz-decoder.cjs.map +7 -0
- package/dist/las/lib/laz-perf/laslaz-decoder.d.ts +129 -0
- package/dist/las/lib/laz-perf/laslaz-decoder.d.ts.map +1 -0
- package/dist/las/lib/laz-perf/laslaz-decoder.js +377 -0
- package/dist/las/lib/laz-perf/laslaz-decoder.js.map +1 -0
- package/dist/las/lib/laz-perf/parse-las.cjs +270 -0
- package/dist/las/lib/laz-perf/parse-las.cjs.map +7 -0
- package/dist/las/lib/laz-perf/parse-las.d.ts +24 -0
- package/dist/las/lib/laz-perf/parse-las.d.ts.map +1 -0
- package/dist/las/lib/laz-perf/parse-las.js +307 -0
- package/dist/las/lib/laz-perf/parse-las.js.map +1 -0
- package/dist/las/lib/laz-rs-wasm/laslaz-decoder.cjs +631 -0
- package/dist/las/lib/laz-rs-wasm/laslaz-decoder.cjs.map +7 -0
- package/dist/las/lib/laz-rs-wasm/laslaz-decoder.d.ts +129 -0
- package/dist/las/lib/laz-rs-wasm/laslaz-decoder.d.ts.map +1 -0
- package/dist/las/lib/laz-rs-wasm/laslaz-decoder.js +414 -0
- package/dist/las/lib/laz-rs-wasm/laslaz-decoder.js.map +1 -0
- package/dist/las/lib/laz-rs-wasm/parse-las.cjs +270 -0
- package/dist/las/lib/laz-rs-wasm/parse-las.cjs.map +7 -0
- package/dist/las/lib/laz-rs-wasm/parse-las.d.ts +24 -0
- package/dist/las/lib/laz-rs-wasm/parse-las.d.ts.map +1 -0
- package/dist/las/lib/laz-rs-wasm/parse-las.js +307 -0
- package/dist/las/lib/laz-rs-wasm/parse-las.js.map +1 -0
- package/dist/las/lib/typescript/parse-las.cjs +2767 -0
- package/dist/las/lib/typescript/parse-las.cjs.map +7 -0
- package/dist/las/lib/typescript/parse-las.d.ts +39 -0
- package/dist/las/lib/typescript/parse-las.d.ts.map +1 -0
- package/dist/las/lib/typescript/parse-las.js +2607 -0
- package/dist/las/lib/typescript/parse-las.js.map +1 -0
- package/dist/las/libs/laz-perf/laz-perf.cjs +18093 -0
- package/dist/las/libs/laz-perf/laz-perf.cjs.map +7 -0
- package/dist/las/libs/laz-perf/laz-perf.d.ts +2 -0
- package/dist/las/libs/laz-perf/laz-perf.d.ts.map +1 -0
- package/dist/las/libs/laz-perf/laz-perf.js +19003 -0
- package/dist/las/libs/laz-perf/laz-perf.js.map +1 -0
- package/dist/las/libs/laz-rs-wasm/laz_rs_wasm.d.ts +95 -0
- package/dist/las/libs/laz-rs-wasm/laz_rs_wasm.d.ts.map +1 -0
- package/dist/las/libs/laz-rs-wasm/laz_rs_wasm.js +442 -0
- package/dist/las/libs/laz-rs-wasm/laz_rs_wasm.js.map +1 -0
- package/dist/las/libs/laz-rs-wasm/laz_rs_wasm_bg.wasm +0 -0
- package/dist/las/libs/laz-rs-wasm/laz_rs_wasm_bg.wasm.d.ts +38 -0
- package/dist/las/unbundled.cjs +71 -0
- package/dist/las/unbundled.cjs.map +7 -0
- package/dist/las/unbundled.d.ts +11 -0
- package/dist/las/unbundled.d.ts.map +1 -0
- package/dist/las/unbundled.js +11 -0
- package/dist/las/unbundled.js.map +1 -0
- package/dist/las/workers/las-worker.cjs +23 -0
- package/dist/las/workers/las-worker.cjs.map +7 -0
- package/dist/las/workers/las-worker.d.ts +2 -0
- package/dist/las/workers/las-worker.d.ts.map +1 -0
- package/dist/las/workers/las-worker.js +23 -0
- package/dist/las/workers/las-worker.js.map +1 -0
- package/dist/las-worker.js +23058 -0
- package/dist/pcd/bundled.cjs +33 -0
- package/dist/pcd/bundled.cjs.map +7 -0
- package/dist/pcd/bundled.d.ts +3 -0
- package/dist/pcd/bundled.d.ts.map +1 -0
- package/dist/pcd/bundled.js +5 -0
- package/dist/pcd/bundled.js.map +1 -0
- package/dist/pcd/index.cjs +40 -0
- package/dist/pcd/index.cjs.map +7 -0
- package/dist/pcd/index.d.ts +8 -0
- package/dist/pcd/index.d.ts.map +1 -0
- package/dist/pcd/index.js +10 -0
- package/dist/pcd/index.js.map +1 -0
- package/dist/pcd/lib/decompress-lzf.cjs +80 -0
- package/dist/pcd/lib/decompress-lzf.cjs.map +7 -0
- package/dist/pcd/lib/decompress-lzf.d.ts +7 -0
- package/dist/pcd/lib/decompress-lzf.d.ts.map +1 -0
- package/dist/pcd/lib/decompress-lzf.js +62 -0
- package/dist/pcd/lib/decompress-lzf.js.map +1 -0
- package/dist/pcd/lib/get-pcd-schema.cjs +70 -0
- package/dist/pcd/lib/get-pcd-schema.cjs.map +7 -0
- package/dist/pcd/lib/get-pcd-schema.d.ts +10 -0
- package/dist/pcd/lib/get-pcd-schema.d.ts.map +1 -0
- package/dist/pcd/lib/get-pcd-schema.js +53 -0
- package/dist/pcd/lib/get-pcd-schema.js.map +1 -0
- package/dist/pcd/lib/parse-pcd.cjs +354 -0
- package/dist/pcd/lib/parse-pcd.cjs.map +7 -0
- package/dist/pcd/lib/parse-pcd.d.ts +20 -0
- package/dist/pcd/lib/parse-pcd.d.ts.map +1 -0
- package/dist/pcd/lib/parse-pcd.js +341 -0
- package/dist/pcd/lib/parse-pcd.js.map +1 -0
- package/dist/pcd/lib/pcd-types.cjs +19 -0
- package/dist/pcd/lib/pcd-types.cjs.map +7 -0
- package/dist/pcd/lib/pcd-types.d.ts +31 -0
- package/dist/pcd/lib/pcd-types.d.ts.map +1 -0
- package/dist/pcd/lib/pcd-types.js +5 -0
- package/dist/pcd/lib/pcd-types.js.map +1 -0
- package/dist/pcd/pcd-format.cjs +42 -0
- package/dist/pcd/pcd-format.cjs.map +7 -0
- package/dist/pcd/pcd-format.d.ts +16 -0
- package/dist/pcd/pcd-format.d.ts.map +1 -0
- package/dist/pcd/pcd-format.js +19 -0
- package/dist/pcd/pcd-format.js.map +1 -0
- package/dist/pcd/pcd-loader-types.cjs +64 -0
- package/dist/pcd/pcd-loader-types.cjs.map +7 -0
- package/dist/pcd/pcd-loader-types.d.ts +105 -0
- package/dist/pcd/pcd-loader-types.d.ts.map +1 -0
- package/dist/pcd/pcd-loader-types.js +35 -0
- package/dist/pcd/pcd-loader-types.js.map +1 -0
- package/dist/pcd/pcd-loader.cjs +144 -0
- package/dist/pcd/pcd-loader.cjs.map +7 -0
- package/dist/pcd/pcd-loader.d.ts +44 -0
- package/dist/pcd/pcd-loader.d.ts.map +1 -0
- package/dist/pcd/pcd-loader.js +128 -0
- package/dist/pcd/pcd-loader.js.map +1 -0
- package/dist/pcd/pcd-writer.cjs +134 -0
- package/dist/pcd/pcd-writer.cjs.map +7 -0
- package/dist/pcd/pcd-writer.d.ts +37 -0
- package/dist/pcd/pcd-writer.d.ts.map +1 -0
- package/dist/pcd/pcd-writer.js +115 -0
- package/dist/pcd/pcd-writer.js.map +1 -0
- package/dist/pcd/unbundled.cjs +33 -0
- package/dist/pcd/unbundled.cjs.map +7 -0
- package/dist/pcd/unbundled.d.ts +3 -0
- package/dist/pcd/unbundled.d.ts.map +1 -0
- package/dist/pcd/unbundled.js +5 -0
- package/dist/pcd/unbundled.js.map +1 -0
- package/dist/pcd/workers/pcd-worker.cjs +23 -0
- package/dist/pcd/workers/pcd-worker.cjs.map +7 -0
- package/dist/pcd/workers/pcd-worker.d.ts +2 -0
- package/dist/pcd/workers/pcd-worker.d.ts.map +1 -0
- package/dist/pcd/workers/pcd-worker.js +23 -0
- package/dist/pcd/workers/pcd-worker.js.map +1 -0
- package/dist/pcd-worker.js +17522 -0
- package/dist/ply/bundled.cjs +33 -0
- package/dist/ply/bundled.cjs.map +7 -0
- package/dist/ply/bundled.d.ts +3 -0
- package/dist/ply/bundled.d.ts.map +1 -0
- package/dist/ply/bundled.js +5 -0
- package/dist/ply/bundled.js.map +1 -0
- package/dist/ply/index.cjs +40 -0
- package/dist/ply/index.cjs.map +7 -0
- package/dist/ply/index.d.ts +8 -0
- package/dist/ply/index.d.ts.map +1 -0
- package/dist/ply/index.js +11 -0
- package/dist/ply/index.js.map +1 -0
- package/dist/ply/lib/get-ply-schema.cjs +126 -0
- package/dist/ply/lib/get-ply-schema.cjs.map +7 -0
- package/dist/ply/lib/get-ply-schema.d.ts +10 -0
- package/dist/ply/lib/get-ply-schema.d.ts.map +1 -0
- package/dist/ply/lib/get-ply-schema.js +117 -0
- package/dist/ply/lib/get-ply-schema.js.map +1 -0
- package/dist/ply/lib/normalize-ply.cjs +96 -0
- package/dist/ply/lib/normalize-ply.cjs.map +7 -0
- package/dist/ply/lib/normalize-ply.d.ts +8 -0
- package/dist/ply/lib/normalize-ply.d.ts.map +1 -0
- package/dist/ply/lib/normalize-ply.js +89 -0
- package/dist/ply/lib/normalize-ply.js.map +1 -0
- package/dist/ply/lib/parse-ply-arrow.cjs +552 -0
- package/dist/ply/lib/parse-ply-arrow.cjs.map +7 -0
- package/dist/ply/lib/parse-ply-arrow.d.ts +25 -0
- package/dist/ply/lib/parse-ply-arrow.d.ts.map +1 -0
- package/dist/ply/lib/parse-ply-arrow.js +493 -0
- package/dist/ply/lib/parse-ply-arrow.js.map +1 -0
- package/dist/ply/lib/parse-ply-in-batches.cjs +607 -0
- package/dist/ply/lib/parse-ply-in-batches.cjs.map +7 -0
- package/dist/ply/lib/parse-ply-in-batches.d.ts +9 -0
- package/dist/ply/lib/parse-ply-in-batches.d.ts.map +1 -0
- package/dist/ply/lib/parse-ply-in-batches.js +625 -0
- package/dist/ply/lib/parse-ply-in-batches.js.map +1 -0
- package/dist/ply/lib/parse-ply.cjs +755 -0
- package/dist/ply/lib/parse-ply.cjs.map +7 -0
- package/dist/ply/lib/parse-ply.d.ts +69 -0
- package/dist/ply/lib/parse-ply.d.ts.map +1 -0
- package/dist/ply/lib/parse-ply.js +851 -0
- package/dist/ply/lib/parse-ply.js.map +1 -0
- package/dist/ply/lib/ply-types.cjs +19 -0
- package/dist/ply/lib/ply-types.cjs.map +7 -0
- package/dist/ply/lib/ply-types.d.ts +37 -0
- package/dist/ply/lib/ply-types.d.ts.map +1 -0
- package/dist/ply/lib/ply-types.js +2 -0
- package/dist/ply/lib/ply-types.js.map +1 -0
- package/dist/ply/ply-format.cjs +43 -0
- package/dist/ply/ply-format.cjs.map +7 -0
- package/dist/ply/ply-format.d.ts +18 -0
- package/dist/ply/ply-format.d.ts.map +1 -0
- package/dist/ply/ply-format.js +22 -0
- package/dist/ply/ply-format.js.map +1 -0
- package/dist/ply/ply-loader-types.cjs +65 -0
- package/dist/ply/ply-loader-types.cjs.map +7 -0
- package/dist/ply/ply-loader-types.d.ts +111 -0
- package/dist/ply/ply-loader-types.d.ts.map +1 -0
- package/dist/ply/ply-loader-types.js +38 -0
- package/dist/ply/ply-loader-types.js.map +1 -0
- package/dist/ply/ply-loader.cjs +134 -0
- package/dist/ply/ply-loader.cjs.map +7 -0
- package/dist/ply/ply-loader.d.ts +44 -0
- package/dist/ply/ply-loader.d.ts.map +1 -0
- package/dist/ply/ply-loader.js +121 -0
- package/dist/ply/ply-loader.js.map +1 -0
- package/dist/ply/ply-writer.cjs +175 -0
- package/dist/ply/ply-writer.cjs.map +7 -0
- package/dist/ply/ply-writer.d.ts +37 -0
- package/dist/ply/ply-writer.d.ts.map +1 -0
- package/dist/ply/ply-writer.js +140 -0
- package/dist/ply/ply-writer.js.map +1 -0
- package/dist/ply/unbundled.cjs +33 -0
- package/dist/ply/unbundled.cjs.map +7 -0
- package/dist/ply/unbundled.d.ts +3 -0
- package/dist/ply/unbundled.d.ts.map +1 -0
- package/dist/ply/unbundled.js +5 -0
- package/dist/ply/unbundled.js.map +1 -0
- package/dist/ply/workers/ply-worker.cjs +34 -0
- package/dist/ply/workers/ply-worker.cjs.map +7 -0
- package/dist/ply/workers/ply-worker.d.ts +2 -0
- package/dist/ply/workers/ply-worker.d.ts.map +1 -0
- package/dist/ply/workers/ply-worker.js +37 -0
- package/dist/ply/workers/ply-worker.js.map +1 -0
- package/dist/ply-worker.js +19175 -0
- package/package.json +234 -4
- package/src/index.ts +19 -0
- package/src/las/bundled.ts +39 -0
- package/src/las/index.ts +70 -0
- package/src/las/las-copc-loader-types.ts +18 -0
- package/src/las/las-copc-loader.ts +61 -0
- package/src/las/las-format.ts +21 -0
- package/src/las/las-loader-shared.ts +124 -0
- package/src/las/las-loader-types.ts +27 -0
- package/src/las/las-loader.ts +109 -0
- package/src/las/las-writer.ts +1473 -0
- package/src/las/laz-rs-loader-types.ts +21 -0
- package/src/las/laz-rs-loader.ts +53 -0
- package/src/las/lazperf-loader-types.ts +22 -0
- package/src/las/lazperf-loader.ts +65 -0
- package/src/las/lib/LASZIP-LICENSE +202 -0
- package/src/las/lib/LASZIP-NOTICE +4 -0
- package/src/las/lib/copc/parse-las.ts +265 -0
- package/src/las/lib/get-las-schema.ts +50 -0
- package/src/las/lib/las-compatibility.ts +178 -0
- package/src/las/lib/las-extra-bytes.ts +274 -0
- package/src/las/lib/las-types.ts +206 -0
- package/src/las/lib/las-waveform.ts +292 -0
- package/src/las/lib/laz-perf/laslaz-decoder.ts +443 -0
- package/src/las/lib/laz-perf/parse-las.ts +412 -0
- package/src/las/lib/laz-rs-wasm/laslaz-decoder.ts +488 -0
- package/src/las/lib/laz-rs-wasm/parse-las.ts +412 -0
- package/src/las/lib/typescript/parse-las.ts +3730 -0
- package/src/las/libs/laz-perf/laz-perf.ts +20615 -0
- package/src/las/libs/laz-rs-wasm/laz_rs_wasm.d.ts +89 -0
- package/src/las/libs/laz-rs-wasm/laz_rs_wasm.js +497 -0
- package/src/las/libs/laz-rs-wasm/laz_rs_wasm_bg.wasm +0 -0
- package/src/las/libs/laz-rs-wasm/laz_rs_wasm_bg.wasm.d.ts +38 -0
- package/src/las/libs/laz-rs-wasm/package.json +19 -0
- package/src/las/unbundled.ts +38 -0
- package/src/las/workers/las-worker.ts +24 -0
- package/src/pcd/bundled.ts +9 -0
- package/src/pcd/index.ts +13 -0
- package/src/pcd/lib/decompress-lzf.ts +68 -0
- package/src/pcd/lib/get-pcd-schema.ts +66 -0
- package/src/pcd/lib/parse-pcd.ts +474 -0
- package/src/pcd/lib/pcd-types.ts +34 -0
- package/src/pcd/pcd-format.ts +21 -0
- package/src/pcd/pcd-loader-types.ts +53 -0
- package/src/pcd/pcd-loader.ts +179 -0
- package/src/pcd/pcd-writer.ts +152 -0
- package/src/pcd/unbundled.ts +6 -0
- package/src/pcd/workers/pcd-worker.ts +24 -0
- package/src/ply/bundled.ts +9 -0
- package/src/ply/index.ts +15 -0
- package/src/ply/lib/get-ply-schema.ts +133 -0
- package/src/ply/lib/normalize-ply.ts +110 -0
- package/src/ply/lib/parse-ply-arrow.ts +676 -0
- package/src/ply/lib/parse-ply-in-batches.ts +827 -0
- package/src/ply/lib/parse-ply.ts +1081 -0
- package/src/ply/lib/ply-types.ts +47 -0
- package/src/ply/ply-format.ts +24 -0
- package/src/ply/ply-loader-types.ts +61 -0
- package/src/ply/ply-loader.ts +185 -0
- package/src/ply/ply-writer.ts +215 -0
- package/src/ply/unbundled.ts +6 -0
- package/src/ply/workers/ply-worker.ts +40 -0
- package/third-party-licenses/plasio-LICENSE +21 -0
- package/third-party-licenses/three-LICENSE +21 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Format} from '@loaders.gl/core/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: 'pointclouds',
|
|
14
|
+
encoding: 'text',
|
|
15
|
+
format: 'pcd',
|
|
16
|
+
extensions: ['pcd'],
|
|
17
|
+
mimeTypes: ['text/plain'],
|
|
18
|
+
category: 'pointcloud',
|
|
19
|
+
text: true,
|
|
20
|
+
binary: true
|
|
21
|
+
} as const satisfies Format;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Loader, LoaderOptions} from '@loaders.gl/core/loader-utils';
|
|
6
|
+
import type {MeshArrowTable, ArrowTableBatch} from '@loaders.gl/core/schema';
|
|
7
|
+
import type {PCDMesh} from './lib/pcd-types';
|
|
8
|
+
import {PCDFormat} from './pcd-format';
|
|
9
|
+
import {serializeArrowWorkerTable} from '@loaders.gl/core/schema-utils/arrow-transport';
|
|
10
|
+
|
|
11
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
12
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
13
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
14
|
+
|
|
15
|
+
export type PCDLoaderOptions = LoaderOptions & {
|
|
16
|
+
pcd?: {
|
|
17
|
+
/** Output shape. Defaults to a Mesh Arrow table. */
|
|
18
|
+
shape?: 'mesh' | 'arrow-table';
|
|
19
|
+
/** Color storage format. Defaults to uint8norm for backwards compatibility. */
|
|
20
|
+
colorFormat?: 'uint8norm' | 'float16' | 'float32';
|
|
21
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
22
|
+
workerUrl?: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Preloads the parser-bearing PCD loader implementation.
|
|
28
|
+
*/
|
|
29
|
+
async function preload() {
|
|
30
|
+
const {PCDLoaderWithParser} = await import('@loaders.gl/pointclouds/pcd/pcd-loader');
|
|
31
|
+
return PCDLoaderWithParser;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Metadata-only worker loader for PCD - Point Cloud Data
|
|
36
|
+
*/
|
|
37
|
+
export const PCDLoader = {
|
|
38
|
+
...PCDFormat,
|
|
39
|
+
dataType: null as unknown as PCDMesh | MeshArrowTable,
|
|
40
|
+
batchType: null as unknown as PCDMesh | ArrowTableBatch,
|
|
41
|
+
version: VERSION,
|
|
42
|
+
worker: true,
|
|
43
|
+
/** Enables the stateful input/output batch protocol on the built-in worker. */
|
|
44
|
+
workerInBatches: true,
|
|
45
|
+
serializeWorkerResult: serializeArrowWorkerTable,
|
|
46
|
+
options: {
|
|
47
|
+
pcd: {shape: 'arrow-table', colorFormat: 'uint8norm'}
|
|
48
|
+
},
|
|
49
|
+
preload
|
|
50
|
+
} as const satisfies Loader<PCDMesh | MeshArrowTable, PCDMesh | ArrowTableBatch, PCDLoaderOptions>;
|
|
51
|
+
|
|
52
|
+
/** @deprecated Use PCDLoader. */
|
|
53
|
+
export const PCDWorkerLoader = PCDLoader;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {PCDLoaderOptions} from './pcd-loader-types';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
concatenateArrayBuffersAsync,
|
|
9
|
+
makeTableScanBatch,
|
|
10
|
+
type LoaderWithParser
|
|
11
|
+
} from '@loaders.gl/core/loader-utils';
|
|
12
|
+
import type {ArrowTableBatch, MeshArrowTable} from '@loaders.gl/core/schema';
|
|
13
|
+
import {
|
|
14
|
+
deserializeArrowWorkerTable,
|
|
15
|
+
serializeArrowWorkerTable
|
|
16
|
+
} from '@loaders.gl/core/schema-utils/arrow-transport';
|
|
17
|
+
import {convertMeshToTable, convertTableToMesh} from '@loaders.gl/core/schema-utils';
|
|
18
|
+
import type {PCDMesh} from './lib/pcd-types';
|
|
19
|
+
import {parsePCD, parsePCDHeader} from './lib/parse-pcd';
|
|
20
|
+
import {PCDLoader as PCDLoaderMetadata} from './pcd-loader-types';
|
|
21
|
+
|
|
22
|
+
const {preload: _PCDLoaderPreload, ...PCDLoaderMetadataWithoutPreload} = PCDLoaderMetadata;
|
|
23
|
+
|
|
24
|
+
type PCDParsedBatch = PCDMesh | ArrowTableBatch;
|
|
25
|
+
|
|
26
|
+
function convertPCDMesh(mesh: PCDMesh, options?: PCDLoaderOptions): PCDMesh | MeshArrowTable {
|
|
27
|
+
const table = convertMeshToTable(mesh, 'arrow-table');
|
|
28
|
+
return options?.pcd?.shape === 'mesh'
|
|
29
|
+
? convertPCDTableToMesh(table, mesh)
|
|
30
|
+
: {...table, loader: mesh.loader, loaderData: mesh.loaderData};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Loader for PCD - Point Cloud Data
|
|
35
|
+
*/
|
|
36
|
+
export const PCDLoaderWithParser = {
|
|
37
|
+
...PCDLoaderMetadataWithoutPreload,
|
|
38
|
+
parse: async (arrayBuffer, options) => convertPCDMesh(parsePCD(arrayBuffer, options), options),
|
|
39
|
+
parseSync: (arrayBuffer, options) => convertPCDMesh(parsePCD(arrayBuffer, options), options),
|
|
40
|
+
parseInBatches: async function* (
|
|
41
|
+
arrayBuffer:
|
|
42
|
+
| AsyncIterable<ArrayBufferLike | ArrayBufferView>
|
|
43
|
+
| Iterable<ArrayBufferLike | ArrayBufferView>,
|
|
44
|
+
options
|
|
45
|
+
): AsyncIterable<PCDParsedBatch> {
|
|
46
|
+
const batchSize = getNumericBatchSize(options);
|
|
47
|
+
const data = await concatenateArrayBuffersAsync(arrayBuffer);
|
|
48
|
+
const textData = new TextDecoder().decode(data);
|
|
49
|
+
const pcdHeader = parsePCDHeader(textData);
|
|
50
|
+
|
|
51
|
+
if (pcdHeader.data === 'ascii') {
|
|
52
|
+
yield* parsePCDASCIIInBatches(data, options, batchSize);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (pcdHeader.data === 'binary') {
|
|
57
|
+
yield* parsePCDBinaryInBatches(data, options, batchSize);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
yield makePCDBatch(parsePCD(data, options), options);
|
|
62
|
+
},
|
|
63
|
+
serializeWorkerResult: serializeArrowWorkerTable,
|
|
64
|
+
deserializeWorkerResult: deserializePCDWorkerResult,
|
|
65
|
+
serializeWorkerBatch: serializeArrowWorkerTable,
|
|
66
|
+
deserializeWorkerBatch: deserializePCDWorkerBatch
|
|
67
|
+
} as const satisfies LoaderWithParser<PCDMesh | MeshArrowTable, PCDParsedBatch, PCDLoaderOptions>;
|
|
68
|
+
|
|
69
|
+
/** Returns a numeric batch size when batching has an explicit row count. */
|
|
70
|
+
function getNumericBatchSize(options?: PCDLoaderOptions): number | undefined {
|
|
71
|
+
const batchSize = options?.batchSize ?? options?.core?.batchSize;
|
|
72
|
+
return typeof batchSize === 'number' ? batchSize : undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function* parsePCDASCIIInBatches(
|
|
76
|
+
data: ArrayBuffer,
|
|
77
|
+
options?: PCDLoaderOptions,
|
|
78
|
+
batchSize?: number
|
|
79
|
+
): Iterable<PCDParsedBatch> {
|
|
80
|
+
const textData = new TextDecoder().decode(data);
|
|
81
|
+
const pcdHeader = parsePCDHeader(textData);
|
|
82
|
+
const lines = textData
|
|
83
|
+
.slice(pcdHeader.headerLen)
|
|
84
|
+
.split(/\r?\n/)
|
|
85
|
+
.filter(line => line.trim().length > 0);
|
|
86
|
+
const normalizedBatchSize = batchSize || lines.length || 1;
|
|
87
|
+
|
|
88
|
+
for (let rowIndex = 0; rowIndex < lines.length; rowIndex += normalizedBatchSize) {
|
|
89
|
+
const batchLines = lines.slice(rowIndex, rowIndex + normalizedBatchSize);
|
|
90
|
+
const batchText = `${makePCDHeaderText(pcdHeader, batchLines.length)}${batchLines.join('\n')}\n`;
|
|
91
|
+
yield makePCDBatch(parsePCD(new TextEncoder().encode(batchText).buffer, options), options);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function* parsePCDBinaryInBatches(
|
|
96
|
+
data: ArrayBuffer,
|
|
97
|
+
options?: PCDLoaderOptions,
|
|
98
|
+
batchSize?: number
|
|
99
|
+
): Iterable<PCDParsedBatch> {
|
|
100
|
+
const textData = new TextDecoder().decode(data);
|
|
101
|
+
const pcdHeader = parsePCDHeader(textData);
|
|
102
|
+
const normalizedBatchSize = batchSize || pcdHeader.points || 1;
|
|
103
|
+
const dataBytes = new Uint8Array(data);
|
|
104
|
+
|
|
105
|
+
for (let pointIndex = 0; pointIndex < pcdHeader.points; pointIndex += normalizedBatchSize) {
|
|
106
|
+
const pointCount = Math.min(normalizedBatchSize, pcdHeader.points - pointIndex);
|
|
107
|
+
const headerBytes = new TextEncoder().encode(makePCDHeaderText(pcdHeader, pointCount));
|
|
108
|
+
const rowByteOffset = pcdHeader.headerLen + pointIndex * pcdHeader.rowSize;
|
|
109
|
+
const rowByteLength = pointCount * pcdHeader.rowSize;
|
|
110
|
+
const batchBytes = new Uint8Array(headerBytes.length + rowByteLength);
|
|
111
|
+
batchBytes.set(headerBytes, 0);
|
|
112
|
+
batchBytes.set(
|
|
113
|
+
dataBytes.subarray(rowByteOffset, rowByteOffset + rowByteLength),
|
|
114
|
+
headerBytes.length
|
|
115
|
+
);
|
|
116
|
+
yield makePCDBatch(parsePCD(batchBytes.buffer, options), options);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function makePCDBatch(mesh: PCDMesh, options?: PCDLoaderOptions): PCDParsedBatch {
|
|
121
|
+
const table = convertMeshToTable(mesh, 'arrow-table');
|
|
122
|
+
if (options?.pcd?.shape === 'mesh') {
|
|
123
|
+
return convertPCDTableToMesh(table, mesh);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return makeTableScanBatch({
|
|
127
|
+
...table,
|
|
128
|
+
loader: mesh.loader,
|
|
129
|
+
loaderData: mesh.loaderData
|
|
130
|
+
} as MeshArrowTable);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Convert the parser's Arrow table to legacy PCD mesh output. */
|
|
134
|
+
function convertPCDTableToMesh(table: MeshArrowTable, sourceMesh: PCDMesh): PCDMesh {
|
|
135
|
+
return {
|
|
136
|
+
...(convertTableToMesh(table) as PCDMesh),
|
|
137
|
+
loader: sourceMesh.loader,
|
|
138
|
+
loaderData: sourceMesh.loaderData
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function makePCDHeaderText(pcdHeader: any, pointCount: number): string {
|
|
143
|
+
const lines = pcdHeader.str
|
|
144
|
+
.split(/\r?\n/)
|
|
145
|
+
.filter(line => line.trim().length > 0)
|
|
146
|
+
.map(line => {
|
|
147
|
+
if (/^WIDTH\s+/i.test(line)) {
|
|
148
|
+
return `WIDTH ${pointCount}`;
|
|
149
|
+
}
|
|
150
|
+
if (/^HEIGHT\s+/i.test(line)) {
|
|
151
|
+
return 'HEIGHT 1';
|
|
152
|
+
}
|
|
153
|
+
if (/^POINTS\s+/i.test(line)) {
|
|
154
|
+
return `POINTS ${pointCount}`;
|
|
155
|
+
}
|
|
156
|
+
return line;
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
if (!lines.some(line => /^POINTS\s+/i.test(line))) {
|
|
160
|
+
const dataLineIndex = lines.findIndex(line => /^DATA\s+/i.test(line));
|
|
161
|
+
lines.splice(dataLineIndex >= 0 ? dataLineIndex : lines.length, 0, `POINTS ${pointCount}`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return `${lines.join('\n')}\n`;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Hydrates worker columns before reconstructing legacy PCD meshes on the caller. */
|
|
168
|
+
function deserializePCDWorkerResult(
|
|
169
|
+
result: unknown,
|
|
170
|
+
options?: PCDLoaderOptions
|
|
171
|
+
): PCDMesh | MeshArrowTable {
|
|
172
|
+
const table = deserializeArrowWorkerTable(result);
|
|
173
|
+
return options?.pcd?.shape === 'mesh' ? convertPCDTableToMesh(table, table) : table;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Restores the existing PCD batch shape after caller-side hydration. */
|
|
177
|
+
function deserializePCDWorkerBatch(result: unknown, options?: PCDLoaderOptions): PCDParsedBatch {
|
|
178
|
+
return deserializePCDWorkerResult(result, options) as PCDParsedBatch;
|
|
179
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {WriterOptions, WriterWithEncoder} from '@loaders.gl/core/loader-utils';
|
|
6
|
+
import type {Mesh, MeshArrowTable, MeshAttribute} from '@loaders.gl/core/schema';
|
|
7
|
+
import {convertMeshToTable, convertTableToMesh} from '@loaders.gl/core/schema-utils';
|
|
8
|
+
import {PCDFormat} from './pcd-format';
|
|
9
|
+
|
|
10
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
11
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
12
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
13
|
+
|
|
14
|
+
/** Options for `PCDWriter`. */
|
|
15
|
+
export type PCDWriterOptions = WriterOptions & {
|
|
16
|
+
/** Reserved for future PCD writer options. */
|
|
17
|
+
pcd?: Record<string, never>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Writer for the PCD point cloud format.
|
|
22
|
+
*/
|
|
23
|
+
export const PCDWriter = {
|
|
24
|
+
...PCDFormat,
|
|
25
|
+
dataType: null as unknown as Mesh | MeshArrowTable,
|
|
26
|
+
batchType: null as never,
|
|
27
|
+
version: VERSION,
|
|
28
|
+
options: {
|
|
29
|
+
pcd: {}
|
|
30
|
+
},
|
|
31
|
+
text: true,
|
|
32
|
+
encode: async (data, options) => encodePCDSync(data, options),
|
|
33
|
+
encodeSync: encodePCDSync,
|
|
34
|
+
encodeTextSync: encodePCD
|
|
35
|
+
} as const satisfies WriterWithEncoder<Mesh | MeshArrowTable, never, PCDWriterOptions>;
|
|
36
|
+
|
|
37
|
+
/** Encode mesh category data as PCD bytes. */
|
|
38
|
+
function encodePCDSync(data: Mesh | MeshArrowTable, options?: PCDWriterOptions): ArrayBuffer {
|
|
39
|
+
const text = encodePCD(data, options);
|
|
40
|
+
return new TextEncoder().encode(text).buffer;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Encode mesh category data as ASCII PCD text. */
|
|
44
|
+
function encodePCD(data: Mesh | MeshArrowTable, options?: PCDWriterOptions): string {
|
|
45
|
+
const mesh = convertTableToMesh(normalizeMeshArrowTable(data));
|
|
46
|
+
const positionAttribute = getRequiredAttribute(mesh, 'POSITION');
|
|
47
|
+
const normalAttribute = mesh.attributes.NORMAL;
|
|
48
|
+
const colorAttribute = mesh.attributes.COLOR_0;
|
|
49
|
+
const vertexCount = positionAttribute.value.length / positionAttribute.size;
|
|
50
|
+
const fieldNames = ['x', 'y', 'z'];
|
|
51
|
+
const fieldSizes = ['4', '4', '4'];
|
|
52
|
+
const fieldTypes = ['F', 'F', 'F'];
|
|
53
|
+
const fieldCounts = ['1', '1', '1'];
|
|
54
|
+
|
|
55
|
+
if (normalAttribute) {
|
|
56
|
+
fieldNames.push('normal_x', 'normal_y', 'normal_z');
|
|
57
|
+
fieldSizes.push('4', '4', '4');
|
|
58
|
+
fieldTypes.push('F', 'F', 'F');
|
|
59
|
+
fieldCounts.push('1', '1', '1');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (colorAttribute) {
|
|
63
|
+
fieldNames.push('rgb');
|
|
64
|
+
fieldSizes.push('4');
|
|
65
|
+
fieldTypes.push('F');
|
|
66
|
+
fieldCounts.push('1');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const lines = [
|
|
70
|
+
'# .PCD v0.7 - Point Cloud Data file generated by loaders.gl',
|
|
71
|
+
'VERSION 0.7',
|
|
72
|
+
`FIELDS ${fieldNames.join(' ')}`,
|
|
73
|
+
`SIZE ${fieldSizes.join(' ')}`,
|
|
74
|
+
`TYPE ${fieldTypes.join(' ')}`,
|
|
75
|
+
`COUNT ${fieldCounts.join(' ')}`,
|
|
76
|
+
`WIDTH ${vertexCount}`,
|
|
77
|
+
'HEIGHT 1',
|
|
78
|
+
'VIEWPOINT 0 0 0 1 0 0 0',
|
|
79
|
+
`POINTS ${vertexCount}`,
|
|
80
|
+
'DATA ascii'
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
for (let vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {
|
|
84
|
+
const row = [
|
|
85
|
+
getComponent(positionAttribute, vertexIndex, 0),
|
|
86
|
+
getComponent(positionAttribute, vertexIndex, 1),
|
|
87
|
+
getComponent(positionAttribute, vertexIndex, 2)
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
if (normalAttribute) {
|
|
91
|
+
row.push(
|
|
92
|
+
getComponent(normalAttribute, vertexIndex, 0),
|
|
93
|
+
getComponent(normalAttribute, vertexIndex, 1),
|
|
94
|
+
getComponent(normalAttribute, vertexIndex, 2)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (colorAttribute) {
|
|
99
|
+
row.push(getPackedRGB(colorAttribute, vertexIndex));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
lines.push(row.join(' '));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return `${lines.join('\n')}\n`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Return mesh data as a MeshArrowTable, converting plain Mesh data first. */
|
|
109
|
+
function normalizeMeshArrowTable(data: Mesh | MeshArrowTable): MeshArrowTable {
|
|
110
|
+
if ('shape' in data && data.shape === 'arrow-table') {
|
|
111
|
+
return data;
|
|
112
|
+
}
|
|
113
|
+
return convertMeshToTable(data as Mesh, 'arrow-table');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Return a required mesh attribute or throw a format-specific error. */
|
|
117
|
+
function getRequiredAttribute(mesh: Mesh, attributeName: string): MeshAttribute {
|
|
118
|
+
const attribute = mesh.attributes[attributeName];
|
|
119
|
+
if (!attribute) {
|
|
120
|
+
throw new Error(`PCDWriter: ${attributeName} attribute is required`);
|
|
121
|
+
}
|
|
122
|
+
return attribute;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Return a single attribute component with 0 as the missing component fallback. */
|
|
126
|
+
function getComponent(
|
|
127
|
+
attribute: MeshAttribute,
|
|
128
|
+
vertexIndex: number,
|
|
129
|
+
componentIndex: number
|
|
130
|
+
): number {
|
|
131
|
+
return attribute.value[vertexIndex * attribute.size + componentIndex] || 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Return an RGB value packed into the PCD float convention. */
|
|
135
|
+
function getPackedRGB(attribute: MeshAttribute, vertexIndex: number): number {
|
|
136
|
+
const bytes = new Uint8Array(4);
|
|
137
|
+
bytes[0] = getColorByte(attribute, vertexIndex, 0);
|
|
138
|
+
bytes[1] = getColorByte(attribute, vertexIndex, 1);
|
|
139
|
+
bytes[2] = getColorByte(attribute, vertexIndex, 2);
|
|
140
|
+
return new DataView(bytes.buffer).getFloat32(0, true);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Return one color component as an unsigned byte. */
|
|
144
|
+
function getColorByte(
|
|
145
|
+
attribute: MeshAttribute,
|
|
146
|
+
vertexIndex: number,
|
|
147
|
+
componentIndex: number
|
|
148
|
+
): number {
|
|
149
|
+
const value = getComponent(attribute, vertexIndex, componentIndex);
|
|
150
|
+
const byteValue = attribute.normalized || value <= 1 ? value * 255 : value;
|
|
151
|
+
return Math.max(0, Math.min(255, Math.round(byteValue)));
|
|
152
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {createLoaderWorker} from '@loaders.gl/core/loader-utils';
|
|
6
|
+
import {PCDLoaderWithParser} from '../pcd-loader';
|
|
7
|
+
|
|
8
|
+
createLoaderWorker({
|
|
9
|
+
...PCDLoaderWithParser,
|
|
10
|
+
/** Always returns columnar data; legacy mesh conversion runs on the caller. */
|
|
11
|
+
parse(input, options) {
|
|
12
|
+
return PCDLoaderWithParser.parse(input, {
|
|
13
|
+
...options,
|
|
14
|
+
pcd: {...options?.pcd, shape: 'arrow-table'}
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
/** Keeps one columnar parser alive for the entire worker input stream. */
|
|
18
|
+
parseInBatches(input, options) {
|
|
19
|
+
return PCDLoaderWithParser.parseInBatches(input, {
|
|
20
|
+
...options,
|
|
21
|
+
pcd: {...options?.pcd, shape: 'arrow-table'}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
package/src/ply/index.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
// PLYLoader
|
|
6
|
+
export {PLYFormat} from './ply-format';
|
|
7
|
+
|
|
8
|
+
export type {PLYLoaderOptions} from './ply-loader-types';
|
|
9
|
+
export {PLYLoader} from './ply-loader-types';
|
|
10
|
+
export type {PLYWriterOptions} from './ply-writer';
|
|
11
|
+
export {PLYWriter} from './ply-writer';
|
|
12
|
+
|
|
13
|
+
// DEPRECATED EXPORTS
|
|
14
|
+
/** @deprecated Use PLYLoader. */
|
|
15
|
+
export {PLYWorkerLoader} from './ply-loader-types';
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Schema, Field, MeshAttributes} from '@loaders.gl/core/schema';
|
|
6
|
+
import {deduceMeshSchema} from '@loaders.gl/core/schema-utils';
|
|
7
|
+
import type {PLYHeader} from './ply-types';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Gets schema from PLY header
|
|
11
|
+
* @param plyHeader
|
|
12
|
+
* @param metadata
|
|
13
|
+
* @returns Schema
|
|
14
|
+
*/
|
|
15
|
+
export function getPLYSchema(plyHeader: PLYHeader, attributes: MeshAttributes): Schema {
|
|
16
|
+
const metadata = makeMetadataFromPlyHeader(plyHeader);
|
|
17
|
+
const schema = deduceMeshSchema(attributes, metadata);
|
|
18
|
+
addGaussianSplatSchemaMetadata(schema, plyHeader);
|
|
19
|
+
return schema;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Make arrow like schema metadata by PlyHeader properties
|
|
24
|
+
* @param plyHeader
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
function makeMetadataFromPlyHeader(plyHeader: PLYHeader): Record<string, string> {
|
|
28
|
+
/* eslint-disable camelcase */
|
|
29
|
+
const metadata: Record<string, string> = {};
|
|
30
|
+
metadata.ply_comments = JSON.stringify(plyHeader.comments);
|
|
31
|
+
metadata.ply_elements = JSON.stringify(plyHeader.elements);
|
|
32
|
+
if (plyHeader.format !== undefined) {
|
|
33
|
+
metadata.ply_format = plyHeader.format;
|
|
34
|
+
}
|
|
35
|
+
if (plyHeader.version !== undefined) {
|
|
36
|
+
metadata.ply_version = plyHeader.version;
|
|
37
|
+
}
|
|
38
|
+
if (plyHeader.headerLength !== undefined) {
|
|
39
|
+
metadata.ply_headerLength = plyHeader.headerLength.toString(10);
|
|
40
|
+
}
|
|
41
|
+
return metadata;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Add Gaussian splat metadata conventions for GraphDECO-style PLY columns. */
|
|
45
|
+
function addGaussianSplatSchemaMetadata(schema: Schema, plyHeader: PLYHeader): void {
|
|
46
|
+
const vertexPropertyNames = getVertexPropertyNames(plyHeader);
|
|
47
|
+
if (!isGaussianSplatPLY(vertexPropertyNames)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
schema.metadata['loaders_gl.semantic_type'] = 'gaussian-splats';
|
|
52
|
+
schema.metadata['loaders_gl.gaussian_splats.version'] = '1';
|
|
53
|
+
|
|
54
|
+
for (const field of schema.fields) {
|
|
55
|
+
addGaussianSplatFieldMetadata(field);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Return the property names for the PLY vertex element. */
|
|
60
|
+
function getVertexPropertyNames(plyHeader: PLYHeader): Set<string> {
|
|
61
|
+
const vertexElement = plyHeader.elements.find(element => element.name === 'vertex');
|
|
62
|
+
return new Set(vertexElement?.properties.map(property => property.name) || []);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Return true if the PLY vertex properties match the de facto Gaussian splat layout. */
|
|
66
|
+
function isGaussianSplatPLY(propertyNames: Set<string>): boolean {
|
|
67
|
+
const requiredPropertyNames = [
|
|
68
|
+
'x',
|
|
69
|
+
'y',
|
|
70
|
+
'z',
|
|
71
|
+
'f_dc_0',
|
|
72
|
+
'f_dc_1',
|
|
73
|
+
'f_dc_2',
|
|
74
|
+
'opacity',
|
|
75
|
+
'scale_0',
|
|
76
|
+
'scale_1',
|
|
77
|
+
'scale_2',
|
|
78
|
+
'rot_0',
|
|
79
|
+
'rot_1',
|
|
80
|
+
'rot_2',
|
|
81
|
+
'rot_3'
|
|
82
|
+
];
|
|
83
|
+
return requiredPropertyNames.every(propertyName => propertyNames.has(propertyName));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Add loaders.gl Gaussian splat metadata to one schema field. */
|
|
87
|
+
function addGaussianSplatFieldMetadata(field: Field): void {
|
|
88
|
+
field.metadata ||= {};
|
|
89
|
+
const metadata = field.metadata;
|
|
90
|
+
|
|
91
|
+
if (field.name === 'opacity') {
|
|
92
|
+
metadata['loaders_gl.gaussian_splats.semantic'] = 'opacity';
|
|
93
|
+
metadata['loaders_gl.gaussian_splats.encoding'] = 'logit';
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const scaleComponent = getNumberedPropertyComponent(field.name, 'scale');
|
|
98
|
+
if (scaleComponent !== undefined) {
|
|
99
|
+
metadata['loaders_gl.gaussian_splats.semantic'] = 'scale';
|
|
100
|
+
metadata['loaders_gl.gaussian_splats.component'] = scaleComponent;
|
|
101
|
+
metadata['loaders_gl.gaussian_splats.encoding'] = 'log';
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const rotationComponent = getNumberedPropertyComponent(field.name, 'rot');
|
|
106
|
+
if (rotationComponent !== undefined) {
|
|
107
|
+
metadata['loaders_gl.gaussian_splats.semantic'] = 'rotation';
|
|
108
|
+
metadata['loaders_gl.gaussian_splats.component'] = rotationComponent;
|
|
109
|
+
metadata['loaders_gl.gaussian_splats.encoding'] = 'quaternion';
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const sphericalHarmonicDCComponent = getNumberedPropertyComponent(field.name, 'f_dc');
|
|
114
|
+
if (sphericalHarmonicDCComponent !== undefined) {
|
|
115
|
+
metadata['loaders_gl.gaussian_splats.semantic'] = 'spherical_harmonic_dc';
|
|
116
|
+
metadata['loaders_gl.gaussian_splats.component'] = sphericalHarmonicDCComponent;
|
|
117
|
+
metadata['loaders_gl.gaussian_splats.encoding'] = 'coefficient';
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const sphericalHarmonicRestComponent = getNumberedPropertyComponent(field.name, 'f_rest');
|
|
122
|
+
if (sphericalHarmonicRestComponent !== undefined) {
|
|
123
|
+
metadata['loaders_gl.gaussian_splats.semantic'] = 'spherical_harmonic_rest';
|
|
124
|
+
metadata['loaders_gl.gaussian_splats.component'] = sphericalHarmonicRestComponent;
|
|
125
|
+
metadata['loaders_gl.gaussian_splats.encoding'] = 'coefficient';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Return the numeric suffix for a property such as scale_0. */
|
|
130
|
+
function getNumberedPropertyComponent(name: string, prefix: string): string | undefined {
|
|
131
|
+
const match = name.match(new RegExp(`^${prefix}_(\\d+)$`));
|
|
132
|
+
return match?.[1];
|
|
133
|
+
}
|