@loaders.gl/pointclouds 0.0.0-stage → 5.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (511) hide show
  1. package/LAS-README.md +12 -0
  2. package/LICENSE +24 -0
  3. package/PCD-README.md +12 -0
  4. package/PLY-README.md +38 -0
  5. package/README.md +11 -2
  6. package/THIRD-PARTY-NOTICES.md +27 -0
  7. package/dist/dist.dev.js +30165 -0
  8. package/dist/dist.min.js +54 -0
  9. package/dist/index.cjs +61 -0
  10. package/dist/index.cjs.map +7 -0
  11. package/dist/index.d.ts +16 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +13 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/las/bundled.cjs +72 -0
  16. package/dist/las/bundled.cjs.map +7 -0
  17. package/dist/las/bundled.d.ts +12 -0
  18. package/dist/las/bundled.d.ts.map +1 -0
  19. package/dist/las/bundled.js +12 -0
  20. package/dist/las/bundled.js.map +1 -0
  21. package/dist/las/index.cjs +78 -0
  22. package/dist/las/index.cjs.map +7 -0
  23. package/dist/las/index.d.ts +17 -0
  24. package/dist/las/index.d.ts.map +1 -0
  25. package/dist/las/index.js +15 -0
  26. package/dist/las/index.js.map +1 -0
  27. package/dist/las/las-copc-loader-types.cjs +49 -0
  28. package/dist/las/las-copc-loader-types.cjs.map +7 -0
  29. package/dist/las/las-copc-loader-types.d.ts +63 -0
  30. package/dist/las/las-copc-loader-types.d.ts.map +1 -0
  31. package/dist/las/las-copc-loader-types.js +14 -0
  32. package/dist/las/las-copc-loader-types.js.map +1 -0
  33. package/dist/las/las-copc-loader.cjs +57 -0
  34. package/dist/las/las-copc-loader.cjs.map +7 -0
  35. package/dist/las/las-copc-loader.d.ts +37 -0
  36. package/dist/las/las-copc-loader.d.ts.map +1 -0
  37. package/dist/las/las-copc-loader.js +40 -0
  38. package/dist/las/las-copc-loader.js.map +1 -0
  39. package/dist/las/las-format.cjs +44 -0
  40. package/dist/las/las-format.cjs.map +7 -0
  41. package/dist/las/las-format.d.ts +16 -0
  42. package/dist/las/las-format.d.ts.map +1 -0
  43. package/dist/las/las-format.js +19 -0
  44. package/dist/las/las-format.js.map +1 -0
  45. package/dist/las/las-loader-shared.cjs +82 -0
  46. package/dist/las/las-loader-shared.cjs.map +7 -0
  47. package/dist/las/las-loader-shared.d.ts +66 -0
  48. package/dist/las/las-loader-shared.d.ts.map +1 -0
  49. package/dist/las/las-loader-shared.js +58 -0
  50. package/dist/las/las-loader-shared.js.map +1 -0
  51. package/dist/las/las-loader-types.cjs +54 -0
  52. package/dist/las/las-loader-types.cjs.map +7 -0
  53. package/dist/las/las-loader-types.d.ts +104 -0
  54. package/dist/las/las-loader-types.d.ts.map +1 -0
  55. package/dist/las/las-loader-types.js +19 -0
  56. package/dist/las/las-loader-types.js.map +1 -0
  57. package/dist/las/las-loader.cjs +80 -0
  58. package/dist/las/las-loader.cjs.map +7 -0
  59. package/dist/las/las-loader.d.ts +45 -0
  60. package/dist/las/las-loader.d.ts.map +1 -0
  61. package/dist/las/las-loader.js +58 -0
  62. package/dist/las/las-loader.js.map +1 -0
  63. package/dist/las/las-writer.cjs +1054 -0
  64. package/dist/las/las-writer.cjs.map +7 -0
  65. package/dist/las/las-writer.d.ts +69 -0
  66. package/dist/las/las-writer.d.ts.map +1 -0
  67. package/dist/las/las-writer.js +994 -0
  68. package/dist/las/las-writer.js.map +1 -0
  69. package/dist/las/laz-rs-loader-types.cjs +49 -0
  70. package/dist/las/laz-rs-loader-types.cjs.map +7 -0
  71. package/dist/las/laz-rs-loader-types.d.ts +65 -0
  72. package/dist/las/laz-rs-loader-types.d.ts.map +1 -0
  73. package/dist/las/laz-rs-loader-types.js +16 -0
  74. package/dist/las/laz-rs-loader-types.js.map +1 -0
  75. package/dist/las/laz-rs-loader.cjs +272 -0
  76. package/dist/las/laz-rs-loader.cjs.map +7 -0
  77. package/dist/las/laz-rs-loader.d.ts +37 -0
  78. package/dist/las/laz-rs-loader.d.ts.map +1 -0
  79. package/dist/las/laz-rs-loader.js +38 -0
  80. package/dist/las/laz-rs-loader.js.map +1 -0
  81. package/dist/las/lazperf-loader-types.cjs +49 -0
  82. package/dist/las/lazperf-loader-types.cjs.map +7 -0
  83. package/dist/las/lazperf-loader-types.d.ts +67 -0
  84. package/dist/las/lazperf-loader-types.d.ts.map +1 -0
  85. package/dist/las/lazperf-loader-types.js +17 -0
  86. package/dist/las/lazperf-loader-types.js.map +1 -0
  87. package/dist/las/lazperf-loader.cjs +60 -0
  88. package/dist/las/lazperf-loader.cjs.map +7 -0
  89. package/dist/las/lazperf-loader.d.ts +39 -0
  90. package/dist/las/lazperf-loader.d.ts.map +1 -0
  91. package/dist/las/lazperf-loader.js +44 -0
  92. package/dist/las/lazperf-loader.js.map +1 -0
  93. package/dist/las/lib/copc/parse-las.cjs +177 -0
  94. package/dist/las/lib/copc/parse-las.cjs.map +7 -0
  95. package/dist/las/lib/copc/parse-las.d.ts +17 -0
  96. package/dist/las/lib/copc/parse-las.d.ts.map +1 -0
  97. package/dist/las/lib/copc/parse-las.js +215 -0
  98. package/dist/las/lib/copc/parse-las.js.map +1 -0
  99. package/dist/las/lib/get-las-schema.cjs +62 -0
  100. package/dist/las/lib/get-las-schema.cjs.map +7 -0
  101. package/dist/las/lib/get-las-schema.d.ts +16 -0
  102. package/dist/las/lib/get-las-schema.d.ts.map +1 -0
  103. package/dist/las/lib/get-las-schema.js +46 -0
  104. package/dist/las/lib/get-las-schema.js.map +1 -0
  105. package/dist/las/lib/las-compatibility.cjs +110 -0
  106. package/dist/las/lib/las-compatibility.cjs.map +7 -0
  107. package/dist/las/lib/las-compatibility.d.ts +40 -0
  108. package/dist/las/lib/las-compatibility.d.ts.map +1 -0
  109. package/dist/las/lib/las-compatibility.js +115 -0
  110. package/dist/las/lib/las-compatibility.js.map +1 -0
  111. package/dist/las/lib/las-extra-bytes.cjs +223 -0
  112. package/dist/las/lib/las-extra-bytes.cjs.map +7 -0
  113. package/dist/las/lib/las-extra-bytes.d.ts +35 -0
  114. package/dist/las/lib/las-extra-bytes.d.ts.map +1 -0
  115. package/dist/las/lib/las-extra-bytes.js +195 -0
  116. package/dist/las/lib/las-extra-bytes.js.map +1 -0
  117. package/dist/las/lib/las-types.cjs +19 -0
  118. package/dist/las/lib/las-types.cjs.map +7 -0
  119. package/dist/las/lib/las-types.d.ts +194 -0
  120. package/dist/las/lib/las-types.d.ts.map +1 -0
  121. package/dist/las/lib/las-types.js +5 -0
  122. package/dist/las/lib/las-types.js.map +1 -0
  123. package/dist/las/lib/las-waveform.cjs +196 -0
  124. package/dist/las/lib/las-waveform.cjs.map +7 -0
  125. package/dist/las/lib/las-waveform.d.ts +89 -0
  126. package/dist/las/lib/las-waveform.d.ts.map +1 -0
  127. package/dist/las/lib/las-waveform.js +193 -0
  128. package/dist/las/lib/las-waveform.js.map +1 -0
  129. package/dist/las/lib/laz-perf/laslaz-decoder.cjs +382 -0
  130. package/dist/las/lib/laz-perf/laslaz-decoder.cjs.map +7 -0
  131. package/dist/las/lib/laz-perf/laslaz-decoder.d.ts +129 -0
  132. package/dist/las/lib/laz-perf/laslaz-decoder.d.ts.map +1 -0
  133. package/dist/las/lib/laz-perf/laslaz-decoder.js +377 -0
  134. package/dist/las/lib/laz-perf/laslaz-decoder.js.map +1 -0
  135. package/dist/las/lib/laz-perf/parse-las.cjs +270 -0
  136. package/dist/las/lib/laz-perf/parse-las.cjs.map +7 -0
  137. package/dist/las/lib/laz-perf/parse-las.d.ts +24 -0
  138. package/dist/las/lib/laz-perf/parse-las.d.ts.map +1 -0
  139. package/dist/las/lib/laz-perf/parse-las.js +307 -0
  140. package/dist/las/lib/laz-perf/parse-las.js.map +1 -0
  141. package/dist/las/lib/laz-rs-wasm/laslaz-decoder.cjs +631 -0
  142. package/dist/las/lib/laz-rs-wasm/laslaz-decoder.cjs.map +7 -0
  143. package/dist/las/lib/laz-rs-wasm/laslaz-decoder.d.ts +129 -0
  144. package/dist/las/lib/laz-rs-wasm/laslaz-decoder.d.ts.map +1 -0
  145. package/dist/las/lib/laz-rs-wasm/laslaz-decoder.js +414 -0
  146. package/dist/las/lib/laz-rs-wasm/laslaz-decoder.js.map +1 -0
  147. package/dist/las/lib/laz-rs-wasm/parse-las.cjs +270 -0
  148. package/dist/las/lib/laz-rs-wasm/parse-las.cjs.map +7 -0
  149. package/dist/las/lib/laz-rs-wasm/parse-las.d.ts +24 -0
  150. package/dist/las/lib/laz-rs-wasm/parse-las.d.ts.map +1 -0
  151. package/dist/las/lib/laz-rs-wasm/parse-las.js +307 -0
  152. package/dist/las/lib/laz-rs-wasm/parse-las.js.map +1 -0
  153. package/dist/las/lib/typescript/parse-las.cjs +2767 -0
  154. package/dist/las/lib/typescript/parse-las.cjs.map +7 -0
  155. package/dist/las/lib/typescript/parse-las.d.ts +39 -0
  156. package/dist/las/lib/typescript/parse-las.d.ts.map +1 -0
  157. package/dist/las/lib/typescript/parse-las.js +2607 -0
  158. package/dist/las/lib/typescript/parse-las.js.map +1 -0
  159. package/dist/las/libs/laz-perf/laz-perf.cjs +18093 -0
  160. package/dist/las/libs/laz-perf/laz-perf.cjs.map +7 -0
  161. package/dist/las/libs/laz-perf/laz-perf.d.ts +2 -0
  162. package/dist/las/libs/laz-perf/laz-perf.d.ts.map +1 -0
  163. package/dist/las/libs/laz-perf/laz-perf.js +19003 -0
  164. package/dist/las/libs/laz-perf/laz-perf.js.map +1 -0
  165. package/dist/las/libs/laz-rs-wasm/laz_rs_wasm.d.ts +95 -0
  166. package/dist/las/libs/laz-rs-wasm/laz_rs_wasm.d.ts.map +1 -0
  167. package/dist/las/libs/laz-rs-wasm/laz_rs_wasm.js +442 -0
  168. package/dist/las/libs/laz-rs-wasm/laz_rs_wasm.js.map +1 -0
  169. package/dist/las/libs/laz-rs-wasm/laz_rs_wasm_bg.wasm +0 -0
  170. package/dist/las/libs/laz-rs-wasm/laz_rs_wasm_bg.wasm.d.ts +38 -0
  171. package/dist/las/unbundled.cjs +71 -0
  172. package/dist/las/unbundled.cjs.map +7 -0
  173. package/dist/las/unbundled.d.ts +11 -0
  174. package/dist/las/unbundled.d.ts.map +1 -0
  175. package/dist/las/unbundled.js +11 -0
  176. package/dist/las/unbundled.js.map +1 -0
  177. package/dist/las/workers/las-worker.cjs +23 -0
  178. package/dist/las/workers/las-worker.cjs.map +7 -0
  179. package/dist/las/workers/las-worker.d.ts +2 -0
  180. package/dist/las/workers/las-worker.d.ts.map +1 -0
  181. package/dist/las/workers/las-worker.js +23 -0
  182. package/dist/las/workers/las-worker.js.map +1 -0
  183. package/dist/las-copc-loader-types.cjs +51 -0
  184. package/dist/las-copc-loader-types.cjs.map +7 -0
  185. package/dist/las-copc-loader-types.d.ts +2 -0
  186. package/dist/las-copc-loader-types.d.ts.map +1 -0
  187. package/dist/las-copc-loader-types.js +2 -0
  188. package/dist/las-copc-loader-types.js.map +1 -0
  189. package/dist/las-copc-loader.cjs +59 -0
  190. package/dist/las-copc-loader.cjs.map +7 -0
  191. package/dist/las-copc-loader.d.ts +2 -0
  192. package/dist/las-copc-loader.d.ts.map +1 -0
  193. package/dist/las-copc-loader.js +2 -0
  194. package/dist/las-copc-loader.js.map +1 -0
  195. package/dist/las-loader-types.cjs +56 -0
  196. package/dist/las-loader-types.cjs.map +7 -0
  197. package/dist/las-loader-types.d.ts +2 -0
  198. package/dist/las-loader-types.d.ts.map +1 -0
  199. package/dist/las-loader-types.js +2 -0
  200. package/dist/las-loader-types.js.map +1 -0
  201. package/dist/las-loader.cjs +82 -0
  202. package/dist/las-loader.cjs.map +7 -0
  203. package/dist/las-loader.d.ts +2 -0
  204. package/dist/las-loader.d.ts.map +1 -0
  205. package/dist/las-loader.js +2 -0
  206. package/dist/las-loader.js.map +1 -0
  207. package/dist/las-worker.js +23169 -0
  208. package/dist/las-writer.cjs +1056 -0
  209. package/dist/las-writer.cjs.map +7 -0
  210. package/dist/las-writer.d.ts +2 -0
  211. package/dist/las-writer.d.ts.map +1 -0
  212. package/dist/las-writer.js +2 -0
  213. package/dist/las-writer.js.map +1 -0
  214. package/dist/laz-rs-loader-types.cjs +51 -0
  215. package/dist/laz-rs-loader-types.cjs.map +7 -0
  216. package/dist/laz-rs-loader-types.d.ts +2 -0
  217. package/dist/laz-rs-loader-types.d.ts.map +1 -0
  218. package/dist/laz-rs-loader-types.js +2 -0
  219. package/dist/laz-rs-loader-types.js.map +1 -0
  220. package/dist/laz-rs-loader.cjs +274 -0
  221. package/dist/laz-rs-loader.cjs.map +7 -0
  222. package/dist/laz-rs-loader.d.ts +2 -0
  223. package/dist/laz-rs-loader.d.ts.map +1 -0
  224. package/dist/laz-rs-loader.js +2 -0
  225. package/dist/laz-rs-loader.js.map +1 -0
  226. package/dist/lazperf-loader-types.cjs +51 -0
  227. package/dist/lazperf-loader-types.cjs.map +7 -0
  228. package/dist/lazperf-loader-types.d.ts +2 -0
  229. package/dist/lazperf-loader-types.d.ts.map +1 -0
  230. package/dist/lazperf-loader-types.js +2 -0
  231. package/dist/lazperf-loader-types.js.map +1 -0
  232. package/dist/lazperf-loader.cjs +62 -0
  233. package/dist/lazperf-loader.cjs.map +7 -0
  234. package/dist/lazperf-loader.d.ts +2 -0
  235. package/dist/lazperf-loader.d.ts.map +1 -0
  236. package/dist/lazperf-loader.js +2 -0
  237. package/dist/lazperf-loader.js.map +1 -0
  238. package/dist/pcd/bundled.cjs +33 -0
  239. package/dist/pcd/bundled.cjs.map +7 -0
  240. package/dist/pcd/bundled.d.ts +3 -0
  241. package/dist/pcd/bundled.d.ts.map +1 -0
  242. package/dist/pcd/bundled.js +5 -0
  243. package/dist/pcd/bundled.js.map +1 -0
  244. package/dist/pcd/index.cjs +40 -0
  245. package/dist/pcd/index.cjs.map +7 -0
  246. package/dist/pcd/index.d.ts +8 -0
  247. package/dist/pcd/index.d.ts.map +1 -0
  248. package/dist/pcd/index.js +10 -0
  249. package/dist/pcd/index.js.map +1 -0
  250. package/dist/pcd/lib/decompress-lzf.cjs +80 -0
  251. package/dist/pcd/lib/decompress-lzf.cjs.map +7 -0
  252. package/dist/pcd/lib/decompress-lzf.d.ts +7 -0
  253. package/dist/pcd/lib/decompress-lzf.d.ts.map +1 -0
  254. package/dist/pcd/lib/decompress-lzf.js +62 -0
  255. package/dist/pcd/lib/decompress-lzf.js.map +1 -0
  256. package/dist/pcd/lib/get-pcd-schema.cjs +70 -0
  257. package/dist/pcd/lib/get-pcd-schema.cjs.map +7 -0
  258. package/dist/pcd/lib/get-pcd-schema.d.ts +10 -0
  259. package/dist/pcd/lib/get-pcd-schema.d.ts.map +1 -0
  260. package/dist/pcd/lib/get-pcd-schema.js +53 -0
  261. package/dist/pcd/lib/get-pcd-schema.js.map +1 -0
  262. package/dist/pcd/lib/parse-pcd.cjs +354 -0
  263. package/dist/pcd/lib/parse-pcd.cjs.map +7 -0
  264. package/dist/pcd/lib/parse-pcd.d.ts +20 -0
  265. package/dist/pcd/lib/parse-pcd.d.ts.map +1 -0
  266. package/dist/pcd/lib/parse-pcd.js +341 -0
  267. package/dist/pcd/lib/parse-pcd.js.map +1 -0
  268. package/dist/pcd/lib/pcd-types.cjs +19 -0
  269. package/dist/pcd/lib/pcd-types.cjs.map +7 -0
  270. package/dist/pcd/lib/pcd-types.d.ts +31 -0
  271. package/dist/pcd/lib/pcd-types.d.ts.map +1 -0
  272. package/dist/pcd/lib/pcd-types.js +5 -0
  273. package/dist/pcd/lib/pcd-types.js.map +1 -0
  274. package/dist/pcd/pcd-format.cjs +42 -0
  275. package/dist/pcd/pcd-format.cjs.map +7 -0
  276. package/dist/pcd/pcd-format.d.ts +16 -0
  277. package/dist/pcd/pcd-format.d.ts.map +1 -0
  278. package/dist/pcd/pcd-format.js +19 -0
  279. package/dist/pcd/pcd-format.js.map +1 -0
  280. package/dist/pcd/pcd-loader-types.cjs +64 -0
  281. package/dist/pcd/pcd-loader-types.cjs.map +7 -0
  282. package/dist/pcd/pcd-loader-types.d.ts +105 -0
  283. package/dist/pcd/pcd-loader-types.d.ts.map +1 -0
  284. package/dist/pcd/pcd-loader-types.js +35 -0
  285. package/dist/pcd/pcd-loader-types.js.map +1 -0
  286. package/dist/pcd/pcd-loader.cjs +144 -0
  287. package/dist/pcd/pcd-loader.cjs.map +7 -0
  288. package/dist/pcd/pcd-loader.d.ts +44 -0
  289. package/dist/pcd/pcd-loader.d.ts.map +1 -0
  290. package/dist/pcd/pcd-loader.js +128 -0
  291. package/dist/pcd/pcd-loader.js.map +1 -0
  292. package/dist/pcd/pcd-writer.cjs +134 -0
  293. package/dist/pcd/pcd-writer.cjs.map +7 -0
  294. package/dist/pcd/pcd-writer.d.ts +37 -0
  295. package/dist/pcd/pcd-writer.d.ts.map +1 -0
  296. package/dist/pcd/pcd-writer.js +115 -0
  297. package/dist/pcd/pcd-writer.js.map +1 -0
  298. package/dist/pcd/unbundled.cjs +33 -0
  299. package/dist/pcd/unbundled.cjs.map +7 -0
  300. package/dist/pcd/unbundled.d.ts +3 -0
  301. package/dist/pcd/unbundled.d.ts.map +1 -0
  302. package/dist/pcd/unbundled.js +5 -0
  303. package/dist/pcd/unbundled.js.map +1 -0
  304. package/dist/pcd/workers/pcd-worker.cjs +23 -0
  305. package/dist/pcd/workers/pcd-worker.cjs.map +7 -0
  306. package/dist/pcd/workers/pcd-worker.d.ts +2 -0
  307. package/dist/pcd/workers/pcd-worker.d.ts.map +1 -0
  308. package/dist/pcd/workers/pcd-worker.js +23 -0
  309. package/dist/pcd/workers/pcd-worker.js.map +1 -0
  310. package/dist/pcd-loader-types.cjs +66 -0
  311. package/dist/pcd-loader-types.cjs.map +7 -0
  312. package/dist/pcd-loader-types.d.ts +2 -0
  313. package/dist/pcd-loader-types.d.ts.map +1 -0
  314. package/dist/pcd-loader-types.js +2 -0
  315. package/dist/pcd-loader-types.js.map +1 -0
  316. package/dist/pcd-loader.cjs +146 -0
  317. package/dist/pcd-loader.cjs.map +7 -0
  318. package/dist/pcd-loader.d.ts +2 -0
  319. package/dist/pcd-loader.d.ts.map +1 -0
  320. package/dist/pcd-loader.js +2 -0
  321. package/dist/pcd-loader.js.map +1 -0
  322. package/dist/pcd-worker.js +17655 -0
  323. package/dist/pcd-writer.cjs +136 -0
  324. package/dist/pcd-writer.cjs.map +7 -0
  325. package/dist/pcd-writer.d.ts +2 -0
  326. package/dist/pcd-writer.d.ts.map +1 -0
  327. package/dist/pcd-writer.js +2 -0
  328. package/dist/pcd-writer.js.map +1 -0
  329. package/dist/ply/bundled.cjs +33 -0
  330. package/dist/ply/bundled.cjs.map +7 -0
  331. package/dist/ply/bundled.d.ts +3 -0
  332. package/dist/ply/bundled.d.ts.map +1 -0
  333. package/dist/ply/bundled.js +5 -0
  334. package/dist/ply/bundled.js.map +1 -0
  335. package/dist/ply/index.cjs +40 -0
  336. package/dist/ply/index.cjs.map +7 -0
  337. package/dist/ply/index.d.ts +8 -0
  338. package/dist/ply/index.d.ts.map +1 -0
  339. package/dist/ply/index.js +11 -0
  340. package/dist/ply/index.js.map +1 -0
  341. package/dist/ply/lib/get-ply-schema.cjs +126 -0
  342. package/dist/ply/lib/get-ply-schema.cjs.map +7 -0
  343. package/dist/ply/lib/get-ply-schema.d.ts +10 -0
  344. package/dist/ply/lib/get-ply-schema.d.ts.map +1 -0
  345. package/dist/ply/lib/get-ply-schema.js +117 -0
  346. package/dist/ply/lib/get-ply-schema.js.map +1 -0
  347. package/dist/ply/lib/normalize-ply.cjs +96 -0
  348. package/dist/ply/lib/normalize-ply.cjs.map +7 -0
  349. package/dist/ply/lib/normalize-ply.d.ts +8 -0
  350. package/dist/ply/lib/normalize-ply.d.ts.map +1 -0
  351. package/dist/ply/lib/normalize-ply.js +89 -0
  352. package/dist/ply/lib/normalize-ply.js.map +1 -0
  353. package/dist/ply/lib/parse-ply-arrow.cjs +552 -0
  354. package/dist/ply/lib/parse-ply-arrow.cjs.map +7 -0
  355. package/dist/ply/lib/parse-ply-arrow.d.ts +25 -0
  356. package/dist/ply/lib/parse-ply-arrow.d.ts.map +1 -0
  357. package/dist/ply/lib/parse-ply-arrow.js +493 -0
  358. package/dist/ply/lib/parse-ply-arrow.js.map +1 -0
  359. package/dist/ply/lib/parse-ply-in-batches.cjs +607 -0
  360. package/dist/ply/lib/parse-ply-in-batches.cjs.map +7 -0
  361. package/dist/ply/lib/parse-ply-in-batches.d.ts +9 -0
  362. package/dist/ply/lib/parse-ply-in-batches.d.ts.map +1 -0
  363. package/dist/ply/lib/parse-ply-in-batches.js +625 -0
  364. package/dist/ply/lib/parse-ply-in-batches.js.map +1 -0
  365. package/dist/ply/lib/parse-ply.cjs +755 -0
  366. package/dist/ply/lib/parse-ply.cjs.map +7 -0
  367. package/dist/ply/lib/parse-ply.d.ts +69 -0
  368. package/dist/ply/lib/parse-ply.d.ts.map +1 -0
  369. package/dist/ply/lib/parse-ply.js +851 -0
  370. package/dist/ply/lib/parse-ply.js.map +1 -0
  371. package/dist/ply/lib/ply-types.cjs +19 -0
  372. package/dist/ply/lib/ply-types.cjs.map +7 -0
  373. package/dist/ply/lib/ply-types.d.ts +37 -0
  374. package/dist/ply/lib/ply-types.d.ts.map +1 -0
  375. package/dist/ply/lib/ply-types.js +2 -0
  376. package/dist/ply/lib/ply-types.js.map +1 -0
  377. package/dist/ply/ply-format.cjs +43 -0
  378. package/dist/ply/ply-format.cjs.map +7 -0
  379. package/dist/ply/ply-format.d.ts +18 -0
  380. package/dist/ply/ply-format.d.ts.map +1 -0
  381. package/dist/ply/ply-format.js +22 -0
  382. package/dist/ply/ply-format.js.map +1 -0
  383. package/dist/ply/ply-loader-types.cjs +65 -0
  384. package/dist/ply/ply-loader-types.cjs.map +7 -0
  385. package/dist/ply/ply-loader-types.d.ts +111 -0
  386. package/dist/ply/ply-loader-types.d.ts.map +1 -0
  387. package/dist/ply/ply-loader-types.js +38 -0
  388. package/dist/ply/ply-loader-types.js.map +1 -0
  389. package/dist/ply/ply-loader.cjs +134 -0
  390. package/dist/ply/ply-loader.cjs.map +7 -0
  391. package/dist/ply/ply-loader.d.ts +44 -0
  392. package/dist/ply/ply-loader.d.ts.map +1 -0
  393. package/dist/ply/ply-loader.js +121 -0
  394. package/dist/ply/ply-loader.js.map +1 -0
  395. package/dist/ply/ply-writer.cjs +175 -0
  396. package/dist/ply/ply-writer.cjs.map +7 -0
  397. package/dist/ply/ply-writer.d.ts +37 -0
  398. package/dist/ply/ply-writer.d.ts.map +1 -0
  399. package/dist/ply/ply-writer.js +140 -0
  400. package/dist/ply/ply-writer.js.map +1 -0
  401. package/dist/ply/unbundled.cjs +33 -0
  402. package/dist/ply/unbundled.cjs.map +7 -0
  403. package/dist/ply/unbundled.d.ts +3 -0
  404. package/dist/ply/unbundled.d.ts.map +1 -0
  405. package/dist/ply/unbundled.js +5 -0
  406. package/dist/ply/unbundled.js.map +1 -0
  407. package/dist/ply/workers/ply-worker.cjs +34 -0
  408. package/dist/ply/workers/ply-worker.cjs.map +7 -0
  409. package/dist/ply/workers/ply-worker.d.ts +2 -0
  410. package/dist/ply/workers/ply-worker.d.ts.map +1 -0
  411. package/dist/ply/workers/ply-worker.js +37 -0
  412. package/dist/ply/workers/ply-worker.js.map +1 -0
  413. package/dist/ply-loader-types.cjs +67 -0
  414. package/dist/ply-loader-types.cjs.map +7 -0
  415. package/dist/ply-loader-types.d.ts +2 -0
  416. package/dist/ply-loader-types.d.ts.map +1 -0
  417. package/dist/ply-loader-types.js +2 -0
  418. package/dist/ply-loader-types.js.map +1 -0
  419. package/dist/ply-loader.cjs +136 -0
  420. package/dist/ply-loader.cjs.map +7 -0
  421. package/dist/ply-loader.d.ts +2 -0
  422. package/dist/ply-loader.d.ts.map +1 -0
  423. package/dist/ply-loader.js +2 -0
  424. package/dist/ply-loader.js.map +1 -0
  425. package/dist/ply-worker.js +19308 -0
  426. package/dist/ply-writer.cjs +177 -0
  427. package/dist/ply-writer.cjs.map +7 -0
  428. package/dist/ply-writer.d.ts +2 -0
  429. package/dist/ply-writer.d.ts.map +1 -0
  430. package/dist/ply-writer.js +2 -0
  431. package/dist/ply-writer.js.map +1 -0
  432. package/package.json +237 -4
  433. package/src/index.ts +19 -0
  434. package/src/las/bundled.ts +39 -0
  435. package/src/las/index.ts +70 -0
  436. package/src/las/las-copc-loader-types.ts +18 -0
  437. package/src/las/las-copc-loader.ts +61 -0
  438. package/src/las/las-format.ts +21 -0
  439. package/src/las/las-loader-shared.ts +124 -0
  440. package/src/las/las-loader-types.ts +27 -0
  441. package/src/las/las-loader.ts +109 -0
  442. package/src/las/las-writer.ts +1473 -0
  443. package/src/las/laz-rs-loader-types.ts +21 -0
  444. package/src/las/laz-rs-loader.ts +53 -0
  445. package/src/las/lazperf-loader-types.ts +22 -0
  446. package/src/las/lazperf-loader.ts +65 -0
  447. package/src/las/lib/LASZIP-LICENSE +202 -0
  448. package/src/las/lib/LASZIP-NOTICE +4 -0
  449. package/src/las/lib/copc/parse-las.ts +265 -0
  450. package/src/las/lib/get-las-schema.ts +50 -0
  451. package/src/las/lib/las-compatibility.ts +178 -0
  452. package/src/las/lib/las-extra-bytes.ts +274 -0
  453. package/src/las/lib/las-types.ts +206 -0
  454. package/src/las/lib/las-waveform.ts +292 -0
  455. package/src/las/lib/laz-perf/laslaz-decoder.ts +443 -0
  456. package/src/las/lib/laz-perf/parse-las.ts +412 -0
  457. package/src/las/lib/laz-rs-wasm/laslaz-decoder.ts +488 -0
  458. package/src/las/lib/laz-rs-wasm/parse-las.ts +412 -0
  459. package/src/las/lib/typescript/parse-las.ts +3730 -0
  460. package/src/las/libs/laz-perf/laz-perf.ts +20615 -0
  461. package/src/las/libs/laz-rs-wasm/README.md +5 -0
  462. package/src/las/libs/laz-rs-wasm/laz_rs_wasm.d.ts +89 -0
  463. package/src/las/libs/laz-rs-wasm/laz_rs_wasm.js +497 -0
  464. package/src/las/libs/laz-rs-wasm/laz_rs_wasm_bg.wasm +0 -0
  465. package/src/las/libs/laz-rs-wasm/laz_rs_wasm_bg.wasm.d.ts +38 -0
  466. package/src/las/libs/laz-rs-wasm/package.json +25 -0
  467. package/src/las/unbundled.ts +38 -0
  468. package/src/las/workers/las-worker.ts +24 -0
  469. package/src/las-copc-loader-types.ts +1 -0
  470. package/src/las-copc-loader.ts +1 -0
  471. package/src/las-loader-types.ts +1 -0
  472. package/src/las-loader.ts +1 -0
  473. package/src/las-writer.ts +1 -0
  474. package/src/laz-rs-loader-types.ts +1 -0
  475. package/src/laz-rs-loader.ts +1 -0
  476. package/src/lazperf-loader-types.ts +1 -0
  477. package/src/lazperf-loader.ts +1 -0
  478. package/src/pcd/bundled.ts +9 -0
  479. package/src/pcd/index.ts +13 -0
  480. package/src/pcd/lib/decompress-lzf.ts +68 -0
  481. package/src/pcd/lib/get-pcd-schema.ts +66 -0
  482. package/src/pcd/lib/parse-pcd.ts +474 -0
  483. package/src/pcd/lib/pcd-types.ts +34 -0
  484. package/src/pcd/pcd-format.ts +21 -0
  485. package/src/pcd/pcd-loader-types.ts +53 -0
  486. package/src/pcd/pcd-loader.ts +179 -0
  487. package/src/pcd/pcd-writer.ts +152 -0
  488. package/src/pcd/unbundled.ts +6 -0
  489. package/src/pcd/workers/pcd-worker.ts +24 -0
  490. package/src/pcd-loader-types.ts +1 -0
  491. package/src/pcd-loader.ts +1 -0
  492. package/src/pcd-writer.ts +1 -0
  493. package/src/ply/bundled.ts +9 -0
  494. package/src/ply/index.ts +15 -0
  495. package/src/ply/lib/get-ply-schema.ts +133 -0
  496. package/src/ply/lib/normalize-ply.ts +110 -0
  497. package/src/ply/lib/parse-ply-arrow.ts +676 -0
  498. package/src/ply/lib/parse-ply-in-batches.ts +827 -0
  499. package/src/ply/lib/parse-ply.ts +1081 -0
  500. package/src/ply/lib/ply-types.ts +47 -0
  501. package/src/ply/ply-format.ts +24 -0
  502. package/src/ply/ply-loader-types.ts +61 -0
  503. package/src/ply/ply-loader.ts +185 -0
  504. package/src/ply/ply-writer.ts +215 -0
  505. package/src/ply/unbundled.ts +6 -0
  506. package/src/ply/workers/ply-worker.ts +40 -0
  507. package/src/ply-loader-types.ts +1 -0
  508. package/src/ply-loader.ts +1 -0
  509. package/src/ply-writer.ts +1 -0
  510. package/third-party-licenses/plasio-LICENSE +21 -0
  511. package/third-party-licenses/three-LICENSE +21 -0
