@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,47 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import type {Mesh, TypedArray} from '@loaders.gl/core/schema';
|
|
5
|
+
|
|
6
|
+
/** A parsed PLY mesh */
|
|
7
|
+
export type PLYMesh = Mesh & {
|
|
8
|
+
loader: 'ply';
|
|
9
|
+
loaderData: PLYHeader;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/** A PLY header */
|
|
13
|
+
export type PLYHeader = {
|
|
14
|
+
format?: string;
|
|
15
|
+
comments: string[];
|
|
16
|
+
elements: PLYElement[];
|
|
17
|
+
version?: string;
|
|
18
|
+
headerLength?: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// INTERNAL TYPES
|
|
22
|
+
|
|
23
|
+
/** A general mesh header */
|
|
24
|
+
export type MeshHeader = {
|
|
25
|
+
vertexCount?: number;
|
|
26
|
+
boundingBox?: [[number, number, number], [number, number, number]];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** The parsed columnar values */
|
|
30
|
+
export type PLYAttributes = {
|
|
31
|
+
[index: string]: number[] | TypedArray;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** A top level PLY element (vertex, face, ...) */
|
|
35
|
+
export type PLYElement = {
|
|
36
|
+
name: string;
|
|
37
|
+
count: number;
|
|
38
|
+
properties: PLYProperty[];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** One property in a top-level PLY element */
|
|
42
|
+
export type PLYProperty = {
|
|
43
|
+
name: string;
|
|
44
|
+
type: string;
|
|
45
|
+
countType?: string;
|
|
46
|
+
itemType?: string;
|
|
47
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
* PLY - Polygon File Format (aka Stanford Triangle Format)
|
|
9
|
+
* @see http://paulbourke.net/dataformats/ply/,
|
|
10
|
+
* @see https://en.wikipedia.org/wiki/PLY_(file_format)
|
|
11
|
+
*/
|
|
12
|
+
export const PLYFormat = {
|
|
13
|
+
name: 'PLY',
|
|
14
|
+
id: 'ply',
|
|
15
|
+
module: 'pointclouds',
|
|
16
|
+
encoding: 'text',
|
|
17
|
+
format: 'ply',
|
|
18
|
+
// shapes: ['mesh', 'gltf', 'columnar-table'],
|
|
19
|
+
extensions: ['ply'],
|
|
20
|
+
mimeTypes: ['text/plain', 'application/octet-stream'],
|
|
21
|
+
text: true,
|
|
22
|
+
binary: true,
|
|
23
|
+
tests: ['ply']
|
|
24
|
+
} as const satisfies Format;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
// PLY Loader
|
|
6
|
+
import type {Loader, LoaderOptions} from '@loaders.gl/core/loader-utils';
|
|
7
|
+
import type {MeshArrowTable, ArrowTableBatch} from '@loaders.gl/core/schema';
|
|
8
|
+
import type {PLYMesh} from './lib/ply-types';
|
|
9
|
+
import type {ParsePLYOptions} from './lib/parse-ply';
|
|
10
|
+
import {PLYFormat} from './ply-format';
|
|
11
|
+
import {serializeArrowWorkerTable} from '@loaders.gl/core/schema-utils/arrow-transport';
|
|
12
|
+
|
|
13
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
14
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
15
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
16
|
+
|
|
17
|
+
export type PLYLoaderOptions = LoaderOptions & {
|
|
18
|
+
ply?: ParsePLYOptions & {
|
|
19
|
+
/** Output shape. Defaults to a Mesh Arrow table. */
|
|
20
|
+
shape?: 'mesh' | 'arrow-table';
|
|
21
|
+
/** Color storage format. Defaults to uint8norm for backwards compatibility. */
|
|
22
|
+
colorFormat?: 'uint8norm' | 'float16' | 'float32';
|
|
23
|
+
/** Treat PLY data as a point cloud by reading only the leading vertex element. */
|
|
24
|
+
pointCloud?: boolean;
|
|
25
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
26
|
+
workerUrl?: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Preloads the parser-bearing PLY loader implementation.
|
|
32
|
+
*/
|
|
33
|
+
async function preload() {
|
|
34
|
+
const {PLYLoaderWithParser} = await import('@loaders.gl/pointclouds/ply/ply-loader');
|
|
35
|
+
return PLYLoaderWithParser;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Metadata-only worker loader for PLY - Polygon File Format (aka Stanford Triangle Format)'
|
|
40
|
+
* links: ['http://paulbourke.net/dataformats/ply/',
|
|
41
|
+
* 'https://en.wikipedia.org/wiki/PLY_(file_format)']
|
|
42
|
+
*/
|
|
43
|
+
export const PLYLoader = {
|
|
44
|
+
dataType: null as unknown as PLYMesh | MeshArrowTable,
|
|
45
|
+
batchType: null as unknown as PLYMesh | ArrowTableBatch,
|
|
46
|
+
|
|
47
|
+
...PLYFormat,
|
|
48
|
+
// shapes: ['mesh', 'gltf', 'columnar-table'],
|
|
49
|
+
version: VERSION,
|
|
50
|
+
worker: true,
|
|
51
|
+
/** Enables the stateful input/output batch protocol on the built-in worker. */
|
|
52
|
+
workerInBatches: true,
|
|
53
|
+
serializeWorkerResult: serializeArrowWorkerTable,
|
|
54
|
+
options: {
|
|
55
|
+
ply: {shape: 'arrow-table', colorFormat: 'uint8norm'}
|
|
56
|
+
},
|
|
57
|
+
preload
|
|
58
|
+
} as const satisfies Loader<PLYMesh | MeshArrowTable, PLYMesh | ArrowTableBatch, LoaderOptions>;
|
|
59
|
+
|
|
60
|
+
/** @deprecated Use PLYLoader. */
|
|
61
|
+
export const PLYWorkerLoader = PLYLoader;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {PLYLoaderOptions} from './ply-loader-types';
|
|
6
|
+
|
|
7
|
+
// PLY Loader
|
|
8
|
+
import {makeTableScanBatch, type LoaderWithParser} from '@loaders.gl/core/loader-utils';
|
|
9
|
+
import {convertColorArrayToFloat16, convertColorArrayToFloat32} from '@loaders.gl/core/schema';
|
|
10
|
+
import type {MeshArrowTable, ArrowTableBatch} from '@loaders.gl/core/schema';
|
|
11
|
+
import {
|
|
12
|
+
deserializeArrowWorkerTable,
|
|
13
|
+
serializeArrowWorkerTable
|
|
14
|
+
} from '@loaders.gl/core/schema-utils/arrow-transport';
|
|
15
|
+
import type {PLYHeader, PLYMesh} from './lib/ply-types';
|
|
16
|
+
import {
|
|
17
|
+
convertMeshToTable,
|
|
18
|
+
convertTableToMesh,
|
|
19
|
+
deduceMeshSchema
|
|
20
|
+
} from '@loaders.gl/core/schema-utils';
|
|
21
|
+
import {parsePLY, parsePLYHeader, parsePLYToArrowTable} from './lib/parse-ply';
|
|
22
|
+
import {
|
|
23
|
+
convertPLYElementTablesToMeshArrowTable,
|
|
24
|
+
parsePLYToElementTables
|
|
25
|
+
} from './lib/parse-ply-arrow';
|
|
26
|
+
import {parsePLYInBatches} from './lib/parse-ply-in-batches';
|
|
27
|
+
import {PLYLoader as PLYLoaderMetadata} from './ply-loader-types';
|
|
28
|
+
|
|
29
|
+
const {preload: _PLYLoaderPreload, ...PLYLoaderMetadataWithoutPreload} = PLYLoaderMetadata;
|
|
30
|
+
|
|
31
|
+
function convertPLYMesh(mesh: PLYMesh, options?: PLYLoaderOptions): PLYMesh | MeshArrowTable {
|
|
32
|
+
const table = convertMeshToTable(mesh, 'arrow-table');
|
|
33
|
+
return convertPLYTable(table, options, mesh.loaderData);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Parse PLY data using a direct Arrow path when requested and supported. */
|
|
37
|
+
function parsePLYData(
|
|
38
|
+
data: ArrayBuffer | string,
|
|
39
|
+
options?: PLYLoaderOptions
|
|
40
|
+
): PLYMesh | MeshArrowTable {
|
|
41
|
+
if (options?.ply?._useLegacyParser) {
|
|
42
|
+
return convertPLYMesh(parsePLY(data, options?.ply), options);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const arrowTable = parsePLYToArrowTable(data, options?.ply);
|
|
46
|
+
if (arrowTable) {
|
|
47
|
+
return convertPLYTable(arrowTable, options, parsePLYHeader(data, options?.ply));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const elementTables = parsePLYToElementTables(data, options?.ply);
|
|
51
|
+
return convertPLYTable(
|
|
52
|
+
convertPLYElementTablesToMeshArrowTable(elementTables),
|
|
53
|
+
options,
|
|
54
|
+
elementTables.header
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Loader for PLY - Polygon File Format
|
|
60
|
+
*/
|
|
61
|
+
export const PLYLoaderWithParser = {
|
|
62
|
+
...PLYLoaderMetadataWithoutPreload,
|
|
63
|
+
parse: async (arrayBuffer, options) => parsePLYData(arrayBuffer, options),
|
|
64
|
+
parseTextSync: (arrayBuffer, options) => parsePLYData(arrayBuffer, options),
|
|
65
|
+
parseSync: (arrayBuffer, options) => parsePLYData(arrayBuffer, options),
|
|
66
|
+
parseInBatches: async function* (
|
|
67
|
+
arrayBuffer:
|
|
68
|
+
| AsyncIterable<ArrayBufferLike | ArrayBufferView>
|
|
69
|
+
| Iterable<ArrayBufferLike | ArrayBufferView>,
|
|
70
|
+
options
|
|
71
|
+
) {
|
|
72
|
+
const plyOptions = {
|
|
73
|
+
...options?.ply,
|
|
74
|
+
batchSize: options?.batchSize ?? options?.core?.batchSize
|
|
75
|
+
};
|
|
76
|
+
for await (const meshOrTable of parsePLYInBatches(arrayBuffer, plyOptions)) {
|
|
77
|
+
const convertedData = isMeshArrowTable(meshOrTable)
|
|
78
|
+
? convertPLYTable(meshOrTable, options)
|
|
79
|
+
: convertPLYMesh(meshOrTable, options);
|
|
80
|
+
yield isMeshArrowTable(convertedData) ? makeTableScanBatch(convertedData) : convertedData;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
serializeWorkerResult: serializeArrowWorkerTable,
|
|
84
|
+
deserializeWorkerResult: deserializePLYWorkerResult,
|
|
85
|
+
serializeWorkerBatch: serializeArrowWorkerTable,
|
|
86
|
+
deserializeWorkerBatch: deserializePLYWorkerBatch
|
|
87
|
+
} as const satisfies LoaderWithParser<
|
|
88
|
+
PLYMesh | MeshArrowTable,
|
|
89
|
+
PLYMesh | ArrowTableBatch,
|
|
90
|
+
PLYLoaderOptions
|
|
91
|
+
>;
|
|
92
|
+
|
|
93
|
+
/** Return requested public PLY shape from the parser's Arrow table. */
|
|
94
|
+
function convertPLYTable(
|
|
95
|
+
table: MeshArrowTable & {
|
|
96
|
+
/** Original source header retained by the streaming parser. */
|
|
97
|
+
loaderData?: PLYHeader;
|
|
98
|
+
},
|
|
99
|
+
options?: PLYLoaderOptions,
|
|
100
|
+
header?: PLYHeader
|
|
101
|
+
): PLYMesh | MeshArrowTable {
|
|
102
|
+
const loaderData = header || table.loaderData || {comments: [], elements: []};
|
|
103
|
+
const result =
|
|
104
|
+
options?.ply?.shape === 'arrow-table'
|
|
105
|
+
? {...table, loader: 'ply' as const, loaderData}
|
|
106
|
+
: {
|
|
107
|
+
...(convertTableToMesh(table) as PLYMesh),
|
|
108
|
+
loader: 'ply',
|
|
109
|
+
loaderData
|
|
110
|
+
};
|
|
111
|
+
const colorFormat = options?.ply?.colorFormat || 'uint8norm';
|
|
112
|
+
if (colorFormat === 'uint8norm') {
|
|
113
|
+
return result as PLYMesh | MeshArrowTable;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const resultData = result as PLYMesh | MeshArrowTable;
|
|
117
|
+
const formattedMesh = formatPLYMeshColors(
|
|
118
|
+
(isMeshArrowTable(resultData) ? convertTableToMesh(resultData) : resultData) as PLYMesh,
|
|
119
|
+
colorFormat
|
|
120
|
+
);
|
|
121
|
+
return options?.ply?.shape === 'arrow-table'
|
|
122
|
+
? {
|
|
123
|
+
...convertMeshToTable(formattedMesh, 'arrow-table'),
|
|
124
|
+
loader: 'ply' as const,
|
|
125
|
+
loaderData
|
|
126
|
+
}
|
|
127
|
+
: (formattedMesh as PLYMesh);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Apply the requested normalized color representation to a decoded PLY mesh. */
|
|
131
|
+
function formatPLYMeshColors(
|
|
132
|
+
mesh: PLYMesh,
|
|
133
|
+
colorFormat: 'uint8norm' | 'float16' | 'float32'
|
|
134
|
+
): PLYMesh {
|
|
135
|
+
const colorAttribute = mesh.attributes.COLOR_0;
|
|
136
|
+
if (!colorAttribute) {
|
|
137
|
+
return mesh;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const sourceScale = colorAttribute.value instanceof Uint16Array ? 65535 : 255;
|
|
141
|
+
const value =
|
|
142
|
+
colorFormat === 'float16'
|
|
143
|
+
? convertColorArrayToFloat16(colorAttribute.value, sourceScale)
|
|
144
|
+
: convertColorArrayToFloat32(colorAttribute.value, sourceScale);
|
|
145
|
+
const attributes = {...mesh.attributes};
|
|
146
|
+
for (const [attributeName, attribute] of Object.entries(attributes)) {
|
|
147
|
+
if (attribute.value === colorAttribute.value) {
|
|
148
|
+
attributes[attributeName] = {
|
|
149
|
+
...attribute,
|
|
150
|
+
value,
|
|
151
|
+
normalized: false,
|
|
152
|
+
...(colorFormat === 'float16' ? {componentType: 'float16' as const} : {})
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
...mesh,
|
|
158
|
+
attributes,
|
|
159
|
+
schema: deduceMeshSchema(attributes, mesh.schema.metadata)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Return true if a parsed PLY batch is already a Mesh Arrow table. */
|
|
164
|
+
function isMeshArrowTable(data: PLYMesh | MeshArrowTable): data is MeshArrowTable {
|
|
165
|
+
return 'shape' in data && data.shape === 'arrow-table';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Hydrates worker columns and applies the requested PLY shape on the caller. */
|
|
169
|
+
function deserializePLYWorkerResult(
|
|
170
|
+
result: unknown,
|
|
171
|
+
options?: PLYLoaderOptions
|
|
172
|
+
): PLYMesh | MeshArrowTable {
|
|
173
|
+
const table = deserializeArrowWorkerTable(result);
|
|
174
|
+
return options?.ply?.shape === 'mesh'
|
|
175
|
+
? {...convertTableToMesh(table), loader: 'ply', loaderData: table.loaderData}
|
|
176
|
+
: table;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Converts mesh batches only after the Arrow column buffers reach the caller. */
|
|
180
|
+
function deserializePLYWorkerBatch(
|
|
181
|
+
result: unknown,
|
|
182
|
+
options?: PLYLoaderOptions
|
|
183
|
+
): PLYMesh | ArrowTableBatch {
|
|
184
|
+
return deserializePLYWorkerResult(result, options) as PLYMesh | ArrowTableBatch;
|
|
185
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
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 {PLYFormat} from './ply-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 `PLYWriter`. */
|
|
15
|
+
export type PLYWriterOptions = WriterOptions & {
|
|
16
|
+
/** Reserved for future PLY writer options. */
|
|
17
|
+
ply?: Record<string, never>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Writer for the PLY geometry format.
|
|
22
|
+
*/
|
|
23
|
+
export const PLYWriter = {
|
|
24
|
+
...PLYFormat,
|
|
25
|
+
dataType: null as unknown as Mesh | MeshArrowTable,
|
|
26
|
+
batchType: null as never,
|
|
27
|
+
version: VERSION,
|
|
28
|
+
options: {
|
|
29
|
+
ply: {}
|
|
30
|
+
},
|
|
31
|
+
text: true,
|
|
32
|
+
encode: async (data, options) => encodePLYSync(data, options),
|
|
33
|
+
encodeSync: encodePLYSync,
|
|
34
|
+
encodeTextSync: encodePLY
|
|
35
|
+
} as const satisfies WriterWithEncoder<Mesh | MeshArrowTable, never, PLYWriterOptions>;
|
|
36
|
+
|
|
37
|
+
/** Encode mesh category data as PLY bytes. */
|
|
38
|
+
function encodePLYSync(data: Mesh | MeshArrowTable, options?: PLYWriterOptions): ArrayBuffer {
|
|
39
|
+
const text = encodePLY(data, options);
|
|
40
|
+
return new TextEncoder().encode(text).buffer;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Encode mesh category data as ASCII PLY text. */
|
|
44
|
+
function encodePLY(data: Mesh | MeshArrowTable, options?: PLYWriterOptions): string {
|
|
45
|
+
const mesh = convertTableToMesh(normalizeMeshArrowTable(data));
|
|
46
|
+
const positionAttribute = getRequiredAttribute(mesh, 'POSITION');
|
|
47
|
+
const normalAttribute = mesh.attributes.NORMAL;
|
|
48
|
+
const textureCoordinateAttribute = mesh.attributes.TEXCOORD_0;
|
|
49
|
+
const colorAttribute = mesh.attributes.COLOR_0;
|
|
50
|
+
const customScalarAttributes = getCustomScalarAttributes(mesh);
|
|
51
|
+
const vertexCount = positionAttribute.value.length / positionAttribute.size;
|
|
52
|
+
const triangleIndices = getTriangleIndices(mesh, vertexCount);
|
|
53
|
+
const header = getPLYHeader(
|
|
54
|
+
vertexCount,
|
|
55
|
+
triangleIndices.length / 3,
|
|
56
|
+
Boolean(normalAttribute),
|
|
57
|
+
Boolean(textureCoordinateAttribute),
|
|
58
|
+
Boolean(colorAttribute),
|
|
59
|
+
customScalarAttributes
|
|
60
|
+
);
|
|
61
|
+
const rows: string[] = [];
|
|
62
|
+
|
|
63
|
+
for (let vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {
|
|
64
|
+
const row = [
|
|
65
|
+
getComponent(positionAttribute, vertexIndex, 0),
|
|
66
|
+
getComponent(positionAttribute, vertexIndex, 1),
|
|
67
|
+
getComponent(positionAttribute, vertexIndex, 2)
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
if (normalAttribute) {
|
|
71
|
+
row.push(
|
|
72
|
+
getComponent(normalAttribute, vertexIndex, 0),
|
|
73
|
+
getComponent(normalAttribute, vertexIndex, 1),
|
|
74
|
+
getComponent(normalAttribute, vertexIndex, 2)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (textureCoordinateAttribute) {
|
|
79
|
+
row.push(
|
|
80
|
+
getComponent(textureCoordinateAttribute, vertexIndex, 0),
|
|
81
|
+
getComponent(textureCoordinateAttribute, vertexIndex, 1)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (colorAttribute) {
|
|
86
|
+
row.push(
|
|
87
|
+
getColorByte(colorAttribute, vertexIndex, 0),
|
|
88
|
+
getColorByte(colorAttribute, vertexIndex, 1),
|
|
89
|
+
getColorByte(colorAttribute, vertexIndex, 2)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (const [, attribute] of customScalarAttributes) {
|
|
94
|
+
row.push(getComponent(attribute, vertexIndex, 0));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
rows.push(row.join(' '));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
for (let triangleIndex = 0; triangleIndex < triangleIndices.length; triangleIndex += 3) {
|
|
101
|
+
rows.push(
|
|
102
|
+
`3 ${triangleIndices[triangleIndex]} ${triangleIndices[triangleIndex + 1]} ${
|
|
103
|
+
triangleIndices[triangleIndex + 2]
|
|
104
|
+
}`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return `${header.concat(rows).join('\n')}\n`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Return mesh data as a MeshArrowTable, converting plain Mesh data first. */
|
|
112
|
+
function normalizeMeshArrowTable(data: Mesh | MeshArrowTable): MeshArrowTable {
|
|
113
|
+
if ('shape' in data && data.shape === 'arrow-table') {
|
|
114
|
+
return data;
|
|
115
|
+
}
|
|
116
|
+
return convertMeshToTable(data as Mesh, 'arrow-table');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Return a required mesh attribute or throw a format-specific error. */
|
|
120
|
+
function getRequiredAttribute(mesh: Mesh, attributeName: string): MeshAttribute {
|
|
121
|
+
const attribute = mesh.attributes[attributeName];
|
|
122
|
+
if (!attribute) {
|
|
123
|
+
throw new Error(`PLYWriter: ${attributeName} attribute is required`);
|
|
124
|
+
}
|
|
125
|
+
return attribute;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Return the ASCII PLY header lines. */
|
|
129
|
+
function getPLYHeader(
|
|
130
|
+
vertexCount: number,
|
|
131
|
+
faceCount: number,
|
|
132
|
+
hasNormals: boolean,
|
|
133
|
+
hasTextureCoordinates: boolean,
|
|
134
|
+
hasColors: boolean,
|
|
135
|
+
customScalarAttributes: [string, MeshAttribute][]
|
|
136
|
+
): string[] {
|
|
137
|
+
const header = [
|
|
138
|
+
'ply',
|
|
139
|
+
'format ascii 1.0',
|
|
140
|
+
'comment generated by loaders.gl',
|
|
141
|
+
`element vertex ${vertexCount}`,
|
|
142
|
+
'property float x',
|
|
143
|
+
'property float y',
|
|
144
|
+
'property float z'
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
if (hasNormals) {
|
|
148
|
+
header.push('property float nx', 'property float ny', 'property float nz');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (hasTextureCoordinates) {
|
|
152
|
+
header.push('property float s', 'property float t');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (hasColors) {
|
|
156
|
+
header.push('property uchar red', 'property uchar green', 'property uchar blue');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
for (const [attributeName] of customScalarAttributes) {
|
|
160
|
+
header.push(`property float ${attributeName}`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (faceCount > 0) {
|
|
164
|
+
header.push(`element face ${faceCount}`, 'property list uchar int vertex_indices');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
header.push('end_header');
|
|
168
|
+
return header;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Return additional one-component attributes that can be represented as scalar PLY properties. */
|
|
172
|
+
function getCustomScalarAttributes(mesh: Mesh): [string, MeshAttribute][] {
|
|
173
|
+
const reservedAttributeNames = new Set(['POSITION', 'NORMAL', 'TEXCOORD_0', 'COLOR_0']);
|
|
174
|
+
return Object.entries(mesh.attributes).filter(
|
|
175
|
+
([attributeName, attribute]) =>
|
|
176
|
+
!reservedAttributeNames.has(attributeName) && attribute.size === 1
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Return a single attribute component with 0 as the missing component fallback. */
|
|
181
|
+
function getComponent(
|
|
182
|
+
attribute: MeshAttribute,
|
|
183
|
+
vertexIndex: number,
|
|
184
|
+
componentIndex: number
|
|
185
|
+
): number {
|
|
186
|
+
return attribute.value[vertexIndex * attribute.size + componentIndex] || 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Return one color component as an unsigned byte. */
|
|
190
|
+
function getColorByte(
|
|
191
|
+
attribute: MeshAttribute,
|
|
192
|
+
vertexIndex: number,
|
|
193
|
+
componentIndex: number
|
|
194
|
+
): number {
|
|
195
|
+
const value = getComponent(attribute, vertexIndex, componentIndex);
|
|
196
|
+
const byteValue = attribute.normalized || value <= 1 ? value * 255 : value;
|
|
197
|
+
return Math.max(0, Math.min(255, Math.round(byteValue)));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** Return triangle indices for indexed or sequential triangle-list meshes. */
|
|
201
|
+
function getTriangleIndices(mesh: Mesh, vertexCount: number): number[] {
|
|
202
|
+
if (mesh.indices?.value?.length) {
|
|
203
|
+
return Array.from(mesh.indices.value);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (mesh.mode !== 4 && mesh.topology !== 'triangle-list') {
|
|
207
|
+
return [];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const triangleIndices: number[] = [];
|
|
211
|
+
for (let vertexIndex = 0; vertexIndex + 2 < vertexCount; vertexIndex += 3) {
|
|
212
|
+
triangleIndices.push(vertexIndex, vertexIndex + 1, vertexIndex + 2);
|
|
213
|
+
}
|
|
214
|
+
return triangleIndices;
|
|
215
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {createLoaderWorker, makeTableScanBatch} from '@loaders.gl/core/loader-utils';
|
|
6
|
+
import type {MeshArrowTable} from '@loaders.gl/core/schema';
|
|
7
|
+
import {convertMeshToTable} from '@loaders.gl/core/schema-utils';
|
|
8
|
+
import type {PLYMesh} from '../lib/ply-types';
|
|
9
|
+
import type {PLYLoaderOptions} from '../ply-loader-types';
|
|
10
|
+
import {PLYLoaderWithParser} from '../ply-loader';
|
|
11
|
+
|
|
12
|
+
createLoaderWorker({
|
|
13
|
+
...PLYLoaderWithParser,
|
|
14
|
+
/** Always returns columnar data; legacy mesh conversion runs on the caller. */
|
|
15
|
+
parse(input, options) {
|
|
16
|
+
return PLYLoaderWithParser.parse(input, {
|
|
17
|
+
...options,
|
|
18
|
+
ply: {...options?.ply, shape: 'arrow-table'}
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
/** Preserves full-mesh parsing while streaming point-cloud vertices as Arrow batches. */
|
|
22
|
+
async *parseInBatches(input, options?: PLYLoaderOptions) {
|
|
23
|
+
const parseMesh = options?.ply?.shape === 'mesh' && !options?.ply?.pointCloud;
|
|
24
|
+
const parserOptions = parseMesh
|
|
25
|
+
? options
|
|
26
|
+
: {...options, ply: {...options?.ply, shape: 'arrow-table' as const}};
|
|
27
|
+
for await (const batch of PLYLoaderWithParser.parseInBatches(input, parserOptions)) {
|
|
28
|
+
if ('shape' in batch && batch.shape === 'arrow-table') {
|
|
29
|
+
yield batch;
|
|
30
|
+
} else {
|
|
31
|
+
const mesh = batch as PLYMesh;
|
|
32
|
+
yield makeTableScanBatch({
|
|
33
|
+
...convertMeshToTable(mesh, 'arrow-table'),
|
|
34
|
+
loader: mesh.loader,
|
|
35
|
+
loaderData: mesh.loaderData
|
|
36
|
+
} as MeshArrowTable);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Uday Verma, uday.karan@gmail.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2010-2026 three.js authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|