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

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 +31514 -0
  8. package/dist/dist.min.js +54 -0
  9. package/dist/index.cjs +55 -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 +69 -0
  16. package/dist/las/bundled.cjs.map +7 -0
  17. package/dist/las/bundled.d.ts +11 -0
  18. package/dist/las/bundled.d.ts.map +1 -0
  19. package/dist/las/bundled.js +11 -0
  20. package/dist/las/bundled.js.map +1 -0
  21. package/dist/las/index.cjs +75 -0
  22. package/dist/las/index.cjs.map +7 -0
  23. package/dist/las/index.d.ts +15 -0
  24. package/dist/las/index.d.ts.map +1 -0
  25. package/dist/las/index.js +12 -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 +67 -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 +60 -0
  34. package/dist/las/las-copc-loader.cjs.map +7 -0
  35. package/dist/las/las-copc-loader.d.ts +39 -0
  36. package/dist/las/las-copc-loader.d.ts.map +1 -0
  37. package/dist/las/las-copc-loader.js +45 -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 +84 -0
  46. package/dist/las/las-loader-shared.cjs.map +7 -0
  47. package/dist/las/las-loader-shared.d.ts +68 -0
  48. package/dist/las/las-loader-shared.d.ts.map +1 -0
  49. package/dist/las/las-loader-shared.js +60 -0
  50. package/dist/las/las-loader-shared.js.map +1 -0
  51. package/dist/las/las-loader-types.cjs +51 -0
  52. package/dist/las/las-loader-types.cjs.map +7 -0
  53. package/dist/las/las-loader-types.d.ts +77 -0
  54. package/dist/las/las-loader-types.d.ts.map +1 -0
  55. package/dist/las/las-loader-types.js +17 -0
  56. package/dist/las/las-loader-types.js.map +1 -0
  57. package/dist/las/las-loader.cjs +128 -0
  58. package/dist/las/las-loader.cjs.map +7 -0
  59. package/dist/las/las-loader.d.ts +91 -0
  60. package/dist/las/las-loader.d.ts.map +1 -0
  61. package/dist/las/las-loader.js +108 -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 +70 -0
  66. package/dist/las/las-writer.d.ts.map +1 -0
  67. package/dist/las/las-writer.js +992 -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 +69 -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 +275 -0
  76. package/dist/las/laz-rs-loader.cjs.map +7 -0
  77. package/dist/las/laz-rs-loader.d.ts +39 -0
  78. package/dist/las/laz-rs-loader.d.ts.map +1 -0
  79. package/dist/las/laz-rs-loader.js +43 -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 +71 -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 +63 -0
  88. package/dist/las/lazperf-loader.cjs.map +7 -0
  89. package/dist/las/lazperf-loader.d.ts +41 -0
  90. package/dist/las/lazperf-loader.d.ts.map +1 -0
  91. package/dist/las/lazperf-loader.js +49 -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 +67 -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 +52 -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 +228 -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 +197 -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 +271 -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 +308 -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 +271 -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 +308 -0
  152. package/dist/las/lib/laz-rs-wasm/parse-las.js.map +1 -0
  153. package/dist/las/lib/typescript/parse-las.cjs +2889 -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 +2703 -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 +69 -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 +62 -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 +53 -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 +130 -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 +24024 -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 +277 -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 +65 -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 +31 -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 +37 -0
  245. package/dist/pcd/index.cjs.map +7 -0
  246. package/dist/pcd/index.d.ts +6 -0
  247. package/dist/pcd/index.d.ts.map +1 -0
  248. package/dist/pcd/index.js +7 -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 +63 -0
  281. package/dist/pcd/pcd-loader-types.cjs.map +7 -0
  282. package/dist/pcd/pcd-loader-types.d.ts +82 -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 +201 -0
  287. package/dist/pcd/pcd-loader.cjs.map +7 -0
  288. package/dist/pcd/pcd-loader.d.ts +80 -0
  289. package/dist/pcd/pcd-loader.d.ts.map +1 -0
  290. package/dist/pcd/pcd-loader.js +179 -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 +38 -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 +31 -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 +65 -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 +203 -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 +18561 -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 +31 -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 +37 -0
  336. package/dist/ply/index.cjs.map +7 -0
  337. package/dist/ply/index.d.ts +6 -0
  338. package/dist/ply/index.d.ts.map +1 -0
  339. package/dist/ply/index.js +8 -0
  340. package/dist/ply/index.js.map +1 -0
  341. package/dist/ply/lib/get-ply-schema.cjs +128 -0
  342. package/dist/ply/lib/get-ply-schema.cjs.map +7 -0
  343. package/dist/ply/lib/get-ply-schema.d.ts +16 -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 +613 -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 +630 -0
  364. package/dist/ply/lib/parse-ply-in-batches.js.map +1 -0
  365. package/dist/ply/lib/parse-ply.cjs +758 -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 +855 -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 +64 -0
  384. package/dist/ply/ply-loader-types.cjs.map +7 -0
  385. package/dist/ply/ply-loader-types.d.ts +88 -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 +192 -0
  390. package/dist/ply/ply-loader.cjs.map +7 -0
  391. package/dist/ply/ply-loader.d.ts +81 -0
  392. package/dist/ply/ply-loader.d.ts.map +1 -0
  393. package/dist/ply/ply-loader.js +173 -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 +38 -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 +31 -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 +66 -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 +194 -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 +20962 -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 +238 -4
  433. package/src/index.ts +19 -0
  434. package/src/las/bundled.ts +38 -0
  435. package/src/las/index.ts +66 -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 +126 -0
  440. package/src/las/las-loader-types.ts +24 -0
  441. package/src/las/las-loader.ts +163 -0
  442. package/src/las/las-writer.ts +1477 -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 +55 -0
  451. package/src/las/lib/las-compatibility.ts +178 -0
  452. package/src/las/lib/las-extra-bytes.ts +276 -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 +411 -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 +411 -0
  459. package/src/las/lib/typescript/parse-las.ts +3862 -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 +6 -0
  479. package/src/pcd/index.ts +9 -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 +52 -0
  486. package/src/pcd/pcd-loader.ts +247 -0
  487. package/src/pcd/pcd-writer.ts +156 -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 +6 -0
  494. package/src/ply/index.ts +11 -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 +832 -0
  499. package/src/ply/lib/parse-ply.ts +1084 -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 +60 -0
  503. package/src/ply/ply-loader.ts +255 -0
  504. package/src/ply/ply-writer.ts +219 -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,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,60 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ // PLY Loader
