@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,676 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
Mesh,
|
|
7
|
+
MeshAttribute,
|
|
8
|
+
MeshAttributes,
|
|
9
|
+
MeshArrowTable,
|
|
10
|
+
TypedArray
|
|
11
|
+
} from '@loaders.gl/core/schema';
|
|
12
|
+
import {getMeshBoundingBox} from '@loaders.gl/core/schema-utils';
|
|
13
|
+
import * as arrow from 'apache-arrow';
|
|
14
|
+
import type {ParsePLYOptions} from './parse-ply';
|
|
15
|
+
import {parsePLYHeader} from './parse-ply';
|
|
16
|
+
import {getPLYSchema} from './get-ply-schema';
|
|
17
|
+
import type {PLYElement, PLYHeader, PLYMesh, PLYProperty} from './ply-types';
|
|
18
|
+
|
|
19
|
+
const PLY_END_HEADER_PATTERN = /end_header\s/;
|
|
20
|
+
|
|
21
|
+
/** Internal Arrow representation preserving one table per PLY element. */
|
|
22
|
+
export type PLYElementTables = {
|
|
23
|
+
/** Parsed PLY header. */
|
|
24
|
+
header: PLYHeader;
|
|
25
|
+
/** Raw Arrow tables keyed by PLY element order. */
|
|
26
|
+
elements: PLYElementTable[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Raw Arrow table for one PLY element. */
|
|
30
|
+
export type PLYElementTable = {
|
|
31
|
+
/** PLY element definition. */
|
|
32
|
+
element: PLYElement;
|
|
33
|
+
/** Raw property table for the element. */
|
|
34
|
+
table: arrow.Table;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type PropertyCollector = {
|
|
38
|
+
property: PLYProperty;
|
|
39
|
+
values: number[];
|
|
40
|
+
offsets?: number[];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type ElementCollector = {
|
|
44
|
+
element: PLYElement;
|
|
45
|
+
properties: PropertyCollector[];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Parse a full PLY payload into raw Arrow element tables. */
|
|
49
|
+
export function parsePLYToElementTables(
|
|
50
|
+
data: ArrayBuffer | string,
|
|
51
|
+
options: ParsePLYOptions = {}
|
|
52
|
+
): PLYElementTables {
|
|
53
|
+
const header = parsePLYHeader(data, options);
|
|
54
|
+
const parseHeader = options.pointCloud ? getPointCloudPLYHeader(header) : header;
|
|
55
|
+
if (header.format === 'ascii') {
|
|
56
|
+
const text = data instanceof ArrayBuffer ? new TextDecoder().decode(data) : data;
|
|
57
|
+
return parseASCIIPLYToElementTables(text, parseHeader);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!(data instanceof ArrayBuffer)) {
|
|
61
|
+
throw new Error('Binary PLY parsing requires an ArrayBuffer.');
|
|
62
|
+
}
|
|
63
|
+
return parseBinaryPLYToElementTables(data, parseHeader);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Convert raw PLY element tables into the public Mesh Arrow table shape. */
|
|
67
|
+
export function convertPLYElementTablesToMeshArrowTable(
|
|
68
|
+
elementTables: PLYElementTables
|
|
69
|
+
): MeshArrowTable {
|
|
70
|
+
const mesh = convertPLYElementTablesToMesh(elementTables);
|
|
71
|
+
return convertPLYMeshToArrowTable(mesh);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Convert raw PLY element tables into the legacy Mesh shape. */
|
|
75
|
+
export function convertPLYElementTablesToMesh(elementTables: PLYElementTables): PLYMesh {
|
|
76
|
+
const attributes = getMeshAttributesFromPLYElementTables(elementTables);
|
|
77
|
+
const indices = getMeshIndicesFromPLYElementTables(elementTables);
|
|
78
|
+
const boundingBox = getMeshBoundingBox(attributes);
|
|
79
|
+
const vertexCount = attributes.POSITION?.value.length ? attributes.POSITION.value.length / 3 : 0;
|
|
80
|
+
const isTriangles = Boolean(indices?.value.length);
|
|
81
|
+
const mode = isTriangles ? 4 : 0;
|
|
82
|
+
const topology = isTriangles ? 'triangle-list' : 'point-list';
|
|
83
|
+
const schema = getPLYSchema(elementTables.header, attributes);
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
loader: 'ply',
|
|
87
|
+
loaderData: elementTables.header,
|
|
88
|
+
header: {
|
|
89
|
+
vertexCount,
|
|
90
|
+
boundingBox: boundingBox ?? undefined
|
|
91
|
+
},
|
|
92
|
+
schema,
|
|
93
|
+
attributes,
|
|
94
|
+
indices: indices || {value: new Uint32Array(0), size: 0},
|
|
95
|
+
mode,
|
|
96
|
+
topology
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Parse an ASCII PLY payload into raw Arrow element tables. */
|
|
101
|
+
function parseASCIIPLYToElementTables(data: string, header: PLYHeader): PLYElementTables {
|
|
102
|
+
const collector = createElementTablesCollector(header);
|
|
103
|
+
const body = getPLYTextBody(data);
|
|
104
|
+
const lines = body.split('\n');
|
|
105
|
+
let elementIndex = 0;
|
|
106
|
+
let elementRowIndex = 0;
|
|
107
|
+
|
|
108
|
+
for (const sourceLine of lines) {
|
|
109
|
+
const line = sourceLine.trim();
|
|
110
|
+
if (line === '') {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
while (
|
|
114
|
+
elementIndex < header.elements.length &&
|
|
115
|
+
elementRowIndex >= header.elements[elementIndex].count
|
|
116
|
+
) {
|
|
117
|
+
elementIndex++;
|
|
118
|
+
elementRowIndex = 0;
|
|
119
|
+
}
|
|
120
|
+
if (elementIndex >= header.elements.length) {
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
appendASCIIElementRow(collector[elementIndex], line);
|
|
124
|
+
elementRowIndex++;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {header, elements: collector.map(makePLYElementTable)};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Parse a binary PLY payload into raw Arrow element tables. */
|
|
131
|
+
function parseBinaryPLYToElementTables(data: ArrayBuffer, header: PLYHeader): PLYElementTables {
|
|
132
|
+
const collector = createElementTablesCollector(header);
|
|
133
|
+
const dataView = new DataView(data, header.headerLength || 0);
|
|
134
|
+
const littleEndian = header.format !== 'binary_big_endian';
|
|
135
|
+
let byteOffset = 0;
|
|
136
|
+
|
|
137
|
+
for (let elementIndex = 0; elementIndex < header.elements.length; elementIndex++) {
|
|
138
|
+
const element = header.elements[elementIndex];
|
|
139
|
+
for (let rowIndex = 0; rowIndex < element.count; rowIndex++) {
|
|
140
|
+
byteOffset += appendBinaryElementRow(
|
|
141
|
+
collector[elementIndex],
|
|
142
|
+
dataView,
|
|
143
|
+
byteOffset,
|
|
144
|
+
littleEndian
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return {header, elements: collector.map(makePLYElementTable)};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Return a vertex-only PLY header for point-cloud parsing. */
|
|
153
|
+
function getPointCloudPLYHeader(header: PLYHeader): PLYHeader {
|
|
154
|
+
const vertexElement = header.elements[0];
|
|
155
|
+
if (vertexElement?.name !== 'vertex') {
|
|
156
|
+
throw new Error('PLY pointCloud parsing requires a leading vertex element');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
...header,
|
|
161
|
+
elements: [vertexElement]
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Create mutable collectors for all PLY element properties. */
|
|
166
|
+
function createElementTablesCollector(header: PLYHeader): ElementCollector[] {
|
|
167
|
+
return header.elements.map(element => ({
|
|
168
|
+
element,
|
|
169
|
+
properties: element.properties.map(property => ({
|
|
170
|
+
property,
|
|
171
|
+
values: [],
|
|
172
|
+
offsets: property.type === 'list' ? [0] : undefined
|
|
173
|
+
}))
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Append one ASCII row to an element collector. */
|
|
178
|
+
function appendASCIIElementRow(collector: ElementCollector, line: string): void {
|
|
179
|
+
const values = line.split(/\s+/);
|
|
180
|
+
let valueIndex = 0;
|
|
181
|
+
|
|
182
|
+
for (const propertyCollector of collector.properties) {
|
|
183
|
+
const property = propertyCollector.property;
|
|
184
|
+
if (property.type === 'list') {
|
|
185
|
+
const count = parseASCIINumber(values[valueIndex++], property.countType!);
|
|
186
|
+
for (let listIndex = 0; listIndex < count; listIndex++) {
|
|
187
|
+
propertyCollector.values.push(parseASCIINumber(values[valueIndex++], property.itemType!));
|
|
188
|
+
}
|
|
189
|
+
propertyCollector.offsets!.push(propertyCollector.values.length);
|
|
190
|
+
} else {
|
|
191
|
+
propertyCollector.values.push(parseASCIINumber(values[valueIndex++], property.type));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Append one binary row to an element collector and return consumed bytes. */
|
|
197
|
+
function appendBinaryElementRow(
|
|
198
|
+
collector: ElementCollector,
|
|
199
|
+
dataView: DataView,
|
|
200
|
+
byteOffset: number,
|
|
201
|
+
littleEndian: boolean
|
|
202
|
+
): number {
|
|
203
|
+
let localOffset = 0;
|
|
204
|
+
|
|
205
|
+
for (const propertyCollector of collector.properties) {
|
|
206
|
+
const property = propertyCollector.property;
|
|
207
|
+
if (property.type === 'list') {
|
|
208
|
+
const [count, countByteLength] = readBinaryNumber(
|
|
209
|
+
dataView,
|
|
210
|
+
byteOffset + localOffset,
|
|
211
|
+
property.countType!,
|
|
212
|
+
littleEndian
|
|
213
|
+
);
|
|
214
|
+
localOffset += countByteLength;
|
|
215
|
+
for (let listIndex = 0; listIndex < count; listIndex++) {
|
|
216
|
+
const [value, valueByteLength] = readBinaryNumber(
|
|
217
|
+
dataView,
|
|
218
|
+
byteOffset + localOffset,
|
|
219
|
+
property.itemType!,
|
|
220
|
+
littleEndian
|
|
221
|
+
);
|
|
222
|
+
propertyCollector.values.push(value);
|
|
223
|
+
localOffset += valueByteLength;
|
|
224
|
+
}
|
|
225
|
+
propertyCollector.offsets!.push(propertyCollector.values.length);
|
|
226
|
+
} else {
|
|
227
|
+
const [value, valueByteLength] = readBinaryNumber(
|
|
228
|
+
dataView,
|
|
229
|
+
byteOffset + localOffset,
|
|
230
|
+
property.type,
|
|
231
|
+
littleEndian
|
|
232
|
+
);
|
|
233
|
+
propertyCollector.values.push(value);
|
|
234
|
+
localOffset += valueByteLength;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return localOffset;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Convert one element collector into an Arrow table. */
|
|
242
|
+
function makePLYElementTable(collector: ElementCollector): PLYElementTable {
|
|
243
|
+
const fields: arrow.Field[] = [];
|
|
244
|
+
const columns: Record<string, arrow.Vector> = {};
|
|
245
|
+
|
|
246
|
+
for (const propertyCollector of collector.properties) {
|
|
247
|
+
const column = makePLYPropertyVector(propertyCollector);
|
|
248
|
+
columns[propertyCollector.property.name] = column;
|
|
249
|
+
fields.push(new arrow.Field(propertyCollector.property.name, column.type, false));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
element: collector.element,
|
|
254
|
+
table: new arrow.Table(new arrow.Schema(fields), columns)
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** Return a raw Arrow vector for one PLY property. */
|
|
259
|
+
function makePLYPropertyVector(collector: PropertyCollector): arrow.Vector {
|
|
260
|
+
const property = collector.property;
|
|
261
|
+
if (property.type === 'list') {
|
|
262
|
+
return makeListVector(
|
|
263
|
+
property.itemType!,
|
|
264
|
+
collector.values,
|
|
265
|
+
Int32Array.from(collector.offsets || [0])
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
return arrow.makeVector(getTypedArray(collector.values, property.type) as any);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Return the Mesh attributes represented by the PLY vertex table. */
|
|
272
|
+
function getMeshAttributesFromPLYElementTables(elementTables: PLYElementTables): MeshAttributes {
|
|
273
|
+
const vertexTable = getPLYElementTable(elementTables, 'vertex');
|
|
274
|
+
const attributes: MeshAttributes = {};
|
|
275
|
+
if (!vertexTable) {
|
|
276
|
+
return attributes;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const position = makeFixedSizeListAttribute(vertexTable.table, ['x', 'y', 'z'], 'float');
|
|
280
|
+
if (position) {
|
|
281
|
+
attributes.POSITION = position;
|
|
282
|
+
}
|
|
283
|
+
const normal = makeFixedSizeListAttribute(vertexTable.table, ['nx', 'ny', 'nz'], 'float');
|
|
284
|
+
if (normal) {
|
|
285
|
+
attributes.NORMAL = normal;
|
|
286
|
+
}
|
|
287
|
+
const textureCoordinates = makeFixedSizeListAttribute(vertexTable.table, ['s', 't'], 'float');
|
|
288
|
+
if (textureCoordinates) {
|
|
289
|
+
attributes.TEXCOORD_0 = textureCoordinates;
|
|
290
|
+
}
|
|
291
|
+
const color = makeFixedSizeListAttribute(vertexTable.table, ['red', 'green', 'blue'], 'uchar');
|
|
292
|
+
if (color) {
|
|
293
|
+
attributes.COLOR_0 = {...color, normalized: true};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const packedPropertyNames = new Set([
|
|
297
|
+
'x',
|
|
298
|
+
'y',
|
|
299
|
+
'z',
|
|
300
|
+
'nx',
|
|
301
|
+
'ny',
|
|
302
|
+
'nz',
|
|
303
|
+
's',
|
|
304
|
+
't',
|
|
305
|
+
'red',
|
|
306
|
+
'green',
|
|
307
|
+
'blue'
|
|
308
|
+
]);
|
|
309
|
+
for (const property of vertexTable.element.properties) {
|
|
310
|
+
if (property.type === 'list' || packedPropertyNames.has(property.name)) {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
const column = vertexTable.table.getChild(property.name);
|
|
314
|
+
if (column) {
|
|
315
|
+
attributes[property.name] = {
|
|
316
|
+
value: getVectorValues(column) as TypedArray,
|
|
317
|
+
size: 1
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return attributes;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/** Return triangulated mesh indices represented by the face table. */
|
|
326
|
+
function getMeshIndicesFromPLYElementTables(
|
|
327
|
+
elementTables: PLYElementTables
|
|
328
|
+
): MeshAttribute | undefined {
|
|
329
|
+
const faceTable = getPLYElementTable(elementTables, 'face');
|
|
330
|
+
const indicesColumn =
|
|
331
|
+
faceTable?.table.getChild('vertex_indices') || faceTable?.table.getChild('vertex_index');
|
|
332
|
+
if (!indicesColumn) {
|
|
333
|
+
return undefined;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const indices: number[] = [];
|
|
337
|
+
for (let rowIndex = 0; rowIndex < indicesColumn.length; rowIndex++) {
|
|
338
|
+
const vertexIndices = indicesColumn.get(rowIndex) as ArrayLike<number> | null;
|
|
339
|
+
if (!vertexIndices) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (vertexIndices.length === 3) {
|
|
343
|
+
indices.push(
|
|
344
|
+
getArrayLikeValue(vertexIndices, 0),
|
|
345
|
+
getArrayLikeValue(vertexIndices, 1),
|
|
346
|
+
getArrayLikeValue(vertexIndices, 2)
|
|
347
|
+
);
|
|
348
|
+
} else if (vertexIndices.length === 4) {
|
|
349
|
+
indices.push(
|
|
350
|
+
getArrayLikeValue(vertexIndices, 0),
|
|
351
|
+
getArrayLikeValue(vertexIndices, 1),
|
|
352
|
+
getArrayLikeValue(vertexIndices, 3)
|
|
353
|
+
);
|
|
354
|
+
indices.push(
|
|
355
|
+
getArrayLikeValue(vertexIndices, 1),
|
|
356
|
+
getArrayLikeValue(vertexIndices, 2),
|
|
357
|
+
getArrayLikeValue(vertexIndices, 3)
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return indices.length > 0 ? {value: new Uint32Array(indices), size: 1} : undefined;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** Return one value from an Array-like object or Arrow vector. */
|
|
366
|
+
function getArrayLikeValue(values: ArrayLike<number>, index: number): number {
|
|
367
|
+
return 'get' in values && typeof values.get === 'function'
|
|
368
|
+
? Number(values.get(index))
|
|
369
|
+
: Number(values[index]);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** Convert a Mesh into the public Mesh Arrow table shape. */
|
|
373
|
+
function convertPLYMeshToArrowTable(mesh: Mesh): MeshArrowTable {
|
|
374
|
+
const fields: arrow.Field[] = [];
|
|
375
|
+
const columns: Record<string, arrow.Vector> = {};
|
|
376
|
+
const attributeNames = getOrderedAttributeNames(mesh.attributes);
|
|
377
|
+
|
|
378
|
+
for (const attributeName of attributeNames) {
|
|
379
|
+
const attribute = mesh.attributes[attributeName];
|
|
380
|
+
const column = makeMeshAttributeVector(attribute);
|
|
381
|
+
columns[attributeName] = column;
|
|
382
|
+
fields.push(getMeshAttributeField(mesh, attributeName, column));
|
|
383
|
+
|
|
384
|
+
if (attributeName === 'POSITION' && mesh.indices?.value.length) {
|
|
385
|
+
const indicesColumn = makeMeshIndicesVector(mesh.indices.value, column.length);
|
|
386
|
+
columns.indices = indicesColumn;
|
|
387
|
+
fields.push(new arrow.Field('indices', indicesColumn.type, true));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const metadata = getArrowMetadata({
|
|
392
|
+
...mesh.schema.metadata,
|
|
393
|
+
topology: mesh.topology,
|
|
394
|
+
mode: String(mesh.mode),
|
|
395
|
+
boundingBox: mesh.header?.boundingBox ? JSON.stringify(mesh.header.boundingBox) : undefined
|
|
396
|
+
});
|
|
397
|
+
const arrowSchema = new arrow.Schema(fields, metadata);
|
|
398
|
+
|
|
399
|
+
return {
|
|
400
|
+
shape: 'arrow-table',
|
|
401
|
+
schema: mesh.schema,
|
|
402
|
+
data: new arrow.Table(arrowSchema, columns),
|
|
403
|
+
topology: mesh.topology,
|
|
404
|
+
indices: mesh.indices?.value.length ? mesh.indices : undefined
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** Return a mesh attribute vector. */
|
|
409
|
+
function makeMeshAttributeVector(attribute: MeshAttribute): arrow.Vector {
|
|
410
|
+
const {value, size} = attribute;
|
|
411
|
+
if (size === 1) {
|
|
412
|
+
return arrow.makeVector(value as any);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const values = arrow.makeVector(value as any);
|
|
416
|
+
const child = values.data[0];
|
|
417
|
+
const type = new arrow.FixedSizeList(size, new arrow.Field('value', child.type, false));
|
|
418
|
+
const data = new arrow.Data(type, 0, value.length / size, 0, {}, [child]);
|
|
419
|
+
return new arrow.Vector([data]);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** Return a Mesh Arrow field, preserving PLY schema field metadata where available. */
|
|
423
|
+
function getMeshAttributeField(
|
|
424
|
+
mesh: Mesh,
|
|
425
|
+
attributeName: string,
|
|
426
|
+
column: arrow.Vector
|
|
427
|
+
): arrow.Field {
|
|
428
|
+
const field = mesh.schema.fields.find(schemaField => schemaField.name === attributeName);
|
|
429
|
+
return new arrow.Field(attributeName, column.type, false, getArrowMetadata(field?.metadata));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** Return an IndexedMesh indices column with the full index list stored in row 0. */
|
|
433
|
+
function makeMeshIndicesVector(indices: MeshAttribute['value'], vertexCount: number): arrow.Vector {
|
|
434
|
+
const values = indices instanceof Uint32Array ? indices : Uint32Array.from(indices);
|
|
435
|
+
const valueOffsets = new Int32Array(vertexCount + 1);
|
|
436
|
+
if (vertexCount > 0) {
|
|
437
|
+
valueOffsets.fill(values.length, 1);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const nullBitmap = new Uint8Array(Math.ceil(vertexCount / 8));
|
|
441
|
+
if (vertexCount > 0) {
|
|
442
|
+
nullBitmap[0] = 1;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const type = new arrow.List(new arrow.Field('item', new arrow.Uint32(), false));
|
|
446
|
+
const valuesData = new arrow.Data<arrow.Uint32>(type.children[0].type, 0, values.length, 0, {
|
|
447
|
+
[arrow.BufferType.DATA]: values
|
|
448
|
+
});
|
|
449
|
+
const indicesData = new arrow.Data<arrow.List<arrow.Uint32>>(
|
|
450
|
+
type,
|
|
451
|
+
0,
|
|
452
|
+
vertexCount,
|
|
453
|
+
Math.max(0, vertexCount - 1),
|
|
454
|
+
{
|
|
455
|
+
[arrow.BufferType.OFFSET]: valueOffsets,
|
|
456
|
+
[arrow.BufferType.VALIDITY]: nullBitmap
|
|
457
|
+
},
|
|
458
|
+
[valuesData]
|
|
459
|
+
);
|
|
460
|
+
return new arrow.Vector([indicesData]);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/** Return a fixed-size list mesh attribute from separate scalar PLY columns. */
|
|
464
|
+
function makeFixedSizeListAttribute(
|
|
465
|
+
table: arrow.Table,
|
|
466
|
+
columnNames: string[],
|
|
467
|
+
preferredType: string
|
|
468
|
+
): MeshAttribute | null {
|
|
469
|
+
const columns = columnNames.map(columnName => table.getChild(columnName));
|
|
470
|
+
if (columns.some(column => !column)) {
|
|
471
|
+
return null;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const rowCount = table.numRows;
|
|
475
|
+
const values =
|
|
476
|
+
preferredType === 'uchar'
|
|
477
|
+
? new Uint8Array(rowCount * columnNames.length)
|
|
478
|
+
: new Float32Array(rowCount * columnNames.length);
|
|
479
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
480
|
+
for (let componentIndex = 0; componentIndex < columns.length; componentIndex++) {
|
|
481
|
+
values[rowIndex * columns.length + componentIndex] = Number(
|
|
482
|
+
columns[componentIndex]!.get(rowIndex) ?? 0
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
return {value: values, size: columnNames.length};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/** Return a PLY element table by name. */
|
|
491
|
+
function getPLYElementTable(
|
|
492
|
+
elementTables: PLYElementTables,
|
|
493
|
+
elementName: string
|
|
494
|
+
): PLYElementTable | undefined {
|
|
495
|
+
return elementTables.elements.find(elementTable => elementTable.element.name === elementName);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** Return mesh attributes in stable public order. */
|
|
499
|
+
function getOrderedAttributeNames(attributes: MeshAttributes): string[] {
|
|
500
|
+
const firstNames = ['POSITION', 'indices'];
|
|
501
|
+
return [
|
|
502
|
+
...firstNames.filter(attributeName => attributeName in attributes),
|
|
503
|
+
...Object.keys(attributes).filter(attributeName => !firstNames.includes(attributeName))
|
|
504
|
+
];
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/** Return a vector's backing values. */
|
|
508
|
+
function getVectorValues(vector: arrow.Vector): TypedArray {
|
|
509
|
+
const data = vector.data[0];
|
|
510
|
+
return data.values as TypedArray;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/** Return a PLY text body after the header terminator. */
|
|
514
|
+
function getPLYTextBody(data: string): string {
|
|
515
|
+
const match = PLY_END_HEADER_PATTERN.exec(data);
|
|
516
|
+
return match ? data.slice(match.index + match[0].length) : '';
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/** Return an Arrow list vector from value offsets and child values. */
|
|
520
|
+
function makeListVector(
|
|
521
|
+
typeName: string,
|
|
522
|
+
values: number[],
|
|
523
|
+
valueOffsets: Int32Array
|
|
524
|
+
): arrow.Vector {
|
|
525
|
+
const childType = getArrowType(typeName);
|
|
526
|
+
const type = new arrow.List(new arrow.Field('item', childType, false));
|
|
527
|
+
const typedValues = getTypedArray(values, typeName);
|
|
528
|
+
const valuesData = new arrow.Data(childType, 0, typedValues.length, 0, {
|
|
529
|
+
[arrow.BufferType.DATA]: typedValues
|
|
530
|
+
});
|
|
531
|
+
const listData = new arrow.Data(
|
|
532
|
+
type,
|
|
533
|
+
0,
|
|
534
|
+
valueOffsets.length - 1,
|
|
535
|
+
0,
|
|
536
|
+
{[arrow.BufferType.OFFSET]: valueOffsets},
|
|
537
|
+
[valuesData]
|
|
538
|
+
);
|
|
539
|
+
return new arrow.Vector([listData]);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/** Return a typed array for one PLY scalar type. */
|
|
543
|
+
function getTypedArray(values: number[], type: string): TypedArray {
|
|
544
|
+
switch (type) {
|
|
545
|
+
case 'int8':
|
|
546
|
+
case 'char':
|
|
547
|
+
return Int8Array.from(values);
|
|
548
|
+
case 'uint8':
|
|
549
|
+
case 'uchar':
|
|
550
|
+
return Uint8Array.from(values);
|
|
551
|
+
case 'int16':
|
|
552
|
+
case 'short':
|
|
553
|
+
return Int16Array.from(values);
|
|
554
|
+
case 'uint16':
|
|
555
|
+
case 'ushort':
|
|
556
|
+
return Uint16Array.from(values);
|
|
557
|
+
case 'int32':
|
|
558
|
+
case 'int':
|
|
559
|
+
return Int32Array.from(values);
|
|
560
|
+
case 'uint32':
|
|
561
|
+
case 'uint':
|
|
562
|
+
return Uint32Array.from(values);
|
|
563
|
+
case 'float64':
|
|
564
|
+
case 'double':
|
|
565
|
+
return Float64Array.from(values);
|
|
566
|
+
case 'float32':
|
|
567
|
+
case 'float':
|
|
568
|
+
default:
|
|
569
|
+
return Float32Array.from(values);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** Return an Arrow scalar type for one PLY scalar type. */
|
|
574
|
+
function getArrowType(type: string): arrow.DataType {
|
|
575
|
+
switch (type) {
|
|
576
|
+
case 'int8':
|
|
577
|
+
case 'char':
|
|
578
|
+
return new arrow.Int8();
|
|
579
|
+
case 'uint8':
|
|
580
|
+
case 'uchar':
|
|
581
|
+
return new arrow.Uint8();
|
|
582
|
+
case 'int16':
|
|
583
|
+
case 'short':
|
|
584
|
+
return new arrow.Int16();
|
|
585
|
+
case 'uint16':
|
|
586
|
+
case 'ushort':
|
|
587
|
+
return new arrow.Uint16();
|
|
588
|
+
case 'int32':
|
|
589
|
+
case 'int':
|
|
590
|
+
return new arrow.Int32();
|
|
591
|
+
case 'uint32':
|
|
592
|
+
case 'uint':
|
|
593
|
+
return new arrow.Uint32();
|
|
594
|
+
case 'float64':
|
|
595
|
+
case 'double':
|
|
596
|
+
return new arrow.Float64();
|
|
597
|
+
case 'float32':
|
|
598
|
+
case 'float':
|
|
599
|
+
default:
|
|
600
|
+
return new arrow.Float32();
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/** Parse one ASCII scalar value. */
|
|
605
|
+
function parseASCIINumber(value: string, type: string): number {
|
|
606
|
+
switch (type) {
|
|
607
|
+
case 'char':
|
|
608
|
+
case 'uchar':
|
|
609
|
+
case 'short':
|
|
610
|
+
case 'ushort':
|
|
611
|
+
case 'int':
|
|
612
|
+
case 'uint':
|
|
613
|
+
case 'int8':
|
|
614
|
+
case 'uint8':
|
|
615
|
+
case 'int16':
|
|
616
|
+
case 'uint16':
|
|
617
|
+
case 'int32':
|
|
618
|
+
case 'uint32':
|
|
619
|
+
return parseInt(value, 10);
|
|
620
|
+
case 'float':
|
|
621
|
+
case 'double':
|
|
622
|
+
case 'float32':
|
|
623
|
+
case 'float64':
|
|
624
|
+
return parseFloat(value);
|
|
625
|
+
default:
|
|
626
|
+
throw new Error(type);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/** Read one binary scalar value and its byte length. */
|
|
631
|
+
function readBinaryNumber(
|
|
632
|
+
dataView: DataView,
|
|
633
|
+
byteOffset: number,
|
|
634
|
+
type: string,
|
|
635
|
+
littleEndian: boolean
|
|
636
|
+
): [number, number] {
|
|
637
|
+
switch (type) {
|
|
638
|
+
case 'int8':
|
|
639
|
+
case 'char':
|
|
640
|
+
return [dataView.getInt8(byteOffset), 1];
|
|
641
|
+
case 'uint8':
|
|
642
|
+
case 'uchar':
|
|
643
|
+
return [dataView.getUint8(byteOffset), 1];
|
|
644
|
+
case 'int16':
|
|
645
|
+
case 'short':
|
|
646
|
+
return [dataView.getInt16(byteOffset, littleEndian), 2];
|
|
647
|
+
case 'uint16':
|
|
648
|
+
case 'ushort':
|
|
649
|
+
return [dataView.getUint16(byteOffset, littleEndian), 2];
|
|
650
|
+
case 'int32':
|
|
651
|
+
case 'int':
|
|
652
|
+
return [dataView.getInt32(byteOffset, littleEndian), 4];
|
|
653
|
+
case 'uint32':
|
|
654
|
+
case 'uint':
|
|
655
|
+
return [dataView.getUint32(byteOffset, littleEndian), 4];
|
|
656
|
+
case 'float32':
|
|
657
|
+
case 'float':
|
|
658
|
+
return [dataView.getFloat32(byteOffset, littleEndian), 4];
|
|
659
|
+
case 'float64':
|
|
660
|
+
case 'double':
|
|
661
|
+
return [dataView.getFloat64(byteOffset, littleEndian), 8];
|
|
662
|
+
default:
|
|
663
|
+
throw new Error(type);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/** Convert optional metadata to Arrow metadata. */
|
|
668
|
+
function getArrowMetadata(
|
|
669
|
+
metadata: Record<string, string | undefined> | undefined
|
|
670
|
+
): Map<string, string> {
|
|
671
|
+
return new Map(
|
|
672
|
+
Object.entries(metadata || {}).filter(
|
|
673
|
+
(entry): entry is [string, string] => entry[1] !== undefined
|
|
674
|
+
)
|
|
675
|
+
);
|
|
676
|
+
}
|