@@ -0,0 +1,851 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import * as arrow from 'apache-arrow';
5
+ import normalizePLY from "./normalize-ply.js";
6
+ import { getPLYSchema } from "./get-ply-schema.js";
7
+ const PLY_END_HEADER = 'end_header';
8
+ /**
9
+ * @param data
10
+ * @param options
11
+ * @returns
12
+ */
13
+ export function parsePLY(data, options = {}) {
14
+ let header;
15
+ let attributes;
16
+ if (data instanceof ArrayBuffer) {
17
+ header = parsePLYHeader(data, options);
18
+ attributes =
19
+ header.format === 'ascii'
20
+ ? parseASCII(new TextDecoder().decode(data), header)
21
+ : parseBinary(data, header, options);
22
+ }
23
+ else {
24
+ header = parsePLYHeader(data, options);
25
+ attributes = parseASCII(data, header);
26
+ }
27
+ return normalizePLY(header, attributes);
28
+ }
29
+ /**
30
+ * Parse binary scalar point-cloud PLY directly into an Arrow table.
31
+ * @param data PLY data.
32
+ * @param options Parser options.
33
+ * @returns Arrow table, or null when the file requires the general mesh parser.
34
+ */
35
+ export function parsePLYToArrowTable(data, options = {}) {
36
+ if (!(data instanceof ArrayBuffer)) {
37
+ return null;
38
+ }
39
+ const header = parsePLYHeader(data, options);
40
+ if (header.format === 'ascii') {
41
+ return null;
42
+ }
43
+ const attributes = parseBinaryPointCloud(data, header, options);
44
+ if (!attributes) {
45
+ return null;
46
+ }
47
+ return makePLYArrowTable(header, attributes);
48
+ }
49
+ /**
50
+ * Parse a fixed-width binary point-cloud PLY byte range into an Arrow table.
51
+ * @param data Binary PLY bytes containing only vertex records.
52
+ * @param header PLY header describing the vertex record layout.
53
+ * @param options Parser options.
54
+ * @returns Arrow table, or null when the header is not supported by the fixed-width path.
55
+ */
56
+ export function parsePLYBinaryPointCloudToArrowTable(data, header, options = {}) {
57
+ const attributes = parseBinaryPointCloud(data, header, options);
58
+ return attributes ? makePLYArrowTable(header, attributes) : null;
59
+ }
60
+ /**
61
+ * Parse fixed-width binary vertex records directly from a byte view into an Arrow table.
62
+ * @param records Binary PLY vertex records without a header.
63
+ * @param header PLY header with the batch vertex count already applied.
64
+ * @param options Parser options.
65
+ * @param plan Optional reusable parse plan for the same header layout.
66
+ * @returns Arrow table, or null when the header is not supported by the fixed-width path.
67
+ */
68
+ export function parsePLYBinaryPointCloudRecordsToArrowTable(records, header, options = {}, plan) {
69
+ const attributes = parseBinaryPointCloudRecords(records, header, options, plan);
70
+ return attributes ? makePLYArrowTable(header, attributes) : null;
71
+ }
72
+ /**
73
+ * @param data
74
+ * @param options
75
+ * @returns header
76
+ */
77
+ export function parsePLYHeader(data, options) {
78
+ const { headerText, headerLength } = data instanceof ArrayBuffer ? getBinaryHeader(data) : getTextHeader(data);
79
+ const headerStart = headerText.indexOf('ply');
80
+ const headerEndMarker = headerText.lastIndexOf('end_header');
81
+ const headerEnd = headerEndMarker + 'end_header'.length;
82
+ if (headerStart >= 0 &&
83
+ headerEndMarker >= headerStart + 3 &&
84
+ headerEnd < headerText.length &&
85
+ /\s/.test(headerText[headerEnd])) {
86
+ const lines = headerText.slice(headerStart + 3, headerEndMarker).split('\n');
87
+ const header = parseHeaderLines(lines, headerLength || headerEnd + 1 - headerStart, options);
88
+ return header;
89
+ }
90
+ return parseHeaderLines([], headerLength, options);
91
+ }
92
+ /** Return PLY header text and its byte length from binary data without decoding the body. */
93
+ function getBinaryHeader(data) {
94
+ const bytes = new Uint8Array(data);
95
+ const headerEnd = findHeaderEnd(bytes);
96
+ return {
97
+ headerText: new TextDecoder().decode(bytes.subarray(0, headerEnd)),
98
+ headerLength: headerEnd
99
+ };
100
+ }
101
+ /** Return PLY header text and its character length from text data. */
102
+ function getTextHeader(data) {
103
+ const headerEnd = data.indexOf(PLY_END_HEADER);
104
+ if (headerEnd === -1) {
105
+ return { headerText: '', headerLength: 0 };
106
+ }
107
+ let headerLength = headerEnd + PLY_END_HEADER.length;
108
+ if (data[headerLength] === '\r' && data[headerLength + 1] === '\n') {
109
+ headerLength += 2;
110
+ }
111
+ else if (headerLength < data.length && /\s/.test(data[headerLength])) {
112
+ headerLength += 1;
113
+ }
114
+ return { headerText: data.slice(0, headerLength), headerLength };
115
+ }
116
+ /** Find the byte offset immediately after the `end_header` terminator. */
117
+ function findHeaderEnd(bytes) {
118
+ const pattern = new TextEncoder().encode(PLY_END_HEADER);
119
+ const lastPatternStart = bytes.length - pattern.length;
120
+ for (let byteIndex = 0; byteIndex <= lastPatternStart; byteIndex++) {
121
+ let matches = true;
122
+ for (let patternIndex = 0; patternIndex < pattern.length; patternIndex++) {
123
+ if (bytes[byteIndex + patternIndex] !== pattern[patternIndex]) {
124
+ matches = false;
125
+ break;
126
+ }
127
+ }
128
+ if (matches) {
129
+ let headerEnd = byteIndex + pattern.length;
130
+ if (bytes[headerEnd] === 0x0d && bytes[headerEnd + 1] === 0x0a) {
131
+ headerEnd += 2;
132
+ }
133
+ else if (headerEnd < bytes.length && isWhitespaceByte(bytes[headerEnd])) {
134
+ headerEnd += 1;
135
+ }
136
+ return headerEnd;
137
+ }
138
+ }
139
+ return bytes.length;
140
+ }
141
+ /** Return true for ASCII whitespace bytes that can terminate a PLY header. */
142
+ function isWhitespaceByte(byte) {
143
+ return byte === 0x0a || byte === 0x0d || byte === 0x09 || byte === 0x20;
144
+ }
145
+ /**
146
+ * @param lines
147
+ * @param headerLength
148
+ * @param options
149
+ * @returns header
150
+ */
151
+ // eslint-disable-next-line complexity
152
+ function parseHeaderLines(lines, headerLength, options) {
153
+ const header = {
154
+ comments: [],
155
+ elements: [],
156
+ headerLength
157
+ };
158
+ let lineType;
159
+ let lineValues;
160
+ let currentElement = null;
161
+ for (let i = 0; i < lines.length; i++) {
162
+ let line = lines[i];
163
+ line = line.trim();
164
+ if (line === '') {
165
+ // eslint-disable-next-line
166
+ continue;
167
+ }
168
+ lineValues = line.split(/\s+/);
169
+ lineType = lineValues.shift();
170
+ line = lineValues.join(' ');
171
+ switch (lineType) {
172
+ case 'format':
173
+ header.format = lineValues[0];
174
+ header.version = lineValues[1];
175
+ break;
176
+ case 'comment':
177
+ header.comments.push(line);
178
+ break;
179
+ case 'element':
180
+ // Start new element, store previous element
181
+ if (currentElement) {
182
+ header.elements.push(currentElement);
183
+ }
184
+ currentElement = {
185
+ name: lineValues[0],
186
+ count: parseInt(lineValues[1], 10),
187
+ properties: []
188
+ };
189
+ break;
190
+ case 'property':
191
+ if (currentElement) {
192
+ const property = makePLYElementProperty(lineValues);
193
+ if (options?.propertyNameMapping && property.name in options?.propertyNameMapping) {
194
+ property.name = options?.propertyNameMapping[property.name];
195
+ }
196
+ currentElement.properties.push(property);
197
+ }
198
+ break;
199
+ default:
200
+ }
201
+ }
202
+ // Store in-progress element
203
+ if (currentElement) {
204
+ header.elements.push(currentElement);
205
+ }
206
+ return header;
207
+ }
208
+ /** Generate attributes arrays from the header */
209
+ // eslint-disable-next-line complexity
210
+ function getPLYAttributes(header) {
211
+ // TODO Generate only the attribute arrays actually in the header
212
+ const attributes = {
213
+ indices: [],
214
+ vertices: [],
215
+ normals: [],
216
+ uvs: [],
217
+ colors: []
218
+ };
219
+ for (const element of header.elements) {
220
+ if (element.name === 'vertex') {
221
+ for (const property of element.properties) {
222
+ switch (property.name) {
223
+ case 'x':
224
+ case 'y':
225
+ case 'z':
226
+ case 'nx':
227
+ case 'ny':
228
+ case 'nz':
229
+ case 's':
230
+ case 't':
231
+ case 'red':
232
+ case 'green':
233
+ case 'blue':
234
+ break;
235
+ default:
236
+ // Add any non-geometry attributes
237
+ attributes[property.name] = [];
238
+ break;
239
+ }
240
+ }
241
+ }
242
+ }
243
+ return attributes;
244
+ }
245
+ /**
246
+ * @param propertyValues
247
+ * @returns property of ply element
248
+ */
249
+ function makePLYElementProperty(propertyValues) {
250
+ const type = propertyValues[0];
251
+ switch (type) {
252
+ case 'list':
253
+ return {
254
+ type,
255
+ name: propertyValues[3],
256
+ countType: propertyValues[1],
257
+ itemType: propertyValues[2]
258
+ };
259
+ default:
260
+ return {
261
+ type,
262
+ name: propertyValues[1]
263
+ };
264
+ }
265
+ }
266
+ /**
267
+ * Parses ASCII number
268
+ * @param n
269
+ * @param type
270
+ * @returns
271
+ */
272
+ // eslint-disable-next-line complexity
273
+ function parseASCIINumber(n, type) {
274
+ switch (type) {
275
+ case 'char':
276
+ case 'uchar':
277
+ case 'short':
278
+ case 'ushort':
279
+ case 'int':
280
+ case 'uint':
281
+ case 'int8':
282
+ case 'uint8':
283
+ case 'int16':
284
+ case 'uint16':
285
+ case 'int32':
286
+ case 'uint32':
287
+ return parseInt(n, 10);
288
+ case 'float':
289
+ case 'double':
290
+ case 'float32':
291
+ case 'float64':
292
+ return parseFloat(n);
293
+ default:
294
+ throw new Error(type);
295
+ }
296
+ }
297
+ /**
298
+ * @param properties
299
+ * @param line
300
+ * @returns ASCII element
301
+ */
302
+ function parsePLYElement(properties, line) {
303
+ const values = line.split(/\s+/);
304
+ const element = {};
305
+ for (let i = 0; i < properties.length; i++) {
306
+ if (properties[i].type === 'list') {
307
+ const list = [];
308
+ const n = parseASCIINumber(values.shift(), properties[i].countType);
309
+ for (let j = 0; j < n; j++) {
310
+ list.push(parseASCIINumber(values.shift(), properties[i].itemType));
311
+ }
312
+ element[properties[i].name] = list;
313
+ }
314
+ else {
315
+ element[properties[i].name] = parseASCIINumber(values.shift(), properties[i].type);
316
+ }
317
+ }
318
+ return element;
319
+ }
320
+ /**
321
+ * @param data
322
+ * @param header
323
+ * @returns [attributes]
324
+ */
325
+ function parseASCII(data, header) {
326
+ // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)
327
+ const attributes = getPLYAttributes(header);
328
+ const patternBody = /end_header\s([\s\S]*)$/;
329
+ let body = '';
330
+ const result = patternBody.exec(data);
331
+ if (result !== null) {
332
+ body = result[1];
333
+ }
334
+ const lines = body.split('\n');
335
+ let currentElement = 0;
336
+ let currentElementCount = 0;
337
+ for (let i = 0; i < lines.length; i++) {
338
+ let line = lines[i];
339
+ line = line.trim();
340
+ if (line !== '') {
341
+ if (currentElementCount >= header.elements[currentElement].count) {
342
+ currentElement++;
343
+ currentElementCount = 0;
344
+ }
345
+ const element = parsePLYElement(header.elements[currentElement].properties, line);
346
+ handleElement(attributes, header.elements[currentElement].name, element);
347
+ currentElementCount++;
348
+ }
349
+ }
350
+ return attributes;
351
+ }
352
+ /**
353
+ * @param buffer
354
+ * @param elementName
355
+ * @param element
356
+ */
357
+ // eslint-disable-next-line complexity
358
+ function handleElement(buffer, elementName, element = {}) {
359
+ if (elementName === 'vertex') {
360
+ for (const propertyName of Object.keys(element)) {
361
+ switch (propertyName) {
362
+ case 'x':
363
+ buffer.vertices.push(element.x, element.y, element.z);
364
+ break;
365
+ case 'y':
366
+ case 'z':
367
+ break;
368
+ case 'nx':
369
+ if ('nx' in element && 'ny' in element && 'nz' in element) {
370
+ buffer.normals.push(element.nx, element.ny, element.nz);
371
+ }
372
+ break;
373
+ case 'ny':
374
+ case 'nz':
375
+ break;
376
+ case 's':
377
+ if ('s' in element && 't' in element) {
378
+ buffer.uvs.push(element.s, element.t);
379
+ }
380
+ break;
381
+ case 't':
382
+ break;
383
+ case 'red':
384
+ if ('red' in element && 'green' in element && 'blue' in element) {
385
+ buffer.colors.push(element.red, element.green, element.blue);
386
+ }
387
+ break;
388
+ case 'green':
389
+ case 'blue':
390
+ break;
391
+ default:
392
+ buffer[propertyName].push(element[propertyName]);
393
+ }
394
+ }
395
+ }
396
+ else if (elementName === 'face') {
397
+ const vertexIndices = element.vertex_indices || element.vertex_index; // issue #9338
398
+ if (vertexIndices.length === 3) {
399
+ buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[2]);
400
+ }
401
+ else if (vertexIndices.length === 4) {
402
+ buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[3]);
403
+ buffer.indices.push(vertexIndices[1], vertexIndices[2], vertexIndices[3]);
404
+ }
405
+ }
406
+ }
407
+ /**
408
+ * Reads binary data
409
+ * @param dataview
410
+ * @param at
411
+ * @param type
412
+ * @param littleEndian
413
+ * @returns [number, number]
414
+ */
415
+ // eslint-disable-next-line complexity
416
+ function binaryRead(dataview, at, type, littleEndian) {
417
+ switch (type) {
418
+ // corespondences for non-specific length types here match rply:
419
+ case 'int8':
420
+ case 'char':
421
+ return [dataview.getInt8(at), 1];
422
+ case 'uint8':
423
+ case 'uchar':
424
+ return [dataview.getUint8(at), 1];
425
+ case 'int16':
426
+ case 'short':
427
+ return [dataview.getInt16(at, littleEndian), 2];
428
+ case 'uint16':
429
+ case 'ushort':
430
+ return [dataview.getUint16(at, littleEndian), 2];
431
+ case 'int32':
432
+ case 'int':
433
+ return [dataview.getInt32(at, littleEndian), 4];
434
+ case 'uint32':
435
+ case 'uint':
436
+ return [dataview.getUint32(at, littleEndian), 4];
437
+ case 'float32':
438
+ case 'float':
439
+ return [dataview.getFloat32(at, littleEndian), 4];
440
+ case 'float64':
441
+ case 'double':
442
+ return [dataview.getFloat64(at, littleEndian), 8];
443
+ default:
444
+ throw new Error(type);
445
+ }
446
+ }
447
+ /**
448
+ * Reads binary data
449
+ * @param dataview
450
+ * @param at
451
+ * @param properties
452
+ * @param littleEndian
453
+ * @returns [object, number]
454
+ */
455
+ function binaryReadElement(dataview, at, properties, littleEndian) {
456
+ const element = {};
457
+ let result;
458
+ let read = 0;
459
+ for (let i = 0; i < properties.length; i++) {
460
+ if (properties[i].type === 'list') {
461
+ const list = [];
462
+ result = binaryRead(dataview, at + read, properties[i].countType, littleEndian);
463
+ const n = result[0];
464
+ read += result[1];
465
+ for (let j = 0; j < n; j++) {
466
+ result = binaryRead(dataview, at + read, properties[i].itemType, littleEndian);
467
+ // @ts-ignore
468
+ list.push(result[0]);
469
+ read += result[1];
470
+ }
471
+ element[properties[i].name] = list;
472
+ }
473
+ else {
474
+ result = binaryRead(dataview, at + read, properties[i].type, littleEndian);
475
+ element[properties[i].name] = result[0];
476
+ read += result[1];
477
+ }
478
+ }
479
+ return [element, read];
480
+ }
481
+ /** Build an Arrow table from normalized PLY attribute arrays. */
482
+ function makePLYArrowTable(header, attributes) {
483
+ const meshAttributes = getPLYMeshAttributes(attributes);
484
+ const schema = getPLYSchema(header, meshAttributes);
485
+ schema.metadata.topology = 'point-list';
486
+ schema.metadata.mode = '0';
487
+ const columns = {};
488
+ const fields = [];
489
+ for (const field of schema.fields) {
490
+ const attribute = meshAttributes[field.name];
491
+ if (!attribute) {
492
+ continue;
493
+ }
494
+ const column = getPLYArrowVector(attribute);
495
+ columns[field.name] = column;
496
+ fields.push(new arrow.Field(field.name, column.type, false, getArrowMetadata(field.metadata)));
497
+ }
498
+ const arrowSchema = new arrow.Schema(fields, getArrowMetadata(schema.metadata));
499
+ return {
500
+ shape: 'arrow-table',
501
+ schema,
502
+ data: new arrow.Table(arrowSchema, columns),
503
+ topology: 'point-list'
504
+ };
505
+ }
506
+ /** Convert normalized PLY attributes into mesh-style attribute descriptors. */
507
+ function getPLYMeshAttributes(attributes) {
508
+ const meshAttributes = {};
509
+ for (const attributeName of Object.keys(attributes)) {
510
+ switch (attributeName) {
511
+ case 'vertices':
512
+ if (attributes.vertices.length > 0) {
513
+ meshAttributes.POSITION = { value: getFloat32Array(attributes.vertices), size: 3 };
514
+ }
515
+ break;
516
+ case 'normals':
517
+ if (attributes.normals.length > 0) {
518
+ meshAttributes.NORMAL = { value: getFloat32Array(attributes.normals), size: 3 };
519
+ }
520
+ break;
521
+ case 'uvs':
522
+ if (attributes.uvs.length > 0) {
523
+ meshAttributes.TEXCOORD_0 = { value: getFloat32Array(attributes.uvs), size: 2 };
524
+ }
525
+ break;
526
+ case 'colors':
527
+ if (attributes.colors.length > 0) {
528
+ meshAttributes.COLOR_0 = {
529
+ value: getUint8Array(attributes.colors),
530
+ size: 3,
531
+ normalized: true
532
+ };
533
+ }
534
+ break;
535
+ case 'indices':
536
+ break;
537
+ default:
538
+ if (attributes[attributeName].length > 0) {
539
+ meshAttributes[attributeName] = {
540
+ value: getFloat32Array(attributes[attributeName]),
541
+ size: 1
542
+ };
543
+ }
544
+ break;
545
+ }
546
+ }
547
+ return meshAttributes;
548
+ }
549
+ /** Return an Arrow vector for one PLY mesh attribute. */
550
+ function getPLYArrowVector(attribute) {
551
+ const { value, size } = attribute;
552
+ if (size === 1) {
553
+ return arrow.makeVector(value);
554
+ }
555
+ const values = arrow.makeVector(value);
556
+ const child = values.data[0];
557
+ const type = new arrow.FixedSizeList(size, new arrow.Field('value', child.type, false));
558
+ const data = new arrow.Data(type, 0, value.length / size, 0, {}, [child]);
559
+ return new arrow.Vector([data]);
560
+ }
561
+ /** Convert loaders.gl metadata objects to Arrow metadata maps. */
562
+ function getArrowMetadata(metadata) {
563
+ return new Map(Object.entries(metadata || {}));
564
+ }
565
+ /** Return a Float32Array without copying when possible. */
566
+ function getFloat32Array(attribute) {
567
+ return attribute instanceof Float32Array ? attribute : new Float32Array(attribute);
568
+ }
569
+ /** Return a Uint8Array without copying when possible. */
570
+ function getUint8Array(attribute) {
571
+ return attribute instanceof Uint8Array ? attribute : new Uint8Array(attribute);
572
+ }
573
+ /**
574
+ * Parses binary data
575
+ * @param data
576
+ * @param header
577
+ * @returns [attributes] of data
578
+ */
579
+ function parseBinary(data, header, options) {
580
+ const directAttributes = parseBinaryPointCloud(data, header, options);
581
+ if (directAttributes) {
582
+ return directAttributes;
583
+ }
584
+ const attributes = getPLYAttributes(header);
585
+ const littleEndian = header.format === 'binary_little_endian';
586
+ const body = new DataView(data, header.headerLength);
587
+ let result;
588
+ let loc = 0;
589
+ for (let currentElement = 0; currentElement < header.elements.length; currentElement++) {
590
+ const count = header.elements[currentElement].count;
591
+ for (let currentElementCount = 0; currentElementCount < count; currentElementCount++) {
592
+ result = binaryReadElement(body, loc, header.elements[currentElement].properties, littleEndian);
593
+ loc += result[1];
594
+ const element = result[0];
595
+ handleElement(attributes, header.elements[currentElement].name, element);
596
+ }
597
+ }
598
+ return attributes;
599
+ }
600
+ /** Parse binary PLY point clouds directly into typed arrays. */
601
+ function parseBinaryPointCloud(data, header, options) {
602
+ const records = new Uint8Array(data, header.headerLength || 0);
603
+ return parseBinaryPointCloudRecords(records, header, options);
604
+ }
605
+ /** Parse binary PLY point-cloud records directly from a byte view into typed arrays. */
606
+ function parseBinaryPointCloudRecords(records, header, options, parsePlan) {
607
+ const vertexElement = header.elements[0];
608
+ if (!parsePlan &&
609
+ (options?._useLegacyBinaryPointCloudParser ||
610
+ (!options?.pointCloud && header.elements.length !== 1) ||
611
+ vertexElement?.name !== 'vertex' ||
612
+ vertexElement.properties.some(property => property.type === 'list'))) {
613
+ return null;
614
+ }
615
+ const plan = parsePlan || getPLYBinaryPointCloudParsePlan(header, options);
616
+ if (!plan || !vertexElement) {
617
+ return null;
618
+ }
619
+ const attributes = getBinaryPointCloudAttributes(vertexElement);
620
+ const dataView = new DataView(records.buffer, records.byteOffset, records.byteLength);
621
+ let vertexOffset = 0;
622
+ for (let vertexIndex = 0; vertexIndex < vertexElement.count; vertexIndex++) {
623
+ for (const property of plan.properties) {
624
+ const value = property.read(dataView, vertexOffset + property.offset, plan.littleEndian);
625
+ writeBinaryPointCloudProperty(attributes, property.name, value, vertexIndex);
626
+ }
627
+ vertexOffset += plan.vertexStride;
628
+ }
629
+ return attributes;
630
+ }
631
+ /** Return a reusable binary point-cloud parse plan, or null when unsupported. */
632
+ export function getPLYBinaryPointCloudParsePlan(header, options) {
633
+ const vertexElement = header.elements[0];
634
+ if (options?._useLegacyBinaryPointCloudParser ||
635
+ (!options?.pointCloud && header.elements.length !== 1) ||
636
+ vertexElement?.name !== 'vertex' ||
637
+ vertexElement.properties.some(property => property.type === 'list')) {
638
+ return null;
639
+ }
640
+ const properties = getBinaryPointCloudProperties(vertexElement);
641
+ return {
642
+ properties,
643
+ vertexStride: getPLYElementSize(properties),
644
+ littleEndian: header.format === 'binary_little_endian'
645
+ };
646
+ }
647
+ /** Allocate direct typed arrays for the normalized PLY attributes. */
648
+ function getBinaryPointCloudAttributes(vertexElement) {
649
+ const attributes = {
650
+ indices: [],
651
+ vertices: [],
652
+ normals: [],
653
+ uvs: [],
654
+ colors: []
655
+ };
656
+ const propertyNames = new Set(vertexElement.properties.map(property => property.name));
657
+ const vertexCount = vertexElement.count;
658
+ if (propertyNames.has('x') && propertyNames.has('y') && propertyNames.has('z')) {
659
+ attributes.vertices = new Float32Array(vertexCount * 3);
660
+ }
661
+ if (propertyNames.has('nx') && propertyNames.has('ny') && propertyNames.has('nz')) {
662
+ attributes.normals = new Float32Array(vertexCount * 3);
663
+ }
664
+ if (propertyNames.has('s') && propertyNames.has('t')) {
665
+ attributes.uvs = new Float32Array(vertexCount * 2);
666
+ }
667
+ if (propertyNames.has('red') && propertyNames.has('green') && propertyNames.has('blue')) {
668
+ attributes.colors = new Uint8Array(vertexCount * 3);
669
+ }
670
+ for (const property of vertexElement.properties) {
671
+ if (!isNormalizedPLYAttributeProperty(property.name)) {
672
+ attributes[property.name] = new Float32Array(vertexCount);
673
+ }
674
+ }
675
+ return attributes;
676
+ }
677
+ /** Return true if a PLY property is packed into a normalized mesh attribute. */
678
+ function isNormalizedPLYAttributeProperty(propertyName) {
679
+ switch (propertyName) {
680
+ case 'x':
681
+ case 'y':
682
+ case 'z':
683
+ case 'nx':
684
+ case 'ny':
685
+ case 'nz':
686
+ case 's':
687
+ case 't':
688
+ case 'red':
689
+ case 'green':
690
+ case 'blue':
691
+ return true;
692
+ default:
693
+ return false;
694
+ }
695
+ }
696
+ /** Write a scalar PLY property into its normalized typed array. */
697
+ function writeBinaryPointCloudProperty(attributes, propertyName, value, vertexIndex) {
698
+ switch (propertyName) {
699
+ case 'x':
700
+ attributes.vertices[vertexIndex * 3] = value;
701
+ break;
702
+ case 'y':
703
+ attributes.vertices[vertexIndex * 3 + 1] = value;
704
+ break;
705
+ case 'z':
706
+ attributes.vertices[vertexIndex * 3 + 2] = value;
707
+ break;
708
+ case 'nx':
709
+ attributes.normals[vertexIndex * 3] = value;
710
+ break;
711
+ case 'ny':
712
+ attributes.normals[vertexIndex * 3 + 1] = value;
713
+ break;
714
+ case 'nz':
715
+ attributes.normals[vertexIndex * 3 + 2] = value;
716
+ break;
717
+ case 's':
718
+ attributes.uvs[vertexIndex * 2] = value;
719
+ break;
720
+ case 't':
721
+ attributes.uvs[vertexIndex * 2 + 1] = value;
722
+ break;
723
+ case 'red':
724
+ attributes.colors[vertexIndex * 3] = value;
725
+ break;
726
+ case 'green':
727
+ attributes.colors[vertexIndex * 3 + 1] = value;
728
+ break;
729
+ case 'blue':
730
+ attributes.colors[vertexIndex * 3 + 2] = value;
731
+ break;
732
+ default:
733
+ attributes[propertyName][vertexIndex] = value;
734
+ }
735
+ }
736
+ /** Return binary property descriptors with precomputed offsets and readers. */
737
+ function getBinaryPointCloudProperties(element) {
738
+ const properties = [];
739
+ let offset = 0;
740
+ for (const property of element.properties) {
741
+ properties.push({
742
+ name: property.name,
743
+ offset,
744
+ read: getBinaryScalarReader(property.type),
745
+ size: getPLYTypeSize(property.type)
746
+ });
747
+ offset += properties[properties.length - 1].size;
748
+ }
749
+ return properties;
750
+ }
751
+ /** Return the byte size of a scalar PLY element. */
752
+ function getPLYElementSize(properties) {
753
+ if (properties.length === 0) {
754
+ return 0;
755
+ }
756
+ const lastProperty = properties[properties.length - 1];
757
+ return lastProperty.offset + lastProperty.size;
758
+ }
759
+ /** Return the byte size of a scalar PLY type. */
760
+ // eslint-disable-next-line complexity
761
+ function getPLYTypeSize(type) {
762
+ switch (type) {
763
+ case 'int8':
764
+ case 'uint8':
765
+ case 'char':
766
+ case 'uchar':
767
+ return 1;
768
+ case 'int16':
769
+ case 'uint16':
770
+ case 'short':
771
+ case 'ushort':
772
+ return 2;
773
+ case 'int32':
774
+ case 'uint32':
775
+ case 'int':
776
+ case 'uint':
777
+ case 'float32':
778
+ case 'float':
779
+ return 4;
780
+ case 'float64':
781
+ case 'double':
782
+ return 8;
783
+ default:
784
+ throw new Error(type);
785
+ }
786
+ }
787
+ /** Return one scalar PLY value reader. */
788
+ // eslint-disable-next-line complexity
789
+ function getBinaryScalarReader(type) {
790
+ switch (type) {
791
+ case 'int8':
792
+ case 'char':
793
+ return readInt8;
794
+ case 'uint8':
795
+ case 'uchar':
796
+ return readUint8;
797
+ case 'int16':
798
+ case 'short':
799
+ return readInt16;
800
+ case 'uint16':
801
+ case 'ushort':
802
+ return readUint16;
803
+ case 'int32':
804
+ case 'int':
805
+ return readInt32;
806
+ case 'uint32':
807
+ case 'uint':
808
+ return readUint32;
809
+ case 'float32':
810
+ case 'float':
811
+ return readFloat32;
812
+ case 'float64':
813
+ case 'double':
814
+ return readFloat64;
815
+ default:
816
+ throw new Error(type);
817
+ }
818
+ }
819
+ /** Read one signed 8-bit integer. */
820
+ function readInt8(dataView, at) {
821
+ return dataView.getInt8(at);
822
+ }
823
+ /** Read one unsigned 8-bit integer. */
824
+ function readUint8(dataView, at) {
825
+ return dataView.getUint8(at);
826
+ }
827
+ /** Read one signed 16-bit integer. */
828
+ function readInt16(dataView, at, littleEndian) {
829
+ return dataView.getInt16(at, littleEndian);
830
+ }
831
+ /** Read one unsigned 16-bit integer. */
832
+ function readUint16(dataView, at, littleEndian) {
833
+ return dataView.getUint16(at, littleEndian);
834
+ }
835
+ /** Read one signed 32-bit integer. */
836
+ function readInt32(dataView, at, littleEndian) {
837
+ return dataView.getInt32(at, littleEndian);
838
+ }
839
+ /** Read one unsigned 32-bit integer. */
840
+ function readUint32(dataView, at, littleEndian) {
841
+ return dataView.getUint32(at, littleEndian);
842
+ }
843
+ /** Read one 32-bit float. */
844
+ function readFloat32(dataView, at, littleEndian) {
845
+ return dataView.getFloat32(at, littleEndian);
846
+ }
847
+ /** Read one 64-bit float. */
848
+ function readFloat64(dataView, at, littleEndian) {
849
+ return dataView.getFloat64(at, littleEndian);
850
+ }
851
+ //# sourceMappingURL=parse-ply.js.map