6
+ import type {Table, RecordBatch} from 'apache-arrow';
7
+ import type {Loader, LoaderOptions} from '@loaders.gl/core/loader-utils';
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/arrow-worker-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';
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-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
+ defaultShape: 'arrow',
45
+ supportsNativeArrow: true,
46
+ dataType: null as unknown as PLYMesh | Table,
47
+ batchType: null as unknown as PLYMesh | RecordBatch,
48
+
49
+ ...PLYFormat,
50
+ // shapes: ['mesh', 'gltf', 'columnar-table'],
51
+ version: VERSION,
52
+ worker: true,
53
+ /** Enables the stateful input/output batch protocol on the built-in worker. */
54
+ workerInBatches: true,
55
+ serializeWorkerResult: serializeArrowWorkerTable,
56
+ options: {
57
+ ply: {shape: 'arrow', colorFormat: 'uint8norm'}
58
+ },
59
+ preload
60
+ } as const satisfies Loader<PLYMesh | Table, PLYMesh | RecordBatch, LoaderOptions>;
@@ -0,0 +1,255 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {refineArrowTableBatches, makeArrowMetadataBatch} from '@loaders.gl/core/schema-utils';
6
+ import type {Table, RecordBatch} from 'apache-arrow';
7
+ import type {PLYLoaderOptions} from './ply-loader-types';
8
+
9
+ // PLY Loader
10
+ import {makeTableScanBatch, type LoaderWithParser} from '@loaders.gl/core/loader-utils';
11
+ import {convertColorArrayToFloat16, convertColorArrayToFloat32} from '@loaders.gl/core/schema';
12
+ import type {MeshArrowTable, ArrowTableBatch} from '@loaders.gl/core/schema';
13
+ import {
14
+ deserializeArrowWorkerTable,
15
+ serializeArrowWorkerTable
16
+ } from '@loaders.gl/core/arrow-worker-transport';
17
+ import type {PLYHeader, PLYMesh} from './lib/ply-types';
18
+ import {
19
+ convertMeshToArrowTableWrapper,
20
+ convertTableToMesh,
21
+ deduceMeshSchema
22
+ } from '@loaders.gl/core/schema-utils';
23
+ import {parsePLY, parsePLYHeader, parsePLYToArrowTable} from './lib/parse-ply';
24
+ import {
25
+ convertPLYElementTablesToMeshArrowTable,
26
+ parsePLYToElementTables
27
+ } from './lib/parse-ply-arrow';
28
+ import {parsePLYInBatches} from './lib/parse-ply-in-batches';
29
+ import {PLYLoader as PLYLoaderMetadata} from './ply-loader-types';
30
+
31
+ const {preload: _PLYLoaderPreload, ...PLYLoaderMetadataWithoutPreload} = PLYLoaderMetadata;
32
+
33
+ function convertPLYMesh(mesh: PLYMesh, options?: PLYLoaderOptions): PLYMesh | MeshArrowTable {
34
+ const table = convertMeshToArrowTableWrapper(mesh);
35
+ return convertPLYTable(table, options, mesh.loaderData);
36
+ }
37
+
38
+ /** Parse PLY data using a direct Arrow path when requested and supported. */
39
+ function parsePLYData(
40
+ data: ArrayBuffer | string,
41
+ options?: PLYLoaderOptions
42
+ ): PLYMesh | MeshArrowTable {
43
+ if (options?.ply?._useLegacyParser) {
44
+ return convertPLYMesh(parsePLY(data, options?.ply), options);
45
+ }
46
+
47
+ const arrowTable = parsePLYToArrowTable(data, options?.ply);
48
+ if (arrowTable) {
49
+ return convertPLYTable(arrowTable, options, parsePLYHeader(data, options?.ply));
50
+ }
51
+
52
+ const elementTables = parsePLYToElementTables(data, options?.ply);
53
+ return convertPLYTable(
54
+ convertPLYElementTablesToMeshArrowTable(elementTables),
55
+ options,
56
+ elementTables.header
57
+ );
58
+ }
59
+
60
+ /**
61
+ * Loader for PLY - Polygon File Format
62
+ */
63
+ export const PLYColumnLoader = {
64
+ ...PLYLoaderMetadataWithoutPreload,
65
+ dataType: null as unknown as PLYMesh | MeshArrowTable,
66
+ batchType: null as unknown as PLYMesh | ArrowTableBatch,
67
+ parse: async (arrayBuffer, options) => parsePLYData(arrayBuffer, options),
68
+ parseTextSync: (arrayBuffer, options) => parsePLYData(arrayBuffer, options),
69
+ parseSync: (arrayBuffer, options) => parsePLYData(arrayBuffer, options),
70
+ parseInBatches: (input, options) =>
71
+ refineArrowTableBatches(parsePLYWithMetadataInBatches(input, options)),
72
+ serializeWorkerResult: serializeArrowWorkerTable,
73
+ deserializeWorkerResult: deserializePLYWorkerResult,
74
+ serializeWorkerBatch: serializeArrowWorkerTable,
75
+ deserializeWorkerBatch: deserializePLYWorkerBatch
76
+ } as const satisfies LoaderWithParser<
77
+ PLYMesh | MeshArrowTable,
78
+ PLYMesh | ArrowTableBatch,
79
+ PLYLoaderOptions
80
+ >;
81
+
82
+ /** Return requested public PLY shape from the parser's Arrow table. */
83
+ function convertPLYTable(
84
+ table: MeshArrowTable & {
85
+ /** Original source header retained by the streaming parser. */
86
+ loaderData?: PLYHeader;
87
+ },
88
+ options?: PLYLoaderOptions,
89
+ header?: PLYHeader
90
+ ): PLYMesh | MeshArrowTable {
91
+ const loaderData = header || table.loaderData || {comments: [], elements: []};
92
+ const result =
93
+ options?.ply?.shape === 'arrow'
94
+ ? {...table, loader: 'ply' as const, loaderData}
95
+ : {
96
+ ...(convertTableToMesh(table) as PLYMesh),
97
+ loader: 'ply',
98
+ loaderData
99
+ };
100
+ const colorFormat = options?.ply?.colorFormat || 'uint8norm';
101
+ if (colorFormat === 'uint8norm') {
102
+ return result as PLYMesh | MeshArrowTable;
103
+ }
104
+
105
+ const resultData = result as PLYMesh | MeshArrowTable;
106
+ const formattedMesh = formatPLYMeshColors(
107
+ (isMeshArrowTable(resultData) ? convertTableToMesh(resultData) : resultData) as PLYMesh,
108
+ colorFormat
109
+ );
110
+ return options?.ply?.shape === 'arrow'
111
+ ? {
112
+ ...convertMeshToArrowTableWrapper(formattedMesh),
113
+ loader: 'ply' as const,
114
+ loaderData
115
+ }
116
+ : (formattedMesh as PLYMesh);
117
+ }
118
+
119
+ /** Apply the requested normalized color representation to a decoded PLY mesh. */
120
+ function formatPLYMeshColors(
121
+ mesh: PLYMesh,
122
+ colorFormat: 'uint8norm' | 'float16' | 'float32'
123
+ ): PLYMesh {
124
+ const colorAttribute = mesh.attributes.COLOR_0;
125
+ if (!colorAttribute) {
126
+ return mesh;
127
+ }
128
+
129
+ const sourceScale = colorAttribute.value instanceof Uint16Array ? 65535 : 255;
130
+ const value =
131
+ colorFormat === 'float16'
132
+ ? convertColorArrayToFloat16(colorAttribute.value, sourceScale)
133
+ : convertColorArrayToFloat32(colorAttribute.value, sourceScale);
134
+ const attributes = {...mesh.attributes};
135
+ for (const [attributeName, attribute] of Object.entries(attributes)) {
136
+ if (attribute.value === colorAttribute.value) {
137
+ attributes[attributeName] = {
138
+ ...attribute,
139
+ value,
140
+ normalized: false,
141
+ ...(colorFormat === 'float16' ? {componentType: 'float16' as const} : {})
142
+ };
143
+ }
144
+ }
145
+ return {
146
+ ...mesh,
147
+ attributes,
148
+ schema: deduceMeshSchema(attributes, mesh.schema.metadata)
149
+ };
150
+ }
151
+
152
+ /** Return true if a parsed PLY batch is already a Mesh Arrow table. */
153
+ function isMeshArrowTable(data: PLYMesh | MeshArrowTable): data is MeshArrowTable {
154
+ return 'shape' in data && data.shape === 'arrow-table';
155
+ }
156
+
157
+ /** Hydrates worker columns and applies the requested PLY shape on the caller. */
158
+ function deserializePLYWorkerResult(
159
+ result: unknown,
160
+ options?: PLYLoaderOptions
161
+ ): PLYMesh | MeshArrowTable {
162
+ const table = deserializeArrowWorkerTable(result);
163
+ return options?.ply?.shape === 'mesh'
164
+ ? {...convertTableToMesh(table), loader: 'ply', loaderData: table.loaderData}
165
+ : table;
166
+ }
167
+
168
+ /** Converts mesh batches only after the Arrow column buffers reach the caller. */
169
+ function deserializePLYWorkerBatch(
170
+ result: unknown,
171
+ options?: PLYLoaderOptions
172
+ ): PLYMesh | ArrowTableBatch {
173
+ return deserializePLYWorkerResult(result, options) as PLYMesh | ArrowTableBatch;
174
+ }
175
+
176
+ /** Parses PLY batches before shared cumulative metadata refinement. */
177
+ async function* parsePLYWithMetadataInBatches(
178
+ arrayBuffer:
179
+ | AsyncIterable<ArrayBufferLike | ArrayBufferView>
180
+ | Iterable<ArrayBufferLike | ArrayBufferView>,
181
+ options?: PLYLoaderOptions
182
+ ) {
183
+ const plyOptions = {
184
+ ...options?.ply,
185
+ batchSize: options?.core?.batchSize
186
+ };
187
+ for await (const meshOrTable of parsePLYInBatches(arrayBuffer, plyOptions)) {
188
+ const convertedData = isMeshArrowTable(meshOrTable)
189
+ ? convertPLYTable(meshOrTable, options)
190
+ : convertPLYMesh(meshOrTable, options);
191
+ yield isMeshArrowTable(convertedData) ? makeTableScanBatch(convertedData) : convertedData;
192
+ }
193
+ }
194
+
195
+ /** Exposes native Arrow output while retaining the worker's column protocol. */
196
+ export const PLYLoaderWithParser = {
197
+ ...PLYColumnLoader,
198
+ dataType: PLYLoaderMetadata.dataType,
199
+ batchType: PLYLoaderMetadata.batchType,
200
+ parse: async (input: ArrayBuffer, options?: PLYLoaderOptions) =>
201
+ unwrapPLYTable(await PLYColumnLoader.parse(input, options)),
202
+ parseTextSync: (input: string, options?: PLYLoaderOptions) =>
203
+ unwrapPLYTable(PLYColumnLoader.parseTextSync(input, options)),
204
+ parseSync: (input: ArrayBuffer, options?: PLYLoaderOptions) =>
205
+ unwrapPLYTable(PLYColumnLoader.parseSync(input, options)),
206
+ async *parseInBatches(input, options) {
207
+ for await (const batch of PLYColumnLoader.parseInBatches(input, options)) {
208
+ if (isColumnBatch(batch)) {
209
+ batch.data.schema.metadata.set(
210
+ 'loaders.gl.ply.header',
211
+ JSON.stringify((batch as ArrowTableBatch & {loaderData?: unknown}).loaderData)
212
+ );
213
+ for (const recordBatch of batch.data.batches) {
214
+ recordBatch.schema.metadata.set(
215
+ 'loaders.gl.ply.header',
216
+ batch.data.schema.metadata.get('loaders.gl.ply.header')!
217
+ );
218
+ }
219
+ if (batch.data.batches.length) yield* batch.data.batches;
220
+ else yield makeArrowMetadataBatch(batch.data.schema);
221
+ } else yield batch;
222
+ }
223
+ },
224
+ deserializeWorkerResult: (result: unknown, options?: PLYLoaderOptions) =>
225
+ unwrapPLYTable(PLYColumnLoader.deserializeWorkerResult(result, options)),
226
+ deserializeWorkerBatch(result: unknown, options?: PLYLoaderOptions) {
227
+ const batch = PLYColumnLoader.deserializeWorkerBatch(result, options);
228
+ if (isColumnBatch(batch)) {
229
+ const recordBatch = batch.data.batches[0] ?? makeArrowMetadataBatch(batch.data.schema);
230
+ recordBatch.schema.metadata.set(
231
+ 'loaders.gl.ply.header',
232
+ JSON.stringify((batch as ArrowTableBatch & {loaderData?: unknown}).loaderData)
233
+ );
234
+ return recordBatch;
235
+ }
236
+ return batch;
237
+ }
238
+ } as const satisfies LoaderWithParser<PLYMesh | Table, PLYMesh | RecordBatch, PLYLoaderOptions>;
239
+
240
+ /** Returns the Arrow table with its file metadata or the requested mesh. */
241
+ function unwrapPLYTable(result: PLYMesh | MeshArrowTable): PLYMesh | Table {
242
+ if ('shape' in result && result.shape === 'arrow-table') {
243
+ result.data.schema.metadata.set(
244
+ 'loaders.gl.ply.header',
245
+ JSON.stringify((result as MeshArrowTable & {loaderData?: unknown}).loaderData)
246
+ );
247
+ return result.data;
248
+ }
249
+ return result as PLYMesh;
250
+ }
251
+
252
+ /** Identifies the private Arrow batch envelope. */
253
+ function isColumnBatch(batch: PLYMesh | ArrowTableBatch): batch is ArrowTableBatch {
254
+ return 'shape' in batch && batch.shape === 'arrow-table';
255
+ }
@@ -0,0 +1,219 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {Table} from 'apache-arrow';
6
+ import type {WriterOptions, WriterWithEncoder} from '@loaders.gl/core/loader-utils';
7
+ import type {Mesh, MeshArrowTable, MeshAttribute} from '@loaders.gl/core/schema';
8
+ import {convertMeshToArrowTableWrapper, convertTableToMesh} from '@loaders.gl/core/schema-utils';
9
+ import {PLYFormat} from './ply-format';
10
+
11
+ // __VERSION__ is injected by babel-plugin-version-inline
12
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
13
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
14
+
15
+ /** Options for `PLYWriter`. */
16
+ export type PLYWriterOptions = WriterOptions & {
17
+ /** Reserved for future PLY writer options. */
18
+ ply?: Record<string, never>;
19
+ };
20
+
21
+ /**
22
+ * Writer for the PLY geometry format.
23
+ */
24
+ export const PLYWriter = {
25
+ ...PLYFormat,
26
+ dataType: null as unknown as Mesh | MeshArrowTable | Table,
27
+ batchType: null as never,
28
+ version: VERSION,
29
+ options: {
30
+ ply: {}
31
+ },
32
+ text: true,
33
+ encode: async (data, options) => encodePLYSync(data, options),
34
+ encodeSync: encodePLYSync,
35
+ encodeTextSync: encodePLY
36
+ } as const satisfies WriterWithEncoder<Mesh | MeshArrowTable | Table, never, PLYWriterOptions>;
37
+
38
+ /** Encode mesh category data as PLY bytes. */
39
+ function encodePLYSync(
40
+ data: Mesh | MeshArrowTable | Table,
41
+ options?: PLYWriterOptions
42
+ ): ArrayBuffer {
43
+ const text = encodePLY(data, options);
44
+ return new TextEncoder().encode(text).buffer;
45
+ }
46
+
47
+ /** Encode mesh category data as ASCII PLY text. */
48
+ function encodePLY(data: Mesh | MeshArrowTable | Table, options?: PLYWriterOptions): string {
49
+ const mesh = convertTableToMesh(normalizeMeshArrowTable(data));
50
+ const positionAttribute = getRequiredAttribute(mesh, 'POSITION');
51
+ const normalAttribute = mesh.attributes.NORMAL;
52
+ const textureCoordinateAttribute = mesh.attributes.TEXCOORD_0;
53
+ const colorAttribute = mesh.attributes.COLOR_0;
54
+ const customScalarAttributes = getCustomScalarAttributes(mesh);
55
+ const vertexCount = positionAttribute.value.length / positionAttribute.size;
56
+ const triangleIndices = getTriangleIndices(mesh, vertexCount);
57
+ const header = getPLYHeader(
58
+ vertexCount,
59
+ triangleIndices.length / 3,
60
+ Boolean(normalAttribute),
61
+ Boolean(textureCoordinateAttribute),
62
+ Boolean(colorAttribute),
63
+ customScalarAttributes
64
+ );
65
+ const rows: string[] = [];
66
+
67
+ for (let vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {
68
+ const row = [
69
+ getComponent(positionAttribute, vertexIndex, 0),
70
+ getComponent(positionAttribute, vertexIndex, 1),
71
+ getComponent(positionAttribute, vertexIndex, 2)
72
+ ];
73
+
74
+ if (normalAttribute) {
75
+ row.push(
76
+ getComponent(normalAttribute, vertexIndex, 0),
77
+ getComponent(normalAttribute, vertexIndex, 1),
78
+ getComponent(normalAttribute, vertexIndex, 2)
79
+ );
80
+ }
81
+
82
+ if (textureCoordinateAttribute) {
83
+ row.push(
84
+ getComponent(textureCoordinateAttribute, vertexIndex, 0),
85
+ getComponent(textureCoordinateAttribute, vertexIndex, 1)
86
+ );
87
+ }
88
+
89
+ if (colorAttribute) {
90
+ row.push(
91
+ getColorByte(colorAttribute, vertexIndex, 0),
92
+ getColorByte(colorAttribute, vertexIndex, 1),
93
+ getColorByte(colorAttribute, vertexIndex, 2)
94
+ );
95
+ }
96
+
97
+ for (const [, attribute] of customScalarAttributes) {
98
+ row.push(getComponent(attribute, vertexIndex, 0));
99
+ }
100
+
101
+ rows.push(row.join(' '));
102
+ }
103
+
104
+ for (let triangleIndex = 0; triangleIndex < triangleIndices.length; triangleIndex += 3) {
105
+ rows.push(
106
+ `3 ${triangleIndices[triangleIndex]} ${triangleIndices[triangleIndex + 1]} ${
107
+ triangleIndices[triangleIndex + 2]
108
+ }`
109
+ );
110
+ }
111
+
112
+ return `${header.concat(rows).join('\n')}\n`;
113
+ }
114
+
115
+ /** Return mesh data as a MeshArrowTable, converting plain Mesh data first. */
116
+ function normalizeMeshArrowTable(data: Mesh | MeshArrowTable | Table): MeshArrowTable | Table {
117
+ if (!('attributes' in data)) {
118
+ return data;
119
+ }
120
+ return convertMeshToArrowTableWrapper(data as Mesh);
121
+ }
122
+
123
+ /** Return a required mesh attribute or throw a format-specific error. */
124
+ function getRequiredAttribute(mesh: Mesh, attributeName: string): MeshAttribute {
125
+ const attribute = mesh.attributes[attributeName];
126
+ if (!attribute) {
127
+ throw new Error(`PLYWriter: ${attributeName} attribute is required`);
128
+ }
129
+ return attribute;
130
+ }
131
+
132
+ /** Return the ASCII PLY header lines. */
133
+ function getPLYHeader(
134
+ vertexCount: number,
135
+ faceCount: number,
136
+ hasNormals: boolean,
137
+ hasTextureCoordinates: boolean,
138
+ hasColors: boolean,
139
+ customScalarAttributes: [string, MeshAttribute][]
140
+ ): string[] {
141
+ const header = [
142
+ 'ply',
143
+ 'format ascii 1.0',
144
+ 'comment generated by loaders.gl',
145
+ `element vertex ${vertexCount}`,
146
+ 'property float x',
147
+ 'property float y',
148
+ 'property float z'
149
+ ];
150
+
151
+ if (hasNormals) {
152
+ header.push('property float nx', 'property float ny', 'property float nz');
153
+ }
154
+
155
+ if (hasTextureCoordinates) {
156
+ header.push('property float s', 'property float t');
157
+ }
158
+
159
+ if (hasColors) {
160
+ header.push('property uchar red', 'property uchar green', 'property uchar blue');
161
+ }
162
+
163
+ for (const [attributeName] of customScalarAttributes) {
164
+ header.push(`property float ${attributeName}`);
165
+ }
166
+
167
+ if (faceCount > 0) {
168
+ header.push(`element face ${faceCount}`, 'property list uchar int vertex_indices');
169
+ }
170
+
171
+ header.push('end_header');
172
+ return header;
173
+ }
174
+
175
+ /** Return additional one-component attributes that can be represented as scalar PLY properties. */
176
+ function getCustomScalarAttributes(mesh: Mesh): [string, MeshAttribute][] {
177
+ const reservedAttributeNames = new Set(['POSITION', 'NORMAL', 'TEXCOORD_0', 'COLOR_0']);
178
+ return Object.entries(mesh.attributes).filter(
179
+ ([attributeName, attribute]) =>
180
+ !reservedAttributeNames.has(attributeName) && attribute.size === 1
181
+ );
182
+ }
183
+
184
+ /** Return a single attribute component with 0 as the missing component fallback. */
185
+ function getComponent(
186
+ attribute: MeshAttribute,
187
+ vertexIndex: number,
188
+ componentIndex: number
189
+ ): number {
190
+ return attribute.value[vertexIndex * attribute.size + componentIndex] || 0;
191
+ }
192
+
193
+ /** Return one color component as an unsigned byte. */
194
+ function getColorByte(
195
+ attribute: MeshAttribute,
196
+ vertexIndex: number,
197
+ componentIndex: number
198
+ ): number {
199
+ const value = getComponent(attribute, vertexIndex, componentIndex);
200
+ const byteValue = attribute.normalized || value <= 1 ? value * 255 : value;
201
+ return Math.max(0, Math.min(255, Math.round(byteValue)));
202
+ }
203
+
204
+ /** Return triangle indices for indexed or sequential triangle-list meshes. */
205
+ function getTriangleIndices(mesh: Mesh, vertexCount: number): number[] {
206
+ if (mesh.indices?.value?.length) {
207
+ return Array.from(mesh.indices.value);
208
+ }
209
+
210
+ if (mesh.mode !== 4 && mesh.topology !== 'triangle-list') {
211
+ return [];
212
+ }
213
+
214
+ const triangleIndices: number[] = [];
215
+ for (let vertexIndex = 0; vertexIndex + 2 < vertexCount; vertexIndex += 3) {
216
+ triangleIndices.push(vertexIndex, vertexIndex + 1, vertexIndex + 2);
217
+ }
218
+ return triangleIndices;
219
+ }
@@ -0,0 +1,6 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export type {PLYLoaderOptions} from './ply-loader-types';
6
+ export {PLYLoader} from './ply-loader-types';
@@ -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 {convertMeshToArrowTableWrapper} from '@loaders.gl/core/schema-utils';
8
+ import type {PLYMesh} from '../lib/ply-types';
9
+ import type {PLYLoaderOptions} from '../ply-loader-types';
10
+ import {PLYColumnLoader} from '../ply-loader';
11
+
12
+ createLoaderWorker({
13
+ ...PLYColumnLoader,
14
+ /** Always returns columnar data; legacy mesh conversion runs on the caller. */
15
+ parse(input, options) {
16
+ return PLYColumnLoader.parse(input, {
17
+ ...options,
18
+ ply: {...options?.ply, shape: 'arrow'}
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' as const}};
27
+ for await (const batch of PLYColumnLoader.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
+ ...convertMeshToArrowTableWrapper(mesh),
34
+ loader: mesh.loader,
35
+ loaderData: mesh.loaderData
36
+ } as MeshArrowTable);
37
+ }
38
+ }
39
+ }
40
+ });
@@ -0,0 +1 @@
1
+ export * from './ply/ply-loader-types.js';
@@ -0,0 +1 @@
1
+ export * from './ply/ply-loader.js';
@@ -0,0 +1 @@
1
+ export * from './ply/ply-writer.js';
@@ -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.